From 05af7d57aab0174c720f1dd71e87d39f1197bfa1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 1 Sep 2025 13:51:45 +0000 Subject: [PATCH 001/142] chore: sync repo --- .devcontainer/Dockerfile | 23 + .devcontainer/devcontainer.json | 20 + .gitattributes | 5 + .github/workflows/ci.yml | 85 + .github/workflows/test.yml | 22 - .gitignore | 15 +- .stats.yml | 4 + DEVELOPMENT.md | 21 - LICENSE | 222 +- README.md | 1455 +-- SECURITY.md | 27 + build.gradle.kts | 49 + buildSrc/build.gradle.kts | 12 + .../src/main/kotlin/image-kit.java.gradle.kts | 136 + .../main/kotlin/image-kit.kotlin.gradle.kts | 106 + .../main/kotlin/image-kit.publish.gradle.kts | 61 + gradle.properties | 18 + gradle/wrapper/gradle-wrapper.jar | Bin 55190 -> 43583 bytes gradle/wrapper/gradle-wrapper.properties | 7 +- gradlew | 303 +- gradlew.bat | 178 +- image-kit-java-client-okhttp/build.gradle.kts | 14 + .../api/client/okhttp/ImageKitOkHttpClient.kt | 327 + .../okhttp/ImageKitOkHttpClientAsync.kt | 327 + .../api/client/okhttp/OkHttpClient.kt | 246 + image-kit-java-core/build.gradle.kts | 41 + .../com/imagekit/api/client/ImageKitClient.kt | 107 + .../api/client/ImageKitClientAsync.kt | 111 + .../api/client/ImageKitClientAsyncImpl.kt | 154 + .../imagekit/api/client/ImageKitClientImpl.kt | 144 + .../com/imagekit/api/core/BaseDeserializer.kt | 44 + .../com/imagekit/api/core/BaseSerializer.kt | 6 + .../kotlin/com/imagekit/api/core/Check.kt | 96 + .../com/imagekit/api/core/ClientOptions.kt | 496 ++ .../com/imagekit/api/core/ObjectMappers.kt | 167 + .../kotlin/com/imagekit/api/core/Params.kt | 16 + .../com/imagekit/api/core/PhantomReachable.kt | 56 + .../core/PhantomReachableExecutorService.kt | 58 + .../com/imagekit/api/core/PrepareRequest.kt | 24 + .../com/imagekit/api/core/Properties.kt | 42 + .../com/imagekit/api/core/RequestOptions.kt | 46 + .../kotlin/com/imagekit/api/core/Timeout.kt | 171 + .../kotlin/com/imagekit/api/core/Utils.kt | 115 + .../kotlin/com/imagekit/api/core/Values.kt | 723 ++ .../api/core/handlers/EmptyHandler.kt | 12 + .../api/core/handlers/ErrorHandler.kt | 84 + .../imagekit/api/core/handlers/JsonHandler.kt | 20 + .../api/core/handlers/StringHandler.kt | 13 + .../api/core/http/AsyncStreamResponse.kt | 157 + .../com/imagekit/api/core/http/Headers.kt | 115 + .../com/imagekit/api/core/http/HttpClient.kt | 26 + .../com/imagekit/api/core/http/HttpMethod.kt | 13 + .../com/imagekit/api/core/http/HttpRequest.kt | 146 + .../api/core/http/HttpRequestBodies.kt | 128 + .../imagekit/api/core/http/HttpRequestBody.kt | 25 + .../imagekit/api/core/http/HttpResponse.kt | 22 + .../imagekit/api/core/http/HttpResponseFor.kt | 25 + ...ntomReachableClosingAsyncStreamResponse.kt | 56 + .../http/PhantomReachableClosingHttpClient.kt | 26 + .../PhantomReachableClosingStreamResponse.kt | 21 + .../com/imagekit/api/core/http/QueryParams.kt | 129 + .../api/core/http/RetryingHttpClient.kt | 288 + .../imagekit/api/core/http/StreamResponse.kt | 19 + .../api/errors/BadRequestException.kt | 80 + .../imagekit/api/errors/ImageKitException.kt | 5 + .../errors/ImageKitInvalidDataException.kt | 5 + .../api/errors/ImageKitIoException.kt | 5 + .../api/errors/ImageKitRetryableException.kt | 14 + .../api/errors/ImageKitServiceException.kt | 17 + .../api/errors/InternalServerException.kt | 91 + .../imagekit/api/errors/NotFoundException.kt | 76 + .../api/errors/PermissionDeniedException.kt | 80 + .../imagekit/api/errors/RateLimitException.kt | 80 + .../api/errors/UnauthorizedException.kt | 80 + .../errors/UnexpectedStatusCodeException.kt | 92 + .../errors/UnprocessableEntityException.kt | 80 + .../com/imagekit/api/models/BaseOverlay.kt | 189 + .../com/imagekit/api/models/ImageOverlay.kt | 534 ++ .../kotlin/com/imagekit/api/models/Overlay.kt | 267 + .../imagekit/api/models/OverlayPosition.kt | 785 ++ .../com/imagekit/api/models/OverlayTiming.kt | 801 ++ .../imagekit/api/models/SolidColorOverlay.kt | 359 + .../models/SolidColorOverlayTransformation.kt | 1112 +++ .../com/imagekit/api/models/SrcOptions.kt | 618 ++ .../api/models/StreamingResolution.kt | 168 + .../imagekit/api/models/SubtitleOverlay.kt | 528 ++ .../models/SubtitleOverlayTransformation.kt | 627 ++ .../com/imagekit/api/models/TextOverlay.kt | 532 ++ .../api/models/TextOverlayTransformation.kt | 2061 +++++ .../com/imagekit/api/models/Transformation.kt | 7830 +++++++++++++++++ .../api/models/TransformationPosition.kt | 140 + .../com/imagekit/api/models/VideoOverlay.kt | 530 ++ .../accounts/origins/OriginCreateParams.kt | 239 + .../accounts/origins/OriginDeleteParams.kt | 239 + .../accounts/origins/OriginGetParams.kt | 196 + .../accounts/origins/OriginListParams.kt | 173 + .../models/accounts/origins/OriginRequest.kt | 3908 ++++++++ .../models/accounts/origins/OriginResponse.kt | 3789 ++++++++ .../accounts/origins/OriginUpdateParams.kt | 270 + .../urlendpoints/UrlEndpointCreateParams.kt | 209 + .../urlendpoints/UrlEndpointDeleteParams.kt | 241 + .../urlendpoints/UrlEndpointGetParams.kt | 197 + .../urlendpoints/UrlEndpointListParams.kt | 173 + .../urlendpoints/UrlEndpointRequest.kt | 751 ++ .../urlendpoints/UrlEndpointResponse.kt | 825 ++ .../urlendpoints/UrlEndpointUpdateParams.kt | 237 + .../models/accounts/usage/UsageGetParams.kt | 235 + .../models/accounts/usage/UsageGetResponse.kt | 359 + .../api/models/assets/AssetListParams.kt | 865 ++ .../api/models/assets/AssetListResponse.kt | 187 + .../models/beta/v2/files/FileUploadParams.kt | 4828 ++++++++++ .../beta/v2/files/FileUploadResponse.kt | 2620 ++++++ .../invalidation/InvalidationCreateParams.kt | 415 + .../InvalidationCreateResponse.kt | 162 + .../invalidation/InvalidationGetParams.kt | 193 + .../invalidation/InvalidationGetResponse.kt | 285 + .../CustomMetadataField.kt | 1986 +++++ .../CustomMetadataFieldCreateParams.kt | 2288 +++++ .../CustomMetadataFieldDeleteParams.kt | 238 + .../CustomMetadataFieldDeleteResponse.kt | 120 + .../CustomMetadataFieldListParams.kt | 212 + .../CustomMetadataFieldUpdateParams.kt | 2009 +++++ .../com/imagekit/api/models/files/File.kt | 1658 ++++ .../api/models/files/FileCopyParams.kt | 602 ++ .../api/models/files/FileCopyResponse.kt | 112 + .../api/models/files/FileDeleteParams.kt | 234 + .../api/models/files/FileGetParams.kt | 189 + .../api/models/files/FileMoveParams.kt | 512 ++ .../api/models/files/FileMoveResponse.kt | 112 + .../api/models/files/FileRenameParams.kt | 649 ++ .../api/models/files/FileRenameResponse.kt | 166 + .../api/models/files/FileUpdateParams.kt | 2759 ++++++ .../api/models/files/FileUpdateResponse.kt | 1934 ++++ .../api/models/files/FileUploadParams.kt | 5094 +++++++++++ .../api/models/files/FileUploadResponse.kt | 2619 ++++++ .../com/imagekit/api/models/files/Folder.kt | 478 + .../com/imagekit/api/models/files/Metadata.kt | 3574 ++++++++ .../models/files/bulk/BulkAddTagsParams.kt | 533 ++ .../models/files/bulk/BulkAddTagsResponse.kt | 189 + .../api/models/files/bulk/BulkDeleteParams.kt | 447 + .../models/files/bulk/BulkDeleteResponse.kt | 189 + .../files/bulk/BulkRemoveAiTagsParams.kt | 538 ++ .../files/bulk/BulkRemoveAiTagsResponse.kt | 189 + .../models/files/bulk/BulkRemoveTagsParams.kt | 534 ++ .../files/bulk/BulkRemoveTagsResponse.kt | 189 + .../metadata/MetadataGetFromUrlParams.kt | 203 + .../files/metadata/MetadataGetParams.kt | 195 + .../files/versions/VersionDeleteParams.kt | 262 + .../files/versions/VersionDeleteResponse.kt | 113 + .../models/files/versions/VersionGetParams.kt | 217 + .../files/versions/VersionListParams.kt | 189 + .../files/versions/VersionRestoreParams.kt | 258 + .../api/models/folders/FolderCopyParams.kt | 605 ++ .../api/models/folders/FolderCopyResponse.kt | 172 + .../api/models/folders/FolderCreateParams.kt | 550 ++ .../models/folders/FolderCreateResponse.kt | 113 + .../api/models/folders/FolderDeleteParams.kt | 421 + .../models/folders/FolderDeleteResponse.kt | 113 + .../api/models/folders/FolderMoveParams.kt | 517 ++ .../api/models/folders/FolderMoveResponse.kt | 172 + .../api/models/folders/FolderRenameParams.kt | 646 ++ .../models/folders/FolderRenameResponse.kt | 172 + .../api/models/folders/job/JobGetParams.kt | 189 + .../api/models/folders/job/JobGetResponse.kt | 533 ++ .../webhooks/UnsafeUnwrapWebhookEvent.kt | 560 ++ .../api/models/webhooks/UnwrapWebhookEvent.kt | 549 ++ .../webhooks/UploadPostTransformErrorEvent.kt | 1691 ++++ .../UploadPostTransformSuccessEvent.kt | 1290 +++ .../webhooks/UploadPreTransformErrorEvent.kt | 1101 +++ .../UploadPreTransformSuccessEvent.kt | 3219 +++++++ .../VideoTransformationAcceptedEvent.kt | 2303 +++++ .../webhooks/VideoTransformationErrorEvent.kt | 2652 ++++++ .../webhooks/VideoTransformationReadyEvent.kt | 3080 +++++++ .../api/services/async/AccountServiceAsync.kt | 51 + .../services/async/AccountServiceAsyncImpl.kt | 68 + .../api/services/async/AssetServiceAsync.kt | 87 + .../services/async/AssetServiceAsyncImpl.kt | 84 + .../api/services/async/BetaServiceAsync.kt | 37 + .../services/async/BetaServiceAsyncImpl.kt | 42 + .../api/services/async/CacheServiceAsync.kt | 39 + .../services/async/CacheServiceAsyncImpl.kt | 44 + .../async/CustomMetadataFieldServiceAsync.kt | 280 + .../CustomMetadataFieldServiceAsyncImpl.kt | 216 + .../api/services/async/FileServiceAsync.kt | 420 + .../services/async/FileServiceAsyncImpl.kt | 368 + .../api/services/async/FolderServiceAsync.kt | 195 + .../services/async/FolderServiceAsyncImpl.kt | 258 + .../api/services/async/WebhookServiceAsync.kt | 53 + .../services/async/WebhookServiceAsyncImpl.kt | 50 + .../async/accounts/OriginServiceAsync.kt | 306 + .../async/accounts/OriginServiceAsyncImpl.kt | 245 + .../async/accounts/UrlEndpointServiceAsync.kt | 319 + .../accounts/UrlEndpointServiceAsyncImpl.kt | 245 + .../async/accounts/UsageServiceAsync.kt | 66 + .../async/accounts/UsageServiceAsyncImpl.kt | 84 + .../api/services/async/beta/V2ServiceAsync.kt | 37 + .../services/async/beta/V2ServiceAsyncImpl.kt | 42 + .../async/beta/v2/FileServiceAsync.kt | 83 + .../async/beta/v2/FileServiceAsyncImpl.kt | 89 + .../async/cache/InvalidationServiceAsync.kt | 148 + .../cache/InvalidationServiceAsyncImpl.kt | 130 + .../services/async/files/BulkServiceAsync.kt | 160 + .../async/files/BulkServiceAsyncImpl.kt | 206 + .../async/files/MetadataServiceAsync.kt | 142 + .../async/files/MetadataServiceAsyncImpl.kt | 126 + .../async/files/VersionServiceAsync.kt | 271 + .../async/files/VersionServiceAsyncImpl.kt | 233 + .../services/async/folders/JobServiceAsync.kt | 107 + .../async/folders/JobServiceAsyncImpl.kt | 89 + .../api/services/blocking/AccountService.kt | 47 + .../services/blocking/AccountServiceImpl.kt | 66 + .../api/services/blocking/AssetService.kt | 84 + .../api/services/blocking/AssetServiceImpl.kt | 80 + .../api/services/blocking/BetaService.kt | 37 + .../api/services/blocking/BetaServiceImpl.kt | 41 + .../api/services/blocking/CacheService.kt | 37 + .../api/services/blocking/CacheServiceImpl.kt | 42 + .../blocking/CustomMetadataFieldService.kt | 279 + .../CustomMetadataFieldServiceImpl.kt | 200 + .../api/services/blocking/FileService.kt | 409 + .../api/services/blocking/FileServiceImpl.kt | 334 + .../api/services/blocking/FolderService.kt | 193 + .../services/blocking/FolderServiceImpl.kt | 242 + .../api/services/blocking/WebhookService.kt | 49 + .../services/blocking/WebhookServiceImpl.kt | 58 + .../blocking/accounts/OriginService.kt | 295 + .../blocking/accounts/OriginServiceImpl.kt | 224 + .../blocking/accounts/UrlEndpointService.kt | 314 + .../accounts/UrlEndpointServiceImpl.kt | 227 + .../blocking/accounts/UsageService.kt | 65 + .../blocking/accounts/UsageServiceImpl.kt | 77 + .../api/services/blocking/beta/V2Service.kt | 37 + .../services/blocking/beta/V2ServiceImpl.kt | 41 + .../services/blocking/beta/v2/FileService.kt | 82 + .../blocking/beta/v2/FileServiceImpl.kt | 84 + .../blocking/cache/InvalidationService.kt | 147 + .../blocking/cache/InvalidationServiceImpl.kt | 123 + .../services/blocking/files/BulkService.kt | 160 + .../blocking/files/BulkServiceImpl.kt | 192 + .../blocking/files/MetadataService.kt | 138 + .../blocking/files/MetadataServiceImpl.kt | 116 + .../services/blocking/files/VersionService.kt | 261 + .../blocking/files/VersionServiceImpl.kt | 211 + .../services/blocking/folders/JobService.kt | 104 + .../blocking/folders/JobServiceImpl.kt | 81 + .../META-INF/proguard/image-kit-java-core.pro | 32 + .../com/imagekit/api/TestServerExtension.kt | 62 + .../imagekit/api/core/ClientOptionsTest.kt | 38 + .../imagekit/api/core/ObjectMappersTest.kt | 102 + .../imagekit/api/core/PhantomReachableTest.kt | 27 + .../kotlin/com/imagekit/api/core/UtilsTest.kt | 33 + .../com/imagekit/api/core/ValuesTest.kt | 144 + .../api/core/http/AsyncStreamResponseTest.kt | 268 + .../com/imagekit/api/core/http/HeadersTest.kt | 242 + .../imagekit/api/core/http/QueryParamsTest.kt | 180 + .../api/core/http/RetryingHttpClientTest.kt | 351 + .../imagekit/api/models/BaseOverlayTest.kt | 57 + .../imagekit/api/models/ImageOverlayTest.kt | 67 + .../api/models/OverlayPositionTest.kt | 36 + .../com/imagekit/api/models/OverlayTest.kt | 361 + .../imagekit/api/models/OverlayTimingTest.kt | 34 + .../api/models/SolidColorOverlayTest.kt | 92 + .../SolidColorOverlayTransformationTest.kt | 58 + .../com/imagekit/api/models/SrcOptionsTest.kt | 234 + .../api/models/SubtitleOverlayTest.kt | 98 + .../SubtitleOverlayTransformationTest.kt | 58 + .../imagekit/api/models/TextOverlayTest.kt | 116 + .../models/TextOverlayTransformationTest.kt | 81 + .../imagekit/api/models/TransformationTest.kt | 193 + .../imagekit/api/models/VideoOverlayTest.kt | 67 + .../origins/OriginCreateParamsTest.kt | 90 + .../origins/OriginDeleteParamsTest.kt | 23 + .../accounts/origins/OriginGetParamsTest.kt | 23 + .../accounts/origins/OriginListParamsTest.kt | 13 + .../accounts/origins/OriginRequestTest.kt | 428 + .../accounts/origins/OriginResponseTest.kt | 420 + .../origins/OriginUpdateParamsTest.kt | 113 + .../UrlEndpointCreateParamsTest.kt | 77 + .../UrlEndpointDeleteParamsTest.kt | 23 + .../urlendpoints/UrlEndpointGetParamsTest.kt | 23 + .../urlendpoints/UrlEndpointListParamsTest.kt | 13 + .../urlendpoints/UrlEndpointRequestTest.kt | 63 + .../urlendpoints/UrlEndpointResponseTest.kt | 59 + .../UrlEndpointUpdateParamsTest.kt | 95 + .../accounts/usage/UsageGetParamsTest.kt | 38 + .../accounts/usage/UsageGetResponseTest.kt | 50 + .../api/models/assets/AssetListParamsTest.kt | 61 + .../models/assets/AssetListResponseTest.kt | 165 + .../beta/v2/files/FileUploadParamsTest.kt | 296 + .../beta/v2/files/FileUploadResponseTest.kt | 448 + .../InvalidationCreateParamsTest.kt | 29 + .../InvalidationCreateResponseTest.kt | 34 + .../invalidation/InvalidationGetParamsTest.kt | 23 + .../InvalidationGetResponseTest.kt | 39 + .../CustomMetadataFieldCreateParamsTest.kt | 126 + .../CustomMetadataFieldDeleteParamsTest.kt | 23 + .../CustomMetadataFieldDeleteResponseTest.kt | 31 + .../CustomMetadataFieldListParamsTest.kt | 34 + .../CustomMetadataFieldTest.kt | 108 + .../CustomMetadataFieldUpdateParamsTest.kt | 113 + .../api/models/files/FileCopyParamsTest.kt | 48 + .../api/models/files/FileCopyResponseTest.kt | 30 + .../api/models/files/FileDeleteParamsTest.kt | 23 + .../api/models/files/FileGetParamsTest.kt | 23 + .../api/models/files/FileMoveParamsTest.kt | 31 + .../api/models/files/FileMoveResponseTest.kt | 30 + .../api/models/files/FileRenameParamsTest.kt | 48 + .../models/files/FileRenameResponseTest.kt | 34 + .../com/imagekit/api/models/files/FileTest.kt | 122 + .../api/models/files/FileUpdateParamsTest.kt | 245 + .../models/files/FileUpdateResponseTest.kt | 160 + .../api/models/files/FileUploadParamsTest.kt | 305 + .../models/files/FileUploadResponseTest.kt | 447 + .../imagekit/api/models/files/FolderTest.kt | 51 + .../imagekit/api/models/files/MetadataTest.kt | 289 + .../files/bulk/BulkAddTagsParamsTest.kt | 34 + .../files/bulk/BulkAddTagsResponseTest.kt | 36 + .../models/files/bulk/BulkDeleteParamsTest.kt | 31 + .../files/bulk/BulkDeleteResponseTest.kt | 36 + .../files/bulk/BulkRemoveAiTagsParamsTest.kt | 34 + .../bulk/BulkRemoveAiTagsResponseTest.kt | 36 + .../files/bulk/BulkRemoveTagsParamsTest.kt | 34 + .../files/bulk/BulkRemoveTagsResponseTest.kt | 36 + .../metadata/MetadataGetFromUrlParamsTest.kt | 25 + .../files/metadata/MetadataGetParamsTest.kt | 23 + .../files/versions/VersionDeleteParamsTest.kt | 24 + .../versions/VersionDeleteResponseTest.kt | 30 + .../files/versions/VersionGetParamsTest.kt | 24 + .../files/versions/VersionListParamsTest.kt | 23 + .../versions/VersionRestoreParamsTest.kt | 24 + .../models/folders/FolderCopyParamsTest.kt | 48 + .../models/folders/FolderCopyResponseTest.kt | 32 + .../models/folders/FolderCreateParamsTest.kt | 31 + .../folders/FolderCreateResponseTest.kt | 30 + .../models/folders/FolderDeleteParamsTest.kt | 23 + .../folders/FolderDeleteResponseTest.kt | 30 + .../models/folders/FolderMoveParamsTest.kt | 31 + .../models/folders/FolderMoveResponseTest.kt | 32 + .../models/folders/FolderRenameParamsTest.kt | 48 + .../folders/FolderRenameResponseTest.kt | 32 + .../models/folders/job/JobGetParamsTest.kt | 23 + .../models/folders/job/JobGetResponseTest.kt | 47 + .../webhooks/UnsafeUnwrapWebhookEventTest.kt | 1225 +++ .../models/webhooks/UnwrapWebhookEventTest.kt | 1221 +++ .../UploadPostTransformErrorEventTest.kt | 152 + .../UploadPostTransformSuccessEventTest.kt | 120 + .../UploadPreTransformErrorEventTest.kt | 108 + .../UploadPreTransformSuccessEventTest.kt | 536 ++ .../VideoTransformationAcceptedEventTest.kt | 210 + .../VideoTransformationErrorEventTest.kt | 238 + .../VideoTransformationReadyEventTest.kt | 275 + .../api/services/ErrorHandlingTest.kt | 1762 ++++ .../api/services/ServiceParamsTest.kt | 136 + .../services/async/AssetServiceAsyncTest.kt | 42 + .../CustomMetadataFieldServiceAsyncTest.kt | 160 + .../services/async/FileServiceAsyncTest.kt | 313 + .../services/async/FolderServiceAsyncTest.kt | 132 + .../async/accounts/OriginServiceAsyncTest.kt | 131 + .../accounts/UrlEndpointServiceAsyncTest.kt | 133 + .../async/accounts/UsageServiceAsyncTest.kt | 38 + .../async/beta/v2/FileServiceAsyncTest.kt | 110 + .../cache/InvalidationServiceAsyncTest.kt | 53 + .../async/files/BulkServiceAsyncTest.kt | 112 + .../async/files/MetadataServiceAsyncTest.kt | 51 + .../async/files/VersionServiceAsyncTest.kt | 93 + .../async/folders/JobServiceAsyncTest.kt | 30 + .../api/services/blocking/AssetServiceTest.kt | 41 + .../CustomMetadataFieldServiceTest.kt | 156 + .../api/services/blocking/FileServiceTest.kt | 305 + .../services/blocking/FolderServiceTest.kt | 127 + .../blocking/accounts/OriginServiceTest.kt | 125 + .../accounts/UrlEndpointServiceTest.kt | 127 + .../blocking/accounts/UsageServiceTest.kt | 37 + .../blocking/beta/v2/FileServiceTest.kt | 109 + .../blocking/cache/InvalidationServiceTest.kt | 51 + .../blocking/files/BulkServiceTest.kt | 108 + .../blocking/files/MetadataServiceTest.kt | 49 + .../blocking/files/VersionServiceTest.kt | 89 + .../blocking/folders/JobServiceTest.kt | 29 + image-kit-java-example/build.gradle.kts | 28 + image-kit-java-lib/.keep | 4 + image-kit-java-proguard-test/build.gradle.kts | 101 + .../api/proguard/ProGuardCompatibilityTest.kt | 168 + image-kit-java-proguard-test/test.pro | 9 + image-kit-java/build.gradle.kts | 29 + imagekit-sdk/build.gradle | 28 - .../main/java/io/imagekit/sdk/ImageKit.java | 437 - .../io/imagekit/sdk/config/Configuration.java | 63 - .../imagekit/sdk/constants/Transformer.java | 86 - .../io/imagekit/sdk/constants/Version.java | 5 - .../sdk/exceptions/BadRequestException.java | 32 - .../sdk/exceptions/ConflictException.java | 24 - .../sdk/exceptions/ForbiddenException.java | 32 - .../exceptions/InternalServerException.java | 32 - .../sdk/exceptions/NotFoundException.java | 32 - .../exceptions/PartialSuccessException.java | 32 - .../exceptions/TooManyRequestsException.java | 32 - .../sdk/exceptions/UnauthorizedException.java | 32 - .../sdk/exceptions/UnknownException.java | 36 - .../io/imagekit/sdk/models/AITagsRequest.java | 29 - .../java/io/imagekit/sdk/models/BaseFile.java | 253 - .../imagekit/sdk/models/CopyFileRequest.java | 37 - .../sdk/models/CopyFolderRequest.java | 37 - .../sdk/models/CreateFolderRequest.java | 27 - .../CustomMetaDataFieldCreateRequest.java | 41 - .../CustomMetaDataFieldSchemaObject.java | 94 - .../CustomMetaDataFieldUpdateRequest.java | 41 - .../sdk/models/CustomMetaDataTypeEnum.java | 5 - .../sdk/models/DeleteFileVersionRequest.java | 27 - .../sdk/models/DeleteFolderRequest.java | 18 - .../sdk/models/FileCreateRequest.java | 172 - .../sdk/models/FileUpdateRequest.java | 93 - .../sdk/models/GetFileListRequest.java | 92 - .../java/io/imagekit/sdk/models/MetaData.java | 731 -- .../imagekit/sdk/models/MoveFileRequest.java | 27 - .../sdk/models/MoveFolderRequest.java | 28 - .../sdk/models/RenameFileRequest.java | 37 - .../imagekit/sdk/models/ResponseMetaData.java | 63 - .../io/imagekit/sdk/models/TagsRequest.java | 35 - .../imagekit/sdk/models/results/Result.java | 193 - .../models/results/ResultBulkJobStatus.java | 48 - .../sdk/models/results/ResultCache.java | 67 - .../sdk/models/results/ResultCacheStatus.java | 67 - .../results/ResultCustomMetaDataField.java | 62 - .../ResultCustomMetaDataFieldList.java | 33 - .../sdk/models/results/ResultEmptyBlock.java | 20 - .../sdk/models/results/ResultException.java | 42 - .../sdk/models/results/ResultFileDelete.java | 81 - .../results/ResultFileVersionDetails.java | 221 - .../models/results/ResultFileVersions.java | 33 - .../sdk/models/results/ResultList.java | 73 - .../sdk/models/results/ResultMetaData.java | 68 - .../sdk/models/results/ResultNoContent.java | 20 - .../models/results/ResultOfFolderActions.java | 29 - .../sdk/models/results/ResultRenameFile.java | 30 - .../sdk/models/results/ResultTags.java | 32 - .../io/imagekit/sdk/tasks/Calculation.java | 49 - .../imagekit/sdk/tasks/MultipartBuilder.java | 99 - .../io/imagekit/sdk/tasks/QueryMaker.java | 20 - .../io/imagekit/sdk/tasks/RestClient.java | 964 -- .../java/io/imagekit/sdk/tasks/UrlGen.java | 212 - .../java/io/imagekit/sdk/utils/Utils.java | 185 - .../io/imagekit/sdk/FileOperationTest.java | 255 - .../io/imagekit/sdk/FolderOperationTest.java | 227 - .../test/java/io/imagekit/sdk/GetUrlTest.java | 491 -- .../java/io/imagekit/sdk/ImageKitTest.java | 82 - .../java/io/imagekit/sdk/PurgeCacheTest.java | 98 - .../test/java/io/imagekit/sdk/UploadTest.java | 251 - .../sdk/config/ConfigurationTest.java | 44 - .../sdk/manage/CustomMetaDataFieldTest.java | 477 - .../java/io/imagekit/sdk/manage/FileTest.java | 589 -- .../imagekit/sdk/manage/FileVersionTest.java | 267 - .../java/io/imagekit/sdk/manage/TagsTest.java | 194 - .../imagekit/sdk/tasks/CalculationTest.java | 104 - .../sdk/tasks/MultipartBuilderTest.java | 239 - .../io/imagekit/sdk/tasks/QueryMakerTest.java | 30 - .../io/imagekit/sdk/tasks/UrlGenTest.java | 32 - .../java/io/imagekit/sdk/utils/UtilsTest.java | 90 - .../src/test/resources/config.properties | 6 - imagekit-sdk/src/test/resources/sample1.jpg | Bin 51085 -> 0 bytes scripts/build | 8 + scripts/format | 21 + scripts/java-format | 7 + scripts/kotlin-format | 7 + scripts/lint | 23 + scripts/mock | 41 + scripts/test | 56 + settings.gradle | 3 - settings.gradle.kts | 14 + 469 files changed, 126892 insertions(+), 10172 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .gitattributes create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/test.yml create mode 100644 .stats.yml delete mode 100644 DEVELOPMENT.md create mode 100644 SECURITY.md create mode 100644 build.gradle.kts create mode 100644 buildSrc/build.gradle.kts create mode 100644 buildSrc/src/main/kotlin/image-kit.java.gradle.kts create mode 100644 buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts create mode 100644 buildSrc/src/main/kotlin/image-kit.publish.gradle.kts create mode 100644 gradle.properties create mode 100644 image-kit-java-client-okhttp/build.gradle.kts create mode 100644 image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt create mode 100644 image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt create mode 100644 image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt create mode 100644 image-kit-java-core/build.gradle.kts create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/BaseDeserializer.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/BaseSerializer.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Check.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ObjectMappers.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Params.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachable.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachableExecutorService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PrepareRequest.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Properties.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/RequestOptions.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Timeout.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Utils.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/EmptyHandler.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/ErrorHandler.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/JsonHandler.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/StringHandler.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/AsyncStreamResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/Headers.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpMethod.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequest.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequestBodies.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequestBody.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpResponseFor.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/PhantomReachableClosingHttpClient.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/PhantomReachableClosingStreamResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/QueryParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/StreamResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/BaseOverlay.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ImageOverlay.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Overlay.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayTiming.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlay.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SrcOptions.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/StreamingResolution.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlay.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlayTransformation.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlay.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TransformationPosition.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VideoOverlay.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginDeleteParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginRequest.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequest.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/AssetListParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/AssetListResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileDeleteParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Folder.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Metadata.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionDeleteParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionDeleteResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionListParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRestoreParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetResponse.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AccountServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AccountServiceAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AssetServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AssetServiceAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BetaServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BetaServiceAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CacheServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CacheServiceAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FolderServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FolderServiceAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/V2ServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/V2ServiceAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BulkServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/VersionServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/folders/JobServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AccountService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AccountServiceImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AssetService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AssetServiceImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BetaService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BetaServiceImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CacheService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CacheServiceImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FolderService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FolderServiceImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookServiceImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UsageService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/V2Service.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/V2ServiceImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/v2/FileService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/cache/InvalidationService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BulkService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BulkServiceImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/VersionService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/VersionServiceImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/folders/JobService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/folders/JobServiceImpl.kt create mode 100644 image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/TestServerExtension.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ObjectMappersTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/core/PhantomReachableTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/core/UtilsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ValuesTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/AsyncStreamResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/HeadersTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/QueryParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayPositionTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTimingTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTransformationTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTransformationTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTransformationTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginDeleteParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginRequestTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequestTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/usage/UsageGetParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileCopyParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileCopyResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileDeleteParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileMoveParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileMoveResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRenameParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRenameResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FolderTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/MetadataTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionDeleteParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionDeleteResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRestoreParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCopyParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCopyResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCreateParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCreateResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderDeleteParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderDeleteResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderMoveParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderMoveResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderRenameParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderRenameResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/job/JobGetParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/job/JobGetResponseTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEventTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEventTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEventTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt create mode 100644 image-kit-java-example/build.gradle.kts create mode 100644 image-kit-java-lib/.keep create mode 100644 image-kit-java-proguard-test/build.gradle.kts create mode 100644 image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt create mode 100644 image-kit-java-proguard-test/test.pro create mode 100644 image-kit-java/build.gradle.kts delete mode 100644 imagekit-sdk/build.gradle delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/ImageKit.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/config/Configuration.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/constants/Transformer.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/constants/Version.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/BadRequestException.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/ConflictException.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/ForbiddenException.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/InternalServerException.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/NotFoundException.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/PartialSuccessException.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/TooManyRequestsException.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/UnauthorizedException.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/UnknownException.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/AITagsRequest.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/BaseFile.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/CopyFileRequest.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/CopyFolderRequest.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/CreateFolderRequest.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/CustomMetaDataFieldCreateRequest.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/CustomMetaDataFieldSchemaObject.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/CustomMetaDataFieldUpdateRequest.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/CustomMetaDataTypeEnum.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/DeleteFileVersionRequest.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/DeleteFolderRequest.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/FileCreateRequest.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/FileUpdateRequest.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/GetFileListRequest.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/MetaData.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/MoveFileRequest.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/MoveFolderRequest.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/RenameFileRequest.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/ResponseMetaData.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/TagsRequest.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/Result.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultBulkJobStatus.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultCache.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultCacheStatus.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultCustomMetaDataField.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultCustomMetaDataFieldList.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultEmptyBlock.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultException.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultFileDelete.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultFileVersionDetails.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultFileVersions.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultList.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultMetaData.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultNoContent.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultOfFolderActions.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultRenameFile.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultTags.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/tasks/Calculation.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/tasks/MultipartBuilder.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/tasks/QueryMaker.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/tasks/RestClient.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/tasks/UrlGen.java delete mode 100644 imagekit-sdk/src/main/java/io/imagekit/sdk/utils/Utils.java delete mode 100644 imagekit-sdk/src/test/java/io/imagekit/sdk/FileOperationTest.java delete mode 100644 imagekit-sdk/src/test/java/io/imagekit/sdk/FolderOperationTest.java delete mode 100644 imagekit-sdk/src/test/java/io/imagekit/sdk/GetUrlTest.java delete mode 100644 imagekit-sdk/src/test/java/io/imagekit/sdk/ImageKitTest.java delete mode 100644 imagekit-sdk/src/test/java/io/imagekit/sdk/PurgeCacheTest.java delete mode 100644 imagekit-sdk/src/test/java/io/imagekit/sdk/UploadTest.java delete mode 100644 imagekit-sdk/src/test/java/io/imagekit/sdk/config/ConfigurationTest.java delete mode 100644 imagekit-sdk/src/test/java/io/imagekit/sdk/manage/CustomMetaDataFieldTest.java delete mode 100644 imagekit-sdk/src/test/java/io/imagekit/sdk/manage/FileTest.java delete mode 100644 imagekit-sdk/src/test/java/io/imagekit/sdk/manage/FileVersionTest.java delete mode 100644 imagekit-sdk/src/test/java/io/imagekit/sdk/manage/TagsTest.java delete mode 100644 imagekit-sdk/src/test/java/io/imagekit/sdk/tasks/CalculationTest.java delete mode 100644 imagekit-sdk/src/test/java/io/imagekit/sdk/tasks/MultipartBuilderTest.java delete mode 100644 imagekit-sdk/src/test/java/io/imagekit/sdk/tasks/QueryMakerTest.java delete mode 100644 imagekit-sdk/src/test/java/io/imagekit/sdk/tasks/UrlGenTest.java delete mode 100644 imagekit-sdk/src/test/java/io/imagekit/sdk/utils/UtilsTest.java delete mode 100644 imagekit-sdk/src/test/resources/config.properties delete mode 100644 imagekit-sdk/src/test/resources/sample1.jpg create mode 100755 scripts/build create mode 100755 scripts/format create mode 100755 scripts/java-format create mode 100755 scripts/kotlin-format create mode 100755 scripts/lint create mode 100755 scripts/mock create mode 100755 scripts/test delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..bd8e2619 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,23 @@ +# syntax=docker/dockerfile:1 +FROM debian:bookworm-slim + +RUN apt-get update && apt-get install -y --no-install-recommends \ + libxkbcommon0 \ + ca-certificates \ + ca-certificates-java \ + make \ + curl \ + git \ + openjdk-17-jdk-headless \ + unzip \ + libc++1 \ + vim \ + && apt-get clean autoclean + +# Ensure UTF-8 encoding +ENV LANG=C.UTF-8 +ENV LC_ALL=C.UTF-8 + +WORKDIR /workspace + +COPY . /workspace diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..d55fc4d6 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,20 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/debian +{ + "name": "Debian", + "build": { + "dockerfile": "Dockerfile" + } + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..022b8414 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# These are explicitly windows files and should use crlf +*.bat text eol=crlf diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..02410e79 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,85 @@ +name: CI +on: + push: + branches-ignore: + - 'generated' + - 'codegen/**' + - 'integrated/**' + - 'stl-preview-head/**' + - 'stl-preview-base/**' + pull_request: + branches-ignore: + - 'stl-preview-head/**' + - 'stl-preview-base/**' + +jobs: + lint: + timeout-minutes: 15 + name: lint + runs-on: ${{ github.repository == 'stainless-sdks/imagekit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + + steps: + - uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: | + 8 + 21 + cache: gradle + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Run lints + run: ./scripts/lint + + build: + timeout-minutes: 15 + name: build + runs-on: ${{ github.repository == 'stainless-sdks/imagekit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + + steps: + - uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: | + 8 + 21 + cache: gradle + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Build SDK + run: ./scripts/build + + test: + timeout-minutes: 15 + name: test + runs-on: ${{ github.repository == 'stainless-sdks/imagekit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + steps: + - uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: | + 8 + 21 + cache: gradle + + - name: Set up Gradle + uses: gradle/gradle-build-action@v2 + + - name: Run tests + run: ./scripts/test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index b1a3bc8e..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,22 +0,0 @@ -# This workflow will build a Java project with Gradle -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle - -name: Java CI - -on: [push, pull_request] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Running Test Cases - run: ./gradlew imagekit-sdk:test diff --git a/.gitignore b/.gitignore index bc211734..b1346e6d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,7 @@ -.idea -out/production +.prism.log .gradle -build -config.properties -.DS_Store -.project -.settings -bin -.classpath +.idea +.kotlin +build/ +codegen.log +kls_database.db diff --git a/.stats.yml b/.stats.yml new file mode 100644 index 00000000..ad85869b --- /dev/null +++ b/.stats.yml @@ -0,0 +1,4 @@ +configured_endpoints: 42 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-3d7da4b8ef2ed30aa32c4fb3e98e498e67402e91aaa5fd4c628fc080bfe82ea1.yml +openapi_spec_hash: aaa50fcbccec6f2cf1165f34bc6ac886 +config_hash: cf9d50fe62973f4e91ef65c147aabcc1 diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md deleted file mode 100644 index f220036c..00000000 --- a/DEVELOPMENT.md +++ /dev/null @@ -1,21 +0,0 @@ -# Development Guide - - -**1. To modify version open `imagekit-sdk/build.gradle` and change value of `version`.** - -**2. Run test cases** -```shell -./gradlew imagekit-sdk:test -``` - -**3. Clean cache of SDK** -```shell -./gradlew imagekit-sdk:clean -``` - -**4. Build SDK jar** -```shell script -./gradlew imagekit-sdk:build -``` -Then you will find `jar` inside `imagekit-sdk/build/libs/` with specific version name. Then you can share `jar` or upload `jar` to any java dependency repository. - diff --git a/LICENSE b/LICENSE index 2d96bbbf..e7a4d160 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,201 @@ -MIT License - -Copyright (c) 2020 Imagekit - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2025 Image Kit + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index c608840c..ee8fe401 100644 --- a/README.md +++ b/README.md @@ -1,1209 +1,698 @@ -# ImageKit Java SDK - -[![Java CI](https://github.com/imagekit-developer/imagekit-java/workflows/Java%20CI/badge.svg)](https://github.com/imagekit-developer/imagekit-java) -[![Release](https://jitpack.io/v/com.github.imagekit-developer/imagekit-java.svg)](https://jitpack.io/#com.github.imagekit-developer/imagekit-java) -[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) -[![Twitter Follow](https://img.shields.io/twitter/follow/imagekitio?label=Follow&style=social)](https://twitter.com/ImagekitIo) - -Java SDK for [ImageKit.io](https://imagekit.io/) that implements the new APIs and interface for performing different file operations. - -ImageKit is complete media storage, optimization, and transformation solution that comes with an [image and video CDN](https://imagekit.io). It can be integrated with your existing infrastructure - storage like AWS S3, web servers, your CDN, and custom domain names, allowing you to deliver optimized images in minutes with minimal code changes. - -Table of contents - - * [Installation](#installation) - * [Initialization](#initialization) - * [Usage](#usage) - * [Versioning](#versioning) - * [URL generation](#url-generation) - * [File upload](#file-upload) - * [File management](#file-management) - * [Utility functions](#utility-functions) - * [Handling errors](#handling-errors) - * [Support](#support) - * [Links](#links) - -## Installation +# Image Kit Java API Library -### Requirements +[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-java)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-java/0.0.1) +[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1) -- Java 1.8 or later +The Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs) from applications written in Java. -### Gradle users -Step 1. Add the JitPack repository to your build file -``` -allprojects { - repositories { - ... - maven { url 'https://jitpack.io' } - } -} -``` -Step 2. Add the dependency on the project's `build.gradle`: -``` -dependencies { - implementation 'com.github.imagekit-developer:imagekit-java:2.0.0' -} -``` -### Maven users -Step 1. Add the JitPack repository to your build file -``` - - - jitpack.io - https://jitpack.io - - -``` -Step 2. Add the dependency in the POM file: -``` - - com.github.imagekit-developer - imagekit-java - 2.0.0 - -``` +It is generated with [Stainless](https://www.stainless.com/). -## Initialization +The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1). -**Step 1**. Create a `config.properties` file inside `src/main/resources` of your project. And put essential values of keys [UrlEndpoint, PrivateKey, PublicKey], no need to use quote(`'` or `"`) in values. +## Installation - You can get the value of [URL-endpoint](https://imagekit.io/dashboard#url-endpoints) from your ImageKit dashboard. API keys can be obtained from the [developer](https://imagekit.io/dashboard/developer/api-keys) section in your ImageKit dashboard. +### Gradle -```editorconfig -# Put essential values of keys [UrlEndpoint, PrivateKey, PublicKey] -UrlEndpoint=your_public_api_key -PrivateKey=your_private_api_key -PublicKey=https://ik.imagekit.io/imagekit_id/ +```kotlin +implementation("com.imagekit.api:image-kit-java:0.0.1") ``` -**Step 2**. Then you need to initialize ImageKit with that configuration. - - ```java -import io.imagekit.sdk.ImageKit; -import io.imagekit.sdk.config.Configuration; -import io.imagekit.sdk.utils.Utils; -class App { - public static void main(String[] args){ - ImageKit imageKit=ImageKit.getInstance(); - Configuration config=Utils.getSystemConfig(App.class); - imageKit.setConfig(config); - } -} -``` +### Maven -or - - ```java -import io.imagekit.sdk.ImageKit; -import io.imagekit.sdk.config.Configuration; -import io.imagekit.sdk.utils.Utils; -class App { - public static void main(String[] args) { - ImageKit imageKit = ImageKit.getInstance(); - Configuration config = new Configuration("your_public_key", "your_private_key", "your_url_endpoint"); - imageKit.setConfig(config); - } -} +```xml + + com.imagekit.api + image-kit-java + 0.0.1 + ``` -## Usage -You can use this Java SDK for 3 different kinds of methods: - -* URL generation -* file upload -* file management - -The usage of the SDK has been explained below. - -## Change log -This document presents a list of changes that break the existing functionality of previous versions. We try our best to minimize these disruptions, but sometimes they are unavoidable and will be in major versions. - -### Breaking History: - -Changes from 1.0.3 -> 2.0.0 are listed below - -1. Result `raw` object and `getMap()` properties: +## Requirements -**What changed** -- `raw` and `getMap()` has been deprecated. +This library requires Java 8 or later. -**Who is affected?** -- This affects any development that uses the `raw` or `getMap()` from the response object of APIs and Result object. +## Usage -**How should I update my code?** -- If you still need to use `raw` and `getMap()`, do this `result.getResponseMetaData().getRaw()`. - -2. Result object `message` and `isSuccessful` boolean properties: +```java +import com.imagekit.api.client.ImageKitClient; +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; -**What changed** -- `message` and `isSuccessful` have been replaced with custom exceptions according to response code. +// Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables +ImageKitClient client = ImageKitOkHttpClient.fromEnv(); -**Who is affected?** -- This affects any development that uses the `message` or `isSuccessful` from response object of APIs that is Result object. +FileUploadParams params = FileUploadParams.builder() + .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") + .build(); +FileUploadResponse response = client.files().upload(params); +``` -**How should I update my code?** -- If you still need to use `message` it will be there in the custom exceptions that could be raised when calling the various API methods. `isSuccessful` can be understood to be `true` if the API method doesn't throw any exception. +## Client configuration +Configure the client using system properties or environment variables: -## URL generation +```java +import com.imagekit.api.client.ImageKitClient; +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; -**1. Using image path and URL-endpoint** +// Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables +ImageKitClient client = ImageKitOkHttpClient.fromEnv(); +``` -This method allows you to create an URL to access a file using the relative file path and the ImageKit URL endpoint (`urlEndpoint`). The file can be an image, video, or any other static file supported by ImageKit. +Or manually: ```java -Map queryParam=new HashMap<>(); -queryParam.put("v","123"); - -List> transformation=new ArrayList>(); -Map scale=new HashMap<>(); -scale.put("height","600"); -scale.put("width","400"); -scale.put("raw", "ar-4-3,q-40"); -transformation.add(scale); - -Map options=new HashMap(); -options.put("urlEndpoint","https://ik.imagekit.io/your_imagekit_id/"); -options.put("path","/default-image.jpg"); -options.put("transformation", transformation); - -String url = ImageKit.getInstance().getUrl(options); -``` -The result in a URL like -``` -https://ik.imagekit.io/your_imagekit_id/tr:w-400,h-600/default-image.jpg?v=123 +import com.imagekit.api.client.ImageKitClient; +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; + +ImageKitClient client = ImageKitOkHttpClient.builder() + .privateApiKey("My Private API Key") + .password("My Password") + .build(); ``` -**2. Using full image URL** -This method allows you to add transformation parameters to an absolute URL. For example, if you have configured a custom CNAME and have absolute asset URLs in your database or CMS, you will often need this. +Or using a combination of the two approaches: ```java -List> transformation=new ArrayList>(); -Map scale=new HashMap<>(); -scale.put("height","600"); -scale.put("width","400"); -scale.put("raw", "ar-4-3,q-40"); -transformation.add(scale); - -Map options=new HashMap(); -options.put("src","https://ik.imagekit.io/your_imagekit_id/default-image.jpg"); -options.put("transformation", transformation); - -String url = ImageKit.getInstance().getUrl(options); +import com.imagekit.api.client.ImageKitClient; +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; + +ImageKitClient client = ImageKitOkHttpClient.builder() + // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties + // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables + .fromEnv() + .privateApiKey("My Private API Key") + .build(); ``` -The results in a URL like +See this table for the available options: -``` -https://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=w-400,h-600 -``` +| Setter | System property | Environment variable | Required | Default value | +| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- | +| `privateApiKey` | `imagekit.imagekitPrivateApiKey` | `IMAGEKIT_PRIVATE_API_KEY` | true | - | +| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` | +| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - | +| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` | -The ```.getUrl()``` method accepts the following parameters +System properties take precedence over environment variables. -| Option | Description | -| :---------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| urlEndpoint | Optional. `(Type: String)` The base URL to be appended before the path of the image. If not specified, the URL Endpoint specified during SDK initialization is used. For example, https://ik.imagekit.io/your_imagekit_id/ | -| path | Conditional. `(Type: String)` This is the path at which the image exists. For example, `/path/to/image.jpg`. Either the `path` or `src` parameter needs to be specified for URL generation. | -| src | Conditional. `(Type: String)` This is the complete URL of an image already mapped to ImageKit. For example, `https://ik.imagekit.io/your_imagekit_id/endpoint/path/to/image.jpg`. Either the `path` or `src` parameter needs to be specified for URL generation. | -| transformation | Optional. `(Type: List>)` An array of objects specifying the transformation to be applied in the URL. The transformation name and the value should be specified as a key-value pair in the object. Different steps of a [chained transformation](https://docs.imagekit.io/features/image-transformations/chained-transformations) can be specified as different objects of the array. The complete list of supported transformations in the SDK and some examples of using them are given later. If you use a transformation name that is not specified in the SDK, it gets applied as it is in the URL. | -| transformationPosition | Optional. `(Type: String)` Default value is `path` that places the transformation string as a path parameter in the URL. It can also be specified as `query`, which adds the transformation string as the query parameter `tr` in the URL. If you use the `src` parameter to create the URL, then the transformation string is always added as a query parameter. | -| queryParameters | Optional. `(Type: Map)` These are the other query parameters that you want to add to the final URL. These can be any query parameters and not necessarily related to ImageKit. Especially useful if you want to add some versioning parameters to your URLs. | -| signed | Optional. `(Type: Boolean)` Default is `false`. If set to `true`, the SDK generates a signed image URL adding the image signature to the image URL. This can only be used if you create the URL with the `url_endpoint` and `path` parameters and not with the `src` parameter. | -| expireSeconds | Optional. `(Type: Integer)` Meant to be used along with the `signed` parameter to specify the time in seconds from now when the URL should expire. If specified, the URL contains the expiry timestamp in the URL, and the image signature is modified accordingly. | +> [!TIP] +> Don't create more than one client in the same application. Each client has a connection pool and +> thread pools, which are more efficient to share between requests. +### Modifying configuration -## Examples of generating URLs -**1. Chained Transformations as a query parameter** +To temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service: ```java -List> transformation=new ArrayList>(); -Map scale=new HashMap<>(); -scale.put("height","300"); -scale.put("width","400"); -transformation.add(scale); -Map rotate=new HashMap<>(); -rotate.put("rotation","90"); -transformation.add(rotate); - -Map options=new HashMap(); -options.put("path","/default-image.jpg"); -options.put("transformationPosition","query"); -options.put("transformation", transformation); - -String url = ImageKit.getInstance().getUrl(options); -``` +import com.imagekit.api.client.ImageKitClient; -Sample Result URL - -``` -https://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=h-300&w-400:rt-90 +ImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> { + optionsBuilder.baseUrl("https://example.com"); + optionsBuilder.maxRetries(42); +}); ``` -**2. Sharpening and contrast transform and a progressive JPG image** +The `withOptions()` method does not affect the original client or service. -There are some transforms like [Sharpening](https://docs.imagekit.io/features/image-transformations/image-enhancement-and-color-manipulation) -that can be added to the URL with or without any other value. To use such transforms without specifying a value, specify -the value as "-" in the transformation object. Otherwise, specify the value that you want to be -added to this transformation. +## Requests and responses -```java -List> transformation=new ArrayList>(); -Map scale=new HashMap<>(); -scale.put("format","jpg"); -scale.put("progressive","true"); -scale.put("effect_sharpen","-"); -scale.put("effect_contrast","1"); -transformation.add(scale); - -Map options=new HashMap(); -options.put("path","/default-image.jpg"); -options.put("transformation", transformation); -String url = ImageKit.getInstance().getUrl(options); -``` - -Note that because the `src` parameter was used, the transformation string gets added as a query parameter. - -``` -https://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=f-jpg&pr-true&e-sharpen&e-contrast-1 -``` +To send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. -**3. Signed URL that expires in 300 seconds with the default URL endpoint and other query parameters** +For example, `client.files().upload(...)` should be called with an instance of `FileUploadParams`, and it will return an instance of `FileUploadResponse`. -```java -List> transformation=new ArrayList>(); -Map scale=new HashMap<>(); -scale.put("height","600"); -scale.put("width","400"); - -transformation.add(format); - -Map options=new HashMap(); -options.put("path","/default-image.jpg"); -options.put("signed",true); -options.put("expireSeconds",300); -String url = ImageKit.getInstance().getUrl(options); -``` -**Sample Result URL** -``` -https://ik.imagekit.io/your_imagekit_id/tr:h-600,w-400/default-image.jpg?ik-t=1567358667&ik-s=f2c7cdacbe7707b71a83d49cf1c6110e3d701054 -``` +## Immutability -**4. Adding overlays** +Each class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it. -ImageKit.io enables you to apply overlays to [images](https://docs.imagekit.io/features/image-transformations/overlay-using-layers) and [videos](https://docs.imagekit.io/features/video-transformation/overlay) using the raw parameter with the concept of [layers](https://docs.imagekit.io/features/image-transformations/overlay-using-layers#layers). The raw parameter facilitates incorporating transformations directly in the URL. A layer is a distinct type of transformation that allows you to define an asset to serve as an overlay, along with its positioning and additional transformations. +Each class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy. -**Text as overlays** +Because each class is immutable, builder modification will _never_ affect already built class instances. -You can add any text string over a base video or image using a text layer (l-text). +## Asynchronous execution -For example: +The default client is synchronous. To switch to asynchronous execution, call the `async()` method: ```java -List> transformation=new ArrayList>(); -Map scale=new HashMap<>(); -scale.put("height","300"); -scale.put("width","400"); -scale.put("raw", "l-text,i-Imagekit,fs-50,l-end"); -transformation.add(scale); - -Map options=new HashMap(); -options.put("src","https://ik.imagekit.io/your_imagekit_id/default-image.jpg"); -options.put("transformation", transformation); - -String url = ImageKit.getInstance().getUrl(options); -``` -**Sample Result URL** -``` -https://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=h-300,w-400,l-text,i-Imagekit,fs-50,l-end -``` - -**Image as overlays** +import com.imagekit.api.client.ImageKitClient; +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; +import java.util.concurrent.CompletableFuture; -You can add an image over a base video or image using an image layer (l-image). +// Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables +ImageKitClient client = ImageKitOkHttpClient.fromEnv(); -For example: - -```java -List> transformation=new ArrayList>(); -Map scale=new HashMap<>(); -scale.put("height","300"); -scale.put("width","400"); -scale.put("raw", "l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end"); -transformation.add(scale); - -Map options=new HashMap(); -options.put("src","https://ik.imagekit.io/your_imagekit_id/default-image.jpg"); -options.put("transformation", transformation); - -String url = ImageKit.getInstance().getUrl(options); -``` -**Sample Result URL** -``` -https://ik.imagekit.io/your_imagekit_id/default-image.jpg?tr=h-300,w-400,l-image,i-default-image.jpg,w-100,b-10_CDDC39,l-end +FileUploadParams params = FileUploadParams.builder() + .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") + .build(); +CompletableFuture response = client.async().files().upload(params); ``` -**Solid color blocks as overlays** +Or create an asynchronous client from the beginning: -You can add solid color blocks over a base video or image using an image layer (l-image). +```java +import com.imagekit.api.client.ImageKitClientAsync; +import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync; +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; +import java.util.concurrent.CompletableFuture; -For example: +// Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables +ImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv(); -```java -List> transformation=new ArrayList>(); -Map scale=new HashMap<>(); -scale.put("height","300"); -scale.put("width","400"); -scale.put("raw", "l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end"); -transformation.add(scale); - -Map options=new HashMap(); -options.put("src","https://ik.imagekit.io/your_imagekit_id/img/sample-video.mp4"); -options.put("transformation", transformation); - -String url = ImageKit.getInstance().getUrl(options); -``` -**Sample Result URL** -``` -https://ik.imagekit.io/your_imagekit_id/img/sample-video.mp4?tr=h-300,w-400,l-image,i-ik_canvas,bg-FF0000,w-300,h-100,l-end +FileUploadParams params = FileUploadParams.builder() + .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") + .build(); +CompletableFuture response = client.files().upload(params); ``` -**List of transformations** - -See the complete list of [image](https://docs.imagekit.io/features/image-transformations) and [video](https://docs.imagekit.io/features/video-transformation) transformations supported in ImageKit. The SDK gives a name to each transformation parameter e.g. `height` for `h` and `width` for `w` parameter. It makes your code more readable. If the property does not match any of the following supported options, it is added as it is. - -If you want to generate transformations in your application and add them to the URL as it is, use the `raw` parameter. - -| Supported Transformation Name | Translates to parameter | -|-------------------------------|-------------------------| -| height | h | -| width | w | -| aspectRatio | ar | -| quality | q | -| crop | c | -| cropMode | cm | -| x | x | -| y | y | -| focus | fo | -| format | f | -| radius | r | -| background | bg | -| border | b | -| rotation | rt | -| blur | bl | -| named | n | -| progressive | pr | -| lossless | lo | -| trim | t | -| metadata | md | -| colorProfile | cp | -| defaultImage | di | -| dpr | dpr | -| effectSharpen | e-sharpen | -| effectUSM | e-usm | -| effectContrast | e-contrast | -| effectGray | e-grayscale | -| original | orig | -| raw | `replaced by the parameter value` | - - -## File Upload - -The SDK provides a simple interface using the `.upload()` method to upload files to the ImageKit Media library. It -accepts an object of the `FileCreateRequest` class that contains all the parameters supported by the [ImageKit Upload API](https://docs.imagekit.io/api-reference/upload-file-api/server-side-file-upload). - -The constructor `FileCreateRequest` class requires `file` as (URL/Base64/Byte Array) and `file_name`. The method returns object of `Result` in case of successful, or it will throw custom exception in case of failure. - -Sample usage +The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. -```java -String filePath = "your-local-file-path"; -String base64 = Utils.fileToBase64(new File(filePath)); -FileCreateRequest fileCreateRequest = new FileCreateRequest(base64, "file_name.jpg"); -String customCoordinates = "10,10,20,20"; -fileCreateRequest.setCustomCoordinates(customCoordinates); // optional -List tags = new ArrayList<>(); -tags.add("Sample-tag"); -tags.add("T-shirt"); -fileCreateRequest.setTags(tags); // optional -fileCreateRequest.setFileName("override_file_name.jpg"); // optional -fileCreateRequest.setFolder("sample-folder/nested-folder"); // optional -fileCreateRequest.setPrivateFile(false); // optional -fileCreateRequest.setUseUniqueFileName(true); // optional -List responseFields=new ArrayList<>(); -responseFields.add("tags"); -responseFields.add("customCoordinates"); -fileCreateRequest.setResponseFields(responseFields); // optional -JsonObject innerObject1 = new JsonObject(); -innerObject1.addProperty("name", "remove-bg"); -innerObject1.add("options", optionsInnerObject); -JsonObject innerObject2 = new JsonObject(); -innerObject2.addProperty("name", "google-auto-tagging"); -innerObject2.addProperty("minConfidence", 10); -innerObject2.addProperty("maxTags", 5); -JsonArray jsonArray = new JsonArray(); -jsonArray.add(innerObject1); -jsonArray.add(innerObject2); -fileCreateRequest.setExtensions(jsonArray); // optional -fileCreateRequest.setWebhookUrl("Your webhook url"); // optional -fileCreateRequest.setOverwriteFile(true); // optional -fileCreateRequest.setOverwriteAITags(true); // optional -fileCreateRequest.setOverwriteTags(true); // optional -fileCreateRequest.setOverwriteCustomMetadata(true); // optional -JsonObject jsonObjectCustomMetadata = new JsonObject(); -jsonObjectCustomMetadata.addProperty("test1", 10); -fileCreateRequest.setCustomMetadata(jsonObjectCustomMetadata); // optional -Result result = ImageKit.getInstance().upload(fileCreateRequest); -System.out.println("======FINAL RESULT======="); -System.out.println(result); -System.out.println("Raw Response:"); -System.out.println(result.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(result.getResponseMetaData().getMap()); -``` +## File uploads -If the upload is successful, result will be there as an object of `Result` class that contains the same all the parameters received from ImageKit's servers. +The SDK defines methods that accept files. -If the upload fails, custom exception is thrown and `getMessage()` can be called to get the error message received from ImageKit's servers. +To upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html): +```java +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; +import java.nio.file.Paths; -## File Management +FileUploadParams params = FileUploadParams.builder() + .fileName("fileName") + .file(Paths.get("/path/to/file")) + .build(); +FileUploadResponse response = client.files().upload(params); +``` -The SDK provides a simple interface for all the [media APIs mentioned here](https://docs.imagekit.io/api-reference/media-api) to manage your files. This also returns `error` and `result`, the error will be `None` if API succeeds. +Or an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html): -**1. List & Search Files** +```java +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; +import java.net.URL; -Accepts an object of class `GetFileListRequest` specifying the parameters to be used to list and search files. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/list-and-search-files) can be passed via their setter functions to get the results. +FileUploadParams params = FileUploadParams.builder() + .fileName("fileName") + .file(new URL("https://example.com//path/to/file").openStream()) + .build(); +FileUploadResponse response = client.files().upload(params); +``` -#### Applying Filters -Filter out the files by specifying the parameters. +Or a `byte[]` array: ```java -String[] tags = new String[3]; -tags[0] = "Software"; -tags[1] = "Developer"; -tags[2] = "Engineer"; -GetFileListRequest getFileListRequest = new GetFileListRequest(); -getFileListRequest.setType("file"); -getFileListRequest.setSort("ASC_CREATED"); -getFileListRequest.setPath("/"); -getFileListRequest.setFileType("all"); -getFileListRequest.setLimit("4"); -getFileListRequest.setSkip("1"); -getFileListRequest.setTags(tags); -ResultList resultList = ImageKit.getInstance().getFileList(getFileListRequest); -System.out.println("======FINAL RESULT======="); -System.out.println(resultList); -System.out.println("Raw Response:"); -System.out.println(resultList.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(resultList.getResponseMetaData().getMap()); +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; + +FileUploadParams params = FileUploadParams.builder() + .fileName("fileName") + .file("content".getBytes()) + .build(); +FileUploadResponse response = client.files().upload(params); ``` -#### Advance Search -In addition, you can fine-tune your query by specifying various filters by generating a query string in a Lucene-like syntax and setting this generated string to the `GetFileListRequest` object using `setSearchQuery` function. +Note that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt): ```java -GetFileListRequest getFileListRequest = new GetFileListRequest(); -getFileListRequest.setSearchQuery("createdAt >= '2d' OR size < '2mb' OR format='png'"); -ResultList resultList = ImageKit.getInstance().getFileList(getFileListRequest); -System.out.println("======FINAL RESULT======="); -System.out.println(resultList); -System.out.println("Raw Response:"); -System.out.println(resultList.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(resultList.getResponseMetaData().getMap()); +import com.imagekit.api.core.MultipartField; +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; +import java.io.InputStream; +import java.net.URL; + +FileUploadParams params = FileUploadParams.builder() + .fileName("fileName") + .file(MultipartField.builder() + .value(new URL("https://example.com//path/to/file").openStream()) + .filename("/path/to/file") + .build()) + .build(); +FileUploadResponse response = client.files().upload(params); ``` -Detailed documentation can be found here for [advance search queries](https://docs.imagekit.io/api-reference/media-api/list-and-search-files#advanced-search-queries). +## Raw responses -**2. Get File Details** +The SDK defines methods that deserialize responses into instances of Java classes. However, these methods don't provide access to the response headers, status code, or the raw response body. -Accepts the file ID and fetches the details as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-details) +To access this data, prefix any HTTP method call on a client or service with `withRawResponse()`: ```java -String fileId="your-file-id"; -Result result=ImageKit.getInstance().getFileDetail(fileId); -System.out.println("======FINAL RESULT======="); -System.out.println(result); -System.out.println("Raw Response:"); -System.out.println(result.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(result.getResponseMetaData().getMap()); -``` - -**3. Get File Versions** +import com.imagekit.api.core.http.Headers; +import com.imagekit.api.core.http.HttpResponseFor; +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; -Accepts the file ID and fetches the details as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-versions). +FileUploadParams params = FileUploadParams.builder() + .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") + .build(); +HttpResponseFor response = client.files().withRawResponse().upload(params); -```java -String fileId = "62a04834c10d49825c6de9e8"; -ResultFileVersions resultFileVersions = ImageKit.getInstance().getFileVersions(fileId); -System.out.println("======FINAL RESULT======="); -System.out.println(resultFileVersions); -System.out.println("Raw Response:"); -System.out.println(resultFileVersions.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(resultFileVersions.getResponseMetaData().getMap()); +int statusCode = response.statusCode(); +Headers headers = response.headers(); ``` -**4. Get File Version details** - -Accepts the file ID and version ID and fetches the details as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/get-file-version-details). +You can still deserialize the response into an instance of a Java class if needed: ```java -String fileId = "62a04834c10d49825c6de9e8"; -String versionId = "62a04834c10d49825c6de9e8"; -ResultFileVersionDetails resultFileVersionDetails = ImageKit.getInstance().getFileVersionDetails(fileId, versionId); -System.out.println("======FINAL RESULT======="); -System.out.println(resultFileVersionDetails); -System.out.println("Raw Response:"); -System.out.println(resultFileVersionDetails.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(resultFileVersionDetails.getResponseMetaData().getMap()); +import com.imagekit.api.models.files.FileUploadResponse; + +FileUploadResponse parsedResponse = response.parse(); ``` -**5. Update File Details** +## Error handling -Accepts an object of class `FileUpdateRequest` specifying the parameters to be used to update file details. All parameters specified in the [documentation here] (https://docs.imagekit.io/api-reference/media-api/update-file-details) can be passed via their setter functions to get the results. +The SDK throws custom unchecked exception types: -```java -List tags = new ArrayList<>(); -tags.add("Software"); -tags.add("Developer"); -tags.add("Engineer"); - -List aiTags = new ArrayList<>(); -aiTags.add("Plant"); -FileUpdateRequest fileUpdateRequest = new FileUpdateRequest("fileId"); -fileUpdateRequest.setTags(tags); -fileUpdateRequest.setRemoveAITags(aiTags); -fileUpdateRequest.setWebhookUrl("https://webhook.site/c78d617f-33bc-40d9-9e61-608999721e2e"); - -JsonObject optionsInnerObject = new JsonObject(); -optionsInnerObject.addProperty("add_shadow", true); -optionsInnerObject.addProperty("bg_color", "yellow"); -JsonObject innerObject1 = new JsonObject(); -innerObject1.addProperty("name", "remove-bg"); -innerObject1.add("options", optionsInnerObject); -JsonObject innerObject2 = new JsonObject(); -innerObject2.addProperty("name", "google-auto-tagging"); -innerObject2.addProperty("minConfidence", 15); -innerObject2.addProperty("maxTags", 20); -JsonArray jsonArray = new JsonArray(); -jsonArray.add(innerObject1); -jsonArray.add(innerObject2); - -fileUpdateRequest.setExtensions(jsonArray); -fileUpdateRequest.setCustomCoordinates("10,10,40,40"); -JsonObject jsonObjectCustomMetadata = new JsonObject(); -jsonObjectCustomMetadata.addProperty("test10", 11); -fileUpdateRequest.setCustomMetadata(jsonObjectCustomMetadata); -Result result=ImageKit.getInstance().updateFileDetail(fileUpdateRequest); -System.out.println("======FINAL RESULT======="); -System.out.println(result); -System.out.println("Raw Response:"); -System.out.println(result.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(result.getResponseMetaData().getMap()); -``` +- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code: -**6. Add tags** + | Status | Exception | + | ------ | ------------------------------------------------------------------------------------------------------------------------------- | + | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) | + | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) | + | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) | + | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) | + | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) | + | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) | + | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) | + | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) | -Accepts an object of class `TagsRequest` specifying the parameters to be used to add tags. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/add-tags-bulk) can be passed via their setter functions to get the results. +- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors. -```java -List fileIds = new ArrayList<>(); -fileIds.add("FileId"); -List tags = new ArrayList<>(); -tags.add("tag-to-add-1"); -tags.add("tag-to-add-2"); -ResultTags resultTags=ImageKit.getInstance().addTags(new TagsRequest(fileIds, tags)); -System.out.println("======FINAL RESULT======="); -System.out.println(resultTags); -System.out.println("Raw Response:"); -System.out.println(resultTags.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(resultTags.getResponseMetaData().getMap()); -``` +- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client. -**7. Remove tags** +- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response. -Accepts an object of class `TagsRequest` specifying the parameters to be used to remove tags. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/remove-tags-bulk) can be passed via their setter functions to get the results. +- [`ImageKitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class. -```java -List fileIds = new ArrayList<>(); -fileIds.add("FileId"); -List tags = new ArrayList<>(); -tags.add("tag-to-remove-1"); -tags.add("tag-to-remove-2"); -ResultTags resultTags=ImageKit.getInstance().removeTags(new TagsRequest(fileIds, tags)); -System.out.println("======FINAL RESULT======="); -System.out.println(resultTags); -System.out.println("Raw Response:"); -System.out.println(resultTags.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(resultTags.getResponseMetaData().getMap()); -``` +## Logging -**8. Remove AI tags** +The SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor). -Accepts an object of class `AITagsRequest` specifying the parameters to be used to remove AI tags. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/remove-aitags-bulk) can be passed via their setter functions to get the results. +Enable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`: -```java -List fileIds = new ArrayList<>(); -fileIds.add("629f3de17eb0fe4053615450"); -List aiTags = new ArrayList<>(); -aiTags.add("Rectangle"); -AITagsRequest aiTagsRequest =new AITagsRequest(); -aiTagsRequest.setFileIds(fileIds); -aiTagsRequest.setAITags(aiTags); -ResultTags resultTags = ImageKit.getInstance().removeAITags(aiTagsRequest); -System.out.println("======FINAL RESULT======="); -System.out.println(resultTags); -System.out.println("Raw Response:"); -System.out.println(resultTags.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(resultTags.getResponseMetaData().getMap()); +```sh +$ export IMAGE_KIT_LOG=info ``` -**9. Delete File** - -Accepts the file ID and delete a file as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/delete-file). +Or to `debug` for more verbose logging: -```java -String fileId="your-file-id"; -Result result=ImageKit.getInstance().deleteFile(fileId); -System.out.println("======FINAL RESULT======="); -System.out.println(result); -System.out.println("Raw Response:"); -System.out.println(result.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(result.getResponseMetaData().getMap()); +```sh +$ export IMAGE_KIT_LOG=debug ``` -**10. Delete FileVersion** +## ProGuard and R8 -Accepts an object of class `DeleteFileVersionRequest` specifying the parameters to be used to delete file version. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/delete-file-version) can be passed via their setter functions to get the results. +Although the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `image-kit-java-core` is published with a [configuration file](image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage). -```java -DeleteFileVersionRequest deleteFileVersionRequest = new DeleteFileVersionRequest(); -deleteFileVersionRequest.setFileId("629d95278482ba129fd17c97"); -deleteFileVersionRequest.setVersionId("629d953ebd24e8ceca911a66"); -ResultNoContent resultNoContent = ImageKit.getInstance().deleteFileVersion(deleteFileVersionRequest); -System.out.println("======FINAL RESULT======="); -System.out.println(resultNoContent); -System.out.println("Raw Response:"); -System.out.println(resultNoContent.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(resultNoContent.getResponseMetaData().getMap()); -``` +ProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary. -**11. Delete files (bulk)** +## Jackson -Accepts the file IDs to delete files as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/delete-files-bulk). +The SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default. -```java -List fileIds = new ArrayList<>(); -fileIds.add("your-file-id"); -fileIds.add("your-file-id"); -fileIds.add("your-file-id"); - -ResultFileDelete result=ImageKit.getInstance().bulkDeleteFiles(fileIds); -System.out.println("======FINAL RESULT======="); -System.out.println(result); -System.out.println("Raw Response:"); -System.out.println(result.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(result.getResponseMetaData().getMap()); -``` +The SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config). -**12. Copy file** +If the SDK threw an exception, but you're _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt). -Accepts an object of class `CopyFileRequest` specifying the parameters to be used to copy file. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/copy-file) can be passed via their setter functions to get the results. +> [!CAUTION] +> We make no guarantee that the SDK works correctly when the Jackson version check is disabled. -```java -CopyFileRequest copyFileRequest = new CopyFileRequest(); -copyFileRequest.setSourceFilePath("/w2_image.png"); -copyFileRequest.setDestinationPath("/Gallery/"); -copyFileRequest.setIncludeFileVersions(true); -ResultNoContent resultNoContent = ImageKit.getInstance().copyFile(copyFileRequest); -System.out.println("======FINAL RESULT======="); -System.out.println(resultNoContent); -System.out.println("Raw Response:"); -System.out.println(resultNoContent.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(resultNoContent.getResponseMetaData().getMap()); -``` +## Network options -**13. Move file** +### Retries -Accepts an object of class `MoveFileRequest` specifying the parameters to be used to move file. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/move-file) can be passed via their setter functions to get the results. +The SDK automatically retries 2 times by default, with a short exponential backoff between requests. -```java -MoveFileRequest moveFileRequest = new MoveFileRequest(); -moveFileRequest.setSourceFilePath("/Gallery/w2_image.png"); -moveFileRequest.setDestinationPath("/"); -ResultNoContent resultNoContent = ImageKit.getInstance().moveFile(moveFileRequest); -System.out.println("======FINAL RESULT======="); -System.out.println(resultNoContent); -System.out.println("Raw Response:"); -System.out.println(resultNoContent.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(resultNoContent.getResponseMetaData().getMap()); -``` +Only the following error types are retried: + +- Connection errors (for example, due to a network connectivity problem) +- 408 Request Timeout +- 409 Conflict +- 429 Rate Limit +- 5xx Internal -**14. Rename file** +The API may also explicitly instruct the SDK to retry or not retry a request. -Accepts an object of class `RenameFileRequest` specifying the parameters to be used to rename file. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/rename-file) can be passed via their setter functions to get the results. +To set a custom number of retries, configure the client using the `maxRetries` method: ```java -RenameFileRequest renameFileRequest = new RenameFileRequest(); -renameFileRequest.setFilePath("/w2_image.png"); -renameFileRequest.setNewFileName("w2_image_s.png"); -renameFileRequest.setPurgeCache(true); -ResultRenameFile resultRenameFile = ImageKit.getInstance().renameFile(renameFileRequest); -System.out.println("======FINAL RESULT======="); -System.out.println(resultRenameFile); -System.out.println("Raw Response:"); -System.out.println(resultRenameFile.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(resultRenameFile.getResponseMetaData().getMap()); +import com.imagekit.api.client.ImageKitClient; +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; + +ImageKitClient client = ImageKitOkHttpClient.builder() + .fromEnv() + .maxRetries(4) + .build(); ``` -**15. Restore file Version** +### Timeouts + +Requests time out after 1 minute by default. -Accepts the fileId and versionId to restore file version as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/restore-file-version). +To set a custom timeout, configure the method call using the `timeout` method: ```java -Result result = ImageKit.getInstance().restoreFileVersion("fileId", "versionId"); -System.out.println("======FINAL RESULT======="); -System.out.println(result); -System.out.println("Raw Response:"); -System.out.println(result.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(result.getResponseMetaData().getMap()); -``` +import com.imagekit.api.models.files.FileUploadResponse; -**16. Create Folder** +FileUploadResponse response = client.files().upload( + params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build() +); +``` -Accepts an object of class `CreateFolderRequest` specifying the parameters to be used to create folder. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/create-folder) can be passed via their setter functions to get the results. +Or configure the default for all method calls at the client level: ```java -CreateFolderRequest createFolderRequest = new CreateFolderRequest(); -createFolderRequest.setFolderName("test1"); -createFolderRequest.setParentFolderPath("/"); -ResultEmptyBlock resultEmptyBlock = ImageKit.getInstance().createFolder(createFolderRequest); -System.out.println("======FINAL RESULT======="); -System.out.println(resultEmptyBlock); -System.out.println("Raw Response:"); -System.out.println(resultEmptyBlock.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(resultEmptyBlock.getResponseMetaData().getMap()); +import com.imagekit.api.client.ImageKitClient; +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import java.time.Duration; + +ImageKitClient client = ImageKitOkHttpClient.builder() + .fromEnv() + .timeout(Duration.ofSeconds(30)) + .build(); ``` -**17. Delete Folder** +### Proxies -Accepts an object of class `DeleteFolderRequest` specifying the parameters to be used to delete folder. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/delete-folder) can be passed via their setter functions to get the results. +To route requests through a proxy, configure the client using the `proxy` method: ```java -DeleteFolderRequest deleteFolderRequest = new DeleteFolderRequest(); -deleteFolderRequest.setFolderPath("/test1"); -ResultNoContent resultNoContent = ImageKit.getInstance().deleteFolder(deleteFolderRequest); -System.out.println("======FINAL RESULT======="); -System.out.println(resultNoContent); -System.out.println("Raw Response:"); -System.out.println(resultNoContent.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(resultNoContent.getResponseMetaData().getMap()); +import com.imagekit.api.client.ImageKitClient; +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import java.net.InetSocketAddress; +import java.net.Proxy; + +ImageKitClient client = ImageKitOkHttpClient.builder() + .fromEnv() + .proxy(new Proxy( + Proxy.Type.HTTP, new InetSocketAddress( + "https://example.com", 8080 + ) + )) + .build(); ``` -**18. Copy Folder** +### HTTPS -Accepts an object of class `CopyFolderRequest` specifying the parameters to be used to copy folder. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/copy-folder) can be passed via their setter functions to get the results. +> [!NOTE] +> Most applications should not call these methods, and instead use the system defaults. The defaults include +> special optimizations that can be lost if the implementations are modified. + +To configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods: ```java -CopyFolderRequest copyFolderRequest = new CopyFolderRequest(); -copyFolderRequest.setSourceFolderPath("/Gallery/test"); -copyFolderRequest.setDestinationPath("/"); -ResultOfFolderActions resultOfFolderActions = ImageKit.getInstance().copyFolder(copyFolderRequest); -System.out.println("======FINAL RESULT======="); -System.out.println(resultOfFolderActions); -System.out.println("Raw Response:"); -System.out.println(resultOfFolderActions.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(resultOfFolderActions.getResponseMetaData().getMap()); +import com.imagekit.api.client.ImageKitClient; +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; + +ImageKitClient client = ImageKitOkHttpClient.builder() + .fromEnv() + // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa. + .sslSocketFactory(yourSSLSocketFactory) + .trustManager(yourTrustManager) + .hostnameVerifier(yourHostnameVerifier) + .build(); ``` -**19. Move Folder** +### Custom HTTP client -Accepts an object of class `MoveFolderRequest` specifying the parameters to be used to move folder. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/media-api/move-folder) can be passed via their setter functions to get the results. +The SDK consists of three artifacts: -```java -MoveFolderRequest moveFolderRequest = new MoveFolderRequest(); -moveFolderRequest.setSourceFolderPath("/Gallery/test"); -moveFolderRequest.setDestinationPath("/"); -ResultOfFolderActions resultOfFolderActions = ImageKit.getInstance().moveFolder(moveFolderRequest); -System.out.println("======FINAL RESULT======="); -System.out.println(resultOfFolderActions); -System.out.println("Raw Response:"); -System.out.println(resultOfFolderActions.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(resultOfFolderActions.getResponseMetaData().getMap()); -``` +- `image-kit-java-core` + - Contains core SDK logic + - Does not depend on [OkHttp](https://square.github.io/okhttp) + - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client +- `image-kit-java-client-okhttp` + - Depends on [OkHttp](https://square.github.io/okhttp) + - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp +- `image-kit-java` + - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp` + - Does not have its own logic -**20. Get Bulk Job Status** +This structure allows replacing the SDK's default HTTP client without pulling in unnecessary dependencies. -Accepts the jobId to get bulk job status as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/copy-move-folder-status). +#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html) -```java -String jobId = "629f44ac7eb0fe8173622d4b"; -ResultBulkJobStatus resultBulkJobStatus = ImageKit.getInstance().getBulkJobStatus(jobId); -System.out.println("======FINAL RESULT======="); -System.out.println(resultBulkJobStatus); -System.out.println("Raw Response:"); -System.out.println(resultBulkJobStatus.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(resultBulkJobStatus.getResponseMetaData().getMap()); -``` +> [!TIP] +> Try the available [network options](#network-options) before replacing the default client. -**21. Purge Cache** +To use a customized `OkHttpClient`: -Accepts a full URL of the file for which the cache has to be cleared as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/purge-cache). +1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core` +2. Copy `image-kit-java-client-okhttp`'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it +3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client -```java -ResultCache result=ImageKit.getInstance().purgeCache("https://ik.imagekit.io/imagekit-id/default-image.jpg"); -System.out.println("======FINAL RESULT======="); -System.out.println(result); -System.out.println("Raw Response:"); -System.out.println(result.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(result.getResponseMetaData().getMap()); -``` +### Completely custom HTTP client -**22. Purge Cache Status** +To use a completely custom HTTP client: -Accepts a request ID and fetch purge cache status as per the [API documentation here](https://docs.imagekit.io/api-reference/media-api/purge-cache-status) +1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core` +2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface +3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class -```java -String requestId="cache-requestId"; -ResultCacheStatus result=ImageKit.getInstance().getPurgeCacheStatus(requestId); -System.out.println("======FINAL RESULT======="); -System.out.println(result); -System.out.println("Raw Response:"); -System.out.println(result.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(result.getResponseMetaData().getMap()); -``` +## Undocumented API functionality -**23. Get File Metadata** +The SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API. -Accepts the file ID and fetches the metadata as per the [API documentation here](https://docs.imagekit.io/api-reference/metadata-api/get-image-metadata-for-uploaded-media-files) +### Parameters -```java -String fileId="your-file-id"; -ResultMetaData result=ImageKit.getInstance().getFileMetadata(fileId); -System.out.println("======FINAL RESULT======="); -System.out.println(result); -System.out.println("Raw Response:"); -System.out.println(result.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(result.getResponseMetaData().getMap()); -``` +To set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class: -Another way to get metadata from a remote file URL as per the [API documentation here](https://docs.imagekit.io/api-reference/metadata-api/get-image-metadata-from-remote-url). This file should be accessible over the ImageKit.io URL-endpoint. ```java -String url="Remote File URL"; -ResultMetaData result=ImageKit.getInstance().getRemoteFileMetadata(url); -System.out.println("======FINAL RESULT======="); -System.out.println(result); -System.out.println("Raw Response:"); -System.out.println(result.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(result.getResponseMetaData().getMap()); -``` - -**24. Create CustomMetaDataFields** +import com.imagekit.api.core.JsonValue; +import com.imagekit.api.models.files.FileUploadParams; -Accepts an object of class `CustomMetaDataFieldCreateRequest` specifying the parameters to be used to create cusomMetaDataFields. All parameters specified in the [documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/create-custom-metadata-field) can be passed as-is with the correct values to get the results. +FileUploadParams params = FileUploadParams.builder() + .putAdditionalHeader("Secret-Header", "42") + .putAdditionalQueryParam("secret_query_param", "42") + .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) + .build(); +``` -Check for the [Allowed Values In The Schema](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/create-custom-metadata-field#allowed-values-in-the-schema-object). +These can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods. -#### Examples: +To set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class: ```java -CustomMetaDataFieldSchemaObject schemaObject = new CustomMetaDataFieldSchemaObject(); -schemaObject.setType("Number"); -schemaObject.setMinValue(10); -schemaObject.setMaxValue(200); -CustomMetaDataFieldCreateRequest customMetaDataFieldCreateRequest = new CustomMetaDataFieldCreateRequest(); -customMetaDataFieldCreateRequest.setName("Name"); -customMetaDataFieldCreateRequest.setLabel("Label"); -customMetaDataFieldCreateRequest.setSchema(schemaObject); -ResultCustomMetaDataField resultCustomMetaDataField=ImageKit.getInstance().createCustomMetaDataFields(customMetaDataFieldCreateRequest); -System.out.println("======FINAL RESULT======="); -System.out.println(resultCustomMetaDataField); -System.out.println("Raw Response:"); -System.out.println(resultCustomMetaDataField.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(resultCustomMetaDataField.getResponseMetaData().getMap()); +import com.imagekit.api.core.JsonValue; +import com.imagekit.api.models.files.FileUploadParams; + +FileUploadParams params = FileUploadParams.builder() + .transformation(FileUploadParams.Transformation.builder() + .putAdditionalProperty("secretProperty", JsonValue.from("42")) + .build()) + .build(); ``` -- MultiSelect type Exmample: +These properties can be accessed on the nested built object later using the `_additionalProperties()` method. + +To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter: ```java -List objectList = new ArrayList<>(); -objectList.add("small"); -objectList.add(30); -objectList.add(40); -objectList.add(true); - -List defaultValueObject = new ArrayList<>(); -defaultValueObject.add("small"); -defaultValueObject.add(30); -defaultValueObject.add(true); -CustomMetaDataFieldSchemaObject customMetaDataFieldSchemaObject = new CustomMetaDataFieldSchemaObject(); -customMetaDataFieldSchemaObject.setType("MultiSelect"); -customMetaDataFieldSchemaObject.setValueRequired(true); // optional -customMetaDataFieldSchemaObject.setDefaultValue(defaultValueObject); // required if isValueRequired set to true -customMetaDataFieldSchemaObject.setSelectOptions(objectList); -CustomMetaDataFieldCreateRequest customMetaDataFieldCreateRequest = new CustomMetaDataFieldCreateRequest(); -customMetaDataFieldCreateRequest.setName("Name-MultiSelect"); -customMetaDataFieldCreateRequest.setLabel("Label-MultiSelect"); -customMetaDataFieldCreateRequest.setSchema(customMetaDataFieldSchemaObject); - -ResultCustomMetaDataField resultCustomMetaDataField = ImageKit.getInstance() - .createCustomMetaDataFields(customMetaDataFieldCreateRequest); +import com.imagekit.api.core.JsonValue; +import com.imagekit.api.models.files.FileUploadParams; + +FileUploadParams params = FileUploadParams.builder() + .file(JsonValue.from(42)) + .fileName("file-name.jpg") + .build(); ``` -- Date type Exmample: +The most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method: ```java -CustomMetaDataFieldSchemaObject customMetaDataFieldSchemaObject = new CustomMetaDataFieldSchemaObject(); -customMetaDataFieldSchemaObject.setType("Date"); -customMetaDataFieldSchemaObject.setValueRequired(true); // optional -customMetaDataFieldSchemaObject.setDefaultValue("2022-11-30T10:11:10+00:00"); // required if isValueRequired set to true -customMetaDataFieldSchemaObject.setMinValue("2022-11-30T10:11:10+00:00"); -customMetaDataFieldSchemaObject.setMaxValue("2022-12-30T10:11:10+00:00"); - -CustomMetaDataFieldCreateRequest customMetaDataFieldCreateRequest = new CustomMetaDataFieldCreateRequest(); -customMetaDataFieldCreateRequest.setName("Name"); -customMetaDataFieldCreateRequest.setLabel("Label"); -customMetaDataFieldCreateRequest.setSchema(customMetaDataFieldSchemaObject); - -ResultCustomMetaDataField resultCustomMetaDataField = ImageKit.getInstance() - .createCustomMetaDataFields(customMetaDataFieldCreateRequest); -``` +import com.imagekit.api.core.JsonValue; +import java.util.List; +import java.util.Map; +// Create primitive JSON values +JsonValue nullValue = JsonValue.from(null); +JsonValue booleanValue = JsonValue.from(true); +JsonValue numberValue = JsonValue.from(42); +JsonValue stringValue = JsonValue.from("Hello World!"); -**25. Get CustomMetaDataFields** +// Create a JSON array value equivalent to `["Hello", "World"]` +JsonValue arrayValue = JsonValue.from(List.of( + "Hello", "World" +)); -Accepts the includeDeleted boolean and fetches the metadata as per the [API documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/get-custom-metadata-field) +// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }` +JsonValue objectValue = JsonValue.from(Map.of( + "a", 1, + "b", 2 +)); -```java -ResultCustomMetaDataFieldList resultCustomMetaDataFieldList=ImageKit.getInstance().getCustomMetaDataFields(false); -System.out.println("======FINAL RESULT======="); -System.out.println(resultCustomMetaDataFieldList); -System.out.println("Raw Response:"); -System.out.println(resultCustomMetaDataFieldList.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(resultCustomMetaDataFieldList.getResponseMetaData().getList()); -System.out.println(resultCustomMetaDataFieldList.getResultCustomMetaDataFields()); +// Create an arbitrarily nested JSON equivalent to: +// { +// "a": [1, 2], +// "b": [3, 4] +// } +JsonValue complexValue = JsonValue.from(Map.of( + "a", List.of( + 1, 2 + ), + "b", List.of( + 3, 4 + ) +)); ``` -**26. Edit CustomMetaDataFields** +Normally a `Builder` class's `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset. -Accepts an ID of customMetaDataField and object of class `CustomMetaDataFieldUpdateRequest` specifying the parameters to be used to edit cusomMetaDataFields as per the [API documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/update-custom-metadata-field). +To forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt): ```java -CustomMetaDataFieldSchemaObject schemaObject = new CustomMetaDataFieldSchemaObject(); -schemaObject.setMinValue(10); -schemaObject.setMaxValue(200); - -CustomMetaDataFieldUpdateRequest customMetaDataFieldUpdateRequest = new CustomMetaDataFieldUpdateRequest(); -customMetaDataFieldUpdateRequest.setId("id"); -customMetaDataFieldUpdateRequest.setLabel("label"); -customMetaDataFieldUpdateRequest.setSchema(schemaObject); -ResultCustomMetaDataField resultCustomMetaDataField=ImageKit.getInstance().updateCustomMetaDataFields(customMetaDataFieldUpdateRequest); -System.out.println("======FINAL RESULT======="); -System.out.println(resultCustomMetaDataField); -System.out.println("Raw Response:"); -System.out.println(resultCustomMetaDataField.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(resultCustomMetaDataField.getResponseMetaData().getMap()); +import com.imagekit.api.core.JsonMissing; +import com.imagekit.api.models.files.FileUploadParams; + +FileUploadParams params = FileUploadParams.builder() + .fileName("fileName") + .file(JsonMissing.of()) + .build(); ``` -**27. Delete CustomMetaDataFields** +### Response properties -Accepts the id to delete the customMetaDataFields as per the [API documentation here](https://docs.imagekit.io/api-reference/custom-metadata-fields-api/delete-custom-metadata-field). +To access undocumented response properties, call the `_additionalProperties()` method: ```java -ResultNoContent resultNoContent=ImageKit.getInstance().deleteCustomMetaDataField("id"); -System.out.println("======FINAL RESULT======="); -System.out.println(resultNoContent); -System.out.println("Raw Response:"); -System.out.println(resultNoContent.getResponseMetaData().getRaw()); -System.out.println("Map Response:"); -System.out.println(resultNoContent.getResponseMetaData().getMap()); -``` +import com.imagekit.api.core.JsonValue; +import java.util.Map; -## Utility functions +Map additionalProperties = client.files().upload(params)._additionalProperties(); +JsonValue secretPropertyValue = additionalProperties.get("secretProperty"); -We have included the following commonly used utility functions in this package. +String result = secretPropertyValue.accept(new JsonValue.Visitor<>() { + @Override + public String visitNull() { + return "It's null!"; + } -**Authentication parameter generation** + @Override + public String visitBoolean(boolean value) { + return "It's a boolean!"; + } -In case you are looking to implement client-side file upload, you are going to need a token, expiry timestamp, and a valid signature for that upload. The SDK provides a simple method that you can use in your code to generate these -authentication parameters for you. + @Override + public String visitNumber(Number value) { + return "It's a number!"; + } -Note: The Private API Key should never be exposed in any client-side code. You must always generate these authentications - parameters on the server-side + // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject` + // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden +}); +``` -authentication +To access a property's raw JSON value, which may be undocumented, call its `_` prefixed method: ```java -Map authenticationParams = ImageKit.getInstance().getAuthenticationParameters(token, expire); -``` +import com.imagekit.api.core.JsonField; +import java.io.InputStream; +import java.util.Optional; -Returns Map object of this json -```json -{ - "token": "unique_token", - "expire": "valid_expiry_timestamp", - "signature": "generated_signature" +JsonField file = client.files().upload(params)._file(); + +if (file.isMissing()) { + // The property is absent from the JSON response +} else if (file.isNull()) { + // The property was set to literal null +} else { + // Check if value was provided as a string + // Other methods include `asNumber()`, `asBoolean()`, etc. + Optional jsonString = file.asString(); + + // Try to deserialize into a custom type + MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class); } ``` -Both the `token` and `expire` parameters are optional. If not specified, the SDK uses the uuid to generate a random -token and also generates a valid expiry timestamp internally. The value of the token and expire used to generate the -signature are always returned in the response, no matter if they are provided as an input to this method or not. - -**Distance calculation between two pHash values** +### Response validation -Perceptual hashing allows you to construct a hash value that uniquely identifies an input image based on the contents -of an image. [imagekit.io metadata API](https://docs.imagekit.io/api-reference/metadata-api) returns the pHash -value of an image in the response. You can use this value to find a duplicate (or similar) images by calculating the distance between the two images. +In rare cases, the API may return a response that doesn't match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else. +By default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property. -This SDK exposes phash_distance function to calculate the distance between two pHash value. It accepts two pHash hexadecimal -strings and returns a numeric value indicative of the level of difference between the two images. +If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`: ```java -int calculateDistance(){ - // fetch metadata of two uploaded image files - ... - // extract pHash strings from both: say 'first_hash' and 'second_hash' - ... - // calculate the distance between them: - - int distance = ImageKit.getInstance().pHashDistance(first_hash, second_hash); - return distance; -} +import com.imagekit.api.models.files.FileUploadResponse; + +FileUploadResponse response = client.files().upload(params).validate(); ``` -**Distance calculation examples** -```java -ImageKit.getInstance().pHashDistance("f06830ca9f1e3e90", "f06830ca9f1e3e90"); -// output: 0 (ame image) +Or configure the method call to validate the response using the `responseValidation` method: -ImageKit.getInstance().pHashDistance("2d5ad3936d2e015b", "2d6ed293db36a4fb"); -// output: 17 (similar images) +```java +import com.imagekit.api.models.files.FileUploadResponse; -ImageKit.getInstance().pHashDistance("a4a65595ac94518b", "7838873e791f8400"); -// output: 37 (dissimilar images) +FileUploadResponse response = client.files().upload( + params, RequestOptions.builder().responseValidation(true).build() +); ``` -**HTTP response metadata of Internal API** - -HTTP response metadata of the internal API call can be accessed using the getResponseMetaData function on the Result (or ResultList, ResultCache etc.) object. Example: +Or configure the default for all method calls at the client level: ```java -Result result = ImageKit.getInstance().upload(fileCreateRequest); -result.getResponseMetaData().getRaw(); -result.getResponseMetaData().getHeaders(); -result.getResponseMetaData().getHttpStatusCode(); +import com.imagekit.api.client.ImageKitClient; +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; + +ImageKitClient client = ImageKitOkHttpClient.builder() + .fromEnv() + .responseValidation(true) + .build(); ``` -## Sample Code Instruction +## FAQ -**1. First clone this repository to your system using git.** -```shell script -git clone https://github.com/imagekit-developer/imagekit-java.git -``` -**2. Open project in your favorite Java IDE that can supports Gradle dependency management or you can use Terminal/Command Prompt.** +### Why don't you use plain `enum` classes? -**3. Goto `src/main/resources` directory.** +Java `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value. -**4. Rename file `config.sample.properties` to `config.properties`.** +### Why do you represent fields using `JsonField` instead of just plain `T`? -**5. Edit `config.properties` and write values of given keys.** -```properties -UrlEndpoint=your_url_endpoint -PrivateKey=your_private_key -PublicKey=your_public_key -``` +Using `JsonField` enables a few features: -**5. You will find `App.java` in `src/main/java/io/imagekit/sampleapp/` directory. Edit program as you need, then run `App.java`. If you are using CLI Tool (Terminal/Command Prompt) Then Open Project in CLI and execute using gradle** -```shell -cd imagekit-java -./gradlew run -``` -* Run test case: -```shell -./gradlew imagekit-sdk:test -``` -* Build ImageKit SDK: -```shell -./gradlew imagekit-sdk:clean -./gradlew imagekit-sdk:build -# You will find jar in "imagekit-sdk/build/libs/" directory. -``` +- Allowing usage of [undocumented API functionality](#undocumented-api-functionality) +- Lazily [validating the API response against the expected shape](#response-validation) +- Representing absent vs explicitly null values -## Handling errors -Catch and respond to invalid data, internal problems, and more. +### Why don't you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)? -Imagekit Java SDK raise exceptions for many reasons, such as not found, invalid parameters, authentication errors, and internal server error. We recommend writing code that gracefully handles all possible API exceptions. +It is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don't want to introduce a breaking change every time we add a field to a class. -#### Example: +### Why don't you use checked exceptions? -```java -try { - // Use ImageKit's SDK to make requests... -} catch (BadRequestException e) { - // Missing or Invalid parameters were supplied to Imagekit.io's API - System.out.println("Status is: " + e.getResponseMetaData().getHttpStatusCode()); - System.out.println("Message is: " + e.getMessage()); - System.out.println("Headers are: " + e.getResponseMetaData().getHeaders()); - System.out.println("Raw body is: " + e.getResponseMetaData().getRaw()); - System.out.println("Mapped body is: " + e.getResponseMetaData().getMap()); -} catch (UnauthorizedException e) { - // No valid API key was provided. -} catch (ForbiddenException e) { - // Can be for the following reasons: - // ImageKit could not authenticate your account with the keys provided. - // An expired key (public or private) was used with the request. - // The account is disabled. - // If you are using the upload API, the total storage limit (or upload limit) is exceeded. -} catch (TooManyRequestsException e) { - // Too many requests made to the API too quickly -} catch (InternalServerException e) { - // Something went wrong with ImageKit.io API. -} catch (PartialSuccessException e) { - // Error cases on partial success. -} catch (NotFoundException e) { - // If any of the field or parameter is not found in data -} catch (UnknownException e) { - // Something else happened, which can be unrelated to imagekit, reason will be indicated in the message field -} -``` +Checked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason. + +Checked exceptions: -## Supporttim -For any feedback or to report any issues or general implementation support, please reach out to [support@imagekit.io]() +- Are verbose to handle +- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error +- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function) +- Don't play well with lambdas (also due to the function coloring problem) +## Semantic versioning -## Links +This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions: -* [Documentation](https://docs.imagekit.io/) -* [Main Website](https://imagekit.io/) +1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_ +2. Changes that we do not expect to impact the vast majority of users in practice. +We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. -## License -Released under the MIT license. +We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-java/issues) with questions, bugs, or suggestions. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..8e64327a --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,27 @@ +# Security Policy + +## Reporting Security Issues + +This SDK is generated by [Stainless Software Inc](http://stainless.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken. + +To report a security issue, please contact the Stainless team at security@stainless.com. + +## Responsible Disclosure + +We appreciate the efforts of security researchers and individuals who help us maintain the security of +SDKs we generate. If you believe you have found a security vulnerability, please adhere to responsible +disclosure practices by allowing us a reasonable amount of time to investigate and address the issue +before making any information public. + +## Reporting Non-SDK Related Security Issues + +If you encounter security issues that are not directly related to SDKs but pertain to the services +or products provided by Image Kit, please follow the respective company's security reporting guidelines. + +### Image Kit Terms and Policies + +Please contact developer@imagekit.io for any questions or concerns regarding the security of our services. + +--- + +Thank you for helping us keep the SDKs and systems they interact with secure. diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..7712ede0 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,49 @@ +plugins { + id("io.github.gradle-nexus.publish-plugin") version "1.1.0" + id("org.jetbrains.dokka") version "2.0.0" +} + +repositories { + mavenCentral() +} + +allprojects { + group = "com.imagekit.api" + version = "0.0.1" +} + +subprojects { + // These are populated with dependencies by `buildSrc` scripts. + tasks.register("format") { + group = "Verification" + description = "Formats all source files." + } + tasks.register("lint") { + group = "Verification" + description = "Verifies all source files are formatted." + } + apply(plugin = "org.jetbrains.dokka") +} + +subprojects { + apply(plugin = "org.jetbrains.dokka") +} + +// Avoid race conditions between `dokkaJavadocCollector` and `dokkaJavadocJar` tasks +tasks.named("dokkaJavadocCollector").configure { + subprojects.flatMap { it.tasks } + .filter { it.project.name != "image-kit-java" && it.name == "dokkaJavadocJar" } + .forEach { mustRunAfter(it) } +} + +nexusPublishing { + repositories { + sonatype { + nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + + username.set(System.getenv("SONATYPE_USERNAME")) + password.set(System.getenv("SONATYPE_PASSWORD")) + } + } +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 00000000..0b141353 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + `kotlin-dsl` + kotlin("jvm") version "1.9.20" +} + +repositories { + gradlePluginPortal() +} + +dependencies { + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20") +} diff --git a/buildSrc/src/main/kotlin/image-kit.java.gradle.kts b/buildSrc/src/main/kotlin/image-kit.java.gradle.kts new file mode 100644 index 00000000..81d5d32b --- /dev/null +++ b/buildSrc/src/main/kotlin/image-kit.java.gradle.kts @@ -0,0 +1,136 @@ +import org.gradle.api.tasks.testing.logging.TestExceptionFormat + +plugins { + `java-library` +} + +repositories { + mavenCentral() +} + +configure { + withJavadocJar() + withSourcesJar() +} + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } + + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +tasks.withType().configureEach { + options.compilerArgs.add("-Werror") + options.release.set(8) +} + +tasks.named("javadocJar") { + setZip64(true) +} + +tasks.named("jar") { + manifest { + attributes(mapOf( + "Implementation-Title" to project.name, + "Implementation-Version" to project.version + )) + } +} + +tasks.withType().configureEach { + useJUnitPlatform() + + // Run tests in parallel to some degree. + maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) + forkEvery = 100 + + testLogging { + exceptionFormat = TestExceptionFormat.FULL + } +} + +val palantir by configurations.creating +dependencies { + palantir("com.palantir.javaformat:palantir-java-format:2.73.0") +} + +fun registerPalantir( + name: String, + description: String, +) { + val javaName = "${name}Java" + tasks.register(javaName) { + group = "Verification" + this.description = description + + classpath = palantir + mainClass = "com.palantir.javaformat.java.Main" + + // Avoid an `IllegalAccessError` on Java 9+. + jvmArgs( + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", + ) + + // Use paths relative to the current module. + val argumentFile = + project.layout.buildDirectory.file("palantir-$name-args.txt").get().asFile + val lastRunTimeFile = + project.layout.buildDirectory.file("palantir-$name-last-run.txt").get().asFile + + // Read the time when this task was last executed for this module (if ever). + val lastRunTime = lastRunTimeFile.takeIf { it.exists() }?.readText()?.toLongOrNull() ?: 0L + + // Use a `fileTree` relative to the module's source directory. + val javaFiles = project.fileTree("src") { include("**/*.java") } + + // Determine if any files need to be formatted or linted and continue only if there is at least + // one file. + onlyIf { javaFiles.any { it.lastModified() > lastRunTime } } + + inputs.files(javaFiles) + + doFirst { + // Create the argument file and set the preferred formatting style. + argumentFile.parentFile.mkdirs() + argumentFile.writeText("--palantir\n") + + if (name == "lint") { + // For lint, do a dry run, so no files are modified. Set the exit code to 1 (instead of + // the default 0) if any files need to be formatted, indicating that linting has failed. + argumentFile.appendText("--dry-run\n") + argumentFile.appendText("--set-exit-if-changed\n") + } else { + // `--dry-run` and `--replace` (for in-place formatting) are mutually exclusive. + argumentFile.appendText("--replace\n") + } + + // Write the modified files to the argument file. + javaFiles.filter { it.lastModified() > lastRunTime } + .forEach { argumentFile.appendText("${it.absolutePath}\n") } + } + + doLast { + // Record the last execution time for later up-to-date checking. + lastRunTimeFile.writeText(System.currentTimeMillis().toString()) + } + + // Pass the argument file using the @ symbol + args = listOf("@${argumentFile.absolutePath}") + + outputs.upToDateWhen { javaFiles.none { it.lastModified() > lastRunTime } } + } + + tasks.named(name) { + dependsOn(tasks.named(javaName)) + } +} + +registerPalantir(name = "format", description = "Formats all Java source files.") +registerPalantir(name = "lint", description = "Verifies all Java source files are formatted.") diff --git a/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts b/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts new file mode 100644 index 00000000..aaec88fc --- /dev/null +++ b/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts @@ -0,0 +1,106 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.dsl.KotlinVersion + +plugins { + id("image-kit.java") + kotlin("jvm") +} + +repositories { + mavenCentral() +} + +kotlin { + jvmToolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } + + compilerOptions { + freeCompilerArgs = listOf( + "-Xjvm-default=all", + "-Xjdk-release=1.8", + // Suppress deprecation warnings because we may still reference and test deprecated members. + // TODO: Replace with `-Xsuppress-warning=DEPRECATION` once we use Kotlin compiler 2.1.0+. + "-nowarn", + ) + jvmTarget.set(JvmTarget.JVM_1_8) + languageVersion.set(KotlinVersion.KOTLIN_1_8) + apiVersion.set(KotlinVersion.KOTLIN_1_8) + coreLibrariesVersion = "1.8.0" + } +} + +tasks.withType().configureEach { + systemProperty("junit.jupiter.execution.parallel.enabled", true) + systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent") +} + +val ktfmt by configurations.creating +dependencies { + ktfmt("com.facebook:ktfmt:0.56") +} + +fun registerKtfmt( + name: String, + description: String, +) { + val kotlinName = "${name}Kotlin" + tasks.register(kotlinName) { + group = "Verification" + this.description = description + + classpath = ktfmt + mainClass = "com.facebook.ktfmt.cli.Main" + + // Use paths relative to the current module. + val argumentFile = project.layout.buildDirectory.file("ktfmt-$name-args.txt").get().asFile + val lastRunTimeFile = + project.layout.buildDirectory.file("ktfmt-$name-last-run.txt").get().asFile + + // Read the time when this task was last executed for this module (if ever). + val lastRunTime = lastRunTimeFile.takeIf { it.exists() }?.readText()?.toLongOrNull() ?: 0L + + // Use a `fileTree` relative to the module's source directory. + val kotlinFiles = project.fileTree("src") { include("**/*.kt") } + + // Determine if any files need to be formatted or linted and continue only if there is at least + // one file (otherwise Ktfmt will fail). + onlyIf { kotlinFiles.any { it.lastModified() > lastRunTime } } + + inputs.files(kotlinFiles) + + doFirst { + // Create the argument file and set the preferred formatting style. + argumentFile.parentFile.mkdirs() + argumentFile.writeText("--kotlinlang-style\n") + + if (name == "lint") { + // For lint, do a dry run, so no files are modified. Set the exit code to 1 (instead of + // the default 0) if any files need to be formatted, indicating that linting has failed. + argumentFile.appendText("--dry-run\n") + argumentFile.appendText("--set-exit-if-changed\n") + } + + // Write the modified files to the argument file. + kotlinFiles.filter { it.lastModified() > lastRunTime } + .forEach { argumentFile.appendText("${it.absolutePath}\n") } + } + + doLast { + // Record the last execution time for later up-to-date checking. + lastRunTimeFile.writeText(System.currentTimeMillis().toString()) + } + + // Pass the argument file using the @ symbol + args = listOf("@${argumentFile.absolutePath}") + + outputs.upToDateWhen { kotlinFiles.none { it.lastModified() > lastRunTime } } + } + + tasks.named(name) { + dependsOn(tasks.named(kotlinName)) + } +} + +registerKtfmt(name = "format", description = "Formats all Kotlin source files.") +registerKtfmt(name = "lint", description = "Verifies all Kotlin source files are formatted.") diff --git a/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts b/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts new file mode 100644 index 00000000..ca87253e --- /dev/null +++ b/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts @@ -0,0 +1,61 @@ +plugins { + `maven-publish` + signing +} + +configure { + publications { + register("maven") { + from(components["java"]) + + pom { + name.set("ImageKit API") + description.set("Checkout [API overview](/docs/api-overview) to learn about ImageKit's APIs,\nauthentication, rate limits, and error codes etc.") + url.set("https://imagekit.io/docs") + + licenses { + license { + name.set("Apache-2.0") + } + } + + developers { + developer { + name.set("Image Kit") + email.set("developer@imagekit.io") + } + } + + scm { + connection.set("scm:git:git://github.com/stainless-sdks/imagekit-java.git") + developerConnection.set("scm:git:git://github.com/stainless-sdks/imagekit-java.git") + url.set("https://github.com/stainless-sdks/imagekit-java") + } + + versionMapping { + allVariants { + fromResolutionResult() + } + } + } + } + } +} + +signing { + val signingKeyId = System.getenv("GPG_SIGNING_KEY_ID")?.ifBlank { null } + val signingKey = System.getenv("GPG_SIGNING_KEY")?.ifBlank { null } + val signingPassword = System.getenv("GPG_SIGNING_PASSWORD")?.ifBlank { null } + if (signingKey != null && signingPassword != null) { + useInMemoryPgpKeys( + signingKeyId, + signingKey, + signingPassword, + ) + sign(publishing.publications["maven"]) + } +} + +tasks.named("publish") { + dependsOn(":closeAndReleaseSonatypeStagingRepository") +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..6680f9ce --- /dev/null +++ b/gradle.properties @@ -0,0 +1,18 @@ +org.gradle.caching=true +org.gradle.configuration-cache=true +org.gradle.parallel=true +org.gradle.daemon=false +# These options improve our compilation and test performance. They are inherited by the Kotlin daemon. +org.gradle.jvmargs=\ + -Xms2g \ + -Xmx8g \ + -XX:+UseParallelGC \ + -XX:InitialCodeCacheSize=256m \ + -XX:ReservedCodeCacheSize=1G \ + -XX:MetaspaceSize=512m \ + -XX:MaxMetaspaceSize=2G \ + -XX:TieredStopAtLevel=1 \ + -XX:GCTimeRatio=4 \ + -XX:CICompilerCount=4 \ + -XX:+OptimizeStringConcat \ + -XX:+UseStringDeduplication diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 87b738cbd051603d91cc39de6cb000dd98fe6b02..a4b76b9530d66f5e68d973ea569d8e19de379189 100644 GIT binary patch literal 43583 zcma&N1CXTcmMvW9vTb(Rwr$&4wr$(C?dmSu>@vG-+vuvg^_??!{yS%8zW-#zn-LkA z5&1^$^{lnmUON?}LBF8_K|(?T0Ra(xUH{($5eN!MR#ZihR#HxkUPe+_R8Cn`RRs(P z_^*#_XlXmGv7!4;*Y%p4nw?{bNp@UZHv1?Um8r6)Fei3p@ClJn0ECfg1hkeuUU@Or zDaPa;U3fE=3L}DooL;8f;P0ipPt0Z~9P0)lbStMS)ag54=uL9ia-Lm3nh|@(Y?B`; zx_#arJIpXH!U{fbCbI^17}6Ri*H<>OLR%c|^mh8+)*h~K8Z!9)DPf zR2h?lbDZQ`p9P;&DQ4F0sur@TMa!Y}S8irn(%d-gi0*WxxCSk*A?3lGh=gcYN?FGl z7D=Js!i~0=u3rox^eO3i@$0=n{K1lPNU zwmfjRVmLOCRfe=seV&P*1Iq=^i`502keY8Uy-WNPwVNNtJFx?IwAyRPZo2Wo1+S(xF37LJZ~%i)kpFQ3Fw=mXfd@>%+)RpYQLnr}B~~zoof(JVm^^&f zxKV^+3D3$A1G;qh4gPVjhrC8e(VYUHv#dy^)(RoUFM?o%W-EHxufuWf(l*@-l+7vt z=l`qmR56K~F|v<^Pd*p~1_y^P0P^aPC##d8+HqX4IR1gu+7w#~TBFphJxF)T$2WEa zxa?H&6=Qe7d(#tha?_1uQys2KtHQ{)Qco)qwGjrdNL7thd^G5i8Os)CHqc>iOidS} z%nFEDdm=GXBw=yXe1W-ShHHFb?Cc70+$W~z_+}nAoHFYI1MV1wZegw*0y^tC*s%3h zhD3tN8b=Gv&rj}!SUM6|ajSPp*58KR7MPpI{oAJCtY~JECm)*m_x>AZEu>DFgUcby z1Qaw8lU4jZpQ_$;*7RME+gq1KySGG#Wql>aL~k9tLrSO()LWn*q&YxHEuzmwd1?aAtI zBJ>P=&$=l1efe1CDU;`Fd+_;&wI07?V0aAIgc(!{a z0Jg6Y=inXc3^n!U0Atk`iCFIQooHqcWhO(qrieUOW8X(x?(RD}iYDLMjSwffH2~tB z)oDgNBLB^AJBM1M^c5HdRx6fBfka`(LD-qrlh5jqH~);#nw|iyp)()xVYak3;Ybik z0j`(+69aK*B>)e_p%=wu8XC&9e{AO4c~O1U`5X9}?0mrd*m$_EUek{R?DNSh(=br# z#Q61gBzEpmy`$pA*6!87 zSDD+=@fTY7<4A?GLqpA?Pb2z$pbCc4B4zL{BeZ?F-8`s$?>*lXXtn*NC61>|*w7J* z$?!iB{6R-0=KFmyp1nnEmLsA-H0a6l+1uaH^g%c(p{iT&YFrbQ$&PRb8Up#X3@Zsk zD^^&LK~111%cqlP%!_gFNa^dTYT?rhkGl}5=fL{a`UViaXWI$k-UcHJwmaH1s=S$4 z%4)PdWJX;hh5UoK?6aWoyLxX&NhNRqKam7tcOkLh{%j3K^4Mgx1@i|Pi&}<^5>hs5 zm8?uOS>%)NzT(%PjVPGa?X%`N2TQCKbeH2l;cTnHiHppPSJ<7y-yEIiC!P*ikl&!B z%+?>VttCOQM@ShFguHVjxX^?mHX^hSaO_;pnyh^v9EumqSZTi+#f&_Vaija0Q-e*| z7ulQj6Fs*bbmsWp{`auM04gGwsYYdNNZcg|ph0OgD>7O}Asn7^Z=eI>`$2*v78;sj-}oMoEj&@)9+ycEOo92xSyY344^ z11Hb8^kdOvbf^GNAK++bYioknrpdN>+u8R?JxG=!2Kd9r=YWCOJYXYuM0cOq^FhEd zBg2puKy__7VT3-r*dG4c62Wgxi52EMCQ`bKgf*#*ou(D4-ZN$+mg&7$u!! z-^+Z%;-3IDwqZ|K=ah85OLwkO zKxNBh+4QHh)u9D?MFtpbl)us}9+V!D%w9jfAMYEb>%$A;u)rrI zuBudh;5PN}_6J_}l55P3l_)&RMlH{m!)ai-i$g)&*M`eN$XQMw{v^r@-125^RRCF0 z^2>|DxhQw(mtNEI2Kj(;KblC7x=JlK$@78`O~>V!`|1Lm-^JR$-5pUANAnb(5}B}JGjBsliK4& zk6y(;$e&h)lh2)L=bvZKbvh@>vLlreBdH8No2>$#%_Wp1U0N7Ank!6$dFSi#xzh|( zRi{Uw%-4W!{IXZ)fWx@XX6;&(m_F%c6~X8hx=BN1&q}*( zoaNjWabE{oUPb!Bt$eyd#$5j9rItB-h*5JiNi(v^e|XKAj*8(k<5-2$&ZBR5fF|JA z9&m4fbzNQnAU}r8ab>fFV%J0z5awe#UZ|bz?Ur)U9bCIKWEzi2%A+5CLqh?}K4JHi z4vtM;+uPsVz{Lfr;78W78gC;z*yTch~4YkLr&m-7%-xc ztw6Mh2d>_iO*$Rd8(-Cr1_V8EO1f*^@wRoSozS) zy1UoC@pruAaC8Z_7~_w4Q6n*&B0AjOmMWa;sIav&gu z|J5&|{=a@vR!~k-OjKEgPFCzcJ>#A1uL&7xTDn;{XBdeM}V=l3B8fE1--DHjSaxoSjNKEM9|U9#m2<3>n{Iuo`r3UZp;>GkT2YBNAh|b z^jTq-hJp(ebZh#Lk8hVBP%qXwv-@vbvoREX$TqRGTgEi$%_F9tZES@z8Bx}$#5eeG zk^UsLBH{bc2VBW)*EdS({yw=?qmevwi?BL6*=12k9zM5gJv1>y#ML4!)iiPzVaH9% zgSImetD@dam~e>{LvVh!phhzpW+iFvWpGT#CVE5TQ40n%F|p(sP5mXxna+Ev7PDwA zamaV4m*^~*xV+&p;W749xhb_X=$|LD;FHuB&JL5?*Y2-oIT(wYY2;73<^#46S~Gx| z^cez%V7x$81}UWqS13Gz80379Rj;6~WdiXWOSsdmzY39L;Hg3MH43o*y8ibNBBH`(av4|u;YPq%{R;IuYow<+GEsf@R?=@tT@!}?#>zIIn0CoyV!hq3mw zHj>OOjfJM3F{RG#6ujzo?y32m^tgSXf@v=J$ELdJ+=5j|=F-~hP$G&}tDZsZE?5rX ztGj`!S>)CFmdkccxM9eGIcGnS2AfK#gXwj%esuIBNJQP1WV~b~+D7PJTmWGTSDrR` zEAu4B8l>NPuhsk5a`rReSya2nfV1EK01+G!x8aBdTs3Io$u5!6n6KX%uv@DxAp3F@{4UYg4SWJtQ-W~0MDb|j-$lwVn znAm*Pl!?Ps&3wO=R115RWKb*JKoexo*)uhhHBncEDMSVa_PyA>k{Zm2(wMQ(5NM3# z)jkza|GoWEQo4^s*wE(gHz?Xsg4`}HUAcs42cM1-qq_=+=!Gk^y710j=66(cSWqUe zklbm8+zB_syQv5A2rj!Vbw8;|$@C!vfNmNV!yJIWDQ>{+2x zKjuFX`~~HKG~^6h5FntRpnnHt=D&rq0>IJ9#F0eM)Y-)GpRjiN7gkA8wvnG#K=q{q z9dBn8_~wm4J<3J_vl|9H{7q6u2A!cW{bp#r*-f{gOV^e=8S{nc1DxMHFwuM$;aVI^ zz6A*}m8N-&x8;aunp1w7_vtB*pa+OYBw=TMc6QK=mbA-|Cf* zvyh8D4LRJImooUaSb7t*fVfih<97Gf@VE0|z>NcBwBQze);Rh!k3K_sfunToZY;f2 z^HmC4KjHRVg+eKYj;PRN^|E0>Gj_zagfRbrki68I^#~6-HaHg3BUW%+clM1xQEdPYt_g<2K+z!$>*$9nQ>; zf9Bei{?zY^-e{q_*|W#2rJG`2fy@{%6u0i_VEWTq$*(ZN37|8lFFFt)nCG({r!q#9 z5VK_kkSJ3?zOH)OezMT{!YkCuSSn!K#-Rhl$uUM(bq*jY? zi1xbMVthJ`E>d>(f3)~fozjg^@eheMF6<)I`oeJYx4*+M&%c9VArn(OM-wp%M<-`x z7sLP1&3^%Nld9Dhm@$3f2}87!quhI@nwd@3~fZl_3LYW-B?Ia>ui`ELg z&Qfe!7m6ze=mZ`Ia9$z|ARSw|IdMpooY4YiPN8K z4B(ts3p%2i(Td=tgEHX z0UQ_>URBtG+-?0E;E7Ld^dyZ;jjw0}XZ(}-QzC6+NN=40oDb2^v!L1g9xRvE#@IBR zO!b-2N7wVfLV;mhEaXQ9XAU+>=XVA6f&T4Z-@AX!leJ8obP^P^wP0aICND?~w&NykJ#54x3_@r7IDMdRNy4Hh;h*!u(Ol(#0bJdwEo$5437-UBjQ+j=Ic>Q2z` zJNDf0yO6@mr6y1#n3)s(W|$iE_i8r@Gd@!DWDqZ7J&~gAm1#~maIGJ1sls^gxL9LLG_NhU!pTGty!TbhzQnu)I*S^54U6Yu%ZeCg`R>Q zhBv$n5j0v%O_j{QYWG!R9W?5_b&67KB$t}&e2LdMvd(PxN6Ir!H4>PNlerpBL>Zvyy!yw z-SOo8caEpDt(}|gKPBd$qND5#a5nju^O>V&;f890?yEOfkSG^HQVmEbM3Ugzu+UtH zC(INPDdraBN?P%kE;*Ae%Wto&sgw(crfZ#Qy(<4nk;S|hD3j{IQRI6Yq|f^basLY; z-HB&Je%Gg}Jt@={_C{L$!RM;$$|iD6vu#3w?v?*;&()uB|I-XqEKqZPS!reW9JkLewLb!70T7n`i!gNtb1%vN- zySZj{8-1>6E%H&=V}LM#xmt`J3XQoaD|@XygXjdZ1+P77-=;=eYpoEQ01B@L*a(uW zrZeZz?HJsw_4g0vhUgkg@VF8<-X$B8pOqCuWAl28uB|@r`19DTUQQsb^pfqB6QtiT z*`_UZ`fT}vtUY#%sq2{rchyfu*pCg;uec2$-$N_xgjZcoumE5vSI{+s@iLWoz^Mf; zuI8kDP{!XY6OP~q5}%1&L}CtfH^N<3o4L@J@zg1-mt{9L`s^z$Vgb|mr{@WiwAqKg zp#t-lhrU>F8o0s1q_9y`gQNf~Vb!F%70f}$>i7o4ho$`uciNf=xgJ>&!gSt0g;M>*x4-`U)ysFW&Vs^Vk6m%?iuWU+o&m(2Jm26Y(3%TL; zA7T)BP{WS!&xmxNw%J=$MPfn(9*^*TV;$JwRy8Zl*yUZi8jWYF>==j~&S|Xinsb%c z2?B+kpet*muEW7@AzjBA^wAJBY8i|#C{WtO_or&Nj2{=6JTTX05}|H>N2B|Wf!*3_ z7hW*j6p3TvpghEc6-wufFiY!%-GvOx*bZrhZu+7?iSrZL5q9}igiF^*R3%DE4aCHZ zqu>xS8LkW+Auv%z-<1Xs92u23R$nk@Pk}MU5!gT|c7vGlEA%G^2th&Q*zfg%-D^=f z&J_}jskj|Q;73NP4<4k*Y%pXPU2Thoqr+5uH1yEYM|VtBPW6lXaetokD0u z9qVek6Q&wk)tFbQ8(^HGf3Wp16gKmr>G;#G(HRBx?F`9AIRboK+;OfHaLJ(P>IP0w zyTbTkx_THEOs%Q&aPrxbZrJlio+hCC_HK<4%f3ZoSAyG7Dn`=X=&h@m*|UYO-4Hq0 z-Bq&+Ie!S##4A6OGoC~>ZW`Y5J)*ouaFl_e9GA*VSL!O_@xGiBw!AF}1{tB)z(w%c zS1Hmrb9OC8>0a_$BzeiN?rkPLc9%&;1CZW*4}CDDNr2gcl_3z+WC15&H1Zc2{o~i) z)LLW=WQ{?ricmC`G1GfJ0Yp4Dy~Ba;j6ZV4r{8xRs`13{dD!xXmr^Aga|C=iSmor% z8hi|pTXH)5Yf&v~exp3o+sY4B^^b*eYkkCYl*T{*=-0HniSA_1F53eCb{x~1k3*`W zr~};p1A`k{1DV9=UPnLDgz{aJH=-LQo<5%+Em!DNN252xwIf*wF_zS^!(XSm(9eoj z=*dXG&n0>)_)N5oc6v!>-bd(2ragD8O=M|wGW z!xJQS<)u70m&6OmrF0WSsr@I%T*c#Qo#Ha4d3COcX+9}hM5!7JIGF>7<~C(Ear^Sn zm^ZFkV6~Ula6+8S?oOROOA6$C&q&dp`>oR-2Ym3(HT@O7Sd5c~+kjrmM)YmgPH*tL zX+znN>`tv;5eOfX?h{AuX^LK~V#gPCu=)Tigtq9&?7Xh$qN|%A$?V*v=&-2F$zTUv z`C#WyIrChS5|Kgm_GeudCFf;)!WH7FI60j^0o#65o6`w*S7R@)88n$1nrgU(oU0M9 zx+EuMkC>(4j1;m6NoGqEkpJYJ?vc|B zOlwT3t&UgL!pX_P*6g36`ZXQ; z9~Cv}ANFnJGp(;ZhS(@FT;3e)0)Kp;h^x;$*xZn*k0U6-&FwI=uOGaODdrsp-!K$Ac32^c{+FhI-HkYd5v=`PGsg%6I`4d9Jy)uW0y%) zm&j^9WBAp*P8#kGJUhB!L?a%h$hJgQrx!6KCB_TRo%9{t0J7KW8!o1B!NC)VGLM5! zpZy5Jc{`r{1e(jd%jsG7k%I+m#CGS*BPA65ZVW~fLYw0dA-H_}O zrkGFL&P1PG9p2(%QiEWm6x;U-U&I#;Em$nx-_I^wtgw3xUPVVu zqSuKnx&dIT-XT+T10p;yjo1Y)z(x1fb8Dzfn8e yu?e%!_ptzGB|8GrCfu%p?(_ zQccdaaVK$5bz;*rnyK{_SQYM>;aES6Qs^lj9lEs6_J+%nIiuQC*fN;z8md>r_~Mfl zU%p5Dt_YT>gQqfr@`cR!$NWr~+`CZb%dn;WtzrAOI>P_JtsB76PYe*<%H(y>qx-`Kq!X_; z<{RpAqYhE=L1r*M)gNF3B8r(<%8mo*SR2hu zccLRZwGARt)Hlo1euqTyM>^!HK*!Q2P;4UYrysje@;(<|$&%vQekbn|0Ruu_Io(w4#%p6ld2Yp7tlA`Y$cciThP zKzNGIMPXX%&Ud0uQh!uQZz|FB`4KGD?3!ND?wQt6!n*f4EmCoJUh&b?;B{|lxs#F- z31~HQ`SF4x$&v00@(P+j1pAaj5!s`)b2RDBp*PB=2IB>oBF!*6vwr7Dp%zpAx*dPr zb@Zjq^XjN?O4QcZ*O+8>)|HlrR>oD*?WQl5ri3R#2?*W6iJ>>kH%KnnME&TT@ZzrHS$Q%LC?n|e>V+D+8D zYc4)QddFz7I8#}y#Wj6>4P%34dZH~OUDb?uP%-E zwjXM(?Sg~1!|wI(RVuxbu)-rH+O=igSho_pDCw(c6b=P zKk4ATlB?bj9+HHlh<_!&z0rx13K3ZrAR8W)!@Y}o`?a*JJsD+twZIv`W)@Y?Amu_u zz``@-e2X}27$i(2=9rvIu5uTUOVhzwu%mNazS|lZb&PT;XE2|B&W1>=B58#*!~D&) zfVmJGg8UdP*fx(>Cj^?yS^zH#o-$Q-*$SnK(ZVFkw+er=>N^7!)FtP3y~Xxnu^nzY zikgB>Nj0%;WOltWIob|}%lo?_C7<``a5hEkx&1ku$|)i>Rh6@3h*`slY=9U}(Ql_< zaNG*J8vb&@zpdhAvv`?{=zDedJ23TD&Zg__snRAH4eh~^oawdYi6A3w8<Ozh@Kw)#bdktM^GVb zrG08?0bG?|NG+w^&JvD*7LAbjED{_Zkc`3H!My>0u5Q}m!+6VokMLXxl`Mkd=g&Xx z-a>m*#G3SLlhbKB!)tnzfWOBV;u;ftU}S!NdD5+YtOjLg?X}dl>7m^gOpihrf1;PY zvll&>dIuUGs{Qnd- zwIR3oIrct8Va^Tm0t#(bJD7c$Z7DO9*7NnRZorrSm`b`cxz>OIC;jSE3DO8`hX955ui`s%||YQtt2 z5DNA&pG-V+4oI2s*x^>-$6J?p=I>C|9wZF8z;VjR??Icg?1w2v5Me+FgAeGGa8(3S z4vg*$>zC-WIVZtJ7}o9{D-7d>zCe|z#<9>CFve-OPAYsneTb^JH!Enaza#j}^mXy1 z+ULn^10+rWLF6j2>Ya@@Kq?26>AqK{A_| zQKb*~F1>sE*=d?A?W7N2j?L09_7n+HGi{VY;MoTGr_)G9)ot$p!-UY5zZ2Xtbm=t z@dpPSGwgH=QtIcEulQNI>S-#ifbnO5EWkI;$A|pxJd885oM+ zGZ0_0gDvG8q2xebj+fbCHYfAXuZStH2j~|d^sBAzo46(K8n59+T6rzBwK)^rfPT+B zyIFw)9YC-V^rhtK`!3jrhmW-sTmM+tPH+;nwjL#-SjQPUZ53L@A>y*rt(#M(qsiB2 zx6B)dI}6Wlsw%bJ8h|(lhkJVogQZA&n{?Vgs6gNSXzuZpEyu*xySy8ro07QZ7Vk1!3tJphN_5V7qOiyK8p z#@jcDD8nmtYi1^l8ml;AF<#IPK?!pqf9D4moYk>d99Im}Jtwj6c#+A;f)CQ*f-hZ< z=p_T86jog%!p)D&5g9taSwYi&eP z#JuEK%+NULWus;0w32-SYFku#i}d~+{Pkho&^{;RxzP&0!RCm3-9K6`>KZpnzS6?L z^H^V*s!8<>x8bomvD%rh>Zp3>Db%kyin;qtl+jAv8Oo~1g~mqGAC&Qi_wy|xEt2iz zWAJEfTV%cl2Cs<1L&DLRVVH05EDq`pH7Oh7sR`NNkL%wi}8n>IXcO40hp+J+sC!W?!krJf!GJNE8uj zg-y~Ns-<~D?yqbzVRB}G>0A^f0!^N7l=$m0OdZuqAOQqLc zX?AEGr1Ht+inZ-Qiwnl@Z0qukd__a!C*CKuGdy5#nD7VUBM^6OCpxCa2A(X;e0&V4 zM&WR8+wErQ7UIc6LY~Q9x%Sn*Tn>>P`^t&idaOEnOd(Ufw#>NoR^1QdhJ8s`h^|R_ zXX`c5*O~Xdvh%q;7L!_!ohf$NfEBmCde|#uVZvEo>OfEq%+Ns7&_f$OR9xsihRpBb z+cjk8LyDm@U{YN>+r46?nn{7Gh(;WhFw6GAxtcKD+YWV?uge>;+q#Xx4!GpRkVZYu zzsF}1)7$?%s9g9CH=Zs+B%M_)+~*j3L0&Q9u7!|+T`^O{xE6qvAP?XWv9_MrZKdo& z%IyU)$Q95AB4!#hT!_dA>4e@zjOBD*Y=XjtMm)V|+IXzjuM;(l+8aA5#Kaz_$rR6! zj>#&^DidYD$nUY(D$mH`9eb|dtV0b{S>H6FBfq>t5`;OxA4Nn{J(+XihF(stSche7$es&~N$epi&PDM_N`As;*9D^L==2Q7Z2zD+CiU(|+-kL*VG+&9!Yb3LgPy?A zm7Z&^qRG_JIxK7-FBzZI3Q<;{`DIxtc48k> zc|0dmX;Z=W$+)qE)~`yn6MdoJ4co;%!`ddy+FV538Y)j(vg}5*k(WK)KWZ3WaOG!8 z!syGn=s{H$odtpqFrT#JGM*utN7B((abXnpDM6w56nhw}OY}0TiTG1#f*VFZr+^-g zbP10`$LPq_;PvrA1XXlyx2uM^mrjTzX}w{yuLo-cOClE8MMk47T25G8M!9Z5ypOSV zAJUBGEg5L2fY)ZGJb^E34R2zJ?}Vf>{~gB!8=5Z) z9y$>5c)=;o0HeHHSuE4U)#vG&KF|I%-cF6f$~pdYJWk_dD}iOA>iA$O$+4%@>JU08 zS`ep)$XLPJ+n0_i@PkF#ri6T8?ZeAot$6JIYHm&P6EB=BiaNY|aA$W0I+nz*zkz_z zkEru!tj!QUffq%)8y0y`T&`fuus-1p>=^hnBiBqD^hXrPs`PY9tU3m0np~rISY09> z`P3s=-kt_cYcxWd{de@}TwSqg*xVhp;E9zCsnXo6z z?f&Sv^U7n4`xr=mXle94HzOdN!2kB~4=%)u&N!+2;z6UYKUDqi-s6AZ!haB;@&B`? z_TRX0%@suz^TRdCb?!vNJYPY8L_}&07uySH9%W^Tc&1pia6y1q#?*Drf}GjGbPjBS zbOPcUY#*$3sL2x4v_i*Y=N7E$mR}J%|GUI(>WEr+28+V z%v5{#e!UF*6~G&%;l*q*$V?&r$Pp^sE^i-0$+RH3ERUUdQ0>rAq2(2QAbG}$y{de( z>{qD~GGuOk559Y@%$?N^1ApVL_a704>8OD%8Y%8B;FCt%AoPu8*D1 zLB5X>b}Syz81pn;xnB}%0FnwazlWfUV)Z-~rZg6~b z6!9J$EcE&sEbzcy?CI~=boWA&eeIa%z(7SE^qgVLz??1Vbc1*aRvc%Mri)AJaAG!p z$X!_9Ds;Zz)f+;%s&dRcJt2==P{^j3bf0M=nJd&xwUGlUFn?H=2W(*2I2Gdu zv!gYCwM10aeus)`RIZSrCK=&oKaO_Ry~D1B5!y0R=%!i2*KfXGYX&gNv_u+n9wiR5 z*e$Zjju&ODRW3phN925%S(jL+bCHv6rZtc?!*`1TyYXT6%Ju=|X;6D@lq$8T zW{Y|e39ioPez(pBH%k)HzFITXHvnD6hw^lIoUMA;qAJ^CU?top1fo@s7xT13Fvn1H z6JWa-6+FJF#x>~+A;D~;VDs26>^oH0EI`IYT2iagy23?nyJ==i{g4%HrAf1-*v zK1)~@&(KkwR7TL}L(A@C_S0G;-GMDy=MJn2$FP5s<%wC)4jC5PXoxrQBFZ_k0P{{s@sz+gX`-!=T8rcB(=7vW}^K6oLWMmp(rwDh}b zwaGGd>yEy6fHv%jM$yJXo5oMAQ>c9j`**}F?MCry;T@47@r?&sKHgVe$MCqk#Z_3S z1GZI~nOEN*P~+UaFGnj{{Jo@16`(qVNtbU>O0Hf57-P>x8Jikp=`s8xWs^dAJ9lCQ z)GFm+=OV%AMVqVATtN@|vp61VVAHRn87}%PC^RAzJ%JngmZTasWBAWsoAqBU+8L8u z4A&Pe?fmTm0?mK-BL9t+{y7o(7jm+RpOhL9KnY#E&qu^}B6=K_dB}*VlSEiC9fn)+V=J;OnN)Ta5v66ic1rG+dGAJ1 z1%Zb_+!$=tQ~lxQrzv3x#CPb?CekEkA}0MYSgx$Jdd}q8+R=ma$|&1a#)TQ=l$1tQ z=tL9&_^vJ)Pk}EDO-va`UCT1m#Uty1{v^A3P~83_#v^ozH}6*9mIjIr;t3Uv%@VeW zGL6(CwCUp)Jq%G0bIG%?{_*Y#5IHf*5M@wPo6A{$Um++Co$wLC=J1aoG93&T7Ho}P z=mGEPP7GbvoG!uD$k(H3A$Z))+i{Hy?QHdk>3xSBXR0j!11O^mEe9RHmw!pvzv?Ua~2_l2Yh~_!s1qS`|0~0)YsbHSz8!mG)WiJE| z2f($6TQtt6L_f~ApQYQKSb=`053LgrQq7G@98#igV>y#i==-nEjQ!XNu9 z~;mE+gtj4IDDNQJ~JVk5Ux6&LCSFL!y=>79kE9=V}J7tD==Ga+IW zX)r7>VZ9dY=V&}DR))xUoV!u(Z|%3ciQi_2jl}3=$Agc(`RPb z8kEBpvY>1FGQ9W$n>Cq=DIpski};nE)`p3IUw1Oz0|wxll^)4dq3;CCY@RyJgFgc# zKouFh!`?Xuo{IMz^xi-h=StCis_M7yq$u) z?XHvw*HP0VgR+KR6wI)jEMX|ssqYvSf*_3W8zVTQzD?3>H!#>InzpSO)@SC8q*ii- z%%h}_#0{4JG;Jm`4zg};BPTGkYamx$Xo#O~lBirRY)q=5M45n{GCfV7h9qwyu1NxOMoP4)jjZMxmT|IQQh0U7C$EbnMN<3)Kk?fFHYq$d|ICu>KbY_hO zTZM+uKHe(cIZfEqyzyYSUBZa8;Fcut-GN!HSA9ius`ltNebF46ZX_BbZNU}}ZOm{M2&nANL9@0qvih15(|`S~z}m&h!u4x~(%MAO$jHRWNfuxWF#B)E&g3ghSQ9|> z(MFaLQj)NE0lowyjvg8z0#m6FIuKE9lDO~Glg}nSb7`~^&#(Lw{}GVOS>U)m8bF}x zVjbXljBm34Cs-yM6TVusr+3kYFjr28STT3g056y3cH5Tmge~ASxBj z%|yb>$eF;WgrcOZf569sDZOVwoo%8>XO>XQOX1OyN9I-SQgrm;U;+#3OI(zrWyow3 zk==|{lt2xrQ%FIXOTejR>;wv(Pb8u8}BUpx?yd(Abh6? zsoO3VYWkeLnF43&@*#MQ9-i-d0t*xN-UEyNKeyNMHw|A(k(_6QKO=nKMCxD(W(Yop zsRQ)QeL4X3Lxp^L%wzi2-WVSsf61dqliPUM7srDB?Wm6Lzn0&{*}|IsKQW;02(Y&| zaTKv|`U(pSzuvR6Rduu$wzK_W-Y-7>7s?G$)U}&uK;<>vU}^^ns@Z!p+9?St1s)dG zK%y6xkPyyS1$~&6v{kl?Md6gwM|>mt6Upm>oa8RLD^8T{0?HC!Z>;(Bob7el(DV6x zi`I)$&E&ngwFS@bi4^xFLAn`=fzTC;aimE^!cMI2n@Vo%Ae-ne`RF((&5y6xsjjAZ zVguVoQ?Z9uk$2ON;ersE%PU*xGO@T*;j1BO5#TuZKEf(mB7|g7pcEA=nYJ{s3vlbg zd4-DUlD{*6o%Gc^N!Nptgay>j6E5;3psI+C3Q!1ZIbeCubW%w4pq9)MSDyB{HLm|k zxv-{$$A*pS@csolri$Ge<4VZ}e~78JOL-EVyrbxKra^d{?|NnPp86!q>t<&IP07?Z z^>~IK^k#OEKgRH+LjllZXk7iA>2cfH6+(e&9ku5poo~6y{GC5>(bRK7hwjiurqAiZ zg*DmtgY}v83IjE&AbiWgMyFbaRUPZ{lYiz$U^&Zt2YjG<%m((&_JUbZcfJ22(>bi5 z!J?<7AySj0JZ&<-qXX;mcV!f~>G=sB0KnjWca4}vrtunD^1TrpfeS^4dvFr!65knK zZh`d;*VOkPs4*-9kL>$GP0`(M!j~B;#x?Ba~&s6CopvO86oM?-? zOw#dIRc;6A6T?B`Qp%^<U5 z19x(ywSH$_N+Io!6;e?`tWaM$`=Db!gzx|lQ${DG!zb1Zl&|{kX0y6xvO1o z220r<-oaS^^R2pEyY;=Qllqpmue|5yI~D|iI!IGt@iod{Opz@*ml^w2bNs)p`M(Io z|E;;m*Xpjd9l)4G#KaWfV(t8YUn@A;nK^#xgv=LtnArX|vWQVuw3}B${h+frU2>9^ z!l6)!Uo4`5k`<<;E(ido7M6lKTgWezNLq>U*=uz&s=cc$1%>VrAeOoUtA|T6gO4>UNqsdK=NF*8|~*sl&wI=x9-EGiq*aqV!(VVXA57 zw9*o6Ir8Lj1npUXvlevtn(_+^X5rzdR>#(}4YcB9O50q97%rW2me5_L=%ffYPUSRc z!vv?Kv>dH994Qi>U(a<0KF6NH5b16enCp+mw^Hb3Xs1^tThFpz!3QuN#}KBbww`(h z7GO)1olDqy6?T$()R7y%NYx*B0k_2IBiZ14&8|JPFxeMF{vW>HF-Vi3+ZOI=+qP}n zw(+!WcTd~4ZJX1!ZM&y!+uyt=&i!+~d(V%GjH;-NsEEv6nS1TERt|RHh!0>W4+4pp z1-*EzAM~i`+1f(VEHI8So`S`akPfPTfq*`l{Fz`hS%k#JS0cjT2mS0#QLGf=J?1`he3W*;m4)ce8*WFq1sdP=~$5RlH1EdWm|~dCvKOi4*I_96{^95p#B<(n!d?B z=o`0{t+&OMwKcxiBECznJcfH!fL(z3OvmxP#oWd48|mMjpE||zdiTBdWelj8&Qosv zZFp@&UgXuvJw5y=q6*28AtxZzo-UUpkRW%ne+Ylf!V-0+uQXBW=5S1o#6LXNtY5!I z%Rkz#(S8Pjz*P7bqB6L|M#Er{|QLae-Y{KA>`^} z@lPjeX>90X|34S-7}ZVXe{wEei1<{*e8T-Nbj8JmD4iwcE+Hg_zhkPVm#=@b$;)h6 z<<6y`nPa`f3I6`!28d@kdM{uJOgM%`EvlQ5B2bL)Sl=|y@YB3KeOzz=9cUW3clPAU z^sYc}xf9{4Oj?L5MOlYxR{+>w=vJjvbyO5}ptT(o6dR|ygO$)nVCvNGnq(6;bHlBd zl?w-|plD8spjDF03g5ip;W3Z z><0{BCq!Dw;h5~#1BuQilq*TwEu)qy50@+BE4bX28+7erX{BD4H)N+7U`AVEuREE8 z;X?~fyhF-x_sRfHIj~6f(+^@H)D=ngP;mwJjxhQUbUdzk8f94Ab%59-eRIq?ZKrwD z(BFI=)xrUlgu(b|hAysqK<}8bslmNNeD=#JW*}^~Nrswn^xw*nL@Tx!49bfJecV&KC2G4q5a!NSv)06A_5N3Y?veAz;Gv+@U3R% z)~UA8-0LvVE{}8LVDOHzp~2twReqf}ODIyXMM6=W>kL|OHcx9P%+aJGYi_Om)b!xe zF40Vntn0+VP>o<$AtP&JANjXBn7$}C@{+@3I@cqlwR2MdwGhVPxlTIcRVu@Ho-wO` z_~Or~IMG)A_`6-p)KPS@cT9mu9RGA>dVh5wY$NM9-^c@N=hcNaw4ITjm;iWSP^ZX| z)_XpaI61<+La+U&&%2a z0za$)-wZP@mwSELo#3!PGTt$uy0C(nTT@9NX*r3Ctw6J~7A(m#8fE)0RBd`TdKfAT zCf@$MAxjP`O(u9s@c0Fd@|}UQ6qp)O5Q5DPCeE6mSIh|Rj{$cAVIWsA=xPKVKxdhg zLzPZ`3CS+KIO;T}0Ip!fAUaNU>++ZJZRk@I(h<)RsJUhZ&Ru9*!4Ptn;gX^~4E8W^TSR&~3BAZc#HquXn)OW|TJ`CTahk+{qe`5+ixON^zA9IFd8)kc%*!AiLu z>`SFoZ5bW-%7}xZ>gpJcx_hpF$2l+533{gW{a7ce^B9sIdmLrI0)4yivZ^(Vh@-1q zFT!NQK$Iz^xu%|EOK=n>ug;(7J4OnS$;yWmq>A;hsD_0oAbLYhW^1Vdt9>;(JIYjf zdb+&f&D4@4AS?!*XpH>8egQvSVX`36jMd>$+RgI|pEg))^djhGSo&#lhS~9%NuWfX zDDH;3T*GzRT@5=7ibO>N-6_XPBYxno@mD_3I#rDD?iADxX`! zh*v8^i*JEMzyN#bGEBz7;UYXki*Xr(9xXax(_1qVW=Ml)kSuvK$coq2A(5ZGhs_pF z$*w}FbN6+QDseuB9=fdp_MTs)nQf!2SlROQ!gBJBCXD&@-VurqHj0wm@LWX-TDmS= z71M__vAok|@!qgi#H&H%Vg-((ZfxPAL8AI{x|VV!9)ZE}_l>iWk8UPTGHs*?u7RfP z5MC&=c6X;XlUzrz5q?(!eO@~* zoh2I*%J7dF!!_!vXoSIn5o|wj1#_>K*&CIn{qSaRc&iFVxt*^20ngCL;QonIS>I5^ zMw8HXm>W0PGd*}Ko)f|~dDd%;Wu_RWI_d;&2g6R3S63Uzjd7dn%Svu-OKpx*o|N>F zZg=-~qLb~VRLpv`k zWSdfHh@?dp=s_X`{yxOlxE$4iuyS;Z-x!*E6eqmEm*j2bE@=ZI0YZ5%Yj29!5+J$4h{s($nakA`xgbO8w zi=*r}PWz#lTL_DSAu1?f%-2OjD}NHXp4pXOsCW;DS@BC3h-q4_l`<))8WgzkdXg3! zs1WMt32kS2E#L0p_|x+x**TFV=gn`m9BWlzF{b%6j-odf4{7a4y4Uaef@YaeuPhU8 zHBvRqN^;$Jizy+ z=zW{E5<>2gp$pH{M@S*!sJVQU)b*J5*bX4h>5VJve#Q6ga}cQ&iL#=(u+KroWrxa%8&~p{WEUF0il=db;-$=A;&9M{Rq`ouZ5m%BHT6%st%saGsD6)fQgLN}x@d3q>FC;=f%O3Cyg=Ke@Gh`XW za@RajqOE9UB6eE=zhG%|dYS)IW)&y&Id2n7r)6p_)vlRP7NJL(x4UbhlcFXWT8?K=%s7;z?Vjts?y2+r|uk8Wt(DM*73^W%pAkZa1Jd zNoE)8FvQA>Z`eR5Z@Ig6kS5?0h;`Y&OL2D&xnnAUzQz{YSdh0k zB3exx%A2TyI)M*EM6htrxSlep!Kk(P(VP`$p0G~f$smld6W1r_Z+o?=IB@^weq>5VYsYZZR@` z&XJFxd5{|KPZmVOSxc@^%71C@;z}}WhbF9p!%yLj3j%YOlPL5s>7I3vj25 z@xmf=*z%Wb4;Va6SDk9cv|r*lhZ`(y_*M@>q;wrn)oQx%B(2A$9(74>;$zmQ!4fN; z>XurIk-7@wZys<+7XL@0Fhe-f%*=(weaQEdR9Eh6>Kl-EcI({qoZqyzziGwpg-GM#251sK_ z=3|kitS!j%;fpc@oWn65SEL73^N&t>Ix37xgs= zYG%eQDJc|rqHFia0!_sm7`@lvcv)gfy(+KXA@E{3t1DaZ$DijWAcA)E0@X?2ziJ{v z&KOYZ|DdkM{}t+@{@*6ge}m%xfjIxi%qh`=^2Rwz@w0cCvZ&Tc#UmCDbVwABrON^x zEBK43FO@weA8s7zggCOWhMvGGE`baZ62cC)VHyy!5Zbt%ieH+XN|OLbAFPZWyC6)p z4P3%8sq9HdS3=ih^0OOlqTPbKuzQ?lBEI{w^ReUO{V?@`ARsL|S*%yOS=Z%sF)>-y z(LAQdhgAcuF6LQjRYfdbD1g4o%tV4EiK&ElLB&^VZHbrV1K>tHTO{#XTo>)2UMm`2 z^t4s;vnMQgf-njU-RVBRw0P0-m#d-u`(kq7NL&2T)TjI_@iKuPAK-@oH(J8?%(e!0Ir$yG32@CGUPn5w4)+9@8c&pGx z+K3GKESI4*`tYlmMHt@br;jBWTei&(a=iYslc^c#RU3Q&sYp zSG){)V<(g7+8W!Wxeb5zJb4XE{I|&Y4UrFWr%LHkdQ;~XU zgy^dH-Z3lmY+0G~?DrC_S4@=>0oM8Isw%g(id10gWkoz2Q%7W$bFk@mIzTCcIB(K8 zc<5h&ZzCdT=9n-D>&a8vl+=ZF*`uTvQviG_bLde*k>{^)&0o*b05x$MO3gVLUx`xZ z43j+>!u?XV)Yp@MmG%Y`+COH2?nQcMrQ%k~6#O%PeD_WvFO~Kct za4XoCM_X!c5vhRkIdV=xUB3xI2NNStK*8_Zl!cFjOvp-AY=D;5{uXj}GV{LK1~IE2 z|KffUiBaStRr;10R~K2VVtf{TzM7FaPm;Y(zQjILn+tIPSrJh&EMf6evaBKIvi42-WYU9Vhj~3< zZSM-B;E`g_o8_XTM9IzEL=9Lb^SPhe(f(-`Yh=X6O7+6ALXnTcUFpI>ekl6v)ZQeNCg2 z^H|{SKXHU*%nBQ@I3It0m^h+6tvI@FS=MYS$ZpBaG7j#V@P2ZuYySbp@hA# ze(kc;P4i_-_UDP?%<6>%tTRih6VBgScKU^BV6Aoeg6Uh(W^#J^V$Xo^4#Ekp ztqQVK^g9gKMTHvV7nb64UU7p~!B?>Y0oFH5T7#BSW#YfSB@5PtE~#SCCg3p^o=NkMk$<8- z6PT*yIKGrvne7+y3}_!AC8NNeI?iTY(&nakN>>U-zT0wzZf-RuyZk^X9H-DT_*wk= z;&0}6LsGtfVa1q)CEUPlx#(ED@-?H<1_FrHU#z5^P3lEB|qsxEyn%FOpjx z3S?~gvoXy~L(Q{Jh6*i~=f%9kM1>RGjBzQh_SaIDfSU_9!<>*Pm>l)cJD@wlyxpBV z4Fmhc2q=R_wHCEK69<*wG%}mgD1=FHi4h!98B-*vMu4ZGW~%IrYSLGU{^TuseqVgV zLP<%wirIL`VLyJv9XG_p8w@Q4HzNt-o;U@Au{7%Ji;53!7V8Rv0^Lu^Vf*sL>R(;c zQG_ZuFl)Mh-xEIkGu}?_(HwkB2jS;HdPLSxVU&Jxy9*XRG~^HY(f0g8Q}iqnVmgjI zfd=``2&8GsycjR?M%(zMjn;tn9agcq;&rR!Hp z$B*gzHsQ~aXw8c|a(L^LW(|`yGc!qOnV(ZjU_Q-4z1&0;jG&vAKuNG=F|H?@m5^N@ zq{E!1n;)kNTJ>|Hb2ODt-7U~-MOIFo%9I)_@7fnX+eMMNh>)V$IXesJpBn|uo8f~#aOFytCT zf9&%MCLf8mp4kwHTcojWmM3LU=#|{3L>E}SKwOd?%{HogCZ_Z1BSA}P#O(%H$;z7XyJ^sjGX;j5 zrzp>|Ud;*&VAU3x#f{CKwY7Vc{%TKKqmB@oTHA9;>?!nvMA;8+Jh=cambHz#J18x~ zs!dF>$*AnsQ{{82r5Aw&^7eRCdvcgyxH?*DV5(I$qXh^zS>us*I66_MbL8y4d3ULj z{S(ipo+T3Ag!+5`NU2sc+@*m{_X|&p#O-SAqF&g_n7ObB82~$p%fXA5GLHMC+#qqL zdt`sJC&6C2)=juQ_!NeD>U8lDVpAOkW*khf7MCcs$A(wiIl#B9HM%~GtQ^}yBPjT@ z+E=|A!Z?A(rwzZ;T}o6pOVqHzTr*i;Wrc%&36kc@jXq~+w8kVrs;%=IFdACoLAcCAmhFNpbP8;s`zG|HC2Gv?I~w4ITy=g$`0qMQdkijLSOtX6xW%Z9Nw<;M- zMN`c7=$QxN00DiSjbVt9Mi6-pjv*j(_8PyV-il8Q-&TwBwH1gz1uoxs6~uU}PrgWB zIAE_I-a1EqlIaGQNbcp@iI8W1sm9fBBNOk(k&iLBe%MCo#?xI$%ZmGA?=)M9D=0t7 zc)Q0LnI)kCy{`jCGy9lYX%mUsDWwsY`;jE(;Us@gmWPqjmXL+Hu#^;k%eT>{nMtzj zsV`Iy6leTA8-PndszF;N^X@CJrTw5IIm!GPeu)H2#FQitR{1p;MasQVAG3*+=9FYK zw*k!HT(YQorfQj+1*mCV458(T5=fH`um$gS38hw(OqVMyunQ;rW5aPbF##A3fGH6h z@W)i9Uff?qz`YbK4c}JzQpuxuE3pcQO)%xBRZp{zJ^-*|oryTxJ-rR+MXJ)!f=+pp z10H|DdGd2exhi+hftcYbM0_}C0ZI-2vh+$fU1acsB-YXid7O|=9L!3e@$H*6?G*Zp z%qFB(sgl=FcC=E4CYGp4CN>=M8#5r!RU!u+FJVlH6=gI5xHVD&k;Ta*M28BsxfMV~ zLz+@6TxnfLhF@5=yQo^1&S}cmTN@m!7*c6z;}~*!hNBjuE>NLVl2EwN!F+)0$R1S! zR|lF%n!9fkZ@gPW|x|B={V6x3`=jS*$Pu0+5OWf?wnIy>Y1MbbGSncpKO0qE(qO=ts z!~@&!N`10S593pVQu4FzpOh!tvg}p%zCU(aV5=~K#bKi zHdJ1>tQSrhW%KOky;iW+O_n;`l9~omqM%sdxdLtI`TrJzN6BQz+7xOl*rM>xVI2~# z)7FJ^Dc{DC<%~VS?@WXzuOG$YPLC;>#vUJ^MmtbSL`_yXtNKa$Hk+l-c!aC7gn(Cg ze?YPYZ(2Jw{SF6MiO5(%_pTo7j@&DHNW`|lD`~{iH+_eSTS&OC*2WTT*a`?|9w1dh zh1nh@$a}T#WE5$7Od~NvSEU)T(W$p$s5fe^GpG+7fdJ9=enRT9$wEk+ZaB>G3$KQO zgq?-rZZnIv!p#>Ty~}c*Lb_jxJg$eGM*XwHUwuQ|o^}b3^T6Bxx{!?va8aC@-xK*H ztJBFvFfsSWu89%@b^l3-B~O!CXs)I6Y}y#0C0U0R0WG zybjroj$io0j}3%P7zADXOwHwafT#uu*zfM!oD$6aJx7+WL%t-@6^rD_a_M?S^>c;z zMK580bZXo1f*L$CuMeM4Mp!;P@}b~$cd(s5*q~FP+NHSq;nw3fbWyH)i2)-;gQl{S zZO!T}A}fC}vUdskGSq&{`oxt~0i?0xhr6I47_tBc`fqaSrMOzR4>0H^;A zF)hX1nfHs)%Zb-(YGX;=#2R6C{BG;k=?FfP?9{_uFLri~-~AJ;jw({4MU7e*d)?P@ zXX*GkNY9ItFjhwgAIWq7Y!ksbMzfqpG)IrqKx9q{zu%Mdl+{Dis#p9q`02pr1LG8R z@As?eG!>IoROgS!@J*to<27coFc1zpkh?w=)h9CbYe%^Q!Ui46Y*HO0mr% zEff-*$ndMNw}H2a5@BsGj5oFfd!T(F&0$<{GO!Qdd?McKkorh=5{EIjDTHU`So>8V zBA-fqVLb2;u7UhDV1xMI?y>fe3~4urv3%PX)lDw+HYa;HFkaLqi4c~VtCm&Ca+9C~ zge+67hp#R9`+Euq59WhHX&7~RlXn=--m8$iZ~~1C8cv^2(qO#X0?vl91gzUKBeR1J z^p4!!&7)3#@@X&2aF2-)1Ffcc^F8r|RtdL2X%HgN&XU-KH2SLCbpw?J5xJ*!F-ypZ zMG%AJ!Pr&}`LW?E!K~=(NJxuSVTRCGJ$2a*Ao=uUDSys!OFYu!Vs2IT;xQ6EubLIl z+?+nMGeQQhh~??0!s4iQ#gm3!BpMpnY?04kK375e((Uc7B3RMj;wE?BCoQGu=UlZt!EZ1Q*auI)dj3Jj{Ujgt zW5hd~-HWBLI_3HuO) zNrb^XzPsTIb=*a69wAAA3J6AAZZ1VsYbIG}a`=d6?PjM)3EPaDpW2YP$|GrBX{q*! z$KBHNif)OKMBCFP5>!1d=DK>8u+Upm-{hj5o|Wn$vh1&K!lVfDB&47lw$tJ?d5|=B z^(_9=(1T3Fte)z^>|3**n}mIX;mMN5v2F#l(q*CvU{Ga`@VMp#%rQkDBy7kYbmb-q z<5!4iuB#Q_lLZ8}h|hPODI^U6`gzLJre9u3k3c#%86IKI*^H-@I48Bi*@avYm4v!n0+v zWu{M{&F8#p9cx+gF0yTB_<2QUrjMPo9*7^-uP#~gGW~y3nfPAoV%amgr>PSyVAd@l)}8#X zR5zV6t*uKJZL}?NYvPVK6J0v4iVpwiN|>+t3aYiZSp;m0!(1`bHO}TEtWR1tY%BPB z(W!0DmXbZAsT$iC13p4f>u*ZAy@JoLAkJhzFf1#4;#1deO8#8d&89}en&z!W&A3++^1(;>0SB1*54d@y&9Pn;^IAf3GiXbfT`_>{R+Xv; zQvgL>+0#8-laO!j#-WB~(I>l0NCMt_;@Gp_f0#^c)t?&#Xh1-7RR0@zPyBz!U#0Av zT?}n({(p?p7!4S2ZBw)#KdCG)uPnZe+U|0{BW!m)9 zi_9$F?m<`2!`JNFv+w8MK_K)qJ^aO@7-Ig>cM4-r0bi=>?B_2mFNJ}aE3<+QCzRr*NA!QjHw# z`1OsvcoD0?%jq{*7b!l|L1+Tw0TTAM4XMq7*ntc-Ived>Sj_ZtS|uVdpfg1_I9knY z2{GM_j5sDC7(W&}#s{jqbybqJWyn?{PW*&cQIU|*v8YGOKKlGl@?c#TCnmnAkAzV- zmK={|1G90zz=YUvC}+fMqts0d4vgA%t6Jhjv?d;(Z}(Ep8fTZfHA9``fdUHkA+z3+ zhh{ohP%Bj?T~{i0sYCQ}uC#5BwN`skI7`|c%kqkyWIQ;!ysvA8H`b-t()n6>GJj6xlYDu~8qX{AFo$Cm3d|XFL=4uvc?Keb zzb0ZmMoXca6Mob>JqkNuoP>B2Z>D`Q(TvrG6m`j}-1rGP!g|qoL=$FVQYxJQjFn33lODt3Wb1j8VR zlR++vIT6^DtYxAv_hxupbLLN3e0%A%a+hWTKDV3!Fjr^cWJ{scsAdfhpI)`Bms^M6 zQG$waKgFr=c|p9Piug=fcJvZ1ThMnNhQvBAg-8~b1?6wL*WyqXhtj^g(Ke}mEfZVM zJuLNTUVh#WsE*a6uqiz`b#9ZYg3+2%=C(6AvZGc=u&<6??!slB1a9K)=VL zY9EL^mfyKnD zSJyYBc_>G;5RRnrNgzJz#Rkn3S1`mZgO`(r5;Hw6MveN(URf_XS-r58Cn80K)ArH4 z#Rrd~LG1W&@ttw85cjp8xV&>$b%nSXH_*W}7Ch2pg$$c0BdEo-HWRTZcxngIBJad> z;C>b{jIXjb_9Jis?NZJsdm^EG}e*pR&DAy0EaSGi3XWTa(>C%tz1n$u?5Fb z1qtl?;_yjYo)(gB^iQq?=jusF%kywm?CJP~zEHi0NbZ);$(H$w(Hy@{i>$wcVRD_X|w-~(0Z9BJyh zhNh;+eQ9BEIs;tPz%jSVnfCP!3L&9YtEP;svoj_bNzeGSQIAjd zBss@A;)R^WAu-37RQrM%{DfBNRx>v!G31Z}8-El9IOJlb_MSoMu2}GDYycNaf>uny z+8xykD-7ONCM!APry_Lw6-yT>5!tR}W;W`C)1>pxSs5o1z#j7%m=&=7O4hz+Lsqm` z*>{+xsabZPr&X=}G@obTb{nPTkccJX8w3CG7X+1+t{JcMabv~UNv+G?txRqXib~c^Mo}`q{$`;EBNJ;#F*{gvS12kV?AZ%O0SFB$^ zn+}!HbmEj}w{Vq(G)OGAzH}R~kS^;(-s&=ectz8vN!_)Yl$$U@HNTI-pV`LSj7Opu zTZ5zZ)-S_{GcEQPIQXLQ#oMS`HPu{`SQiAZ)m1at*Hy%3xma|>o`h%E%8BEbi9p0r zVjcsh<{NBKQ4eKlXU|}@XJ#@uQw*$4BxKn6#W~I4T<^f99~(=}a`&3(ur8R9t+|AQ zWkQx7l}wa48-jO@ft2h+7qn%SJtL%~890FG0s5g*kNbL3I&@brh&f6)TlM`K^(bhr zJWM6N6x3flOw$@|C@kPi7yP&SP?bzP-E|HSXQXG>7gk|R9BTj`e=4de9C6+H7H7n# z#GJeVs1mtHhLDmVO?LkYRQc`DVOJ_vdl8VUihO-j#t=0T3%Fc1f9F73ufJz*adn*p zc%&vi(4NqHu^R>sAT_0EDjVR8bc%wTz#$;%NU-kbDyL_dg0%TFafZwZ?5KZpcuaO54Z9hX zD$u>q!-9`U6-D`E#`W~fIfiIF5_m6{fvM)b1NG3xf4Auw;Go~Fu7cth#DlUn{@~yu z=B;RT*dp?bO}o%4x7k9v{r=Y@^YQ^UUm(Qmliw8brO^=NP+UOohLYiaEB3^DB56&V zK?4jV61B|1Uj_5fBKW;8LdwOFZKWp)g{B%7g1~DgO&N& z#lisxf?R~Z@?3E$Mms$$JK8oe@X`5m98V*aV6Ua}8Xs2#A!{x?IP|N(%nxsH?^c{& z@vY&R1QmQs83BW28qAmJfS7MYi=h(YK??@EhjL-t*5W!p z^gYX!Q6-vBqcv~ruw@oMaU&qp0Fb(dbVzm5xJN%0o_^@fWq$oa3X?9s%+b)x4w-q5Koe(@j6Ez7V@~NRFvd zfBH~)U5!ix3isg`6be__wBJp=1@yfsCMw1C@y+9WYD9_C%{Q~7^0AF2KFryfLlUP# zwrtJEcH)jm48!6tUcxiurAMaiD04C&tPe6DI0#aoqz#Bt0_7_*X*TsF7u*zv(iEfA z;$@?XVu~oX#1YXtceQL{dSneL&*nDug^OW$DSLF0M1Im|sSX8R26&)<0Fbh^*l6!5wfSu8MpMoh=2l z^^0Sr$UpZp*9oqa23fcCfm7`ya2<4wzJ`Axt7e4jJrRFVf?nY~2&tRL* zd;6_njcz01c>$IvN=?K}9ie%Z(BO@JG2J}fT#BJQ+f5LFSgup7i!xWRKw6)iITjZU z%l6hPZia>R!`aZjwCp}I zg)%20;}f+&@t;(%5;RHL>K_&7MH^S+7<|(SZH!u zznW|jz$uA`P9@ZWtJgv$EFp>)K&Gt+4C6#*khZQXS*S~6N%JDT$r`aJDs9|uXWdbg zBwho$phWx}x!qy8&}6y5Vr$G{yGSE*r$^r{}pw zVTZKvikRZ`J_IJrjc=X1uw?estdwm&bEahku&D04HD+0Bm~q#YGS6gp!KLf$A{%Qd z&&yX@Hp>~(wU{|(#U&Bf92+1i&Q*-S+=y=3pSZy$#8Uc$#7oiJUuO{cE6=tsPhwPe| zxQpK>`Dbka`V)$}e6_OXKLB%i76~4N*zA?X+PrhH<&)}prET;kel24kW%+9))G^JI zsq7L{P}^#QsZViX%KgxBvEugr>ZmFqe^oAg?{EI=&_O#e)F3V#rc z8$4}0Zr19qd3tE4#$3_f=Bbx9oV6VO!d3(R===i-7p=Vj`520w0D3W6lQfY48}!D* z&)lZMG;~er2qBoI2gsX+Ts-hnpS~NYRDtPd^FPzn!^&yxRy#CSz(b&E*tL|jIkq|l zf%>)7Dtu>jCf`-7R#*GhGn4FkYf;B$+9IxmqH|lf6$4irg{0ept__%)V*R_OK=T06 zyT_m-o@Kp6U{l5h>W1hGq*X#8*y@<;vsOFqEjTQXFEotR+{3}ODDnj;o0@!bB5x=N z394FojuGOtVKBlVRLtHp%EJv_G5q=AgF)SKyRN5=cGBjDWv4LDn$IL`*=~J7u&Dy5 zrMc83y+w^F&{?X(KOOAl-sWZDb{9X9#jrQtmrEXD?;h-}SYT7yM(X_6qksM=K_a;Z z3u0qT0TtaNvDER_8x*rxXw&C^|h{P1qxK|@pS7vdlZ#P z7PdB7MmC2}%sdzAxt>;WM1s0??`1983O4nFK|hVAbHcZ3x{PzytQLkCVk7hA!Lo` zEJH?4qw|}WH{dc4z%aB=0XqsFW?^p=X}4xnCJXK%c#ItOSjdSO`UXJyuc8bh^Cf}8 z@Ht|vXd^6{Fgai8*tmyRGmD_s_nv~r^Fy7j`Bu`6=G)5H$i7Q7lvQnmea&TGvJp9a|qOrUymZ$6G|Ly z#zOCg++$3iB$!6!>215A4!iryregKuUT344X)jQb3|9qY>c0LO{6Vby05n~VFzd?q zgGZv&FGlkiH*`fTurp>B8v&nSxNz)=5IF$=@rgND4d`!AaaX;_lK~)-U8la_Wa8i?NJC@BURO*sUW)E9oyv3RG^YGfN%BmxzjlT)bp*$<| zX3tt?EAy<&K+bhIuMs-g#=d1}N_?isY)6Ay$mDOKRh z4v1asEGWoAp=srraLW^h&_Uw|6O+r;wns=uwYm=JN4Q!quD8SQRSeEcGh|Eb5Jg8m zOT}u;N|x@aq)=&;wufCc^#)5U^VcZw;d_wwaoh9$p@Xrc{DD6GZUqZ ziC6OT^zSq@-lhbgR8B+e;7_Giv;DK5gn^$bs<6~SUadiosfewWDJu`XsBfOd1|p=q zE>m=zF}!lObA%ePey~gqU8S6h-^J2Y?>7)L2+%8kV}Gp=h`Xm_}rlm)SyUS=`=S7msKu zC|T!gPiI1rWGb1z$Md?0YJQ;%>uPLOXf1Z>N~`~JHJ!^@D5kSXQ4ugnFZ>^`zH8CAiZmp z6Ms|#2gcGsQ{{u7+Nb9sA?U>(0e$5V1|WVwY`Kn)rsnnZ4=1u=7u!4WexZD^IQ1Jk zfF#NLe>W$3m&C^ULjdw+5|)-BSHwpegdyt9NYC{3@QtMfd8GrIWDu`gd0nv-3LpGCh@wgBaG z176tikL!_NXM+Bv#7q^cyn9$XSeZR6#!B4JE@GVH zoobHZN_*RF#@_SVYKkQ_igme-Y5U}cV(hkR#k1c{bQNMji zU7aE`?dHyx=1`kOYZo_8U7?3-7vHOp`Qe%Z*i+FX!s?6huNp0iCEW-Z7E&jRWmUW_ z67j>)Ew!yq)hhG4o?^z}HWH-e=es#xJUhDRc4B51M4~E-l5VZ!&zQq`gWe`?}#b~7w1LH4Xa-UCT5LXkXQWheBa2YJYbyQ zl1pXR%b(KCXMO0OsXgl0P0Og<{(@&z1aokU-Pq`eQq*JYgt8xdFQ6S z6Z3IFSua8W&M#`~*L#r>Jfd6*BzJ?JFdBR#bDv$_0N!_5vnmo@!>vULcDm`MFU823 zpG9pqjqz^FE5zMDoGqhs5OMmC{Y3iVcl>F}5Rs24Y5B^mYQ;1T&ks@pIApHOdrzXF z-SdX}Hf{X;TaSxG_T$0~#RhqKISGKNK47}0*x&nRIPtmdwxc&QT3$8&!3fWu1eZ_P zJveQj^hJL#Sn!*4k`3}(d(aasl&7G0j0-*_2xtAnoX1@9+h zO#c>YQg60Z;o{Bi=3i7S`Ic+ZE>K{(u|#)9y}q*j8uKQ1^>+(BI}m%1v3$=4ojGBc zm+o1*!T&b}-lVvZqIUBc8V}QyFEgm#oyIuC{8WqUNV{Toz`oxhYpP!_p2oHHh5P@iB*NVo~2=GQm+8Yrkm2Xjc_VyHg1c0>+o~@>*Qzo zHVBJS>$$}$_4EniTI;b1WShX<5-p#TPB&!;lP!lBVBbLOOxh6FuYloD%m;n{r|;MU3!q4AVkua~fieeWu2 zQAQ$ue(IklX6+V;F1vCu-&V?I3d42FgWgsb_e^29ol}HYft?{SLf>DrmOp9o!t>I^ zY7fBCk+E8n_|apgM|-;^=#B?6RnFKlN`oR)`e$+;D=yO-(U^jV;rft^G_zl`n7qnM zL z*-Y4Phq+ZI1$j$F-f;`CD#|`-T~OM5Q>x}a>B~Gb3-+9i>Lfr|Ca6S^8g*{*?_5!x zH_N!SoRP=gX1?)q%>QTY!r77e2j9W(I!uAz{T`NdNmPBBUzi2{`XMB^zJGGwFWeA9 z{fk33#*9SO0)DjROug+(M)I-pKA!CX;IY(#gE!UxXVsa)X!UftIN98{pt#4MJHOhY zM$_l}-TJlxY?LS6Nuz1T<44m<4i^8k@D$zuCPrkmz@sdv+{ciyFJG2Zwy&%c7;atIeTdh!a(R^QXnu1Oq1b42*OQFWnyQ zWeQrdvP|w_idy53Wa<{QH^lFmEd+VlJkyiC>6B#s)F;w-{c;aKIm;Kp50HnA-o3lY z9B~F$gJ@yYE#g#X&3ADx&tO+P_@mnQTz9gv30_sTsaGXkfNYXY{$(>*PEN3QL>I!k zp)KibPhrfX3%Z$H6SY`rXGYS~143wZrG2;=FLj50+VM6soI~up_>fU(2Wl@{BRsMi zO%sL3x?2l1cXTF)k&moNsHfQrQ+wu(gBt{sk#CU=UhrvJIncy@tJX5klLjgMn>~h= zg|FR&;@eh|C7`>s_9c~0-{IAPV){l|Ts`i=)AW;d9&KPc3fMeoTS%8@V~D8*h;&(^>yjT84MM}=%#LS7shLAuuj(0VAYoozhWjq z4LEr?wUe2^WGwdTIgWBkDUJa>YP@5d9^Rs$kCXmMRxuF*YMVrn?0NFyPl}>`&dqZb z<5eqR=ZG3>n2{6v6BvJ`YBZeeTtB88TAY(x0a58EWyuf>+^|x8Qa6wA|1Nb_p|nA zWWa}|z8a)--Wj`LqyFk_a3gN2>5{Rl_wbW?#by7&i*^hRknK%jwIH6=dQ8*-_{*x0j^DUfMX0`|K@6C<|1cgZ~D(e5vBFFm;HTZF(!vT8=T$K+|F)x3kqzBV4-=p1V(lzi(s7jdu0>LD#N=$Lk#3HkG!a zIF<7>%B7sRNzJ66KrFV76J<2bdYhxll0y2^_rdG=I%AgW4~)1Nvz=$1UkE^J%BxLo z+lUci`UcU062os*=`-j4IfSQA{w@y|3}Vk?i;&SSdh8n+$iHA#%ERL{;EpXl6u&8@ zzg}?hkEOUOJt?ZL=pWZFJ19mI1@P=$U5*Im1e_8Z${JsM>Ov?nh8Z zP5QvI!{Jy@&BP48%P2{Jr_VgzW;P@7)M9n|lDT|Ep#}7C$&ud&6>C^5ZiwKIg2McPU(4jhM!BD@@L(Gd*Nu$ji(ljZ<{FIeW_1Mmf;76{LU z-ywN~=uNN)Xi6$<12A9y)K%X|(W0p|&>>4OXB?IiYr||WKDOJPxiSe01NSV-h24^L z_>m$;|C+q!Mj**-qQ$L-*++en(g|hw;M!^%_h-iDjFHLo-n3JpB;p?+o2;`*jpvJU zLY^lt)Un4joij^^)O(CKs@7E%*!w>!HA4Q?0}oBJ7Nr8NQ7QmY^4~jvf0-`%waOLn zdNjAPaC0_7c|RVhw)+71NWjRi!y>C+Bl;Z`NiL^zn2*0kmj5gyhCLCxts*cWCdRI| zjsd=sT5BVJc^$GxP~YF$-U{-?kW6r@^vHXB%{CqYzU@1>dzf#3SYedJG-Rm6^RB7s zGM5PR(yKPKR)>?~vpUIeTP7A1sc8-knnJk*9)3t^e%izbdm>Y=W{$wm(cy1RB-19i za#828DMBY+ps#7Y8^6t)=Ea@%Nkt)O6JCx|ybC;Ap}Z@Zw~*}3P>MZLPb4Enxz9Wf zssobT^(R@KuShj8>@!1M7tm|2%-pYYDxz-5`rCbaTCG5{;Uxm z*g=+H1X8{NUvFGzz~wXa%Eo};I;~`37*WrRU&K0dPSB$yk(Z*@K&+mFal^?c zurbqB-+|Kb5|sznT;?Pj!+kgFY1#Dr;_%A(GIQC{3ct|{*Bji%FNa6c-thbpBkA;U zURV!Dr&X{0J}iht#-Qp2=xzuh(fM>zRoiGrYl5ttw2#r34gC41CCOC31m~^UPTK@s z6;A@)7O7_%C)>bnAXerYuAHdE93>j2N}H${zEc6&SbZ|-fiG*-qtGuy-qDelH(|u$ zorf8_T6Zqe#Ub!+e3oSyrskt_HyW_^5lrWt#30l)tHk|j$@YyEkXUOV;6B51L;M@=NIWZXU;GrAa(LGxO%|im%7F<-6N;en0Cr zLH>l*y?pMwt`1*cH~LdBPFY_l;~`N!Clyfr;7w<^X;&(ZiVdF1S5e(+Q%60zgh)s4 zn2yj$+mE=miVERP(g8}G4<85^-5f@qxh2ec?n+$A_`?qN=iyT1?U@t?V6DM~BIlBB z>u~eXm-aE>R0sQy!-I4xtCNi!!qh?R1!kKf6BoH2GG{L4%PAz0{Sh6xpuyI%*~u)s z%rLuFl)uQUCBQAtMyN;%)zFMx4loh7uTfKeB2Xif`lN?2gq6NhWhfz0u5WP9J>=V2 zo{mLtSy&BA!mSzs&CrKWq^y40JF5a&GSXIi2= z{EYb59J4}VwikL4P=>+mc6{($FNE@e=VUwG+KV21;<@lrN`mnz5jYGASyvz7BOG_6(p^eTxD-4O#lROgon;R35=|nj#eHIfJBYPWG>H>`dHKCDZ3`R{-?HO0mE~(5_WYcFmp8sU?wr*UkAQiNDGc6T zA%}GOLXlOWqL?WwfHO8MB#8M8*~Y*gz;1rWWoVSXP&IbKxbQ8+s%4Jnt?kDsq7btI zCDr0PZ)b;B%!lu&CT#RJzm{l{2fq|BcY85`w~3LSK<><@(2EdzFLt9Y_`;WXL6x`0 zDoQ?=?I@Hbr;*VVll1Gmd8*%tiXggMK81a+T(5Gx6;eNb8=uYn z5BG-0g>pP21NPn>$ntBh>`*})Fl|38oC^9Qz>~MAazH%3Q~Qb!ALMf$srexgPZ2@&c~+hxRi1;}+)-06)!#Mq<6GhP z-Q?qmgo${aFBApb5p}$1OJKTClfi8%PpnczyVKkoHw7Ml9e7ikrF0d~UB}i3vizos zXW4DN$SiEV9{faLt5bHy2a>33K%7Td-n5C*N;f&ZqAg#2hIqEb(y<&f4u5BWJ>2^4 z414GosL=Aom#m&=x_v<0-fp1r%oVJ{T-(xnomNJ(Dryv zh?vj+%=II_nV+@NR+(!fZZVM&(W6{6%9cm+o+Z6}KqzLw{(>E86uA1`_K$HqINlb1 zKelh3-jr2I9V?ych`{hta9wQ2c9=MM`2cC{m6^MhlL2{DLv7C^j z$xXBCnDl_;l|bPGMX@*tV)B!c|4oZyftUlP*?$YU9C_eAsuVHJ58?)zpbr30P*C`T z7y#ao`uE-SOG(Pi+`$=e^mle~)pRrdwL5)N;o{gpW21of(QE#U6w%*C~`v-z0QqBML!!5EeYA5IQB0 z^l01c;L6E(iytN!LhL}wfwP7W9PNAkb+)Cst?qg#$n;z41O4&v+8-zPs+XNb-q zIeeBCh#ivnFLUCwfS;p{LC0O7tm+Sf9Jn)~b%uwP{%69;QC)Ok0t%*a5M+=;y8j=v z#!*pp$9@!x;UMIs4~hP#pnfVc!%-D<+wsG@R2+J&%73lK|2G!EQC)O05TCV=&3g)C!lT=czLpZ@Sa%TYuoE?v8T8`V;e$#Zf2_Nj6nvBgh1)2 GZ~q4|mN%#X literal 55190 zcmafaW0WS*vSoFbZQHhO+s0S6%`V%vZQJa!ZQHKus_B{g-pt%P_q|ywBQt-*Stldc z$+IJ3?^KWm27v+sf`9-50uuadKtMnL*BJ;1^6ynvR7H?hQcjE>7)art9Bu0Pcm@7C z@c%WG|JzYkP)<@zR9S^iR_sA`azaL$mTnGKnwDyMa;8yL_0^>Ba^)phg0L5rOPTbm7g*YIRLg-2^{qe^`rb!2KqS zk~5wEJtTdD?)3+}=eby3x6%i)sb+m??NHC^u=tcG8p$TzB<;FL(WrZGV&cDQb?O0GMe6PBV=V z?tTO*5_HTW$xea!nkc~Cnx#cL_rrUGWPRa6l+A{aiMY=<0@8y5OC#UcGeE#I>nWh}`#M#kIn-$A;q@u-p71b#hcSItS!IPw?>8 zvzb|?@Ahb22L(O4#2Sre&l9H(@TGT>#Py)D&eW-LNb!=S;I`ZQ{w;MaHW z#to!~TVLgho_Pm%zq@o{K3Xq?I|MVuVSl^QHnT~sHlrVxgsqD-+YD?Nz9@HA<;x2AQjxP)r6Femg+LJ-*)k%EZ}TTRw->5xOY z9#zKJqjZgC47@AFdk1$W+KhTQJKn7e>A&?@-YOy!v_(}GyV@9G#I?bsuto4JEp;5|N{orxi_?vTI4UF0HYcA( zKyGZ4<7Fk?&LZMQb6k10N%E*$gr#T&HsY4SPQ?yerqRz5c?5P$@6dlD6UQwZJ*Je9 z7n-@7!(OVdU-mg@5$D+R%gt82Lt%&n6Yr4=|q>XT%&^z_D*f*ug8N6w$`woqeS-+#RAOfSY&Rz z?1qYa5xi(7eTCrzCFJfCxc%j{J}6#)3^*VRKF;w+`|1n;Xaojr2DI{!<3CaP`#tXs z*`pBQ5k@JLKuCmovFDqh_`Q;+^@t_;SDm29 zCNSdWXbV?9;D4VcoV`FZ9Ggrr$i<&#Dx3W=8>bSQIU_%vf)#(M2Kd3=rN@^d=QAtC zI-iQ;;GMk|&A++W5#hK28W(YqN%?!yuW8(|Cf`@FOW5QbX|`97fxmV;uXvPCqxBD zJ9iI37iV)5TW1R+fV16y;6}2tt~|0J3U4E=wQh@sx{c_eu)t=4Yoz|%Vp<#)Qlh1V z0@C2ZtlT>5gdB6W)_bhXtcZS)`9A!uIOa`K04$5>3&8An+i9BD&GvZZ=7#^r=BN=k za+=Go;qr(M)B~KYAz|<^O3LJON}$Q6Yuqn8qu~+UkUKK~&iM%pB!BO49L+?AL7N7o z(OpM(C-EY753=G=WwJHE`h*lNLMNP^c^bBk@5MyP5{v7x>GNWH>QSgTe5 z!*GPkQ(lcbEs~)4ovCu!Zt&$${9$u(<4@9%@{U<-ksAqB?6F`bQ;o-mvjr)Jn7F&j$@`il1Mf+-HdBs<-`1FahTxmPMMI)@OtI&^mtijW6zGZ67O$UOv1Jj z;a3gmw~t|LjPkW3!EZ=)lLUhFzvO;Yvj9g`8hm%6u`;cuek_b-c$wS_0M4-N<@3l|88 z@V{Sd|M;4+H6guqMm4|v=C6B7mlpP(+It%0E;W`dxMOf9!jYwWj3*MRk`KpS_jx4c z=hrKBkFK;gq@;wUV2eqE3R$M+iUc+UD0iEl#-rECK+XmH9hLKrC={j@uF=f3UiceB zU5l$FF7#RKjx+6!JHMG5-!@zI-eG=a-!Bs^AFKqN_M26%cIIcSs61R$yuq@5a3c3& z4%zLs!g}+C5%`ja?F`?5-og0lv-;(^e<`r~p$x%&*89_Aye1N)9LNVk?9BwY$Y$$F^!JQAjBJvywXAesj7lTZ)rXuxv(FFNZVknJha99lN=^h`J2> zl5=~(tKwvHHvh|9-41@OV`c;Ws--PE%{7d2sLNbDp;A6_Ka6epzOSFdqb zBa0m3j~bT*q1lslHsHqaHIP%DF&-XMpCRL(v;MV#*>mB^&)a=HfLI7efblG z(@hzN`|n+oH9;qBklb=d^S0joHCsArnR1-h{*dIUThik>ot^!6YCNjg;J_i3h6Rl0ji)* zo(tQ~>xB!rUJ(nZjCA^%X;)H{@>uhR5|xBDA=d21p@iJ!cH?+%U|VSh2S4@gv`^)^ zNKD6YlVo$%b4W^}Rw>P1YJ|fTb$_(7C;hH+ z1XAMPb6*p^h8)e5nNPKfeAO}Ik+ZN_`NrADeeJOq4Ak;sD~ zTe77no{Ztdox56Xi4UE6S7wRVxJzWxKj;B%v7|FZ3cV9MdfFp7lWCi+W{}UqekdpH zdO#eoOuB3Fu!DU`ErfeoZWJbWtRXUeBzi zBTF-AI7yMC^ntG+8%mn(I6Dw}3xK8v#Ly{3w3_E?J4(Q5JBq~I>u3!CNp~Ekk&YH` z#383VO4O42NNtcGkr*K<+wYZ>@|sP?`AQcs5oqX@-EIqgK@Pmp5~p6O6qy4ml~N{D z{=jQ7k(9!CM3N3Vt|u@%ssTw~r~Z(}QvlROAkQQ?r8OQ3F0D$aGLh zny+uGnH5muJ<67Z=8uilKvGuANrg@s3Vu_lU2ajb?rIhuOd^E@l!Kl0hYIxOP1B~Q zggUmXbh$bKL~YQ#!4fos9UUVG#}HN$lIkM<1OkU@r>$7DYYe37cXYwfK@vrHwm;pg zbh(hEU|8{*d$q7LUm+x&`S@VbW*&p-sWrplWnRM|I{P;I;%U`WmYUCeJhYc|>5?&& zj}@n}w~Oo=l}iwvi7K6)osqa;M8>fRe}>^;bLBrgA;r^ZGgY@IC^ioRmnE&H4)UV5 zO{7egQ7sBAdoqGsso5q4R(4$4Tjm&&C|7Huz&5B0wXoJzZzNc5Bt)=SOI|H}+fbit z-PiF5(NHSy>4HPMrNc@SuEMDuKYMQ--G+qeUPqO_9mOsg%1EHpqoX^yNd~~kbo`cH zlV0iAkBFTn;rVb>EK^V6?T~t~3vm;csx+lUh_%ROFPy0(omy7+_wYjN!VRDtwDu^h4n|xpAMsLepm% zggvs;v8+isCW`>BckRz1MQ=l>K6k^DdT`~sDXTWQ<~+JtY;I~I>8XsAq3yXgxe>`O zZdF*{9@Z|YtS$QrVaB!8&`&^W->_O&-JXn1n&~}o3Z7FL1QE5R*W2W@=u|w~7%EeC1aRfGtJWxImfY-D3t!!nBkWM> zafu>^Lz-ONgT6ExjV4WhN!v~u{lt2-QBN&UxwnvdH|I%LS|J-D;o>@@sA62@&yew0 z)58~JSZP!(lX;da!3`d)D1+;K9!lyNlkF|n(UduR-%g>#{`pvrD^ClddhJyfL7C-(x+J+9&7EsC~^O`&}V%)Ut8^O_7YAXPDpzv8ir4 zl`d)(;imc6r16k_d^)PJZ+QPxxVJS5e^4wX9D=V2zH&wW0-p&OJe=}rX`*->XT=;_qI&)=WHkYnZx6bLoUh_)n-A}SF_ z9z7agNTM5W6}}ui=&Qs@pO5$zHsOWIbd_&%j^Ok5PJ3yUWQw*i4*iKO)_er2CDUME ztt+{Egod~W-fn^aLe)aBz)MOc_?i-stTj}~iFk7u^-gGSbU;Iem06SDP=AEw9SzuF zeZ|hKCG3MV(z_PJg0(JbqTRf4T{NUt%kz&}4S`)0I%}ZrG!jgW2GwP=WTtkWS?DOs znI9LY!dK+1_H0h+i-_~URb^M;4&AMrEO_UlDV8o?E>^3x%ZJyh$JuDMrtYL8|G3If zPf2_Qb_W+V?$#O; zydKFv*%O;Y@o_T_UAYuaqx1isMKZ^32JtgeceA$0Z@Ck0;lHbS%N5)zzAW9iz; z8tTKeK7&qw!8XVz-+pz>z-BeIzr*#r0nB^cntjQ9@Y-N0=e&ZK72vlzX>f3RT@i7@ z=z`m7jNk!9%^xD0ug%ptZnM>F;Qu$rlwo}vRGBIymPL)L|x}nan3uFUw(&N z24gdkcb7!Q56{0<+zu zEtc5WzG2xf%1<@vo$ZsuOK{v9gx^0`gw>@h>ZMLy*h+6ueoie{D#}}` zK2@6Xxq(uZaLFC%M!2}FX}ab%GQ8A0QJ?&!vaI8Gv=vMhd);6kGguDmtuOElru()) zuRk&Z{?Vp!G~F<1#s&6io1`poBqpRHyM^p;7!+L??_DzJ8s9mYFMQ0^%_3ft7g{PD zZd}8E4EV}D!>F?bzcX=2hHR_P`Xy6?FOK)mCj)Ym4s2hh z0OlOdQa@I;^-3bhB6mpw*X5=0kJv8?#XP~9){G-+0ST@1Roz1qi8PhIXp1D$XNqVG zMl>WxwT+K`SdO1RCt4FWTNy3!i?N>*-lbnn#OxFJrswgD7HjuKpWh*o@QvgF&j+CT z{55~ZsUeR1aB}lv#s_7~+9dCix!5(KR#c?K?e2B%P$fvrsZxy@GP#R#jwL{y#Ld$} z7sF>QT6m|}?V;msb?Nlohj7a5W_D$y+4O6eI;Zt$jVGymlzLKscqer9#+p2$0It&u zWY!dCeM6^B^Z;ddEmhi?8`scl=Lhi7W%2|pT6X6^%-=q90DS(hQ-%c+E*ywPvmoF(KqDoW4!*gmQIklm zk#!GLqv|cs(JRF3G?=AYY19{w@~`G3pa z@xR9S-Hquh*&5Yas*VI};(%9%PADn`kzm zeWMJVW=>>wap*9|R7n#!&&J>gq04>DTCMtj{P^d12|2wXTEKvSf?$AvnE!peqV7i4 zE>0G%CSn%WCW1yre?yi9*aFP{GvZ|R4JT}M%x_%Hztz2qw?&28l&qW<6?c6ym{f$d z5YCF+k#yEbjCN|AGi~-NcCG8MCF1!MXBFL{#7q z)HO+WW173?kuI}^Xat;Q^gb4Hi0RGyB}%|~j8>`6X4CPo+|okMbKy9PHkr58V4bX6<&ERU)QlF8%%huUz&f+dwTN|tk+C&&o@Q1RtG`}6&6;ncQuAcfHoxd5AgD7`s zXynq41Y`zRSiOY@*;&1%1z>oNcWTV|)sjLg1X8ijg1Y zbIGL0X*Sd}EXSQ2BXCKbJmlckY(@EWn~Ut2lYeuw1wg?hhj@K?XB@V_ZP`fyL~Yd3n3SyHU-RwMBr6t-QWE5TinN9VD4XVPU; zonIIR!&pGqrLQK)=#kj40Im%V@ij0&Dh0*s!lnTw+D`Dt-xmk-jmpJv$1-E-vfYL4 zqKr#}Gm}~GPE+&$PI@4ag@=M}NYi7Y&HW82Q`@Y=W&PE31D110@yy(1vddLt`P%N^ z>Yz195A%tnt~tvsSR2{m!~7HUc@x<&`lGX1nYeQUE(%sphTi>JsVqSw8xql*Ys@9B z>RIOH*rFi*C`ohwXjyeRBDt8p)-u{O+KWP;$4gg||%*u{$~yEj+Al zE(hAQRQ1k7MkCq9s4^N3ep*$h^L%2Vq?f?{+cicpS8lo)$Cb69b98au+m2J_e7nYwID0@`M9XIo1H~|eZFc8Hl!qly612ADCVpU zY8^*RTMX(CgehD{9v|^9vZ6Rab`VeZ2m*gOR)Mw~73QEBiktViBhR!_&3l$|be|d6 zupC`{g89Y|V3uxl2!6CM(RNpdtynaiJ~*DqSTq9Mh`ohZnb%^3G{k;6%n18$4nAqR zjPOrP#-^Y9;iw{J@XH9=g5J+yEVh|e=4UeY<^65`%gWtdQ=-aqSgtywM(1nKXh`R4 zzPP&7r)kv_uC7X9n=h=!Zrf<>X=B5f<9~Q>h#jYRD#CT7D~@6@RGNyO-#0iq0uHV1 zPJr2O4d_xLmg2^TmG7|dpfJ?GGa`0|YE+`2Rata9!?$j#e9KfGYuLL(*^z z!SxFA`$qm)q-YKh)WRJZ@S+-sD_1E$V?;(?^+F3tVcK6 z2fE=8hV*2mgiAbefU^uvcM?&+Y&E}vG=Iz!%jBF7iv){lyC`)*yyS~D8k+Mx|N3bm zI~L~Z$=W9&`x)JnO;8c>3LSDw!fzN#X3qi|0`sXY4?cz{*#xz!kvZ9bO=K3XbN z5KrgN=&(JbXH{Wsu9EdmQ-W`i!JWEmfI;yVTT^a-8Ch#D8xf2dtyi?7p z%#)W3n*a#ndFpd{qN|+9Jz++AJQO#-Y7Z6%*%oyEP5zs}d&kKIr`FVEY z;S}@d?UU=tCdw~EJ{b}=9x}S2iv!!8<$?d7VKDA8h{oeD#S-$DV)-vPdGY@x08n)@ zag?yLF_E#evvRTj4^CcrLvBL=fft&@HOhZ6Ng4`8ijt&h2y}fOTC~7GfJi4vpomA5 zOcOM)o_I9BKz}I`q)fu+Qnfy*W`|mY%LO>eF^a z;$)?T4F-(X#Q-m}!-k8L_rNPf`Mr<9IWu)f&dvt=EL+ESYmCvErd@8B9hd)afc(ZL94S z?rp#h&{7Ah5IJftK4VjATklo7@hm?8BX*~oBiz)jyc9FuRw!-V;Uo>p!CWpLaIQyt zAs5WN)1CCeux-qiGdmbIk8LR`gM+Qg=&Ve}w?zA6+sTL)abU=-cvU`3E?p5$Hpkxw znu0N659qR=IKnde*AEz_7z2pdi_Bh-sb3b=PdGO1Pdf_q2;+*Cx9YN7p_>rl``knY zRn%aVkcv1(W;`Mtp_DNOIECtgq%ufk-mu_<+Fu3Q17Tq4Rr(oeq)Yqk_CHA7LR@7@ zIZIDxxhS&=F2IQfusQ+Nsr%*zFK7S4g!U0y@3H^Yln|i;0a5+?RPG;ZSp6Tul>ezM z`40+516&719qT)mW|ArDSENle5hE2e8qY+zfeZoy12u&xoMgcP)4=&P-1Ib*-bAy` zlT?>w&B|ei-rCXO;sxo7*G;!)_p#%PAM-?m$JP(R%x1Hfas@KeaG%LO?R=lmkXc_MKZW}3f%KZ*rAN?HYvbu2L$ zRt_uv7~-IejlD1x;_AhwGXjB94Q=%+PbxuYzta*jw?S&%|qb=(JfJ?&6P=R7X zV%HP_!@-zO*zS}46g=J}#AMJ}rtWBr21e6hOn&tEmaM%hALH7nlm2@LP4rZ>2 zebe5aH@k!e?ij4Zwak#30|}>;`bquDQK*xmR=zc6vj0yuyC6+U=LusGnO3ZKFRpen z#pwzh!<+WBVp-!$MAc<0i~I%fW=8IO6K}bJ<-Scq>e+)951R~HKB?Mx2H}pxPHE@} zvqpq5j81_jtb_WneAvp<5kgdPKm|u2BdQx9%EzcCN&U{l+kbkhmV<1}yCTDv%&K^> zg;KCjwh*R1f_`6`si$h6`jyIKT7rTv5#k~x$mUyIw)_>Vr)D4fwIs@}{FSX|5GB1l z4vv;@oS@>Bu7~{KgUa_8eg#Lk6IDT2IY$41$*06{>>V;Bwa(-@N;ex4;D`(QK*b}{ z{#4$Hmt)FLqERgKz=3zXiV<{YX6V)lvYBr3V>N6ajeI~~hGR5Oe>W9r@sg)Na(a4- zxm%|1OKPN6^%JaD^^O~HbLSu=f`1px>RawOxLr+1b2^28U*2#h*W^=lSpSY4(@*^l z{!@9RSLG8Me&RJYLi|?$c!B0fP=4xAM4rerxX{xy{&i6=AqXueQAIBqO+pmuxy8Ib z4X^}r!NN3-upC6B#lt7&x0J;)nb9O~xjJMemm$_fHuP{DgtlU3xiW0UesTzS30L+U zQzDI3p&3dpONhd5I8-fGk^}@unluzu%nJ$9pzoO~Kk!>dLxw@M)M9?pNH1CQhvA`z zV;uacUtnBTdvT`M$1cm9`JrT3BMW!MNVBy%?@ZX%;(%(vqQAz<7I!hlDe|J3cn9=} zF7B;V4xE{Ss76s$W~%*$JviK?w8^vqCp#_G^jN0j>~Xq#Zru26e#l3H^{GCLEXI#n z?n~F-Lv#hU(bZS`EI9(xGV*jT=8R?CaK)t8oHc9XJ;UPY0Hz$XWt#QyLBaaz5+}xM zXk(!L_*PTt7gwWH*HLWC$h3Ho!SQ-(I||nn_iEC{WT3S{3V{8IN6tZ1C+DiFM{xlI zeMMk{o5;I6UvaC)@WKp9D+o?2Vd@4)Ue-nYci()hCCsKR`VD;hr9=vA!cgGL%3k^b(jADGyPi2TKr(JNh8mzlIR>n(F_hgiV(3@Ds(tjbNM7GoZ;T|3 zWzs8S`5PrA!9){jBJuX4y`f<4;>9*&NY=2Sq2Bp`M2(fox7ZhIDe!BaQUb@P(ub9D zlP8!p(AN&CwW!V&>H?yPFMJ)d5x#HKfwx;nS{Rr@oHqpktOg)%F+%1#tsPtq7zI$r zBo-Kflhq-=7_eW9B2OQv=@?|y0CKN77)N;z@tcg;heyW{wlpJ1t`Ap!O0`Xz{YHqO zI1${8Hag^r!kA<2_~bYtM=<1YzQ#GGP+q?3T7zYbIjN6Ee^V^b&9en$8FI*NIFg9G zPG$OXjT0Ku?%L7fat8Mqbl1`azf1ltmKTa(HH$Dqlav|rU{zP;Tbnk-XkGFQ6d+gi z-PXh?_kEJl+K98&OrmzgPIijB4!Pozbxd0H1;Usy!;V>Yn6&pu*zW8aYx`SC!$*ti zSn+G9p=~w6V(fZZHc>m|PPfjK6IN4(o=IFu?pC?+`UZAUTw!e`052{P=8vqT^(VeG z=psASIhCv28Y(;7;TuYAe>}BPk5Qg=8$?wZj9lj>h2kwEfF_CpK=+O6Rq9pLn4W)# zeXCKCpi~jsfqw7Taa0;!B5_C;B}e56W1s8@p*)SPzA;Fd$Slsn^=!_&!mRHV*Lmt| zBGIDPuR>CgS4%cQ4wKdEyO&Z>2aHmja;Pz+n|7(#l%^2ZLCix%>@_mbnyPEbyrHaz z>j^4SIv;ZXF-Ftzz>*t4wyq)ng8%0d;(Z_ExZ-cxwei=8{(br-`JYO(f23Wae_MqE z3@{Mlf^%M5G1SIN&en1*| zH~ANY1h3&WNsBy$G9{T=`kcxI#-X|>zLX2r*^-FUF+m0{k)n#GTG_mhG&fJfLj~K& zU~~6othMlvMm9<*SUD2?RD+R17|Z4mgR$L*R3;nBbo&Vm@39&3xIg;^aSxHS>}gwR zmzs?h8oPnNVgET&dx5^7APYx6Vv6eou07Zveyd+^V6_LzI$>ic+pxD_8s~ zC<}ucul>UH<@$KM zT4oI=62M%7qQO{}re-jTFqo9Z;rJKD5!X5$iwUsh*+kcHVhID08MB5cQD4TBWB(rI zuWc%CA}}v|iH=9gQ?D$1#Gu!y3o~p7416n54&Hif`U-cV?VrUMJyEqo_NC4#{puzU zzXEE@UppeeRlS9W*^N$zS`SBBi<@tT+<%3l@KhOy^%MWB9(A#*J~DQ;+MK*$rxo6f zcx3$3mcx{tly!q(p2DQrxcih|)0do_ZY77pyHGE#Q(0k*t!HUmmMcYFq%l$-o6%lS zDb49W-E?rQ#Hl``C3YTEdGZjFi3R<>t)+NAda(r~f1cT5jY}s7-2^&Kvo&2DLTPYP zhVVo-HLwo*vl83mtQ9)PR#VBg)FN}+*8c-p8j`LnNUU*Olm1O1Qqe62D#$CF#?HrM zy(zkX|1oF}Z=T#3XMLWDrm(|m+{1&BMxHY7X@hM_+cV$5-t!8HT(dJi6m9{ja53Yw z3f^`yb6Q;(e|#JQIz~B*=!-GbQ4nNL-NL z@^NWF_#w-Cox@h62;r^;Y`NX8cs?l^LU;5IWE~yvU8TqIHij!X8ydbLlT0gwmzS9} z@5BccG?vO;rvCs$mse1*ANi-cYE6Iauz$Fbn3#|ToAt5v7IlYnt6RMQEYLldva{~s zvr>1L##zmeoYgvIXJ#>bbuCVuEv2ZvZ8I~PQUN3wjP0UC)!U+wn|&`V*8?)` zMSCuvnuGec>QL+i1nCPGDAm@XSMIo?A9~C?g2&G8aNKjWd2pDX{qZ?04+2 zeyLw}iEd4vkCAWwa$ zbrHlEf3hfN7^1g~aW^XwldSmx1v~1z(s=1az4-wl} z`mM+G95*N*&1EP#u3}*KwNrPIgw8Kpp((rdEOO;bT1;6ea~>>sK+?!;{hpJ3rR<6UJb`O8P4@{XGgV%63_fs%cG8L zk9Fszbdo4tS$g0IWP1>t@0)E%-&9yj%Q!fiL2vcuL;90fPm}M==<>}Q)&sp@STFCY z^p!RzmN+uXGdtPJj1Y-khNyCb6Y$Vs>eZyW zPaOV=HY_T@FwAlleZCFYl@5X<<7%5DoO(7S%Lbl55?{2vIr_;SXBCbPZ(up;pC6Wx={AZL?shYOuFxLx1*>62;2rP}g`UT5+BHg(ju z&7n5QSvSyXbioB9CJTB#x;pexicV|9oaOpiJ9VK6EvKhl4^Vsa(p6cIi$*Zr0UxQ z;$MPOZnNae2Duuce~7|2MCfhNg*hZ9{+8H3?ts9C8#xGaM&sN;2lriYkn9W>&Gry! z3b(Xx1x*FhQkD-~V+s~KBfr4M_#0{`=Yrh90yj}Ph~)Nx;1Y^8<418tu!$1<3?T*~ z7Dl0P3Uok-7w0MPFQexNG1P5;y~E8zEvE49>$(f|XWtkW2Mj`udPn)pb%} zrA%wRFp*xvDgC767w!9`0vx1=q!)w!G+9(-w&p*a@WXg{?T&%;qaVcHo>7ca%KX$B z^7|KBPo<2;kM{2mRnF8vKm`9qGV%|I{y!pKm8B(q^2V;;x2r!1VJ^Zz8bWa)!-7a8 zSRf@dqEPlsj!7}oNvFFAA)75})vTJUwQ03hD$I*j6_5xbtd_JkE2`IJD_fQ;a$EkO z{fQ{~e%PKgPJsD&PyEvDmg+Qf&p*-qu!#;1k2r_(H72{^(Z)htgh@F?VIgK#_&eS- z$~(qInec>)XIkv@+{o6^DJLpAb>!d}l1DK^(l%#OdD9tKK6#|_R?-%0V!`<9Hj z3w3chDwG*SFte@>Iqwq`J4M&{aHXzyigT620+Vf$X?3RFfeTcvx_e+(&Q*z)t>c0e zpZH$1Z3X%{^_vylHVOWT6tno=l&$3 z9^eQ@TwU#%WMQaFvaYp_we%_2-9=o{+ck zF{cKJCOjpW&qKQquyp2BXCAP920dcrZ}T1@piukx_NY;%2W>@Wca%=Ch~x5Oj58Hv z;D-_ALOZBF(Mqbcqjd}P3iDbek#Dwzu`WRs`;hRIr*n0PV7vT+%Io(t}8KZ zpp?uc2eW!v28ipep0XNDPZt7H2HJ6oey|J3z!ng#1H~x_k%35P+Cp%mqXJ~cV0xdd z^4m5^K_dQ^Sg?$P`))ccV=O>C{Ds(C2WxX$LMC5vy=*44pP&)X5DOPYfqE${)hDg< z3hcG%U%HZ39=`#Ko4Uctg&@PQLf>?0^D|4J(_1*TFMOMB!Vv1_mnOq$BzXQdOGqgy zOp#LBZ!c>bPjY1NTXksZmbAl0A^Y&(%a3W-k>bE&>K?px5Cm%AT2E<&)Y?O*?d80d zgI5l~&Mve;iXm88Q+Fw7{+`PtN4G7~mJWR^z7XmYQ>uoiV!{tL)hp|= zS(M)813PM`d<501>{NqaPo6BZ^T{KBaqEVH(2^Vjeq zgeMeMpd*1tE@@);hGjuoVzF>Cj;5dNNwh40CnU+0DSKb~GEMb_# zT8Z&gz%SkHq6!;_6dQFYE`+b`v4NT7&@P>cA1Z1xmXy<2htaDhm@XXMp!g($ zw(7iFoH2}WR`UjqjaqOQ$ecNt@c|K1H1kyBArTTjLp%-M`4nzOhkfE#}dOpcd;b#suq8cPJ&bf5`6Tq>ND(l zib{VrPZ>{KuaIg}Y$W>A+nrvMg+l4)-@2jpAQ5h(Tii%Ni^-UPVg{<1KGU2EIUNGaXcEkOedJOusFT9X3%Pz$R+-+W+LlRaY-a$5r?4V zbPzgQl22IPG+N*iBRDH%l{Zh$fv9$RN1sU@Hp3m=M}{rX%y#;4(x1KR2yCO7Pzo>rw(67E{^{yUR`91nX^&MxY@FwmJJbyPAoWZ9Z zcBS$r)&ogYBn{DOtD~tIVJUiq|1foX^*F~O4hlLp-g;Y2wKLLM=?(r3GDqsPmUo*? zwKMEi*%f)C_@?(&&hk>;m07F$X7&i?DEK|jdRK=CaaNu-)pX>n3}@%byPKVkpLzBq z{+Py&!`MZ^4@-;iY`I4#6G@aWMv{^2VTH7|WF^u?3vsB|jU3LgdX$}=v7#EHRN(im zI(3q-eU$s~r=S#EWqa_2!G?b~ z<&brq1vvUTJH380=gcNntZw%7UT8tLAr-W49;9y^=>TDaTC|cKA<(gah#2M|l~j)w zY8goo28gj$n&zcNgqX1Qn6=<8?R0`FVO)g4&QtJAbW3G#D)uNeac-7cH5W#6i!%BH z=}9}-f+FrtEkkrQ?nkoMQ1o-9_b+&=&C2^h!&mWFga#MCrm85hW;)1pDt;-uvQG^D zntSB?XA*0%TIhtWDS!KcI}kp3LT>!(Nlc(lQN?k^bS8Q^GGMfo}^|%7s;#r+pybl@?KA++|FJ zr%se9(B|g*ERQU96az%@4gYrxRRxaM2*b}jNsG|0dQi;Rw{0WM0E>rko!{QYAJJKY z)|sX0N$!8d9E|kND~v|f>3YE|uiAnqbkMn)hu$if4kUkzKqoNoh8v|S>VY1EKmgO} zR$0UU2o)4i4yc1inx3}brso+sio{)gfbLaEgLahj8(_Z#4R-v) zglqwI%`dsY+589a8$Mu7#7_%kN*ekHupQ#48DIN^uhDxblDg3R1yXMr^NmkR z7J_NWCY~fhg}h!_aXJ#?wsZF$q`JH>JWQ9`jbZzOBpS`}-A$Vgkq7+|=lPx9H7QZG z8i8guMN+yc4*H*ANr$Q-3I{FQ-^;8ezWS2b8rERp9TMOLBxiG9J*g5=?h)mIm3#CGi4JSq1ohFrcrxx@`**K5%T}qbaCGldV!t zVeM)!U3vbf5FOy;(h08JnhSGxm)8Kqxr9PsMeWi=b8b|m_&^@#A3lL;bVKTBx+0v8 zLZeWAxJ~N27lsOT2b|qyp$(CqzqgW@tyy?CgwOe~^i;ZH zlL``i4r!>i#EGBNxV_P@KpYFQLz4Bdq{#zA&sc)*@7Mxsh9u%e6Ke`?5Yz1jkTdND zR8!u_yw_$weBOU}24(&^Bm|(dSJ(v(cBct}87a^X(v>nVLIr%%D8r|&)mi+iBc;B;x;rKq zd8*X`r?SZsTNCPQqoFOrUz8nZO?225Z#z(B!4mEp#ZJBzwd7jW1!`sg*?hPMJ$o`T zR?KrN6OZA1H{9pA;p0cSSu;@6->8aJm1rrO-yDJ7)lxuk#npUk7WNER1Wwnpy%u zF=t6iHzWU(L&=vVSSc^&D_eYP3TM?HN!Tgq$SYC;pSIPWW;zeNm7Pgub#yZ@7WPw#f#Kl)W4%B>)+8%gpfoH1qZ;kZ*RqfXYeGXJ_ zk>2otbp+1By`x^1V!>6k5v8NAK@T;89$`hE0{Pc@Q$KhG0jOoKk--Qx!vS~lAiypV zCIJ&6B@24`!TxhJ4_QS*S5;;Pk#!f(qIR7*(c3dN*POKtQe)QvR{O2@QsM%ujEAWEm) z+PM=G9hSR>gQ`Bv2(k}RAv2+$7qq(mU`fQ+&}*i%-RtSUAha>70?G!>?w%F(b4k!$ zvm;E!)2`I?etmSUFW7WflJ@8Nx`m_vE2HF#)_BiD#FaNT|IY@!uUbd4v$wTglIbIX zblRy5=wp)VQzsn0_;KdM%g<8@>#;E?vypTf=F?3f@SSdZ;XpX~J@l1;p#}_veWHp>@Iq_T z@^7|h;EivPYv1&u0~l9(a~>dV9Uw10QqB6Dzu1G~-l{*7IktljpK<_L8m0|7VV_!S zRiE{u97(%R-<8oYJ{molUd>vlGaE-C|^<`hppdDz<7OS13$#J zZ+)(*rZIDSt^Q$}CRk0?pqT5PN5TT`Ya{q(BUg#&nAsg6apPMhLTno!SRq1e60fl6GvpnwDD4N> z9B=RrufY8+g3_`@PRg+(+gs2(bd;5#{uTZk96CWz#{=&h9+!{_m60xJxC%r&gd_N! z>h5UzVX%_7@CUeAA1XFg_AF%(uS&^1WD*VPS^jcC!M2v@RHZML;e(H-=(4(3O&bX- zI6>usJOS+?W&^S&DL{l|>51ZvCXUKlH2XKJPXnHjs*oMkNM#ZDLx!oaM5(%^)5XaP zk6&+P16sA>vyFe9v`Cp5qnbE#r#ltR5E+O3!WnKn`56Grs2;sqr3r# zp@Zp<^q`5iq8OqOlJ`pIuyK@3zPz&iJ0Jcc`hDQ1bqos2;}O|$i#}e@ua*x5VCSx zJAp}+?Hz++tm9dh3Fvm_bO6mQo38al#>^O0g)Lh^&l82+&x)*<n7^Sw-AJo9tEzZDwyJ7L^i7|BGqHu+ea6(&7jKpBq>~V z8CJxurD)WZ{5D0?s|KMi=e7A^JVNM6sdwg@1Eg_+Bw=9j&=+KO1PG|y(mP1@5~x>d z=@c{EWU_jTSjiJl)d(>`qEJ;@iOBm}alq8;OK;p(1AdH$)I9qHNmxxUArdzBW0t+Qeyl)m3?D09770g z)hzXEOy>2_{?o%2B%k%z4d23!pZcoxyW1Ik{|m7Q1>fm4`wsRrl)~h z_=Z*zYL+EG@DV1{6@5@(Ndu!Q$l_6Qlfoz@79q)Kmsf~J7t1)tl#`MD<;1&CAA zH8;i+oBm89dTTDl{aH`cmTPTt@^K-%*sV+t4X9q0Z{A~vEEa!&rRRr=0Rbz4NFCJr zLg2u=0QK@w9XGE=6(-JgeP}G#WG|R&tfHRA3a9*zh5wNTBAD;@YYGx%#E4{C#Wlfo z%-JuW9=FA_T6mR2-Vugk1uGZvJbFvVVWT@QOWz$;?u6+CbyQsbK$>O1APk|xgnh_8 zc)s@Mw7#0^wP6qTtyNq2G#s?5j~REyoU6^lT7dpX{T-rhZWHD%dik*=EA7bIJgOVf_Ga!yC8V^tkTOEHe+JK@Fh|$kfNxO^= z#lpV^(ZQ-3!^_BhV>aXY~GC9{8%1lOJ}6vzXDvPhC>JrtXwFBC+!3a*Z-%#9}i z#<5&0LLIa{q!rEIFSFc9)>{-_2^qbOg5;_A9 ztQ))C6#hxSA{f9R3Eh^`_f${pBJNe~pIQ`tZVR^wyp}=gLK}e5_vG@w+-mp#Fu>e| z*?qBp5CQ5zu+Fi}xAs)YY1;bKG!htqR~)DB$ILN6GaChoiy%Bq@i+1ZnANC0U&D z_4k$=YP47ng+0NhuEt}6C;9-JDd8i5S>`Ml==9wHDQFOsAlmtrVwurYDw_)Ihfk35 zJDBbe!*LUpg%4n>BExWz>KIQ9vexUu^d!7rc_kg#Bf= z7TLz|l*y*3d2vi@c|pX*@ybf!+Xk|2*z$@F4K#MT8Dt4zM_EcFmNp31#7qT6(@GG? zdd;sSY9HHuDb=w&|K%sm`bYX#%UHKY%R`3aLMO?{T#EI@FNNFNO>p@?W*i0z(g2dt z{=9Ofh80Oxv&)i35AQN>TPMjR^UID-T7H5A?GI{MD_VeXZ%;uo41dVm=uT&ne2h0i zv*xI%9vPtdEK@~1&V%p1sFc2AA`9?H)gPnRdlO~URx!fiSV)j?Tf5=5F>hnO=$d$x zzaIfr*wiIc!U1K*$JO@)gP4%xp!<*DvJSv7p}(uTLUb=MSb@7_yO+IsCj^`PsxEl& zIxsi}s3L?t+p+3FXYqujGhGwTx^WXgJ1}a@Yq5mwP0PvGEr*qu7@R$9j>@-q1rz5T zriz;B^(ex?=3Th6h;7U`8u2sDlfS{0YyydK=*>-(NOm9>S_{U|eg(J~C7O zIe{|LK=Y`hXiF_%jOM8Haw3UtaE{hWdzo3BbD6ud7br4cODBtN(~Hl+odP0SSWPw;I&^m)yLw+nd#}3#z}?UIcX3=SssI}`QwY=% zAEXTODk|MqTx}2DVG<|~(CxgLyi*A{m>M@1h^wiC)4Hy>1K7@|Z&_VPJsaQoS8=ex zDL&+AZdQa>ylxhT_Q$q=60D5&%pi6+qlY3$3c(~rsITX?>b;({FhU!7HOOhSP7>bmTkC8KM%!LRGI^~y3Ug+gh!QM=+NZXznM)?L3G=4=IMvFgX3BAlyJ z`~jjA;2z+65D$j5xbv9=IWQ^&-K3Yh`vC(1Qz2h2`o$>Cej@XRGff!it$n{@WEJ^N z41qk%Wm=}mA*iwCqU_6}Id!SQd13aFER3unXaJJXIsSnxvG2(hSCP{i&QH$tL&TPx zDYJsuk+%laN&OvKb-FHK$R4dy%M7hSB*yj#-nJy?S9tVoxAuDei{s}@+pNT!vLOIC z8g`-QQW8FKp3cPsX%{)0B+x+OhZ1=L7F-jizt|{+f1Ga7%+!BXqjCjH&x|3%?UbN# zh?$I1^YokvG$qFz5ySK+Ja5=mkR&p{F}ev**rWdKMko+Gj^?Or=UH?SCg#0F(&a_y zXOh}dPv0D9l0RVedq1~jCNV=8?vZfU-Xi|nkeE->;ohG3U7z+^0+HV17~-_Mv#mV` zzvwUJJ15v5wwKPv-)i@dsEo@#WEO9zie7mdRAbgL2kjbW4&lk$vxkbq=w5mGKZK6@ zjXWctDkCRx58NJD_Q7e}HX`SiV)TZMJ}~zY6P1(LWo`;yDynY_5_L?N-P`>ALfmyl z8C$a~FDkcwtzK9m$tof>(`Vu3#6r#+v8RGy#1D2)F;vnsiL&P-c^PO)^B-4VeJteLlT@25sPa z%W~q5>YMjj!mhN})p$47VA^v$Jo6_s{!y?}`+h+VM_SN`!11`|;C;B};B&Z<@%FOG z_YQVN+zFF|q5zKab&e4GH|B;sBbKimHt;K@tCH+S{7Ry~88`si7}S)1E{21nldiu5 z_4>;XTJa~Yd$m4A9{Qbd)KUAm7XNbZ4xHbg3a8-+1uf*$1PegabbmCzgC~1WB2F(W zYj5XhVos!X!QHuZXCatkRsdEsSCc+D2?*S7a+(v%toqyxhjz|`zdrUvsxQS{J>?c& zvx*rHw^8b|v^7wq8KWVofj&VUitbm*a&RU_ln#ZFA^3AKEf<#T%8I!Lg3XEsdH(A5 zlgh&M_XEoal)i#0tcq8c%Gs6`xu;vvP2u)D9p!&XNt z!TdF_H~;`g@fNXkO-*t<9~;iEv?)Nee%hVe!aW`N%$cFJ(Dy9+Xk*odyFj72T!(b%Vo5zvCGZ%3tkt$@Wcx8BWEkefI1-~C_3y*LjlQ5%WEz9WD8i^ z2MV$BHD$gdPJV4IaV)G9CIFwiV=ca0cfXdTdK7oRf@lgyPx;_7*RRFk=?@EOb9Gcz zg~VZrzo*Snp&EE{$CWr)JZW)Gr;{B2ka6B!&?aknM-FENcl%45#y?oq9QY z3^1Y5yn&^D67Da4lI}ljDcphaEZw2;tlYuzq?uB4b9Mt6!KTW&ptxd^vF;NbX=00T z@nE1lIBGgjqs?ES#P{ZfRb6f!At51vk%<0X%d_~NL5b8UyfQMPDtfU@>ijA0NP3UU zh{lCf`Wu7cX!go`kUG`1K=7NN@SRGjUKuo<^;@GS!%iDXbJs`o6e`v3O8-+7vRkFm z)nEa$sD#-v)*Jb>&Me+YIW3PsR1)h=-Su)))>-`aRcFJG-8icomO4J@60 zw10l}BYxi{eL+Uu0xJYk-Vc~BcR49Qyyq!7)PR27D`cqGrik=?k1Of>gY7q@&d&Ds zt7&WixP`9~jjHO`Cog~RA4Q%uMg+$z^Gt&vn+d3&>Ux{_c zm|bc;k|GKbhZLr-%p_f%dq$eiZ;n^NxoS-Nu*^Nx5vm46)*)=-Bf<;X#?`YC4tLK; z?;u?shFbXeks+dJ?^o$l#tg*1NA?(1iFff@I&j^<74S!o;SWR^Xi);DM%8XiWpLi0 zQE2dL9^a36|L5qC5+&Pf0%>l&qQ&)OU4vjd)%I6{|H+pw<0(a``9w(gKD&+o$8hOC zNAiShtc}e~ob2`gyVZx59y<6Fpl*$J41VJ-H*e-yECWaDMmPQi-N8XI3 z%iI@ljc+d}_okL1CGWffeaejlxWFVDWu%e=>H)XeZ|4{HlbgC-Uvof4ISYQzZ0Um> z#Ov{k1c*VoN^f(gfiueuag)`TbjL$XVq$)aCUBL_M`5>0>6Ska^*Knk__pw{0I>jA zzh}Kzg{@PNi)fcAk7jMAdi-_RO%x#LQszDMS@_>iFoB+zJ0Q#CQJzFGa8;pHFdi`^ zxnTC`G$7Rctm3G8t8!SY`GwFi4gF|+dAk7rh^rA{NXzc%39+xSYM~($L(pJ(8Zjs* zYdN_R^%~LiGHm9|ElV4kVZGA*T$o@YY4qpJOxGHlUi*S*A(MrgQ{&xoZQo+#PuYRs zv3a$*qoe9gBqbN|y|eaH=w^LE{>kpL!;$wRahY(hhzRY;d33W)m*dfem@)>pR54Qy z ze;^F?mwdU?K+=fBabokSls^6_6At#1Sh7W*y?r6Ss*dmZP{n;VB^LDxM1QWh;@H0J z!4S*_5j_;+@-NpO1KfQd&;C7T`9ak;X8DTRz$hDNcjG}xAfg%gwZSb^zhE~O);NMO zn2$fl7Evn%=Lk!*xsM#(y$mjukN?A&mzEw3W5>_o+6oh62kq=4-`e3B^$rG=XG}Kd zK$blh(%!9;@d@3& zGFO60j1Vf54S}+XD?%*uk7wW$f`4U3F*p7@I4Jg7f`Il}2H<{j5h?$DDe%wG7jZQL zI{mj?t?Hu>$|2UrPr5&QyK2l3mas?zzOk0DV30HgOQ|~xLXDQ8M3o#;CNKO8RK+M; zsOi%)js-MU>9H4%Q)#K_me}8OQC1u;f4!LO%|5toa1|u5Q@#mYy8nE9IXmR}b#sZK z3sD395q}*TDJJA9Er7N`y=w*S&tA;mv-)Sx4(k$fJBxXva0_;$G6!9bGBw13c_Uws zXks4u(8JA@0O9g5f?#V~qR5*u5aIe2HQO^)RW9TTcJk28l`Syl>Q#ZveEE4Em+{?%iz6=V3b>rCm9F zPQQm@-(hfNdo2%n?B)u_&Qh7^^@U>0qMBngH8}H|v+Ejg*Dd(Y#|jgJ-A zQ_bQscil%eY}8oN7ZL+2r|qv+iJY?*l)&3W_55T3GU;?@Om*(M`u0DXAsQ7HSl56> z4P!*(%&wRCb?a4HH&n;lAmr4rS=kMZb74Akha2U~Ktni>>cD$6jpugjULq)D?ea%b zk;UW0pAI~TH59P+o}*c5Ei5L-9OE;OIBt>^(;xw`>cN2`({Rzg71qrNaE=cAH^$wP zNrK9Glp^3a%m+ilQj0SnGq`okjzmE7<3I{JLD6Jn^+oas=h*4>Wvy=KXqVBa;K&ri z4(SVmMXPG}0-UTwa2-MJ=MTfM3K)b~DzSVq8+v-a0&Dsv>4B65{dBhD;(d44CaHSM zb!0ne(*<^Q%|nuaL`Gb3D4AvyO8wyygm=1;9#u5x*k0$UOwx?QxR*6Od8>+ujfyo0 zJ}>2FgW_iv(dBK2OWC-Y=Tw!UwIeOAOUUC;h95&S1hn$G#if+d;*dWL#j#YWswrz_ zMlV=z+zjZJ%SlDhxf)vv@`%~$Afd)T+MS1>ZE7V$Rj#;J*<9Ld=PrK0?qrazRJWx) z(BTLF@Wk279nh|G%ZY7_lK7=&j;x`bMND=zgh_>>-o@6%8_#Bz!FnF*onB@_k|YCF z?vu!s6#h9bL3@tPn$1;#k5=7#s*L;FLK#=M89K^|$3LICYWIbd^qguQp02w5>8p-H z+@J&+pP_^iF4Xu>`D>DcCnl8BUwwOlq6`XkjHNpi@B?OOd`4{dL?kH%lt78(-L}eah8?36zw9d-dI6D{$s{f=M7)1 zRH1M*-82}DoFF^Mi$r}bTB5r6y9>8hjL54%KfyHxn$LkW=AZ(WkHWR;tIWWr@+;^^ zVomjAWT)$+rn%g`LHB6ZSO@M3KBA? z+W7ThSBgpk`jZHZUrp`F;*%6M5kLWy6AW#T{jFHTiKXP9ITrMlEdti7@&AT_a-BA!jc(Kt zWk>IdY-2Zbz?U1)tk#n_Lsl?W;0q`;z|t9*g-xE!(}#$fScX2VkjSiboKWE~afu5d z2B@9mvT=o2fB_>Mnie=TDJB+l`GMKCy%2+NcFsbpv<9jS@$X37K_-Y!cvF5NEY`#p z3sWEc<7$E*X*fp+MqsOyMXO=<2>o8)E(T?#4KVQgt=qa%5FfUG_LE`n)PihCz2=iNUt7im)s@;mOc9SR&{`4s9Q6)U31mn?}Y?$k3kU z#h??JEgH-HGt`~%)1ZBhT9~uRi8br&;a5Y3K_Bl1G)-y(ytx?ok9S*Tz#5Vb=P~xH z^5*t_R2It95=!XDE6X{MjLYn4Eszj9Y91T2SFz@eYlx9Z9*hWaS$^5r7=W5|>sY8}mS(>e9Ez2qI1~wtlA$yv2e-Hjn&K*P z2zWSrC~_8Wrxxf#%QAL&f8iH2%R)E~IrQLgWFg8>`Vnyo?E=uiALoRP&qT{V2{$79 z%9R?*kW-7b#|}*~P#cA@q=V|+RC9=I;aK7Pju$K-n`EoGV^-8Mk=-?@$?O37evGKn z3NEgpo_4{s>=FB}sqx21d3*=gKq-Zk)U+bM%Q_}0`XGkYh*+jRaP+aDnRv#Zz*n$pGp zEU9omuYVXH{AEx>=kk}h2iKt!yqX=EHN)LF}z1j zJx((`CesN1HxTFZ7yrvA2jTPmKYVij>45{ZH2YtsHuGzIRotIFj?(8T@ZWUv{_%AI zgMZlB03C&FtgJqv9%(acqt9N)`4jy4PtYgnhqev!r$GTIOvLF5aZ{tW5MN@9BDGu* zBJzwW3sEJ~Oy8is`l6Ly3an7RPtRr^1Iu(D!B!0O241Xua>Jee;Rc7tWvj!%#yX#m z&pU*?=rTVD7pF6va1D@u@b#V@bShFr3 zMyMbNCZwT)E-%L-{%$3?n}>EN>ai7b$zR_>=l59mW;tfKj^oG)>_TGCJ#HbLBsNy$ zqAqPagZ3uQ(Gsv_-VrZmG&hHaOD#RB#6J8&sL=^iMFB=gH5AIJ+w@sTf7xa&Cnl}@ zxrtzoNq>t?=(+8bS)s2p3>jW}tye0z2aY_Dh@(18-vdfvn;D?sv<>UgL{Ti08$1Q+ zZI3q}yMA^LK=d?YVg({|v?d1|R?5 zL0S3fw)BZazRNNX|7P4rh7!+3tCG~O8l+m?H} z(CB>8(9LtKYIu3ohJ-9ecgk+L&!FX~Wuim&;v$>M4 zUfvn<=Eok(63Ubc>mZrd8d7(>8bG>J?PtOHih_xRYFu1Hg{t;%+hXu2#x%a%qzcab zv$X!ccoj)exoOnaco_jbGw7KryOtuf(SaR-VJ0nAe(1*AA}#QV1lMhGtzD>RoUZ;WA?~!K{8%chYn?ttlz17UpDLlhTkGcVfHY6R<2r4E{mU zq-}D?+*2gAkQYAKrk*rB%4WFC-B!eZZLg4(tR#@kUQHIzEqV48$9=Q(~J_0 zy1%LSCbkoOhRO!J+Oh#;bGuXe;~(bIE*!J@i<%_IcB7wjhB5iF#jBn5+u~fEECN2* z!QFh!m<(>%49H12Y33+?$JxKV3xW{xSs=gxkxW-@Xds^|O1`AmorDKrE8N2-@ospk z=Au%h=f!`_X|G^A;XWL}-_L@D6A~*4Yf!5RTTm$!t8y&fp5_oqvBjW{FufS`!)5m% z2g(=9Ap6Y2y(9OYOWuUVGp-K=6kqQ)kM0P^TQT{X{V$*sN$wbFb-DaUuJF*!?EJPl zJev!UsOB^UHZ2KppYTELh+kqDw+5dPFv&&;;C~=u$Mt+Ywga!8YkL2~@g67}3wAQP zrx^RaXb1(c7vwU8a2se75X(cX^$M{FH4AHS7d2}heqqg4F0!1|Na>UtAdT%3JnS!B)&zelTEj$^b0>Oyfw=P-y-Wd^#dEFRUN*C{!`aJIHi<_YA2?piC%^ zj!p}+ZnBrM?ErAM+D97B*7L8U$K zo(IR-&LF(85p+fuct9~VTSdRjs`d-m|6G;&PoWvC&s8z`TotPSoksp;RsL4VL@CHf z_3|Tn%`ObgRhLmr60<;ya-5wbh&t z#ycN_)3P_KZN5CRyG%LRO4`Ot)3vY#dNX9!f!`_>1%4Q`81E*2BRg~A-VcN7pcX#j zrbl@7`V%n z6J53(m?KRzKb)v?iCuYWbH*l6M77dY4keS!%>}*8n!@ROE4!|7mQ+YS4dff1JJC(t z6Fnuf^=dajqHpH1=|pb(po9Fr8it^;2dEk|Ro=$fxqK$^Yix{G($0m-{RCFQJ~LqUnO7jJcjr zl*N*!6WU;wtF=dLCWzD6kW;y)LEo=4wSXQDIcq5WttgE#%@*m><@H;~Q&GniA-$in z`sjWFLgychS1kIJmPtd-w6%iKkj&dGhtB%0)pyy0M<4HZ@ZY0PWLAd7FCrj&i|NRh?>hZj*&FYnyu%Ur`JdiTu&+n z78d3n)Rl6q&NwVj_jcr#s5G^d?VtV8bkkYco5lV0LiT+t8}98LW>d)|v|V3++zLbHC(NC@X#Hx?21J0M*gP2V`Yd^DYvVIr{C zSc4V)hZKf|OMSm%FVqSRC!phWSyuUAu%0fredf#TDR$|hMZihJ__F!)Nkh6z)d=NC z3q4V*K3JTetxCPgB2_)rhOSWhuXzu+%&>}*ARxUaDeRy{$xK(AC0I=9%X7dmc6?lZNqe-iM(`?Xn3x2Ov>sej6YVQJ9Q42>?4lil?X zew-S>tm{=@QC-zLtg*nh5mQojYnvVzf3!4TpXPuobW_*xYJs;9AokrXcs!Ay z;HK>#;G$*TPN2M!WxdH>oDY6k4A6S>BM0Nimf#LfboKxJXVBC=RBuO&g-=+@O-#0m zh*aPG16zY^tzQLNAF7L(IpGPa+mDsCeAK3k=IL6^LcE8l0o&)k@?dz!79yxUquQIe($zm5DG z5RdXTv)AjHaOPv6z%99mPsa#8OD@9=URvHoJ1hYnV2bG*2XYBgB!-GEoP&8fLmWGg z9NG^xl5D&3L^io&3iYweV*qhc=m+r7C#Jppo$Ygg;jO2yaFU8+F*RmPL` zYxfGKla_--I}YUT353k}nF1zt2NO?+kofR8Efl$Bb^&llgq+HV_UYJUH7M5IoN0sT z4;wDA0gs55ZI|FmJ0}^Pc}{Ji-|#jdR$`!s)Di4^g3b_Qr<*Qu2rz}R6!B^;`Lj3sKWzjMYjexX)-;f5Y+HfkctE{PstO-BZan0zdXPQ=V8 zS8cBhnQyy4oN?J~oK0zl!#S|v6h-nx5to7WkdEk0HKBm;?kcNO*A+u=%f~l&aY*+J z>%^Dz`EQ6!+SEX$>?d(~|MNWU-}JTrk}&`IR|Ske(G^iMdk04)Cxd@}{1=P0U*%L5 zMFH_$R+HUGGv|ju2Z>5x(-aIbVJLcH1S+(E#MNe9g;VZX{5f%_|Kv7|UY-CM(>vf= z!4m?QS+AL+rUyfGJ;~uJGp4{WhOOc%2ybVP68@QTwI(8kDuYf?#^xv zBmOHCZU8O(x)=GVFn%tg@TVW1)qJJ_bU}4e7i>&V?r zh-03>d3DFj&@}6t1y3*yOzllYQ++BO-q!)zsk`D(z||)y&}o%sZ-tUF>0KsiYKFg6 zTONq)P+uL5Vm0w{D5Gms^>H1qa&Z##*X31=58*r%Z@Ko=IMXX{;aiMUp-!$As3{sq z0EEk02MOsgGm7$}E%H1ys2$yftNbB%1rdo@?6~0!a8Ym*1f;jIgfcYEF(I_^+;Xdr z2a>&oc^dF3pm(UNpazXgVzuF<2|zdPGjrNUKpdb$HOgNp*V56XqH`~$c~oSiqx;8_ zEz3fHoU*aJUbFJ&?W)sZB3qOSS;OIZ=n-*#q{?PCXi?Mq4aY@=XvlNQdA;yVC0Vy+ z{Zk6OO!lMYWd`T#bS8FV(`%flEA9El;~WjZKU1YmZpG#49`ku`oV{Bdtvzyz3{k&7 zlG>ik>eL1P93F zd&!aXluU_qV1~sBQf$F%sM4kTfGx5MxO0zJy<#5Z&qzNfull=k1_CZivd-WAuIQf> zBT3&WR|VD|=nKelnp3Q@A~^d_jN3@$x2$f@E~e<$dk$L@06Paw$);l*ewndzL~LuU zq`>vfKb*+=uw`}NsM}~oY}gW%XFwy&A>bi{7s>@(cu4NM;!%ieP$8r6&6jfoq756W z$Y<`J*d7nK4`6t`sZ;l%Oen|+pk|Ry2`p9lri5VD!Gq`U#Ms}pgX3ylAFr8(?1#&dxrtJgB>VqrlWZf61(r`&zMXsV~l{UGjI7R@*NiMJLUoK*kY&gY9kC@^}Fj* zd^l6_t}%Ku<0PY71%zQL`@}L}48M!@=r)Q^Ie5AWhv%#l+Rhu6fRpvv$28TH;N7Cl z%I^4ffBqx@Pxpq|rTJV)$CnxUPOIn`u278s9#ukn>PL25VMv2mff)-RXV&r`Dwid7}TEZxXX1q(h{R6v6X z&x{S_tW%f)BHc!jHNbnrDRjGB@cam{i#zZK*_*xlW@-R3VDmp)<$}S%t*@VmYX;1h zFWmpXt@1xJlc15Yjs2&e%)d`fimRfi?+fS^BoTcrsew%e@T^}wyVv6NGDyMGHSKIQ zC>qFr4GY?#S#pq!%IM_AOf`#}tPoMn7JP8dHXm(v3UTq!aOfEXNRtEJ^4ED@jx%le zvUoUs-d|2(zBsrN0wE(Pj^g5wx{1YPg9FL1)V1JupsVaXNzq4fX+R!oVX+q3tG?L= z>=s38J_!$eSzy0m?om6Wv|ZCbYVHDH*J1_Ndajoh&?L7h&(CVii&rmLu+FcI;1qd_ zHDb3Vk=(`WV?Uq;<0NccEh0s`mBXcEtmwt6oN99RQt7MNER3`{snV$qBTp={Hn!zz z1gkYi#^;P8s!tQl(Y>|lvz{5$uiXsitTD^1YgCp+1%IMIRLiSP`sJru0oY-p!FPbI)!6{XM%)(_Dolh1;$HlghB-&e><;zU&pc=ujpa-(+S&Jj zX1n4T#DJDuG7NP;F5TkoG#qjjZ8NdXxF0l58RK?XO7?faM5*Z17stidTP|a%_N z^e$D?@~q#Pf+708cLSWCK|toT1YSHfXVIs9Dnh5R(}(I;7KhKB7RD>f%;H2X?Z9eR z{lUMuO~ffT!^ew= z7u13>STI4tZpCQ?yb9;tSM-(EGb?iW$a1eBy4-PVejgMXFIV_Ha^XB|F}zK_gzdhM z!)($XfrFHPf&uyFQf$EpcAfk83}91Y`JFJOiQ;v5ca?)a!IxOi36tGkPk4S6EW~eq z>WiK`Vu3D1DaZ}515nl6>;3#xo{GQp1(=uTXl1~ z4gdWxr-8a$L*_G^UVd&bqW_nzMM&SlNW$8|$lAfo@zb+P>2q?=+T^qNwblP*RsN?N zdZE%^Zs;yAwero1qaoqMp~|KL=&npffh981>2om!fseU(CtJ=bW7c6l{U5(07*e0~ zJRbid6?&psp)ilmYYR3ZIg;t;6?*>hoZ3uq7dvyyq-yq$zH$yyImjfhpQb@WKENSP zl;KPCE+KXzU5!)mu12~;2trrLfs&nlEVOndh9&!SAOdeYd}ugwpE-9OF|yQs(w@C9 zoXVX`LP~V>%$<(%~tE*bsq(EFm zU5z{H@Fs^>nm%m%wZs*hRl=KD%4W3|(@j!nJr{Mmkl`e_uR9fZ-E{JY7#s6i()WXB0g-b`R{2r@K{2h3T+a>82>722+$RM*?W5;Bmo6$X3+Ieg9&^TU(*F$Q3 zT572!;vJeBr-)x?cP;^w1zoAM`nWYVz^<6N>SkgG3s4MrNtzQO|A?odKurb6DGZffo>DP_)S0$#gGQ_vw@a9JDXs2}hV&c>$ zUT0;1@cY5kozKOcbN6)n5v)l#>nLFL_x?2NQgurQH(KH@gGe>F|$&@ zq@2A!EXcIsDdzf@cWqElI5~t z4cL9gg7{%~4@`ANXnVAi=JvSsj95-7V& zME3o-%9~2?cvlH#twW~99=-$C=+b5^Yv}Zh4;Mg-!LS zw>gqc=}CzS9>v5C?#re>JsRY!w|Mtv#%O3%Ydn=S9cQarqkZwaM4z(gL~1&oJZ;t; zA5+g3O6itCsu93!G1J_J%Icku>b3O6qBW$1Ej_oUWc@MI)| zQ~eyS-EAAnVZp}CQnvG0N>Kc$h^1DRJkE7xZqJ0>p<>9*apXgBMI-v87E0+PeJ-K& z#(8>P_W^h_kBkI;&e_{~!M+TXt@z8Po*!L^8XBn{of)knd-xp{heZh~@EunB2W)gd zAVTw6ZZasTi>((qpBFh(r4)k zz&@Mc@ZcI-4d639AfcOgHOU+YtpZ)rC%Bc5gw5o~+E-i+bMm(A6!uE>=>1M;V!Wl4 z<#~muol$FsY_qQC{JDc8b=$l6Y_@_!$av^08`czSm!Xan{l$@GO-zPq1s>WF)G=wv zDD8j~Ht1pFj)*-b7h>W)@O&m&VyYci&}K|0_Z*w`L>1jnGfCf@6p}Ef*?wdficVe_ zmPRUZ(C+YJU+hIj@_#IiM7+$4kH#VS5tM!Ksz01siPc-WUe9Y3|pb4u2qnn zRavJiRpa zq?tr&YV?yKt<@-kAFl3s&Kq#jag$hN+Y%%kX_ytvpCsElgFoN3SsZLC>0f|m#&Jhu zp7c1dV$55$+k78FI2q!FT}r|}cIV;zp~#6X2&}22$t6cHx_95FL~T~1XW21VFuatb zpM@6w>c^SJ>Pq6{L&f9()uy)TAWf;6LyHH3BUiJ8A4}od)9sriz~e7}l7Vr0e%(=>KG1Jay zW0azuWC`(|B?<6;R)2}aU`r@mt_#W2VrO{LcX$Hg9f4H#XpOsAOX02x^w9+xnLVAt z^~hv2guE-DElBG+`+`>PwXn5kuP_ZiOO3QuwoEr)ky;o$n7hFoh}Aq0@Ar<8`H!n} zspCC^EB=6>$q*gf&M2wj@zzfBl(w_@0;h^*fC#PW9!-kT-dt*e7^)OIU{Uw%U4d#g zL&o>6`hKQUps|G4F_5AuFU4wI)(%9(av7-u40(IaI|%ir@~w9-rLs&efOR@oQy)}{ z&T#Qf`!|52W0d+>G!h~5A}7VJky`C3^fkJzt3|M&xW~x-8rSi-uz=qBsgODqbl(W#f{Ew#ui(K)(Hr&xqZs` zfrK^2)tF#|U=K|_U@|r=M_Hb;qj1GJG=O=d`~#AFAccecIaq3U`(Ds1*f*TIs=IGL zp_vlaRUtFNK8(k;JEu&|i_m39c(HblQkF8g#l|?hPaUzH2kAAF1>>Yykva0;U@&oRV8w?5yEK??A0SBgh?@Pd zJg{O~4xURt7!a;$rz9%IMHQeEZHR8KgFQixarg+MfmM_OeX#~#&?mx44qe!wt`~dd zqyt^~ML>V>2Do$huU<7}EF2wy9^kJJSm6HoAD*sRz%a|aJWz_n6?bz99h)jNMp}3k ztPVbos1$lC1nX_OK0~h>=F&v^IfgBF{#BIi&HTL}O7H-t4+wwa)kf3AE2-Dx@#mTA z!0f`>vz+d3AF$NH_-JqkuK1C+5>yns0G;r5ApsU|a-w9^j4c+FS{#+7- zH%skr+TJ~W_8CK_j$T1b;$ql_+;q6W|D^BNK*A+W5XQBbJy|)(IDA=L9d>t1`KX2b zOX(Ffv*m?e>! zS3lc>XC@IqPf1g-%^4XyGl*1v0NWnwZTW?z4Y6sncXkaA{?NYna3(n@(+n+#sYm}A zGQS;*Li$4R(Ff{obl3#6pUsA0fKuWurQo$mWXMNPV5K66V!XYOyc})^>889Hg3I<{V^Lj9($B4Zu$xRr=89-lDz9x`+I8q(vEAimx1K{sTbs|5x7S zZ+7o$;9&9>@3K;5-DVzGw=kp7ez%1*kxhGytdLS>Q)=xUWv3k_x(IsS8we39Tijvr z`GKk>gkZTHSht;5q%fh9z?vk%sWO}KR04G9^jleJ^@ovWrob7{1xy7V=;S~dDVt%S za$Q#Th%6g1(hiP>hDe}7lcuI94K-2~Q0R3A1nsb7Y*Z!DtQ(Ic<0;TDKvc6%1kBdJ z$hF!{uALB0pa?B^TC}#N5gZ|CKjy|BnT$7eaKj;f>Alqdb_FA3yjZ4CCvm)D&ibL) zZRi91HC!TIAUl<|`rK_6avGh`!)TKk=j|8*W|!vb9>HLv^E%t$`@r@piI(6V8pqDG zBON7~=cf1ZWF6jc{qkKm;oYBtUpIdau6s+<-o^5qNi-p%L%xAtn9OktFd{@EjVAT% z#?-MJ5}Q9QiK_jYYWs+;I4&!N^(mb!%4zx7qO6oCEDn=8oL6#*9XIJ&iJ30O`0vsFy|fEVkw}*jd&B6!IYi+~Y)qv6QlM&V9g0 zh)@^BVDB|P&#X{31>G*nAT}Mz-j~zd>L{v{9AxrxKFw8j;ccQ$NE0PZCc(7fEt1xd z`(oR2!gX6}R+Z77VkDz^{I)@%&HQT5q+1xlf*3R^U8q%;IT8-B53&}dNA7GW`Ki&= z$lrdH zDCu;j$GxW<&v_4Te7=AE2J0u1NM_7Hl9$u{z(8#%8vvrx2P#R7AwnY|?#LbWmROa; zOJzU_*^+n(+k;Jd{e~So9>OF>fPx$Hb$?~K1ul2xr>>o@**n^6IMu8+o3rDp(X$cC z`wQt9qIS>yjA$K~bg{M%kJ00A)U4L+#*@$8UlS#lN3YA{R{7{-zu#n1>0@(#^eb_% zY|q}2)jOEM8t~9p$X5fpT7BZQ1bND#^Uyaa{mNcFWL|MoYb@>y`d{VwmsF&haoJuS2W7azZU0{tu#Jj_-^QRc35tjW~ae&zhKk!wD}#xR1WHu z_7Fys#bp&R?VXy$WYa$~!dMxt2@*(>@xS}5f-@6eoT%rwH zv_6}M?+piNE;BqaKzm1kK@?fTy$4k5cqYdN8x-<(o6KelwvkTqC3VW5HEnr+WGQlF zs`lcYEm=HPpmM4;Ich7A3a5Mb3YyQs7(Tuz-k4O0*-YGvl+2&V(B&L1F8qfR0@vQM-rF<2h-l9T12eL}3LnNAVyY_z51xVr$%@VQ-lS~wf3mnHc zoM({3Z<3+PpTFCRn_Y6cbxu9v>_>eTN0>hHPl_NQQuaK^Mhrv zX{q#80ot;ptt3#js3>kD&uNs{G0mQp>jyc0GG?=9wb33hm z`y2jL=J)T1JD7eX3xa4h$bG}2ev=?7f>-JmCj6){Upo&$k{2WA=%f;KB;X5e;JF3IjQBa4e-Gp~xv- z|In&Rad7LjJVz*q*+splCj|{7=kvQLw0F@$vPuw4m^z=B^7=A4asK_`%lEf_oIJ-O z{L)zi4bd#&g0w{p1$#I&@bz3QXu%Y)j46HAJKWVfRRB*oXo4lIy7BcVl4hRs<%&iQ zr|)Z^LUJ>qn>{6y`JdabfNNFPX7#3`x|uw+z@h<`x{J4&NlDjnknMf(VW_nKWT!Jh zo1iWBqT6^BR-{T=4Ybe+?6zxP_;A5Uo{}Xel%*=|zRGm1)pR43K39SZ=%{MDCS2d$~}PE-xPw4ZK6)H;Zc&0D5p!vjCn0wCe&rVIhchR9ql!p2`g0b@JsC^J#n_r*4lZ~u0UHKwo(HaHUJDHf^gdJhTdTW z3i7Zp_`xyKC&AI^#~JMVZj^9WsW}UR#nc#o+ifY<4`M+?Y9NTBT~p`ONtAFf8(ltr*ER-Ig!yRs2xke#NN zkyFcaQKYv>L8mQdrL+#rjgVY>Z2_$bIUz(kaqL}cYENh-2S6BQK-a(VNDa_UewSW` zMgHi<3`f!eHsyL6*^e^W7#l?V|42CfAjsgyiJsA`yNfAMB*lAsJj^K3EcCzm1KT zDU2+A5~X%ax-JJ@&7>m`T;;}(-e%gcYQtj}?ic<*gkv)X2-QJI5I0tA2`*zZRX(;6 zJ0dYfMbQ+{9Rn3T@Iu4+imx3Y%bcf2{uT4j-msZ~eO)5Z_T7NC|Nr3)|NWjomhv=E zXaVin)MY)`1QtDyO7mUCjG{5+o1jD_anyKn73uflH*ASA8rm+S=gIfgJ);>Zx*hNG z!)8DDCNOrbR#9M7Ud_1kf6BP)x^p(|_VWCJ+(WGDbYmnMLWc?O4zz#eiP3{NfP1UV z(n3vc-axE&vko^f+4nkF=XK-mnHHQ7>w05$Q}iv(kJc4O3TEvuIDM<=U9@`~WdKN* zp4e4R1ncR_kghW}>aE$@OOc~*aH5OOwB5U*Z)%{LRlhtHuigxH8KuDwvq5{3Zg{Vr zrd@)KPwVKFP2{rXho(>MTZZfkr$*alm_lltPob4N4MmhEkv`J(9NZFzA>q0Ch;!Ut zi@jS_=0%HAlN+$-IZGPi_6$)ap>Z{XQGt&@ZaJ(es!Po5*3}>R4x66WZNsjE4BVgn z>}xm=V?F#tx#e+pimNPH?Md5hV7>0pAg$K!?mpt@pXg6UW9c?gvzlNe0 z3QtIWmw$0raJkjQcbv-7Ri&eX6Ks@@EZ&53N|g7HU<;V1pkc&$3D#8k!coJ=^{=vf z-pCP;vr2#A+i#6VA?!hs6A4P@mN62XYY$#W9;MwNia~89i`=1GoFESI+%Mbrmwg*0 zbBq4^bA^XT#1MAOum)L&ARDXJ6S#G>&*72f50M1r5JAnM1p7GFIv$Kf9eVR(u$KLt z9&hQ{t^i16zL1c(tRa~?qr?lbSN;1k;%;p*#gw_BwHJRjcYPTj6>y-rw*dFTnEs95 z`%-AoPL!P16{=#RI0 zUb6#`KR|v^?6uNnY`zglZ#Wd|{*rZ(x&Hk8N6ob6mpX~e^qu5kxvh$2TLJA$M=rx zc!#ot+sS+-!O<0KR6+Lx&~zgEhCsbFY{i_DQCihspM?e z-V}HemMAvFzXR#fV~a=Xf-;tJ1edd}Mry@^=9BxON;dYr8vDEK<<{ zW~rg(ZspxuC&aJo$GTM!9_sXu(EaQJNkV9AC(ob#uA=b4*!Uf}B*@TK=*dBvKKPAF z%14J$S)s-ws9~qKsf>DseEW(ssVQ9__YNg}r9GGx3AJiZR@w_QBlGP>yYh0lQCBtf zx+G;mP+cMAg&b^7J!`SiBwC81M_r0X9kAr2y$0(Lf1gZK#>i!cbww(hn$;fLIxRf? z!AtkSZc-h76KGSGz%48Oe`8ZBHkSXeVb!TJt_VC>$m<#}(Z}!(3h631ltKb3CDMw^fTRy%Ia!b&at`^g7Ew-%WLT9(#V0OP9CE?uj62s>`GI3NA z!`$U+i<`;IQyNBkou4|-7^9^ylac-Xu!M+V5p5l0Ve?J0wTSV+$gYtoc=+Ve*OJUJ z$+uIGALW?}+M!J9+M&#bT=Hz@{R2o>NtNGu1yS({pyteyb>*sg4N`KAD?`u3F#C1y z2K4FKOAPASGZTep54PqyCG(h3?kqQQAxDSW@>T2d!n;9C8NGS;3A8YMRcL>b=<<%M zMiWf$jY;`Ojq5S{kA!?28o)v$;)5bTL<4eM-_^h4)F#eeC2Dj*S`$jl^yn#NjJOYT zx%yC5Ww@eX*zsM)P(5#wRd=0+3~&3pdIH7CxF_2iZSw@>kCyd z%M}$1p((Bidw4XNtk&`BTkU{-PG)SXIZ)yQ!Iol6u8l*SQ1^%zC72FP zLvG>_Z0SReMvB%)1@+et0S{<3hV@^SY3V~5IY(KUtTR{*^xJ^2NN{sIMD9Mr9$~(C$GLNlSpzS=fsbw-DtHb_T|{s z9OR|sx!{?F``H!gVUltY7l~dx^a(2;OUV^)7 z%@hg`8+r&xIxmzZ;Q&v0X%9P)U0SE@r@(lKP%TO(>6I_iF{?PX(bez6v8Gp!W_nd5 z<8)`1jcT)ImNZp-9rr4_1MQ|!?#8sJQx{`~7)QZ75I=DPAFD9Mt{zqFrcrXCU9MG8 zEuGcy;nZ?J#M3!3DWW?Zqv~dnN6ijlIjPfJx(#S0cs;Z=jDjKY|$w2s4*Xa1Iz953sN2Lt!Vmk|%ZwOOqj`sA--5Hiaq8!C%LV zvWZ=bxeRV(&%BffMJ_F~~*FdcjhRVNUXu)MS(S#67rDe%Ler=GS+WysC1I2=Bmbh3s6wdS}o$0 zz%H08#SPFY9JPdL6blGD$D-AaYi;X!#zqib`(XX*i<*eh+2UEPzU4}V4RlC3{<>-~ zadGA8lSm>b7Z!q;D_f9DT4i)Q_}ByElGl*Cy~zX%IzHp)@g-itZB6xM70psn z;AY8II99e6P2drgtTG5>`^|7qg`9MTp%T~|1N3tBqV}2zgow3TFAH{XPor0%=HrkXnKyxyozHlJ6 zd3}OWkl?H$l#yZqOzZbMI+lDLoH48;s10!m1!K87g;t}^+A3f3e&w{EYhVPR0Km*- zh5-ku$Z|Ss{2?4pGm(Rz!0OQb^_*N`)rW{z)^Cw_`a(_L9j=&HEJl(!4rQy1IS)>- zeTIr>hOii`gc(fgYF(cs$R8l@q{mJzpoB5`5r>|sG zBpsY}RkY(g5`bj~D>(;F8v*DyjX(#nVLSs>)XneWI&%Wo>a0u#4A?N<1SK4D}&V1oN)76 z%S>a2n3n>G`YY1>0Hvn&AMtMuI_?`5?4y3w2Hnq4Qa2YH5 zxKdfM;k467djL31Y$0kd9FCPbU=pHBp@zaIi`Xkd80;%&66zvSqsq6%aY)jZacfvw ztkWE{ZV6V2WL9e}Dvz|!d96KqVkJU@5ryp#rReeWu>mSrOJxY^tWC9wd0)$+lZc%{ zY=c4#%OSyQJvQUuy^u}s8DN8|8T%TajOuaY^)R-&8s@r9D`(Ic4NmEu)fg1f!u`xUb;9t#rM z>}cY=648@d5(9A;J)d{a^*ORdVtJrZ77!g~^lZ9@)|-ojvW#>)Jhe8$7W3mhmQh@S zU=CSO+1gSsQ+Tv=x-BD}*py_Ox@;%#hPb&tqXqyUW9jV+fonnuCyVw=?HR>dAB~Fg z^vl*~y*4|)WUW*9RC%~O1gHW~*tJb^a-j;ae2LRNo|0S2`RX>MYqGKB^_ng7YRc@! zFxg1X!VsvXkNuv^3mI`F2=x6$(pZdw=jfYt1ja3FY7a41T07FPdCqFhU6%o|Yb6Z4 zpBGa=(ao3vvhUv#*S{li|EyujXQPUV;0sa5!0Ut)>tPWyC9e0_9(=v*z`TV5OUCcx zT=w=^8#5u~7<}8Mepqln4lDv*-~g^VoV{(+*4w(q{At6d^E-Usa2`JXty++Oh~on^ z;;WHkJsk2jvh#N|?(2PLl+g!M0#z_A;(#Uy=TzL&{Ei5G9#V{JbhKV$Qmkm%5tn!CMA? z@hM=b@2DZWTQ6>&F6WCq6;~~WALiS#@{|I+ucCmD6|tBf&e;$_)%JL8$oIQ%!|Xih1v4A$=7xNO zZVz$G8;G5)rxyD+M0$20L$4yukA_D+)xmK3DMTH3Q+$N&L%qB)XwYx&s1gkh=%qGCCPwnwhbT4p%*3R)I}S#w7HK3W^E%4w z2+7ctHPx3Q97MFYB48HfD!xKKb(U^K_4)Bz(5dvwyl*R?)k;uHEYVi|{^rvh)w7}t z`tnH{v9nlVHj2ign|1an_wz0vO)*`3RaJc#;(W-Q6!P&>+@#fptCgtUSn4!@b7tW0&pE2Qj@7}f#ugu4*C)8_}AMRuz^WG zc)XDcOPQjRaGptRD^57B83B-2NKRo!j6TBAJntJPHNQG;^Oz}zt5F^kId~miK3J@l ztc-IKp6qL!?u~q?qfGP0I~$5gvq#-0;R(oLU@sYayr*QH95fnrYA*E|n%&FP@Cz`a zSdJ~(c@O^>qaO`m9IQ8sd8!L<+)GPJDrL7{4{ko2gWOZel^3!($Gjt|B&$4dtfTmBmC>V`R&&6$wpgvdmns zxcmfS%9_ZoN>F~azvLFtA(9Q5HYT#A(byGkESnt{$Tu<73$W~reB4&KF^JBsoqJ6b zS?$D7DoUgzLO-?P`V?5_ub$nf1p0mF?I)StvPomT{uYjy!w&z$t~j&en=F~hw|O(1 zlV9$arQmKTc$L)Kupwz_zA~deT+-0WX6NzFPh&d+ly*3$%#?Ca9Z9lOJsGVoQ&1HNg+)tJ_sw)%oo*DK)iU~n zvL``LqTe=r=7SwZ@LB)9|3QB5`0(B9r(iR}0nUwJss-v=dXnwMRQFYSRK1blS#^g(3@z{`=8_CGDm!LESTWig zzm1{?AG&7`uYJ;PoFO$o8RWuYsV26V{>D-iYTnvq7igWx9@w$EC*FV^vpvDl@i9yp zPIqiX@hEZF4VqzI3Y)CHhR`xKN8poL&~ak|wgbE4zR%Dm(a@?bw%(7(!^>CM!^4@J z6Z)KhoQP;WBq_Z_&<@i2t2&xq>N>b;Np2rX?yK|-!14iE2T}E|jC+=wYe~`y38g3J z8QGZquvqBaG!vw&VtdXWX5*i5*% zJP~7h{?&E|<#l{klGPaun`IgAJ4;RlbRqgJz5rmHF>MtJHbfqyyZi53?Lhj=(Ku#& z__ubmZIxzSq3F90Xur!1)Vqe6b@!ueHA!93H~jdHmaS5Q^CULso}^poy)0Op6!{^9 zWyCyyIrdBP4fkliZ%*g+J-A!6VFSRF6Liu6G^^=W>cn81>4&7(c7(6vCGSAJ zQZ|S3mb|^Wf=yJ(h~rq`iiW~|n#$+KcblIR<@|lDtm!&NBzSG-1;7#YaU+-@=xIm4 zE}edTYd~e&_%+`dIqqgFntL-FxL3!m4yTNt<(^Vt9c6F(`?9`u>$oNxoKB29<}9FE zgf)VK!*F}nW?}l95%RRk8N4^Rf8)Xf;drT4<|lUDLPj^NPMrBPL;MX&0oGCsS za3}vWcF(IPx&W6{s%zwX{UxHX2&xLGfT{d9bWP!g;Lg#etpuno$}tHoG<4Kd*=kpU z;4%y(<^yj(UlG%l-7E9z_Kh2KoQ19qT3CR@Ghr>BAgr3Vniz3LmpC4g=g|A3968yD2KD$P7v$ zx9Q8`2&qH3&y-iv0#0+jur@}k`6C%7fKbCr|tHX2&O%r?rBpg`YNy~2m+ z*L7dP$RANzVUsG_Lb>=__``6vA*xpUecuGsL+AW?BeSwyoQfDlXe8R1*R1M{0#M?M zF+m19`3<`gM{+GpgW^=UmuK*yMh3}x)7P738wL8r@(Na6%ULPgbPVTa6gh5Q(SR0f znr6kdRpe^(LVM;6Rt(Z@Lsz3EX*ry6(WZ?w>#ZRelx)N%sE+MN>5G|Z8{%@b&D+Ov zPU{shc9}%;G7l;qbonIb_1m^Qc8ez}gTC-k02G8Rl?7={9zBz8uRX2{XJQ{vZhs67avlRn| zgRtWl0Lhjet&!YC47GIm%1gdq%T24_^@!W3pCywc89X4I5pnBCZDn(%!$lOGvS*`0!AoMtqxNPFgaMR zwoW$p;8l6v%a)vaNsesED3f}$%(>zICnoE|5JwP&+0XI}JxPccd+D^gx`g`=GsUc0 z9Uad|C+_@_0%JmcObGnS@3+J^0P!tg+fUZ_w#4rk#TlJYPXJiO>SBxzs9(J;XV9d{ zmTQE1(K8EYaz9p^XLbdWudyIPJlGPo0U*)fAh-jnbfm@SYD_2+?|DJ-^P+ojG{2{6 z>HJtedEjO@j_tqZ4;Zq1t5*5cWm~W?HGP!@_f6m#btM@46cEMhhK{(yI&jG)fwL1W z^n_?o@G8a-jYt!}$H*;{0#z8lANlo!9b@!c5K8<(#lPlpE!z86Yq#>WT&2} z;;G1$pD%iNoj#Z=&kij5&V1KHIhN-h<;{HC5wD)PvkF>CzlQOEx_0;-TJ*!#&{Wzt zKcvq^SZIdop}y~iouNqtU7K7+?eIz-v_rfNM>t#i+dD$s_`M;sjGubTdP)WI*uL@xPOLHt#~T<@Yz>xt50ZoTw;a(a}lNiDN-J${gOdE zx?8LOA|tv{Mb}=TTR=LcqMqbCJkKj+@;4Mu)Cu0{`~ohix6E$g&tff)aHeUAQQ%M? zIN4uSUTzC1iMEWL*W-in1y)C`E+R8j?4_?X4&2Zv5?QdkNMz(k} zw##^Ikx`#_s>i&CO_mu@vJJ*|3ePRDl5pq$9V^>D;g0R%l>lw;ttyM6Sy`NBF{)Lr zSk)V>mZr96+aHY%vTLLt%vO-+juw6^SO_ zYGJaGeWX6W(TOQx=5oTGXOFqMMU*uZyt>MR-Y`vxW#^&)H zk0!F8f*@v6NO@Z*@Qo)+hlX40EWcj~j9dGrLaq%1;DE_%#lffXCcJ;!ZyyyZTz74Q zb2WSly6sX{`gQeToQsi1-()5EJ1nJ*kXGD`xpXr~?F#V^sxE3qSOwRSaC9x9oa~jJ zTG9`E|q zC5Qs1xh}jzb5UPYF`3N9YuMnI7xsZ41P;?@c|%w zl=OxLr6sMGR+`LStLvh)g?fA5p|xbUD;yFAMQg&!PEDYxVYDfA>oTY;CFt`cg?Li1 z0b})!9Rvw&j#*&+D2))kXLL z0+j=?7?#~_}N-qdEIP>DQaZh#F(#e0WNLzwUAj@r694VJ8?Dr5_io2X49XYsG^ zREt0$HiNI~6VV!ycvao+0v7uT$_ilKCvsC+VDNg7yG1X+eNe^3D^S==F3ByiW0T^F zH6EsH^}Uj^VPIE&m)xlmOScYR(w750>hclqH~~dM2+;%GDXT`u4zG!p((*`Hwx41M z4KB+`hfT(YA%W)Ve(n+Gu9kuXWKzxg{1ff^xNQw>w%L-)RySTk9kAS92(X0Shg^Q? zx1YXg_TLC^?h6!4mBqZ9pKhXByu|u~gF%`%`vdoaGBN3^j4l!4x?Bw4Jd)Z4^di}! zXlG1;hFvc>H?bmmu1E7Vx=%vahd!P1#ZGJOJYNbaek^$DHt`EOE|Hlij+hX>ocQFSLVu|wz`|KVl@Oa;m2k6b*mNK2Vo{~l9>Qa3@B7G7#k?)aLx;w6U ze8bBq%vF?5v>#TspEoaII!N}sRT~>bh-VWJ7Q*1qsz%|G)CFmnttbq$Ogb{~YK_=! z{{0vhlW@g!$>|}$&4E3@k`KPElW6x#tSX&dfle>o!irek$NAbDzdd2pVeNzk4&qgJ zXvNF0$R96~g0x+R1igR=Xu&X_Hc5;!Ze&C)eUTB$9wW&?$&o8Yxhm5s(S`;?{> z*F?9Gr0|!OiKA>Rq-ae=_okB6&yMR?!JDer{@iQgIn=cGxs-u^!8Q$+N&pfg2WM&Z zulHu=Uh~U>fS{=Nm0x>ACvG*4R`Dx^kJ65&Vvfj`rSCV$5>c04N26Rt2S?*kh3JKq z9(3}5T?*x*AP(X2Ukftym0XOvg~r6Ms$2x&R&#}Sz23aMGU&7sU-cFvE3Eq`NBJe84VoftWF#v7PDAp`@V zRFCS24_k~;@~R*L)eCx@Q9EYmM)Sn}HLbVMyxx%{XnMBDc-YZ<(DXDBYUt8$u5Zh} zBK~=M9cG$?_m_M61YG+#|9Vef7LfbH>(C21&aC)x$^Lg}fa#SF){RX|?-xZjSOrn# z2ZAwUF)$VB<&S;R3FhNSQOV~8w%A`V9dWyLiy zgt7G=Z4t|zU3!dh5|s(@XyS|waBr$>@=^Dspmem8)@L`Ns{xl%rGdX!R(BiC5C7Vo zXetb$oC_iXS}2x_Hy}T(hUUNbO47Q@+^4Q`h>(R-;OxCyW#eoOeC51jzxnM1yxBrp zz6}z`(=cngs6X05e79o_B7@3K|Qpe3n38Py_~ zpi?^rj!`pq!7PHGliC$`-8A^Ib?2qgJJCW+(&TfOnFGJ+@-<<~`7BR0f4oSINBq&R z2CM`0%WLg_Duw^1SPwj-{?BUl2Y=M4e+7yL1{C&&f&zjF06#xf>VdLozgNye(BNgSD`=fFbBy0HIosLl@JwCQl^s;eTnc( z3!r8G=K>zb`|bLLI0N|eFJk%s)B>oJ^M@AQzqR;HUjLsOqW<0v>1ksT_#24*U@R3HJu*A^#1o#P3%3_jq>icD@<`tqU6ICEgZrME(xX#?i^Z z%Id$_uyQGlFD-CcaiRtRdGn|K`Lq5L-rx7`vYYGH7I=eLfHRozPiUtSe~Tt;IN2^gCXmf2#D~g2@9bhzK}3nphhG%d?V7+Zq{I2?Gt*!NSn_r~dd$ zqkUOg{U=MI?Ehx@`(X%rQB?LP=CjJ*V!rec{#0W2WshH$X#9zep!K)tzZoge*LYd5 z@g?-j5_mtMp>_WW`p*UNUZTFN{_+#m*bJzt{hvAdkF{W40{#L3w6gzPztnsA_4?&0 z(+>pv!zB16rR-(nm(^c>Z(its{ny677vT8sF564^mlZvJ!h65}OW%Hn|2OXbOQM%b z{6C54Z2v;^hyMQ;UH+HwFD2!F!VlQ}6Z{L0_9g5~CH0@Mqz?ZC`^QkhOU#$Lx<4`B zyZsa9uPF!rZDo8ZVfzzR#raQ>5|)k~_Ef*wDqG^76o)j!C4 zykvT*o$!-MBko@?{b~*Zf2*YMlImrK`cEp|#D7f%Twm<|C|dWD \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -81,92 +132,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" fi +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 0f8d5937..9d21a218 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,84 +1,94 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/image-kit-java-client-okhttp/build.gradle.kts b/image-kit-java-client-okhttp/build.gradle.kts new file mode 100644 index 00000000..cd001ec2 --- /dev/null +++ b/image-kit-java-client-okhttp/build.gradle.kts @@ -0,0 +1,14 @@ +plugins { + id("image-kit.kotlin") + id("image-kit.publish") +} + +dependencies { + api(project(":image-kit-java-core")) + + implementation("com.squareup.okhttp3:okhttp:4.12.0") + implementation("com.squareup.okhttp3:logging-interceptor:4.12.0") + + testImplementation(kotlin("test")) + testImplementation("org.assertj:assertj-core:3.25.3") +} diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt new file mode 100644 index 00000000..2da16e75 --- /dev/null +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt @@ -0,0 +1,327 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.client.okhttp + +import com.fasterxml.jackson.databind.json.JsonMapper +import com.imagekit.api.client.ImageKitClient +import com.imagekit.api.client.ImageKitClientImpl +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.Timeout +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.HttpClient +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.core.jsonMapper +import java.net.Proxy +import java.time.Clock +import java.time.Duration +import java.util.Optional +import javax.net.ssl.HostnameVerifier +import javax.net.ssl.SSLSocketFactory +import javax.net.ssl.X509TrustManager +import kotlin.jvm.optionals.getOrNull + +/** + * A class that allows building an instance of [ImageKitClient] with [OkHttpClient] as the + * underlying [HttpClient]. + */ +class ImageKitOkHttpClient private constructor() { + + companion object { + + /** Returns a mutable builder for constructing an instance of [ImageKitClient]. */ + @JvmStatic fun builder() = Builder() + + /** + * Returns a client configured using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ + @JvmStatic fun fromEnv(): ImageKitClient = builder().fromEnv().build() + } + + /** A builder for [ImageKitOkHttpClient]. */ + class Builder internal constructor() { + + private var clientOptions: ClientOptions.Builder = ClientOptions.builder() + private var proxy: Proxy? = null + private var sslSocketFactory: SSLSocketFactory? = null + private var trustManager: X509TrustManager? = null + private var hostnameVerifier: HostnameVerifier? = null + + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + + /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ + fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + + /** + * The socket factory used to secure HTTPS connections. + * + * If this is set, then [trustManager] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { + this.sslSocketFactory = sslSocketFactory + } + + /** Alias for calling [Builder.sslSocketFactory] with `sslSocketFactory.orElse(null)`. */ + fun sslSocketFactory(sslSocketFactory: Optional) = + sslSocketFactory(sslSocketFactory.getOrNull()) + + /** + * The trust manager used to secure HTTPS connections. + * + * If this is set, then [sslSocketFactory] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun trustManager(trustManager: X509TrustManager?) = apply { + this.trustManager = trustManager + } + + /** Alias for calling [Builder.trustManager] with `trustManager.orElse(null)`. */ + fun trustManager(trustManager: Optional) = + trustManager(trustManager.getOrNull()) + + /** + * The verifier used to confirm that response certificates apply to requested hostnames for + * HTTPS connections. + * + * If unset, then a default hostname verifier is used. + */ + fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply { + this.hostnameVerifier = hostnameVerifier + } + + /** Alias for calling [Builder.hostnameVerifier] with `hostnameVerifier.orElse(null)`. */ + fun hostnameVerifier(hostnameVerifier: Optional) = + hostnameVerifier(hostnameVerifier.getOrNull()) + + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee + * that the SDK will work correctly when using an incompatible Jackson version. + */ + fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { + clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility) + } + + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [com.imagekit.api.core.jsonMapper]. The default is usually sufficient and + * rarely needs to be overridden. + */ + fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.imagekit.io`. + */ + fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ + fun responseValidation(responseValidation: Boolean) = apply { + clientOptions.responseValidation(responseValidation) + } + + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ + fun timeout(timeout: Timeout) = apply { clientOptions.timeout(timeout) } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = apply { clientOptions.timeout(timeout) } + + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * Only the following error types are retried: + * - Connection errors (for example, due to a network connectivity problem) + * - 408 Request Timeout + * - 409 Conflict + * - 429 Rate Limit + * - 5xx Internal + * + * The API may also explicitly instruct the SDK to retry or not retry a request. + * + * Defaults to 2. + */ + fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + + /** + * Your ImageKit private API key (it starts with `private_`). You can view and manage API + * keys in the [dashboard](https://imagekit.io/dashboard/developer/api-keys). + */ + fun privateApiKey(privateApiKey: String) = apply { + clientOptions.privateApiKey(privateApiKey) + } + + /** + * ImageKit Basic Auth only uses the username field and ignores the password. This field is + * unused. + * + * Defaults to `"do_not_set"`. + */ + fun password(password: String?) = apply { clientOptions.password(password) } + + /** Alias for calling [Builder.password] with `password.orElse(null)`. */ + fun password(password: Optional) = password(password.getOrNull()) + + /** + * Your ImageKit webhook secret. This is used by the SDK to verify webhook signatures. It + * starts with a `whsec_` prefix. You can view and manage your webhook secret in the + * [dashboard](https://imagekit.io/dashboard/developer/webhooks). Treat the secret like a + * password, keep it private and do not expose it publicly. Learn more about + * [webhook verification](https://imagekit.io/docs/webhooks#verify-webhook-signature). + */ + fun webhookSecret(webhookSecret: String?) = apply { + clientOptions.webhookSecret(webhookSecret) + } + + /** Alias for calling [Builder.webhookSecret] with `webhookSecret.orElse(null)`. */ + fun webhookSecret(webhookSecret: Optional) = + webhookSecret(webhookSecret.getOrNull()) + + fun headers(headers: Headers) = apply { clientOptions.headers(headers) } + + fun headers(headers: Map>) = apply { + clientOptions.headers(headers) + } + + fun putHeader(name: String, value: String) = apply { clientOptions.putHeader(name, value) } + + fun putHeaders(name: String, values: Iterable) = apply { + clientOptions.putHeaders(name, values) + } + + fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) } + + fun putAllHeaders(headers: Map>) = apply { + clientOptions.putAllHeaders(headers) + } + + fun replaceHeaders(name: String, value: String) = apply { + clientOptions.replaceHeaders(name, value) + } + + fun replaceHeaders(name: String, values: Iterable) = apply { + clientOptions.replaceHeaders(name, values) + } + + fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) } + + fun replaceAllHeaders(headers: Map>) = apply { + clientOptions.replaceAllHeaders(headers) + } + + fun removeHeaders(name: String) = apply { clientOptions.removeHeaders(name) } + + fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } + + fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) } + + fun queryParams(queryParams: Map>) = apply { + clientOptions.queryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = apply { + clientOptions.putQueryParam(key, value) + } + + fun putQueryParams(key: String, values: Iterable) = apply { + clientOptions.putQueryParams(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = apply { + clientOptions.replaceQueryParams(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + clientOptions.replaceQueryParams(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun removeQueryParams(key: String) = apply { clientOptions.removeQueryParams(key) } + + fun removeAllQueryParams(keys: Set) = apply { + clientOptions.removeAllQueryParams(keys) + } + + /** + * Updates configuration using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ + fun fromEnv() = apply { clientOptions.fromEnv() } + + /** + * Returns an immutable instance of [ImageKitClient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ImageKitClient = + ImageKitClientImpl( + clientOptions + .httpClient( + OkHttpClient.builder() + .timeout(clientOptions.timeout()) + .proxy(proxy) + .sslSocketFactory(sslSocketFactory) + .trustManager(trustManager) + .hostnameVerifier(hostnameVerifier) + .build() + ) + .build() + ) + } +} diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt new file mode 100644 index 00000000..d998ad81 --- /dev/null +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt @@ -0,0 +1,327 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.client.okhttp + +import com.fasterxml.jackson.databind.json.JsonMapper +import com.imagekit.api.client.ImageKitClientAsync +import com.imagekit.api.client.ImageKitClientAsyncImpl +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.Timeout +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.HttpClient +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.core.jsonMapper +import java.net.Proxy +import java.time.Clock +import java.time.Duration +import java.util.Optional +import javax.net.ssl.HostnameVerifier +import javax.net.ssl.SSLSocketFactory +import javax.net.ssl.X509TrustManager +import kotlin.jvm.optionals.getOrNull + +/** + * A class that allows building an instance of [ImageKitClientAsync] with [OkHttpClient] as the + * underlying [HttpClient]. + */ +class ImageKitOkHttpClientAsync private constructor() { + + companion object { + + /** Returns a mutable builder for constructing an instance of [ImageKitClientAsync]. */ + @JvmStatic fun builder() = Builder() + + /** + * Returns a client configured using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ + @JvmStatic fun fromEnv(): ImageKitClientAsync = builder().fromEnv().build() + } + + /** A builder for [ImageKitOkHttpClientAsync]. */ + class Builder internal constructor() { + + private var clientOptions: ClientOptions.Builder = ClientOptions.builder() + private var proxy: Proxy? = null + private var sslSocketFactory: SSLSocketFactory? = null + private var trustManager: X509TrustManager? = null + private var hostnameVerifier: HostnameVerifier? = null + + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + + /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ + fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + + /** + * The socket factory used to secure HTTPS connections. + * + * If this is set, then [trustManager] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { + this.sslSocketFactory = sslSocketFactory + } + + /** Alias for calling [Builder.sslSocketFactory] with `sslSocketFactory.orElse(null)`. */ + fun sslSocketFactory(sslSocketFactory: Optional) = + sslSocketFactory(sslSocketFactory.getOrNull()) + + /** + * The trust manager used to secure HTTPS connections. + * + * If this is set, then [sslSocketFactory] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun trustManager(trustManager: X509TrustManager?) = apply { + this.trustManager = trustManager + } + + /** Alias for calling [Builder.trustManager] with `trustManager.orElse(null)`. */ + fun trustManager(trustManager: Optional) = + trustManager(trustManager.getOrNull()) + + /** + * The verifier used to confirm that response certificates apply to requested hostnames for + * HTTPS connections. + * + * If unset, then a default hostname verifier is used. + */ + fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply { + this.hostnameVerifier = hostnameVerifier + } + + /** Alias for calling [Builder.hostnameVerifier] with `hostnameVerifier.orElse(null)`. */ + fun hostnameVerifier(hostnameVerifier: Optional) = + hostnameVerifier(hostnameVerifier.getOrNull()) + + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee + * that the SDK will work correctly when using an incompatible Jackson version. + */ + fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { + clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility) + } + + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [com.imagekit.api.core.jsonMapper]. The default is usually sufficient and + * rarely needs to be overridden. + */ + fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.imagekit.io`. + */ + fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ + fun responseValidation(responseValidation: Boolean) = apply { + clientOptions.responseValidation(responseValidation) + } + + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ + fun timeout(timeout: Timeout) = apply { clientOptions.timeout(timeout) } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = apply { clientOptions.timeout(timeout) } + + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * Only the following error types are retried: + * - Connection errors (for example, due to a network connectivity problem) + * - 408 Request Timeout + * - 409 Conflict + * - 429 Rate Limit + * - 5xx Internal + * + * The API may also explicitly instruct the SDK to retry or not retry a request. + * + * Defaults to 2. + */ + fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + + /** + * Your ImageKit private API key (it starts with `private_`). You can view and manage API + * keys in the [dashboard](https://imagekit.io/dashboard/developer/api-keys). + */ + fun privateApiKey(privateApiKey: String) = apply { + clientOptions.privateApiKey(privateApiKey) + } + + /** + * ImageKit Basic Auth only uses the username field and ignores the password. This field is + * unused. + * + * Defaults to `"do_not_set"`. + */ + fun password(password: String?) = apply { clientOptions.password(password) } + + /** Alias for calling [Builder.password] with `password.orElse(null)`. */ + fun password(password: Optional) = password(password.getOrNull()) + + /** + * Your ImageKit webhook secret. This is used by the SDK to verify webhook signatures. It + * starts with a `whsec_` prefix. You can view and manage your webhook secret in the + * [dashboard](https://imagekit.io/dashboard/developer/webhooks). Treat the secret like a + * password, keep it private and do not expose it publicly. Learn more about + * [webhook verification](https://imagekit.io/docs/webhooks#verify-webhook-signature). + */ + fun webhookSecret(webhookSecret: String?) = apply { + clientOptions.webhookSecret(webhookSecret) + } + + /** Alias for calling [Builder.webhookSecret] with `webhookSecret.orElse(null)`. */ + fun webhookSecret(webhookSecret: Optional) = + webhookSecret(webhookSecret.getOrNull()) + + fun headers(headers: Headers) = apply { clientOptions.headers(headers) } + + fun headers(headers: Map>) = apply { + clientOptions.headers(headers) + } + + fun putHeader(name: String, value: String) = apply { clientOptions.putHeader(name, value) } + + fun putHeaders(name: String, values: Iterable) = apply { + clientOptions.putHeaders(name, values) + } + + fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) } + + fun putAllHeaders(headers: Map>) = apply { + clientOptions.putAllHeaders(headers) + } + + fun replaceHeaders(name: String, value: String) = apply { + clientOptions.replaceHeaders(name, value) + } + + fun replaceHeaders(name: String, values: Iterable) = apply { + clientOptions.replaceHeaders(name, values) + } + + fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) } + + fun replaceAllHeaders(headers: Map>) = apply { + clientOptions.replaceAllHeaders(headers) + } + + fun removeHeaders(name: String) = apply { clientOptions.removeHeaders(name) } + + fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } + + fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) } + + fun queryParams(queryParams: Map>) = apply { + clientOptions.queryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = apply { + clientOptions.putQueryParam(key, value) + } + + fun putQueryParams(key: String, values: Iterable) = apply { + clientOptions.putQueryParams(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = apply { + clientOptions.replaceQueryParams(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + clientOptions.replaceQueryParams(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun removeQueryParams(key: String) = apply { clientOptions.removeQueryParams(key) } + + fun removeAllQueryParams(keys: Set) = apply { + clientOptions.removeAllQueryParams(keys) + } + + /** + * Updates configuration using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ + fun fromEnv() = apply { clientOptions.fromEnv() } + + /** + * Returns an immutable instance of [ImageKitClientAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ImageKitClientAsync = + ImageKitClientAsyncImpl( + clientOptions + .httpClient( + OkHttpClient.builder() + .timeout(clientOptions.timeout()) + .proxy(proxy) + .sslSocketFactory(sslSocketFactory) + .trustManager(trustManager) + .hostnameVerifier(hostnameVerifier) + .build() + ) + .build() + ) + } +} diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt new file mode 100644 index 00000000..f86881b5 --- /dev/null +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt @@ -0,0 +1,246 @@ +package com.imagekit.api.client.okhttp + +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.Timeout +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.HttpClient +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpRequestBody +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.errors.ImageKitIoException +import java.io.IOException +import java.io.InputStream +import java.net.Proxy +import java.time.Duration +import java.util.concurrent.CompletableFuture +import javax.net.ssl.HostnameVerifier +import javax.net.ssl.SSLSocketFactory +import javax.net.ssl.X509TrustManager +import okhttp3.Call +import okhttp3.Callback +import okhttp3.HttpUrl.Companion.toHttpUrl +import okhttp3.MediaType +import okhttp3.MediaType.Companion.toMediaType +import okhttp3.Request +import okhttp3.RequestBody +import okhttp3.RequestBody.Companion.toRequestBody +import okhttp3.Response +import okhttp3.logging.HttpLoggingInterceptor +import okio.BufferedSink + +class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient) : + HttpClient { + + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { + val call = newCall(request, requestOptions) + + return try { + call.execute().toResponse() + } catch (e: IOException) { + throw ImageKitIoException("Request failed", e) + } finally { + request.body?.close() + } + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + val future = CompletableFuture() + + request.body?.run { future.whenComplete { _, _ -> close() } } + + newCall(request, requestOptions) + .enqueue( + object : Callback { + override fun onResponse(call: Call, response: Response) { + future.complete(response.toResponse()) + } + + override fun onFailure(call: Call, e: IOException) { + future.completeExceptionally(ImageKitIoException("Request failed", e)) + } + } + ) + + return future + } + + override fun close() { + okHttpClient.dispatcher.executorService.shutdown() + okHttpClient.connectionPool.evictAll() + okHttpClient.cache?.close() + } + + private fun newCall(request: HttpRequest, requestOptions: RequestOptions): Call { + val clientBuilder = okHttpClient.newBuilder() + + val logLevel = + when (System.getenv("IMAGE_KIT_LOG")?.lowercase()) { + "info" -> HttpLoggingInterceptor.Level.BASIC + "debug" -> HttpLoggingInterceptor.Level.BODY + else -> null + } + if (logLevel != null) { + clientBuilder.addNetworkInterceptor( + HttpLoggingInterceptor().setLevel(logLevel).apply { redactHeader("Authorization") } + ) + } + + requestOptions.timeout?.let { + clientBuilder + .connectTimeout(it.connect()) + .readTimeout(it.read()) + .writeTimeout(it.write()) + .callTimeout(it.request()) + } + + val client = clientBuilder.build() + return client.newCall(request.toRequest(client)) + } + + private fun HttpRequest.toRequest(client: okhttp3.OkHttpClient): Request { + var body: RequestBody? = body?.toRequestBody() + if (body == null && requiresBody(method)) { + body = "".toRequestBody() + } + + val builder = Request.Builder().url(toUrl()).method(method.name, body) + headers.names().forEach { name -> + headers.values(name).forEach { builder.header(name, it) } + } + + if ( + !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 + ) { + builder.header( + "X-Stainless-Read-Timeout", + Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), + ) + } + if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { + builder.header( + "X-Stainless-Timeout", + Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), + ) + } + + return builder.build() + } + + /** `OkHttpClient` always requires a request body for some methods. */ + private fun requiresBody(method: HttpMethod): Boolean = + when (method) { + HttpMethod.POST, + HttpMethod.PUT, + HttpMethod.PATCH -> true + else -> false + } + + private fun HttpRequest.toUrl(): String { + val builder = baseUrl.toHttpUrl().newBuilder() + pathSegments.forEach(builder::addPathSegment) + queryParams.keys().forEach { key -> + queryParams.values(key).forEach { builder.addQueryParameter(key, it) } + } + + return builder.toString() + } + + private fun HttpRequestBody.toRequestBody(): RequestBody { + val mediaType = contentType()?.toMediaType() + val length = contentLength() + + return object : RequestBody() { + override fun contentType(): MediaType? = mediaType + + override fun contentLength(): Long = length + + override fun isOneShot(): Boolean = !repeatable() + + override fun writeTo(sink: BufferedSink) = writeTo(sink.outputStream()) + } + } + + private fun Response.toResponse(): HttpResponse { + val headers = headers.toHeaders() + + return object : HttpResponse { + override fun statusCode(): Int = code + + override fun headers(): Headers = headers + + override fun body(): InputStream = body!!.byteStream() + + override fun close() = body!!.close() + } + } + + private fun okhttp3.Headers.toHeaders(): Headers { + val headersBuilder = Headers.builder() + forEach { (name, value) -> headersBuilder.put(name, value) } + return headersBuilder.build() + } + + companion object { + @JvmStatic fun builder() = Builder() + } + + class Builder internal constructor() { + + private var timeout: Timeout = Timeout.default() + private var proxy: Proxy? = null + private var sslSocketFactory: SSLSocketFactory? = null + private var trustManager: X509TrustManager? = null + private var hostnameVerifier: HostnameVerifier? = null + + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) + + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { + this.sslSocketFactory = sslSocketFactory + } + + fun trustManager(trustManager: X509TrustManager?) = apply { + this.trustManager = trustManager + } + + fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply { + this.hostnameVerifier = hostnameVerifier + } + + fun build(): OkHttpClient = + OkHttpClient( + okhttp3.OkHttpClient.Builder() + .connectTimeout(timeout.connect()) + .readTimeout(timeout.read()) + .writeTimeout(timeout.write()) + .callTimeout(timeout.request()) + .proxy(proxy) + .apply { + val sslSocketFactory = sslSocketFactory + val trustManager = trustManager + if (sslSocketFactory != null && trustManager != null) { + sslSocketFactory(sslSocketFactory, trustManager) + } else { + check((sslSocketFactory != null) == (trustManager != null)) { + "Both or none of `sslSocketFactory` and `trustManager` must be set, but only one was set" + } + } + + hostnameVerifier?.let(::hostnameVerifier) + } + .build() + .apply { + // We usually make all our requests to the same host so it makes sense to + // raise the per-host limit to the overall limit. + dispatcher.maxRequestsPerHost = dispatcher.maxRequests + } + ) + } +} diff --git a/image-kit-java-core/build.gradle.kts b/image-kit-java-core/build.gradle.kts new file mode 100644 index 00000000..92263956 --- /dev/null +++ b/image-kit-java-core/build.gradle.kts @@ -0,0 +1,41 @@ +plugins { + id("image-kit.kotlin") + id("image-kit.publish") +} + +configurations.all { + resolutionStrategy { + // Compile and test against a lower Jackson version to ensure we're compatible with it. + // We publish with a higher version (see below) to ensure users depend on a secure version by default. + force("com.fasterxml.jackson.core:jackson-core:2.13.4") + force("com.fasterxml.jackson.core:jackson-databind:2.13.4") + force("com.fasterxml.jackson.core:jackson-annotations:2.13.4") + force("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.13.4") + force("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.4") + force("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4") + } +} + +dependencies { + api("com.fasterxml.jackson.core:jackson-core:2.18.2") + api("com.fasterxml.jackson.core:jackson-databind:2.18.2") + api("com.google.errorprone:error_prone_annotations:2.33.0") + + implementation("com.fasterxml.jackson.core:jackson-annotations:2.18.2") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2") + implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.2") + implementation("org.apache.httpcomponents.core5:httpcore5:5.2.4") + implementation("org.apache.httpcomponents.client5:httpclient5:5.3.1") + + testImplementation(kotlin("test")) + testImplementation(project(":image-kit-java-client-okhttp")) + testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") + testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") + testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3") + testImplementation("org.junit-pioneer:junit-pioneer:1.9.1") + testImplementation("org.mockito:mockito-core:5.14.2") + testImplementation("org.mockito:mockito-junit-jupiter:5.14.2") + testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0") +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt new file mode 100644 index 00000000..ff5e2276 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt @@ -0,0 +1,107 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.client + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.services.blocking.AccountService +import com.imagekit.api.services.blocking.AssetService +import com.imagekit.api.services.blocking.BetaService +import com.imagekit.api.services.blocking.CacheService +import com.imagekit.api.services.blocking.CustomMetadataFieldService +import com.imagekit.api.services.blocking.FileService +import com.imagekit.api.services.blocking.FolderService +import com.imagekit.api.services.blocking.WebhookService +import java.util.function.Consumer + +/** + * A client for interacting with the Image Kit REST API synchronously. You can also switch to + * asynchronous execution via the [async] method. + * + * This client performs best when you create a single instance and reuse it for all interactions + * with the REST API. This is because each client holds its own connection pool and thread pools. + * Reusing connections and threads reduces latency and saves memory. The client also handles rate + * limiting per client. This means that creating and using multiple instances at the same time will + * not respect rate limits. + * + * The threads and connections that are held will be released automatically if they remain idle. But + * if you are writing an application that needs to aggressively release unused resources, then you + * may call [close]. + */ +interface ImageKitClient { + + /** + * Returns a version of this client that uses asynchronous execution. + * + * The returned client shares its resources, like its connection pool and thread pools, with + * this client. + */ + fun async(): ImageKitClientAsync + + /** + * 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): ImageKitClient + + fun customMetadataFields(): CustomMetadataFieldService + + fun files(): FileService + + fun assets(): AssetService + + fun cache(): CacheService + + fun folders(): FolderService + + fun accounts(): AccountService + + fun beta(): BetaService + + fun webhooks(): WebhookService + + /** + * Closes this client, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and + * usually should not be synchronously closed via try-with-resources. + * + * It's also usually not necessary to call this method at all. the default HTTP client + * automatically releases threads and connections if they remain idle, but if you are writing an + * application that needs to aggressively release unused resources, then you may call this + * method. + */ + fun close() + + /** A view of [ImageKitClient] 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): ImageKitClient.WithRawResponse + + fun customMetadataFields(): CustomMetadataFieldService.WithRawResponse + + fun files(): FileService.WithRawResponse + + fun assets(): AssetService.WithRawResponse + + fun cache(): CacheService.WithRawResponse + + fun folders(): FolderService.WithRawResponse + + fun accounts(): AccountService.WithRawResponse + + fun beta(): BetaService.WithRawResponse + + fun webhooks(): WebhookService.WithRawResponse + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt new file mode 100644 index 00000000..22131527 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt @@ -0,0 +1,111 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.client + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.services.async.AccountServiceAsync +import com.imagekit.api.services.async.AssetServiceAsync +import com.imagekit.api.services.async.BetaServiceAsync +import com.imagekit.api.services.async.CacheServiceAsync +import com.imagekit.api.services.async.CustomMetadataFieldServiceAsync +import com.imagekit.api.services.async.FileServiceAsync +import com.imagekit.api.services.async.FolderServiceAsync +import com.imagekit.api.services.async.WebhookServiceAsync +import java.util.function.Consumer + +/** + * A client for interacting with the Image Kit REST API asynchronously. You can also switch to + * synchronous execution via the [sync] method. + * + * This client performs best when you create a single instance and reuse it for all interactions + * with the REST API. This is because each client holds its own connection pool and thread pools. + * Reusing connections and threads reduces latency and saves memory. The client also handles rate + * limiting per client. This means that creating and using multiple instances at the same time will + * not respect rate limits. + * + * The threads and connections that are held will be released automatically if they remain idle. But + * if you are writing an application that needs to aggressively release unused resources, then you + * may call [close]. + */ +interface ImageKitClientAsync { + + /** + * Returns a version of this client that uses synchronous execution. + * + * The returned client shares its resources, like its connection pool and thread pools, with + * this client. + */ + fun sync(): ImageKitClient + + /** + * 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): ImageKitClientAsync + + fun customMetadataFields(): CustomMetadataFieldServiceAsync + + fun files(): FileServiceAsync + + fun assets(): AssetServiceAsync + + fun cache(): CacheServiceAsync + + fun folders(): FolderServiceAsync + + fun accounts(): AccountServiceAsync + + fun beta(): BetaServiceAsync + + fun webhooks(): WebhookServiceAsync + + /** + * Closes this client, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and + * usually should not be synchronously closed via try-with-resources. + * + * It's also usually not necessary to call this method at all. the default HTTP client + * automatically releases threads and connections if they remain idle, but if you are writing an + * application that needs to aggressively release unused resources, then you may call this + * method. + */ + fun close() + + /** + * A view of [ImageKitClientAsync] 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 + ): ImageKitClientAsync.WithRawResponse + + fun customMetadataFields(): CustomMetadataFieldServiceAsync.WithRawResponse + + fun files(): FileServiceAsync.WithRawResponse + + fun assets(): AssetServiceAsync.WithRawResponse + + fun cache(): CacheServiceAsync.WithRawResponse + + fun folders(): FolderServiceAsync.WithRawResponse + + fun accounts(): AccountServiceAsync.WithRawResponse + + fun beta(): BetaServiceAsync.WithRawResponse + + fun webhooks(): WebhookServiceAsync.WithRawResponse + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt new file mode 100644 index 00000000..4ddc0590 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt @@ -0,0 +1,154 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.client + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.getPackageVersion +import com.imagekit.api.services.async.AccountServiceAsync +import com.imagekit.api.services.async.AccountServiceAsyncImpl +import com.imagekit.api.services.async.AssetServiceAsync +import com.imagekit.api.services.async.AssetServiceAsyncImpl +import com.imagekit.api.services.async.BetaServiceAsync +import com.imagekit.api.services.async.BetaServiceAsyncImpl +import com.imagekit.api.services.async.CacheServiceAsync +import com.imagekit.api.services.async.CacheServiceAsyncImpl +import com.imagekit.api.services.async.CustomMetadataFieldServiceAsync +import com.imagekit.api.services.async.CustomMetadataFieldServiceAsyncImpl +import com.imagekit.api.services.async.FileServiceAsync +import com.imagekit.api.services.async.FileServiceAsyncImpl +import com.imagekit.api.services.async.FolderServiceAsync +import com.imagekit.api.services.async.FolderServiceAsyncImpl +import com.imagekit.api.services.async.WebhookServiceAsync +import com.imagekit.api.services.async.WebhookServiceAsyncImpl +import java.util.function.Consumer + +class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageKitClientAsync { + + private val clientOptionsWithUserAgent = + if (clientOptions.headers.names().contains("User-Agent")) clientOptions + else + clientOptions + .toBuilder() + .putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}") + .build() + + // Pass the original clientOptions so that this client sets its own User-Agent. + private val sync: ImageKitClient by lazy { ImageKitClientImpl(clientOptions) } + + private val withRawResponse: ImageKitClientAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val customMetadataFields: CustomMetadataFieldServiceAsync by lazy { + CustomMetadataFieldServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val files: FileServiceAsync by lazy { FileServiceAsyncImpl(clientOptionsWithUserAgent) } + + private val assets: AssetServiceAsync by lazy { + AssetServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val cache: CacheServiceAsync by lazy { + CacheServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val folders: FolderServiceAsync by lazy { + FolderServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val accounts: AccountServiceAsync by lazy { + AccountServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val beta: BetaServiceAsync by lazy { BetaServiceAsyncImpl(clientOptionsWithUserAgent) } + + private val webhooks: WebhookServiceAsync by lazy { + WebhookServiceAsyncImpl(clientOptionsWithUserAgent) + } + + override fun sync(): ImageKitClient = sync + + override fun withRawResponse(): ImageKitClientAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ImageKitClientAsync = + ImageKitClientAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun customMetadataFields(): CustomMetadataFieldServiceAsync = customMetadataFields + + override fun files(): FileServiceAsync = files + + override fun assets(): AssetServiceAsync = assets + + override fun cache(): CacheServiceAsync = cache + + override fun folders(): FolderServiceAsync = folders + + override fun accounts(): AccountServiceAsync = accounts + + override fun beta(): BetaServiceAsync = beta + + override fun webhooks(): WebhookServiceAsync = webhooks + + override fun close() = clientOptions.close() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ImageKitClientAsync.WithRawResponse { + + private val customMetadataFields: CustomMetadataFieldServiceAsync.WithRawResponse by lazy { + CustomMetadataFieldServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val files: FileServiceAsync.WithRawResponse by lazy { + FileServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val assets: AssetServiceAsync.WithRawResponse by lazy { + AssetServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val cache: CacheServiceAsync.WithRawResponse by lazy { + CacheServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val folders: FolderServiceAsync.WithRawResponse by lazy { + FolderServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val accounts: AccountServiceAsync.WithRawResponse by lazy { + AccountServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val beta: BetaServiceAsync.WithRawResponse by lazy { + BetaServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val webhooks: WebhookServiceAsync.WithRawResponse by lazy { + WebhookServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): ImageKitClientAsync.WithRawResponse = + ImageKitClientAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun customMetadataFields(): CustomMetadataFieldServiceAsync.WithRawResponse = + customMetadataFields + + override fun files(): FileServiceAsync.WithRawResponse = files + + override fun assets(): AssetServiceAsync.WithRawResponse = assets + + override fun cache(): CacheServiceAsync.WithRawResponse = cache + + override fun folders(): FolderServiceAsync.WithRawResponse = folders + + override fun accounts(): AccountServiceAsync.WithRawResponse = accounts + + override fun beta(): BetaServiceAsync.WithRawResponse = beta + + override fun webhooks(): WebhookServiceAsync.WithRawResponse = webhooks + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt new file mode 100644 index 00000000..433b100c --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt @@ -0,0 +1,144 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.client + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.getPackageVersion +import com.imagekit.api.services.blocking.AccountService +import com.imagekit.api.services.blocking.AccountServiceImpl +import com.imagekit.api.services.blocking.AssetService +import com.imagekit.api.services.blocking.AssetServiceImpl +import com.imagekit.api.services.blocking.BetaService +import com.imagekit.api.services.blocking.BetaServiceImpl +import com.imagekit.api.services.blocking.CacheService +import com.imagekit.api.services.blocking.CacheServiceImpl +import com.imagekit.api.services.blocking.CustomMetadataFieldService +import com.imagekit.api.services.blocking.CustomMetadataFieldServiceImpl +import com.imagekit.api.services.blocking.FileService +import com.imagekit.api.services.blocking.FileServiceImpl +import com.imagekit.api.services.blocking.FolderService +import com.imagekit.api.services.blocking.FolderServiceImpl +import com.imagekit.api.services.blocking.WebhookService +import com.imagekit.api.services.blocking.WebhookServiceImpl +import java.util.function.Consumer + +class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitClient { + + private val clientOptionsWithUserAgent = + if (clientOptions.headers.names().contains("User-Agent")) clientOptions + else + clientOptions + .toBuilder() + .putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}") + .build() + + // Pass the original clientOptions so that this client sets its own User-Agent. + private val async: ImageKitClientAsync by lazy { ImageKitClientAsyncImpl(clientOptions) } + + private val withRawResponse: ImageKitClient.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val customMetadataFields: CustomMetadataFieldService by lazy { + CustomMetadataFieldServiceImpl(clientOptionsWithUserAgent) + } + + private val files: FileService by lazy { FileServiceImpl(clientOptionsWithUserAgent) } + + private val assets: AssetService by lazy { AssetServiceImpl(clientOptionsWithUserAgent) } + + private val cache: CacheService by lazy { CacheServiceImpl(clientOptionsWithUserAgent) } + + private val folders: FolderService by lazy { FolderServiceImpl(clientOptionsWithUserAgent) } + + private val accounts: AccountService by lazy { AccountServiceImpl(clientOptionsWithUserAgent) } + + private val beta: BetaService by lazy { BetaServiceImpl(clientOptionsWithUserAgent) } + + private val webhooks: WebhookService by lazy { WebhookServiceImpl(clientOptionsWithUserAgent) } + + override fun async(): ImageKitClientAsync = async + + override fun withRawResponse(): ImageKitClient.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ImageKitClient = + ImageKitClientImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun customMetadataFields(): CustomMetadataFieldService = customMetadataFields + + override fun files(): FileService = files + + override fun assets(): AssetService = assets + + override fun cache(): CacheService = cache + + override fun folders(): FolderService = folders + + override fun accounts(): AccountService = accounts + + override fun beta(): BetaService = beta + + override fun webhooks(): WebhookService = webhooks + + override fun close() = clientOptions.close() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ImageKitClient.WithRawResponse { + + private val customMetadataFields: CustomMetadataFieldService.WithRawResponse by lazy { + CustomMetadataFieldServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val files: FileService.WithRawResponse by lazy { + FileServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val assets: AssetService.WithRawResponse by lazy { + AssetServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val cache: CacheService.WithRawResponse by lazy { + CacheServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val folders: FolderService.WithRawResponse by lazy { + FolderServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val accounts: AccountService.WithRawResponse by lazy { + AccountServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val beta: BetaService.WithRawResponse by lazy { + BetaServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val webhooks: WebhookService.WithRawResponse by lazy { + WebhookServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): ImageKitClient.WithRawResponse = + ImageKitClientImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun customMetadataFields(): CustomMetadataFieldService.WithRawResponse = + customMetadataFields + + override fun files(): FileService.WithRawResponse = files + + override fun assets(): AssetService.WithRawResponse = assets + + override fun cache(): CacheService.WithRawResponse = cache + + override fun folders(): FolderService.WithRawResponse = folders + + override fun accounts(): AccountService.WithRawResponse = accounts + + override fun beta(): BetaService.WithRawResponse = beta + + override fun webhooks(): WebhookService.WithRawResponse = webhooks + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/BaseDeserializer.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/BaseDeserializer.kt new file mode 100644 index 00000000..106fb746 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/BaseDeserializer.kt @@ -0,0 +1,44 @@ +package com.imagekit.api.core + +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.core.type.TypeReference +import com.fasterxml.jackson.databind.BeanProperty +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.JavaType +import com.fasterxml.jackson.databind.JsonDeserializer +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.deser.ContextualDeserializer +import com.fasterxml.jackson.databind.deser.std.StdDeserializer +import kotlin.reflect.KClass + +abstract class BaseDeserializer(type: KClass) : + StdDeserializer(type.java), ContextualDeserializer { + + override fun createContextual( + context: DeserializationContext, + property: BeanProperty?, + ): JsonDeserializer { + return this + } + + override fun deserialize(parser: JsonParser, context: DeserializationContext): T { + return parser.codec.deserialize(parser.readValueAsTree()) + } + + protected abstract fun ObjectCodec.deserialize(node: JsonNode): T + + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: TypeReference): T? = + try { + readValue(treeAsTokens(node), type) + } catch (e: Exception) { + null + } + + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: JavaType): T? = + try { + readValue(treeAsTokens(node), type) + } catch (e: Exception) { + null + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/BaseSerializer.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/BaseSerializer.kt new file mode 100644 index 00000000..b0d195be --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/BaseSerializer.kt @@ -0,0 +1,6 @@ +package com.imagekit.api.core + +import com.fasterxml.jackson.databind.ser.std.StdSerializer +import kotlin.reflect.KClass + +abstract class BaseSerializer(type: KClass) : StdSerializer(type.java) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Check.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Check.kt new file mode 100644 index 00000000..93bcc538 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Check.kt @@ -0,0 +1,96 @@ +@file:JvmName("Check") + +package com.imagekit.api.core + +import com.fasterxml.jackson.core.Version +import com.fasterxml.jackson.core.util.VersionUtil + +fun checkRequired(name: String, condition: Boolean) = + check(condition) { "`$name` is required, but was not set" } + +fun checkRequired(name: String, value: T?): T = + checkNotNull(value) { "`$name` is required, but was not set" } + +@JvmSynthetic +internal fun checkKnown(name: String, value: JsonField): T = + value.asKnown().orElseThrow { + IllegalStateException("`$name` is not a known type: ${value.javaClass.simpleName}") + } + +@JvmSynthetic +internal fun checkKnown(name: String, value: MultipartField): T = + value.value.asKnown().orElseThrow { + IllegalStateException("`$name` is not a known type: ${value.javaClass.simpleName}") + } + +@JvmSynthetic +internal fun checkLength(name: String, value: String, length: Int): String = + value.also { + check(it.length == length) { "`$name` must have length $length, but was ${it.length}" } + } + +@JvmSynthetic +internal fun checkMinLength(name: String, value: String, minLength: Int): String = + value.also { + check(it.length >= minLength) { + if (minLength == 1) "`$name` must be non-empty, but was empty" + else "`$name` must have at least length $minLength, but was ${it.length}" + } + } + +@JvmSynthetic +internal fun checkMaxLength(name: String, value: String, maxLength: Int): String = + value.also { + check(it.length <= maxLength) { + "`$name` must have at most length $maxLength, but was ${it.length}" + } + } + +@JvmSynthetic +internal fun checkJacksonVersionCompatibility() { + val incompatibleJacksonVersions = + RUNTIME_JACKSON_VERSIONS.mapNotNull { + val badVersionReason = BAD_JACKSON_VERSIONS[it.toString()] + when { + it.majorVersion != MINIMUM_JACKSON_VERSION.majorVersion -> + it to "incompatible major version" + it.minorVersion < MINIMUM_JACKSON_VERSION.minorVersion -> + it to "minor version too low" + it.minorVersion == MINIMUM_JACKSON_VERSION.minorVersion && + it.patchLevel < MINIMUM_JACKSON_VERSION.patchLevel -> + it to "patch version too low" + badVersionReason != null -> it to badVersionReason + else -> null + } + } + check(incompatibleJacksonVersions.isEmpty()) { + """ +This SDK requires a minimum Jackson version of $MINIMUM_JACKSON_VERSION, but the following incompatible Jackson versions were detected at runtime: + +${incompatibleJacksonVersions.asSequence().map { (version, incompatibilityReason) -> + "- `${version.toFullString().replace("/", ":")}` ($incompatibilityReason)" +}.joinToString("\n")} + +This can happen if you are either: +1. Directly depending on different Jackson versions +2. Depending on some library that depends on different Jackson versions, potentially transitively + +Double-check that you are depending on compatible Jackson versions. + +See https://www.github.com/stainless-sdks/imagekit-java#jackson for more information. + """ + .trimIndent() + } +} + +private val MINIMUM_JACKSON_VERSION: Version = VersionUtil.parseVersion("2.13.4", null, null) +private val BAD_JACKSON_VERSIONS: Map = + mapOf("2.18.1" to "due to https://github.com/FasterXML/jackson-databind/issues/4639") +private val RUNTIME_JACKSON_VERSIONS: List = + listOf( + com.fasterxml.jackson.core.json.PackageVersion.VERSION, + com.fasterxml.jackson.databind.cfg.PackageVersion.VERSION, + com.fasterxml.jackson.datatype.jdk8.PackageVersion.VERSION, + com.fasterxml.jackson.datatype.jsr310.PackageVersion.VERSION, + com.fasterxml.jackson.module.kotlin.PackageVersion.VERSION, + ) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt new file mode 100644 index 00000000..7b379cd1 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt @@ -0,0 +1,496 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.core + +import com.fasterxml.jackson.databind.json.JsonMapper +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.HttpClient +import com.imagekit.api.core.http.PhantomReachableClosingHttpClient +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.core.http.RetryingHttpClient +import java.time.Clock +import java.time.Duration +import java.util.Base64 +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A class representing the SDK client configuration. */ +class ClientOptions +private constructor( + private val originalHttpClient: HttpClient, + /** + * The HTTP client to use in the SDK. + * + * Use the one published in `image-kit-java-client-okhttp` or implement your own. + * + * This class takes ownership of the client and closes it when closed. + */ + @get:JvmName("httpClient") val httpClient: HttpClient, + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee that + * the SDK will work correctly when using an incompatible Jackson version. + */ + @get:JvmName("checkJacksonVersionCompatibility") val checkJacksonVersionCompatibility: Boolean, + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [com.imagekit.api.core.jsonMapper]. The default is usually sufficient and rarely + * needs to be overridden. + */ + @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + @get:JvmName("clock") val clock: Clock, + private val baseUrl: String?, + /** Headers to send with the request. */ + @get:JvmName("headers") val headers: Headers, + /** Query params to send with the request. */ + @get:JvmName("queryParams") val queryParams: QueryParams, + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ + @get:JvmName("responseValidation") val responseValidation: Boolean, + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ + @get:JvmName("timeout") val timeout: Timeout, + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * Only the following error types are retried: + * - Connection errors (for example, due to a network connectivity problem) + * - 408 Request Timeout + * - 409 Conflict + * - 429 Rate Limit + * - 5xx Internal + * + * The API may also explicitly instruct the SDK to retry or not retry a request. + * + * Defaults to 2. + */ + @get:JvmName("maxRetries") val maxRetries: Int, + /** + * Your ImageKit private API key (it starts with `private_`). You can view and manage API keys + * in the [dashboard](https://imagekit.io/dashboard/developer/api-keys). + */ + @get:JvmName("privateApiKey") val privateApiKey: String, + private val password: String?, + private val webhookSecret: String?, +) { + + init { + if (checkJacksonVersionCompatibility) { + checkJacksonVersionCompatibility() + } + } + + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.imagekit.io`. + */ + fun baseUrl(): String = baseUrl ?: PRODUCTION_URL + + fun baseUrlOverridden(): Boolean = baseUrl != null + + /** + * ImageKit Basic Auth only uses the username field and ignores the password. This field is + * unused. + * + * Defaults to `"do_not_set"`. + */ + fun password(): Optional = Optional.ofNullable(password) + + /** + * Your ImageKit webhook secret. This is used by the SDK to verify webhook signatures. It starts + * with a `whsec_` prefix. You can view and manage your webhook secret in the + * [dashboard](https://imagekit.io/dashboard/developer/webhooks). Treat the secret like a + * password, keep it private and do not expose it publicly. Learn more about + * [webhook verification](https://imagekit.io/docs/webhooks#verify-webhook-signature). + */ + fun webhookSecret(): Optional = Optional.ofNullable(webhookSecret) + + fun toBuilder() = Builder().from(this) + + companion object { + + const val PRODUCTION_URL = "https://api.imagekit.io" + + /** + * Returns a mutable builder for constructing an instance of [ClientOptions]. + * + * The following fields are required: + * ```java + * .httpClient() + * .privateApiKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns options configured using system properties and environment variables. + * + * @see Builder.fromEnv + */ + @JvmStatic fun fromEnv(): ClientOptions = builder().fromEnv().build() + } + + /** A builder for [ClientOptions]. */ + class Builder internal constructor() { + + private var httpClient: HttpClient? = null + private var checkJacksonVersionCompatibility: Boolean = true + private var jsonMapper: JsonMapper = jsonMapper() + private var clock: Clock = Clock.systemUTC() + private var baseUrl: String? = null + private var headers: Headers.Builder = Headers.builder() + private var queryParams: QueryParams.Builder = QueryParams.builder() + private var responseValidation: Boolean = false + private var timeout: Timeout = Timeout.default() + private var maxRetries: Int = 2 + private var privateApiKey: String? = null + private var password: String? = "do_not_set" + private var webhookSecret: String? = null + + @JvmSynthetic + internal fun from(clientOptions: ClientOptions) = apply { + httpClient = clientOptions.originalHttpClient + checkJacksonVersionCompatibility = clientOptions.checkJacksonVersionCompatibility + jsonMapper = clientOptions.jsonMapper + clock = clientOptions.clock + baseUrl = clientOptions.baseUrl + headers = clientOptions.headers.toBuilder() + queryParams = clientOptions.queryParams.toBuilder() + responseValidation = clientOptions.responseValidation + timeout = clientOptions.timeout + maxRetries = clientOptions.maxRetries + privateApiKey = clientOptions.privateApiKey + password = clientOptions.password + webhookSecret = clientOptions.webhookSecret + } + + /** + * The HTTP client to use in the SDK. + * + * Use the one published in `image-kit-java-client-okhttp` or implement your own. + * + * This class takes ownership of the client and closes it when closed. + */ + fun httpClient(httpClient: HttpClient) = apply { + this.httpClient = PhantomReachableClosingHttpClient(httpClient) + } + + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee + * that the SDK will work correctly when using an incompatible Jackson version. + */ + fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { + this.checkJacksonVersionCompatibility = checkJacksonVersionCompatibility + } + + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [com.imagekit.api.core.jsonMapper]. The default is usually sufficient and + * rarely needs to be overridden. + */ + fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } + + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + fun clock(clock: Clock) = apply { this.clock = clock } + + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.imagekit.io`. + */ + fun baseUrl(baseUrl: String?) = apply { this.baseUrl = baseUrl } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ + fun responseValidation(responseValidation: Boolean) = apply { + this.responseValidation = responseValidation + } + + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) + + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * Only the following error types are retried: + * - Connection errors (for example, due to a network connectivity problem) + * - 408 Request Timeout + * - 409 Conflict + * - 429 Rate Limit + * - 5xx Internal + * + * The API may also explicitly instruct the SDK to retry or not retry a request. + * + * Defaults to 2. + */ + fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + + /** + * Your ImageKit private API key (it starts with `private_`). You can view and manage API + * keys in the [dashboard](https://imagekit.io/dashboard/developer/api-keys). + */ + fun privateApiKey(privateApiKey: String) = apply { this.privateApiKey = privateApiKey } + + /** + * ImageKit Basic Auth only uses the username field and ignores the password. This field is + * unused. + * + * Defaults to `"do_not_set"`. + */ + fun password(password: String?) = apply { this.password = password } + + /** Alias for calling [Builder.password] with `password.orElse(null)`. */ + fun password(password: Optional) = password(password.getOrNull()) + + /** + * Your ImageKit webhook secret. This is used by the SDK to verify webhook signatures. It + * starts with a `whsec_` prefix. You can view and manage your webhook secret in the + * [dashboard](https://imagekit.io/dashboard/developer/webhooks). Treat the secret like a + * password, keep it private and do not expose it publicly. Learn more about + * [webhook verification](https://imagekit.io/docs/webhooks#verify-webhook-signature). + */ + fun webhookSecret(webhookSecret: String?) = apply { this.webhookSecret = webhookSecret } + + /** Alias for calling [Builder.webhookSecret] with `webhookSecret.orElse(null)`. */ + fun webhookSecret(webhookSecret: Optional) = + webhookSecret(webhookSecret.getOrNull()) + + fun headers(headers: Headers) = apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun headers(headers: Map>) = apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun putHeader(name: String, value: String) = apply { headers.put(name, value) } + + fun putHeaders(name: String, values: Iterable) = apply { headers.put(name, values) } + + fun putAllHeaders(headers: Headers) = apply { this.headers.putAll(headers) } + + fun putAllHeaders(headers: Map>) = apply { + this.headers.putAll(headers) + } + + fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) } + + fun replaceHeaders(name: String, values: Iterable) = apply { + headers.replace(name, values) + } + + fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) } + + fun replaceAllHeaders(headers: Map>) = apply { + this.headers.replaceAll(headers) + } + + fun removeHeaders(name: String) = apply { headers.remove(name) } + + fun removeAllHeaders(names: Set) = apply { headers.removeAll(names) } + + fun queryParams(queryParams: QueryParams) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } + + fun queryParams(queryParams: Map>) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } + + fun putQueryParams(key: String, values: Iterable) = apply { + queryParams.put(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.putAll(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + this.queryParams.putAll(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = apply { + queryParams.replace(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + queryParams.replace(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.replaceAll(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + this.queryParams.replaceAll(queryParams) + } + + fun removeQueryParams(key: String) = apply { queryParams.remove(key) } + + fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } + + fun timeout(): Timeout = timeout + + /** + * Updates configuration using system properties and environment variables. + * + * See this table for the available options: + * + * |Setter |System property |Environment variable |Required|Default value | + * |---------------|--------------------------------------|--------------------------------|--------|---------------------------| + * |`privateApiKey`|`imagekit.imagekitPrivateApiKey` |`IMAGEKIT_PRIVATE_API_KEY` |true |- | + * |`password` |`imagekit.optionalImagekitIgnoresThis`|`OPTIONAL_IMAGEKIT_IGNORES_THIS`|false |`"do_not_set"` | + * |`webhookSecret`|`imagekit.imagekitWebhookSecret` |`IMAGEKIT_WEBHOOK_SECRET` |false |- | + * |`baseUrl` |`imagekit.baseUrl` |`IMAGE_KIT_BASE_URL` |true |`"https://api.imagekit.io"`| + * + * System properties take precedence over environment variables. + */ + fun fromEnv() = apply { + (System.getProperty("imagekit.baseUrl") ?: System.getenv("IMAGE_KIT_BASE_URL"))?.let { + baseUrl(it) + } + (System.getProperty("imagekit.imagekitPrivateApiKey") + ?: System.getenv("IMAGEKIT_PRIVATE_API_KEY")) + ?.let { privateApiKey(it) } + (System.getProperty("imagekit.optionalImagekitIgnoresThis") + ?: System.getenv("OPTIONAL_IMAGEKIT_IGNORES_THIS")) + ?.let { password(it) } + (System.getProperty("imagekit.imagekitWebhookSecret") + ?: System.getenv("IMAGEKIT_WEBHOOK_SECRET")) + ?.let { webhookSecret(it) } + } + + /** + * Returns an immutable instance of [ClientOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .httpClient() + * .privateApiKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ClientOptions { + val httpClient = checkRequired("httpClient", httpClient) + val privateApiKey = checkRequired("privateApiKey", privateApiKey) + + val headers = Headers.builder() + val queryParams = QueryParams.builder() + headers.put("X-Stainless-Lang", "java") + headers.put("X-Stainless-Arch", getOsArch()) + headers.put("X-Stainless-OS", getOsName()) + headers.put("X-Stainless-OS-Version", getOsVersion()) + headers.put("X-Stainless-Package-Version", getPackageVersion()) + headers.put("X-Stainless-Runtime", "JRE") + headers.put("X-Stainless-Runtime-Version", getJavaVersion()) + privateApiKey.let { username -> + password?.let { password -> + if (!username.isEmpty() && !password.isEmpty()) { + headers.put( + "Authorization", + "Basic ${Base64.getEncoder().encodeToString("$username:$password".toByteArray())}", + ) + } + } + } + headers.replaceAll(this.headers.build()) + queryParams.replaceAll(this.queryParams.build()) + + return ClientOptions( + httpClient, + RetryingHttpClient.builder() + .httpClient(httpClient) + .clock(clock) + .maxRetries(maxRetries) + .build(), + checkJacksonVersionCompatibility, + jsonMapper, + clock, + baseUrl, + headers.build(), + queryParams.build(), + responseValidation, + timeout, + maxRetries, + privateApiKey, + password, + webhookSecret, + ) + } + } + + /** + * Closes these client options, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client options are + * long-lived and usually should not be synchronously closed via try-with-resources. + * + * It's also usually not necessary to call this method at all. the default client automatically + * releases threads and connections if they remain idle, but if you are writing an application + * that needs to aggressively release unused resources, then you may call this method. + */ + fun close() { + httpClient.close() + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ObjectMappers.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ObjectMappers.kt new file mode 100644 index 00000000..beaef0fa --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ObjectMappers.kt @@ -0,0 +1,167 @@ +@file:JvmName("ObjectMappers") + +package com.imagekit.api.core + +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.JsonParseException +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.DeserializationFeature +import com.fasterxml.jackson.databind.MapperFeature +import com.fasterxml.jackson.databind.SerializationFeature +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.cfg.CoercionAction +import com.fasterxml.jackson.databind.cfg.CoercionInputShape +import com.fasterxml.jackson.databind.deser.std.StdDeserializer +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.databind.module.SimpleModule +import com.fasterxml.jackson.databind.type.LogicalType +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule +import com.fasterxml.jackson.module.kotlin.kotlinModule +import java.io.InputStream +import java.time.DateTimeException +import java.time.LocalDate +import java.time.LocalDateTime +import java.time.ZonedDateTime +import java.time.format.DateTimeFormatter +import java.time.temporal.ChronoField + +fun jsonMapper(): JsonMapper = + JsonMapper.builder() + .addModule(kotlinModule()) + .addModule(Jdk8Module()) + .addModule(JavaTimeModule()) + .addModule( + SimpleModule() + .addSerializer(InputStreamSerializer) + .addDeserializer(LocalDateTime::class.java, LenientLocalDateTimeDeserializer()) + ) + .withCoercionConfig(LogicalType.Boolean) { + it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Integer) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Float) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Textual) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Array) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Collection) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Map) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.POJO) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + } + .serializationInclusion(JsonInclude.Include.NON_ABSENT) + .disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE) + .disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .disable(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS) + .disable(MapperFeature.ALLOW_COERCION_OF_SCALARS) + .disable(MapperFeature.AUTO_DETECT_CREATORS) + .disable(MapperFeature.AUTO_DETECT_FIELDS) + .disable(MapperFeature.AUTO_DETECT_GETTERS) + .disable(MapperFeature.AUTO_DETECT_IS_GETTERS) + .disable(MapperFeature.AUTO_DETECT_SETTERS) + .build() + +/** A serializer that serializes [InputStream] to bytes. */ +private object InputStreamSerializer : BaseSerializer(InputStream::class) { + + private fun readResolve(): Any = InputStreamSerializer + + override fun serialize( + value: InputStream?, + gen: JsonGenerator?, + serializers: SerializerProvider?, + ) { + if (value == null) { + gen?.writeNull() + } else { + value.use { gen?.writeBinary(it.readBytes()) } + } + } +} + +/** + * A deserializer that can deserialize [LocalDateTime] from datetimes, dates, and zoned datetimes. + */ +private class LenientLocalDateTimeDeserializer : + StdDeserializer(LocalDateTime::class.java) { + + companion object { + + private val DATE_TIME_FORMATTERS = + listOf( + DateTimeFormatter.ISO_LOCAL_DATE_TIME, + DateTimeFormatter.ISO_LOCAL_DATE, + DateTimeFormatter.ISO_ZONED_DATE_TIME, + ) + } + + override fun logicalType(): LogicalType = LogicalType.DateTime + + override fun deserialize(p: JsonParser, context: DeserializationContext?): LocalDateTime { + val exceptions = mutableListOf() + + for (formatter in DATE_TIME_FORMATTERS) { + try { + val temporal = formatter.parse(p.text) + + return when { + !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> + LocalDate.from(temporal).atStartOfDay() + !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> + LocalDateTime.from(temporal) + else -> ZonedDateTime.from(temporal).toLocalDateTime() + } + } catch (e: DateTimeException) { + exceptions.add(e) + } + } + + throw JsonParseException(p, "Cannot parse `LocalDateTime` from value: ${p.text}").apply { + exceptions.forEach { addSuppressed(it) } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Params.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Params.kt new file mode 100644 index 00000000..2a62a936 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Params.kt @@ -0,0 +1,16 @@ +package com.imagekit.api.core + +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams + +/** An interface representing parameters passed to a service method. */ +interface Params { + /** The full set of headers in the parameters, including both fixed and additional headers. */ + fun _headers(): Headers + + /** + * The full set of query params in the parameters, including both fixed and additional query + * params. + */ + fun _queryParams(): QueryParams +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachable.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachable.kt new file mode 100644 index 00000000..d17a6894 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachable.kt @@ -0,0 +1,56 @@ +@file:JvmName("PhantomReachable") + +package com.imagekit.api.core + +import com.imagekit.api.errors.ImageKitException +import java.lang.reflect.InvocationTargetException + +/** + * Closes [closeable] when [observed] becomes only phantom reachable. + * + * This is a wrapper around a Java 9+ [java.lang.ref.Cleaner], or a no-op in older Java versions. + */ +@JvmSynthetic +internal fun closeWhenPhantomReachable(observed: Any, closeable: AutoCloseable) { + check(observed !== closeable) { + "`observed` cannot be the same object as `closeable` because it would never become phantom reachable" + } + closeWhenPhantomReachable(observed, closeable::close) +} + +/** + * Calls [close] when [observed] becomes only phantom reachable. + * + * This is a wrapper around a Java 9+ [java.lang.ref.Cleaner], or a no-op in older Java versions. + */ +@JvmSynthetic +internal fun closeWhenPhantomReachable(observed: Any, close: () -> Unit) { + closeWhenPhantomReachable?.let { it(observed, close) } +} + +private val closeWhenPhantomReachable: ((Any, () -> Unit) -> Unit)? by lazy { + try { + val cleanerClass = Class.forName("java.lang.ref.Cleaner") + val cleanerCreate = cleanerClass.getMethod("create") + val cleanerRegister = + cleanerClass.getMethod("register", Any::class.java, Runnable::class.java) + val cleanerObject = cleanerCreate.invoke(null); + + { observed, close -> + try { + cleanerRegister.invoke(cleanerObject, observed, Runnable { close() }) + } catch (e: ReflectiveOperationException) { + if (e is InvocationTargetException) { + when (val cause = e.cause) { + is RuntimeException, + is Error -> throw cause + } + } + throw ImageKitException("Unexpected reflective invocation failure", e) + } + } + } catch (e: ReflectiveOperationException) { + // We're running Java 8, which has no Cleaner. + null + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachableExecutorService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachableExecutorService.kt new file mode 100644 index 00000000..19a35385 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachableExecutorService.kt @@ -0,0 +1,58 @@ +package com.imagekit.api.core + +import java.util.concurrent.Callable +import java.util.concurrent.ExecutorService +import java.util.concurrent.Future +import java.util.concurrent.TimeUnit + +/** + * A delegating wrapper around an [ExecutorService] that shuts it down once it's only phantom + * reachable. + * + * This class ensures the [ExecutorService] is shut down even if the user forgets to do it. + */ +internal class PhantomReachableExecutorService(private val executorService: ExecutorService) : + ExecutorService { + init { + closeWhenPhantomReachable(this) { executorService.shutdown() } + } + + override fun execute(command: Runnable) = executorService.execute(command) + + override fun shutdown() = executorService.shutdown() + + override fun shutdownNow(): MutableList = executorService.shutdownNow() + + override fun isShutdown(): Boolean = executorService.isShutdown + + override fun isTerminated(): Boolean = executorService.isTerminated + + override fun awaitTermination(timeout: Long, unit: TimeUnit): Boolean = + executorService.awaitTermination(timeout, unit) + + override fun submit(task: Callable): Future = executorService.submit(task) + + override fun submit(task: Runnable, result: T): Future = + executorService.submit(task, result) + + override fun submit(task: Runnable): Future<*> = executorService.submit(task) + + override fun invokeAll( + tasks: MutableCollection> + ): MutableList> = executorService.invokeAll(tasks) + + override fun invokeAll( + tasks: MutableCollection>, + timeout: Long, + unit: TimeUnit, + ): MutableList> = executorService.invokeAll(tasks, timeout, unit) + + override fun invokeAny(tasks: MutableCollection>): T = + executorService.invokeAny(tasks) + + override fun invokeAny( + tasks: MutableCollection>, + timeout: Long, + unit: TimeUnit, + ): T = executorService.invokeAny(tasks, timeout, unit) +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PrepareRequest.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PrepareRequest.kt new file mode 100644 index 00000000..5ea20e42 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PrepareRequest.kt @@ -0,0 +1,24 @@ +@file:JvmName("PrepareRequest") + +package com.imagekit.api.core + +import com.imagekit.api.core.http.HttpRequest +import java.util.concurrent.CompletableFuture + +@JvmSynthetic +internal fun HttpRequest.prepare(clientOptions: ClientOptions, params: Params): HttpRequest = + toBuilder() + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params._queryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params._headers()) + .build() + +@JvmSynthetic +internal fun HttpRequest.prepareAsync( + clientOptions: ClientOptions, + params: Params, +): CompletableFuture = + // This async version exists to make it easier to add async specific preparation logic in the + // future. + CompletableFuture.completedFuture(prepare(clientOptions, params)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Properties.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Properties.kt new file mode 100644 index 00000000..bc15f01f --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Properties.kt @@ -0,0 +1,42 @@ +@file:JvmName("Properties") + +package com.imagekit.api.core + +import java.util.Properties + +fun getOsArch(): String { + val osArch = System.getProperty("os.arch") + + return when (osArch) { + null -> "unknown" + "i386", + "x32", + "x86" -> "x32" + "amd64", + "x86_64" -> "x64" + "arm" -> "arm" + "aarch64" -> "arm64" + else -> "other:${osArch}" + } +} + +fun getOsName(): String { + val osName = System.getProperty("os.name") + val vendorUrl = System.getProperty("java.vendor.url") + + return when { + osName == null -> "Unknown" + osName.startsWith("Linux") && vendorUrl == "http://www.android.com/" -> "Android" + osName.startsWith("Linux") -> "Linux" + osName.startsWith("Mac OS") -> "MacOS" + osName.startsWith("Windows") -> "Windows" + else -> "Other:${osName}" + } +} + +fun getOsVersion(): String = System.getProperty("os.version", "unknown") + +fun getPackageVersion(): String = + Properties::class.java.`package`.implementationVersion ?: "unknown" + +fun getJavaVersion(): String = System.getProperty("java.version", "unknown") diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/RequestOptions.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/RequestOptions.kt new file mode 100644 index 00000000..2d4840a6 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/RequestOptions.kt @@ -0,0 +1,46 @@ +package com.imagekit.api.core + +import java.time.Duration + +class RequestOptions private constructor(val responseValidation: Boolean?, val timeout: Timeout?) { + + companion object { + + private val NONE = builder().build() + + @JvmStatic fun none() = NONE + + @JvmSynthetic + internal fun from(clientOptions: ClientOptions): RequestOptions = + builder() + .responseValidation(clientOptions.responseValidation) + .timeout(clientOptions.timeout) + .build() + + @JvmStatic fun builder() = Builder() + } + + fun applyDefaults(options: RequestOptions): RequestOptions = + RequestOptions( + responseValidation = responseValidation ?: options.responseValidation, + timeout = + if (options.timeout != null && timeout != null) timeout.assign(options.timeout) + else timeout ?: options.timeout, + ) + + class Builder internal constructor() { + + private var responseValidation: Boolean? = null + private var timeout: Timeout? = null + + fun responseValidation(responseValidation: Boolean) = apply { + this.responseValidation = responseValidation + } + + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) + + fun build(): RequestOptions = RequestOptions(responseValidation, timeout) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Timeout.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Timeout.kt new file mode 100644 index 00000000..5ca59899 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Timeout.kt @@ -0,0 +1,171 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.core + +import java.time.Duration +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A class containing timeouts for various processing phases of a request. */ +class Timeout +private constructor( + private val connect: Duration?, + private val read: Duration?, + private val write: Duration?, + private val request: Duration?, +) { + + /** + * The maximum time allowed to establish a connection with a host. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun connect(): Duration = connect ?: Duration.ofMinutes(1) + + /** + * The maximum time allowed between two data packets when waiting for the server’s response. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun read(): Duration = read ?: request() + + /** + * The maximum time allowed between two data packets when sending the request to the server. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun write(): Duration = write ?: request() + + /** + * The maximum time allowed for a complete HTTP call, not including retries. + * + * This includes resolving DNS, connecting, writing the request body, server processing, as well + * as reading the response body. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun request(): Duration = request ?: Duration.ofMinutes(1) + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun default() = builder().build() + + /** Returns a mutable builder for constructing an instance of [Timeout]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Timeout]. */ + class Builder internal constructor() { + + private var connect: Duration? = null + private var read: Duration? = null + private var write: Duration? = null + private var request: Duration? = null + + @JvmSynthetic + internal fun from(timeout: Timeout) = apply { + connect = timeout.connect + read = timeout.read + write = timeout.write + request = timeout.request + } + + /** + * The maximum time allowed to establish a connection with a host. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun connect(connect: Duration?) = apply { this.connect = connect } + + /** Alias for calling [Builder.connect] with `connect.orElse(null)`. */ + fun connect(connect: Optional) = connect(connect.getOrNull()) + + /** + * The maximum time allowed between two data packets when waiting for the server’s response. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun read(read: Duration?) = apply { this.read = read } + + /** Alias for calling [Builder.read] with `read.orElse(null)`. */ + fun read(read: Optional) = read(read.getOrNull()) + + /** + * The maximum time allowed between two data packets when sending the request to the server. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun write(write: Duration?) = apply { this.write = write } + + /** Alias for calling [Builder.write] with `write.orElse(null)`. */ + fun write(write: Optional) = write(write.getOrNull()) + + /** + * The maximum time allowed for a complete HTTP call, not including retries. + * + * This includes resolving DNS, connecting, writing the request body, server processing, as + * well as reading the response body. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun request(request: Duration?) = apply { this.request = request } + + /** Alias for calling [Builder.request] with `request.orElse(null)`. */ + fun request(request: Optional) = request(request.getOrNull()) + + /** + * Returns an immutable instance of [Timeout]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Timeout = Timeout(connect, read, write, request) + } + + @JvmSynthetic + internal fun assign(target: Timeout): Timeout = + target + .toBuilder() + .apply { + connect?.let(this::connect) + read?.let(this::read) + write?.let(this::write) + request?.let(this::request) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Timeout && + connect == other.connect && + read == other.read && + write == other.write && + request == other.request + } + + override fun hashCode(): Int = Objects.hash(connect, read, write, request) + + override fun toString() = + "Timeout{connect=$connect, read=$read, write=$write, request=$request}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Utils.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Utils.kt new file mode 100644 index 00000000..20765365 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Utils.kt @@ -0,0 +1,115 @@ +@file:JvmName("Utils") + +package com.imagekit.api.core + +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.SortedMap +import java.util.concurrent.CompletableFuture +import java.util.concurrent.locks.Lock + +@JvmSynthetic +internal fun T?.getOrThrow(name: String): T = + this ?: throw ImageKitInvalidDataException("`${name}` is not present") + +@JvmSynthetic +internal fun List.toImmutable(): List = + if (isEmpty()) Collections.emptyList() else Collections.unmodifiableList(toList()) + +@JvmSynthetic +internal fun Map.toImmutable(): Map = + if (isEmpty()) immutableEmptyMap() else Collections.unmodifiableMap(toMap()) + +@JvmSynthetic internal fun immutableEmptyMap(): Map = Collections.emptyMap() + +@JvmSynthetic +internal fun , V> SortedMap.toImmutable(): SortedMap = + if (isEmpty()) Collections.emptySortedMap() + else Collections.unmodifiableSortedMap(toSortedMap(comparator())) + +/** + * Returns all elements that yield the largest value for the given function, or an empty list if + * there are zero elements. + * + * This is similar to [Sequence.maxByOrNull] except it returns _all_ elements that yield the largest + * value; not just the first one. + */ +@JvmSynthetic +internal fun > Sequence.allMaxBy(selector: (T) -> R): List { + var maxValue: R? = null + val maxElements = mutableListOf() + + val iterator = iterator() + while (iterator.hasNext()) { + val element = iterator.next() + val value = selector(element) + if (maxValue == null || value > maxValue) { + maxValue = value + maxElements.clear() + maxElements.add(element) + } else if (value == maxValue) { + maxElements.add(element) + } + } + + return maxElements +} + +/** + * Returns whether [this] is equal to [other]. + * + * This differs from [Object.equals] because it also deeply equates arrays based on their contents, + * even when there are arrays directly nested within other arrays. + */ +@JvmSynthetic +internal infix fun Any?.contentEquals(other: Any?): Boolean = + arrayOf(this).contentDeepEquals(arrayOf(other)) + +/** + * Returns a hash of the given sequence of [values]. + * + * This differs from [java.util.Objects.hash] because it also deeply hashes arrays based on their + * contents, even when there are arrays directly nested within other arrays. + */ +@JvmSynthetic internal fun contentHash(vararg values: Any?): Int = values.contentDeepHashCode() + +/** + * Returns a [String] representation of [this]. + * + * This differs from [Object.toString] because it also deeply stringifies arrays based on their + * contents, even when there are arrays directly nested within other arrays. + */ +@JvmSynthetic +internal fun Any?.contentToString(): String { + var string = arrayOf(this).contentDeepToString() + if (string.startsWith('[')) { + string = string.substring(1) + } + if (string.endsWith(']')) { + string = string.substring(0, string.length - 1) + } + return string +} + +internal interface Enum + +/** + * Executes the given [action] while holding the lock, returning a [CompletableFuture] with the + * result. + * + * @param action The asynchronous action to execute while holding the lock + * @return A [CompletableFuture] that completes with the result of the action + */ +@JvmSynthetic +internal fun Lock.withLockAsync(action: () -> CompletableFuture): CompletableFuture { + lock() + val future = + try { + action() + } catch (e: Throwable) { + unlock() + throw e + } + future.whenComplete { _, _ -> unlock() } + return future +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt new file mode 100644 index 00000000..43bda412 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt @@ -0,0 +1,723 @@ +package com.imagekit.api.core + +import com.fasterxml.jackson.annotation.JacksonAnnotationsInside +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.core.type.TypeReference +import com.fasterxml.jackson.databind.BeanProperty +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.JavaType +import com.fasterxml.jackson.databind.JsonDeserializer +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.node.JsonNodeType.ARRAY +import com.fasterxml.jackson.databind.node.JsonNodeType.BINARY +import com.fasterxml.jackson.databind.node.JsonNodeType.BOOLEAN +import com.fasterxml.jackson.databind.node.JsonNodeType.MISSING +import com.fasterxml.jackson.databind.node.JsonNodeType.NULL +import com.fasterxml.jackson.databind.node.JsonNodeType.NUMBER +import com.fasterxml.jackson.databind.node.JsonNodeType.OBJECT +import com.fasterxml.jackson.databind.node.JsonNodeType.POJO +import com.fasterxml.jackson.databind.node.JsonNodeType.STRING +import com.fasterxml.jackson.databind.ser.std.NullSerializer +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.io.InputStream +import java.util.Objects +import java.util.Optional + +/** + * A class representing a serializable JSON field. + * + * It can either be a [KnownValue] value of type [T], matching the type the SDK expects, or an + * arbitrary JSON value that bypasses the type system (via [JsonValue]). + */ +@JsonDeserialize(using = JsonField.Deserializer::class) +sealed class JsonField { + + /** + * Returns whether this field is missing, which means it will be omitted from the serialized + * JSON entirely. + */ + fun isMissing(): Boolean = this is JsonMissing + + /** Whether this field is explicitly set to `null`. */ + fun isNull(): Boolean = this is JsonNull + + /** + * Returns an [Optional] containing this field's "known" value, meaning it matches the type the + * SDK expects, or an empty [Optional] if this field contains an arbitrary [JsonValue]. + * + * This is the opposite of [asUnknown]. + */ + fun asKnown(): + Optional< + // Safe because `Optional` is effectively covariant, but Kotlin doesn't know that. + @UnsafeVariance + T + > = Optional.ofNullable((this as? KnownValue)?.value) + + /** + * Returns an [Optional] containing this field's arbitrary [JsonValue], meaning it mismatches + * the type the SDK expects, or an empty [Optional] if this field contains a "known" value. + * + * This is the opposite of [asKnown]. + */ + fun asUnknown(): Optional = Optional.ofNullable(this as? JsonValue) + + /** + * Returns an [Optional] containing this field's boolean value, or an empty [Optional] if it + * doesn't contain a boolean. + * + * This method checks for both a [KnownValue] containing a boolean and for [JsonBoolean]. + */ + fun asBoolean(): Optional = + when (this) { + is JsonBoolean -> Optional.of(value) + is KnownValue -> Optional.ofNullable(value as? Boolean) + else -> Optional.empty() + } + + /** + * Returns an [Optional] containing this field's numerical value, or an empty [Optional] if it + * doesn't contain a number. + * + * This method checks for both a [KnownValue] containing a number and for [JsonNumber]. + */ + fun asNumber(): Optional = + when (this) { + is JsonNumber -> Optional.of(value) + is KnownValue -> Optional.ofNullable(value as? Number) + else -> Optional.empty() + } + + /** + * Returns an [Optional] containing this field's string value, or an empty [Optional] if it + * doesn't contain a string. + * + * This method checks for both a [KnownValue] containing a string and for [JsonString]. + */ + fun asString(): Optional = + when (this) { + is JsonString -> Optional.of(value) + is KnownValue -> Optional.ofNullable(value as? String) + else -> Optional.empty() + } + + fun asStringOrThrow(): String = + asString().orElseThrow { ImageKitInvalidDataException("Value is not a string") } + + /** + * Returns an [Optional] containing this field's list value, or an empty [Optional] if it + * doesn't contain a list. + * + * This method checks for both a [KnownValue] containing a list and for [JsonArray]. + */ + fun asArray(): Optional> = + when (this) { + is JsonArray -> Optional.of(values) + is KnownValue -> + Optional.ofNullable( + (value as? List<*>)?.map { + try { + JsonValue.from(it) + } catch (e: IllegalArgumentException) { + // The known value is a list, but not all values are convertible to + // `JsonValue`. + return Optional.empty() + } + } + ) + else -> Optional.empty() + } + + /** + * Returns an [Optional] containing this field's map value, or an empty [Optional] if it doesn't + * contain a map. + * + * This method checks for both a [KnownValue] containing a map and for [JsonObject]. + */ + fun asObject(): Optional> = + when (this) { + is JsonObject -> Optional.of(values) + is KnownValue -> + Optional.ofNullable( + (value as? Map<*, *>) + ?.map { (key, value) -> + if (key !is String) { + return Optional.empty() + } + + val jsonValue = + try { + JsonValue.from(value) + } catch (e: IllegalArgumentException) { + // The known value is a map, but not all items are convertible + // to `JsonValue`. + return Optional.empty() + } + + key to jsonValue + } + ?.toMap() + ) + else -> Optional.empty() + } + + @JvmSynthetic + internal fun getRequired(name: String): T = + when (this) { + is KnownValue -> value + is JsonMissing -> throw ImageKitInvalidDataException("`$name` is not set") + is JsonNull -> throw ImageKitInvalidDataException("`$name` is null") + else -> throw ImageKitInvalidDataException("`$name` is invalid, received $this") + } + + @JvmSynthetic + internal fun getOptional( + name: String + ): Optional< + // Safe because `Optional` is effectively covariant, but Kotlin doesn't know that. + @UnsafeVariance + T + > = + when (this) { + is KnownValue -> Optional.of(value) + is JsonMissing, + is JsonNull -> Optional.empty() + else -> throw ImageKitInvalidDataException("`$name` is invalid, received $this") + } + + @JvmSynthetic + internal fun map(transform: (T) -> R): JsonField = + when (this) { + is KnownValue -> KnownValue.of(transform(value)) + is JsonValue -> this + } + + @JvmSynthetic internal fun accept(consume: (T) -> Unit) = asKnown().ifPresent(consume) + + /** Returns the result of calling the [visitor] method corresponding to this field's state. */ + fun accept(visitor: Visitor): R = + when (this) { + is KnownValue -> visitor.visitKnown(value) + is JsonValue -> accept(visitor as JsonValue.Visitor) + } + + /** + * An interface that defines how to map each possible state of a `JsonField` to a value of + * type [R]. + */ + interface Visitor : JsonValue.Visitor { + + fun visitKnown(value: T): R = visitDefault() + } + + companion object { + + /** Returns a [JsonField] containing the given "known" [value]. */ + @JvmStatic fun of(value: T): JsonField = KnownValue.of(value) + + /** + * Returns a [JsonField] containing the given "known" [value], or [JsonNull] if [value] is + * null. + */ + @JvmStatic + fun ofNullable(value: T?): JsonField = + when (value) { + null -> JsonNull.of() + else -> KnownValue.of(value) + } + } + + /** + * This class is a Jackson filter that can be used to exclude missing properties from objects. + * This filter should not be used directly and should instead use the @ExcludeMissing + * annotation. + */ + class IsMissing { + + override fun equals(other: Any?): Boolean = other is JsonMissing + + override fun hashCode(): Int = Objects.hash() + } + + class Deserializer(private val type: JavaType? = null) : + BaseDeserializer>(JsonField::class) { + + override fun createContextual( + context: DeserializationContext, + property: BeanProperty?, + ): JsonDeserializer> = Deserializer(context.contextualType?.containedType(0)) + + override fun ObjectCodec.deserialize(node: JsonNode): JsonField<*> = + type?.let { tryDeserialize(node, type) }?.let { of(it) } + ?: JsonValue.fromJsonNode(node) + + override fun getNullValue(context: DeserializationContext): JsonField<*> = JsonNull.of() + } +} + +/** + * A class representing an arbitrary JSON value. + * + * It is immutable and assignable to any [JsonField], regardless of its expected type (i.e. its + * generic type argument). + */ +@JsonDeserialize(using = JsonValue.Deserializer::class) +sealed class JsonValue : JsonField() { + + fun convert(type: TypeReference): R? = JSON_MAPPER.convertValue(this, type) + + fun convert(type: Class): R? = JSON_MAPPER.convertValue(this, type) + + /** Returns the result of calling the [visitor] method corresponding to this value's variant. */ + fun accept(visitor: Visitor): R = + when (this) { + is JsonMissing -> visitor.visitMissing() + is JsonNull -> visitor.visitNull() + is JsonBoolean -> visitor.visitBoolean(value) + is JsonNumber -> visitor.visitNumber(value) + is JsonString -> visitor.visitString(value) + is JsonArray -> visitor.visitArray(values) + is JsonObject -> visitor.visitObject(values) + } + + /** + * An interface that defines how to map each variant state of a [JsonValue] to a value of type + * [R]. + */ + interface Visitor { + + fun visitNull(): R = visitDefault() + + fun visitMissing(): R = visitDefault() + + fun visitBoolean(value: Boolean): R = visitDefault() + + fun visitNumber(value: Number): R = visitDefault() + + fun visitString(value: String): R = visitDefault() + + fun visitArray(values: List): R = visitDefault() + + fun visitObject(values: Map): R = visitDefault() + + /** + * The default implementation for unimplemented visitor methods. + * + * @throws IllegalArgumentException in the default implementation. + */ + fun visitDefault(): R = throw IllegalArgumentException("Unexpected value") + } + + companion object { + + private val JSON_MAPPER = jsonMapper() + + /** + * Converts the given [value] to a [JsonValue]. + * + * This method works best on primitive types, [List] values, [Map] values, and nested + * combinations of these. For example: + * ```java + * // Create primitive JSON values + * JsonValue nullValue = JsonValue.from(null); + * JsonValue booleanValue = JsonValue.from(true); + * JsonValue numberValue = JsonValue.from(42); + * JsonValue stringValue = JsonValue.from("Hello World!"); + * + * // Create a JSON array value equivalent to `["Hello", "World"]` + * JsonValue arrayValue = JsonValue.from(List.of("Hello", "World")); + * + * // Create a JSON object value equivalent to `{ "a": 1, "b": 2 }` + * JsonValue objectValue = JsonValue.from(Map.of( + * "a", 1, + * "b", 2 + * )); + * + * // Create an arbitrarily nested JSON equivalent to: + * // { + * // "a": [1, 2], + * // "b": [3, 4] + * // } + * JsonValue complexValue = JsonValue.from(Map.of( + * "a", List.of(1, 2), + * "b", List.of(3, 4) + * )); + * ``` + * + * @throws IllegalArgumentException if [value] is not JSON serializable. + */ + @JvmStatic + fun from(value: Any?): JsonValue = + when (value) { + null -> JsonNull.of() + is JsonValue -> value + else -> JSON_MAPPER.convertValue(value, JsonValue::class.java) + } + + /** + * Returns a [JsonValue] converted from the given Jackson [JsonNode]. + * + * @throws IllegalStateException for unsupported node types. + */ + @JvmStatic + fun fromJsonNode(node: JsonNode): JsonValue = + when (node.nodeType) { + MISSING -> JsonMissing.of() + NULL -> JsonNull.of() + BOOLEAN -> JsonBoolean.of(node.booleanValue()) + NUMBER -> JsonNumber.of(node.numberValue()) + STRING -> JsonString.of(node.textValue()) + ARRAY -> + JsonArray.of(node.elements().asSequence().map { fromJsonNode(it) }.toList()) + OBJECT -> + JsonObject.of( + node.fields().asSequence().map { it.key to fromJsonNode(it.value) }.toMap() + ) + BINARY, + POJO, + null -> throw IllegalStateException("Unexpected JsonNode type: ${node.nodeType}") + } + } + + class Deserializer : BaseDeserializer(JsonValue::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): JsonValue = fromJsonNode(node) + + override fun getNullValue(context: DeserializationContext?): JsonValue = JsonNull.of() + } +} + +/** + * A class representing a "known" JSON serializable value of type [T], matching the type the SDK + * expects. + * + * It is assignable to `JsonField`. + */ +class KnownValue +private constructor( + @com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: T +) : JsonField() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is KnownValue<*> && value contentEquals other.value + } + + override fun hashCode() = contentHash(value) + + override fun toString() = value.contentToString() + + companion object { + + /** Returns a [KnownValue] containing the given [value]. */ + @JsonCreator @JvmStatic fun of(value: T) = KnownValue(value) + } +} + +/** + * A [JsonValue] representing an omitted JSON field. + * + * An instance of this class will cause a JSON field to be omitted from the serialized JSON + * entirely. + */ +@JsonSerialize(using = JsonMissing.Serializer::class) +class JsonMissing : JsonValue() { + + override fun toString() = "" + + companion object { + + private val INSTANCE: JsonMissing = JsonMissing() + + /** Returns the singleton instance of [JsonMissing]. */ + @JvmStatic fun of() = INSTANCE + } + + class Serializer : BaseSerializer(JsonMissing::class) { + + override fun serialize( + value: JsonMissing, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + throw IllegalStateException("JsonMissing cannot be serialized") + } + } +} + +/** A [JsonValue] representing a JSON `null` value. */ +@JsonSerialize(using = NullSerializer::class) +class JsonNull : JsonValue() { + + override fun toString() = "null" + + companion object { + + private val INSTANCE: JsonNull = JsonNull() + + /** Returns the singleton instance of [JsonMissing]. */ + @JsonCreator @JvmStatic fun of() = INSTANCE + } +} + +/** A [JsonValue] representing a JSON boolean value. */ +class JsonBoolean +private constructor( + @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: Boolean +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonBoolean && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + /** Returns a [JsonBoolean] containing the given [value]. */ + @JsonCreator @JvmStatic fun of(value: Boolean) = JsonBoolean(value) + } +} + +/** A [JsonValue] representing a JSON number value. */ +class JsonNumber +private constructor( + @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: Number +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonNumber && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + /** Returns a [JsonNumber] containing the given [value]. */ + @JsonCreator @JvmStatic fun of(value: Number) = JsonNumber(value) + } +} + +/** A [JsonValue] representing a JSON string value. */ +class JsonString +private constructor( + @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: String +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonString && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value + + companion object { + + /** Returns a [JsonString] containing the given [value]. */ + @JsonCreator @JvmStatic fun of(value: String) = JsonString(value) + } +} + +/** A [JsonValue] representing a JSON array value. */ +class JsonArray +private constructor( + @get:com.fasterxml.jackson.annotation.JsonValue + @get:JvmName("values") + val values: List +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonArray && values == other.values + } + + override fun hashCode() = values.hashCode() + + override fun toString() = values.toString() + + companion object { + + /** Returns a [JsonArray] containing the given [values]. */ + @JsonCreator @JvmStatic fun of(values: List) = JsonArray(values.toImmutable()) + } +} + +/** A [JsonValue] representing a JSON object value. */ +class JsonObject +private constructor( + @get:com.fasterxml.jackson.annotation.JsonValue + @get:JvmName("values") + val values: Map +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonObject && values == other.values + } + + override fun hashCode() = values.hashCode() + + override fun toString() = values.toString() + + companion object { + + /** Returns a [JsonObject] containing the given [values]. */ + @JsonCreator + @JvmStatic + fun of(values: Map) = JsonObject(values.toImmutable()) + } +} + +/** A Jackson annotation for excluding fields set to [JsonMissing] from the serialized JSON. */ +@JacksonAnnotationsInside +@JsonInclude(JsonInclude.Include.CUSTOM, valueFilter = JsonField.IsMissing::class) +annotation class ExcludeMissing + +/** A class representing a field in a `multipart/form-data` request. */ +class MultipartField +private constructor( + /** A [JsonField] value, which will be serialized to zero or more parts. */ + @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: JsonField, + /** A content type for the serialized parts. */ + @get:JvmName("contentType") val contentType: String, + private val filename: String?, +) { + + companion object { + + /** + * Returns a [MultipartField] containing the given [value] as a [KnownValue]. + * + * [contentType] will be set to `application/octet-stream` if [value] is binary data, or + * `text/plain; charset=utf-8` otherwise. + */ + @JvmStatic fun of(value: T?) = builder().value(value).build() + + /** + * Returns a [MultipartField] containing the given [value]. + * + * [contentType] will be set to `application/octet-stream` if [value] is binary data, or + * `text/plain; charset=utf-8` otherwise. + */ + @JvmStatic fun of(value: JsonField) = builder().value(value).build() + + /** + * Returns a mutable builder for constructing an instance of [MultipartField]. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * If [contentType] is unset, then it will be set to `application/octet-stream` if [value] + * is binary data, or `text/plain; charset=utf-8` otherwise. + */ + @JvmStatic fun builder() = Builder() + } + + /** Returns the filename directive that will be included in the serialized field. */ + fun filename(): Optional = Optional.ofNullable(filename) + + @JvmSynthetic + internal fun map(transform: (T) -> R): MultipartField = + builder().value(value.map(transform)).contentType(contentType).filename(filename).build() + + /** A builder for [MultipartField]. */ + class Builder internal constructor() { + + private var value: JsonField? = null + private var contentType: String? = null + private var filename: String? = null + + fun value(value: JsonField) = apply { this.value = value } + + fun value(value: T?) = value(JsonField.ofNullable(value)) + + fun contentType(contentType: String) = apply { this.contentType = contentType } + + fun filename(filename: String?) = apply { this.filename = filename } + + /** Alias for calling [Builder.filename] with `filename.orElse(null)`. */ + fun filename(filename: Optional) = filename(filename.orElse(null)) + + /** + * Returns an immutable instance of [MultipartField]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * If [contentType] is unset, then it will be set to `application/octet-stream` if [value] + * is binary data, or `text/plain; charset=utf-8` otherwise. + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MultipartField { + val value = checkRequired("value", value) + return MultipartField( + value, + contentType + ?: if ( + value is KnownValue && + (value.value is InputStream || value.value is ByteArray) + ) + "application/octet-stream" + else "text/plain; charset=utf-8", + filename, + ) + } + } + + private val hashCode: Int by lazy { contentHash(value, contentType, filename) } + + override fun hashCode(): Int = hashCode + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MultipartField<*> && + value == other.value && + contentType == other.contentType && + filename == other.filename + } + + override fun toString(): String = + "MultipartField{value=$value, contentType=$contentType, filename=$filename}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/EmptyHandler.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/EmptyHandler.kt new file mode 100644 index 00000000..3828715e --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/EmptyHandler.kt @@ -0,0 +1,12 @@ +@file:JvmName("EmptyHandler") + +package com.imagekit.api.core.handlers + +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler + +@JvmSynthetic internal fun emptyHandler(): Handler = EmptyHandlerInternal + +private object EmptyHandlerInternal : Handler { + override fun handle(response: HttpResponse): Void? = null +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/ErrorHandler.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/ErrorHandler.kt new file mode 100644 index 00000000..203fb654 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/ErrorHandler.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:JvmName("ErrorHandler") + +package com.imagekit.api.core.handlers + +import com.fasterxml.jackson.databind.json.JsonMapper +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.errors.BadRequestException +import com.imagekit.api.errors.InternalServerException +import com.imagekit.api.errors.NotFoundException +import com.imagekit.api.errors.PermissionDeniedException +import com.imagekit.api.errors.RateLimitException +import com.imagekit.api.errors.UnauthorizedException +import com.imagekit.api.errors.UnexpectedStatusCodeException +import com.imagekit.api.errors.UnprocessableEntityException + +@JvmSynthetic +internal fun errorBodyHandler(jsonMapper: JsonMapper): Handler { + val handler = jsonHandler(jsonMapper) + + return object : Handler { + override fun handle(response: HttpResponse): JsonValue = + try { + handler.handle(response) + } catch (e: Exception) { + JsonMissing.of() + } + } +} + +@JvmSynthetic +internal fun errorHandler(errorBodyHandler: Handler): Handler = + object : Handler { + override fun handle(response: HttpResponse): HttpResponse = + when (val statusCode = response.statusCode()) { + in 200..299 -> response + 400 -> + throw BadRequestException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + 401 -> + throw UnauthorizedException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + 403 -> + throw PermissionDeniedException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + 404 -> + throw NotFoundException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + 422 -> + throw UnprocessableEntityException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + 429 -> + throw RateLimitException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + in 500..599 -> + throw InternalServerException.builder() + .statusCode(statusCode) + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + else -> + throw UnexpectedStatusCodeException.builder() + .statusCode(statusCode) + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + } + } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/JsonHandler.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/JsonHandler.kt new file mode 100644 index 00000000..7eedf389 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/JsonHandler.kt @@ -0,0 +1,20 @@ +@file:JvmName("JsonHandler") + +package com.imagekit.api.core.handlers + +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.errors.ImageKitInvalidDataException + +@JvmSynthetic +internal inline fun jsonHandler(jsonMapper: JsonMapper): Handler = + object : Handler { + override fun handle(response: HttpResponse): T = + try { + jsonMapper.readValue(response.body(), jacksonTypeRef()) + } catch (e: Exception) { + throw ImageKitInvalidDataException("Error reading response", e) + } + } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/StringHandler.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/StringHandler.kt new file mode 100644 index 00000000..7c374505 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/StringHandler.kt @@ -0,0 +1,13 @@ +@file:JvmName("StringHandler") + +package com.imagekit.api.core.handlers + +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler + +@JvmSynthetic internal fun stringHandler(): Handler = StringHandlerInternal + +private object StringHandlerInternal : Handler { + override fun handle(response: HttpResponse): String = + response.body().readBytes().toString(Charsets.UTF_8) +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/AsyncStreamResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/AsyncStreamResponse.kt new file mode 100644 index 00000000..21385e33 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/AsyncStreamResponse.kt @@ -0,0 +1,157 @@ +package com.imagekit.api.core.http + +import com.imagekit.api.core.http.AsyncStreamResponse.Handler +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.concurrent.atomic.AtomicReference + +/** + * A class providing access to an API response as an asynchronous stream of chunks of type [T], + * where each chunk can be individually processed as soon as it arrives instead of waiting on the + * full response. + */ +interface AsyncStreamResponse { + + /** + * Registers [handler] to be called for events of this stream. + * + * [handler]'s methods will be called in the client's configured or default thread pool. + * + * @throws IllegalStateException if [subscribe] has already been called. + */ + fun subscribe(handler: Handler): AsyncStreamResponse + + /** + * Registers [handler] to be called for events of this stream. + * + * [handler]'s methods will be called in the given [executor]. + * + * @throws IllegalStateException if [subscribe] has already been called. + */ + fun subscribe(handler: Handler, executor: Executor): AsyncStreamResponse + + /** + * Returns a future that completes when a stream is fully consumed, errors, or gets closed + * early. + */ + fun onCompleteFuture(): CompletableFuture + + /** + * Closes this resource, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because this response should not be + * synchronously closed via try-with-resources. + */ + fun close() + + /** A class for handling streaming events. */ + fun interface Handler { + + /** Called whenever a chunk is received. */ + fun onNext(value: T) + + /** + * Called when a stream is fully consumed, errors, or gets closed early. + * + * [onNext] will not be called once this method is called. + * + * @param error Non-empty if the stream completed due to an error. + */ + fun onComplete(error: Optional) {} + } +} + +@JvmSynthetic +internal fun CompletableFuture>.toAsync(streamHandlerExecutor: Executor) = + PhantomReachableClosingAsyncStreamResponse( + object : AsyncStreamResponse { + + private val onCompleteFuture = CompletableFuture() + private val state = AtomicReference(State.NEW) + + init { + this@toAsync.whenComplete { _, error -> + // If an error occurs from the original future, then we should resolve the + // `onCompleteFuture` even if `subscribe` has not been called. + error?.let(onCompleteFuture::completeExceptionally) + } + } + + override fun subscribe(handler: Handler): AsyncStreamResponse = + subscribe(handler, streamHandlerExecutor) + + override fun subscribe( + handler: Handler, + executor: Executor, + ): AsyncStreamResponse = apply { + // TODO(JDK): Use `compareAndExchange` once targeting JDK 9. + check(state.compareAndSet(State.NEW, State.SUBSCRIBED)) { + if (state.get() == State.SUBSCRIBED) "Cannot subscribe more than once" + else "Cannot subscribe after the response is closed" + } + + this@toAsync.whenCompleteAsync( + { streamResponse, futureError -> + if (state.get() == State.CLOSED) { + // Avoid doing any work if `close` was called before the future + // completed. + return@whenCompleteAsync + } + + if (futureError != null) { + // An error occurred before we started passing chunks to the handler. + handler.onComplete(Optional.of(futureError)) + return@whenCompleteAsync + } + + var streamError: Throwable? = null + try { + streamResponse.stream().forEach(handler::onNext) + } catch (e: Throwable) { + streamError = e + } + + try { + handler.onComplete(Optional.ofNullable(streamError)) + } finally { + try { + // Notify completion via the `onCompleteFuture` as well. This is in + // a separate `try-finally` block so that we still complete the + // future if `handler.onComplete` throws. + if (streamError == null) { + onCompleteFuture.complete(null) + } else { + onCompleteFuture.completeExceptionally(streamError) + } + } finally { + close() + } + } + }, + executor, + ) + } + + override fun onCompleteFuture(): CompletableFuture = onCompleteFuture + + override fun close() { + val previousState = state.getAndSet(State.CLOSED) + if (previousState == State.CLOSED) { + return + } + + this@toAsync.whenComplete { streamResponse, error -> streamResponse?.close() } + // When the stream is closed, we should always consider it closed. If it closed due + // to an error, then we will have already completed the future earlier, and this + // will be a no-op. + onCompleteFuture.complete(null) + } + } + ) + +private enum class State { + NEW, + SUBSCRIBED, + CLOSED, +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/Headers.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/Headers.kt new file mode 100644 index 00000000..9c6ac033 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/Headers.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.core.http + +import com.imagekit.api.core.JsonArray +import com.imagekit.api.core.JsonBoolean +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonNull +import com.imagekit.api.core.JsonNumber +import com.imagekit.api.core.JsonObject +import com.imagekit.api.core.JsonString +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.toImmutable +import java.util.TreeMap + +class Headers +private constructor( + private val map: Map>, + @get:JvmName("size") val size: Int, +) { + + fun isEmpty(): Boolean = map.isEmpty() + + fun names(): Set = map.keys + + fun values(name: String): List = map[name].orEmpty() + + fun toBuilder(): Builder = Builder().putAll(map) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder internal constructor() { + + private val map: MutableMap> = + TreeMap(String.CASE_INSENSITIVE_ORDER) + private var size: Int = 0 + + fun put(name: String, value: JsonValue): Builder = apply { + when (value) { + is JsonMissing, + is JsonNull -> {} + is JsonBoolean -> put(name, value.value.toString()) + is JsonNumber -> put(name, value.value.toString()) + is JsonString -> put(name, value.value) + is JsonArray -> value.values.forEach { put(name, it) } + is JsonObject -> + value.values.forEach { (nestedName, value) -> put("$name.$nestedName", value) } + } + } + + fun put(name: String, value: String) = apply { + map.getOrPut(name) { mutableListOf() }.add(value) + size++ + } + + fun put(name: String, values: Iterable) = apply { values.forEach { put(name, it) } } + + fun putAll(headers: Map>) = apply { headers.forEach(::put) } + + fun putAll(headers: Headers) = apply { + headers.names().forEach { put(it, headers.values(it)) } + } + + fun replace(name: String, value: String) = apply { + remove(name) + put(name, value) + } + + fun replace(name: String, values: Iterable) = apply { + remove(name) + put(name, values) + } + + fun replaceAll(headers: Map>) = apply { + headers.forEach(::replace) + } + + fun replaceAll(headers: Headers) = apply { + headers.names().forEach { replace(it, headers.values(it)) } + } + + fun remove(name: String) = apply { size -= map.remove(name).orEmpty().size } + + fun removeAll(names: Set) = apply { names.forEach(::remove) } + + fun clear() = apply { + map.clear() + size = 0 + } + + fun build() = + Headers( + map.mapValuesTo(TreeMap(String.CASE_INSENSITIVE_ORDER)) { (_, values) -> + values.toImmutable() + } + .toImmutable(), + size, + ) + } + + override fun hashCode(): Int = map.hashCode() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Headers && map == other.map + } + + override fun toString(): String = "Headers{map=$map}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt new file mode 100644 index 00000000..c26e5152 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt @@ -0,0 +1,26 @@ +package com.imagekit.api.core.http + +import com.imagekit.api.core.RequestOptions +import java.lang.AutoCloseable +import java.util.concurrent.CompletableFuture + +interface HttpClient : AutoCloseable { + + fun execute( + request: HttpRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + fun execute(request: HttpRequest): HttpResponse = execute(request, RequestOptions.none()) + + fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + fun executeAsync(request: HttpRequest): CompletableFuture = + executeAsync(request, RequestOptions.none()) + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpMethod.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpMethod.kt new file mode 100644 index 00000000..8f320c37 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpMethod.kt @@ -0,0 +1,13 @@ +package com.imagekit.api.core.http + +enum class HttpMethod { + GET, + HEAD, + POST, + PUT, + DELETE, + CONNECT, + OPTIONS, + TRACE, + PATCH, +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequest.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequest.kt new file mode 100644 index 00000000..7cbf3855 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequest.kt @@ -0,0 +1,146 @@ +package com.imagekit.api.core.http + +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.toImmutable + +class HttpRequest +private constructor( + @get:JvmName("method") val method: HttpMethod, + @get:JvmName("baseUrl") val baseUrl: String, + @get:JvmName("pathSegments") val pathSegments: List, + @get:JvmName("headers") val headers: Headers, + @get:JvmName("queryParams") val queryParams: QueryParams, + @get:JvmName("body") val body: HttpRequestBody?, +) { + + fun toBuilder(): Builder = Builder().from(this) + + override fun toString(): String = + "HttpRequest{method=$method, baseUrl=$baseUrl, pathSegments=$pathSegments, headers=$headers, queryParams=$queryParams, body=$body}" + + companion object { + @JvmStatic fun builder() = Builder() + } + + class Builder internal constructor() { + + private var method: HttpMethod? = null + private var baseUrl: String? = null + private var pathSegments: MutableList = mutableListOf() + private var headers: Headers.Builder = Headers.builder() + private var queryParams: QueryParams.Builder = QueryParams.builder() + private var body: HttpRequestBody? = null + + @JvmSynthetic + internal fun from(request: HttpRequest) = apply { + method = request.method + baseUrl = request.baseUrl + pathSegments = request.pathSegments.toMutableList() + headers = request.headers.toBuilder() + queryParams = request.queryParams.toBuilder() + body = request.body + } + + fun method(method: HttpMethod) = apply { this.method = method } + + fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + + fun addPathSegment(pathSegment: String) = apply { pathSegments.add(pathSegment) } + + fun addPathSegments(vararg pathSegments: String) = apply { + this.pathSegments.addAll(pathSegments) + } + + fun headers(headers: Headers) = apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun headers(headers: Map>) = apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun putHeader(name: String, value: String) = apply { headers.put(name, value) } + + fun putHeaders(name: String, values: Iterable) = apply { headers.put(name, values) } + + fun putAllHeaders(headers: Headers) = apply { this.headers.putAll(headers) } + + fun putAllHeaders(headers: Map>) = apply { + this.headers.putAll(headers) + } + + fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) } + + fun replaceHeaders(name: String, values: Iterable) = apply { + headers.replace(name, values) + } + + fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) } + + fun replaceAllHeaders(headers: Map>) = apply { + this.headers.replaceAll(headers) + } + + fun removeHeaders(name: String) = apply { headers.remove(name) } + + fun removeAllHeaders(names: Set) = apply { headers.removeAll(names) } + + fun queryParams(queryParams: QueryParams) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } + + fun queryParams(queryParams: Map>) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } + + fun putQueryParams(key: String, values: Iterable) = apply { + queryParams.put(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.putAll(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + this.queryParams.putAll(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = apply { + queryParams.replace(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + queryParams.replace(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.replaceAll(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + this.queryParams.replaceAll(queryParams) + } + + fun removeQueryParams(key: String) = apply { queryParams.remove(key) } + + fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } + + fun body(body: HttpRequestBody) = apply { this.body = body } + + fun build(): HttpRequest = + HttpRequest( + checkRequired("method", method), + checkRequired("baseUrl", baseUrl), + pathSegments.toImmutable(), + headers.build(), + queryParams.build(), + body, + ) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequestBodies.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequestBodies.kt new file mode 100644 index 00000000..82008d23 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequestBodies.kt @@ -0,0 +1,128 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:JvmName("HttpRequestBodies") + +package com.imagekit.api.core.http + +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.databind.node.JsonNodeType +import com.imagekit.api.core.MultipartField +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.io.InputStream +import java.io.OutputStream +import kotlin.jvm.optionals.getOrNull +import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder +import org.apache.hc.core5.http.ContentType +import org.apache.hc.core5.http.HttpEntity + +@JvmSynthetic +internal inline fun json(jsonMapper: JsonMapper, value: T): HttpRequestBody = + object : HttpRequestBody { + private val bytes: ByteArray by lazy { jsonMapper.writeValueAsBytes(value) } + + override fun writeTo(outputStream: OutputStream) = outputStream.write(bytes) + + override fun contentType(): String = "application/json" + + override fun contentLength(): Long = bytes.size.toLong() + + override fun repeatable(): Boolean = true + + override fun close() {} + } + +@JvmSynthetic +internal fun multipartFormData( + jsonMapper: JsonMapper, + fields: Map>, +): HttpRequestBody = + object : HttpRequestBody { + private val entity: HttpEntity by lazy { + MultipartEntityBuilder.create() + .apply { + fields.forEach { (name, field) -> + val knownValue = field.value.asKnown().getOrNull() + val parts = + if (knownValue is InputStream) { + // Read directly from the `InputStream` instead of reading it all + // into memory due to the `jsonMapper` serialization below. + sequenceOf(name to knownValue) + } else { + val node = jsonMapper.valueToTree(field.value) + serializePart(name, node) + } + + parts.forEach { (name, bytes) -> + addBinaryBody( + name, + bytes, + ContentType.parseLenient(field.contentType), + field.filename().getOrNull(), + ) + } + } + } + .build() + } + + private fun serializePart( + name: String, + node: JsonNode, + ): Sequence> = + when (node.nodeType) { + JsonNodeType.MISSING, + JsonNodeType.NULL -> emptySequence() + JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue().inputStream()) + JsonNodeType.STRING -> sequenceOf(name to node.textValue().inputStream()) + JsonNodeType.BOOLEAN -> + sequenceOf(name to node.booleanValue().toString().inputStream()) + JsonNodeType.NUMBER -> + sequenceOf(name to node.numberValue().toString().inputStream()) + JsonNodeType.ARRAY -> + sequenceOf( + name to + node + .elements() + .asSequence() + .mapNotNull { element -> + when (element.nodeType) { + JsonNodeType.MISSING, + JsonNodeType.NULL -> null + JsonNodeType.STRING -> node.textValue() + JsonNodeType.BOOLEAN -> node.booleanValue().toString() + JsonNodeType.NUMBER -> node.numberValue().toString() + null, + JsonNodeType.BINARY, + JsonNodeType.ARRAY, + JsonNodeType.OBJECT, + JsonNodeType.POJO -> + throw ImageKitInvalidDataException( + "Unexpected JsonNode type in array: ${node.nodeType}" + ) + } + } + .joinToString(",") + .inputStream() + ) + JsonNodeType.OBJECT -> + node.fields().asSequence().flatMap { (key, value) -> + serializePart("$name[$key]", value) + } + JsonNodeType.POJO, + null -> + throw ImageKitInvalidDataException("Unexpected JsonNode type: ${node.nodeType}") + } + + private fun String.inputStream(): InputStream = toByteArray().inputStream() + + override fun writeTo(outputStream: OutputStream) = entity.writeTo(outputStream) + + override fun contentType(): String = entity.contentType + + override fun contentLength(): Long = entity.contentLength + + override fun repeatable(): Boolean = entity.isRepeatable + + override fun close() = entity.close() + } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequestBody.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequestBody.kt new file mode 100644 index 00000000..31269712 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequestBody.kt @@ -0,0 +1,25 @@ +package com.imagekit.api.core.http + +import java.io.OutputStream +import java.lang.AutoCloseable + +interface HttpRequestBody : AutoCloseable { + + fun writeTo(outputStream: OutputStream) + + fun contentType(): String? + + fun contentLength(): Long + + /** + * Determines if a request can be repeated in a meaningful way, for example before doing a + * retry. + * + * The most typical case when a request can't be retried is if the request body is being + * streamed. In this case the body data isn't available on subsequent attempts. + */ + fun repeatable(): Boolean + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpResponse.kt new file mode 100644 index 00000000..4df614c0 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpResponse.kt @@ -0,0 +1,22 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.core.http + +import java.io.InputStream + +interface HttpResponse : AutoCloseable { + + fun statusCode(): Int + + fun headers(): Headers + + fun body(): InputStream + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() + + interface Handler { + + fun handle(response: HttpResponse): T + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpResponseFor.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpResponseFor.kt new file mode 100644 index 00000000..e8951c98 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpResponseFor.kt @@ -0,0 +1,25 @@ +package com.imagekit.api.core.http + +import java.io.InputStream + +interface HttpResponseFor : HttpResponse { + + fun parse(): T +} + +@JvmSynthetic +internal fun HttpResponse.parseable(parse: () -> T): HttpResponseFor = + object : HttpResponseFor { + + private val parsed: T by lazy { parse() } + + override fun parse(): T = parsed + + override fun statusCode(): Int = this@parseable.statusCode() + + override fun headers(): Headers = this@parseable.headers() + + override fun body(): InputStream = this@parseable.body() + + override fun close() = this@parseable.close() + } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt new file mode 100644 index 00000000..791212d3 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt @@ -0,0 +1,56 @@ +package com.imagekit.api.core.http + +import com.imagekit.api.core.closeWhenPhantomReachable +import com.imagekit.api.core.http.AsyncStreamResponse.Handler +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor + +/** + * A delegating wrapper around an `AsyncStreamResponse` that closes it once it's only phantom + * reachable. + * + * This class ensures the `AsyncStreamResponse` is closed even if the user forgets to close it. + */ +internal class PhantomReachableClosingAsyncStreamResponse( + private val asyncStreamResponse: AsyncStreamResponse +) : AsyncStreamResponse { + + /** + * An object used for keeping `asyncStreamResponse` open while the object is still reachable. + */ + private val reachabilityTracker = Object() + + init { + closeWhenPhantomReachable(reachabilityTracker, asyncStreamResponse::close) + } + + override fun subscribe(handler: Handler): AsyncStreamResponse = apply { + asyncStreamResponse.subscribe(TrackedHandler(handler, reachabilityTracker)) + } + + override fun subscribe(handler: Handler, executor: Executor): AsyncStreamResponse = + apply { + asyncStreamResponse.subscribe(TrackedHandler(handler, reachabilityTracker), executor) + } + + override fun onCompleteFuture(): CompletableFuture = + asyncStreamResponse.onCompleteFuture() + + override fun close() = asyncStreamResponse.close() +} + +/** + * A wrapper around a `Handler` that also references a `reachabilityTracker` object. + * + * Referencing the `reachabilityTracker` object prevents it from getting reclaimed while the handler + * is still reachable. + */ +private class TrackedHandler( + private val handler: Handler, + private val reachabilityTracker: Any, +) : Handler { + override fun onNext(value: T) = handler.onNext(value) + + override fun onComplete(error: Optional) = handler.onComplete(error) +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/PhantomReachableClosingHttpClient.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/PhantomReachableClosingHttpClient.kt new file mode 100644 index 00000000..fc9a25e3 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/PhantomReachableClosingHttpClient.kt @@ -0,0 +1,26 @@ +package com.imagekit.api.core.http + +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.closeWhenPhantomReachable +import java.util.concurrent.CompletableFuture + +/** + * A delegating wrapper around an `HttpClient` that closes it once it's only phantom reachable. + * + * This class ensures the `HttpClient` is closed even if the user forgets to close it. + */ +internal class PhantomReachableClosingHttpClient(private val httpClient: HttpClient) : HttpClient { + init { + closeWhenPhantomReachable(this, httpClient) + } + + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse = + httpClient.execute(request, requestOptions) + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture = httpClient.executeAsync(request, requestOptions) + + override fun close() = httpClient.close() +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/PhantomReachableClosingStreamResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/PhantomReachableClosingStreamResponse.kt new file mode 100644 index 00000000..cf856563 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/PhantomReachableClosingStreamResponse.kt @@ -0,0 +1,21 @@ +package com.imagekit.api.core.http + +import com.imagekit.api.core.closeWhenPhantomReachable +import java.util.stream.Stream + +/** + * A delegating wrapper around a `StreamResponse` that closes it once it's only phantom reachable. + * + * This class ensures the `StreamResponse` is closed even if the user forgets to close it. + */ +internal class PhantomReachableClosingStreamResponse( + private val streamResponse: StreamResponse +) : StreamResponse { + init { + closeWhenPhantomReachable(this, streamResponse) + } + + override fun stream(): Stream = streamResponse.stream() + + override fun close() = streamResponse.close() +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/QueryParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/QueryParams.kt new file mode 100644 index 00000000..3f16c45e --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/QueryParams.kt @@ -0,0 +1,129 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.core.http + +import com.imagekit.api.core.JsonArray +import com.imagekit.api.core.JsonBoolean +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonNull +import com.imagekit.api.core.JsonNumber +import com.imagekit.api.core.JsonObject +import com.imagekit.api.core.JsonString +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.toImmutable + +class QueryParams +private constructor( + private val map: Map>, + @get:JvmName("size") val size: Int, +) { + + fun isEmpty(): Boolean = map.isEmpty() + + fun keys(): Set = map.keys + + fun values(key: String): List = map[key].orEmpty() + + fun toBuilder(): Builder = Builder().putAll(map) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder internal constructor() { + + private val map: MutableMap> = mutableMapOf() + private var size: Int = 0 + + fun put(key: String, value: JsonValue): Builder = apply { + when (value) { + is JsonMissing, + is JsonNull -> {} + is JsonBoolean -> put(key, value.value.toString()) + is JsonNumber -> put(key, value.value.toString()) + is JsonString -> put(key, value.value) + is JsonArray -> + put( + key, + value.values + .asSequence() + .mapNotNull { + when (it) { + is JsonMissing, + is JsonNull -> null + is JsonBoolean -> it.value.toString() + is JsonNumber -> it.value.toString() + is JsonString -> it.value + is JsonArray, + is JsonObject -> + throw IllegalArgumentException( + "Cannot comma separate non-primitives in query params" + ) + } + } + .joinToString(","), + ) + is JsonObject -> + value.values.forEach { (nestedKey, value) -> put("$key[$nestedKey]", value) } + } + } + + fun put(key: String, value: String) = apply { + map.getOrPut(key) { mutableListOf() }.add(value) + size++ + } + + fun put(key: String, values: Iterable) = apply { values.forEach { put(key, it) } } + + fun putAll(queryParams: Map>) = apply { + queryParams.forEach(::put) + } + + fun putAll(queryParams: QueryParams) = apply { + queryParams.keys().forEach { put(it, queryParams.values(it)) } + } + + fun replace(key: String, value: String) = apply { + remove(key) + put(key, value) + } + + fun replace(key: String, values: Iterable) = apply { + remove(key) + put(key, values) + } + + fun replaceAll(queryParams: Map>) = apply { + queryParams.forEach(::replace) + } + + fun replaceAll(queryParams: QueryParams) = apply { + queryParams.keys().forEach { replace(it, queryParams.values(it)) } + } + + fun remove(key: String) = apply { size -= map.remove(key).orEmpty().size } + + fun removeAll(keys: Set) = apply { keys.forEach(::remove) } + + fun clear() = apply { + map.clear() + size = 0 + } + + fun build() = + QueryParams(map.mapValues { (_, values) -> values.toImmutable() }.toImmutable(), size) + } + + override fun hashCode(): Int = map.hashCode() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is QueryParams && map == other.map + } + + override fun toString(): String = "QueryParams{map=$map}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt new file mode 100644 index 00000000..e8e45bee --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt @@ -0,0 +1,288 @@ +package com.imagekit.api.core.http + +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.checkRequired +import com.imagekit.api.errors.ImageKitIoException +import com.imagekit.api.errors.ImageKitRetryableException +import java.io.IOException +import java.time.Clock +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.time.format.DateTimeParseException +import java.time.temporal.ChronoUnit +import java.util.Timer +import java.util.TimerTask +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.ThreadLocalRandom +import java.util.concurrent.TimeUnit +import java.util.function.Function +import kotlin.math.min +import kotlin.math.pow + +class RetryingHttpClient +private constructor( + private val httpClient: HttpClient, + private val sleeper: Sleeper, + private val clock: Clock, + private val maxRetries: Int, + private val idempotencyHeader: String?, +) : HttpClient { + + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { + if (!isRetryable(request) || maxRetries <= 0) { + return httpClient.execute(request, requestOptions) + } + + var modifiedRequest = maybeAddIdempotencyHeader(request) + + // Don't send the current retry count in the headers if the caller set their own value. + val shouldSendRetryCount = + !modifiedRequest.headers.names().contains("X-Stainless-Retry-Count") + + var retries = 0 + + while (true) { + if (shouldSendRetryCount) { + modifiedRequest = setRetryCountHeader(modifiedRequest, retries) + } + + val response = + try { + val response = httpClient.execute(modifiedRequest, requestOptions) + if (++retries > maxRetries || !shouldRetry(response)) { + return response + } + + response + } catch (throwable: Throwable) { + if (++retries > maxRetries || !shouldRetry(throwable)) { + throw throwable + } + + null + } + + val backoffDuration = getRetryBackoffDuration(retries, response) + // All responses must be closed, so close the failed one before retrying. + response?.close() + sleeper.sleep(backoffDuration) + } + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + if (!isRetryable(request) || maxRetries <= 0) { + return httpClient.executeAsync(request, requestOptions) + } + + val modifiedRequest = maybeAddIdempotencyHeader(request) + + // Don't send the current retry count in the headers if the caller set their own value. + val shouldSendRetryCount = + !modifiedRequest.headers.names().contains("X-Stainless-Retry-Count") + + var retries = 0 + + fun executeWithRetries( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + val requestWithRetryCount = + if (shouldSendRetryCount) setRetryCountHeader(request, retries) else request + + return httpClient + .executeAsync(requestWithRetryCount, requestOptions) + .handleAsync( + fun( + response: HttpResponse?, + throwable: Throwable?, + ): CompletableFuture { + if (response != null) { + if (++retries > maxRetries || !shouldRetry(response)) { + return CompletableFuture.completedFuture(response) + } + } else { + if (++retries > maxRetries || !shouldRetry(throwable!!)) { + val failedFuture = CompletableFuture() + failedFuture.completeExceptionally(throwable) + return failedFuture + } + } + + val backoffDuration = getRetryBackoffDuration(retries, response) + // All responses must be closed, so close the failed one before retrying. + response?.close() + return sleeper.sleepAsync(backoffDuration).thenCompose { + executeWithRetries(requestWithRetryCount, requestOptions) + } + } + ) { + // Run in the same thread. + it.run() + } + .thenCompose(Function.identity()) + } + + return executeWithRetries(modifiedRequest, requestOptions) + } + + override fun close() = httpClient.close() + + private fun isRetryable(request: HttpRequest): Boolean = + // Some requests, such as when a request body is being streamed, cannot be retried because + // the body data aren't available on subsequent attempts. + request.body?.repeatable() ?: true + + private fun setRetryCountHeader(request: HttpRequest, retries: Int): HttpRequest = + request.toBuilder().replaceHeaders("X-Stainless-Retry-Count", retries.toString()).build() + + private fun idempotencyKey(): String = "stainless-java-retry-${UUID.randomUUID()}" + + private fun maybeAddIdempotencyHeader(request: HttpRequest): HttpRequest { + if (idempotencyHeader == null || request.headers.names().contains(idempotencyHeader)) { + return request + } + + return request + .toBuilder() + // Set a header to uniquely identify the request when retried. + .putHeader(idempotencyHeader, idempotencyKey()) + .build() + } + + private fun shouldRetry(response: HttpResponse): Boolean { + // Note: this is not a standard header + val shouldRetryHeader = response.headers().values("X-Should-Retry").getOrNull(0) + val statusCode = response.statusCode() + + return when { + // If the server explicitly says whether to retry, obey + shouldRetryHeader == "true" -> true + shouldRetryHeader == "false" -> false + + // Retry on request timeouts + statusCode == 408 -> true + // Retry on lock timeouts + statusCode == 409 -> true + // Retry on rate limits + statusCode == 429 -> true + // Retry internal errors + statusCode >= 500 -> true + else -> false + } + } + + private fun shouldRetry(throwable: Throwable): Boolean = + // Only retry known retryable exceptions, other exceptions are not intended to be retried. + throwable is IOException || + throwable is ImageKitIoException || + throwable is ImageKitRetryableException + + private fun getRetryBackoffDuration(retries: Int, response: HttpResponse?): Duration { + // About the Retry-After header: + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After + response + ?.headers() + ?.let { headers -> + headers + .values("Retry-After-Ms") + .getOrNull(0) + ?.toFloatOrNull() + ?.times(TimeUnit.MILLISECONDS.toNanos(1)) + ?: headers.values("Retry-After").getOrNull(0)?.let { retryAfter -> + retryAfter.toFloatOrNull()?.times(TimeUnit.SECONDS.toNanos(1)) + ?: try { + ChronoUnit.MILLIS.between( + OffsetDateTime.now(clock), + OffsetDateTime.parse( + retryAfter, + DateTimeFormatter.RFC_1123_DATE_TIME, + ), + ) + } catch (e: DateTimeParseException) { + null + } + } + } + ?.let { retryAfterNanos -> + // If the API asks us to wait a certain amount of time (and it's a reasonable + // amount), just + // do what it says. + val retryAfter = Duration.ofNanos(retryAfterNanos.toLong()) + if (retryAfter in Duration.ofNanos(0)..Duration.ofMinutes(1)) { + return retryAfter + } + } + + // Apply exponential backoff, but not more than the max. + val backoffSeconds = min(0.5 * 2.0.pow(retries - 1), 8.0) + + // Apply some jitter + val jitter = 1.0 - 0.25 * ThreadLocalRandom.current().nextDouble() + + return Duration.ofNanos((TimeUnit.SECONDS.toNanos(1) * backoffSeconds * jitter).toLong()) + } + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder internal constructor() { + + private var httpClient: HttpClient? = null + private var sleeper: Sleeper = + object : Sleeper { + + private val timer = Timer("RetryingHttpClient", true) + + override fun sleep(duration: Duration) = Thread.sleep(duration.toMillis()) + + override fun sleepAsync(duration: Duration): CompletableFuture { + val future = CompletableFuture() + timer.schedule( + object : TimerTask() { + override fun run() { + future.complete(null) + } + }, + duration.toMillis(), + ) + return future + } + } + private var clock: Clock = Clock.systemUTC() + private var maxRetries: Int = 2 + private var idempotencyHeader: String? = null + + fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + + @JvmSynthetic internal fun sleeper(sleeper: Sleeper) = apply { this.sleeper = sleeper } + + fun clock(clock: Clock) = apply { this.clock = clock } + + fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + + fun idempotencyHeader(header: String) = apply { this.idempotencyHeader = header } + + fun build(): HttpClient = + RetryingHttpClient( + checkRequired("httpClient", httpClient), + sleeper, + clock, + maxRetries, + idempotencyHeader, + ) + } + + internal interface Sleeper { + + fun sleep(duration: Duration) + + fun sleepAsync(duration: Duration): CompletableFuture + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/StreamResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/StreamResponse.kt new file mode 100644 index 00000000..d5427be4 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/StreamResponse.kt @@ -0,0 +1,19 @@ +package com.imagekit.api.core.http + +import java.util.stream.Stream + +interface StreamResponse : AutoCloseable { + + fun stream(): Stream + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() +} + +@JvmSynthetic +internal fun StreamResponse.map(transform: (T) -> R): StreamResponse = + object : StreamResponse { + override fun stream(): Stream = this@map.stream().map(transform) + + override fun close() = this@map.close() + } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt new file mode 100644 index 00000000..c0928e0a --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.errors + +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BadRequestException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + ImageKitServiceException("400: $body", cause) { + + override fun statusCode(): Int = 400 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BadRequestException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BadRequestException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(badRequestException: BadRequestException) = apply { + headers = badRequestException.headers + body = badRequestException.body + cause = badRequestException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [BadRequestException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BadRequestException = + BadRequestException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt new file mode 100644 index 00000000..799b887b --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt @@ -0,0 +1,5 @@ +package com.imagekit.api.errors + +open class ImageKitException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : RuntimeException(message, cause) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt new file mode 100644 index 00000000..5ab2f9b4 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt @@ -0,0 +1,5 @@ +package com.imagekit.api.errors + +class ImageKitInvalidDataException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : ImageKitException(message, cause) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt new file mode 100644 index 00000000..0cb36092 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt @@ -0,0 +1,5 @@ +package com.imagekit.api.errors + +class ImageKitIoException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : ImageKitException(message, cause) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt new file mode 100644 index 00000000..a9c4e94b --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt @@ -0,0 +1,14 @@ +package com.imagekit.api.errors + +/** + * Exception that indicates a transient error that can be retried. + * + * When this exception is thrown during an HTTP request, the SDK will automatically retry the + * request up to the maximum number of retries. + * + * @param message A descriptive error message + * @param cause The underlying cause of this exception, if any + */ +class ImageKitRetryableException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : ImageKitException(message, cause) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt new file mode 100644 index 00000000..3e8bb7ca --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt @@ -0,0 +1,17 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.errors + +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.http.Headers + +abstract class ImageKitServiceException +protected constructor(message: String, cause: Throwable? = null) : + ImageKitException(message, cause) { + + abstract fun statusCode(): Int + + abstract fun headers(): Headers + + abstract fun body(): JsonValue +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt new file mode 100644 index 00000000..dbdbcc04 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt @@ -0,0 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.errors + +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class InternalServerException +private constructor( + private val statusCode: Int, + private val headers: Headers, + private val body: JsonValue, + cause: Throwable?, +) : ImageKitServiceException("$statusCode: $body", cause) { + + override fun statusCode(): Int = statusCode + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InternalServerException]. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InternalServerException]. */ + class Builder internal constructor() { + + private var statusCode: Int? = null + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(internalServerException: InternalServerException) = apply { + statusCode = internalServerException.statusCode + headers = internalServerException.headers + body = internalServerException.body + cause = internalServerException.cause + } + + fun statusCode(statusCode: Int) = apply { this.statusCode = statusCode } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [InternalServerException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InternalServerException = + InternalServerException( + checkRequired("statusCode", statusCode), + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt new file mode 100644 index 00000000..61926165 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.errors + +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class NotFoundException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + ImageKitServiceException("404: $body", cause) { + + override fun statusCode(): Int = 404 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NotFoundException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NotFoundException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(notFoundException: NotFoundException) = apply { + headers = notFoundException.headers + body = notFoundException.body + cause = notFoundException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [NotFoundException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NotFoundException = + NotFoundException(checkRequired("headers", headers), checkRequired("body", body), cause) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt new file mode 100644 index 00000000..95f536bc --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.errors + +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class PermissionDeniedException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + ImageKitServiceException("403: $body", cause) { + + override fun statusCode(): Int = 403 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PermissionDeniedException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PermissionDeniedException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(permissionDeniedException: PermissionDeniedException) = apply { + headers = permissionDeniedException.headers + body = permissionDeniedException.body + cause = permissionDeniedException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [PermissionDeniedException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PermissionDeniedException = + PermissionDeniedException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt new file mode 100644 index 00000000..c9d078b9 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.errors + +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class RateLimitException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + ImageKitServiceException("429: $body", cause) { + + override fun statusCode(): Int = 429 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RateLimitException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RateLimitException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(rateLimitException: RateLimitException) = apply { + headers = rateLimitException.headers + body = rateLimitException.body + cause = rateLimitException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [RateLimitException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RateLimitException = + RateLimitException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt new file mode 100644 index 00000000..46009ee1 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.errors + +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class UnauthorizedException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + ImageKitServiceException("401: $body", cause) { + + override fun statusCode(): Int = 401 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnauthorizedException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnauthorizedException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(unauthorizedException: UnauthorizedException) = apply { + headers = unauthorizedException.headers + body = unauthorizedException.body + cause = unauthorizedException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [UnauthorizedException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnauthorizedException = + UnauthorizedException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt new file mode 100644 index 00000000..f21d5606 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt @@ -0,0 +1,92 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.errors + +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class UnexpectedStatusCodeException +private constructor( + private val statusCode: Int, + private val headers: Headers, + private val body: JsonValue, + cause: Throwable?, +) : ImageKitServiceException("$statusCode: $body", cause) { + + override fun statusCode(): Int = statusCode + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnexpectedStatusCodeException]. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnexpectedStatusCodeException]. */ + class Builder internal constructor() { + + private var statusCode: Int? = null + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(unexpectedStatusCodeException: UnexpectedStatusCodeException) = apply { + statusCode = unexpectedStatusCodeException.statusCode + headers = unexpectedStatusCodeException.headers + body = unexpectedStatusCodeException.body + cause = unexpectedStatusCodeException.cause + } + + fun statusCode(statusCode: Int) = apply { this.statusCode = statusCode } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [UnexpectedStatusCodeException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnexpectedStatusCodeException = + UnexpectedStatusCodeException( + checkRequired("statusCode", statusCode), + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt new file mode 100644 index 00000000..2d468300 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.errors + +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class UnprocessableEntityException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + ImageKitServiceException("422: $body", cause) { + + override fun statusCode(): Int = 422 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnprocessableEntityException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnprocessableEntityException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(unprocessableEntityException: UnprocessableEntityException) = apply { + headers = unprocessableEntityException.headers + body = unprocessableEntityException.body + cause = unprocessableEntityException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [UnprocessableEntityException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnprocessableEntityException = + UnprocessableEntityException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/BaseOverlay.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/BaseOverlay.kt new file mode 100644 index 00000000..7030982b --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/BaseOverlay.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BaseOverlay +private constructor( + private val position: JsonField, + private val timing: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("position") + @ExcludeMissing + position: JsonField = JsonMissing.of(), + @JsonProperty("timing") @ExcludeMissing timing: JsonField = JsonMissing.of(), + ) : this(position, timing, mutableMapOf()) + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun position(): Optional = position.getOptional("position") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timing(): Optional = timing.getOptional("timing") + + /** + * Returns the raw JSON value of [position]. + * + * Unlike [position], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position + + /** + * Returns the raw JSON value of [timing]. + * + * Unlike [timing], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timing") @ExcludeMissing fun _timing(): JsonField = timing + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [BaseOverlay]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BaseOverlay]. */ + class Builder internal constructor() { + + private var position: JsonField = JsonMissing.of() + private var timing: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(baseOverlay: BaseOverlay) = apply { + position = baseOverlay.position + timing = baseOverlay.timing + additionalProperties = baseOverlay.additionalProperties.toMutableMap() + } + + fun position(position: OverlayPosition) = position(JsonField.of(position)) + + /** + * Sets [Builder.position] to an arbitrary JSON value. + * + * You should usually call [Builder.position] with a well-typed [OverlayPosition] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun position(position: JsonField) = apply { this.position = position } + + fun timing(timing: OverlayTiming) = timing(JsonField.of(timing)) + + /** + * Sets [Builder.timing] to an arbitrary JSON value. + * + * You should usually call [Builder.timing] with a well-typed [OverlayTiming] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun timing(timing: JsonField) = apply { this.timing = timing } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BaseOverlay]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BaseOverlay = + BaseOverlay(position, timing, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): BaseOverlay = apply { + if (validated) { + return@apply + } + + position().ifPresent { it.validate() } + timing().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (position.asKnown().getOrNull()?.validity() ?: 0) + + (timing.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BaseOverlay && + position == other.position && + timing == other.timing && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(position, timing, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BaseOverlay{position=$position, timing=$timing, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ImageOverlay.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ImageOverlay.kt new file mode 100644 index 00000000..3c5b235f --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ImageOverlay.kt @@ -0,0 +1,534 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ImageOverlay +private constructor( + private val position: JsonField, + private val timing: JsonField, + private val input: JsonField, + private val type: JsonValue, + private val encoding: JsonField, + private val transformation: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("position") + @ExcludeMissing + position: JsonField = JsonMissing.of(), + @JsonProperty("timing") @ExcludeMissing timing: JsonField = JsonMissing.of(), + @JsonProperty("input") @ExcludeMissing input: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("encoding") @ExcludeMissing encoding: JsonField = JsonMissing.of(), + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField> = JsonMissing.of(), + ) : this(position, timing, input, type, encoding, transformation, mutableMapOf()) + + fun toBaseOverlay(): BaseOverlay = + BaseOverlay.builder().position(position).timing(timing).build() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun position(): Optional = position.getOptional("position") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timing(): Optional = timing.getOptional("timing") + + /** + * Specifies the relative path to the image used as an overlay. + * + * @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 input(): String = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("image") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * The input path can be included in the layer as either `i-{input}` or + * `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate format + * automatically. To always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + * To always use plain text (`i-{input}`), set it to `plain`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun encoding(): Optional = encoding.getOptional("encoding") + + /** + * Array of transformations to be applied to the overlay image. Supported transformations + * depends on the base/parent asset. See overlays on + * [Images](https://imagekit.io/docs/add-overlays-on-images#list-of-supported-image-transformations-in-image-layers) + * and + * [Videos](https://imagekit.io/docs/add-overlays-on-videos#list-of-transformations-supported-on-image-overlay). + * + * @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 [position]. + * + * Unlike [position], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position + + /** + * Returns the raw JSON value of [timing]. + * + * Unlike [timing], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timing") @ExcludeMissing fun _timing(): JsonField = timing + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [encoding]. + * + * Unlike [encoding], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("encoding") @ExcludeMissing fun _encoding(): JsonField = encoding + + /** + * 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 [ImageOverlay]. + * + * The following fields are required: + * ```java + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ImageOverlay]. */ + class Builder internal constructor() { + + private var position: JsonField = JsonMissing.of() + private var timing: JsonField = JsonMissing.of() + private var input: JsonField? = null + private var type: JsonValue = JsonValue.from("image") + private var encoding: JsonField = JsonMissing.of() + private var transformation: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(imageOverlay: ImageOverlay) = apply { + position = imageOverlay.position + timing = imageOverlay.timing + input = imageOverlay.input + type = imageOverlay.type + encoding = imageOverlay.encoding + transformation = imageOverlay.transformation.map { it.toMutableList() } + additionalProperties = imageOverlay.additionalProperties.toMutableMap() + } + + fun position(position: OverlayPosition) = position(JsonField.of(position)) + + /** + * Sets [Builder.position] to an arbitrary JSON value. + * + * You should usually call [Builder.position] with a well-typed [OverlayPosition] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun position(position: JsonField) = apply { this.position = position } + + fun timing(timing: OverlayTiming) = timing(JsonField.of(timing)) + + /** + * Sets [Builder.timing] to an arbitrary JSON value. + * + * You should usually call [Builder.timing] with a well-typed [OverlayTiming] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun timing(timing: JsonField) = apply { this.timing = timing } + + /** Specifies the relative path to the image used as an overlay. */ + fun input(input: String) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("image") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * The input path can be included in the layer as either `i-{input}` or + * `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate format + * automatically. To always use base64 encoding (`ie-{base64}`), set this parameter to + * `base64`. To always use plain text (`i-{input}`), set it to `plain`. + */ + fun encoding(encoding: Encoding) = encoding(JsonField.of(encoding)) + + /** + * Sets [Builder.encoding] to an arbitrary JSON value. + * + * You should usually call [Builder.encoding] with a well-typed [Encoding] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun encoding(encoding: JsonField) = apply { this.encoding = encoding } + + /** + * Array of transformations to be applied to the overlay image. Supported transformations + * depends on the base/parent asset. See overlays on + * [Images](https://imagekit.io/docs/add-overlays-on-images#list-of-supported-image-transformations-in-image-layers) + * and + * [Videos](https://imagekit.io/docs/add-overlays-on-videos#list-of-transformations-supported-on-image-overlay). + */ + fun transformation(transformation: List) = + transformation(JsonField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary JSON value. + * + * You should usually call [Builder.transformation] with a well-typed `List` + * 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.map { it.toMutableList() } + } + + /** + * Adds a single [Transformation] to [Builder.transformation]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTransformation(transformation: Transformation) = apply { + this.transformation = + (this.transformation ?: JsonField.of(mutableListOf())).also { + checkKnown("transformation", it).add(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 [ImageOverlay]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ImageOverlay = + ImageOverlay( + position, + timing, + checkRequired("input", input), + type, + encoding, + (transformation ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ImageOverlay = apply { + if (validated) { + return@apply + } + + position().ifPresent { it.validate() } + timing().ifPresent { it.validate() } + input() + _type().let { + if (it != JsonValue.from("image")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + encoding().ifPresent { it.validate() } + transformation().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (position.asKnown().getOrNull()?.validity() ?: 0) + + (timing.asKnown().getOrNull()?.validity() ?: 0) + + (if (input.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("image")) 1 else 0 } + + (encoding.asKnown().getOrNull()?.validity() ?: 0) + + (transformation.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** + * The input path can be included in the layer as either `i-{input}` or + * `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate format + * automatically. To always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + * To always use plain text (`i-{input}`), set it to `plain`. + */ + class Encoding @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AUTO = of("auto") + + @JvmField val PLAIN = of("plain") + + @JvmField val BASE64 = of("base64") + + @JvmStatic fun of(value: String) = Encoding(JsonField.of(value)) + } + + /** An enum containing [Encoding]'s known values. */ + enum class Known { + AUTO, + PLAIN, + BASE64, + } + + /** + * An enum containing [Encoding]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Encoding] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AUTO, + PLAIN, + BASE64, + /** An enum member indicating that [Encoding] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + PLAIN -> Value.PLAIN + BASE64 -> Value.BASE64 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + PLAIN -> Known.PLAIN + BASE64 -> Known.BASE64 + else -> throw ImageKitInvalidDataException("Unknown Encoding: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Encoding = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Encoding && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ImageOverlay && + position == other.position && + timing == other.timing && + input == other.input && + type == other.type && + encoding == other.encoding && + transformation == other.transformation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(position, timing, input, type, encoding, transformation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ImageOverlay{position=$position, timing=$timing, input=$input, type=$type, encoding=$encoding, transformation=$transformation, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Overlay.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Overlay.kt new file mode 100644 index 00000000..51a9db0f --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Overlay.kt @@ -0,0 +1,267 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.allMaxBy +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Objects +import java.util.Optional + +/** + * Specifies an overlay to be applied on the parent image or video. ImageKit supports overlays + * including images, text, videos, subtitles, and solid colors. See + * [Overlay using layers](https://imagekit.io/docs/transformations#overlay-using-layers). + */ +@JsonDeserialize(using = Overlay.Deserializer::class) +@JsonSerialize(using = Overlay.Serializer::class) +class Overlay +private constructor( + private val text: TextOverlay? = null, + private val image: ImageOverlay? = null, + private val video: VideoOverlay? = null, + private val subtitle: SubtitleOverlay? = null, + private val solidColor: SolidColorOverlay? = null, + private val _json: JsonValue? = null, +) { + + fun text(): Optional = Optional.ofNullable(text) + + fun image(): Optional = Optional.ofNullable(image) + + fun video(): Optional = Optional.ofNullable(video) + + fun subtitle(): Optional = Optional.ofNullable(subtitle) + + fun solidColor(): Optional = Optional.ofNullable(solidColor) + + fun isText(): Boolean = text != null + + fun isImage(): Boolean = image != null + + fun isVideo(): Boolean = video != null + + fun isSubtitle(): Boolean = subtitle != null + + fun isSolidColor(): Boolean = solidColor != null + + fun asText(): TextOverlay = text.getOrThrow("text") + + fun asImage(): ImageOverlay = image.getOrThrow("image") + + fun asVideo(): VideoOverlay = video.getOrThrow("video") + + fun asSubtitle(): SubtitleOverlay = subtitle.getOrThrow("subtitle") + + fun asSolidColor(): SolidColorOverlay = solidColor.getOrThrow("solidColor") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + text != null -> visitor.visitText(text) + image != null -> visitor.visitImage(image) + video != null -> visitor.visitVideo(video) + subtitle != null -> visitor.visitSubtitle(subtitle) + solidColor != null -> visitor.visitSolidColor(solidColor) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Overlay = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitText(text: TextOverlay) { + text.validate() + } + + override fun visitImage(image: ImageOverlay) { + image.validate() + } + + override fun visitVideo(video: VideoOverlay) { + video.validate() + } + + override fun visitSubtitle(subtitle: SubtitleOverlay) { + subtitle.validate() + } + + override fun visitSolidColor(solidColor: SolidColorOverlay) { + solidColor.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitText(text: TextOverlay) = text.validity() + + override fun visitImage(image: ImageOverlay) = image.validity() + + override fun visitVideo(video: VideoOverlay) = video.validity() + + override fun visitSubtitle(subtitle: SubtitleOverlay) = subtitle.validity() + + override fun visitSolidColor(solidColor: SolidColorOverlay) = solidColor.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Overlay && + text == other.text && + image == other.image && + video == other.video && + subtitle == other.subtitle && + solidColor == other.solidColor + } + + override fun hashCode(): Int = Objects.hash(text, image, video, subtitle, solidColor) + + override fun toString(): String = + when { + text != null -> "Overlay{text=$text}" + image != null -> "Overlay{image=$image}" + video != null -> "Overlay{video=$video}" + subtitle != null -> "Overlay{subtitle=$subtitle}" + solidColor != null -> "Overlay{solidColor=$solidColor}" + _json != null -> "Overlay{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Overlay") + } + + companion object { + + @JvmStatic fun ofText(text: TextOverlay) = Overlay(text = text) + + @JvmStatic fun ofImage(image: ImageOverlay) = Overlay(image = image) + + @JvmStatic fun ofVideo(video: VideoOverlay) = Overlay(video = video) + + @JvmStatic fun ofSubtitle(subtitle: SubtitleOverlay) = Overlay(subtitle = subtitle) + + @JvmStatic + fun ofSolidColor(solidColor: SolidColorOverlay) = Overlay(solidColor = solidColor) + } + + /** An interface that defines how to map each variant of [Overlay] to a value of type [T]. */ + interface Visitor { + + fun visitText(text: TextOverlay): T + + fun visitImage(image: ImageOverlay): T + + fun visitVideo(video: VideoOverlay): T + + fun visitSubtitle(subtitle: SubtitleOverlay): T + + fun visitSolidColor(solidColor: SolidColorOverlay): T + + /** + * Maps an unknown variant of [Overlay] to a value of type [T]. + * + * An instance of [Overlay] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version than + * the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Overlay: $json") + } + } + + internal class Deserializer : BaseDeserializer(Overlay::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Overlay { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Overlay(text = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Overlay(image = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Overlay(video = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Overlay(subtitle = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Overlay(solidColor = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> Overlay(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Overlay::class) { + + override fun serialize( + value: Overlay, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.text != null -> generator.writeObject(value.text) + value.image != null -> generator.writeObject(value.image) + value.video != null -> generator.writeObject(value.video) + value.subtitle != null -> generator.writeObject(value.subtitle) + value.solidColor != null -> generator.writeObject(value.solidColor) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Overlay") + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt new file mode 100644 index 00000000..42f5e18e --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt @@ -0,0 +1,785 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.allMaxBy +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class OverlayPosition +private constructor( + private val focus: JsonField, + private val x: JsonField, + private val y: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("focus") @ExcludeMissing focus: JsonField = JsonMissing.of(), + @JsonProperty("x") @ExcludeMissing x: JsonField = JsonMissing.of(), + @JsonProperty("y") @ExcludeMissing y: JsonField = JsonMissing.of(), + ) : this(focus, x, y, mutableMapOf()) + + /** + * Specifies the position of the overlay relative to the parent image or video. Maps to `lfo` in + * the URL. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun focus(): Optional = focus.getOptional("focus") + + /** + * Specifies the x-coordinate of the top-left corner of the base asset where the overlay's + * top-left corner will be positioned. It also accepts arithmetic expressions such as + * `bw_mul_0.4` or `bw_sub_cw`. Maps to `lx` in the URL. Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun x(): Optional = x.getOptional("x") + + /** + * Specifies the y-coordinate of the top-left corner of the base asset where the overlay's + * top-left corner will be positioned. It also accepts arithmetic expressions such as + * `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun y(): Optional = y.getOptional("y") + + /** + * Returns the raw JSON value of [focus]. + * + * Unlike [focus], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("focus") @ExcludeMissing fun _focus(): JsonField = focus + + /** + * Returns the raw JSON value of [x]. + * + * Unlike [x], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("x") @ExcludeMissing fun _x(): JsonField = x + + /** + * Returns the raw JSON value of [y]. + * + * Unlike [y], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("y") @ExcludeMissing fun _y(): JsonField = y + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [OverlayPosition]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OverlayPosition]. */ + class Builder internal constructor() { + + private var focus: JsonField = JsonMissing.of() + private var x: JsonField = JsonMissing.of() + private var y: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(overlayPosition: OverlayPosition) = apply { + focus = overlayPosition.focus + x = overlayPosition.x + y = overlayPosition.y + additionalProperties = overlayPosition.additionalProperties.toMutableMap() + } + + /** + * Specifies the position of the overlay relative to the parent image or video. Maps to + * `lfo` in the URL. + */ + fun focus(focus: Focus) = focus(JsonField.of(focus)) + + /** + * Sets [Builder.focus] to an arbitrary JSON value. + * + * You should usually call [Builder.focus] with a well-typed [Focus] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun focus(focus: JsonField) = apply { this.focus = focus } + + /** + * Specifies the x-coordinate of the top-left corner of the base asset where the overlay's + * top-left corner will be positioned. It also accepts arithmetic expressions such as + * `bw_mul_0.4` or `bw_sub_cw`. Maps to `lx` in the URL. Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + */ + fun x(x: X) = x(JsonField.of(x)) + + /** + * Sets [Builder.x] to an arbitrary JSON value. + * + * You should usually call [Builder.x] with a well-typed [X] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun x(x: JsonField) = apply { this.x = x } + + /** Alias for calling [x] with `X.ofNumber(number)`. */ + fun x(number: Double) = x(X.ofNumber(number)) + + /** Alias for calling [x] with `X.ofString(string)`. */ + fun x(string: String) = x(X.ofString(string)) + + /** + * Specifies the y-coordinate of the top-left corner of the base asset where the overlay's + * top-left corner will be positioned. It also accepts arithmetic expressions such as + * `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + */ + fun y(y: Y) = y(JsonField.of(y)) + + /** + * Sets [Builder.y] to an arbitrary JSON value. + * + * You should usually call [Builder.y] with a well-typed [Y] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun y(y: JsonField) = apply { this.y = y } + + /** Alias for calling [y] with `Y.ofNumber(number)`. */ + fun y(number: Double) = y(Y.ofNumber(number)) + + /** Alias for calling [y] with `Y.ofString(string)`. */ + fun y(string: String) = y(Y.ofString(string)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OverlayPosition]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OverlayPosition = + OverlayPosition(focus, x, y, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): OverlayPosition = apply { + if (validated) { + return@apply + } + + focus().ifPresent { it.validate() } + x().ifPresent { it.validate() } + y().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (focus.asKnown().getOrNull()?.validity() ?: 0) + + (x.asKnown().getOrNull()?.validity() ?: 0) + + (y.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Specifies the position of the overlay relative to the parent image or video. Maps to `lfo` in + * the URL. + */ + class Focus @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CENTER = of("center") + + @JvmField val TOP = of("top") + + @JvmField val LEFT = of("left") + + @JvmField val BOTTOM = of("bottom") + + @JvmField val RIGHT = of("right") + + @JvmField val TOP_LEFT = of("top_left") + + @JvmField val TOP_RIGHT = of("top_right") + + @JvmField val BOTTOM_LEFT = of("bottom_left") + + @JvmField val BOTTOM_RIGHT = of("bottom_right") + + @JvmStatic fun of(value: String) = Focus(JsonField.of(value)) + } + + /** An enum containing [Focus]'s known values. */ + enum class Known { + CENTER, + TOP, + LEFT, + BOTTOM, + RIGHT, + TOP_LEFT, + TOP_RIGHT, + BOTTOM_LEFT, + BOTTOM_RIGHT, + } + + /** + * An enum containing [Focus]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Focus] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CENTER, + TOP, + LEFT, + BOTTOM, + RIGHT, + TOP_LEFT, + TOP_RIGHT, + BOTTOM_LEFT, + BOTTOM_RIGHT, + /** An enum member indicating that [Focus] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CENTER -> Value.CENTER + TOP -> Value.TOP + LEFT -> Value.LEFT + BOTTOM -> Value.BOTTOM + RIGHT -> Value.RIGHT + TOP_LEFT -> Value.TOP_LEFT + TOP_RIGHT -> Value.TOP_RIGHT + BOTTOM_LEFT -> Value.BOTTOM_LEFT + BOTTOM_RIGHT -> Value.BOTTOM_RIGHT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CENTER -> Known.CENTER + TOP -> Known.TOP + LEFT -> Known.LEFT + BOTTOM -> Known.BOTTOM + RIGHT -> Known.RIGHT + TOP_LEFT -> Known.TOP_LEFT + TOP_RIGHT -> Known.TOP_RIGHT + BOTTOM_LEFT -> Known.BOTTOM_LEFT + BOTTOM_RIGHT -> Known.BOTTOM_RIGHT + else -> throw ImageKitInvalidDataException("Unknown Focus: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Focus = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Focus && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Specifies the x-coordinate of the top-left corner of the base asset where the overlay's + * top-left corner will be positioned. It also accepts arithmetic expressions such as + * `bw_mul_0.4` or `bw_sub_cw`. Maps to `lx` in the URL. Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + */ + @JsonDeserialize(using = X.Deserializer::class) + @JsonSerialize(using = X.Serializer::class) + class X + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): X = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is X && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "X{number=$number}" + string != null -> "X{string=$string}" + _json != null -> "X{_unknown=$_json}" + else -> throw IllegalStateException("Invalid X") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = X(number = number) + + @JvmStatic fun ofString(string: String) = X(string = string) + } + + /** An interface that defines how to map each variant of [X] to a value of type [T]. */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [X] to a value of type [T]. + * + * An instance of [X] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown X: $json") + } + } + + internal class Deserializer : BaseDeserializer(X::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): X { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + X(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + X(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> X(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(X::class) { + + override fun serialize( + value: X, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid X") + } + } + } + } + + /** + * Specifies the y-coordinate of the top-left corner of the base asset where the overlay's + * top-left corner will be positioned. It also accepts arithmetic expressions such as + * `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + */ + @JsonDeserialize(using = Y.Deserializer::class) + @JsonSerialize(using = Y.Serializer::class) + class Y + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Y = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Y && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "Y{number=$number}" + string != null -> "Y{string=$string}" + _json != null -> "Y{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Y") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Y(number = number) + + @JvmStatic fun ofString(string: String) = Y(string = string) + } + + /** An interface that defines how to map each variant of [Y] to a value of type [T]. */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Y] to a value of type [T]. + * + * An instance of [Y] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Y: $json") + } + } + + internal class Deserializer : BaseDeserializer(Y::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Y { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Y(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Y(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Y(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Y::class) { + + override fun serialize( + value: Y, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Y") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OverlayPosition && + focus == other.focus && + x == other.x && + y == other.y && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(focus, x, y, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OverlayPosition{focus=$focus, x=$x, y=$y, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayTiming.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayTiming.kt new file mode 100644 index 00000000..4d94f499 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayTiming.kt @@ -0,0 +1,801 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.allMaxBy +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class OverlayTiming +private constructor( + private val duration: JsonField, + private val end: JsonField, + private val start: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), + @JsonProperty("end") @ExcludeMissing end: JsonField = JsonMissing.of(), + @JsonProperty("start") @ExcludeMissing start: JsonField = JsonMissing.of(), + ) : this(duration, end, start, mutableMapOf()) + + /** + * Specifies the duration (in seconds) during which the overlay should appear on the base video. + * Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) and arithmetic + * expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. Applies only if the base asset is a + * video. Maps to `ldu` in the URL. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun duration(): Optional = duration.getOptional("duration") + + /** + * Specifies the end time (in seconds) for when the overlay should disappear from the base + * video. If both end and duration are provided, duration is ignored. Accepts a positive number + * up to two decimal places (e.g., `20` or `20.50`) and arithmetic expressions such as + * `bdu_mul_0.4` or `bdu_sub_idu`. Applies only if the base asset is a video. Maps to `leo` in + * the URL. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun end(): Optional = end.getOptional("end") + + /** + * Specifies the start time (in seconds) for when the overlay should appear on the base video. + * Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) and arithmetic + * expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. Applies only if the base asset is a + * video. Maps to `lso` in the URL. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun start(): Optional = start.getOptional("start") + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [end]. + * + * Unlike [end], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end + + /** + * Returns the raw JSON value of [start]. + * + * Unlike [start], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [OverlayTiming]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OverlayTiming]. */ + class Builder internal constructor() { + + private var duration: JsonField = JsonMissing.of() + private var end: JsonField = JsonMissing.of() + private var start: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(overlayTiming: OverlayTiming) = apply { + duration = overlayTiming.duration + end = overlayTiming.end + start = overlayTiming.start + additionalProperties = overlayTiming.additionalProperties.toMutableMap() + } + + /** + * Specifies the duration (in seconds) during which the overlay should appear on the base + * video. Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) and + * arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. Applies only if the base + * asset is a video. Maps to `ldu` in the URL. + */ + fun duration(duration: Duration) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Duration] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** Alias for calling [duration] with `Duration.ofNumber(number)`. */ + fun duration(number: Double) = duration(Duration.ofNumber(number)) + + /** Alias for calling [duration] with `Duration.ofString(string)`. */ + fun duration(string: String) = duration(Duration.ofString(string)) + + /** + * Specifies the end time (in seconds) for when the overlay should disappear from the base + * video. If both end and duration are provided, duration is ignored. Accepts a positive + * number up to two decimal places (e.g., `20` or `20.50`) and arithmetic expressions such + * as `bdu_mul_0.4` or `bdu_sub_idu`. Applies only if the base asset is a video. Maps to + * `leo` in the URL. + */ + fun end(end: End) = end(JsonField.of(end)) + + /** + * Sets [Builder.end] to an arbitrary JSON value. + * + * You should usually call [Builder.end] with a well-typed [End] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun end(end: JsonField) = apply { this.end = end } + + /** Alias for calling [end] with `End.ofNumber(number)`. */ + fun end(number: Double) = end(End.ofNumber(number)) + + /** Alias for calling [end] with `End.ofString(string)`. */ + fun end(string: String) = end(End.ofString(string)) + + /** + * Specifies the start time (in seconds) for when the overlay should appear on the base + * video. Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) and + * arithmetic expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. Applies only if the base + * asset is a video. Maps to `lso` in the URL. + */ + fun start(start: Start) = start(JsonField.of(start)) + + /** + * Sets [Builder.start] to an arbitrary JSON value. + * + * You should usually call [Builder.start] with a well-typed [Start] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun start(start: JsonField) = apply { this.start = start } + + /** Alias for calling [start] with `Start.ofNumber(number)`. */ + fun start(number: Double) = start(Start.ofNumber(number)) + + /** Alias for calling [start] with `Start.ofString(string)`. */ + fun start(string: String) = start(Start.ofString(string)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OverlayTiming]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OverlayTiming = + OverlayTiming(duration, end, start, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): OverlayTiming = apply { + if (validated) { + return@apply + } + + duration().ifPresent { it.validate() } + end().ifPresent { it.validate() } + start().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (duration.asKnown().getOrNull()?.validity() ?: 0) + + (end.asKnown().getOrNull()?.validity() ?: 0) + + (start.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Specifies the duration (in seconds) during which the overlay should appear on the base video. + * Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) and arithmetic + * expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. Applies only if the base asset is a + * video. Maps to `ldu` in the URL. + */ + @JsonDeserialize(using = Duration.Deserializer::class) + @JsonSerialize(using = Duration.Serializer::class) + class Duration + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Duration = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Duration && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "Duration{number=$number}" + string != null -> "Duration{string=$string}" + _json != null -> "Duration{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Duration") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Duration(number = number) + + @JvmStatic fun ofString(string: String) = Duration(string = string) + } + + /** + * An interface that defines how to map each variant of [Duration] to a value of type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Duration] to a value of type [T]. + * + * An instance of [Duration] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Duration: $json") + } + } + + internal class Deserializer : BaseDeserializer(Duration::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Duration { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Duration(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Duration(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Duration(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Duration::class) { + + override fun serialize( + value: Duration, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Duration") + } + } + } + } + + /** + * Specifies the end time (in seconds) for when the overlay should disappear from the base + * video. If both end and duration are provided, duration is ignored. Accepts a positive number + * up to two decimal places (e.g., `20` or `20.50`) and arithmetic expressions such as + * `bdu_mul_0.4` or `bdu_sub_idu`. Applies only if the base asset is a video. Maps to `leo` in + * the URL. + */ + @JsonDeserialize(using = End.Deserializer::class) + @JsonSerialize(using = End.Serializer::class) + class End + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): End = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is End && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "End{number=$number}" + string != null -> "End{string=$string}" + _json != null -> "End{_unknown=$_json}" + else -> throw IllegalStateException("Invalid End") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = End(number = number) + + @JvmStatic fun ofString(string: String) = End(string = string) + } + + /** An interface that defines how to map each variant of [End] to a value of type [T]. */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [End] to a value of type [T]. + * + * An instance of [End] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown End: $json") + } + } + + internal class Deserializer : BaseDeserializer(End::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): End { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + End(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + End(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> End(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(End::class) { + + override fun serialize( + value: End, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid End") + } + } + } + } + + /** + * Specifies the start time (in seconds) for when the overlay should appear on the base video. + * Accepts a positive number up to two decimal places (e.g., `20` or `20.50`) and arithmetic + * expressions such as `bdu_mul_0.4` or `bdu_sub_idu`. Applies only if the base asset is a + * video. Maps to `lso` in the URL. + */ + @JsonDeserialize(using = Start.Deserializer::class) + @JsonSerialize(using = Start.Serializer::class) + class Start + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Start = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Start && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "Start{number=$number}" + string != null -> "Start{string=$string}" + _json != null -> "Start{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Start") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Start(number = number) + + @JvmStatic fun ofString(string: String) = Start(string = string) + } + + /** An interface that defines how to map each variant of [Start] to a value of type [T]. */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Start] to a value of type [T]. + * + * An instance of [Start] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Start: $json") + } + } + + internal class Deserializer : BaseDeserializer(Start::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Start { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Start(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Start(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Start(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Start::class) { + + override fun serialize( + value: Start, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Start") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OverlayTiming && + duration == other.duration && + end == other.end && + start == other.start && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(duration, end, start, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OverlayTiming{duration=$duration, end=$end, start=$start, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlay.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlay.kt new file mode 100644 index 00000000..882fbd6c --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlay.kt @@ -0,0 +1,359 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class SolidColorOverlay +private constructor( + private val position: JsonField, + private val timing: JsonField, + private val color: JsonField, + private val type: JsonValue, + private val transformation: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("position") + @ExcludeMissing + position: JsonField = JsonMissing.of(), + @JsonProperty("timing") @ExcludeMissing timing: JsonField = JsonMissing.of(), + @JsonProperty("color") @ExcludeMissing color: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField> = JsonMissing.of(), + ) : this(position, timing, color, type, transformation, mutableMapOf()) + + fun toBaseOverlay(): BaseOverlay = + BaseOverlay.builder().position(position).timing(timing).build() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun position(): Optional = position.getOptional("position") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timing(): Optional = timing.getOptional("timing") + + /** + * Specifies the color of the block using an RGB hex code (e.g., `FF0000`), an RGBA code (e.g., + * `FFAABB50`), or a color name (e.g., `red`). If an 8-character value is provided, the last two + * characters represent the opacity level (from `00` for 0.00 to `99` for 0.99). + * + * @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 color(): String = color.getRequired("color") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("solidColor") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Control width and height of the solid color overlay. Supported transformations depend on the + * base/parent asset. See overlays on + * [Images](https://imagekit.io/docs/add-overlays-on-images#apply-transformation-on-solid-color-overlay) + * and + * [Videos](https://imagekit.io/docs/add-overlays-on-videos#apply-transformations-on-solid-color-block-overlay). + * + * @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 [position]. + * + * Unlike [position], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position + + /** + * Returns the raw JSON value of [timing]. + * + * Unlike [timing], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timing") @ExcludeMissing fun _timing(): JsonField = timing + + /** + * Returns the raw JSON value of [color]. + * + * Unlike [color], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + + /** + * 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 [SolidColorOverlay]. + * + * The following fields are required: + * ```java + * .color() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SolidColorOverlay]. */ + class Builder internal constructor() { + + private var position: JsonField = JsonMissing.of() + private var timing: JsonField = JsonMissing.of() + private var color: JsonField? = null + private var type: JsonValue = JsonValue.from("solidColor") + private var transformation: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(solidColorOverlay: SolidColorOverlay) = apply { + position = solidColorOverlay.position + timing = solidColorOverlay.timing + color = solidColorOverlay.color + type = solidColorOverlay.type + transformation = solidColorOverlay.transformation.map { it.toMutableList() } + additionalProperties = solidColorOverlay.additionalProperties.toMutableMap() + } + + fun position(position: OverlayPosition) = position(JsonField.of(position)) + + /** + * Sets [Builder.position] to an arbitrary JSON value. + * + * You should usually call [Builder.position] with a well-typed [OverlayPosition] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun position(position: JsonField) = apply { this.position = position } + + fun timing(timing: OverlayTiming) = timing(JsonField.of(timing)) + + /** + * Sets [Builder.timing] to an arbitrary JSON value. + * + * You should usually call [Builder.timing] with a well-typed [OverlayTiming] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun timing(timing: JsonField) = apply { this.timing = timing } + + /** + * Specifies the color of the block using an RGB hex code (e.g., `FF0000`), an RGBA code + * (e.g., `FFAABB50`), or a color name (e.g., `red`). If an 8-character value is provided, + * the last two characters represent the opacity level (from `00` for 0.00 to `99` for + * 0.99). + */ + fun color(color: String) = color(JsonField.of(color)) + + /** + * Sets [Builder.color] to an arbitrary JSON value. + * + * You should usually call [Builder.color] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun color(color: JsonField) = apply { this.color = color } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("solidColor") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Control width and height of the solid color overlay. Supported transformations depend on + * the base/parent asset. See overlays on + * [Images](https://imagekit.io/docs/add-overlays-on-images#apply-transformation-on-solid-color-overlay) + * and + * [Videos](https://imagekit.io/docs/add-overlays-on-videos#apply-transformations-on-solid-color-block-overlay). + */ + fun transformation(transformation: List) = + transformation(JsonField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary JSON value. + * + * You should usually call [Builder.transformation] with a well-typed + * `List` 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.map { it.toMutableList() } + } + + /** + * Adds a single [SolidColorOverlayTransformation] to [Builder.transformation]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTransformation(transformation: SolidColorOverlayTransformation) = apply { + this.transformation = + (this.transformation ?: JsonField.of(mutableListOf())).also { + checkKnown("transformation", it).add(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 [SolidColorOverlay]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .color() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SolidColorOverlay = + SolidColorOverlay( + position, + timing, + checkRequired("color", color), + type, + (transformation ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SolidColorOverlay = apply { + if (validated) { + return@apply + } + + position().ifPresent { it.validate() } + timing().ifPresent { it.validate() } + color() + _type().let { + if (it != JsonValue.from("solidColor")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + transformation().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (position.asKnown().getOrNull()?.validity() ?: 0) + + (timing.asKnown().getOrNull()?.validity() ?: 0) + + (if (color.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("solidColor")) 1 else 0 } + + (transformation.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SolidColorOverlay && + position == other.position && + timing == other.timing && + color == other.color && + type == other.type && + transformation == other.transformation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(position, timing, color, type, transformation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SolidColorOverlay{position=$position, timing=$timing, color=$color, type=$type, transformation=$transformation, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt new file mode 100644 index 00000000..8d69770f --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt @@ -0,0 +1,1112 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.allMaxBy +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class SolidColorOverlayTransformation +private constructor( + private val alpha: JsonField, + private val background: JsonField, + private val gradient: JsonField, + private val height: JsonField, + private val radius: JsonField, + private val width: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("alpha") @ExcludeMissing alpha: JsonField = JsonMissing.of(), + @JsonProperty("background") + @ExcludeMissing + background: JsonField = JsonMissing.of(), + @JsonProperty("gradient") @ExcludeMissing gradient: JsonField = JsonMissing.of(), + @JsonProperty("height") @ExcludeMissing height: JsonField = JsonMissing.of(), + @JsonProperty("radius") @ExcludeMissing radius: JsonField = JsonMissing.of(), + @JsonProperty("width") @ExcludeMissing width: JsonField = JsonMissing.of(), + ) : this(alpha, background, gradient, height, radius, width, mutableMapOf()) + + /** + * Specifies the transparency level of the solid color overlay. Accepts integers from `1` to + * `9`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun alpha(): Optional = alpha.getOptional("alpha") + + /** + * Specifies the background color of the solid color overlay. Accepts an RGB hex code (e.g., + * `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun background(): Optional = background.getOptional("background") + + /** + * Creates a linear gradient with two colors. Pass `true` for a default gradient, or provide a + * string for a custom gradient. Only works if the base asset is an image. See + * [gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun gradient(): Optional = gradient.getOptional("gradient") + + /** + * Controls the height of the solid color overlay. Accepts a numeric value or an arithmetic + * expression. Learn about + * [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun height(): Optional = height.getOptional("height") + + /** + * Specifies the corner radius of the solid color overlay. Set to `max` for circular or oval + * shape. See [radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun radius(): Optional = radius.getOptional("radius") + + /** + * Controls the width of the solid color overlay. Accepts a numeric value or an arithmetic + * expression (e.g., `bw_mul_0.2` or `bh_div_2`). Learn about + * [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun width(): Optional = width.getOptional("width") + + /** + * Returns the raw JSON value of [alpha]. + * + * Unlike [alpha], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("alpha") @ExcludeMissing fun _alpha(): JsonField = alpha + + /** + * Returns the raw JSON value of [background]. + * + * Unlike [background], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("background") @ExcludeMissing fun _background(): JsonField = background + + /** + * Returns the raw JSON value of [gradient]. + * + * Unlike [gradient], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gradient") @ExcludeMissing fun _gradient(): JsonField = gradient + + /** + * Returns the raw JSON value of [height]. + * + * Unlike [height], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("height") @ExcludeMissing fun _height(): JsonField = height + + /** + * Returns the raw JSON value of [radius]. + * + * Unlike [radius], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("radius") @ExcludeMissing fun _radius(): JsonField = radius + + /** + * Returns the raw JSON value of [width]. + * + * Unlike [width], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("width") @ExcludeMissing fun _width(): JsonField = width + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SolidColorOverlayTransformation]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SolidColorOverlayTransformation]. */ + class Builder internal constructor() { + + private var alpha: JsonField = JsonMissing.of() + private var background: JsonField = JsonMissing.of() + private var gradient: JsonField = JsonMissing.of() + private var height: JsonField = JsonMissing.of() + private var radius: JsonField = JsonMissing.of() + private var width: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(solidColorOverlayTransformation: SolidColorOverlayTransformation) = + apply { + alpha = solidColorOverlayTransformation.alpha + background = solidColorOverlayTransformation.background + gradient = solidColorOverlayTransformation.gradient + height = solidColorOverlayTransformation.height + radius = solidColorOverlayTransformation.radius + width = solidColorOverlayTransformation.width + additionalProperties = + solidColorOverlayTransformation.additionalProperties.toMutableMap() + } + + /** + * Specifies the transparency level of the solid color overlay. Accepts integers from `1` to + * `9`. + */ + fun alpha(alpha: Double) = alpha(JsonField.of(alpha)) + + /** + * Sets [Builder.alpha] to an arbitrary JSON value. + * + * You should usually call [Builder.alpha] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun alpha(alpha: JsonField) = apply { this.alpha = alpha } + + /** + * Specifies the background color of the solid color overlay. Accepts an RGB hex code (e.g., + * `FF0000`), an RGBA code (e.g., `FFAABB50`), or a color name. + */ + fun background(background: String) = background(JsonField.of(background)) + + /** + * Sets [Builder.background] to an arbitrary JSON value. + * + * You should usually call [Builder.background] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun background(background: JsonField) = apply { this.background = background } + + /** + * Creates a linear gradient with two colors. Pass `true` for a default gradient, or provide + * a string for a custom gradient. Only works if the base asset is an image. See + * [gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + */ + fun gradient(gradient: Gradient) = gradient(JsonField.of(gradient)) + + /** + * Sets [Builder.gradient] to an arbitrary JSON value. + * + * You should usually call [Builder.gradient] with a well-typed [Gradient] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun gradient(gradient: JsonField) = apply { this.gradient = gradient } + + /** Alias for calling [gradient] with `Gradient.ofTrue()`. */ + fun gradientTrue() = gradient(Gradient.ofTrue()) + + /** Alias for calling [gradient] with `Gradient.ofString(string)`. */ + fun gradient(string: String) = gradient(Gradient.ofString(string)) + + /** + * Controls the height of the solid color overlay. Accepts a numeric value or an arithmetic + * expression. Learn about + * [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + */ + fun height(height: Height) = height(JsonField.of(height)) + + /** + * Sets [Builder.height] to an arbitrary JSON value. + * + * You should usually call [Builder.height] with a well-typed [Height] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun height(height: JsonField) = apply { this.height = height } + + /** Alias for calling [height] with `Height.ofNumber(number)`. */ + fun height(number: Double) = height(Height.ofNumber(number)) + + /** Alias for calling [height] with `Height.ofString(string)`. */ + fun height(string: String) = height(Height.ofString(string)) + + /** + * Specifies the corner radius of the solid color overlay. Set to `max` for circular or oval + * shape. See [radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + */ + fun radius(radius: Radius) = radius(JsonField.of(radius)) + + /** + * Sets [Builder.radius] to an arbitrary JSON value. + * + * You should usually call [Builder.radius] with a well-typed [Radius] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun radius(radius: JsonField) = apply { this.radius = radius } + + /** Alias for calling [radius] with `Radius.ofNumber(number)`. */ + fun radius(number: Double) = radius(Radius.ofNumber(number)) + + /** Alias for calling [radius] with `Radius.ofMax()`. */ + fun radiusMax() = radius(Radius.ofMax()) + + /** + * Controls the width of the solid color overlay. Accepts a numeric value or an arithmetic + * expression (e.g., `bw_mul_0.2` or `bh_div_2`). Learn about + * [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + */ + fun width(width: Width) = width(JsonField.of(width)) + + /** + * Sets [Builder.width] to an arbitrary JSON value. + * + * You should usually call [Builder.width] with a well-typed [Width] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun width(width: JsonField) = apply { this.width = width } + + /** Alias for calling [width] with `Width.ofNumber(number)`. */ + fun width(number: Double) = width(Width.ofNumber(number)) + + /** Alias for calling [width] with `Width.ofString(string)`. */ + fun width(string: String) = width(Width.ofString(string)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SolidColorOverlayTransformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SolidColorOverlayTransformation = + SolidColorOverlayTransformation( + alpha, + background, + gradient, + height, + radius, + width, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SolidColorOverlayTransformation = apply { + if (validated) { + return@apply + } + + alpha() + background() + gradient().ifPresent { it.validate() } + height().ifPresent { it.validate() } + radius().ifPresent { it.validate() } + width().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (alpha.asKnown().isPresent) 1 else 0) + + (if (background.asKnown().isPresent) 1 else 0) + + (gradient.asKnown().getOrNull()?.validity() ?: 0) + + (height.asKnown().getOrNull()?.validity() ?: 0) + + (radius.asKnown().getOrNull()?.validity() ?: 0) + + (width.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Creates a linear gradient with two colors. Pass `true` for a default gradient, or provide a + * string for a custom gradient. Only works if the base asset is an image. See + * [gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + */ + @JsonDeserialize(using = Gradient.Deserializer::class) + @JsonSerialize(using = Gradient.Serializer::class) + class Gradient + private constructor( + private val true_: JsonValue? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun true_(): Optional = Optional.ofNullable(true_) + + fun string(): Optional = Optional.ofNullable(string) + + fun isTrue(): Boolean = true_ != null + + fun isString(): Boolean = string != null + + fun asTrue(): JsonValue = true_.getOrThrow("true_") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + true_ != null -> visitor.visitTrue(true_) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Gradient = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTrue(true_: JsonValue) { + true_.let { + if (it != JsonValue.from(true)) { + throw ImageKitInvalidDataException( + "'true_' is invalid, received $it" + ) + } + } + } + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitTrue(true_: JsonValue) = + true_.let { if (it == JsonValue.from(true)) 1 else 0 } + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Gradient && true_ == other.true_ && string == other.string + } + + override fun hashCode(): Int = Objects.hash(true_, string) + + override fun toString(): String = + when { + true_ != null -> "Gradient{true_=$true_}" + string != null -> "Gradient{string=$string}" + _json != null -> "Gradient{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Gradient") + } + + companion object { + + @JvmStatic fun ofTrue() = Gradient(true_ = JsonValue.from(true)) + + @JvmStatic fun ofString(string: String) = Gradient(string = string) + } + + /** + * An interface that defines how to map each variant of [Gradient] to a value of type [T]. + */ + interface Visitor { + + fun visitTrue(true_: JsonValue): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Gradient] to a value of type [T]. + * + * An instance of [Gradient] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Gradient: $json") + } + } + + internal class Deserializer : BaseDeserializer(Gradient::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Gradient { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Gradient(true_ = it, _json = json) } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef())?.let { + Gradient(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Gradient(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Gradient::class) { + + override fun serialize( + value: Gradient, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.true_ != null -> generator.writeObject(value.true_) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Gradient") + } + } + } + } + + /** + * Controls the height of the solid color overlay. Accepts a numeric value or an arithmetic + * expression. Learn about + * [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + */ + @JsonDeserialize(using = Height.Deserializer::class) + @JsonSerialize(using = Height.Serializer::class) + class Height + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Height = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Height && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "Height{number=$number}" + string != null -> "Height{string=$string}" + _json != null -> "Height{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Height") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Height(number = number) + + @JvmStatic fun ofString(string: String) = Height(string = string) + } + + /** An interface that defines how to map each variant of [Height] to a value of type [T]. */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Height] to a value of type [T]. + * + * An instance of [Height] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Height: $json") + } + } + + internal class Deserializer : BaseDeserializer(Height::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Height { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Height(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Height(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Height(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Height::class) { + + override fun serialize( + value: Height, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Height") + } + } + } + } + + /** + * Specifies the corner radius of the solid color overlay. Set to `max` for circular or oval + * shape. See [radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + */ + @JsonDeserialize(using = Radius.Deserializer::class) + @JsonSerialize(using = Radius.Serializer::class) + class Radius + private constructor( + private val number: Double? = null, + private val max: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun max(): Optional = Optional.ofNullable(max) + + fun isNumber(): Boolean = number != null + + fun isMax(): Boolean = max != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asMax(): JsonValue = max.getOrThrow("max") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + max != null -> visitor.visitMax(max) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Radius = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitMax(max: JsonValue) { + max.let { + if (it != JsonValue.from("max")) { + throw ImageKitInvalidDataException("'max' is invalid, received $it") + } + } + } + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitMax(max: JsonValue) = + max.let { if (it == JsonValue.from("max")) 1 else 0 } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Radius && number == other.number && max == other.max + } + + override fun hashCode(): Int = Objects.hash(number, max) + + override fun toString(): String = + when { + number != null -> "Radius{number=$number}" + max != null -> "Radius{max=$max}" + _json != null -> "Radius{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Radius") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Radius(number = number) + + @JvmStatic fun ofMax() = Radius(max = JsonValue.from("max")) + } + + /** An interface that defines how to map each variant of [Radius] to a value of type [T]. */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitMax(max: JsonValue): T + + /** + * Maps an unknown variant of [Radius] to a value of type [T]. + * + * An instance of [Radius] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Radius: $json") + } + } + + internal class Deserializer : BaseDeserializer(Radius::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Radius { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Radius(max = it, _json = json) } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef())?.let { + Radius(number = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Radius(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Radius::class) { + + override fun serialize( + value: Radius, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.max != null -> generator.writeObject(value.max) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Radius") + } + } + } + } + + /** + * Controls the width of the solid color overlay. Accepts a numeric value or an arithmetic + * expression (e.g., `bw_mul_0.2` or `bh_div_2`). Learn about + * [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + */ + @JsonDeserialize(using = Width.Deserializer::class) + @JsonSerialize(using = Width.Serializer::class) + class Width + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Width = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Width && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "Width{number=$number}" + string != null -> "Width{string=$string}" + _json != null -> "Width{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Width") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Width(number = number) + + @JvmStatic fun ofString(string: String) = Width(string = string) + } + + /** An interface that defines how to map each variant of [Width] to a value of type [T]. */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Width] to a value of type [T]. + * + * An instance of [Width] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Width: $json") + } + } + + internal class Deserializer : BaseDeserializer(Width::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Width { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Width(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Width(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Width(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Width::class) { + + override fun serialize( + value: Width, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Width") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SolidColorOverlayTransformation && + alpha == other.alpha && + background == other.background && + gradient == other.gradient && + height == other.height && + radius == other.radius && + width == other.width && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(alpha, background, gradient, height, radius, width, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SolidColorOverlayTransformation{alpha=$alpha, background=$background, gradient=$gradient, height=$height, radius=$radius, width=$width, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SrcOptions.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SrcOptions.kt new file mode 100644 index 00000000..24c50b25 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SrcOptions.kt @@ -0,0 +1,618 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Options for generating ImageKit URLs with transformations. See the + * [Transformations guide](https://imagekit.io/docs/transformations). + */ +class SrcOptions +private constructor( + private val src: JsonField, + private val urlEndpoint: JsonField, + private val expiresIn: JsonField, + private val queryParameters: JsonField, + private val signed: JsonField, + private val transformation: JsonField>, + private val transformationPosition: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("src") @ExcludeMissing src: JsonField = JsonMissing.of(), + @JsonProperty("urlEndpoint") + @ExcludeMissing + urlEndpoint: JsonField = JsonMissing.of(), + @JsonProperty("expiresIn") @ExcludeMissing expiresIn: JsonField = JsonMissing.of(), + @JsonProperty("queryParameters") + @ExcludeMissing + queryParameters: JsonField = JsonMissing.of(), + @JsonProperty("signed") @ExcludeMissing signed: JsonField = JsonMissing.of(), + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField> = JsonMissing.of(), + @JsonProperty("transformationPosition") + @ExcludeMissing + transformationPosition: JsonField = JsonMissing.of(), + ) : this( + src, + urlEndpoint, + expiresIn, + queryParameters, + signed, + transformation, + transformationPosition, + mutableMapOf(), + ) + + /** + * Accepts a relative or absolute path of the resource. If a relative path is provided, it is + * appended to the `urlEndpoint`. If an absolute path is provided, `urlEndpoint` is ignored. + * + * @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 src(): String = src.getRequired("src") + + /** + * Get your urlEndpoint from the + * [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints). + * + * @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 urlEndpoint(): String = urlEndpoint.getRequired("urlEndpoint") + + /** + * When you want the signed URL to expire, specified in seconds. If `expiresIn` is anything + * above 0, the URL will always be signed even if `signed` is set to false. If not specified and + * `signed` is `true`, the signed URL will not expire (valid indefinitely). + * + * Example: Setting `expiresIn: 3600` will make the URL expire 1 hour from generation time. + * After the expiry time, the signed URL will no longer be valid and ImageKit will return a 401 + * Unauthorized status code. + * + * [Learn + * more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiresIn(): Optional = expiresIn.getOptional("expiresIn") + + /** + * These are additional query parameters that you want to add to the final URL. They can be any + * query parameters and not necessarily related to ImageKit. This is especially useful if you + * want to add a versioning parameter to your URLs. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun queryParameters(): Optional = + queryParameters.getOptional("queryParameters") + + /** + * Whether to sign the URL or not. Set this to `true` if you want to generate a signed URL. If + * `signed` is `true` and `expiresIn` is not specified, the signed URL will not expire (valid + * indefinitely). Note: If `expiresIn` is set to any value above 0, the URL will always be + * signed regardless of this setting. + * [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun signed(): Optional = signed.getOptional("signed") + + /** + * An array of objects specifying the transformations to be applied in the URL. If more than one + * transformation is specified, they are applied in the order they are specified as chained + * transformations. See + * [Chained transformations](https://imagekit.io/docs/transformations#chained-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") + + /** + * By default, the transformation string is added as a query parameter in the URL, e.g., + * `?tr=w-100,h-100`. If you want to add the transformation string in the path of the URL, set + * this to `path`. Learn more in the + * [Transformations guide](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 transformationPosition(): Optional = + transformationPosition.getOptional("transformationPosition") + + /** + * Returns the raw JSON value of [src]. + * + * Unlike [src], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("src") @ExcludeMissing fun _src(): JsonField = src + + /** + * Returns the raw JSON value of [urlEndpoint]. + * + * Unlike [urlEndpoint], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("urlEndpoint") @ExcludeMissing fun _urlEndpoint(): JsonField = urlEndpoint + + /** + * Returns the raw JSON value of [expiresIn]. + * + * Unlike [expiresIn], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expiresIn") @ExcludeMissing fun _expiresIn(): JsonField = expiresIn + + /** + * Returns the raw JSON value of [queryParameters]. + * + * Unlike [queryParameters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("queryParameters") + @ExcludeMissing + fun _queryParameters(): JsonField = queryParameters + + /** + * Returns the raw JSON value of [signed]. + * + * Unlike [signed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("signed") @ExcludeMissing fun _signed(): JsonField = signed + + /** + * 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 [transformationPosition]. + * + * Unlike [transformationPosition], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("transformationPosition") + @ExcludeMissing + fun _transformationPosition(): JsonField = transformationPosition + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SrcOptions]. + * + * The following fields are required: + * ```java + * .src() + * .urlEndpoint() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SrcOptions]. */ + class Builder internal constructor() { + + private var src: JsonField? = null + private var urlEndpoint: JsonField? = null + private var expiresIn: JsonField = JsonMissing.of() + private var queryParameters: JsonField = JsonMissing.of() + private var signed: JsonField = JsonMissing.of() + private var transformation: JsonField>? = null + private var transformationPosition: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(srcOptions: SrcOptions) = apply { + src = srcOptions.src + urlEndpoint = srcOptions.urlEndpoint + expiresIn = srcOptions.expiresIn + queryParameters = srcOptions.queryParameters + signed = srcOptions.signed + transformation = srcOptions.transformation.map { it.toMutableList() } + transformationPosition = srcOptions.transformationPosition + additionalProperties = srcOptions.additionalProperties.toMutableMap() + } + + /** + * Accepts a relative or absolute path of the resource. If a relative path is provided, it + * is appended to the `urlEndpoint`. If an absolute path is provided, `urlEndpoint` is + * ignored. + */ + fun src(src: String) = src(JsonField.of(src)) + + /** + * Sets [Builder.src] to an arbitrary JSON value. + * + * You should usually call [Builder.src] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun src(src: JsonField) = apply { this.src = src } + + /** + * Get your urlEndpoint from the + * [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints). + */ + fun urlEndpoint(urlEndpoint: String) = urlEndpoint(JsonField.of(urlEndpoint)) + + /** + * Sets [Builder.urlEndpoint] to an arbitrary JSON value. + * + * You should usually call [Builder.urlEndpoint] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun urlEndpoint(urlEndpoint: JsonField) = apply { this.urlEndpoint = urlEndpoint } + + /** + * When you want the signed URL to expire, specified in seconds. If `expiresIn` is anything + * above 0, the URL will always be signed even if `signed` is set to false. If not specified + * and `signed` is `true`, the signed URL will not expire (valid indefinitely). + * + * Example: Setting `expiresIn: 3600` will make the URL expire 1 hour from generation time. + * After the expiry time, the signed URL will no longer be valid and ImageKit will return a + * 401 Unauthorized status code. + * + * [Learn + * more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + */ + fun expiresIn(expiresIn: Double) = expiresIn(JsonField.of(expiresIn)) + + /** + * Sets [Builder.expiresIn] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresIn] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun expiresIn(expiresIn: JsonField) = apply { this.expiresIn = expiresIn } + + /** + * These are additional query parameters that you want to add to the final URL. They can be + * any query parameters and not necessarily related to ImageKit. This is especially useful + * if you want to add a versioning parameter to your URLs. + */ + fun queryParameters(queryParameters: QueryParameters) = + queryParameters(JsonField.of(queryParameters)) + + /** + * Sets [Builder.queryParameters] to an arbitrary JSON value. + * + * You should usually call [Builder.queryParameters] with a well-typed [QueryParameters] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun queryParameters(queryParameters: JsonField) = apply { + this.queryParameters = queryParameters + } + + /** + * Whether to sign the URL or not. Set this to `true` if you want to generate a signed URL. + * If `signed` is `true` and `expiresIn` is not specified, the signed URL will not expire + * (valid indefinitely). Note: If `expiresIn` is set to any value above 0, the URL will + * always be signed regardless of this setting. + * [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + */ + fun signed(signed: Boolean) = signed(JsonField.of(signed)) + + /** + * Sets [Builder.signed] to an arbitrary JSON value. + * + * You should usually call [Builder.signed] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun signed(signed: JsonField) = apply { this.signed = signed } + + /** + * An array of objects specifying the transformations to be applied in the URL. If more than + * one transformation is specified, they are applied in the order they are specified as + * chained transformations. See + * [Chained transformations](https://imagekit.io/docs/transformations#chained-transformations). + */ + fun transformation(transformation: List) = + transformation(JsonField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary JSON value. + * + * You should usually call [Builder.transformation] with a well-typed `List` + * 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.map { it.toMutableList() } + } + + /** + * Adds a single [Transformation] to [Builder.transformation]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTransformation(transformation: Transformation) = apply { + this.transformation = + (this.transformation ?: JsonField.of(mutableListOf())).also { + checkKnown("transformation", it).add(transformation) + } + } + + /** + * By default, the transformation string is added as a query parameter in the URL, e.g., + * `?tr=w-100,h-100`. If you want to add the transformation string in the path of the URL, + * set this to `path`. Learn more in the + * [Transformations guide](https://imagekit.io/docs/transformations). + */ + fun transformationPosition(transformationPosition: TransformationPosition) = + transformationPosition(JsonField.of(transformationPosition)) + + /** + * Sets [Builder.transformationPosition] to an arbitrary JSON value. + * + * You should usually call [Builder.transformationPosition] with a well-typed + * [TransformationPosition] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun transformationPosition(transformationPosition: JsonField) = + apply { + this.transformationPosition = transformationPosition + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SrcOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .src() + * .urlEndpoint() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SrcOptions = + SrcOptions( + checkRequired("src", src), + checkRequired("urlEndpoint", urlEndpoint), + expiresIn, + queryParameters, + signed, + (transformation ?: JsonMissing.of()).map { it.toImmutable() }, + transformationPosition, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SrcOptions = apply { + if (validated) { + return@apply + } + + src() + urlEndpoint() + expiresIn() + queryParameters().ifPresent { it.validate() } + signed() + transformation().ifPresent { it.forEach { it.validate() } } + transformationPosition().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (src.asKnown().isPresent) 1 else 0) + + (if (urlEndpoint.asKnown().isPresent) 1 else 0) + + (if (expiresIn.asKnown().isPresent) 1 else 0) + + (queryParameters.asKnown().getOrNull()?.validity() ?: 0) + + (if (signed.asKnown().isPresent) 1 else 0) + + (transformation.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (transformationPosition.asKnown().getOrNull()?.validity() ?: 0) + + /** + * These are additional query parameters that you want to add to the final URL. They can be any + * query parameters and not necessarily related to ImageKit. This is especially useful if you + * want to add a versioning parameter to your URLs. + */ + class QueryParameters + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [QueryParameters]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [QueryParameters]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(queryParameters: QueryParameters) = apply { + additionalProperties = queryParameters.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [QueryParameters]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): QueryParameters = QueryParameters(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): QueryParameters = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is QueryParameters && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "QueryParameters{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SrcOptions && + src == other.src && + urlEndpoint == other.urlEndpoint && + expiresIn == other.expiresIn && + queryParameters == other.queryParameters && + signed == other.signed && + transformation == other.transformation && + transformationPosition == other.transformationPosition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + src, + urlEndpoint, + expiresIn, + queryParameters, + signed, + transformation, + transformationPosition, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SrcOptions{src=$src, urlEndpoint=$urlEndpoint, expiresIn=$expiresIn, queryParameters=$queryParameters, signed=$signed, transformation=$transformation, transformationPosition=$transformationPosition, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/StreamingResolution.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/StreamingResolution.kt new file mode 100644 index 00000000..f9aa05d5 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/StreamingResolution.kt @@ -0,0 +1,168 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonCreator +import com.imagekit.api.core.Enum +import com.imagekit.api.core.JsonField +import com.imagekit.api.errors.ImageKitInvalidDataException + +/** + * Available streaming resolutions for + * [adaptive bitrate streaming](https://imagekit.io/docs/adaptive-bitrate-streaming) + */ +class StreamingResolution @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val _240 = of("240") + + @JvmField val _360 = of("360") + + @JvmField val _480 = of("480") + + @JvmField val _720 = of("720") + + @JvmField val _1080 = of("1080") + + @JvmField val _1440 = of("1440") + + @JvmField val _2160 = of("2160") + + @JvmStatic fun of(value: String) = StreamingResolution(JsonField.of(value)) + } + + /** An enum containing [StreamingResolution]'s known values. */ + enum class Known { + _240, + _360, + _480, + _720, + _1080, + _1440, + _2160, + } + + /** + * An enum containing [StreamingResolution]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [StreamingResolution] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + _240, + _360, + _480, + _720, + _1080, + _1440, + _2160, + /** + * An enum member indicating that [StreamingResolution] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + _240 -> Value._240 + _360 -> Value._360 + _480 -> Value._480 + _720 -> Value._720 + _1080 -> Value._1080 + _1440 -> Value._1440 + _2160 -> Value._2160 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + _240 -> Known._240 + _360 -> Known._360 + _480 -> Known._480 + _720 -> Known._720 + _1080 -> Known._1080 + _1440 -> Known._1440 + _2160 -> Known._2160 + else -> throw ImageKitInvalidDataException("Unknown StreamingResolution: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { ImageKitInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): StreamingResolution = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StreamingResolution && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlay.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlay.kt new file mode 100644 index 00000000..6a0485c3 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlay.kt @@ -0,0 +1,528 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class SubtitleOverlay +private constructor( + private val position: JsonField, + private val timing: JsonField, + private val input: JsonField, + private val type: JsonValue, + private val encoding: JsonField, + private val transformation: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("position") + @ExcludeMissing + position: JsonField = JsonMissing.of(), + @JsonProperty("timing") @ExcludeMissing timing: JsonField = JsonMissing.of(), + @JsonProperty("input") @ExcludeMissing input: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("encoding") @ExcludeMissing encoding: JsonField = JsonMissing.of(), + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField> = JsonMissing.of(), + ) : this(position, timing, input, type, encoding, transformation, mutableMapOf()) + + fun toBaseOverlay(): BaseOverlay = + BaseOverlay.builder().position(position).timing(timing).build() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun position(): Optional = position.getOptional("position") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timing(): Optional = timing.getOptional("timing") + + /** + * Specifies the relative path to the subtitle file used as an overlay. + * + * @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 input(): String = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("subtitle") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * The input path can be included in the layer as either `i-{input}` or + * `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate format + * automatically. To always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + * To always use plain text (`i-{input}`), set it to `plain`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun encoding(): Optional = encoding.getOptional("encoding") + + /** + * Control styling of the subtitle. See + * [Styling subtitles](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer). + * + * @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 [position]. + * + * Unlike [position], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position + + /** + * Returns the raw JSON value of [timing]. + * + * Unlike [timing], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timing") @ExcludeMissing fun _timing(): JsonField = timing + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [encoding]. + * + * Unlike [encoding], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("encoding") @ExcludeMissing fun _encoding(): JsonField = encoding + + /** + * 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 [SubtitleOverlay]. + * + * The following fields are required: + * ```java + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubtitleOverlay]. */ + class Builder internal constructor() { + + private var position: JsonField = JsonMissing.of() + private var timing: JsonField = JsonMissing.of() + private var input: JsonField? = null + private var type: JsonValue = JsonValue.from("subtitle") + private var encoding: JsonField = JsonMissing.of() + private var transformation: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subtitleOverlay: SubtitleOverlay) = apply { + position = subtitleOverlay.position + timing = subtitleOverlay.timing + input = subtitleOverlay.input + type = subtitleOverlay.type + encoding = subtitleOverlay.encoding + transformation = subtitleOverlay.transformation.map { it.toMutableList() } + additionalProperties = subtitleOverlay.additionalProperties.toMutableMap() + } + + fun position(position: OverlayPosition) = position(JsonField.of(position)) + + /** + * Sets [Builder.position] to an arbitrary JSON value. + * + * You should usually call [Builder.position] with a well-typed [OverlayPosition] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun position(position: JsonField) = apply { this.position = position } + + fun timing(timing: OverlayTiming) = timing(JsonField.of(timing)) + + /** + * Sets [Builder.timing] to an arbitrary JSON value. + * + * You should usually call [Builder.timing] with a well-typed [OverlayTiming] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun timing(timing: JsonField) = apply { this.timing = timing } + + /** Specifies the relative path to the subtitle file used as an overlay. */ + fun input(input: String) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("subtitle") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * The input path can be included in the layer as either `i-{input}` or + * `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate format + * automatically. To always use base64 encoding (`ie-{base64}`), set this parameter to + * `base64`. To always use plain text (`i-{input}`), set it to `plain`. + */ + fun encoding(encoding: Encoding) = encoding(JsonField.of(encoding)) + + /** + * Sets [Builder.encoding] to an arbitrary JSON value. + * + * You should usually call [Builder.encoding] with a well-typed [Encoding] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun encoding(encoding: JsonField) = apply { this.encoding = encoding } + + /** + * Control styling of the subtitle. See + * [Styling subtitles](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer). + */ + fun transformation(transformation: List) = + transformation(JsonField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary JSON value. + * + * You should usually call [Builder.transformation] with a well-typed + * `List` 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.map { it.toMutableList() } + } + + /** + * Adds a single [SubtitleOverlayTransformation] to [Builder.transformation]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTransformation(transformation: SubtitleOverlayTransformation) = apply { + this.transformation = + (this.transformation ?: JsonField.of(mutableListOf())).also { + checkKnown("transformation", it).add(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 [SubtitleOverlay]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubtitleOverlay = + SubtitleOverlay( + position, + timing, + checkRequired("input", input), + type, + encoding, + (transformation ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SubtitleOverlay = apply { + if (validated) { + return@apply + } + + position().ifPresent { it.validate() } + timing().ifPresent { it.validate() } + input() + _type().let { + if (it != JsonValue.from("subtitle")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + encoding().ifPresent { it.validate() } + transformation().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (position.asKnown().getOrNull()?.validity() ?: 0) + + (timing.asKnown().getOrNull()?.validity() ?: 0) + + (if (input.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("subtitle")) 1 else 0 } + + (encoding.asKnown().getOrNull()?.validity() ?: 0) + + (transformation.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** + * The input path can be included in the layer as either `i-{input}` or + * `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate format + * automatically. To always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + * To always use plain text (`i-{input}`), set it to `plain`. + */ + class Encoding @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AUTO = of("auto") + + @JvmField val PLAIN = of("plain") + + @JvmField val BASE64 = of("base64") + + @JvmStatic fun of(value: String) = Encoding(JsonField.of(value)) + } + + /** An enum containing [Encoding]'s known values. */ + enum class Known { + AUTO, + PLAIN, + BASE64, + } + + /** + * An enum containing [Encoding]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Encoding] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AUTO, + PLAIN, + BASE64, + /** An enum member indicating that [Encoding] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + PLAIN -> Value.PLAIN + BASE64 -> Value.BASE64 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + PLAIN -> Known.PLAIN + BASE64 -> Known.BASE64 + else -> throw ImageKitInvalidDataException("Unknown Encoding: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Encoding = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Encoding && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SubtitleOverlay && + position == other.position && + timing == other.timing && + input == other.input && + type == other.type && + encoding == other.encoding && + transformation == other.transformation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(position, timing, input, type, encoding, transformation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SubtitleOverlay{position=$position, timing=$timing, input=$input, type=$type, encoding=$encoding, transformation=$transformation, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlayTransformation.kt new file mode 100644 index 00000000..11c122df --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlayTransformation.kt @@ -0,0 +1,627 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Subtitle styling options. + * [Learn more](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + * from the docs. + */ +class SubtitleOverlayTransformation +private constructor( + private val background: JsonField, + private val color: JsonField, + private val fontFamily: JsonField, + private val fontOutline: JsonField, + private val fontShadow: JsonField, + private val fontSize: JsonField, + private val typography: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("background") + @ExcludeMissing + background: JsonField = JsonMissing.of(), + @JsonProperty("color") @ExcludeMissing color: JsonField = JsonMissing.of(), + @JsonProperty("fontFamily") + @ExcludeMissing + fontFamily: JsonField = JsonMissing.of(), + @JsonProperty("fontOutline") + @ExcludeMissing + fontOutline: JsonField = JsonMissing.of(), + @JsonProperty("fontShadow") + @ExcludeMissing + fontShadow: JsonField = JsonMissing.of(), + @JsonProperty("fontSize") @ExcludeMissing fontSize: JsonField = JsonMissing.of(), + @JsonProperty("typography") + @ExcludeMissing + typography: JsonField = JsonMissing.of(), + ) : this( + background, + color, + fontFamily, + fontOutline, + fontShadow, + fontSize, + typography, + mutableMapOf(), + ) + + /** + * Specifies the subtitle background color using a standard color name, an RGB color code (e.g., + * FF0000), or an RGBA color code (e.g., FFAABB50). + * + * [Subtitle styling + * options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun background(): Optional = background.getOptional("background") + + /** + * Sets the font color of the subtitle text using a standard color name, an RGB color code + * (e.g., FF0000), or an RGBA color code (e.g., FFAABB50). + * + * [Subtitle styling + * options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun color(): Optional = color.getOptional("color") + + /** + * Font family for subtitles. Refer to the + * [supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fontFamily(): Optional = fontFamily.getOptional("fontFamily") + + /** + * Sets the font outline of the subtitle text. Requires the outline width (an integer) and the + * outline color (as an RGB color code, RGBA color code, or standard web color name) separated + * by an underscore. Example: `fol-2_blue` (outline width of 2px and outline color blue), + * `fol-2_A1CCDD` (outline width of 2px and outline color `#A1CCDD`) and `fol-2_A1CCDD50` + * (outline width of 2px and outline color `#A1CCDD` at 50% opacity). + * + * [Subtitle styling + * options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fontOutline(): Optional = fontOutline.getOptional("fontOutline") + + /** + * Sets the font shadow for the subtitle text. Requires the shadow color (as an RGB color code, + * RGBA color code, or standard web color name) and shadow indent (an integer) separated by an + * underscore. Example: `fsh-blue_2` (shadow color blue, indent of 2px), `fsh-A1CCDD_3` (shadow + * color `#A1CCDD`, indent of 3px), `fsh-A1CCDD50_3` (shadow color `#A1CCDD` at 50% opacity, + * indent of 3px). + * + * [Subtitle styling + * options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fontShadow(): Optional = fontShadow.getOptional("fontShadow") + + /** + * Sets the font size of subtitle text. + * + * [Subtitle styling + * options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fontSize(): Optional = fontSize.getOptional("fontSize") + + /** + * Sets the typography style of the subtitle text. Supports values are `b` for bold, `i` for + * italics, and `b_i` for bold with italics. + * + * [Subtitle styling + * options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun typography(): Optional = typography.getOptional("typography") + + /** + * Returns the raw JSON value of [background]. + * + * Unlike [background], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("background") @ExcludeMissing fun _background(): JsonField = background + + /** + * Returns the raw JSON value of [color]. + * + * Unlike [color], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("color") @ExcludeMissing fun _color(): JsonField = color + + /** + * Returns the raw JSON value of [fontFamily]. + * + * Unlike [fontFamily], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fontFamily") @ExcludeMissing fun _fontFamily(): JsonField = fontFamily + + /** + * Returns the raw JSON value of [fontOutline]. + * + * Unlike [fontOutline], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fontOutline") @ExcludeMissing fun _fontOutline(): JsonField = fontOutline + + /** + * Returns the raw JSON value of [fontShadow]. + * + * Unlike [fontShadow], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fontShadow") @ExcludeMissing fun _fontShadow(): JsonField = fontShadow + + /** + * Returns the raw JSON value of [fontSize]. + * + * Unlike [fontSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fontSize") @ExcludeMissing fun _fontSize(): JsonField = fontSize + + /** + * Returns the raw JSON value of [typography]. + * + * Unlike [typography], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("typography") + @ExcludeMissing + fun _typography(): JsonField = typography + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SubtitleOverlayTransformation]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubtitleOverlayTransformation]. */ + class Builder internal constructor() { + + private var background: JsonField = JsonMissing.of() + private var color: JsonField = JsonMissing.of() + private var fontFamily: JsonField = JsonMissing.of() + private var fontOutline: JsonField = JsonMissing.of() + private var fontShadow: JsonField = JsonMissing.of() + private var fontSize: JsonField = JsonMissing.of() + private var typography: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subtitleOverlayTransformation: SubtitleOverlayTransformation) = apply { + background = subtitleOverlayTransformation.background + color = subtitleOverlayTransformation.color + fontFamily = subtitleOverlayTransformation.fontFamily + fontOutline = subtitleOverlayTransformation.fontOutline + fontShadow = subtitleOverlayTransformation.fontShadow + fontSize = subtitleOverlayTransformation.fontSize + typography = subtitleOverlayTransformation.typography + additionalProperties = subtitleOverlayTransformation.additionalProperties.toMutableMap() + } + + /** + * Specifies the subtitle background color using a standard color name, an RGB color code + * (e.g., FF0000), or an RGBA color code (e.g., FFAABB50). + * + * [Subtitle styling + * options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + */ + fun background(background: String) = background(JsonField.of(background)) + + /** + * Sets [Builder.background] to an arbitrary JSON value. + * + * You should usually call [Builder.background] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun background(background: JsonField) = apply { this.background = background } + + /** + * Sets the font color of the subtitle text using a standard color name, an RGB color code + * (e.g., FF0000), or an RGBA color code (e.g., FFAABB50). + * + * [Subtitle styling + * options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + */ + fun color(color: String) = color(JsonField.of(color)) + + /** + * Sets [Builder.color] to an arbitrary JSON value. + * + * You should usually call [Builder.color] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun color(color: JsonField) = apply { this.color = color } + + /** + * Font family for subtitles. Refer to the + * [supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list). + */ + fun fontFamily(fontFamily: String) = fontFamily(JsonField.of(fontFamily)) + + /** + * Sets [Builder.fontFamily] to an arbitrary JSON value. + * + * You should usually call [Builder.fontFamily] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun fontFamily(fontFamily: JsonField) = apply { this.fontFamily = fontFamily } + + /** + * Sets the font outline of the subtitle text. Requires the outline width (an integer) and + * the outline color (as an RGB color code, RGBA color code, or standard web color name) + * separated by an underscore. Example: `fol-2_blue` (outline width of 2px and outline color + * blue), `fol-2_A1CCDD` (outline width of 2px and outline color `#A1CCDD`) and + * `fol-2_A1CCDD50` (outline width of 2px and outline color `#A1CCDD` at 50% opacity). + * + * [Subtitle styling + * options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + */ + fun fontOutline(fontOutline: String) = fontOutline(JsonField.of(fontOutline)) + + /** + * Sets [Builder.fontOutline] to an arbitrary JSON value. + * + * You should usually call [Builder.fontOutline] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun fontOutline(fontOutline: JsonField) = apply { this.fontOutline = fontOutline } + + /** + * Sets the font shadow for the subtitle text. Requires the shadow color (as an RGB color + * code, RGBA color code, or standard web color name) and shadow indent (an integer) + * separated by an underscore. Example: `fsh-blue_2` (shadow color blue, indent of 2px), + * `fsh-A1CCDD_3` (shadow color `#A1CCDD`, indent of 3px), `fsh-A1CCDD50_3` (shadow color + * `#A1CCDD` at 50% opacity, indent of 3px). + * + * [Subtitle styling + * options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + */ + fun fontShadow(fontShadow: String) = fontShadow(JsonField.of(fontShadow)) + + /** + * Sets [Builder.fontShadow] to an arbitrary JSON value. + * + * You should usually call [Builder.fontShadow] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun fontShadow(fontShadow: JsonField) = apply { this.fontShadow = fontShadow } + + /** + * Sets the font size of subtitle text. + * + * [Subtitle styling + * options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + */ + fun fontSize(fontSize: Double) = fontSize(JsonField.of(fontSize)) + + /** + * Sets [Builder.fontSize] to an arbitrary JSON value. + * + * You should usually call [Builder.fontSize] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fontSize(fontSize: JsonField) = apply { this.fontSize = fontSize } + + /** + * Sets the typography style of the subtitle text. Supports values are `b` for bold, `i` for + * italics, and `b_i` for bold with italics. + * + * [Subtitle styling + * options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + */ + fun typography(typography: Typography) = typography(JsonField.of(typography)) + + /** + * Sets [Builder.typography] to an arbitrary JSON value. + * + * You should usually call [Builder.typography] with a well-typed [Typography] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun typography(typography: JsonField) = apply { this.typography = typography } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SubtitleOverlayTransformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SubtitleOverlayTransformation = + SubtitleOverlayTransformation( + background, + color, + fontFamily, + fontOutline, + fontShadow, + fontSize, + typography, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SubtitleOverlayTransformation = apply { + if (validated) { + return@apply + } + + background() + color() + fontFamily() + fontOutline() + fontShadow() + fontSize() + typography().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (background.asKnown().isPresent) 1 else 0) + + (if (color.asKnown().isPresent) 1 else 0) + + (if (fontFamily.asKnown().isPresent) 1 else 0) + + (if (fontOutline.asKnown().isPresent) 1 else 0) + + (if (fontShadow.asKnown().isPresent) 1 else 0) + + (if (fontSize.asKnown().isPresent) 1 else 0) + + (typography.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Sets the typography style of the subtitle text. Supports values are `b` for bold, `i` for + * italics, and `b_i` for bold with italics. + * + * [Subtitle styling + * options](https://imagekit.io/docs/add-overlays-on-videos#styling-controls-for-subtitles-layer) + */ + class Typography @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val B = of("b") + + @JvmField val I = of("i") + + @JvmField val B_I = of("b_i") + + @JvmStatic fun of(value: String) = Typography(JsonField.of(value)) + } + + /** An enum containing [Typography]'s known values. */ + enum class Known { + B, + I, + B_I, + } + + /** + * An enum containing [Typography]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Typography] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + B, + I, + B_I, + /** + * An enum member indicating that [Typography] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + B -> Value.B + I -> Value.I + B_I -> Value.B_I + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + B -> Known.B + I -> Known.I + B_I -> Known.B_I + else -> throw ImageKitInvalidDataException("Unknown Typography: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Typography = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Typography && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SubtitleOverlayTransformation && + background == other.background && + color == other.color && + fontFamily == other.fontFamily && + fontOutline == other.fontOutline && + fontShadow == other.fontShadow && + fontSize == other.fontSize && + typography == other.typography && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + background, + color, + fontFamily, + fontOutline, + fontShadow, + fontSize, + typography, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SubtitleOverlayTransformation{background=$background, color=$color, fontFamily=$fontFamily, fontOutline=$fontOutline, fontShadow=$fontShadow, fontSize=$fontSize, typography=$typography, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlay.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlay.kt new file mode 100644 index 00000000..6bd7dfef --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlay.kt @@ -0,0 +1,532 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class TextOverlay +private constructor( + private val position: JsonField, + private val timing: JsonField, + private val text: JsonField, + private val type: JsonValue, + private val encoding: JsonField, + private val transformation: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("position") + @ExcludeMissing + position: JsonField = JsonMissing.of(), + @JsonProperty("timing") @ExcludeMissing timing: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("encoding") @ExcludeMissing encoding: JsonField = JsonMissing.of(), + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField> = JsonMissing.of(), + ) : this(position, timing, text, type, encoding, transformation, mutableMapOf()) + + fun toBaseOverlay(): BaseOverlay = + BaseOverlay.builder().position(position).timing(timing).build() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun position(): Optional = position.getOptional("position") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timing(): Optional = timing.getOptional("timing") + + /** + * Specifies the text to be displayed in the overlay. The SDK automatically handles special + * characters and encoding. + * + * @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 text(): String = text.getRequired("text") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("text") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Text can be included in the layer as either `i-{input}` (plain text) or + * `ie-{base64_encoded_input}` (base64). By default, the SDK selects the appropriate format + * based on the input text. To always use base64 (`ie-{base64}`), set this parameter to + * `base64`. To always use plain text (`i-{input}`), set it to `plain`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun encoding(): Optional = encoding.getOptional("encoding") + + /** + * Control styling of the text overlay. See + * [Text overlays](https://imagekit.io/docs/add-overlays-on-images#text-overlay). + * + * @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 [position]. + * + * Unlike [position], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position + + /** + * Returns the raw JSON value of [timing]. + * + * Unlike [timing], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timing") @ExcludeMissing fun _timing(): JsonField = timing + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [encoding]. + * + * Unlike [encoding], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("encoding") @ExcludeMissing fun _encoding(): JsonField = encoding + + /** + * 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 [TextOverlay]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TextOverlay]. */ + class Builder internal constructor() { + + private var position: JsonField = JsonMissing.of() + private var timing: JsonField = JsonMissing.of() + private var text: JsonField? = null + private var type: JsonValue = JsonValue.from("text") + private var encoding: JsonField = JsonMissing.of() + private var transformation: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(textOverlay: TextOverlay) = apply { + position = textOverlay.position + timing = textOverlay.timing + text = textOverlay.text + type = textOverlay.type + encoding = textOverlay.encoding + transformation = textOverlay.transformation.map { it.toMutableList() } + additionalProperties = textOverlay.additionalProperties.toMutableMap() + } + + fun position(position: OverlayPosition) = position(JsonField.of(position)) + + /** + * Sets [Builder.position] to an arbitrary JSON value. + * + * You should usually call [Builder.position] with a well-typed [OverlayPosition] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun position(position: JsonField) = apply { this.position = position } + + fun timing(timing: OverlayTiming) = timing(JsonField.of(timing)) + + /** + * Sets [Builder.timing] to an arbitrary JSON value. + * + * You should usually call [Builder.timing] with a well-typed [OverlayTiming] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun timing(timing: JsonField) = apply { this.timing = timing } + + /** + * Specifies the text to be displayed in the overlay. The SDK automatically handles special + * characters and encoding. + */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("text") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Text can be included in the layer as either `i-{input}` (plain text) or + * `ie-{base64_encoded_input}` (base64). By default, the SDK selects the appropriate format + * based on the input text. To always use base64 (`ie-{base64}`), set this parameter to + * `base64`. To always use plain text (`i-{input}`), set it to `plain`. + */ + fun encoding(encoding: Encoding) = encoding(JsonField.of(encoding)) + + /** + * Sets [Builder.encoding] to an arbitrary JSON value. + * + * You should usually call [Builder.encoding] with a well-typed [Encoding] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun encoding(encoding: JsonField) = apply { this.encoding = encoding } + + /** + * Control styling of the text overlay. See + * [Text overlays](https://imagekit.io/docs/add-overlays-on-images#text-overlay). + */ + fun transformation(transformation: List) = + transformation(JsonField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary JSON value. + * + * You should usually call [Builder.transformation] with a well-typed + * `List` 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.map { it.toMutableList() } + } + + /** + * Adds a single [TextOverlayTransformation] to [Builder.transformation]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTransformation(transformation: TextOverlayTransformation) = apply { + this.transformation = + (this.transformation ?: JsonField.of(mutableListOf())).also { + checkKnown("transformation", it).add(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 [TextOverlay]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TextOverlay = + TextOverlay( + position, + timing, + checkRequired("text", text), + type, + encoding, + (transformation ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TextOverlay = apply { + if (validated) { + return@apply + } + + position().ifPresent { it.validate() } + timing().ifPresent { it.validate() } + text() + _type().let { + if (it != JsonValue.from("text")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + encoding().ifPresent { it.validate() } + transformation().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (position.asKnown().getOrNull()?.validity() ?: 0) + + (timing.asKnown().getOrNull()?.validity() ?: 0) + + (if (text.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("text")) 1 else 0 } + + (encoding.asKnown().getOrNull()?.validity() ?: 0) + + (transformation.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** + * Text can be included in the layer as either `i-{input}` (plain text) or + * `ie-{base64_encoded_input}` (base64). By default, the SDK selects the appropriate format + * based on the input text. To always use base64 (`ie-{base64}`), set this parameter to + * `base64`. To always use plain text (`i-{input}`), set it to `plain`. + */ + class Encoding @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AUTO = of("auto") + + @JvmField val PLAIN = of("plain") + + @JvmField val BASE64 = of("base64") + + @JvmStatic fun of(value: String) = Encoding(JsonField.of(value)) + } + + /** An enum containing [Encoding]'s known values. */ + enum class Known { + AUTO, + PLAIN, + BASE64, + } + + /** + * An enum containing [Encoding]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Encoding] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AUTO, + PLAIN, + BASE64, + /** An enum member indicating that [Encoding] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + PLAIN -> Value.PLAIN + BASE64 -> Value.BASE64 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + PLAIN -> Known.PLAIN + BASE64 -> Known.BASE64 + else -> throw ImageKitInvalidDataException("Unknown Encoding: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Encoding = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Encoding && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TextOverlay && + position == other.position && + timing == other.timing && + text == other.text && + type == other.type && + encoding == other.encoding && + transformation == other.transformation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(position, timing, text, type, encoding, transformation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TextOverlay{position=$position, timing=$timing, text=$text, type=$type, encoding=$encoding, transformation=$transformation, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt new file mode 100644 index 00000000..c29f846b --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt @@ -0,0 +1,2061 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.allMaxBy +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class TextOverlayTransformation +private constructor( + private val alpha: JsonField, + private val background: JsonField, + private val flip: JsonField, + private val fontColor: JsonField, + private val fontFamily: JsonField, + private val fontSize: JsonField, + private val innerAlignment: JsonField, + private val lineHeight: JsonField, + private val padding: JsonField, + private val radius: JsonField, + private val rotation: JsonField, + private val typography: JsonField, + private val width: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("alpha") @ExcludeMissing alpha: JsonField = JsonMissing.of(), + @JsonProperty("background") + @ExcludeMissing + background: JsonField = JsonMissing.of(), + @JsonProperty("flip") @ExcludeMissing flip: JsonField = JsonMissing.of(), + @JsonProperty("fontColor") @ExcludeMissing fontColor: JsonField = JsonMissing.of(), + @JsonProperty("fontFamily") + @ExcludeMissing + fontFamily: JsonField = JsonMissing.of(), + @JsonProperty("fontSize") @ExcludeMissing fontSize: JsonField = JsonMissing.of(), + @JsonProperty("innerAlignment") + @ExcludeMissing + innerAlignment: JsonField = JsonMissing.of(), + @JsonProperty("lineHeight") + @ExcludeMissing + lineHeight: JsonField = JsonMissing.of(), + @JsonProperty("padding") @ExcludeMissing padding: JsonField = JsonMissing.of(), + @JsonProperty("radius") @ExcludeMissing radius: JsonField = JsonMissing.of(), + @JsonProperty("rotation") @ExcludeMissing rotation: JsonField = JsonMissing.of(), + @JsonProperty("typography") + @ExcludeMissing + typography: JsonField = JsonMissing.of(), + @JsonProperty("width") @ExcludeMissing width: JsonField = JsonMissing.of(), + ) : this( + alpha, + background, + flip, + fontColor, + fontFamily, + fontSize, + innerAlignment, + lineHeight, + padding, + radius, + rotation, + typography, + width, + mutableMapOf(), + ) + + /** + * Specifies the transparency level of the text overlay. Accepts integers from `1` to `9`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun alpha(): Optional = alpha.getOptional("alpha") + + /** + * Specifies the background color of the text overlay. Accepts an RGB hex code, an RGBA code, or + * a color name. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun background(): Optional = background.getOptional("background") + + /** + * Flip the text overlay horizontally, vertically, or both. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun flip(): Optional = flip.getOptional("flip") + + /** + * Specifies the font color of the overlaid text. Accepts an RGB hex code (e.g., `FF0000`), an + * RGBA code (e.g., `FFAABB50`), or a color name. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fontColor(): Optional = fontColor.getOptional("fontColor") + + /** + * Specifies the font family of the overlaid text. Choose from the supported fonts list or use a + * custom font. See + * [Supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list) + * and + * [Custom font](https://imagekit.io/docs/add-overlays-on-images#change-font-family-in-text-overlay). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fontFamily(): Optional = fontFamily.getOptional("fontFamily") + + /** + * Specifies the font size of the overlaid text. Accepts a numeric value or an arithmetic + * expression. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fontSize(): Optional = fontSize.getOptional("fontSize") + + /** + * Specifies the inner alignment of the text when width is more than the text length. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun innerAlignment(): Optional = innerAlignment.getOptional("innerAlignment") + + /** + * Specifies the line height of the text overlay. Accepts integer values representing line + * height in points. It can also accept + * [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations) + * such as `bw_mul_0.2`, or `bh_div_20`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lineHeight(): Optional = lineHeight.getOptional("lineHeight") + + /** + * Specifies the padding around the overlaid text. Can be provided as a single positive integer + * or multiple values separated by underscores (following CSS shorthand order). Arithmetic + * expressions are also accepted. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun padding(): Optional = padding.getOptional("padding") + + /** + * Specifies the corner radius of the text overlay. Set to `max` to achieve a circular or oval + * shape. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun radius(): Optional = radius.getOptional("radius") + + /** + * Specifies the rotation angle of the text overlay. Accepts a numeric value for clockwise + * rotation or a string prefixed with "N" for counter-clockwise rotation. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun rotation(): Optional = rotation.getOptional("rotation") + + /** + * Specifies the typography style of the text. Supported values: + * - Single styles: `b` (bold), `i` (italic), `strikethrough`. + * - Combinations: Any combination separated by underscores, e.g., `b_i`, `b_i_strikethrough`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun typography(): Optional = typography.getOptional("typography") + + /** + * Specifies the maximum width (in pixels) of the overlaid text. The text wraps automatically, + * and arithmetic expressions (e.g., `bw_mul_0.2` or `bh_div_2`) are supported. Useful when used + * in conjunction with the `background`. Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun width(): Optional = width.getOptional("width") + + /** + * Returns the raw JSON value of [alpha]. + * + * Unlike [alpha], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("alpha") @ExcludeMissing fun _alpha(): JsonField = alpha + + /** + * Returns the raw JSON value of [background]. + * + * Unlike [background], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("background") @ExcludeMissing fun _background(): JsonField = background + + /** + * Returns the raw JSON value of [flip]. + * + * Unlike [flip], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("flip") @ExcludeMissing fun _flip(): JsonField = flip + + /** + * Returns the raw JSON value of [fontColor]. + * + * Unlike [fontColor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fontColor") @ExcludeMissing fun _fontColor(): JsonField = fontColor + + /** + * Returns the raw JSON value of [fontFamily]. + * + * Unlike [fontFamily], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fontFamily") @ExcludeMissing fun _fontFamily(): JsonField = fontFamily + + /** + * Returns the raw JSON value of [fontSize]. + * + * Unlike [fontSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fontSize") @ExcludeMissing fun _fontSize(): JsonField = fontSize + + /** + * Returns the raw JSON value of [innerAlignment]. + * + * Unlike [innerAlignment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("innerAlignment") + @ExcludeMissing + fun _innerAlignment(): JsonField = innerAlignment + + /** + * Returns the raw JSON value of [lineHeight]. + * + * Unlike [lineHeight], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lineHeight") + @ExcludeMissing + fun _lineHeight(): JsonField = lineHeight + + /** + * Returns the raw JSON value of [padding]. + * + * Unlike [padding], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("padding") @ExcludeMissing fun _padding(): JsonField = padding + + /** + * Returns the raw JSON value of [radius]. + * + * Unlike [radius], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("radius") @ExcludeMissing fun _radius(): JsonField = radius + + /** + * Returns the raw JSON value of [rotation]. + * + * Unlike [rotation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rotation") @ExcludeMissing fun _rotation(): JsonField = rotation + + /** + * Returns the raw JSON value of [typography]. + * + * Unlike [typography], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("typography") @ExcludeMissing fun _typography(): JsonField = typography + + /** + * Returns the raw JSON value of [width]. + * + * Unlike [width], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("width") @ExcludeMissing fun _width(): JsonField = width + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TextOverlayTransformation]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TextOverlayTransformation]. */ + class Builder internal constructor() { + + private var alpha: JsonField = JsonMissing.of() + private var background: JsonField = JsonMissing.of() + private var flip: JsonField = JsonMissing.of() + private var fontColor: JsonField = JsonMissing.of() + private var fontFamily: JsonField = JsonMissing.of() + private var fontSize: JsonField = JsonMissing.of() + private var innerAlignment: JsonField = JsonMissing.of() + private var lineHeight: JsonField = JsonMissing.of() + private var padding: JsonField = JsonMissing.of() + private var radius: JsonField = JsonMissing.of() + private var rotation: JsonField = JsonMissing.of() + private var typography: JsonField = JsonMissing.of() + private var width: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(textOverlayTransformation: TextOverlayTransformation) = apply { + alpha = textOverlayTransformation.alpha + background = textOverlayTransformation.background + flip = textOverlayTransformation.flip + fontColor = textOverlayTransformation.fontColor + fontFamily = textOverlayTransformation.fontFamily + fontSize = textOverlayTransformation.fontSize + innerAlignment = textOverlayTransformation.innerAlignment + lineHeight = textOverlayTransformation.lineHeight + padding = textOverlayTransformation.padding + radius = textOverlayTransformation.radius + rotation = textOverlayTransformation.rotation + typography = textOverlayTransformation.typography + width = textOverlayTransformation.width + additionalProperties = textOverlayTransformation.additionalProperties.toMutableMap() + } + + /** + * Specifies the transparency level of the text overlay. Accepts integers from `1` to `9`. + */ + fun alpha(alpha: Double) = alpha(JsonField.of(alpha)) + + /** + * Sets [Builder.alpha] to an arbitrary JSON value. + * + * You should usually call [Builder.alpha] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun alpha(alpha: JsonField) = apply { this.alpha = alpha } + + /** + * Specifies the background color of the text overlay. Accepts an RGB hex code, an RGBA + * code, or a color name. + */ + fun background(background: String) = background(JsonField.of(background)) + + /** + * Sets [Builder.background] to an arbitrary JSON value. + * + * You should usually call [Builder.background] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun background(background: JsonField) = apply { this.background = background } + + /** Flip the text overlay horizontally, vertically, or both. */ + fun flip(flip: Flip) = flip(JsonField.of(flip)) + + /** + * Sets [Builder.flip] to an arbitrary JSON value. + * + * You should usually call [Builder.flip] with a well-typed [Flip] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun flip(flip: JsonField) = apply { this.flip = flip } + + /** + * Specifies the font color of the overlaid text. Accepts an RGB hex code (e.g., `FF0000`), + * an RGBA code (e.g., `FFAABB50`), or a color name. + */ + fun fontColor(fontColor: String) = fontColor(JsonField.of(fontColor)) + + /** + * Sets [Builder.fontColor] to an arbitrary JSON value. + * + * You should usually call [Builder.fontColor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun fontColor(fontColor: JsonField) = apply { this.fontColor = fontColor } + + /** + * Specifies the font family of the overlaid text. Choose from the supported fonts list or + * use a custom font. See + * [Supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list) + * and + * [Custom font](https://imagekit.io/docs/add-overlays-on-images#change-font-family-in-text-overlay). + */ + fun fontFamily(fontFamily: String) = fontFamily(JsonField.of(fontFamily)) + + /** + * Sets [Builder.fontFamily] to an arbitrary JSON value. + * + * You should usually call [Builder.fontFamily] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun fontFamily(fontFamily: JsonField) = apply { this.fontFamily = fontFamily } + + /** + * Specifies the font size of the overlaid text. Accepts a numeric value or an arithmetic + * expression. + */ + fun fontSize(fontSize: FontSize) = fontSize(JsonField.of(fontSize)) + + /** + * Sets [Builder.fontSize] to an arbitrary JSON value. + * + * You should usually call [Builder.fontSize] with a well-typed [FontSize] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun fontSize(fontSize: JsonField) = apply { this.fontSize = fontSize } + + /** Alias for calling [fontSize] with `FontSize.ofNumber(number)`. */ + fun fontSize(number: Double) = fontSize(FontSize.ofNumber(number)) + + /** Alias for calling [fontSize] with `FontSize.ofString(string)`. */ + fun fontSize(string: String) = fontSize(FontSize.ofString(string)) + + /** Specifies the inner alignment of the text when width is more than the text length. */ + fun innerAlignment(innerAlignment: InnerAlignment) = + innerAlignment(JsonField.of(innerAlignment)) + + /** + * Sets [Builder.innerAlignment] to an arbitrary JSON value. + * + * You should usually call [Builder.innerAlignment] with a well-typed [InnerAlignment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun innerAlignment(innerAlignment: JsonField) = apply { + this.innerAlignment = innerAlignment + } + + /** + * Specifies the line height of the text overlay. Accepts integer values representing line + * height in points. It can also accept + * [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations) + * such as `bw_mul_0.2`, or `bh_div_20`. + */ + fun lineHeight(lineHeight: LineHeight) = lineHeight(JsonField.of(lineHeight)) + + /** + * Sets [Builder.lineHeight] to an arbitrary JSON value. + * + * You should usually call [Builder.lineHeight] with a well-typed [LineHeight] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lineHeight(lineHeight: JsonField) = apply { this.lineHeight = lineHeight } + + /** Alias for calling [lineHeight] with `LineHeight.ofNumber(number)`. */ + fun lineHeight(number: Double) = lineHeight(LineHeight.ofNumber(number)) + + /** Alias for calling [lineHeight] with `LineHeight.ofString(string)`. */ + fun lineHeight(string: String) = lineHeight(LineHeight.ofString(string)) + + /** + * Specifies the padding around the overlaid text. Can be provided as a single positive + * integer or multiple values separated by underscores (following CSS shorthand order). + * Arithmetic expressions are also accepted. + */ + fun padding(padding: Padding) = padding(JsonField.of(padding)) + + /** + * Sets [Builder.padding] to an arbitrary JSON value. + * + * You should usually call [Builder.padding] with a well-typed [Padding] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun padding(padding: JsonField) = apply { this.padding = padding } + + /** Alias for calling [padding] with `Padding.ofNumber(number)`. */ + fun padding(number: Double) = padding(Padding.ofNumber(number)) + + /** Alias for calling [padding] with `Padding.ofString(string)`. */ + fun padding(string: String) = padding(Padding.ofString(string)) + + /** + * Specifies the corner radius of the text overlay. Set to `max` to achieve a circular or + * oval shape. + */ + fun radius(radius: Radius) = radius(JsonField.of(radius)) + + /** + * Sets [Builder.radius] to an arbitrary JSON value. + * + * You should usually call [Builder.radius] with a well-typed [Radius] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun radius(radius: JsonField) = apply { this.radius = radius } + + /** Alias for calling [radius] with `Radius.ofNumber(number)`. */ + fun radius(number: Double) = radius(Radius.ofNumber(number)) + + /** Alias for calling [radius] with `Radius.ofMax()`. */ + fun radiusMax() = radius(Radius.ofMax()) + + /** + * Specifies the rotation angle of the text overlay. Accepts a numeric value for clockwise + * rotation or a string prefixed with "N" for counter-clockwise rotation. + */ + fun rotation(rotation: Rotation) = rotation(JsonField.of(rotation)) + + /** + * Sets [Builder.rotation] to an arbitrary JSON value. + * + * You should usually call [Builder.rotation] with a well-typed [Rotation] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun rotation(rotation: JsonField) = apply { this.rotation = rotation } + + /** Alias for calling [rotation] with `Rotation.ofNumber(number)`. */ + fun rotation(number: Double) = rotation(Rotation.ofNumber(number)) + + /** Alias for calling [rotation] with `Rotation.ofString(string)`. */ + fun rotation(string: String) = rotation(Rotation.ofString(string)) + + /** + * Specifies the typography style of the text. Supported values: + * - Single styles: `b` (bold), `i` (italic), `strikethrough`. + * - Combinations: Any combination separated by underscores, e.g., `b_i`, + * `b_i_strikethrough`. + */ + fun typography(typography: String) = typography(JsonField.of(typography)) + + /** + * Sets [Builder.typography] to an arbitrary JSON value. + * + * You should usually call [Builder.typography] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun typography(typography: JsonField) = apply { this.typography = typography } + + /** + * Specifies the maximum width (in pixels) of the overlaid text. The text wraps + * automatically, and arithmetic expressions (e.g., `bw_mul_0.2` or `bh_div_2`) are + * supported. Useful when used in conjunction with the `background`. Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + */ + fun width(width: Width) = width(JsonField.of(width)) + + /** + * Sets [Builder.width] to an arbitrary JSON value. + * + * You should usually call [Builder.width] with a well-typed [Width] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun width(width: JsonField) = apply { this.width = width } + + /** Alias for calling [width] with `Width.ofNumber(number)`. */ + fun width(number: Double) = width(Width.ofNumber(number)) + + /** Alias for calling [width] with `Width.ofString(string)`. */ + fun width(string: String) = width(Width.ofString(string)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TextOverlayTransformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TextOverlayTransformation = + TextOverlayTransformation( + alpha, + background, + flip, + fontColor, + fontFamily, + fontSize, + innerAlignment, + lineHeight, + padding, + radius, + rotation, + typography, + width, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TextOverlayTransformation = apply { + if (validated) { + return@apply + } + + alpha() + background() + flip().ifPresent { it.validate() } + fontColor() + fontFamily() + fontSize().ifPresent { it.validate() } + innerAlignment().ifPresent { it.validate() } + lineHeight().ifPresent { it.validate() } + padding().ifPresent { it.validate() } + radius().ifPresent { it.validate() } + rotation().ifPresent { it.validate() } + typography() + width().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (alpha.asKnown().isPresent) 1 else 0) + + (if (background.asKnown().isPresent) 1 else 0) + + (flip.asKnown().getOrNull()?.validity() ?: 0) + + (if (fontColor.asKnown().isPresent) 1 else 0) + + (if (fontFamily.asKnown().isPresent) 1 else 0) + + (fontSize.asKnown().getOrNull()?.validity() ?: 0) + + (innerAlignment.asKnown().getOrNull()?.validity() ?: 0) + + (lineHeight.asKnown().getOrNull()?.validity() ?: 0) + + (padding.asKnown().getOrNull()?.validity() ?: 0) + + (radius.asKnown().getOrNull()?.validity() ?: 0) + + (rotation.asKnown().getOrNull()?.validity() ?: 0) + + (if (typography.asKnown().isPresent) 1 else 0) + + (width.asKnown().getOrNull()?.validity() ?: 0) + + /** Flip the text overlay horizontally, vertically, or both. */ + class Flip @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val H = of("h") + + @JvmField val V = of("v") + + @JvmField val H_V = of("h_v") + + @JvmField val V_H = of("v_h") + + @JvmStatic fun of(value: String) = Flip(JsonField.of(value)) + } + + /** An enum containing [Flip]'s known values. */ + enum class Known { + H, + V, + H_V, + V_H, + } + + /** + * An enum containing [Flip]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Flip] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + H, + V, + H_V, + V_H, + /** An enum member indicating that [Flip] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + H -> Value.H + V -> Value.V + H_V -> Value.H_V + V_H -> Value.V_H + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + H -> Known.H + V -> Known.V + H_V -> Known.H_V + V_H -> Known.V_H + else -> throw ImageKitInvalidDataException("Unknown Flip: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Flip = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Flip && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Specifies the font size of the overlaid text. Accepts a numeric value or an arithmetic + * expression. + */ + @JsonDeserialize(using = FontSize.Deserializer::class) + @JsonSerialize(using = FontSize.Serializer::class) + class FontSize + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): FontSize = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FontSize && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "FontSize{number=$number}" + string != null -> "FontSize{string=$string}" + _json != null -> "FontSize{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FontSize") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = FontSize(number = number) + + @JvmStatic fun ofString(string: String) = FontSize(string = string) + } + + /** + * An interface that defines how to map each variant of [FontSize] to a value of type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [FontSize] to a value of type [T]. + * + * An instance of [FontSize] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown FontSize: $json") + } + } + + internal class Deserializer : BaseDeserializer(FontSize::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): FontSize { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + FontSize(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + FontSize(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> FontSize(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(FontSize::class) { + + override fun serialize( + value: FontSize, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FontSize") + } + } + } + } + + /** Specifies the inner alignment of the text when width is more than the text length. */ + class InnerAlignment @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LEFT = of("left") + + @JvmField val RIGHT = of("right") + + @JvmField val CENTER = of("center") + + @JvmStatic fun of(value: String) = InnerAlignment(JsonField.of(value)) + } + + /** An enum containing [InnerAlignment]'s known values. */ + enum class Known { + LEFT, + RIGHT, + CENTER, + } + + /** + * An enum containing [InnerAlignment]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [InnerAlignment] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LEFT, + RIGHT, + CENTER, + /** + * An enum member indicating that [InnerAlignment] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LEFT -> Value.LEFT + RIGHT -> Value.RIGHT + CENTER -> Value.CENTER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LEFT -> Known.LEFT + RIGHT -> Known.RIGHT + CENTER -> Known.CENTER + else -> throw ImageKitInvalidDataException("Unknown InnerAlignment: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): InnerAlignment = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InnerAlignment && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Specifies the line height of the text overlay. Accepts integer values representing line + * height in points. It can also accept + * [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations) + * such as `bw_mul_0.2`, or `bh_div_20`. + */ + @JsonDeserialize(using = LineHeight.Deserializer::class) + @JsonSerialize(using = LineHeight.Serializer::class) + class LineHeight + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): LineHeight = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LineHeight && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "LineHeight{number=$number}" + string != null -> "LineHeight{string=$string}" + _json != null -> "LineHeight{_unknown=$_json}" + else -> throw IllegalStateException("Invalid LineHeight") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = LineHeight(number = number) + + @JvmStatic fun ofString(string: String) = LineHeight(string = string) + } + + /** + * An interface that defines how to map each variant of [LineHeight] to a value of type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [LineHeight] to a value of type [T]. + * + * An instance of [LineHeight] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown LineHeight: $json") + } + } + + internal class Deserializer : BaseDeserializer(LineHeight::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): LineHeight { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + LineHeight(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + LineHeight(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> LineHeight(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(LineHeight::class) { + + override fun serialize( + value: LineHeight, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid LineHeight") + } + } + } + } + + /** + * Specifies the padding around the overlaid text. Can be provided as a single positive integer + * or multiple values separated by underscores (following CSS shorthand order). Arithmetic + * expressions are also accepted. + */ + @JsonDeserialize(using = Padding.Deserializer::class) + @JsonSerialize(using = Padding.Serializer::class) + class Padding + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Padding = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Padding && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "Padding{number=$number}" + string != null -> "Padding{string=$string}" + _json != null -> "Padding{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Padding") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Padding(number = number) + + @JvmStatic fun ofString(string: String) = Padding(string = string) + } + + /** + * An interface that defines how to map each variant of [Padding] to a value of type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Padding] to a value of type [T]. + * + * An instance of [Padding] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Padding: $json") + } + } + + internal class Deserializer : BaseDeserializer(Padding::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Padding { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Padding(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Padding(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Padding(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Padding::class) { + + override fun serialize( + value: Padding, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Padding") + } + } + } + } + + /** + * Specifies the corner radius of the text overlay. Set to `max` to achieve a circular or oval + * shape. + */ + @JsonDeserialize(using = Radius.Deserializer::class) + @JsonSerialize(using = Radius.Serializer::class) + class Radius + private constructor( + private val number: Double? = null, + private val max: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun max(): Optional = Optional.ofNullable(max) + + fun isNumber(): Boolean = number != null + + fun isMax(): Boolean = max != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asMax(): JsonValue = max.getOrThrow("max") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + max != null -> visitor.visitMax(max) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Radius = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitMax(max: JsonValue) { + max.let { + if (it != JsonValue.from("max")) { + throw ImageKitInvalidDataException("'max' is invalid, received $it") + } + } + } + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitMax(max: JsonValue) = + max.let { if (it == JsonValue.from("max")) 1 else 0 } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Radius && number == other.number && max == other.max + } + + override fun hashCode(): Int = Objects.hash(number, max) + + override fun toString(): String = + when { + number != null -> "Radius{number=$number}" + max != null -> "Radius{max=$max}" + _json != null -> "Radius{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Radius") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Radius(number = number) + + @JvmStatic fun ofMax() = Radius(max = JsonValue.from("max")) + } + + /** An interface that defines how to map each variant of [Radius] to a value of type [T]. */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitMax(max: JsonValue): T + + /** + * Maps an unknown variant of [Radius] to a value of type [T]. + * + * An instance of [Radius] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Radius: $json") + } + } + + internal class Deserializer : BaseDeserializer(Radius::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Radius { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Radius(max = it, _json = json) } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef())?.let { + Radius(number = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Radius(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Radius::class) { + + override fun serialize( + value: Radius, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.max != null -> generator.writeObject(value.max) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Radius") + } + } + } + } + + /** + * Specifies the rotation angle of the text overlay. Accepts a numeric value for clockwise + * rotation or a string prefixed with "N" for counter-clockwise rotation. + */ + @JsonDeserialize(using = Rotation.Deserializer::class) + @JsonSerialize(using = Rotation.Serializer::class) + class Rotation + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Rotation = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Rotation && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "Rotation{number=$number}" + string != null -> "Rotation{string=$string}" + _json != null -> "Rotation{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Rotation") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Rotation(number = number) + + @JvmStatic fun ofString(string: String) = Rotation(string = string) + } + + /** + * An interface that defines how to map each variant of [Rotation] to a value of type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Rotation] to a value of type [T]. + * + * An instance of [Rotation] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Rotation: $json") + } + } + + internal class Deserializer : BaseDeserializer(Rotation::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Rotation { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Rotation(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Rotation(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Rotation(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Rotation::class) { + + override fun serialize( + value: Rotation, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Rotation") + } + } + } + } + + /** + * Specifies the maximum width (in pixels) of the overlaid text. The text wraps automatically, + * and arithmetic expressions (e.g., `bw_mul_0.2` or `bh_div_2`) are supported. Useful when used + * in conjunction with the `background`. Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + */ + @JsonDeserialize(using = Width.Deserializer::class) + @JsonSerialize(using = Width.Serializer::class) + class Width + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Width = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Width && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "Width{number=$number}" + string != null -> "Width{string=$string}" + _json != null -> "Width{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Width") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Width(number = number) + + @JvmStatic fun ofString(string: String) = Width(string = string) + } + + /** An interface that defines how to map each variant of [Width] to a value of type [T]. */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Width] to a value of type [T]. + * + * An instance of [Width] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Width: $json") + } + } + + internal class Deserializer : BaseDeserializer(Width::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Width { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Width(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Width(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Width(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Width::class) { + + override fun serialize( + value: Width, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Width") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TextOverlayTransformation && + alpha == other.alpha && + background == other.background && + flip == other.flip && + fontColor == other.fontColor && + fontFamily == other.fontFamily && + fontSize == other.fontSize && + innerAlignment == other.innerAlignment && + lineHeight == other.lineHeight && + padding == other.padding && + radius == other.radius && + rotation == other.rotation && + typography == other.typography && + width == other.width && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + alpha, + background, + flip, + fontColor, + fontFamily, + fontSize, + innerAlignment, + lineHeight, + padding, + radius, + rotation, + typography, + width, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TextOverlayTransformation{alpha=$alpha, background=$background, flip=$flip, fontColor=$fontColor, fontFamily=$fontFamily, fontSize=$fontSize, innerAlignment=$innerAlignment, lineHeight=$lineHeight, padding=$padding, radius=$radius, rotation=$rotation, typography=$typography, width=$width, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt new file mode 100644 index 00000000..ee1ca86e --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt @@ -0,0 +1,7830 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.allMaxBy +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * The SDK provides easy-to-use names for transformations. These names are converted to the + * corresponding transformation string before being added to the URL. SDKs are updated regularly to + * support new transformations. If you want to use a transformation that is not supported by the + * SDK, You can use the `raw` parameter to pass the transformation string directly. See the + * [Transformations documentation](https://imagekit.io/docs/transformations). + */ +class Transformation +private constructor( + private val aiChangeBackground: JsonField, + private val aiDropShadow: JsonField, + private val aiEdit: JsonField, + private val aiRemoveBackground: JsonField, + private val aiRemoveBackgroundExternal: JsonField, + private val aiRetouch: JsonField, + private val aiUpscale: JsonField, + private val aiVariation: JsonField, + private val aspectRatio: JsonField, + private val audioCodec: JsonField, + private val background: JsonField, + private val blur: JsonField, + private val border: JsonField, + private val colorProfile: JsonField, + private val contrastStretch: JsonField, + private val crop: JsonField, + private val cropMode: JsonField, + private val defaultImage: JsonField, + private val dpr: JsonField, + private val duration: JsonField, + private val endOffset: JsonField, + private val flip: JsonField, + private val focus: JsonField, + private val format: JsonField, + private val gradient: JsonField, + private val grayscale: JsonField, + private val height: JsonField, + private val lossless: JsonField, + private val metadata: JsonField, + private val named: JsonField, + private val opacity: JsonField, + private val original: JsonField, + private val overlay: JsonField, + private val page: JsonField, + private val progressive: JsonField, + private val quality: JsonField, + private val radius: JsonField, + private val raw: JsonField, + private val rotation: JsonField, + private val shadow: JsonField, + private val sharpen: JsonField, + private val startOffset: JsonField, + private val streamingResolutions: JsonField>, + private val trim: JsonField, + private val unsharpMask: JsonField, + private val videoCodec: JsonField, + private val width: JsonField, + private val x: JsonField, + private val xCenter: JsonField, + private val y: JsonField, + private val yCenter: JsonField, + private val zoom: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("aiChangeBackground") + @ExcludeMissing + aiChangeBackground: JsonField = JsonMissing.of(), + @JsonProperty("aiDropShadow") + @ExcludeMissing + aiDropShadow: JsonField = JsonMissing.of(), + @JsonProperty("aiEdit") @ExcludeMissing aiEdit: JsonField = JsonMissing.of(), + @JsonProperty("aiRemoveBackground") + @ExcludeMissing + aiRemoveBackground: JsonField = JsonMissing.of(), + @JsonProperty("aiRemoveBackgroundExternal") + @ExcludeMissing + aiRemoveBackgroundExternal: JsonField = JsonMissing.of(), + @JsonProperty("aiRetouch") + @ExcludeMissing + aiRetouch: JsonField = JsonMissing.of(), + @JsonProperty("aiUpscale") + @ExcludeMissing + aiUpscale: JsonField = JsonMissing.of(), + @JsonProperty("aiVariation") + @ExcludeMissing + aiVariation: JsonField = JsonMissing.of(), + @JsonProperty("aspectRatio") + @ExcludeMissing + aspectRatio: JsonField = JsonMissing.of(), + @JsonProperty("audioCodec") + @ExcludeMissing + audioCodec: JsonField = JsonMissing.of(), + @JsonProperty("background") + @ExcludeMissing + background: JsonField = JsonMissing.of(), + @JsonProperty("blur") @ExcludeMissing blur: JsonField = JsonMissing.of(), + @JsonProperty("border") @ExcludeMissing border: JsonField = JsonMissing.of(), + @JsonProperty("colorProfile") + @ExcludeMissing + colorProfile: JsonField = JsonMissing.of(), + @JsonProperty("contrastStretch") + @ExcludeMissing + contrastStretch: JsonField = JsonMissing.of(), + @JsonProperty("crop") @ExcludeMissing crop: JsonField = JsonMissing.of(), + @JsonProperty("cropMode") @ExcludeMissing cropMode: JsonField = JsonMissing.of(), + @JsonProperty("defaultImage") + @ExcludeMissing + defaultImage: JsonField = JsonMissing.of(), + @JsonProperty("dpr") @ExcludeMissing dpr: JsonField = JsonMissing.of(), + @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), + @JsonProperty("endOffset") + @ExcludeMissing + endOffset: JsonField = JsonMissing.of(), + @JsonProperty("flip") @ExcludeMissing flip: JsonField = JsonMissing.of(), + @JsonProperty("focus") @ExcludeMissing focus: JsonField = JsonMissing.of(), + @JsonProperty("format") @ExcludeMissing format: JsonField = JsonMissing.of(), + @JsonProperty("gradient") @ExcludeMissing gradient: JsonField = JsonMissing.of(), + @JsonProperty("grayscale") + @ExcludeMissing + grayscale: JsonField = JsonMissing.of(), + @JsonProperty("height") @ExcludeMissing height: JsonField = JsonMissing.of(), + @JsonProperty("lossless") @ExcludeMissing lossless: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("named") @ExcludeMissing named: JsonField = JsonMissing.of(), + @JsonProperty("opacity") @ExcludeMissing opacity: JsonField = JsonMissing.of(), + @JsonProperty("original") @ExcludeMissing original: JsonField = JsonMissing.of(), + @JsonProperty("overlay") @ExcludeMissing overlay: JsonField = JsonMissing.of(), + @JsonProperty("page") @ExcludeMissing page: JsonField = JsonMissing.of(), + @JsonProperty("progressive") + @ExcludeMissing + progressive: JsonField = JsonMissing.of(), + @JsonProperty("quality") @ExcludeMissing quality: JsonField = JsonMissing.of(), + @JsonProperty("radius") @ExcludeMissing radius: JsonField = JsonMissing.of(), + @JsonProperty("raw") @ExcludeMissing raw: JsonField = JsonMissing.of(), + @JsonProperty("rotation") @ExcludeMissing rotation: JsonField = JsonMissing.of(), + @JsonProperty("shadow") @ExcludeMissing shadow: JsonField = JsonMissing.of(), + @JsonProperty("sharpen") @ExcludeMissing sharpen: JsonField = JsonMissing.of(), + @JsonProperty("startOffset") + @ExcludeMissing + startOffset: JsonField = JsonMissing.of(), + @JsonProperty("streamingResolutions") + @ExcludeMissing + streamingResolutions: JsonField> = JsonMissing.of(), + @JsonProperty("trim") @ExcludeMissing trim: JsonField = JsonMissing.of(), + @JsonProperty("unsharpMask") + @ExcludeMissing + unsharpMask: JsonField = JsonMissing.of(), + @JsonProperty("videoCodec") + @ExcludeMissing + videoCodec: JsonField = JsonMissing.of(), + @JsonProperty("width") @ExcludeMissing width: JsonField = JsonMissing.of(), + @JsonProperty("x") @ExcludeMissing x: JsonField = JsonMissing.of(), + @JsonProperty("xCenter") @ExcludeMissing xCenter: JsonField = JsonMissing.of(), + @JsonProperty("y") @ExcludeMissing y: JsonField = JsonMissing.of(), + @JsonProperty("yCenter") @ExcludeMissing yCenter: JsonField = JsonMissing.of(), + @JsonProperty("zoom") @ExcludeMissing zoom: JsonField = JsonMissing.of(), + ) : this( + aiChangeBackground, + aiDropShadow, + aiEdit, + aiRemoveBackground, + aiRemoveBackgroundExternal, + aiRetouch, + aiUpscale, + aiVariation, + aspectRatio, + audioCodec, + background, + blur, + border, + colorProfile, + contrastStretch, + crop, + cropMode, + defaultImage, + dpr, + duration, + endOffset, + flip, + focus, + format, + gradient, + grayscale, + height, + lossless, + metadata, + named, + opacity, + original, + overlay, + page, + progressive, + quality, + radius, + raw, + rotation, + shadow, + sharpen, + startOffset, + streamingResolutions, + trim, + unsharpMask, + videoCodec, + width, + x, + xCenter, + y, + yCenter, + zoom, + mutableMapOf(), + ) + + /** + * Uses AI to change the background. Provide a text prompt or a base64-encoded prompt, e.g., + * `prompt-snow road` or `prompte-[urlencoded_base64_encoded_text]`. Not supported inside + * overlay. See + * [AI Change Background](https://imagekit.io/docs/ai-transformations#change-background-e-changebg). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun aiChangeBackground(): Optional = + aiChangeBackground.getOptional("aiChangeBackground") + + /** + * Adds an AI-based drop shadow around a foreground object on a transparent or removed + * background. Optionally, control the direction, elevation, and saturation of the light source + * (e.g., `az-45` to change light direction). Pass `true` for the default drop shadow, or + * provide a string for a custom drop shadow. Supported inside overlay. See + * [AI Drop Shadow](https://imagekit.io/docs/ai-transformations#ai-drop-shadow-e-dropshadow). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun aiDropShadow(): Optional = aiDropShadow.getOptional("aiDropShadow") + + /** + * Uses AI to edit images based on a text prompt. Provide a text prompt or a base64-encoded + * prompt, e.g., `prompt-snow road` or `prompte-[urlencoded_base64_encoded_text]`. Not supported + * inside overlay. See [AI Edit](https://imagekit.io/docs/ai-transformations#edit-image-e-edit). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun aiEdit(): Optional = aiEdit.getOptional("aiEdit") + + /** + * Applies ImageKit's in-house background removal. Supported inside overlay. See + * [AI Background Removal](https://imagekit.io/docs/ai-transformations#imagekit-background-removal-e-bgremove). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun aiRemoveBackground(): Optional = + aiRemoveBackground.getOptional("aiRemoveBackground") + + /** + * Uses third-party background removal. Note: It is recommended to use aiRemoveBackground, + * ImageKit's in-house solution, which is more cost-effective. Supported inside overlay. See + * [External Background Removal](https://imagekit.io/docs/ai-transformations#background-removal-e-removedotbg). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun aiRemoveBackgroundExternal(): Optional = + aiRemoveBackgroundExternal.getOptional("aiRemoveBackgroundExternal") + + /** + * Performs AI-based retouching to improve faces or product shots. Not supported inside overlay. + * See [AI Retouch](https://imagekit.io/docs/ai-transformations#retouch-e-retouch). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun aiRetouch(): Optional = aiRetouch.getOptional("aiRetouch") + + /** + * Upscales images beyond their original dimensions using AI. Not supported inside overlay. See + * [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun aiUpscale(): Optional = aiUpscale.getOptional("aiUpscale") + + /** + * Generates a variation of an image using AI. This produces a new image with slight variations + * from the original, such as changes in color, texture, and other visual elements, while + * preserving the structure and essence of the original image. Not supported inside overlay. See + * [AI Generate Variations](https://imagekit.io/docs/ai-transformations#generate-variations-of-an-image-e-genvar). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun aiVariation(): Optional = aiVariation.getOptional("aiVariation") + + /** + * Specifies the aspect ratio for the output, e.g., "ar-4-3". Typically used with either width + * or height (but not both). For example: aspectRatio = `4:3`, `4_3`, or an expression like + * `iar_div_2`. See + * [Image resize and crop – Aspect ratio](https://imagekit.io/docs/image-resize-and-crop#aspect-ratio---ar). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun aspectRatio(): Optional = aspectRatio.getOptional("aspectRatio") + + /** + * Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See + * [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun audioCodec(): Optional = audioCodec.getOptional("audioCodec") + + /** + * Specifies the background to be used in conjunction with certain cropping strategies when + * resizing an image. + * - A solid color: e.g., `red`, `F3F3F3`, `AAFF0010`. See + * [Solid color background](https://imagekit.io/docs/effects-and-enhancements#solid-color-background). + * - A blurred background: e.g., `blurred`, `blurred_25_N15`, etc. See + * [Blurred background](https://imagekit.io/docs/effects-and-enhancements#blurred-background). + * - Expand the image boundaries using generative fill: `genfill`. Not supported inside overlay. + * Optionally, control the background scene by passing a text prompt: + * `genfill[:-prompt-${text}]` or `genfill[:-prompte-${urlencoded_base64_encoded_text}]`. See + * [Generative fill background](https://imagekit.io/docs/ai-transformations#generative-fill-bg-genfill). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun background(): Optional = background.getOptional("background") + + /** + * Specifies the Gaussian blur level. Accepts an integer value between 1 and 100, or an + * expression like `bl-10`. See + * [Blur](https://imagekit.io/docs/effects-and-enhancements#blur---bl). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun blur(): Optional = blur.getOptional("blur") + + /** + * Adds a border to the output media. Accepts a string in the format `_` + * (e.g., `5_FFF000` for a 5px yellow border), or an expression like `ih_div_20_FF00FF`. See + * [Border](https://imagekit.io/docs/effects-and-enhancements#border---b). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun border(): Optional = border.getOptional("border") + + /** + * Indicates whether the output image should retain the original color profile. See + * [Color profile](https://imagekit.io/docs/image-optimization#color-profile---cp). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun colorProfile(): Optional = colorProfile.getOptional("colorProfile") + + /** + * Automatically enhances the contrast of an image (contrast stretch). See + * [Contrast Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun contrastStretch(): Optional = + contrastStretch.getOptional("contrastStretch") + + /** + * Crop modes for image resizing. See + * [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun crop(): Optional = crop.getOptional("crop") + + /** + * Additional crop modes for image resizing. See + * [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cropMode(): Optional = cropMode.getOptional("cropMode") + + /** + * Specifies a fallback image if the resource is not found, e.g., a URL or file path. See + * [Default image](https://imagekit.io/docs/image-transformation#default-image---di). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun defaultImage(): Optional = defaultImage.getOptional("defaultImage") + + /** + * Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio (DPR) + * calculation. See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dpr(): Optional = dpr.getOptional("dpr") + + /** + * Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. Typically used + * with startOffset to indicate the length from the start offset. Arithmetic expressions are + * supported. See [Trim videos – Duration](https://imagekit.io/docs/trim-videos#duration---du). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun duration(): Optional = duration.getOptional("duration") + + /** + * Specifies the end offset (in seconds) for trimming videos, e.g., `5` or `10.5`. Typically + * used with startOffset to define a time window. Arithmetic expressions are supported. See + * [Trim videos – End offset](https://imagekit.io/docs/trim-videos#end-offset---eo). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endOffset(): Optional = endOffset.getOptional("endOffset") + + /** + * Flips or mirrors an image either horizontally, vertically, or both. Acceptable values: `h` + * (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or `v_h`. See + * [Flip](https://imagekit.io/docs/effects-and-enhancements#flip---fl). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun flip(): Optional = flip.getOptional("flip") + + /** + * Refines padding and cropping behavior for pad resize, maintain ratio, and extract crop modes. + * Supports manual positions and coordinate-based focus. With AI-based cropping, you can + * automatically keep key subjects in frame—such as faces or detected objects (e.g., `fo-face`, + * `fo-person`, `fo-car`)— while resizing. + * - See [Focus](https://imagekit.io/docs/image-resize-and-crop#focus---fo). + * - [Object aware + * cropping](https://imagekit.io/docs/image-resize-and-crop#object-aware-cropping---fo-object-name) + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun focus(): Optional = focus.getOptional("focus") + + /** + * Specifies the output format for images or videos, e.g., `jpg`, `png`, `webp`, `mp4`, or + * `auto`. You can also pass `orig` for images to return the original format. ImageKit + * automatically delivers images and videos in the optimal format based on device support unless + * overridden by the dashboard settings or the format parameter. See + * [Image format](https://imagekit.io/docs/image-optimization#format---f) and + * [Video format](https://imagekit.io/docs/video-optimization#format---f). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun format(): Optional = format.getOptional("format") + + /** + * Creates a linear gradient with two colors. Pass `true` for a default gradient, or provide a + * string for a custom gradient. See + * [Gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun gradient(): Optional = gradient.getOptional("gradient") + + /** + * Enables a grayscale effect for images. See + * [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun grayscale(): Optional = grayscale.getOptional("grayscale") + + /** + * Specifies the height of the output. If a value between 0 and 1 is provided, it is treated as + * a percentage (e.g., `0.5` represents 50% of the original height). You can also supply + * arithmetic expressions (e.g., `ih_mul_0.5`). Height transformation – + * [Images](https://imagekit.io/docs/image-resize-and-crop#height---h) · + * [Videos](https://imagekit.io/docs/video-resize-and-crop#height---h) + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun height(): Optional = height.getOptional("height") + + /** + * Specifies whether the output image (in JPEG or PNG) should be compressed losslessly. See + * [Lossless compression](https://imagekit.io/docs/image-optimization#lossless-webp-and-png---lo). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lossless(): Optional = lossless.getOptional("lossless") + + /** + * By default, ImageKit removes all metadata during automatic image compression. Set this to + * true to preserve metadata. See + * [Image metadata](https://imagekit.io/docs/image-optimization#image-metadata---md). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Named transformation reference. See + * [Named transformations](https://imagekit.io/docs/transformations#named-transformations). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun named(): Optional = named.getOptional("named") + + /** + * Specifies the opacity level of the output image. See + * [Opacity](https://imagekit.io/docs/effects-and-enhancements#opacity---o). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun opacity(): Optional = opacity.getOptional("opacity") + + /** + * If set to true, serves the original file without applying any transformations. See + * [Deliver original file as-is](https://imagekit.io/docs/core-delivery-features#deliver-original-file-as-is---orig-true). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun original(): Optional = original.getOptional("original") + + /** + * Specifies an overlay to be applied on the parent image or video. ImageKit supports overlays + * including images, text, videos, subtitles, and solid colors. See + * [Overlay using layers](https://imagekit.io/docs/transformations#overlay-using-layers). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun overlay(): Optional = overlay.getOptional("overlay") + + /** + * Extracts a specific page or frame from multi-page or layered files (PDF, PSD, AI). For + * example, specify by number (e.g., `2`), a range (e.g., `3-4` for the 2nd and 3rd layers), or + * by name (e.g., `name-layer-4` for a PSD layer). See + * [Thumbnail extraction](https://imagekit.io/docs/vector-and-animated-images#get-thumbnail-from-psd-pdf-ai-eps-and-animated-files). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun page(): Optional = page.getOptional("page") + + /** + * Specifies whether the output JPEG image should be rendered progressively. Progressive loading + * begins with a low-quality, pixelated version of the full image, which gradually improves to + * provide a faster perceived load time. See + * [Progressive images](https://imagekit.io/docs/image-optimization#progressive-image---pr). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun progressive(): Optional = progressive.getOptional("progressive") + + /** + * Specifies the quality of the output image for lossy formats such as JPEG, WebP, and AVIF. A + * higher quality value results in a larger file size with better quality, while a lower value + * produces a smaller file size with reduced quality. See + * [Quality](https://imagekit.io/docs/image-optimization#quality---q). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun quality(): Optional = quality.getOptional("quality") + + /** + * Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular or oval + * shape. See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun radius(): Optional = radius.getOptional("radius") + + /** + * Pass any transformation not directly supported by the SDK. This transformation string is + * appended to the URL as provided. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun raw(): Optional = raw.getOptional("raw") + + /** + * Specifies the rotation angle in degrees. Positive values rotate the image clockwise; you can + * also use, for example, `N40` for counterclockwise rotation or `auto` to use the orientation + * specified in the image's EXIF data. For videos, only the following values are supported: 0, + * 90, 180, 270, or 360. See + * [Rotate](https://imagekit.io/docs/effects-and-enhancements#rotate---rt). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun rotation(): Optional = rotation.getOptional("rotation") + + /** + * Adds a shadow beneath solid objects in an image with a transparent background. For AI-based + * drop shadows, refer to aiDropShadow. Pass `true` for a default shadow, or provide a string + * for a custom shadow. See + * [Shadow](https://imagekit.io/docs/effects-and-enhancements#shadow---e-shadow). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun shadow(): Optional = shadow.getOptional("shadow") + + /** + * Sharpens the input image, highlighting edges and finer details. Pass `true` for default + * sharpening, or provide a numeric value for custom sharpening. See + * [Sharpen](https://imagekit.io/docs/effects-and-enhancements#sharpen---e-sharpen). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sharpen(): Optional = sharpen.getOptional("sharpen") + + /** + * Specifies the start offset (in seconds) for trimming videos, e.g., `5` or `10.5`. Arithmetic + * expressions are also supported. See + * [Trim videos – Start offset](https://imagekit.io/docs/trim-videos#start-offset---so). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun startOffset(): Optional = startOffset.getOptional("startOffset") + + /** + * An array of resolutions for adaptive bitrate streaming, e.g., + * [`240`, `360`, `480`, `720`, `1080`]. See + * [Adaptive Bitrate Streaming](https://imagekit.io/docs/adaptive-bitrate-streaming). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun streamingResolutions(): Optional> = + streamingResolutions.getOptional("streamingResolutions") + + /** + * Useful for images with a solid or nearly solid background and a central object. This + * parameter trims the background, leaving only the central object in the output image. See + * [Trim edges](https://imagekit.io/docs/effects-and-enhancements#trim-edges---t). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun trim(): Optional = trim.getOptional("trim") + + /** + * Applies Unsharp Masking (USM), an image sharpening technique. Pass `true` for a default + * unsharp mask, or provide a string for a custom unsharp mask. See + * [Unsharp Mask](https://imagekit.io/docs/effects-and-enhancements#unsharp-mask---e-usm). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun unsharpMask(): Optional = unsharpMask.getOptional("unsharpMask") + + /** + * Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See + * [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun videoCodec(): Optional = videoCodec.getOptional("videoCodec") + + /** + * Specifies the width of the output. If a value between 0 and 1 is provided, it is treated as a + * percentage (e.g., `0.4` represents 40% of the original width). You can also supply arithmetic + * expressions (e.g., `iw_div_2`). Width transformation – + * [Images](https://imagekit.io/docs/image-resize-and-crop#width---w) · + * [Videos](https://imagekit.io/docs/video-resize-and-crop#width---w) + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun width(): Optional = width.getOptional("width") + + /** + * Focus using cropped image coordinates - X coordinate. See + * [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun x(): Optional = x.getOptional("x") + + /** + * Focus using cropped image coordinates - X center coordinate. See + * [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun xCenter(): Optional = xCenter.getOptional("xCenter") + + /** + * Focus using cropped image coordinates - Y coordinate. See + * [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun y(): Optional = y.getOptional("y") + + /** + * Focus using cropped image coordinates - Y center coordinate. See + * [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun yCenter(): Optional = yCenter.getOptional("yCenter") + + /** + * Accepts a numeric value that determines how much to zoom in or out of the cropped area. It + * should be used in conjunction with fo-face or fo-. See + * [Zoom](https://imagekit.io/docs/image-resize-and-crop#zoom---z). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun zoom(): Optional = zoom.getOptional("zoom") + + /** + * Returns the raw JSON value of [aiChangeBackground]. + * + * Unlike [aiChangeBackground], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("aiChangeBackground") + @ExcludeMissing + fun _aiChangeBackground(): JsonField = aiChangeBackground + + /** + * Returns the raw JSON value of [aiDropShadow]. + * + * Unlike [aiDropShadow], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("aiDropShadow") + @ExcludeMissing + fun _aiDropShadow(): JsonField = aiDropShadow + + /** + * Returns the raw JSON value of [aiEdit]. + * + * Unlike [aiEdit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("aiEdit") @ExcludeMissing fun _aiEdit(): JsonField = aiEdit + + /** + * Returns the raw JSON value of [aiRemoveBackground]. + * + * Unlike [aiRemoveBackground], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("aiRemoveBackground") + @ExcludeMissing + fun _aiRemoveBackground(): JsonField = aiRemoveBackground + + /** + * Returns the raw JSON value of [aiRemoveBackgroundExternal]. + * + * Unlike [aiRemoveBackgroundExternal], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("aiRemoveBackgroundExternal") + @ExcludeMissing + fun _aiRemoveBackgroundExternal(): JsonField = + aiRemoveBackgroundExternal + + /** + * Returns the raw JSON value of [aiRetouch]. + * + * Unlike [aiRetouch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("aiRetouch") @ExcludeMissing fun _aiRetouch(): JsonField = aiRetouch + + /** + * Returns the raw JSON value of [aiUpscale]. + * + * Unlike [aiUpscale], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("aiUpscale") @ExcludeMissing fun _aiUpscale(): JsonField = aiUpscale + + /** + * Returns the raw JSON value of [aiVariation]. + * + * Unlike [aiVariation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("aiVariation") + @ExcludeMissing + fun _aiVariation(): JsonField = aiVariation + + /** + * Returns the raw JSON value of [aspectRatio]. + * + * Unlike [aspectRatio], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("aspectRatio") + @ExcludeMissing + fun _aspectRatio(): JsonField = aspectRatio + + /** + * Returns the raw JSON value of [audioCodec]. + * + * Unlike [audioCodec], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("audioCodec") + @ExcludeMissing + fun _audioCodec(): JsonField = audioCodec + + /** + * Returns the raw JSON value of [background]. + * + * Unlike [background], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("background") @ExcludeMissing fun _background(): JsonField = background + + /** + * Returns the raw JSON value of [blur]. + * + * Unlike [blur], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("blur") @ExcludeMissing fun _blur(): JsonField = blur + + /** + * Returns the raw JSON value of [border]. + * + * Unlike [border], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("border") @ExcludeMissing fun _border(): JsonField = border + + /** + * Returns the raw JSON value of [colorProfile]. + * + * Unlike [colorProfile], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("colorProfile") + @ExcludeMissing + fun _colorProfile(): JsonField = colorProfile + + /** + * Returns the raw JSON value of [contrastStretch]. + * + * Unlike [contrastStretch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("contrastStretch") + @ExcludeMissing + fun _contrastStretch(): JsonField = contrastStretch + + /** + * Returns the raw JSON value of [crop]. + * + * Unlike [crop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("crop") @ExcludeMissing fun _crop(): JsonField = crop + + /** + * Returns the raw JSON value of [cropMode]. + * + * Unlike [cropMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cropMode") @ExcludeMissing fun _cropMode(): JsonField = cropMode + + /** + * Returns the raw JSON value of [defaultImage]. + * + * Unlike [defaultImage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("defaultImage") + @ExcludeMissing + fun _defaultImage(): JsonField = defaultImage + + /** + * Returns the raw JSON value of [dpr]. + * + * Unlike [dpr], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dpr") @ExcludeMissing fun _dpr(): JsonField = dpr + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [endOffset]. + * + * Unlike [endOffset], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("endOffset") @ExcludeMissing fun _endOffset(): JsonField = endOffset + + /** + * Returns the raw JSON value of [flip]. + * + * Unlike [flip], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("flip") @ExcludeMissing fun _flip(): JsonField = flip + + /** + * Returns the raw JSON value of [focus]. + * + * Unlike [focus], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("focus") @ExcludeMissing fun _focus(): JsonField = focus + + /** + * Returns the raw JSON value of [format]. + * + * Unlike [format], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("format") @ExcludeMissing fun _format(): JsonField = format + + /** + * Returns the raw JSON value of [gradient]. + * + * Unlike [gradient], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gradient") @ExcludeMissing fun _gradient(): JsonField = gradient + + /** + * Returns the raw JSON value of [grayscale]. + * + * Unlike [grayscale], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("grayscale") @ExcludeMissing fun _grayscale(): JsonField = grayscale + + /** + * Returns the raw JSON value of [height]. + * + * Unlike [height], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("height") @ExcludeMissing fun _height(): JsonField = height + + /** + * Returns the raw JSON value of [lossless]. + * + * Unlike [lossless], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lossless") @ExcludeMissing fun _lossless(): JsonField = lossless + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [named]. + * + * Unlike [named], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("named") @ExcludeMissing fun _named(): JsonField = named + + /** + * Returns the raw JSON value of [opacity]. + * + * Unlike [opacity], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("opacity") @ExcludeMissing fun _opacity(): JsonField = opacity + + /** + * Returns the raw JSON value of [original]. + * + * Unlike [original], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("original") @ExcludeMissing fun _original(): JsonField = original + + /** + * Returns the raw JSON value of [overlay]. + * + * Unlike [overlay], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("overlay") @ExcludeMissing fun _overlay(): JsonField = overlay + + /** + * Returns the raw JSON value of [page]. + * + * Unlike [page], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("page") @ExcludeMissing fun _page(): JsonField = page + + /** + * Returns the raw JSON value of [progressive]. + * + * Unlike [progressive], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("progressive") + @ExcludeMissing + fun _progressive(): JsonField = progressive + + /** + * Returns the raw JSON value of [quality]. + * + * Unlike [quality], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("quality") @ExcludeMissing fun _quality(): JsonField = quality + + /** + * Returns the raw JSON value of [radius]. + * + * Unlike [radius], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("radius") @ExcludeMissing fun _radius(): JsonField = radius + + /** + * Returns the raw JSON value of [raw]. + * + * Unlike [raw], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("raw") @ExcludeMissing fun _raw(): JsonField = raw + + /** + * Returns the raw JSON value of [rotation]. + * + * Unlike [rotation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rotation") @ExcludeMissing fun _rotation(): JsonField = rotation + + /** + * Returns the raw JSON value of [shadow]. + * + * Unlike [shadow], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("shadow") @ExcludeMissing fun _shadow(): JsonField = shadow + + /** + * Returns the raw JSON value of [sharpen]. + * + * Unlike [sharpen], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sharpen") @ExcludeMissing fun _sharpen(): JsonField = sharpen + + /** + * Returns the raw JSON value of [startOffset]. + * + * Unlike [startOffset], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("startOffset") + @ExcludeMissing + fun _startOffset(): JsonField = startOffset + + /** + * Returns the raw JSON value of [streamingResolutions]. + * + * Unlike [streamingResolutions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("streamingResolutions") + @ExcludeMissing + fun _streamingResolutions(): JsonField> = streamingResolutions + + /** + * Returns the raw JSON value of [trim]. + * + * Unlike [trim], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trim") @ExcludeMissing fun _trim(): JsonField = trim + + /** + * Returns the raw JSON value of [unsharpMask]. + * + * Unlike [unsharpMask], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unsharpMask") + @ExcludeMissing + fun _unsharpMask(): JsonField = unsharpMask + + /** + * Returns the raw JSON value of [videoCodec]. + * + * Unlike [videoCodec], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("videoCodec") + @ExcludeMissing + fun _videoCodec(): JsonField = videoCodec + + /** + * Returns the raw JSON value of [width]. + * + * Unlike [width], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("width") @ExcludeMissing fun _width(): JsonField = width + + /** + * Returns the raw JSON value of [x]. + * + * Unlike [x], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("x") @ExcludeMissing fun _x(): JsonField = x + + /** + * Returns the raw JSON value of [xCenter]. + * + * Unlike [xCenter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("xCenter") @ExcludeMissing fun _xCenter(): JsonField = xCenter + + /** + * Returns the raw JSON value of [y]. + * + * Unlike [y], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("y") @ExcludeMissing fun _y(): JsonField = y + + /** + * Returns the raw JSON value of [yCenter]. + * + * Unlike [yCenter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("yCenter") @ExcludeMissing fun _yCenter(): JsonField = yCenter + + /** + * Returns the raw JSON value of [zoom]. + * + * Unlike [zoom], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("zoom") @ExcludeMissing fun _zoom(): JsonField = zoom + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Transformation]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Transformation]. */ + class Builder internal constructor() { + + private var aiChangeBackground: JsonField = JsonMissing.of() + private var aiDropShadow: JsonField = JsonMissing.of() + private var aiEdit: JsonField = JsonMissing.of() + private var aiRemoveBackground: JsonField = JsonMissing.of() + private var aiRemoveBackgroundExternal: JsonField = + JsonMissing.of() + private var aiRetouch: JsonField = JsonMissing.of() + private var aiUpscale: JsonField = JsonMissing.of() + private var aiVariation: JsonField = JsonMissing.of() + private var aspectRatio: JsonField = JsonMissing.of() + private var audioCodec: JsonField = JsonMissing.of() + private var background: JsonField = JsonMissing.of() + private var blur: JsonField = JsonMissing.of() + private var border: JsonField = JsonMissing.of() + private var colorProfile: JsonField = JsonMissing.of() + private var contrastStretch: JsonField = JsonMissing.of() + private var crop: JsonField = JsonMissing.of() + private var cropMode: JsonField = JsonMissing.of() + private var defaultImage: JsonField = JsonMissing.of() + private var dpr: JsonField = JsonMissing.of() + private var duration: JsonField = JsonMissing.of() + private var endOffset: JsonField = JsonMissing.of() + private var flip: JsonField = JsonMissing.of() + private var focus: JsonField = JsonMissing.of() + private var format: JsonField = JsonMissing.of() + private var gradient: JsonField = JsonMissing.of() + private var grayscale: JsonField = JsonMissing.of() + private var height: JsonField = JsonMissing.of() + private var lossless: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var named: JsonField = JsonMissing.of() + private var opacity: JsonField = JsonMissing.of() + private var original: JsonField = JsonMissing.of() + private var overlay: JsonField = JsonMissing.of() + private var page: JsonField = JsonMissing.of() + private var progressive: JsonField = JsonMissing.of() + private var quality: JsonField = JsonMissing.of() + private var radius: JsonField = JsonMissing.of() + private var raw: JsonField = JsonMissing.of() + private var rotation: JsonField = JsonMissing.of() + private var shadow: JsonField = JsonMissing.of() + private var sharpen: JsonField = JsonMissing.of() + private var startOffset: JsonField = JsonMissing.of() + private var streamingResolutions: JsonField>? = null + private var trim: JsonField = JsonMissing.of() + private var unsharpMask: JsonField = JsonMissing.of() + private var videoCodec: JsonField = JsonMissing.of() + private var width: JsonField = JsonMissing.of() + private var x: JsonField = JsonMissing.of() + private var xCenter: JsonField = JsonMissing.of() + private var y: JsonField = JsonMissing.of() + private var yCenter: JsonField = JsonMissing.of() + private var zoom: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(transformation: Transformation) = apply { + aiChangeBackground = transformation.aiChangeBackground + aiDropShadow = transformation.aiDropShadow + aiEdit = transformation.aiEdit + aiRemoveBackground = transformation.aiRemoveBackground + aiRemoveBackgroundExternal = transformation.aiRemoveBackgroundExternal + aiRetouch = transformation.aiRetouch + aiUpscale = transformation.aiUpscale + aiVariation = transformation.aiVariation + aspectRatio = transformation.aspectRatio + audioCodec = transformation.audioCodec + background = transformation.background + blur = transformation.blur + border = transformation.border + colorProfile = transformation.colorProfile + contrastStretch = transformation.contrastStretch + crop = transformation.crop + cropMode = transformation.cropMode + defaultImage = transformation.defaultImage + dpr = transformation.dpr + duration = transformation.duration + endOffset = transformation.endOffset + flip = transformation.flip + focus = transformation.focus + format = transformation.format + gradient = transformation.gradient + grayscale = transformation.grayscale + height = transformation.height + lossless = transformation.lossless + metadata = transformation.metadata + named = transformation.named + opacity = transformation.opacity + original = transformation.original + overlay = transformation.overlay + page = transformation.page + progressive = transformation.progressive + quality = transformation.quality + radius = transformation.radius + raw = transformation.raw + rotation = transformation.rotation + shadow = transformation.shadow + sharpen = transformation.sharpen + startOffset = transformation.startOffset + streamingResolutions = transformation.streamingResolutions.map { it.toMutableList() } + trim = transformation.trim + unsharpMask = transformation.unsharpMask + videoCodec = transformation.videoCodec + width = transformation.width + x = transformation.x + xCenter = transformation.xCenter + y = transformation.y + yCenter = transformation.yCenter + zoom = transformation.zoom + additionalProperties = transformation.additionalProperties.toMutableMap() + } + + /** + * Uses AI to change the background. Provide a text prompt or a base64-encoded prompt, e.g., + * `prompt-snow road` or `prompte-[urlencoded_base64_encoded_text]`. Not supported inside + * overlay. See + * [AI Change Background](https://imagekit.io/docs/ai-transformations#change-background-e-changebg). + */ + fun aiChangeBackground(aiChangeBackground: String) = + aiChangeBackground(JsonField.of(aiChangeBackground)) + + /** + * Sets [Builder.aiChangeBackground] to an arbitrary JSON value. + * + * You should usually call [Builder.aiChangeBackground] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun aiChangeBackground(aiChangeBackground: JsonField) = apply { + this.aiChangeBackground = aiChangeBackground + } + + /** + * Adds an AI-based drop shadow around a foreground object on a transparent or removed + * background. Optionally, control the direction, elevation, and saturation of the light + * source (e.g., `az-45` to change light direction). Pass `true` for the default drop + * shadow, or provide a string for a custom drop shadow. Supported inside overlay. See + * [AI Drop Shadow](https://imagekit.io/docs/ai-transformations#ai-drop-shadow-e-dropshadow). + */ + fun aiDropShadow(aiDropShadow: AiDropShadow) = aiDropShadow(JsonField.of(aiDropShadow)) + + /** + * Sets [Builder.aiDropShadow] to an arbitrary JSON value. + * + * You should usually call [Builder.aiDropShadow] with a well-typed [AiDropShadow] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun aiDropShadow(aiDropShadow: JsonField) = apply { + this.aiDropShadow = aiDropShadow + } + + /** Alias for calling [aiDropShadow] with `AiDropShadow.ofTrue()`. */ + fun aiDropShadowTrue() = aiDropShadow(AiDropShadow.ofTrue()) + + /** Alias for calling [aiDropShadow] with `AiDropShadow.ofString(string)`. */ + fun aiDropShadow(string: String) = aiDropShadow(AiDropShadow.ofString(string)) + + /** + * Uses AI to edit images based on a text prompt. Provide a text prompt or a base64-encoded + * prompt, e.g., `prompt-snow road` or `prompte-[urlencoded_base64_encoded_text]`. Not + * supported inside overlay. See + * [AI Edit](https://imagekit.io/docs/ai-transformations#edit-image-e-edit). + */ + fun aiEdit(aiEdit: String) = aiEdit(JsonField.of(aiEdit)) + + /** + * Sets [Builder.aiEdit] to an arbitrary JSON value. + * + * You should usually call [Builder.aiEdit] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun aiEdit(aiEdit: JsonField) = apply { this.aiEdit = aiEdit } + + /** + * Applies ImageKit's in-house background removal. Supported inside overlay. See + * [AI Background Removal](https://imagekit.io/docs/ai-transformations#imagekit-background-removal-e-bgremove). + */ + fun aiRemoveBackground(aiRemoveBackground: AiRemoveBackground) = + aiRemoveBackground(JsonField.of(aiRemoveBackground)) + + /** + * Sets [Builder.aiRemoveBackground] to an arbitrary JSON value. + * + * You should usually call [Builder.aiRemoveBackground] with a well-typed + * [AiRemoveBackground] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun aiRemoveBackground(aiRemoveBackground: JsonField) = apply { + this.aiRemoveBackground = aiRemoveBackground + } + + /** + * Uses third-party background removal. Note: It is recommended to use aiRemoveBackground, + * ImageKit's in-house solution, which is more cost-effective. Supported inside overlay. See + * [External Background Removal](https://imagekit.io/docs/ai-transformations#background-removal-e-removedotbg). + */ + fun aiRemoveBackgroundExternal(aiRemoveBackgroundExternal: AiRemoveBackgroundExternal) = + aiRemoveBackgroundExternal(JsonField.of(aiRemoveBackgroundExternal)) + + /** + * Sets [Builder.aiRemoveBackgroundExternal] to an arbitrary JSON value. + * + * You should usually call [Builder.aiRemoveBackgroundExternal] with a well-typed + * [AiRemoveBackgroundExternal] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun aiRemoveBackgroundExternal( + aiRemoveBackgroundExternal: JsonField + ) = apply { this.aiRemoveBackgroundExternal = aiRemoveBackgroundExternal } + + /** + * Performs AI-based retouching to improve faces or product shots. Not supported inside + * overlay. See [AI Retouch](https://imagekit.io/docs/ai-transformations#retouch-e-retouch). + */ + fun aiRetouch(aiRetouch: AiRetouch) = aiRetouch(JsonField.of(aiRetouch)) + + /** + * Sets [Builder.aiRetouch] to an arbitrary JSON value. + * + * You should usually call [Builder.aiRetouch] with a well-typed [AiRetouch] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun aiRetouch(aiRetouch: JsonField) = apply { this.aiRetouch = aiRetouch } + + /** + * Upscales images beyond their original dimensions using AI. Not supported inside overlay. + * See [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale). + */ + fun aiUpscale(aiUpscale: AiUpscale) = aiUpscale(JsonField.of(aiUpscale)) + + /** + * Sets [Builder.aiUpscale] to an arbitrary JSON value. + * + * You should usually call [Builder.aiUpscale] with a well-typed [AiUpscale] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun aiUpscale(aiUpscale: JsonField) = apply { this.aiUpscale = aiUpscale } + + /** + * Generates a variation of an image using AI. This produces a new image with slight + * variations from the original, such as changes in color, texture, and other visual + * elements, while preserving the structure and essence of the original image. Not supported + * inside overlay. See + * [AI Generate Variations](https://imagekit.io/docs/ai-transformations#generate-variations-of-an-image-e-genvar). + */ + fun aiVariation(aiVariation: AiVariation) = aiVariation(JsonField.of(aiVariation)) + + /** + * Sets [Builder.aiVariation] to an arbitrary JSON value. + * + * You should usually call [Builder.aiVariation] with a well-typed [AiVariation] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun aiVariation(aiVariation: JsonField) = apply { + this.aiVariation = aiVariation + } + + /** + * Specifies the aspect ratio for the output, e.g., "ar-4-3". Typically used with either + * width or height (but not both). For example: aspectRatio = `4:3`, `4_3`, or an expression + * like `iar_div_2`. See + * [Image resize and crop – Aspect ratio](https://imagekit.io/docs/image-resize-and-crop#aspect-ratio---ar). + */ + fun aspectRatio(aspectRatio: AspectRatio) = aspectRatio(JsonField.of(aspectRatio)) + + /** + * Sets [Builder.aspectRatio] to an arbitrary JSON value. + * + * You should usually call [Builder.aspectRatio] with a well-typed [AspectRatio] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun aspectRatio(aspectRatio: JsonField) = apply { + this.aspectRatio = aspectRatio + } + + /** Alias for calling [aspectRatio] with `AspectRatio.ofNumber(number)`. */ + fun aspectRatio(number: Double) = aspectRatio(AspectRatio.ofNumber(number)) + + /** Alias for calling [aspectRatio] with `AspectRatio.ofString(string)`. */ + fun aspectRatio(string: String) = aspectRatio(AspectRatio.ofString(string)) + + /** + * Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See + * [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac). + */ + fun audioCodec(audioCodec: AudioCodec) = audioCodec(JsonField.of(audioCodec)) + + /** + * Sets [Builder.audioCodec] to an arbitrary JSON value. + * + * You should usually call [Builder.audioCodec] with a well-typed [AudioCodec] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun audioCodec(audioCodec: JsonField) = apply { this.audioCodec = audioCodec } + + /** + * Specifies the background to be used in conjunction with certain cropping strategies when + * resizing an image. + * - A solid color: e.g., `red`, `F3F3F3`, `AAFF0010`. See + * [Solid color background](https://imagekit.io/docs/effects-and-enhancements#solid-color-background). + * - A blurred background: e.g., `blurred`, `blurred_25_N15`, etc. See + * [Blurred background](https://imagekit.io/docs/effects-and-enhancements#blurred-background). + * - Expand the image boundaries using generative fill: `genfill`. Not supported inside + * overlay. Optionally, control the background scene by passing a text prompt: + * `genfill[:-prompt-${text}]` or `genfill[:-prompte-${urlencoded_base64_encoded_text}]`. + * See + * [Generative fill background](https://imagekit.io/docs/ai-transformations#generative-fill-bg-genfill). + */ + fun background(background: String) = background(JsonField.of(background)) + + /** + * Sets [Builder.background] to an arbitrary JSON value. + * + * You should usually call [Builder.background] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun background(background: JsonField) = apply { this.background = background } + + /** + * Specifies the Gaussian blur level. Accepts an integer value between 1 and 100, or an + * expression like `bl-10`. See + * [Blur](https://imagekit.io/docs/effects-and-enhancements#blur---bl). + */ + fun blur(blur: Double) = blur(JsonField.of(blur)) + + /** + * Sets [Builder.blur] to an arbitrary JSON value. + * + * You should usually call [Builder.blur] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun blur(blur: JsonField) = apply { this.blur = blur } + + /** + * Adds a border to the output media. Accepts a string in the format + * `_` (e.g., `5_FFF000` for a 5px yellow border), or an expression + * like `ih_div_20_FF00FF`. See + * [Border](https://imagekit.io/docs/effects-and-enhancements#border---b). + */ + fun border(border: String) = border(JsonField.of(border)) + + /** + * Sets [Builder.border] to an arbitrary JSON value. + * + * You should usually call [Builder.border] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun border(border: JsonField) = apply { this.border = border } + + /** + * Indicates whether the output image should retain the original color profile. See + * [Color profile](https://imagekit.io/docs/image-optimization#color-profile---cp). + */ + fun colorProfile(colorProfile: Boolean) = colorProfile(JsonField.of(colorProfile)) + + /** + * Sets [Builder.colorProfile] to an arbitrary JSON value. + * + * You should usually call [Builder.colorProfile] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun colorProfile(colorProfile: JsonField) = apply { + this.colorProfile = colorProfile + } + + /** + * Automatically enhances the contrast of an image (contrast stretch). See + * [Contrast Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). + */ + fun contrastStretch(contrastStretch: ContrastStretch) = + contrastStretch(JsonField.of(contrastStretch)) + + /** + * Sets [Builder.contrastStretch] to an arbitrary JSON value. + * + * You should usually call [Builder.contrastStretch] with a well-typed [ContrastStretch] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun contrastStretch(contrastStretch: JsonField) = apply { + this.contrastStretch = contrastStretch + } + + /** + * Crop modes for image resizing. See + * [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + */ + fun crop(crop: Crop) = crop(JsonField.of(crop)) + + /** + * Sets [Builder.crop] to an arbitrary JSON value. + * + * You should usually call [Builder.crop] with a well-typed [Crop] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun crop(crop: JsonField) = apply { this.crop = crop } + + /** + * Additional crop modes for image resizing. See + * [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + */ + fun cropMode(cropMode: CropMode) = cropMode(JsonField.of(cropMode)) + + /** + * Sets [Builder.cropMode] to an arbitrary JSON value. + * + * You should usually call [Builder.cropMode] with a well-typed [CropMode] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cropMode(cropMode: JsonField) = apply { this.cropMode = cropMode } + + /** + * Specifies a fallback image if the resource is not found, e.g., a URL or file path. See + * [Default image](https://imagekit.io/docs/image-transformation#default-image---di). + */ + fun defaultImage(defaultImage: String) = defaultImage(JsonField.of(defaultImage)) + + /** + * Sets [Builder.defaultImage] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultImage] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun defaultImage(defaultImage: JsonField) = apply { + this.defaultImage = defaultImage + } + + /** + * Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio (DPR) + * calculation. See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). + */ + fun dpr(dpr: Double) = dpr(JsonField.of(dpr)) + + /** + * Sets [Builder.dpr] to an arbitrary JSON value. + * + * You should usually call [Builder.dpr] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun dpr(dpr: JsonField) = apply { this.dpr = dpr } + + /** + * Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. Typically + * used with startOffset to indicate the length from the start offset. Arithmetic + * expressions are supported. See + * [Trim videos – Duration](https://imagekit.io/docs/trim-videos#duration---du). + */ + fun duration(duration: Duration) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Duration] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** Alias for calling [duration] with `Duration.ofNumber(number)`. */ + fun duration(number: Double) = duration(Duration.ofNumber(number)) + + /** Alias for calling [duration] with `Duration.ofString(string)`. */ + fun duration(string: String) = duration(Duration.ofString(string)) + + /** + * Specifies the end offset (in seconds) for trimming videos, e.g., `5` or `10.5`. Typically + * used with startOffset to define a time window. Arithmetic expressions are supported. See + * [Trim videos – End offset](https://imagekit.io/docs/trim-videos#end-offset---eo). + */ + fun endOffset(endOffset: EndOffset) = endOffset(JsonField.of(endOffset)) + + /** + * Sets [Builder.endOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.endOffset] with a well-typed [EndOffset] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun endOffset(endOffset: JsonField) = apply { this.endOffset = endOffset } + + /** Alias for calling [endOffset] with `EndOffset.ofNumber(number)`. */ + fun endOffset(number: Double) = endOffset(EndOffset.ofNumber(number)) + + /** Alias for calling [endOffset] with `EndOffset.ofString(string)`. */ + fun endOffset(string: String) = endOffset(EndOffset.ofString(string)) + + /** + * Flips or mirrors an image either horizontally, vertically, or both. Acceptable values: + * `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or `v_h`. See + * [Flip](https://imagekit.io/docs/effects-and-enhancements#flip---fl). + */ + fun flip(flip: Flip) = flip(JsonField.of(flip)) + + /** + * Sets [Builder.flip] to an arbitrary JSON value. + * + * You should usually call [Builder.flip] with a well-typed [Flip] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun flip(flip: JsonField) = apply { this.flip = flip } + + /** + * Refines padding and cropping behavior for pad resize, maintain ratio, and extract crop + * modes. Supports manual positions and coordinate-based focus. With AI-based cropping, you + * can automatically keep key subjects in frame—such as faces or detected objects (e.g., + * `fo-face`, `fo-person`, `fo-car`)— while resizing. + * - See [Focus](https://imagekit.io/docs/image-resize-and-crop#focus---fo). + * - [Object aware + * cropping](https://imagekit.io/docs/image-resize-and-crop#object-aware-cropping---fo-object-name) + */ + fun focus(focus: String) = focus(JsonField.of(focus)) + + /** + * Sets [Builder.focus] to an arbitrary JSON value. + * + * You should usually call [Builder.focus] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun focus(focus: JsonField) = apply { this.focus = focus } + + /** + * Specifies the output format for images or videos, e.g., `jpg`, `png`, `webp`, `mp4`, or + * `auto`. You can also pass `orig` for images to return the original format. ImageKit + * automatically delivers images and videos in the optimal format based on device support + * unless overridden by the dashboard settings or the format parameter. See + * [Image format](https://imagekit.io/docs/image-optimization#format---f) and + * [Video format](https://imagekit.io/docs/video-optimization#format---f). + */ + fun format(format: Format) = format(JsonField.of(format)) + + /** + * Sets [Builder.format] to an arbitrary JSON value. + * + * You should usually call [Builder.format] with a well-typed [Format] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun format(format: JsonField) = apply { this.format = format } + + /** + * Creates a linear gradient with two colors. Pass `true` for a default gradient, or provide + * a string for a custom gradient. See + * [Gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + */ + fun gradient(gradient: Gradient) = gradient(JsonField.of(gradient)) + + /** + * Sets [Builder.gradient] to an arbitrary JSON value. + * + * You should usually call [Builder.gradient] with a well-typed [Gradient] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun gradient(gradient: JsonField) = apply { this.gradient = gradient } + + /** Alias for calling [gradient] with `Gradient.ofTrue()`. */ + fun gradientTrue() = gradient(Gradient.ofTrue()) + + /** Alias for calling [gradient] with `Gradient.ofString(string)`. */ + fun gradient(string: String) = gradient(Gradient.ofString(string)) + + /** + * Enables a grayscale effect for images. See + * [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale). + */ + fun grayscale(grayscale: Grayscale) = grayscale(JsonField.of(grayscale)) + + /** + * Sets [Builder.grayscale] to an arbitrary JSON value. + * + * You should usually call [Builder.grayscale] with a well-typed [Grayscale] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun grayscale(grayscale: JsonField) = apply { this.grayscale = grayscale } + + /** + * Specifies the height of the output. If a value between 0 and 1 is provided, it is treated + * as a percentage (e.g., `0.5` represents 50% of the original height). You can also supply + * arithmetic expressions (e.g., `ih_mul_0.5`). Height transformation – + * [Images](https://imagekit.io/docs/image-resize-and-crop#height---h) · + * [Videos](https://imagekit.io/docs/video-resize-and-crop#height---h) + */ + fun height(height: Height) = height(JsonField.of(height)) + + /** + * Sets [Builder.height] to an arbitrary JSON value. + * + * You should usually call [Builder.height] with a well-typed [Height] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun height(height: JsonField) = apply { this.height = height } + + /** Alias for calling [height] with `Height.ofNumber(number)`. */ + fun height(number: Double) = height(Height.ofNumber(number)) + + /** Alias for calling [height] with `Height.ofString(string)`. */ + fun height(string: String) = height(Height.ofString(string)) + + /** + * Specifies whether the output image (in JPEG or PNG) should be compressed losslessly. See + * [Lossless compression](https://imagekit.io/docs/image-optimization#lossless-webp-and-png---lo). + */ + fun lossless(lossless: Boolean) = lossless(JsonField.of(lossless)) + + /** + * Sets [Builder.lossless] to an arbitrary JSON value. + * + * You should usually call [Builder.lossless] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun lossless(lossless: JsonField) = apply { this.lossless = lossless } + + /** + * By default, ImageKit removes all metadata during automatic image compression. Set this to + * true to preserve metadata. See + * [Image metadata](https://imagekit.io/docs/image-optimization#image-metadata---md). + */ + fun metadata(metadata: Boolean) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** + * Named transformation reference. See + * [Named transformations](https://imagekit.io/docs/transformations#named-transformations). + */ + fun named(named: String) = named(JsonField.of(named)) + + /** + * Sets [Builder.named] to an arbitrary JSON value. + * + * You should usually call [Builder.named] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun named(named: JsonField) = apply { this.named = named } + + /** + * Specifies the opacity level of the output image. See + * [Opacity](https://imagekit.io/docs/effects-and-enhancements#opacity---o). + */ + fun opacity(opacity: Double) = opacity(JsonField.of(opacity)) + + /** + * Sets [Builder.opacity] to an arbitrary JSON value. + * + * You should usually call [Builder.opacity] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun opacity(opacity: JsonField) = apply { this.opacity = opacity } + + /** + * If set to true, serves the original file without applying any transformations. See + * [Deliver original file as-is](https://imagekit.io/docs/core-delivery-features#deliver-original-file-as-is---orig-true). + */ + fun original(original: Boolean) = original(JsonField.of(original)) + + /** + * Sets [Builder.original] to an arbitrary JSON value. + * + * You should usually call [Builder.original] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun original(original: JsonField) = apply { this.original = original } + + /** + * Specifies an overlay to be applied on the parent image or video. ImageKit supports + * overlays including images, text, videos, subtitles, and solid colors. See + * [Overlay using layers](https://imagekit.io/docs/transformations#overlay-using-layers). + */ + fun overlay(overlay: Overlay) = overlay(JsonField.of(overlay)) + + /** + * Sets [Builder.overlay] to an arbitrary JSON value. + * + * You should usually call [Builder.overlay] with a well-typed [Overlay] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun overlay(overlay: JsonField) = apply { this.overlay = overlay } + + /** Alias for calling [overlay] with `Overlay.ofText(text)`. */ + fun overlay(text: TextOverlay) = overlay(Overlay.ofText(text)) + + /** + * Alias for calling [overlay] with the following: + * ```java + * TextOverlay.builder() + * .text(text) + * .build() + * ``` + */ + fun textOverlay(text: String) = overlay(TextOverlay.builder().text(text).build()) + + /** Alias for calling [overlay] with `Overlay.ofImage(image)`. */ + fun overlay(image: ImageOverlay) = overlay(Overlay.ofImage(image)) + + /** + * Alias for calling [overlay] with the following: + * ```java + * ImageOverlay.builder() + * .input(input) + * .build() + * ``` + */ + fun imageOverlay(input: String) = overlay(ImageOverlay.builder().input(input).build()) + + /** Alias for calling [overlay] with `Overlay.ofVideo(video)`. */ + fun overlay(video: VideoOverlay) = overlay(Overlay.ofVideo(video)) + + /** + * Alias for calling [overlay] with the following: + * ```java + * VideoOverlay.builder() + * .input(input) + * .build() + * ``` + */ + fun videoOverlay(input: String) = overlay(VideoOverlay.builder().input(input).build()) + + /** Alias for calling [overlay] with `Overlay.ofSubtitle(subtitle)`. */ + fun overlay(subtitle: SubtitleOverlay) = overlay(Overlay.ofSubtitle(subtitle)) + + /** + * Alias for calling [overlay] with the following: + * ```java + * SubtitleOverlay.builder() + * .input(input) + * .build() + * ``` + */ + fun subtitleOverlay(input: String) = overlay(SubtitleOverlay.builder().input(input).build()) + + /** Alias for calling [overlay] with `Overlay.ofSolidColor(solidColor)`. */ + fun overlay(solidColor: SolidColorOverlay) = overlay(Overlay.ofSolidColor(solidColor)) + + /** + * Alias for calling [overlay] with the following: + * ```java + * SolidColorOverlay.builder() + * .color(color) + * .build() + * ``` + */ + fun solidColorOverlay(color: String) = + overlay(SolidColorOverlay.builder().color(color).build()) + + /** + * Extracts a specific page or frame from multi-page or layered files (PDF, PSD, AI). For + * example, specify by number (e.g., `2`), a range (e.g., `3-4` for the 2nd and 3rd layers), + * or by name (e.g., `name-layer-4` for a PSD layer). See + * [Thumbnail extraction](https://imagekit.io/docs/vector-and-animated-images#get-thumbnail-from-psd-pdf-ai-eps-and-animated-files). + */ + fun page(page: Page) = page(JsonField.of(page)) + + /** + * Sets [Builder.page] to an arbitrary JSON value. + * + * You should usually call [Builder.page] with a well-typed [Page] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun page(page: JsonField) = apply { this.page = page } + + /** Alias for calling [page] with `Page.ofNumber(number)`. */ + fun page(number: Double) = page(Page.ofNumber(number)) + + /** Alias for calling [page] with `Page.ofString(string)`. */ + fun page(string: String) = page(Page.ofString(string)) + + /** + * Specifies whether the output JPEG image should be rendered progressively. Progressive + * loading begins with a low-quality, pixelated version of the full image, which gradually + * improves to provide a faster perceived load time. See + * [Progressive images](https://imagekit.io/docs/image-optimization#progressive-image---pr). + */ + fun progressive(progressive: Boolean) = progressive(JsonField.of(progressive)) + + /** + * Sets [Builder.progressive] to an arbitrary JSON value. + * + * You should usually call [Builder.progressive] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun progressive(progressive: JsonField) = apply { this.progressive = progressive } + + /** + * Specifies the quality of the output image for lossy formats such as JPEG, WebP, and AVIF. + * A higher quality value results in a larger file size with better quality, while a lower + * value produces a smaller file size with reduced quality. See + * [Quality](https://imagekit.io/docs/image-optimization#quality---q). + */ + fun quality(quality: Double) = quality(JsonField.of(quality)) + + /** + * Sets [Builder.quality] to an arbitrary JSON value. + * + * You should usually call [Builder.quality] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun quality(quality: JsonField) = apply { this.quality = quality } + + /** + * Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular or oval + * shape. See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + */ + fun radius(radius: Radius) = radius(JsonField.of(radius)) + + /** + * Sets [Builder.radius] to an arbitrary JSON value. + * + * You should usually call [Builder.radius] with a well-typed [Radius] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun radius(radius: JsonField) = apply { this.radius = radius } + + /** Alias for calling [radius] with `Radius.ofNumber(number)`. */ + fun radius(number: Double) = radius(Radius.ofNumber(number)) + + /** Alias for calling [radius] with `Radius.ofMax()`. */ + fun radiusMax() = radius(Radius.ofMax()) + + /** + * Pass any transformation not directly supported by the SDK. This transformation string is + * appended to the URL as provided. + */ + fun raw(raw: String) = raw(JsonField.of(raw)) + + /** + * Sets [Builder.raw] to an arbitrary JSON value. + * + * You should usually call [Builder.raw] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun raw(raw: JsonField) = apply { this.raw = raw } + + /** + * Specifies the rotation angle in degrees. Positive values rotate the image clockwise; you + * can also use, for example, `N40` for counterclockwise rotation or `auto` to use the + * orientation specified in the image's EXIF data. For videos, only the following values are + * supported: 0, 90, 180, 270, or 360. See + * [Rotate](https://imagekit.io/docs/effects-and-enhancements#rotate---rt). + */ + fun rotation(rotation: Rotation) = rotation(JsonField.of(rotation)) + + /** + * Sets [Builder.rotation] to an arbitrary JSON value. + * + * You should usually call [Builder.rotation] with a well-typed [Rotation] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun rotation(rotation: JsonField) = apply { this.rotation = rotation } + + /** Alias for calling [rotation] with `Rotation.ofNumber(number)`. */ + fun rotation(number: Double) = rotation(Rotation.ofNumber(number)) + + /** Alias for calling [rotation] with `Rotation.ofString(string)`. */ + fun rotation(string: String) = rotation(Rotation.ofString(string)) + + /** + * Adds a shadow beneath solid objects in an image with a transparent background. For + * AI-based drop shadows, refer to aiDropShadow. Pass `true` for a default shadow, or + * provide a string for a custom shadow. See + * [Shadow](https://imagekit.io/docs/effects-and-enhancements#shadow---e-shadow). + */ + fun shadow(shadow: Shadow) = shadow(JsonField.of(shadow)) + + /** + * Sets [Builder.shadow] to an arbitrary JSON value. + * + * You should usually call [Builder.shadow] with a well-typed [Shadow] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun shadow(shadow: JsonField) = apply { this.shadow = shadow } + + /** Alias for calling [shadow] with `Shadow.ofTrue()`. */ + fun shadowTrue() = shadow(Shadow.ofTrue()) + + /** Alias for calling [shadow] with `Shadow.ofString(string)`. */ + fun shadow(string: String) = shadow(Shadow.ofString(string)) + + /** + * Sharpens the input image, highlighting edges and finer details. Pass `true` for default + * sharpening, or provide a numeric value for custom sharpening. See + * [Sharpen](https://imagekit.io/docs/effects-and-enhancements#sharpen---e-sharpen). + */ + fun sharpen(sharpen: Sharpen) = sharpen(JsonField.of(sharpen)) + + /** + * Sets [Builder.sharpen] to an arbitrary JSON value. + * + * You should usually call [Builder.sharpen] with a well-typed [Sharpen] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun sharpen(sharpen: JsonField) = apply { this.sharpen = sharpen } + + /** Alias for calling [sharpen] with `Sharpen.ofTrue()`. */ + fun sharpenTrue() = sharpen(Sharpen.ofTrue()) + + /** Alias for calling [sharpen] with `Sharpen.ofNumber(number)`. */ + fun sharpen(number: Double) = sharpen(Sharpen.ofNumber(number)) + + /** + * Specifies the start offset (in seconds) for trimming videos, e.g., `5` or `10.5`. + * Arithmetic expressions are also supported. See + * [Trim videos – Start offset](https://imagekit.io/docs/trim-videos#start-offset---so). + */ + fun startOffset(startOffset: StartOffset) = startOffset(JsonField.of(startOffset)) + + /** + * Sets [Builder.startOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.startOffset] with a well-typed [StartOffset] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startOffset(startOffset: JsonField) = apply { + this.startOffset = startOffset + } + + /** Alias for calling [startOffset] with `StartOffset.ofNumber(number)`. */ + fun startOffset(number: Double) = startOffset(StartOffset.ofNumber(number)) + + /** Alias for calling [startOffset] with `StartOffset.ofString(string)`. */ + fun startOffset(string: String) = startOffset(StartOffset.ofString(string)) + + /** + * An array of resolutions for adaptive bitrate streaming, e.g., + * [`240`, `360`, `480`, `720`, `1080`]. See + * [Adaptive Bitrate Streaming](https://imagekit.io/docs/adaptive-bitrate-streaming). + */ + fun streamingResolutions(streamingResolutions: List) = + streamingResolutions(JsonField.of(streamingResolutions)) + + /** + * Sets [Builder.streamingResolutions] to an arbitrary JSON value. + * + * You should usually call [Builder.streamingResolutions] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun streamingResolutions(streamingResolutions: JsonField>) = + apply { + this.streamingResolutions = streamingResolutions.map { it.toMutableList() } + } + + /** + * Adds a single [StreamingResolution] to [streamingResolutions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStreamingResolution(streamingResolution: StreamingResolution) = apply { + streamingResolutions = + (streamingResolutions ?: JsonField.of(mutableListOf())).also { + checkKnown("streamingResolutions", it).add(streamingResolution) + } + } + + /** + * Useful for images with a solid or nearly solid background and a central object. This + * parameter trims the background, leaving only the central object in the output image. See + * [Trim edges](https://imagekit.io/docs/effects-and-enhancements#trim-edges---t). + */ + fun trim(trim: Trim) = trim(JsonField.of(trim)) + + /** + * Sets [Builder.trim] to an arbitrary JSON value. + * + * You should usually call [Builder.trim] with a well-typed [Trim] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun trim(trim: JsonField) = apply { this.trim = trim } + + /** Alias for calling [trim] with `Trim.ofTrue()`. */ + fun trimTrue() = trim(Trim.ofTrue()) + + /** Alias for calling [trim] with `Trim.ofNumber(number)`. */ + fun trim(number: Double) = trim(Trim.ofNumber(number)) + + /** + * Applies Unsharp Masking (USM), an image sharpening technique. Pass `true` for a default + * unsharp mask, or provide a string for a custom unsharp mask. See + * [Unsharp Mask](https://imagekit.io/docs/effects-and-enhancements#unsharp-mask---e-usm). + */ + fun unsharpMask(unsharpMask: UnsharpMask) = unsharpMask(JsonField.of(unsharpMask)) + + /** + * Sets [Builder.unsharpMask] to an arbitrary JSON value. + * + * You should usually call [Builder.unsharpMask] with a well-typed [UnsharpMask] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unsharpMask(unsharpMask: JsonField) = apply { + this.unsharpMask = unsharpMask + } + + /** Alias for calling [unsharpMask] with `UnsharpMask.ofTrue()`. */ + fun unsharpMaskTrue() = unsharpMask(UnsharpMask.ofTrue()) + + /** Alias for calling [unsharpMask] with `UnsharpMask.ofString(string)`. */ + fun unsharpMask(string: String) = unsharpMask(UnsharpMask.ofString(string)) + + /** + * Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See + * [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc). + */ + fun videoCodec(videoCodec: VideoCodec) = videoCodec(JsonField.of(videoCodec)) + + /** + * Sets [Builder.videoCodec] to an arbitrary JSON value. + * + * You should usually call [Builder.videoCodec] with a well-typed [VideoCodec] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun videoCodec(videoCodec: JsonField) = apply { this.videoCodec = videoCodec } + + /** + * Specifies the width of the output. If a value between 0 and 1 is provided, it is treated + * as a percentage (e.g., `0.4` represents 40% of the original width). You can also supply + * arithmetic expressions (e.g., `iw_div_2`). Width transformation – + * [Images](https://imagekit.io/docs/image-resize-and-crop#width---w) · + * [Videos](https://imagekit.io/docs/video-resize-and-crop#width---w) + */ + fun width(width: Width) = width(JsonField.of(width)) + + /** + * Sets [Builder.width] to an arbitrary JSON value. + * + * You should usually call [Builder.width] with a well-typed [Width] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun width(width: JsonField) = apply { this.width = width } + + /** Alias for calling [width] with `Width.ofNumber(number)`. */ + fun width(number: Double) = width(Width.ofNumber(number)) + + /** Alias for calling [width] with `Width.ofString(string)`. */ + fun width(string: String) = width(Width.ofString(string)) + + /** + * Focus using cropped image coordinates - X coordinate. See + * [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + */ + fun x(x: X) = x(JsonField.of(x)) + + /** + * Sets [Builder.x] to an arbitrary JSON value. + * + * You should usually call [Builder.x] with a well-typed [X] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun x(x: JsonField) = apply { this.x = x } + + /** Alias for calling [x] with `X.ofNumber(number)`. */ + fun x(number: Double) = x(X.ofNumber(number)) + + /** Alias for calling [x] with `X.ofString(string)`. */ + fun x(string: String) = x(X.ofString(string)) + + /** + * Focus using cropped image coordinates - X center coordinate. See + * [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + */ + fun xCenter(xCenter: XCenter) = xCenter(JsonField.of(xCenter)) + + /** + * Sets [Builder.xCenter] to an arbitrary JSON value. + * + * You should usually call [Builder.xCenter] with a well-typed [XCenter] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun xCenter(xCenter: JsonField) = apply { this.xCenter = xCenter } + + /** Alias for calling [xCenter] with `XCenter.ofNumber(number)`. */ + fun xCenter(number: Double) = xCenter(XCenter.ofNumber(number)) + + /** Alias for calling [xCenter] with `XCenter.ofString(string)`. */ + fun xCenter(string: String) = xCenter(XCenter.ofString(string)) + + /** + * Focus using cropped image coordinates - Y coordinate. See + * [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + */ + fun y(y: Y) = y(JsonField.of(y)) + + /** + * Sets [Builder.y] to an arbitrary JSON value. + * + * You should usually call [Builder.y] with a well-typed [Y] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun y(y: JsonField) = apply { this.y = y } + + /** Alias for calling [y] with `Y.ofNumber(number)`. */ + fun y(number: Double) = y(Y.ofNumber(number)) + + /** Alias for calling [y] with `Y.ofString(string)`. */ + fun y(string: String) = y(Y.ofString(string)) + + /** + * Focus using cropped image coordinates - Y center coordinate. See + * [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + */ + fun yCenter(yCenter: YCenter) = yCenter(JsonField.of(yCenter)) + + /** + * Sets [Builder.yCenter] to an arbitrary JSON value. + * + * You should usually call [Builder.yCenter] with a well-typed [YCenter] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun yCenter(yCenter: JsonField) = apply { this.yCenter = yCenter } + + /** Alias for calling [yCenter] with `YCenter.ofNumber(number)`. */ + fun yCenter(number: Double) = yCenter(YCenter.ofNumber(number)) + + /** Alias for calling [yCenter] with `YCenter.ofString(string)`. */ + fun yCenter(string: String) = yCenter(YCenter.ofString(string)) + + /** + * Accepts a numeric value that determines how much to zoom in or out of the cropped area. + * It should be used in conjunction with fo-face or fo-. See + * [Zoom](https://imagekit.io/docs/image-resize-and-crop#zoom---z). + */ + fun zoom(zoom: Double) = zoom(JsonField.of(zoom)) + + /** + * Sets [Builder.zoom] to an arbitrary JSON value. + * + * You should usually call [Builder.zoom] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun zoom(zoom: JsonField) = apply { this.zoom = zoom } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Transformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Transformation = + Transformation( + aiChangeBackground, + aiDropShadow, + aiEdit, + aiRemoveBackground, + aiRemoveBackgroundExternal, + aiRetouch, + aiUpscale, + aiVariation, + aspectRatio, + audioCodec, + background, + blur, + border, + colorProfile, + contrastStretch, + crop, + cropMode, + defaultImage, + dpr, + duration, + endOffset, + flip, + focus, + format, + gradient, + grayscale, + height, + lossless, + metadata, + named, + opacity, + original, + overlay, + page, + progressive, + quality, + radius, + raw, + rotation, + shadow, + sharpen, + startOffset, + (streamingResolutions ?: JsonMissing.of()).map { it.toImmutable() }, + trim, + unsharpMask, + videoCodec, + width, + x, + xCenter, + y, + yCenter, + zoom, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Transformation = apply { + if (validated) { + return@apply + } + + aiChangeBackground() + aiDropShadow().ifPresent { it.validate() } + aiEdit() + aiRemoveBackground().ifPresent { it.validate() } + aiRemoveBackgroundExternal().ifPresent { it.validate() } + aiRetouch().ifPresent { it.validate() } + aiUpscale().ifPresent { it.validate() } + aiVariation().ifPresent { it.validate() } + aspectRatio().ifPresent { it.validate() } + audioCodec().ifPresent { it.validate() } + background() + blur() + border() + colorProfile() + contrastStretch().ifPresent { it.validate() } + crop().ifPresent { it.validate() } + cropMode().ifPresent { it.validate() } + defaultImage() + dpr() + duration().ifPresent { it.validate() } + endOffset().ifPresent { it.validate() } + flip().ifPresent { it.validate() } + focus() + format().ifPresent { it.validate() } + gradient().ifPresent { it.validate() } + grayscale().ifPresent { it.validate() } + height().ifPresent { it.validate() } + lossless() + metadata() + named() + opacity() + original() + overlay().ifPresent { it.validate() } + page().ifPresent { it.validate() } + progressive() + quality() + radius().ifPresent { it.validate() } + raw() + rotation().ifPresent { it.validate() } + shadow().ifPresent { it.validate() } + sharpen().ifPresent { it.validate() } + startOffset().ifPresent { it.validate() } + streamingResolutions().ifPresent { it.forEach { it.validate() } } + trim().ifPresent { it.validate() } + unsharpMask().ifPresent { it.validate() } + videoCodec().ifPresent { it.validate() } + width().ifPresent { it.validate() } + x().ifPresent { it.validate() } + xCenter().ifPresent { it.validate() } + y().ifPresent { it.validate() } + yCenter().ifPresent { it.validate() } + zoom() + 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 (aiChangeBackground.asKnown().isPresent) 1 else 0) + + (aiDropShadow.asKnown().getOrNull()?.validity() ?: 0) + + (if (aiEdit.asKnown().isPresent) 1 else 0) + + (aiRemoveBackground.asKnown().getOrNull()?.validity() ?: 0) + + (aiRemoveBackgroundExternal.asKnown().getOrNull()?.validity() ?: 0) + + (aiRetouch.asKnown().getOrNull()?.validity() ?: 0) + + (aiUpscale.asKnown().getOrNull()?.validity() ?: 0) + + (aiVariation.asKnown().getOrNull()?.validity() ?: 0) + + (aspectRatio.asKnown().getOrNull()?.validity() ?: 0) + + (audioCodec.asKnown().getOrNull()?.validity() ?: 0) + + (if (background.asKnown().isPresent) 1 else 0) + + (if (blur.asKnown().isPresent) 1 else 0) + + (if (border.asKnown().isPresent) 1 else 0) + + (if (colorProfile.asKnown().isPresent) 1 else 0) + + (contrastStretch.asKnown().getOrNull()?.validity() ?: 0) + + (crop.asKnown().getOrNull()?.validity() ?: 0) + + (cropMode.asKnown().getOrNull()?.validity() ?: 0) + + (if (defaultImage.asKnown().isPresent) 1 else 0) + + (if (dpr.asKnown().isPresent) 1 else 0) + + (duration.asKnown().getOrNull()?.validity() ?: 0) + + (endOffset.asKnown().getOrNull()?.validity() ?: 0) + + (flip.asKnown().getOrNull()?.validity() ?: 0) + + (if (focus.asKnown().isPresent) 1 else 0) + + (format.asKnown().getOrNull()?.validity() ?: 0) + + (gradient.asKnown().getOrNull()?.validity() ?: 0) + + (grayscale.asKnown().getOrNull()?.validity() ?: 0) + + (height.asKnown().getOrNull()?.validity() ?: 0) + + (if (lossless.asKnown().isPresent) 1 else 0) + + (if (metadata.asKnown().isPresent) 1 else 0) + + (if (named.asKnown().isPresent) 1 else 0) + + (if (opacity.asKnown().isPresent) 1 else 0) + + (if (original.asKnown().isPresent) 1 else 0) + + (overlay.asKnown().getOrNull()?.validity() ?: 0) + + (page.asKnown().getOrNull()?.validity() ?: 0) + + (if (progressive.asKnown().isPresent) 1 else 0) + + (if (quality.asKnown().isPresent) 1 else 0) + + (radius.asKnown().getOrNull()?.validity() ?: 0) + + (if (raw.asKnown().isPresent) 1 else 0) + + (rotation.asKnown().getOrNull()?.validity() ?: 0) + + (shadow.asKnown().getOrNull()?.validity() ?: 0) + + (sharpen.asKnown().getOrNull()?.validity() ?: 0) + + (startOffset.asKnown().getOrNull()?.validity() ?: 0) + + (streamingResolutions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (trim.asKnown().getOrNull()?.validity() ?: 0) + + (unsharpMask.asKnown().getOrNull()?.validity() ?: 0) + + (videoCodec.asKnown().getOrNull()?.validity() ?: 0) + + (width.asKnown().getOrNull()?.validity() ?: 0) + + (x.asKnown().getOrNull()?.validity() ?: 0) + + (xCenter.asKnown().getOrNull()?.validity() ?: 0) + + (y.asKnown().getOrNull()?.validity() ?: 0) + + (yCenter.asKnown().getOrNull()?.validity() ?: 0) + + (if (zoom.asKnown().isPresent) 1 else 0) + + /** + * Adds an AI-based drop shadow around a foreground object on a transparent or removed + * background. Optionally, control the direction, elevation, and saturation of the light source + * (e.g., `az-45` to change light direction). Pass `true` for the default drop shadow, or + * provide a string for a custom drop shadow. Supported inside overlay. See + * [AI Drop Shadow](https://imagekit.io/docs/ai-transformations#ai-drop-shadow-e-dropshadow). + */ + @JsonDeserialize(using = AiDropShadow.Deserializer::class) + @JsonSerialize(using = AiDropShadow.Serializer::class) + class AiDropShadow + private constructor( + private val true_: JsonValue? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun true_(): Optional = Optional.ofNullable(true_) + + fun string(): Optional = Optional.ofNullable(string) + + fun isTrue(): Boolean = true_ != null + + fun isString(): Boolean = string != null + + fun asTrue(): JsonValue = true_.getOrThrow("true_") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + true_ != null -> visitor.visitTrue(true_) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): AiDropShadow = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTrue(true_: JsonValue) { + true_.let { + if (it != JsonValue.from(true)) { + throw ImageKitInvalidDataException( + "'true_' is invalid, received $it" + ) + } + } + } + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitTrue(true_: JsonValue) = + true_.let { if (it == JsonValue.from(true)) 1 else 0 } + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiDropShadow && true_ == other.true_ && string == other.string + } + + override fun hashCode(): Int = Objects.hash(true_, string) + + override fun toString(): String = + when { + true_ != null -> "AiDropShadow{true_=$true_}" + string != null -> "AiDropShadow{string=$string}" + _json != null -> "AiDropShadow{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AiDropShadow") + } + + companion object { + + @JvmStatic fun ofTrue() = AiDropShadow(true_ = JsonValue.from(true)) + + @JvmStatic fun ofString(string: String) = AiDropShadow(string = string) + } + + /** + * An interface that defines how to map each variant of [AiDropShadow] to a value of type + * [T]. + */ + interface Visitor { + + fun visitTrue(true_: JsonValue): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [AiDropShadow] to a value of type [T]. + * + * An instance of [AiDropShadow] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown AiDropShadow: $json") + } + } + + internal class Deserializer : BaseDeserializer(AiDropShadow::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AiDropShadow { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { AiDropShadow(true_ = it, _json = json) } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef())?.let { + AiDropShadow(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> AiDropShadow(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(AiDropShadow::class) { + + override fun serialize( + value: AiDropShadow, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.true_ != null -> generator.writeObject(value.true_) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AiDropShadow") + } + } + } + } + + /** + * Applies ImageKit's in-house background removal. Supported inside overlay. See + * [AI Background Removal](https://imagekit.io/docs/ai-transformations#imagekit-background-removal-e-bgremove). + */ + class AiRemoveBackground + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TRUE = of(true) + + @JvmStatic fun of(value: Boolean) = AiRemoveBackground(JsonField.of(value)) + } + + /** An enum containing [AiRemoveBackground]'s known values. */ + enum class Known { + TRUE + } + + /** + * An enum containing [AiRemoveBackground]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AiRemoveBackground] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TRUE, + /** + * An enum member indicating that [AiRemoveBackground] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TRUE -> Value.TRUE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TRUE -> Known.TRUE + else -> throw ImageKitInvalidDataException("Unknown AiRemoveBackground: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asBoolean(): Boolean = + _value().asBoolean().orElseThrow { + ImageKitInvalidDataException("Value is not a Boolean") + } + + private var validated: Boolean = false + + fun validate(): AiRemoveBackground = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiRemoveBackground && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Uses third-party background removal. Note: It is recommended to use aiRemoveBackground, + * ImageKit's in-house solution, which is more cost-effective. Supported inside overlay. See + * [External Background Removal](https://imagekit.io/docs/ai-transformations#background-removal-e-removedotbg). + */ + class AiRemoveBackgroundExternal + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TRUE = of(true) + + @JvmStatic fun of(value: Boolean) = AiRemoveBackgroundExternal(JsonField.of(value)) + } + + /** An enum containing [AiRemoveBackgroundExternal]'s known values. */ + enum class Known { + TRUE + } + + /** + * An enum containing [AiRemoveBackgroundExternal]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AiRemoveBackgroundExternal] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TRUE, + /** + * An enum member indicating that [AiRemoveBackgroundExternal] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TRUE -> Value.TRUE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TRUE -> Known.TRUE + else -> + throw ImageKitInvalidDataException("Unknown AiRemoveBackgroundExternal: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asBoolean(): Boolean = + _value().asBoolean().orElseThrow { + ImageKitInvalidDataException("Value is not a Boolean") + } + + private var validated: Boolean = false + + fun validate(): AiRemoveBackgroundExternal = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiRemoveBackgroundExternal && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Performs AI-based retouching to improve faces or product shots. Not supported inside overlay. + * See [AI Retouch](https://imagekit.io/docs/ai-transformations#retouch-e-retouch). + */ + class AiRetouch @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TRUE = of(true) + + @JvmStatic fun of(value: Boolean) = AiRetouch(JsonField.of(value)) + } + + /** An enum containing [AiRetouch]'s known values. */ + enum class Known { + TRUE + } + + /** + * An enum containing [AiRetouch]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AiRetouch] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TRUE, + /** + * An enum member indicating that [AiRetouch] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TRUE -> Value.TRUE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TRUE -> Known.TRUE + else -> throw ImageKitInvalidDataException("Unknown AiRetouch: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asBoolean(): Boolean = + _value().asBoolean().orElseThrow { + ImageKitInvalidDataException("Value is not a Boolean") + } + + private var validated: Boolean = false + + fun validate(): AiRetouch = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiRetouch && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Upscales images beyond their original dimensions using AI. Not supported inside overlay. See + * [AI Upscale](https://imagekit.io/docs/ai-transformations#upscale-e-upscale). + */ + class AiUpscale @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TRUE = of(true) + + @JvmStatic fun of(value: Boolean) = AiUpscale(JsonField.of(value)) + } + + /** An enum containing [AiUpscale]'s known values. */ + enum class Known { + TRUE + } + + /** + * An enum containing [AiUpscale]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AiUpscale] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TRUE, + /** + * An enum member indicating that [AiUpscale] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TRUE -> Value.TRUE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TRUE -> Known.TRUE + else -> throw ImageKitInvalidDataException("Unknown AiUpscale: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asBoolean(): Boolean = + _value().asBoolean().orElseThrow { + ImageKitInvalidDataException("Value is not a Boolean") + } + + private var validated: Boolean = false + + fun validate(): AiUpscale = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiUpscale && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Generates a variation of an image using AI. This produces a new image with slight variations + * from the original, such as changes in color, texture, and other visual elements, while + * preserving the structure and essence of the original image. Not supported inside overlay. See + * [AI Generate Variations](https://imagekit.io/docs/ai-transformations#generate-variations-of-an-image-e-genvar). + */ + class AiVariation @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TRUE = of(true) + + @JvmStatic fun of(value: Boolean) = AiVariation(JsonField.of(value)) + } + + /** An enum containing [AiVariation]'s known values. */ + enum class Known { + TRUE + } + + /** + * An enum containing [AiVariation]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AiVariation] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TRUE, + /** + * An enum member indicating that [AiVariation] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TRUE -> Value.TRUE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TRUE -> Known.TRUE + else -> throw ImageKitInvalidDataException("Unknown AiVariation: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asBoolean(): Boolean = + _value().asBoolean().orElseThrow { + ImageKitInvalidDataException("Value is not a Boolean") + } + + private var validated: Boolean = false + + fun validate(): AiVariation = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiVariation && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Specifies the aspect ratio for the output, e.g., "ar-4-3". Typically used with either width + * or height (but not both). For example: aspectRatio = `4:3`, `4_3`, or an expression like + * `iar_div_2`. See + * [Image resize and crop – Aspect ratio](https://imagekit.io/docs/image-resize-and-crop#aspect-ratio---ar). + */ + @JsonDeserialize(using = AspectRatio.Deserializer::class) + @JsonSerialize(using = AspectRatio.Serializer::class) + class AspectRatio + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): AspectRatio = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AspectRatio && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "AspectRatio{number=$number}" + string != null -> "AspectRatio{string=$string}" + _json != null -> "AspectRatio{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AspectRatio") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = AspectRatio(number = number) + + @JvmStatic fun ofString(string: String) = AspectRatio(string = string) + } + + /** + * An interface that defines how to map each variant of [AspectRatio] to a value of type + * [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [AspectRatio] to a value of type [T]. + * + * An instance of [AspectRatio] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown AspectRatio: $json") + } + } + + internal class Deserializer : BaseDeserializer(AspectRatio::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AspectRatio { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + AspectRatio(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + AspectRatio(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> AspectRatio(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(AspectRatio::class) { + + override fun serialize( + value: AspectRatio, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AspectRatio") + } + } + } + } + + /** + * Specifies the audio codec, e.g., `aac`, `opus`, or `none`. See + * [Audio codec](https://imagekit.io/docs/video-optimization#audio-codec---ac). + */ + class AudioCodec @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AAC = of("aac") + + @JvmField val OPUS = of("opus") + + @JvmField val NONE = of("none") + + @JvmStatic fun of(value: String) = AudioCodec(JsonField.of(value)) + } + + /** An enum containing [AudioCodec]'s known values. */ + enum class Known { + AAC, + OPUS, + NONE, + } + + /** + * An enum containing [AudioCodec]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AudioCodec] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AAC, + OPUS, + NONE, + /** + * An enum member indicating that [AudioCodec] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AAC -> Value.AAC + OPUS -> Value.OPUS + NONE -> Value.NONE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AAC -> Known.AAC + OPUS -> Known.OPUS + NONE -> Known.NONE + else -> throw ImageKitInvalidDataException("Unknown AudioCodec: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AudioCodec = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AudioCodec && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Automatically enhances the contrast of an image (contrast stretch). See + * [Contrast Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). + */ + class ContrastStretch @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TRUE = of(true) + + @JvmStatic fun of(value: Boolean) = ContrastStretch(JsonField.of(value)) + } + + /** An enum containing [ContrastStretch]'s known values. */ + enum class Known { + TRUE + } + + /** + * An enum containing [ContrastStretch]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ContrastStretch] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TRUE, + /** + * An enum member indicating that [ContrastStretch] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TRUE -> Value.TRUE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TRUE -> Known.TRUE + else -> throw ImageKitInvalidDataException("Unknown ContrastStretch: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asBoolean(): Boolean = + _value().asBoolean().orElseThrow { + ImageKitInvalidDataException("Value is not a Boolean") + } + + private var validated: Boolean = false + + fun validate(): ContrastStretch = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ContrastStretch && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Crop modes for image resizing. See + * [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + */ + class Crop @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val FORCE = of("force") + + @JvmField val AT_MAX = of("at_max") + + @JvmField val AT_MAX_ENLARGE = of("at_max_enlarge") + + @JvmField val AT_LEAST = of("at_least") + + @JvmField val MAINTAIN_RATIO = of("maintain_ratio") + + @JvmStatic fun of(value: String) = Crop(JsonField.of(value)) + } + + /** An enum containing [Crop]'s known values. */ + enum class Known { + FORCE, + AT_MAX, + AT_MAX_ENLARGE, + AT_LEAST, + MAINTAIN_RATIO, + } + + /** + * An enum containing [Crop]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Crop] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FORCE, + AT_MAX, + AT_MAX_ENLARGE, + AT_LEAST, + MAINTAIN_RATIO, + /** An enum member indicating that [Crop] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FORCE -> Value.FORCE + AT_MAX -> Value.AT_MAX + AT_MAX_ENLARGE -> Value.AT_MAX_ENLARGE + AT_LEAST -> Value.AT_LEAST + MAINTAIN_RATIO -> Value.MAINTAIN_RATIO + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + FORCE -> Known.FORCE + AT_MAX -> Known.AT_MAX + AT_MAX_ENLARGE -> Known.AT_MAX_ENLARGE + AT_LEAST -> Known.AT_LEAST + MAINTAIN_RATIO -> Known.MAINTAIN_RATIO + else -> throw ImageKitInvalidDataException("Unknown Crop: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Crop = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Crop && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Additional crop modes for image resizing. See + * [Crop modes & focus](https://imagekit.io/docs/image-resize-and-crop#crop-crop-modes--focus). + */ + class CropMode @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PAD_RESIZE = of("pad_resize") + + @JvmField val EXTRACT = of("extract") + + @JvmField val PAD_EXTRACT = of("pad_extract") + + @JvmStatic fun of(value: String) = CropMode(JsonField.of(value)) + } + + /** An enum containing [CropMode]'s known values. */ + enum class Known { + PAD_RESIZE, + EXTRACT, + PAD_EXTRACT, + } + + /** + * An enum containing [CropMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [CropMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PAD_RESIZE, + EXTRACT, + PAD_EXTRACT, + /** An enum member indicating that [CropMode] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PAD_RESIZE -> Value.PAD_RESIZE + EXTRACT -> Value.EXTRACT + PAD_EXTRACT -> Value.PAD_EXTRACT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PAD_RESIZE -> Known.PAD_RESIZE + EXTRACT -> Known.EXTRACT + PAD_EXTRACT -> Known.PAD_EXTRACT + else -> throw ImageKitInvalidDataException("Unknown CropMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CropMode = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CropMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. Typically used + * with startOffset to indicate the length from the start offset. Arithmetic expressions are + * supported. See [Trim videos – Duration](https://imagekit.io/docs/trim-videos#duration---du). + */ + @JsonDeserialize(using = Duration.Deserializer::class) + @JsonSerialize(using = Duration.Serializer::class) + class Duration + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Duration = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Duration && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "Duration{number=$number}" + string != null -> "Duration{string=$string}" + _json != null -> "Duration{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Duration") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Duration(number = number) + + @JvmStatic fun ofString(string: String) = Duration(string = string) + } + + /** + * An interface that defines how to map each variant of [Duration] to a value of type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Duration] to a value of type [T]. + * + * An instance of [Duration] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Duration: $json") + } + } + + internal class Deserializer : BaseDeserializer(Duration::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Duration { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Duration(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Duration(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Duration(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Duration::class) { + + override fun serialize( + value: Duration, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Duration") + } + } + } + } + + /** + * Specifies the end offset (in seconds) for trimming videos, e.g., `5` or `10.5`. Typically + * used with startOffset to define a time window. Arithmetic expressions are supported. See + * [Trim videos – End offset](https://imagekit.io/docs/trim-videos#end-offset---eo). + */ + @JsonDeserialize(using = EndOffset.Deserializer::class) + @JsonSerialize(using = EndOffset.Serializer::class) + class EndOffset + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): EndOffset = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EndOffset && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "EndOffset{number=$number}" + string != null -> "EndOffset{string=$string}" + _json != null -> "EndOffset{_unknown=$_json}" + else -> throw IllegalStateException("Invalid EndOffset") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = EndOffset(number = number) + + @JvmStatic fun ofString(string: String) = EndOffset(string = string) + } + + /** + * An interface that defines how to map each variant of [EndOffset] to a value of type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [EndOffset] to a value of type [T]. + * + * An instance of [EndOffset] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown EndOffset: $json") + } + } + + internal class Deserializer : BaseDeserializer(EndOffset::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): EndOffset { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + EndOffset(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + EndOffset(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> EndOffset(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(EndOffset::class) { + + override fun serialize( + value: EndOffset, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid EndOffset") + } + } + } + } + + /** + * Flips or mirrors an image either horizontally, vertically, or both. Acceptable values: `h` + * (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or `v_h`. See + * [Flip](https://imagekit.io/docs/effects-and-enhancements#flip---fl). + */ + class Flip @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val H = of("h") + + @JvmField val V = of("v") + + @JvmField val H_V = of("h_v") + + @JvmField val V_H = of("v_h") + + @JvmStatic fun of(value: String) = Flip(JsonField.of(value)) + } + + /** An enum containing [Flip]'s known values. */ + enum class Known { + H, + V, + H_V, + V_H, + } + + /** + * An enum containing [Flip]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Flip] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + H, + V, + H_V, + V_H, + /** An enum member indicating that [Flip] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + H -> Value.H + V -> Value.V + H_V -> Value.H_V + V_H -> Value.V_H + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + H -> Known.H + V -> Known.V + H_V -> Known.H_V + V_H -> Known.V_H + else -> throw ImageKitInvalidDataException("Unknown Flip: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Flip = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Flip && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Specifies the output format for images or videos, e.g., `jpg`, `png`, `webp`, `mp4`, or + * `auto`. You can also pass `orig` for images to return the original format. ImageKit + * automatically delivers images and videos in the optimal format based on device support unless + * overridden by the dashboard settings or the format parameter. See + * [Image format](https://imagekit.io/docs/image-optimization#format---f) and + * [Video format](https://imagekit.io/docs/video-optimization#format---f). + */ + class Format @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AUTO = of("auto") + + @JvmField val WEBP = of("webp") + + @JvmField val JPG = of("jpg") + + @JvmField val JPEG = of("jpeg") + + @JvmField val PNG = of("png") + + @JvmField val GIF = of("gif") + + @JvmField val SVG = of("svg") + + @JvmField val MP4 = of("mp4") + + @JvmField val WEBM = of("webm") + + @JvmField val AVIF = of("avif") + + @JvmField val ORIG = of("orig") + + @JvmStatic fun of(value: String) = Format(JsonField.of(value)) + } + + /** An enum containing [Format]'s known values. */ + enum class Known { + AUTO, + WEBP, + JPG, + JPEG, + PNG, + GIF, + SVG, + MP4, + WEBM, + AVIF, + ORIG, + } + + /** + * An enum containing [Format]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Format] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AUTO, + WEBP, + JPG, + JPEG, + PNG, + GIF, + SVG, + MP4, + WEBM, + AVIF, + ORIG, + /** An enum member indicating that [Format] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + WEBP -> Value.WEBP + JPG -> Value.JPG + JPEG -> Value.JPEG + PNG -> Value.PNG + GIF -> Value.GIF + SVG -> Value.SVG + MP4 -> Value.MP4 + WEBM -> Value.WEBM + AVIF -> Value.AVIF + ORIG -> Value.ORIG + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + WEBP -> Known.WEBP + JPG -> Known.JPG + JPEG -> Known.JPEG + PNG -> Known.PNG + GIF -> Known.GIF + SVG -> Known.SVG + MP4 -> Known.MP4 + WEBM -> Known.WEBM + AVIF -> Known.AVIF + ORIG -> Known.ORIG + else -> throw ImageKitInvalidDataException("Unknown Format: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Format = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Format && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Creates a linear gradient with two colors. Pass `true` for a default gradient, or provide a + * string for a custom gradient. See + * [Gradient](https://imagekit.io/docs/effects-and-enhancements#gradient---e-gradient). + */ + @JsonDeserialize(using = Gradient.Deserializer::class) + @JsonSerialize(using = Gradient.Serializer::class) + class Gradient + private constructor( + private val true_: JsonValue? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun true_(): Optional = Optional.ofNullable(true_) + + fun string(): Optional = Optional.ofNullable(string) + + fun isTrue(): Boolean = true_ != null + + fun isString(): Boolean = string != null + + fun asTrue(): JsonValue = true_.getOrThrow("true_") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + true_ != null -> visitor.visitTrue(true_) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Gradient = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTrue(true_: JsonValue) { + true_.let { + if (it != JsonValue.from(true)) { + throw ImageKitInvalidDataException( + "'true_' is invalid, received $it" + ) + } + } + } + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitTrue(true_: JsonValue) = + true_.let { if (it == JsonValue.from(true)) 1 else 0 } + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Gradient && true_ == other.true_ && string == other.string + } + + override fun hashCode(): Int = Objects.hash(true_, string) + + override fun toString(): String = + when { + true_ != null -> "Gradient{true_=$true_}" + string != null -> "Gradient{string=$string}" + _json != null -> "Gradient{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Gradient") + } + + companion object { + + @JvmStatic fun ofTrue() = Gradient(true_ = JsonValue.from(true)) + + @JvmStatic fun ofString(string: String) = Gradient(string = string) + } + + /** + * An interface that defines how to map each variant of [Gradient] to a value of type [T]. + */ + interface Visitor { + + fun visitTrue(true_: JsonValue): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Gradient] to a value of type [T]. + * + * An instance of [Gradient] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Gradient: $json") + } + } + + internal class Deserializer : BaseDeserializer(Gradient::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Gradient { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Gradient(true_ = it, _json = json) } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef())?.let { + Gradient(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Gradient(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Gradient::class) { + + override fun serialize( + value: Gradient, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.true_ != null -> generator.writeObject(value.true_) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Gradient") + } + } + } + } + + /** + * Enables a grayscale effect for images. See + * [Grayscale](https://imagekit.io/docs/effects-and-enhancements#grayscale---e-grayscale). + */ + class Grayscale @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TRUE = of(true) + + @JvmStatic fun of(value: Boolean) = Grayscale(JsonField.of(value)) + } + + /** An enum containing [Grayscale]'s known values. */ + enum class Known { + TRUE + } + + /** + * An enum containing [Grayscale]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Grayscale] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TRUE, + /** + * An enum member indicating that [Grayscale] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TRUE -> Value.TRUE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TRUE -> Known.TRUE + else -> throw ImageKitInvalidDataException("Unknown Grayscale: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asBoolean(): Boolean = + _value().asBoolean().orElseThrow { + ImageKitInvalidDataException("Value is not a Boolean") + } + + private var validated: Boolean = false + + fun validate(): Grayscale = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Grayscale && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Specifies the height of the output. If a value between 0 and 1 is provided, it is treated as + * a percentage (e.g., `0.5` represents 50% of the original height). You can also supply + * arithmetic expressions (e.g., `ih_mul_0.5`). Height transformation – + * [Images](https://imagekit.io/docs/image-resize-and-crop#height---h) · + * [Videos](https://imagekit.io/docs/video-resize-and-crop#height---h) + */ + @JsonDeserialize(using = Height.Deserializer::class) + @JsonSerialize(using = Height.Serializer::class) + class Height + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Height = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Height && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "Height{number=$number}" + string != null -> "Height{string=$string}" + _json != null -> "Height{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Height") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Height(number = number) + + @JvmStatic fun ofString(string: String) = Height(string = string) + } + + /** An interface that defines how to map each variant of [Height] to a value of type [T]. */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Height] to a value of type [T]. + * + * An instance of [Height] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Height: $json") + } + } + + internal class Deserializer : BaseDeserializer(Height::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Height { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Height(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Height(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Height(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Height::class) { + + override fun serialize( + value: Height, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Height") + } + } + } + } + + /** + * Extracts a specific page or frame from multi-page or layered files (PDF, PSD, AI). For + * example, specify by number (e.g., `2`), a range (e.g., `3-4` for the 2nd and 3rd layers), or + * by name (e.g., `name-layer-4` for a PSD layer). See + * [Thumbnail extraction](https://imagekit.io/docs/vector-and-animated-images#get-thumbnail-from-psd-pdf-ai-eps-and-animated-files). + */ + @JsonDeserialize(using = Page.Deserializer::class) + @JsonSerialize(using = Page.Serializer::class) + class Page + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Page = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Page && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "Page{number=$number}" + string != null -> "Page{string=$string}" + _json != null -> "Page{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Page") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Page(number = number) + + @JvmStatic fun ofString(string: String) = Page(string = string) + } + + /** An interface that defines how to map each variant of [Page] to a value of type [T]. */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Page] to a value of type [T]. + * + * An instance of [Page] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Page: $json") + } + } + + internal class Deserializer : BaseDeserializer(Page::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Page { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Page(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Page(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Page(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Page::class) { + + override fun serialize( + value: Page, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Page") + } + } + } + } + + /** + * Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular or oval + * shape. See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + */ + @JsonDeserialize(using = Radius.Deserializer::class) + @JsonSerialize(using = Radius.Serializer::class) + class Radius + private constructor( + private val number: Double? = null, + private val max: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun max(): Optional = Optional.ofNullable(max) + + fun isNumber(): Boolean = number != null + + fun isMax(): Boolean = max != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asMax(): JsonValue = max.getOrThrow("max") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + max != null -> visitor.visitMax(max) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Radius = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitMax(max: JsonValue) { + max.let { + if (it != JsonValue.from("max")) { + throw ImageKitInvalidDataException("'max' is invalid, received $it") + } + } + } + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitMax(max: JsonValue) = + max.let { if (it == JsonValue.from("max")) 1 else 0 } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Radius && number == other.number && max == other.max + } + + override fun hashCode(): Int = Objects.hash(number, max) + + override fun toString(): String = + when { + number != null -> "Radius{number=$number}" + max != null -> "Radius{max=$max}" + _json != null -> "Radius{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Radius") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Radius(number = number) + + @JvmStatic fun ofMax() = Radius(max = JsonValue.from("max")) + } + + /** An interface that defines how to map each variant of [Radius] to a value of type [T]. */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitMax(max: JsonValue): T + + /** + * Maps an unknown variant of [Radius] to a value of type [T]. + * + * An instance of [Radius] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Radius: $json") + } + } + + internal class Deserializer : BaseDeserializer(Radius::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Radius { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Radius(max = it, _json = json) } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef())?.let { + Radius(number = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Radius(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Radius::class) { + + override fun serialize( + value: Radius, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.max != null -> generator.writeObject(value.max) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Radius") + } + } + } + } + + /** + * Specifies the rotation angle in degrees. Positive values rotate the image clockwise; you can + * also use, for example, `N40` for counterclockwise rotation or `auto` to use the orientation + * specified in the image's EXIF data. For videos, only the following values are supported: 0, + * 90, 180, 270, or 360. See + * [Rotate](https://imagekit.io/docs/effects-and-enhancements#rotate---rt). + */ + @JsonDeserialize(using = Rotation.Deserializer::class) + @JsonSerialize(using = Rotation.Serializer::class) + class Rotation + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Rotation = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Rotation && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "Rotation{number=$number}" + string != null -> "Rotation{string=$string}" + _json != null -> "Rotation{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Rotation") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Rotation(number = number) + + @JvmStatic fun ofString(string: String) = Rotation(string = string) + } + + /** + * An interface that defines how to map each variant of [Rotation] to a value of type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Rotation] to a value of type [T]. + * + * An instance of [Rotation] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Rotation: $json") + } + } + + internal class Deserializer : BaseDeserializer(Rotation::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Rotation { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Rotation(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Rotation(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Rotation(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Rotation::class) { + + override fun serialize( + value: Rotation, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Rotation") + } + } + } + } + + /** + * Adds a shadow beneath solid objects in an image with a transparent background. For AI-based + * drop shadows, refer to aiDropShadow. Pass `true` for a default shadow, or provide a string + * for a custom shadow. See + * [Shadow](https://imagekit.io/docs/effects-and-enhancements#shadow---e-shadow). + */ + @JsonDeserialize(using = Shadow.Deserializer::class) + @JsonSerialize(using = Shadow.Serializer::class) + class Shadow + private constructor( + private val true_: JsonValue? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun true_(): Optional = Optional.ofNullable(true_) + + fun string(): Optional = Optional.ofNullable(string) + + fun isTrue(): Boolean = true_ != null + + fun isString(): Boolean = string != null + + fun asTrue(): JsonValue = true_.getOrThrow("true_") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + true_ != null -> visitor.visitTrue(true_) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Shadow = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTrue(true_: JsonValue) { + true_.let { + if (it != JsonValue.from(true)) { + throw ImageKitInvalidDataException( + "'true_' is invalid, received $it" + ) + } + } + } + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitTrue(true_: JsonValue) = + true_.let { if (it == JsonValue.from(true)) 1 else 0 } + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Shadow && true_ == other.true_ && string == other.string + } + + override fun hashCode(): Int = Objects.hash(true_, string) + + override fun toString(): String = + when { + true_ != null -> "Shadow{true_=$true_}" + string != null -> "Shadow{string=$string}" + _json != null -> "Shadow{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Shadow") + } + + companion object { + + @JvmStatic fun ofTrue() = Shadow(true_ = JsonValue.from(true)) + + @JvmStatic fun ofString(string: String) = Shadow(string = string) + } + + /** An interface that defines how to map each variant of [Shadow] to a value of type [T]. */ + interface Visitor { + + fun visitTrue(true_: JsonValue): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Shadow] to a value of type [T]. + * + * An instance of [Shadow] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Shadow: $json") + } + } + + internal class Deserializer : BaseDeserializer(Shadow::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Shadow { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Shadow(true_ = it, _json = json) } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef())?.let { + Shadow(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Shadow(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Shadow::class) { + + override fun serialize( + value: Shadow, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.true_ != null -> generator.writeObject(value.true_) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Shadow") + } + } + } + } + + /** + * Sharpens the input image, highlighting edges and finer details. Pass `true` for default + * sharpening, or provide a numeric value for custom sharpening. See + * [Sharpen](https://imagekit.io/docs/effects-and-enhancements#sharpen---e-sharpen). + */ + @JsonDeserialize(using = Sharpen.Deserializer::class) + @JsonSerialize(using = Sharpen.Serializer::class) + class Sharpen + private constructor( + private val true_: JsonValue? = null, + private val number: Double? = null, + private val _json: JsonValue? = null, + ) { + + fun true_(): Optional = Optional.ofNullable(true_) + + fun number(): Optional = Optional.ofNullable(number) + + fun isTrue(): Boolean = true_ != null + + fun isNumber(): Boolean = number != null + + fun asTrue(): JsonValue = true_.getOrThrow("true_") + + fun asNumber(): Double = number.getOrThrow("number") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + true_ != null -> visitor.visitTrue(true_) + number != null -> visitor.visitNumber(number) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Sharpen = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTrue(true_: JsonValue) { + true_.let { + if (it != JsonValue.from(true)) { + throw ImageKitInvalidDataException( + "'true_' is invalid, received $it" + ) + } + } + } + + override fun visitNumber(number: Double) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitTrue(true_: JsonValue) = + true_.let { if (it == JsonValue.from(true)) 1 else 0 } + + override fun visitNumber(number: Double) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Sharpen && true_ == other.true_ && number == other.number + } + + override fun hashCode(): Int = Objects.hash(true_, number) + + override fun toString(): String = + when { + true_ != null -> "Sharpen{true_=$true_}" + number != null -> "Sharpen{number=$number}" + _json != null -> "Sharpen{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Sharpen") + } + + companion object { + + @JvmStatic fun ofTrue() = Sharpen(true_ = JsonValue.from(true)) + + @JvmStatic fun ofNumber(number: Double) = Sharpen(number = number) + } + + /** + * An interface that defines how to map each variant of [Sharpen] to a value of type [T]. + */ + interface Visitor { + + fun visitTrue(true_: JsonValue): T + + fun visitNumber(number: Double): T + + /** + * Maps an unknown variant of [Sharpen] to a value of type [T]. + * + * An instance of [Sharpen] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Sharpen: $json") + } + } + + internal class Deserializer : BaseDeserializer(Sharpen::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Sharpen { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Sharpen(true_ = it, _json = json) } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef())?.let { + Sharpen(number = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from string). + 0 -> Sharpen(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Sharpen::class) { + + override fun serialize( + value: Sharpen, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.true_ != null -> generator.writeObject(value.true_) + value.number != null -> generator.writeObject(value.number) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Sharpen") + } + } + } + } + + /** + * Specifies the start offset (in seconds) for trimming videos, e.g., `5` or `10.5`. Arithmetic + * expressions are also supported. See + * [Trim videos – Start offset](https://imagekit.io/docs/trim-videos#start-offset---so). + */ + @JsonDeserialize(using = StartOffset.Deserializer::class) + @JsonSerialize(using = StartOffset.Serializer::class) + class StartOffset + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): StartOffset = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StartOffset && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "StartOffset{number=$number}" + string != null -> "StartOffset{string=$string}" + _json != null -> "StartOffset{_unknown=$_json}" + else -> throw IllegalStateException("Invalid StartOffset") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = StartOffset(number = number) + + @JvmStatic fun ofString(string: String) = StartOffset(string = string) + } + + /** + * An interface that defines how to map each variant of [StartOffset] to a value of type + * [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [StartOffset] to a value of type [T]. + * + * An instance of [StartOffset] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown StartOffset: $json") + } + } + + internal class Deserializer : BaseDeserializer(StartOffset::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): StartOffset { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + StartOffset(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + StartOffset(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> StartOffset(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(StartOffset::class) { + + override fun serialize( + value: StartOffset, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid StartOffset") + } + } + } + } + + /** + * Useful for images with a solid or nearly solid background and a central object. This + * parameter trims the background, leaving only the central object in the output image. See + * [Trim edges](https://imagekit.io/docs/effects-and-enhancements#trim-edges---t). + */ + @JsonDeserialize(using = Trim.Deserializer::class) + @JsonSerialize(using = Trim.Serializer::class) + class Trim + private constructor( + private val true_: JsonValue? = null, + private val number: Double? = null, + private val _json: JsonValue? = null, + ) { + + fun true_(): Optional = Optional.ofNullable(true_) + + fun number(): Optional = Optional.ofNullable(number) + + fun isTrue(): Boolean = true_ != null + + fun isNumber(): Boolean = number != null + + fun asTrue(): JsonValue = true_.getOrThrow("true_") + + fun asNumber(): Double = number.getOrThrow("number") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + true_ != null -> visitor.visitTrue(true_) + number != null -> visitor.visitNumber(number) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Trim = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTrue(true_: JsonValue) { + true_.let { + if (it != JsonValue.from(true)) { + throw ImageKitInvalidDataException( + "'true_' is invalid, received $it" + ) + } + } + } + + override fun visitNumber(number: Double) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitTrue(true_: JsonValue) = + true_.let { if (it == JsonValue.from(true)) 1 else 0 } + + override fun visitNumber(number: Double) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Trim && true_ == other.true_ && number == other.number + } + + override fun hashCode(): Int = Objects.hash(true_, number) + + override fun toString(): String = + when { + true_ != null -> "Trim{true_=$true_}" + number != null -> "Trim{number=$number}" + _json != null -> "Trim{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Trim") + } + + companion object { + + @JvmStatic fun ofTrue() = Trim(true_ = JsonValue.from(true)) + + @JvmStatic fun ofNumber(number: Double) = Trim(number = number) + } + + /** An interface that defines how to map each variant of [Trim] to a value of type [T]. */ + interface Visitor { + + fun visitTrue(true_: JsonValue): T + + fun visitNumber(number: Double): T + + /** + * Maps an unknown variant of [Trim] to a value of type [T]. + * + * An instance of [Trim] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Trim: $json") + } + } + + internal class Deserializer : BaseDeserializer(Trim::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Trim { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Trim(true_ = it, _json = json) } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef())?.let { + Trim(number = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from string). + 0 -> Trim(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Trim::class) { + + override fun serialize( + value: Trim, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.true_ != null -> generator.writeObject(value.true_) + value.number != null -> generator.writeObject(value.number) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Trim") + } + } + } + } + + /** + * Applies Unsharp Masking (USM), an image sharpening technique. Pass `true` for a default + * unsharp mask, or provide a string for a custom unsharp mask. See + * [Unsharp Mask](https://imagekit.io/docs/effects-and-enhancements#unsharp-mask---e-usm). + */ + @JsonDeserialize(using = UnsharpMask.Deserializer::class) + @JsonSerialize(using = UnsharpMask.Serializer::class) + class UnsharpMask + private constructor( + private val true_: JsonValue? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun true_(): Optional = Optional.ofNullable(true_) + + fun string(): Optional = Optional.ofNullable(string) + + fun isTrue(): Boolean = true_ != null + + fun isString(): Boolean = string != null + + fun asTrue(): JsonValue = true_.getOrThrow("true_") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + true_ != null -> visitor.visitTrue(true_) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnsharpMask = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTrue(true_: JsonValue) { + true_.let { + if (it != JsonValue.from(true)) { + throw ImageKitInvalidDataException( + "'true_' is invalid, received $it" + ) + } + } + } + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitTrue(true_: JsonValue) = + true_.let { if (it == JsonValue.from(true)) 1 else 0 } + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnsharpMask && true_ == other.true_ && string == other.string + } + + override fun hashCode(): Int = Objects.hash(true_, string) + + override fun toString(): String = + when { + true_ != null -> "UnsharpMask{true_=$true_}" + string != null -> "UnsharpMask{string=$string}" + _json != null -> "UnsharpMask{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnsharpMask") + } + + companion object { + + @JvmStatic fun ofTrue() = UnsharpMask(true_ = JsonValue.from(true)) + + @JvmStatic fun ofString(string: String) = UnsharpMask(string = string) + } + + /** + * An interface that defines how to map each variant of [UnsharpMask] to a value of type + * [T]. + */ + interface Visitor { + + fun visitTrue(true_: JsonValue): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [UnsharpMask] to a value of type [T]. + * + * An instance of [UnsharpMask] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown UnsharpMask: $json") + } + } + + internal class Deserializer : BaseDeserializer(UnsharpMask::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): UnsharpMask { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { UnsharpMask(true_ = it, _json = json) } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnsharpMask(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> UnsharpMask(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(UnsharpMask::class) { + + override fun serialize( + value: UnsharpMask, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.true_ != null -> generator.writeObject(value.true_) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid UnsharpMask") + } + } + } + } + + /** + * Specifies the video codec, e.g., `h264`, `vp9`, `av1`, or `none`. See + * [Video codec](https://imagekit.io/docs/video-optimization#video-codec---vc). + */ + class VideoCodec @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val H264 = of("h264") + + @JvmField val VP9 = of("vp9") + + @JvmField val AV1 = of("av1") + + @JvmField val NONE = of("none") + + @JvmStatic fun of(value: String) = VideoCodec(JsonField.of(value)) + } + + /** An enum containing [VideoCodec]'s known values. */ + enum class Known { + H264, + VP9, + AV1, + NONE, + } + + /** + * An enum containing [VideoCodec]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [VideoCodec] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + H264, + VP9, + AV1, + NONE, + /** + * An enum member indicating that [VideoCodec] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + H264 -> Value.H264 + VP9 -> Value.VP9 + AV1 -> Value.AV1 + NONE -> Value.NONE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + H264 -> Known.H264 + VP9 -> Known.VP9 + AV1 -> Known.AV1 + NONE -> Known.NONE + else -> throw ImageKitInvalidDataException("Unknown VideoCodec: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): VideoCodec = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VideoCodec && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Specifies the width of the output. If a value between 0 and 1 is provided, it is treated as a + * percentage (e.g., `0.4` represents 40% of the original width). You can also supply arithmetic + * expressions (e.g., `iw_div_2`). Width transformation – + * [Images](https://imagekit.io/docs/image-resize-and-crop#width---w) · + * [Videos](https://imagekit.io/docs/video-resize-and-crop#width---w) + */ + @JsonDeserialize(using = Width.Deserializer::class) + @JsonSerialize(using = Width.Serializer::class) + class Width + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Width = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Width && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "Width{number=$number}" + string != null -> "Width{string=$string}" + _json != null -> "Width{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Width") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Width(number = number) + + @JvmStatic fun ofString(string: String) = Width(string = string) + } + + /** An interface that defines how to map each variant of [Width] to a value of type [T]. */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Width] to a value of type [T]. + * + * An instance of [Width] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Width: $json") + } + } + + internal class Deserializer : BaseDeserializer(Width::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Width { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Width(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Width(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Width(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Width::class) { + + override fun serialize( + value: Width, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Width") + } + } + } + } + + /** + * Focus using cropped image coordinates - X coordinate. See + * [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + */ + @JsonDeserialize(using = X.Deserializer::class) + @JsonSerialize(using = X.Serializer::class) + class X + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): X = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is X && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "X{number=$number}" + string != null -> "X{string=$string}" + _json != null -> "X{_unknown=$_json}" + else -> throw IllegalStateException("Invalid X") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = X(number = number) + + @JvmStatic fun ofString(string: String) = X(string = string) + } + + /** An interface that defines how to map each variant of [X] to a value of type [T]. */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [X] to a value of type [T]. + * + * An instance of [X] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown X: $json") + } + } + + internal class Deserializer : BaseDeserializer(X::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): X { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + X(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + X(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> X(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(X::class) { + + override fun serialize( + value: X, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid X") + } + } + } + } + + /** + * Focus using cropped image coordinates - X center coordinate. See + * [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + */ + @JsonDeserialize(using = XCenter.Deserializer::class) + @JsonSerialize(using = XCenter.Serializer::class) + class XCenter + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): XCenter = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is XCenter && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "XCenter{number=$number}" + string != null -> "XCenter{string=$string}" + _json != null -> "XCenter{_unknown=$_json}" + else -> throw IllegalStateException("Invalid XCenter") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = XCenter(number = number) + + @JvmStatic fun ofString(string: String) = XCenter(string = string) + } + + /** + * An interface that defines how to map each variant of [XCenter] to a value of type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [XCenter] to a value of type [T]. + * + * An instance of [XCenter] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown XCenter: $json") + } + } + + internal class Deserializer : BaseDeserializer(XCenter::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): XCenter { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + XCenter(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + XCenter(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> XCenter(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(XCenter::class) { + + override fun serialize( + value: XCenter, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid XCenter") + } + } + } + } + + /** + * Focus using cropped image coordinates - Y coordinate. See + * [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + */ + @JsonDeserialize(using = Y.Deserializer::class) + @JsonSerialize(using = Y.Serializer::class) + class Y + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Y = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Y && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "Y{number=$number}" + string != null -> "Y{string=$string}" + _json != null -> "Y{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Y") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Y(number = number) + + @JvmStatic fun ofString(string: String) = Y(string = string) + } + + /** An interface that defines how to map each variant of [Y] to a value of type [T]. */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Y] to a value of type [T]. + * + * An instance of [Y] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Y: $json") + } + } + + internal class Deserializer : BaseDeserializer(Y::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Y { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Y(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Y(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Y(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Y::class) { + + override fun serialize( + value: Y, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Y") + } + } + } + } + + /** + * Focus using cropped image coordinates - Y center coordinate. See + * [Focus using cropped coordinates](https://imagekit.io/docs/image-resize-and-crop#example---focus-using-cropped-image-coordinates). + */ + @JsonDeserialize(using = YCenter.Deserializer::class) + @JsonSerialize(using = YCenter.Serializer::class) + class YCenter + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): YCenter = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is YCenter && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "YCenter{number=$number}" + string != null -> "YCenter{string=$string}" + _json != null -> "YCenter{_unknown=$_json}" + else -> throw IllegalStateException("Invalid YCenter") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = YCenter(number = number) + + @JvmStatic fun ofString(string: String) = YCenter(string = string) + } + + /** + * An interface that defines how to map each variant of [YCenter] to a value of type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [YCenter] to a value of type [T]. + * + * An instance of [YCenter] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown YCenter: $json") + } + } + + internal class Deserializer : BaseDeserializer(YCenter::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): YCenter { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + YCenter(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + YCenter(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> YCenter(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(YCenter::class) { + + override fun serialize( + value: YCenter, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid YCenter") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Transformation && + aiChangeBackground == other.aiChangeBackground && + aiDropShadow == other.aiDropShadow && + aiEdit == other.aiEdit && + aiRemoveBackground == other.aiRemoveBackground && + aiRemoveBackgroundExternal == other.aiRemoveBackgroundExternal && + aiRetouch == other.aiRetouch && + aiUpscale == other.aiUpscale && + aiVariation == other.aiVariation && + aspectRatio == other.aspectRatio && + audioCodec == other.audioCodec && + background == other.background && + blur == other.blur && + border == other.border && + colorProfile == other.colorProfile && + contrastStretch == other.contrastStretch && + crop == other.crop && + cropMode == other.cropMode && + defaultImage == other.defaultImage && + dpr == other.dpr && + duration == other.duration && + endOffset == other.endOffset && + flip == other.flip && + focus == other.focus && + format == other.format && + gradient == other.gradient && + grayscale == other.grayscale && + height == other.height && + lossless == other.lossless && + metadata == other.metadata && + named == other.named && + opacity == other.opacity && + original == other.original && + overlay == other.overlay && + page == other.page && + progressive == other.progressive && + quality == other.quality && + radius == other.radius && + raw == other.raw && + rotation == other.rotation && + shadow == other.shadow && + sharpen == other.sharpen && + startOffset == other.startOffset && + streamingResolutions == other.streamingResolutions && + trim == other.trim && + unsharpMask == other.unsharpMask && + videoCodec == other.videoCodec && + width == other.width && + x == other.x && + xCenter == other.xCenter && + y == other.y && + yCenter == other.yCenter && + zoom == other.zoom && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aiChangeBackground, + aiDropShadow, + aiEdit, + aiRemoveBackground, + aiRemoveBackgroundExternal, + aiRetouch, + aiUpscale, + aiVariation, + aspectRatio, + audioCodec, + background, + blur, + border, + colorProfile, + contrastStretch, + crop, + cropMode, + defaultImage, + dpr, + duration, + endOffset, + flip, + focus, + format, + gradient, + grayscale, + height, + lossless, + metadata, + named, + opacity, + original, + overlay, + page, + progressive, + quality, + radius, + raw, + rotation, + shadow, + sharpen, + startOffset, + streamingResolutions, + trim, + unsharpMask, + videoCodec, + width, + x, + xCenter, + y, + yCenter, + zoom, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Transformation{aiChangeBackground=$aiChangeBackground, aiDropShadow=$aiDropShadow, aiEdit=$aiEdit, aiRemoveBackground=$aiRemoveBackground, aiRemoveBackgroundExternal=$aiRemoveBackgroundExternal, aiRetouch=$aiRetouch, aiUpscale=$aiUpscale, aiVariation=$aiVariation, aspectRatio=$aspectRatio, audioCodec=$audioCodec, background=$background, blur=$blur, border=$border, colorProfile=$colorProfile, contrastStretch=$contrastStretch, crop=$crop, cropMode=$cropMode, defaultImage=$defaultImage, dpr=$dpr, duration=$duration, endOffset=$endOffset, flip=$flip, focus=$focus, format=$format, gradient=$gradient, grayscale=$grayscale, height=$height, lossless=$lossless, metadata=$metadata, named=$named, opacity=$opacity, original=$original, overlay=$overlay, page=$page, progressive=$progressive, quality=$quality, radius=$radius, raw=$raw, rotation=$rotation, shadow=$shadow, sharpen=$sharpen, startOffset=$startOffset, streamingResolutions=$streamingResolutions, trim=$trim, unsharpMask=$unsharpMask, videoCodec=$videoCodec, width=$width, x=$x, xCenter=$xCenter, y=$y, yCenter=$yCenter, zoom=$zoom, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TransformationPosition.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TransformationPosition.kt new file mode 100644 index 00000000..5a62532e --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TransformationPosition.kt @@ -0,0 +1,140 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonCreator +import com.imagekit.api.core.Enum +import com.imagekit.api.core.JsonField +import com.imagekit.api.errors.ImageKitInvalidDataException + +/** + * By default, the transformation string is added as a query parameter in the URL, e.g., + * `?tr=w-100,h-100`. If you want to add the transformation string in the path of the URL, set this + * to `path`. Learn more in the [Transformations guide](https://imagekit.io/docs/transformations). + */ +class TransformationPosition +@JsonCreator +private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PATH = of("path") + + @JvmField val QUERY = of("query") + + @JvmStatic fun of(value: String) = TransformationPosition(JsonField.of(value)) + } + + /** An enum containing [TransformationPosition]'s known values. */ + enum class Known { + PATH, + QUERY, + } + + /** + * An enum containing [TransformationPosition]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TransformationPosition] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PATH, + QUERY, + /** + * An enum member indicating that [TransformationPosition] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + PATH -> Value.PATH + QUERY -> Value.QUERY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + PATH -> Known.PATH + QUERY -> Known.QUERY + else -> throw ImageKitInvalidDataException("Unknown TransformationPosition: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { ImageKitInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): TransformationPosition = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TransformationPosition && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VideoOverlay.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VideoOverlay.kt new file mode 100644 index 00000000..2ca94d24 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VideoOverlay.kt @@ -0,0 +1,530 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class VideoOverlay +private constructor( + private val position: JsonField, + private val timing: JsonField, + private val input: JsonField, + private val type: JsonValue, + private val encoding: JsonField, + private val transformation: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("position") + @ExcludeMissing + position: JsonField = JsonMissing.of(), + @JsonProperty("timing") @ExcludeMissing timing: JsonField = JsonMissing.of(), + @JsonProperty("input") @ExcludeMissing input: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("encoding") @ExcludeMissing encoding: JsonField = JsonMissing.of(), + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField> = JsonMissing.of(), + ) : this(position, timing, input, type, encoding, transformation, mutableMapOf()) + + fun toBaseOverlay(): BaseOverlay = + BaseOverlay.builder().position(position).timing(timing).build() + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun position(): Optional = position.getOptional("position") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timing(): Optional = timing.getOptional("timing") + + /** + * Specifies the relative path to the video used as an overlay. + * + * @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 input(): String = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("video") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * The input path can be included in the layer as either `i-{input}` or + * `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate format + * automatically. To always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + * To always use plain text (`i-{input}`), set it to `plain`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun encoding(): Optional = encoding.getOptional("encoding") + + /** + * Array of transformation to be applied to the overlay video. Except `streamingResolutions`, + * all other video transformations are supported. See + * [Video transformations](https://imagekit.io/docs/video-transformation). + * + * @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 [position]. + * + * Unlike [position], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position + + /** + * Returns the raw JSON value of [timing]. + * + * Unlike [timing], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timing") @ExcludeMissing fun _timing(): JsonField = timing + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [encoding]. + * + * Unlike [encoding], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("encoding") @ExcludeMissing fun _encoding(): JsonField = encoding + + /** + * 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 [VideoOverlay]. + * + * The following fields are required: + * ```java + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VideoOverlay]. */ + class Builder internal constructor() { + + private var position: JsonField = JsonMissing.of() + private var timing: JsonField = JsonMissing.of() + private var input: JsonField? = null + private var type: JsonValue = JsonValue.from("video") + private var encoding: JsonField = JsonMissing.of() + private var transformation: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(videoOverlay: VideoOverlay) = apply { + position = videoOverlay.position + timing = videoOverlay.timing + input = videoOverlay.input + type = videoOverlay.type + encoding = videoOverlay.encoding + transformation = videoOverlay.transformation.map { it.toMutableList() } + additionalProperties = videoOverlay.additionalProperties.toMutableMap() + } + + fun position(position: OverlayPosition) = position(JsonField.of(position)) + + /** + * Sets [Builder.position] to an arbitrary JSON value. + * + * You should usually call [Builder.position] with a well-typed [OverlayPosition] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun position(position: JsonField) = apply { this.position = position } + + fun timing(timing: OverlayTiming) = timing(JsonField.of(timing)) + + /** + * Sets [Builder.timing] to an arbitrary JSON value. + * + * You should usually call [Builder.timing] with a well-typed [OverlayTiming] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun timing(timing: JsonField) = apply { this.timing = timing } + + /** Specifies the relative path to the video used as an overlay. */ + fun input(input: String) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("video") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * The input path can be included in the layer as either `i-{input}` or + * `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate format + * automatically. To always use base64 encoding (`ie-{base64}`), set this parameter to + * `base64`. To always use plain text (`i-{input}`), set it to `plain`. + */ + fun encoding(encoding: Encoding) = encoding(JsonField.of(encoding)) + + /** + * Sets [Builder.encoding] to an arbitrary JSON value. + * + * You should usually call [Builder.encoding] with a well-typed [Encoding] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun encoding(encoding: JsonField) = apply { this.encoding = encoding } + + /** + * Array of transformation to be applied to the overlay video. Except + * `streamingResolutions`, all other video transformations are supported. See + * [Video transformations](https://imagekit.io/docs/video-transformation). + */ + fun transformation(transformation: List) = + transformation(JsonField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary JSON value. + * + * You should usually call [Builder.transformation] with a well-typed `List` + * 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.map { it.toMutableList() } + } + + /** + * Adds a single [Transformation] to [Builder.transformation]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTransformation(transformation: Transformation) = apply { + this.transformation = + (this.transformation ?: JsonField.of(mutableListOf())).also { + checkKnown("transformation", it).add(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 [VideoOverlay]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VideoOverlay = + VideoOverlay( + position, + timing, + checkRequired("input", input), + type, + encoding, + (transformation ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): VideoOverlay = apply { + if (validated) { + return@apply + } + + position().ifPresent { it.validate() } + timing().ifPresent { it.validate() } + input() + _type().let { + if (it != JsonValue.from("video")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + encoding().ifPresent { it.validate() } + transformation().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (position.asKnown().getOrNull()?.validity() ?: 0) + + (timing.asKnown().getOrNull()?.validity() ?: 0) + + (if (input.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("video")) 1 else 0 } + + (encoding.asKnown().getOrNull()?.validity() ?: 0) + + (transformation.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** + * The input path can be included in the layer as either `i-{input}` or + * `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate format + * automatically. To always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. + * To always use plain text (`i-{input}`), set it to `plain`. + */ + class Encoding @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AUTO = of("auto") + + @JvmField val PLAIN = of("plain") + + @JvmField val BASE64 = of("base64") + + @JvmStatic fun of(value: String) = Encoding(JsonField.of(value)) + } + + /** An enum containing [Encoding]'s known values. */ + enum class Known { + AUTO, + PLAIN, + BASE64, + } + + /** + * An enum containing [Encoding]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Encoding] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AUTO, + PLAIN, + BASE64, + /** An enum member indicating that [Encoding] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AUTO -> Value.AUTO + PLAIN -> Value.PLAIN + BASE64 -> Value.BASE64 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AUTO -> Known.AUTO + PLAIN -> Known.PLAIN + BASE64 -> Known.BASE64 + else -> throw ImageKitInvalidDataException("Unknown Encoding: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Encoding = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Encoding && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VideoOverlay && + position == other.position && + timing == other.timing && + input == other.input && + type == other.type && + encoding == other.encoding && + transformation == other.transformation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(position, timing, input, type, encoding, transformation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VideoOverlay{position=$position, timing=$timing, input=$input, type=$type, encoding=$encoding, transformation=$transformation, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParams.kt new file mode 100644 index 00000000..85b329b8 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParams.kt @@ -0,0 +1,239 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.origins + +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import java.util.Objects + +/** **Note:** This API is currently in beta. Creates a new origin and returns the origin object. */ +class OriginCreateParams +private constructor( + private val origin: OriginRequest, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Schema for origin request resources. */ + fun origin(): OriginRequest = origin + + /** 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 [OriginCreateParams]. + * + * The following fields are required: + * ```java + * .origin() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OriginCreateParams]. */ + class Builder internal constructor() { + + private var origin: OriginRequest? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(originCreateParams: OriginCreateParams) = apply { + origin = originCreateParams.origin + additionalHeaders = originCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = originCreateParams.additionalQueryParams.toBuilder() + } + + /** Schema for origin request resources. */ + fun origin(origin: OriginRequest) = apply { this.origin = origin } + + /** Alias for calling [origin] with `OriginRequest.ofS3(s3)`. */ + fun origin(s3: OriginRequest.S3) = origin(OriginRequest.ofS3(s3)) + + /** Alias for calling [origin] with `OriginRequest.ofS3Compatible(s3Compatible)`. */ + fun origin(s3Compatible: OriginRequest.S3Compatible) = + origin(OriginRequest.ofS3Compatible(s3Compatible)) + + /** Alias for calling [origin] with `OriginRequest.ofCloudinaryBackup(cloudinaryBackup)`. */ + fun origin(cloudinaryBackup: OriginRequest.CloudinaryBackup) = + origin(OriginRequest.ofCloudinaryBackup(cloudinaryBackup)) + + /** Alias for calling [origin] with `OriginRequest.ofWebFolder(webFolder)`. */ + fun origin(webFolder: OriginRequest.WebFolder) = + origin(OriginRequest.ofWebFolder(webFolder)) + + /** Alias for calling [origin] with `OriginRequest.ofWebProxy(webProxy)`. */ + fun origin(webProxy: OriginRequest.WebProxy) = origin(OriginRequest.ofWebProxy(webProxy)) + + /** + * Alias for calling [origin] with the following: + * ```java + * OriginRequest.WebProxy.builder() + * .name(name) + * .build() + * ``` + */ + fun webProxyOrigin(name: String) = + origin(OriginRequest.WebProxy.builder().name(name).build()) + + /** Alias for calling [origin] with `OriginRequest.ofGcs(gcs)`. */ + fun origin(gcs: OriginRequest.Gcs) = origin(OriginRequest.ofGcs(gcs)) + + /** Alias for calling [origin] with `OriginRequest.ofAzureBlob(azureBlob)`. */ + fun origin(azureBlob: OriginRequest.AzureBlob) = + origin(OriginRequest.ofAzureBlob(azureBlob)) + + /** Alias for calling [origin] with `OriginRequest.ofAkeneoPim(akeneoPim)`. */ + fun origin(akeneoPim: OriginRequest.AkeneoPim) = + origin(OriginRequest.ofAkeneoPim(akeneoPim)) + + 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 [OriginCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .origin() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OriginCreateParams = + OriginCreateParams( + checkRequired("origin", origin), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): OriginRequest = origin + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OriginCreateParams && + origin == other.origin && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(origin, additionalHeaders, additionalQueryParams) + + override fun toString() = + "OriginCreateParams{origin=$origin, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginDeleteParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginDeleteParams.kt new file mode 100644 index 00000000..f96b6b3e --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginDeleteParams.kt @@ -0,0 +1,239 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.origins + +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * **Note:** This API is currently in beta. Permanently removes the origin identified by `id`. If + * the origin is in use by any URL‑endpoints, the API will return an error. + */ +class OriginDeleteParams +private constructor( + private val id: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + */ + 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(): OriginDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [OriginDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OriginDeleteParams]. */ + 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(originDeleteParams: OriginDeleteParams) = apply { + id = originDeleteParams.id + additionalHeaders = originDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = originDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = originDeleteParams.additionalBodyProperties.toMutableMap() + } + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new + * origin. + */ + 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 [OriginDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OriginDeleteParams = + OriginDeleteParams( + 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 OriginDeleteParams && + 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() = + "OriginDeleteParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetParams.kt new file mode 100644 index 00000000..b4b2f306 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetParams.kt @@ -0,0 +1,196 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.origins + +import com.imagekit.api.core.Params +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** **Note:** This API is currently in beta. Retrieves the origin identified by `id`. */ +class OriginGetParams +private constructor( + private val id: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + */ + 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(): OriginGetParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [OriginGetParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OriginGetParams]. */ + 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(originGetParams: OriginGetParams) = apply { + id = originGetParams.id + additionalHeaders = originGetParams.additionalHeaders.toBuilder() + additionalQueryParams = originGetParams.additionalQueryParams.toBuilder() + } + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new + * origin. + */ + 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 [OriginGetParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OriginGetParams = + OriginGetParams(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 OriginGetParams && + id == other.id && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(id, additionalHeaders, additionalQueryParams) + + override fun toString() = + "OriginGetParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListParams.kt new file mode 100644 index 00000000..a1f09509 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListParams.kt @@ -0,0 +1,173 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.origins + +import com.imagekit.api.core.Params +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import java.util.Objects + +/** + * **Note:** This API is currently in beta. Returns an array of all configured origins for the + * current account. + */ +class OriginListParams +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(): OriginListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [OriginListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OriginListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(originListParams: OriginListParams) = apply { + additionalHeaders = originListParams.additionalHeaders.toBuilder() + additionalQueryParams = originListParams.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 [OriginListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OriginListParams = + OriginListParams(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 OriginListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "OriginListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginRequest.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginRequest.kt new file mode 100644 index 00000000..56eb7949 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginRequest.kt @@ -0,0 +1,3908 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.origins + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Schema for origin request resources. */ +@JsonDeserialize(using = OriginRequest.Deserializer::class) +@JsonSerialize(using = OriginRequest.Serializer::class) +class OriginRequest +private constructor( + private val s3: S3? = null, + private val s3Compatible: S3Compatible? = null, + private val cloudinaryBackup: CloudinaryBackup? = null, + private val webFolder: WebFolder? = null, + private val webProxy: WebProxy? = null, + private val gcs: Gcs? = null, + private val azureBlob: AzureBlob? = null, + private val akeneoPim: AkeneoPim? = null, + private val _json: JsonValue? = null, +) { + + fun s3(): Optional = Optional.ofNullable(s3) + + fun s3Compatible(): Optional = Optional.ofNullable(s3Compatible) + + fun cloudinaryBackup(): Optional = Optional.ofNullable(cloudinaryBackup) + + fun webFolder(): Optional = Optional.ofNullable(webFolder) + + fun webProxy(): Optional = Optional.ofNullable(webProxy) + + fun gcs(): Optional = Optional.ofNullable(gcs) + + fun azureBlob(): Optional = Optional.ofNullable(azureBlob) + + fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) + + fun isS3(): Boolean = s3 != null + + fun isS3Compatible(): Boolean = s3Compatible != null + + fun isCloudinaryBackup(): Boolean = cloudinaryBackup != null + + fun isWebFolder(): Boolean = webFolder != null + + fun isWebProxy(): Boolean = webProxy != null + + fun isGcs(): Boolean = gcs != null + + fun isAzureBlob(): Boolean = azureBlob != null + + fun isAkeneoPim(): Boolean = akeneoPim != null + + fun asS3(): S3 = s3.getOrThrow("s3") + + fun asS3Compatible(): S3Compatible = s3Compatible.getOrThrow("s3Compatible") + + fun asCloudinaryBackup(): CloudinaryBackup = cloudinaryBackup.getOrThrow("cloudinaryBackup") + + fun asWebFolder(): WebFolder = webFolder.getOrThrow("webFolder") + + fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") + + fun asGcs(): Gcs = gcs.getOrThrow("gcs") + + fun asAzureBlob(): AzureBlob = azureBlob.getOrThrow("azureBlob") + + fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + s3 != null -> visitor.visitS3(s3) + s3Compatible != null -> visitor.visitS3Compatible(s3Compatible) + cloudinaryBackup != null -> visitor.visitCloudinaryBackup(cloudinaryBackup) + webFolder != null -> visitor.visitWebFolder(webFolder) + webProxy != null -> visitor.visitWebProxy(webProxy) + gcs != null -> visitor.visitGcs(gcs) + azureBlob != null -> visitor.visitAzureBlob(azureBlob) + akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): OriginRequest = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitS3(s3: S3) { + s3.validate() + } + + override fun visitS3Compatible(s3Compatible: S3Compatible) { + s3Compatible.validate() + } + + override fun visitCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) { + cloudinaryBackup.validate() + } + + override fun visitWebFolder(webFolder: WebFolder) { + webFolder.validate() + } + + override fun visitWebProxy(webProxy: WebProxy) { + webProxy.validate() + } + + override fun visitGcs(gcs: Gcs) { + gcs.validate() + } + + override fun visitAzureBlob(azureBlob: AzureBlob) { + azureBlob.validate() + } + + override fun visitAkeneoPim(akeneoPim: AkeneoPim) { + akeneoPim.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitS3(s3: S3) = s3.validity() + + override fun visitS3Compatible(s3Compatible: S3Compatible) = s3Compatible.validity() + + override fun visitCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = + cloudinaryBackup.validity() + + override fun visitWebFolder(webFolder: WebFolder) = webFolder.validity() + + override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() + + override fun visitGcs(gcs: Gcs) = gcs.validity() + + override fun visitAzureBlob(azureBlob: AzureBlob) = azureBlob.validity() + + override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OriginRequest && + s3 == other.s3 && + s3Compatible == other.s3Compatible && + cloudinaryBackup == other.cloudinaryBackup && + webFolder == other.webFolder && + webProxy == other.webProxy && + gcs == other.gcs && + azureBlob == other.azureBlob && + akeneoPim == other.akeneoPim + } + + override fun hashCode(): Int = + Objects.hash( + s3, + s3Compatible, + cloudinaryBackup, + webFolder, + webProxy, + gcs, + azureBlob, + akeneoPim, + ) + + override fun toString(): String = + when { + s3 != null -> "OriginRequest{s3=$s3}" + s3Compatible != null -> "OriginRequest{s3Compatible=$s3Compatible}" + cloudinaryBackup != null -> "OriginRequest{cloudinaryBackup=$cloudinaryBackup}" + webFolder != null -> "OriginRequest{webFolder=$webFolder}" + webProxy != null -> "OriginRequest{webProxy=$webProxy}" + gcs != null -> "OriginRequest{gcs=$gcs}" + azureBlob != null -> "OriginRequest{azureBlob=$azureBlob}" + akeneoPim != null -> "OriginRequest{akeneoPim=$akeneoPim}" + _json != null -> "OriginRequest{_unknown=$_json}" + else -> throw IllegalStateException("Invalid OriginRequest") + } + + companion object { + + @JvmStatic fun ofS3(s3: S3) = OriginRequest(s3 = s3) + + @JvmStatic + fun ofS3Compatible(s3Compatible: S3Compatible) = OriginRequest(s3Compatible = s3Compatible) + + @JvmStatic + fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = + OriginRequest(cloudinaryBackup = cloudinaryBackup) + + @JvmStatic fun ofWebFolder(webFolder: WebFolder) = OriginRequest(webFolder = webFolder) + + @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginRequest(webProxy = webProxy) + + @JvmStatic fun ofGcs(gcs: Gcs) = OriginRequest(gcs = gcs) + + @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = OriginRequest(azureBlob = azureBlob) + + @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginRequest(akeneoPim = akeneoPim) + } + + /** + * An interface that defines how to map each variant of [OriginRequest] to a value of type [T]. + */ + interface Visitor { + + fun visitS3(s3: S3): T + + fun visitS3Compatible(s3Compatible: S3Compatible): T + + fun visitCloudinaryBackup(cloudinaryBackup: CloudinaryBackup): T + + fun visitWebFolder(webFolder: WebFolder): T + + fun visitWebProxy(webProxy: WebProxy): T + + fun visitGcs(gcs: Gcs): T + + fun visitAzureBlob(azureBlob: AzureBlob): T + + fun visitAkeneoPim(akeneoPim: AkeneoPim): T + + /** + * Maps an unknown variant of [OriginRequest] to a value of type [T]. + * + * An instance of [OriginRequest] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown OriginRequest: $json") + } + } + + internal class Deserializer : BaseDeserializer(OriginRequest::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): OriginRequest { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "S3" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginRequest(s3 = it, _json = json) + } ?: OriginRequest(_json = json) + } + "S3_COMPATIBLE" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginRequest(s3Compatible = it, _json = json) + } ?: OriginRequest(_json = json) + } + "CLOUDINARY_BACKUP" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginRequest(cloudinaryBackup = it, _json = json) + } ?: OriginRequest(_json = json) + } + "WEB_FOLDER" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginRequest(webFolder = it, _json = json) + } ?: OriginRequest(_json = json) + } + "WEB_PROXY" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginRequest(webProxy = it, _json = json) + } ?: OriginRequest(_json = json) + } + "GCS" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginRequest(gcs = it, _json = json) + } ?: OriginRequest(_json = json) + } + "AZURE_BLOB" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginRequest(azureBlob = it, _json = json) + } ?: OriginRequest(_json = json) + } + "AKENEO_PIM" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginRequest(akeneoPim = it, _json = json) + } ?: OriginRequest(_json = json) + } + } + + return OriginRequest(_json = json) + } + } + + internal class Serializer : BaseSerializer(OriginRequest::class) { + + override fun serialize( + value: OriginRequest, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.s3 != null -> generator.writeObject(value.s3) + value.s3Compatible != null -> generator.writeObject(value.s3Compatible) + value.cloudinaryBackup != null -> generator.writeObject(value.cloudinaryBackup) + value.webFolder != null -> generator.writeObject(value.webFolder) + value.webProxy != null -> generator.writeObject(value.webProxy) + value.gcs != null -> generator.writeObject(value.gcs) + value.azureBlob != null -> generator.writeObject(value.azureBlob) + value.akeneoPim != null -> generator.writeObject(value.akeneoPim) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid OriginRequest") + } + } + } + + class S3 + private constructor( + private val accessKey: JsonField, + private val bucket: JsonField, + private val name: JsonField, + private val secretKey: JsonField, + private val type: JsonValue, + private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accessKey") + @ExcludeMissing + accessKey: JsonField = JsonMissing.of(), + @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("secretKey") + @ExcludeMissing + secretKey: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + ) : this( + accessKey, + bucket, + name, + secretKey, + type, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + mutableMapOf(), + ) + + /** + * Access key for the bucket. + * + * @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 accessKey(): String = accessKey.getRequired("accessKey") + + /** + * S3 bucket name. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun bucket(): String = bucket.getRequired("bucket") + + /** + * Display name of the origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Secret key for the bucket. + * + * @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 secretKey(): String = secretKey.getRequired("secretKey") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("S3") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * URL used in the Canonical header (if enabled). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun baseUrlForCanonicalHeader(): Optional = + baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") + + /** + * Whether to send a Canonical header. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") + + /** + * Path prefix inside the bucket. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun prefix(): Optional = prefix.getOptional("prefix") + + /** + * Returns the raw JSON value of [accessKey]. + * + * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("accessKey") @ExcludeMissing fun _accessKey(): JsonField = accessKey + + /** + * Returns the raw JSON value of [bucket]. + * + * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket + + /** + * 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 [secretKey]. + * + * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + + /** + * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + + /** + * Returns the raw JSON value of [includeCanonicalHeader]. + * + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + + /** + * Returns the raw JSON value of [prefix]. + * + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [S3]. + * + * The following fields are required: + * ```java + * .accessKey() + * .bucket() + * .name() + * .secretKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [S3]. */ + class Builder internal constructor() { + + private var accessKey: JsonField? = null + private var bucket: JsonField? = null + private var name: JsonField? = null + private var secretKey: JsonField? = null + private var type: JsonValue = JsonValue.from("S3") + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var includeCanonicalHeader: JsonField = JsonMissing.of() + private var prefix: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(s3: S3) = apply { + accessKey = s3.accessKey + bucket = s3.bucket + name = s3.name + secretKey = s3.secretKey + type = s3.type + baseUrlForCanonicalHeader = s3.baseUrlForCanonicalHeader + includeCanonicalHeader = s3.includeCanonicalHeader + prefix = s3.prefix + additionalProperties = s3.additionalProperties.toMutableMap() + } + + /** Access key for the bucket. */ + fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) + + /** + * Sets [Builder.accessKey] to an arbitrary JSON value. + * + * You should usually call [Builder.accessKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } + + /** S3 bucket name. */ + fun bucket(bucket: String) = bucket(JsonField.of(bucket)) + + /** + * Sets [Builder.bucket] to an arbitrary JSON value. + * + * You should usually call [Builder.bucket] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bucket(bucket: JsonField) = apply { this.bucket = bucket } + + /** Display name of the origin. */ + 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 } + + /** Secret key for the bucket. */ + fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) + + /** + * Sets [Builder.secretKey] to an arbitrary JSON value. + * + * You should usually call [Builder.secretKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("S3") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** URL used in the Canonical header (if enabled). */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = + baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) + + /** + * Sets [Builder.baseUrlForCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrlForCanonicalHeader] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } + + /** Whether to send a Canonical header. */ + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + + /** + * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.includeCanonicalHeader] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader + } + + /** Path prefix inside the bucket. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + + /** + * Sets [Builder.prefix] to an arbitrary JSON value. + * + * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [S3]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accessKey() + * .bucket() + * .name() + * .secretKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): S3 = + S3( + checkRequired("accessKey", accessKey), + checkRequired("bucket", bucket), + checkRequired("name", name), + checkRequired("secretKey", secretKey), + type, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): S3 = apply { + if (validated) { + return@apply + } + + accessKey() + bucket() + name() + secretKey() + _type().let { + if (it != JsonValue.from("S3")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() + 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 (accessKey.asKnown().isPresent) 1 else 0) + + (if (bucket.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (secretKey.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("S3")) 1 else 0 } + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is S3 && + accessKey == other.accessKey && + bucket == other.bucket && + name == other.name && + secretKey == other.secretKey && + type == other.type && + baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accessKey, + bucket, + name, + secretKey, + type, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "S3{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + } + + class S3Compatible + private constructor( + private val accessKey: JsonField, + private val bucket: JsonField, + private val endpoint: JsonField, + private val name: JsonField, + private val secretKey: JsonField, + private val type: JsonValue, + private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: JsonField, + private val s3ForcePathStyle: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accessKey") + @ExcludeMissing + accessKey: JsonField = JsonMissing.of(), + @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), + @JsonProperty("endpoint") + @ExcludeMissing + endpoint: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("secretKey") + @ExcludeMissing + secretKey: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + @JsonProperty("s3ForcePathStyle") + @ExcludeMissing + s3ForcePathStyle: JsonField = JsonMissing.of(), + ) : this( + accessKey, + bucket, + endpoint, + name, + secretKey, + type, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + s3ForcePathStyle, + mutableMapOf(), + ) + + /** + * Access key for the bucket. + * + * @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 accessKey(): String = accessKey.getRequired("accessKey") + + /** + * S3 bucket name. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun bucket(): String = bucket.getRequired("bucket") + + /** + * Custom S3-compatible endpoint. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun endpoint(): String = endpoint.getRequired("endpoint") + + /** + * Display name of the origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Secret key for the bucket. + * + * @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 secretKey(): String = secretKey.getRequired("secretKey") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("S3_COMPATIBLE") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * URL used in the Canonical header (if enabled). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun baseUrlForCanonicalHeader(): Optional = + baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") + + /** + * Whether to send a Canonical header. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") + + /** + * Path prefix inside the bucket. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun prefix(): Optional = prefix.getOptional("prefix") + + /** + * Use path-style S3 URLs? + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun s3ForcePathStyle(): Optional = s3ForcePathStyle.getOptional("s3ForcePathStyle") + + /** + * Returns the raw JSON value of [accessKey]. + * + * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("accessKey") @ExcludeMissing fun _accessKey(): JsonField = accessKey + + /** + * Returns the raw JSON value of [bucket]. + * + * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket + + /** + * Returns the raw JSON value of [endpoint]. + * + * Unlike [endpoint], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("endpoint") @ExcludeMissing fun _endpoint(): JsonField = endpoint + + /** + * 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 [secretKey]. + * + * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + + /** + * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + + /** + * Returns the raw JSON value of [includeCanonicalHeader]. + * + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + + /** + * Returns the raw JSON value of [prefix]. + * + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + + /** + * Returns the raw JSON value of [s3ForcePathStyle]. + * + * Unlike [s3ForcePathStyle], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("s3ForcePathStyle") + @ExcludeMissing + fun _s3ForcePathStyle(): JsonField = s3ForcePathStyle + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [S3Compatible]. + * + * The following fields are required: + * ```java + * .accessKey() + * .bucket() + * .endpoint() + * .name() + * .secretKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [S3Compatible]. */ + class Builder internal constructor() { + + private var accessKey: JsonField? = null + private var bucket: JsonField? = null + private var endpoint: JsonField? = null + private var name: JsonField? = null + private var secretKey: JsonField? = null + private var type: JsonValue = JsonValue.from("S3_COMPATIBLE") + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var includeCanonicalHeader: JsonField = JsonMissing.of() + private var prefix: JsonField = JsonMissing.of() + private var s3ForcePathStyle: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(s3Compatible: S3Compatible) = apply { + accessKey = s3Compatible.accessKey + bucket = s3Compatible.bucket + endpoint = s3Compatible.endpoint + name = s3Compatible.name + secretKey = s3Compatible.secretKey + type = s3Compatible.type + baseUrlForCanonicalHeader = s3Compatible.baseUrlForCanonicalHeader + includeCanonicalHeader = s3Compatible.includeCanonicalHeader + prefix = s3Compatible.prefix + s3ForcePathStyle = s3Compatible.s3ForcePathStyle + additionalProperties = s3Compatible.additionalProperties.toMutableMap() + } + + /** Access key for the bucket. */ + fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) + + /** + * Sets [Builder.accessKey] to an arbitrary JSON value. + * + * You should usually call [Builder.accessKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } + + /** S3 bucket name. */ + fun bucket(bucket: String) = bucket(JsonField.of(bucket)) + + /** + * Sets [Builder.bucket] to an arbitrary JSON value. + * + * You should usually call [Builder.bucket] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bucket(bucket: JsonField) = apply { this.bucket = bucket } + + /** Custom S3-compatible endpoint. */ + fun endpoint(endpoint: String) = endpoint(JsonField.of(endpoint)) + + /** + * Sets [Builder.endpoint] to an arbitrary JSON value. + * + * You should usually call [Builder.endpoint] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endpoint(endpoint: JsonField) = apply { this.endpoint = endpoint } + + /** Display name of the origin. */ + 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 } + + /** Secret key for the bucket. */ + fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) + + /** + * Sets [Builder.secretKey] to an arbitrary JSON value. + * + * You should usually call [Builder.secretKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("S3_COMPATIBLE") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** URL used in the Canonical header (if enabled). */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = + baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) + + /** + * Sets [Builder.baseUrlForCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrlForCanonicalHeader] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } + + /** Whether to send a Canonical header. */ + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + + /** + * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.includeCanonicalHeader] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader + } + + /** Path prefix inside the bucket. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + + /** + * Sets [Builder.prefix] to an arbitrary JSON value. + * + * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } + + /** Use path-style S3 URLs? */ + fun s3ForcePathStyle(s3ForcePathStyle: Boolean) = + s3ForcePathStyle(JsonField.of(s3ForcePathStyle)) + + /** + * Sets [Builder.s3ForcePathStyle] to an arbitrary JSON value. + * + * You should usually call [Builder.s3ForcePathStyle] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun s3ForcePathStyle(s3ForcePathStyle: JsonField) = apply { + this.s3ForcePathStyle = s3ForcePathStyle + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [S3Compatible]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accessKey() + * .bucket() + * .endpoint() + * .name() + * .secretKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): S3Compatible = + S3Compatible( + checkRequired("accessKey", accessKey), + checkRequired("bucket", bucket), + checkRequired("endpoint", endpoint), + checkRequired("name", name), + checkRequired("secretKey", secretKey), + type, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + s3ForcePathStyle, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): S3Compatible = apply { + if (validated) { + return@apply + } + + accessKey() + bucket() + endpoint() + name() + secretKey() + _type().let { + if (it != JsonValue.from("S3_COMPATIBLE")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() + s3ForcePathStyle() + 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 (accessKey.asKnown().isPresent) 1 else 0) + + (if (bucket.asKnown().isPresent) 1 else 0) + + (if (endpoint.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (secretKey.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("S3_COMPATIBLE")) 1 else 0 } + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + (if (s3ForcePathStyle.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is S3Compatible && + accessKey == other.accessKey && + bucket == other.bucket && + endpoint == other.endpoint && + name == other.name && + secretKey == other.secretKey && + type == other.type && + baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && + s3ForcePathStyle == other.s3ForcePathStyle && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accessKey, + bucket, + endpoint, + name, + secretKey, + type, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + s3ForcePathStyle, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "S3Compatible{accessKey=$accessKey, bucket=$bucket, endpoint=$endpoint, name=$name, secretKey=$secretKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, s3ForcePathStyle=$s3ForcePathStyle, additionalProperties=$additionalProperties}" + } + + class CloudinaryBackup + private constructor( + private val accessKey: JsonField, + private val bucket: JsonField, + private val name: JsonField, + private val secretKey: JsonField, + private val type: JsonValue, + private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accessKey") + @ExcludeMissing + accessKey: JsonField = JsonMissing.of(), + @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("secretKey") + @ExcludeMissing + secretKey: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + ) : this( + accessKey, + bucket, + name, + secretKey, + type, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + mutableMapOf(), + ) + + /** + * Access key for the bucket. + * + * @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 accessKey(): String = accessKey.getRequired("accessKey") + + /** + * S3 bucket name. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun bucket(): String = bucket.getRequired("bucket") + + /** + * Display name of the origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Secret key for the bucket. + * + * @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 secretKey(): String = secretKey.getRequired("secretKey") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("CLOUDINARY_BACKUP") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * URL used in the Canonical header (if enabled). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun baseUrlForCanonicalHeader(): Optional = + baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") + + /** + * Whether to send a Canonical header. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") + + /** + * Path prefix inside the bucket. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun prefix(): Optional = prefix.getOptional("prefix") + + /** + * Returns the raw JSON value of [accessKey]. + * + * Unlike [accessKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("accessKey") @ExcludeMissing fun _accessKey(): JsonField = accessKey + + /** + * Returns the raw JSON value of [bucket]. + * + * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket + + /** + * 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 [secretKey]. + * + * Unlike [secretKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("secretKey") @ExcludeMissing fun _secretKey(): JsonField = secretKey + + /** + * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + + /** + * Returns the raw JSON value of [includeCanonicalHeader]. + * + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + + /** + * Returns the raw JSON value of [prefix]. + * + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CloudinaryBackup]. + * + * The following fields are required: + * ```java + * .accessKey() + * .bucket() + * .name() + * .secretKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CloudinaryBackup]. */ + class Builder internal constructor() { + + private var accessKey: JsonField? = null + private var bucket: JsonField? = null + private var name: JsonField? = null + private var secretKey: JsonField? = null + private var type: JsonValue = JsonValue.from("CLOUDINARY_BACKUP") + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var includeCanonicalHeader: JsonField = JsonMissing.of() + private var prefix: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cloudinaryBackup: CloudinaryBackup) = apply { + accessKey = cloudinaryBackup.accessKey + bucket = cloudinaryBackup.bucket + name = cloudinaryBackup.name + secretKey = cloudinaryBackup.secretKey + type = cloudinaryBackup.type + baseUrlForCanonicalHeader = cloudinaryBackup.baseUrlForCanonicalHeader + includeCanonicalHeader = cloudinaryBackup.includeCanonicalHeader + prefix = cloudinaryBackup.prefix + additionalProperties = cloudinaryBackup.additionalProperties.toMutableMap() + } + + /** Access key for the bucket. */ + fun accessKey(accessKey: String) = accessKey(JsonField.of(accessKey)) + + /** + * Sets [Builder.accessKey] to an arbitrary JSON value. + * + * You should usually call [Builder.accessKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accessKey(accessKey: JsonField) = apply { this.accessKey = accessKey } + + /** S3 bucket name. */ + fun bucket(bucket: String) = bucket(JsonField.of(bucket)) + + /** + * Sets [Builder.bucket] to an arbitrary JSON value. + * + * You should usually call [Builder.bucket] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bucket(bucket: JsonField) = apply { this.bucket = bucket } + + /** Display name of the origin. */ + 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 } + + /** Secret key for the bucket. */ + fun secretKey(secretKey: String) = secretKey(JsonField.of(secretKey)) + + /** + * Sets [Builder.secretKey] to an arbitrary JSON value. + * + * You should usually call [Builder.secretKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun secretKey(secretKey: JsonField) = apply { this.secretKey = secretKey } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("CLOUDINARY_BACKUP") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** URL used in the Canonical header (if enabled). */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = + baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) + + /** + * Sets [Builder.baseUrlForCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrlForCanonicalHeader] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } + + /** Whether to send a Canonical header. */ + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + + /** + * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.includeCanonicalHeader] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader + } + + /** Path prefix inside the bucket. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + + /** + * Sets [Builder.prefix] to an arbitrary JSON value. + * + * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CloudinaryBackup]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accessKey() + * .bucket() + * .name() + * .secretKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CloudinaryBackup = + CloudinaryBackup( + checkRequired("accessKey", accessKey), + checkRequired("bucket", bucket), + checkRequired("name", name), + checkRequired("secretKey", secretKey), + type, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CloudinaryBackup = apply { + if (validated) { + return@apply + } + + accessKey() + bucket() + name() + secretKey() + _type().let { + if (it != JsonValue.from("CLOUDINARY_BACKUP")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() + 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 (accessKey.asKnown().isPresent) 1 else 0) + + (if (bucket.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (secretKey.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("CLOUDINARY_BACKUP")) 1 else 0 } + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CloudinaryBackup && + accessKey == other.accessKey && + bucket == other.bucket && + name == other.name && + secretKey == other.secretKey && + type == other.type && + baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accessKey, + bucket, + name, + secretKey, + type, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CloudinaryBackup{accessKey=$accessKey, bucket=$bucket, name=$name, secretKey=$secretKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + } + + class WebFolder + private constructor( + private val baseUrl: JsonField, + private val name: JsonField, + private val type: JsonValue, + private val baseUrlForCanonicalHeader: JsonField, + private val forwardHostHeaderToOrigin: JsonField, + private val includeCanonicalHeader: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("forwardHostHeaderToOrigin") + @ExcludeMissing + forwardHostHeaderToOrigin: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + ) : this( + baseUrl, + name, + type, + baseUrlForCanonicalHeader, + forwardHostHeaderToOrigin, + includeCanonicalHeader, + mutableMapOf(), + ) + + /** + * Root URL for the web folder origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun baseUrl(): String = baseUrl.getRequired("baseUrl") + + /** + * Display name of the origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("WEB_FOLDER") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * URL used in the Canonical header (if enabled). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun baseUrlForCanonicalHeader(): Optional = + baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") + + /** + * Forward the Host header to origin? + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun forwardHostHeaderToOrigin(): Optional = + forwardHostHeaderToOrigin.getOptional("forwardHostHeaderToOrigin") + + /** + * Whether to send a Canonical header. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") + + /** + * Returns the raw JSON value of [baseUrl]. + * + * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl + + /** + * 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 [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + + /** + * Returns the raw JSON value of [forwardHostHeaderToOrigin]. + * + * Unlike [forwardHostHeaderToOrigin], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("forwardHostHeaderToOrigin") + @ExcludeMissing + fun _forwardHostHeaderToOrigin(): JsonField = forwardHostHeaderToOrigin + + /** + * Returns the raw JSON value of [includeCanonicalHeader]. + * + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [WebFolder]. + * + * The following fields are required: + * ```java + * .baseUrl() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebFolder]. */ + class Builder internal constructor() { + + private var baseUrl: JsonField? = null + private var name: JsonField? = null + private var type: JsonValue = JsonValue.from("WEB_FOLDER") + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var forwardHostHeaderToOrigin: JsonField = JsonMissing.of() + private var includeCanonicalHeader: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webFolder: WebFolder) = apply { + baseUrl = webFolder.baseUrl + name = webFolder.name + type = webFolder.type + baseUrlForCanonicalHeader = webFolder.baseUrlForCanonicalHeader + forwardHostHeaderToOrigin = webFolder.forwardHostHeaderToOrigin + includeCanonicalHeader = webFolder.includeCanonicalHeader + additionalProperties = webFolder.additionalProperties.toMutableMap() + } + + /** Root URL for the web folder origin. */ + fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) + + /** + * Sets [Builder.baseUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } + + /** Display name of the origin. */ + 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 } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("WEB_FOLDER") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** URL used in the Canonical header (if enabled). */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = + baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) + + /** + * Sets [Builder.baseUrlForCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrlForCanonicalHeader] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } + + /** Forward the Host header to origin? */ + fun forwardHostHeaderToOrigin(forwardHostHeaderToOrigin: Boolean) = + forwardHostHeaderToOrigin(JsonField.of(forwardHostHeaderToOrigin)) + + /** + * Sets [Builder.forwardHostHeaderToOrigin] to an arbitrary JSON value. + * + * You should usually call [Builder.forwardHostHeaderToOrigin] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun forwardHostHeaderToOrigin(forwardHostHeaderToOrigin: JsonField) = apply { + this.forwardHostHeaderToOrigin = forwardHostHeaderToOrigin + } + + /** Whether to send a Canonical header. */ + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + + /** + * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.includeCanonicalHeader] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [WebFolder]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .baseUrl() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WebFolder = + WebFolder( + checkRequired("baseUrl", baseUrl), + checkRequired("name", name), + type, + baseUrlForCanonicalHeader, + forwardHostHeaderToOrigin, + includeCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WebFolder = apply { + if (validated) { + return@apply + } + + baseUrl() + name() + _type().let { + if (it != JsonValue.from("WEB_FOLDER")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + baseUrlForCanonicalHeader() + forwardHostHeaderToOrigin() + includeCanonicalHeader() + 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 (baseUrl.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("WEB_FOLDER")) 1 else 0 } + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WebFolder && + baseUrl == other.baseUrl && + name == other.name && + type == other.type && + baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && + includeCanonicalHeader == other.includeCanonicalHeader && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + baseUrl, + name, + type, + baseUrlForCanonicalHeader, + forwardHostHeaderToOrigin, + includeCanonicalHeader, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "WebFolder{baseUrl=$baseUrl, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + } + + class WebProxy + private constructor( + private val name: JsonField, + private val type: JsonValue, + private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + ) : this(name, type, baseUrlForCanonicalHeader, includeCanonicalHeader, mutableMapOf()) + + /** + * Display name of the origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("WEB_PROXY") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * URL used in the Canonical header (if enabled). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun baseUrlForCanonicalHeader(): Optional = + baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") + + /** + * Whether to send a Canonical header. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") + + /** + * 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 [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + + /** + * Returns the raw JSON value of [includeCanonicalHeader]. + * + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [WebProxy]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebProxy]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var type: JsonValue = JsonValue.from("WEB_PROXY") + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var includeCanonicalHeader: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webProxy: WebProxy) = apply { + name = webProxy.name + type = webProxy.type + baseUrlForCanonicalHeader = webProxy.baseUrlForCanonicalHeader + includeCanonicalHeader = webProxy.includeCanonicalHeader + additionalProperties = webProxy.additionalProperties.toMutableMap() + } + + /** Display name of the origin. */ + 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 } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("WEB_PROXY") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** URL used in the Canonical header (if enabled). */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = + baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) + + /** + * Sets [Builder.baseUrlForCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrlForCanonicalHeader] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } + + /** Whether to send a Canonical header. */ + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + + /** + * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.includeCanonicalHeader] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [WebProxy]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WebProxy = + WebProxy( + checkRequired("name", name), + type, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WebProxy = apply { + if (validated) { + return@apply + } + + name() + _type().let { + if (it != JsonValue.from("WEB_PROXY")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + baseUrlForCanonicalHeader() + includeCanonicalHeader() + 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) + + type.let { if (it == JsonValue.from("WEB_PROXY")) 1 else 0 } + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WebProxy && + name == other.name && + type == other.type && + baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + name, + type, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "WebProxy{name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + } + + class Gcs + private constructor( + private val bucket: JsonField, + private val clientEmail: JsonField, + private val name: JsonField, + private val privateKey: JsonField, + private val type: JsonValue, + private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), + @JsonProperty("clientEmail") + @ExcludeMissing + clientEmail: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("privateKey") + @ExcludeMissing + privateKey: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + ) : this( + bucket, + clientEmail, + name, + privateKey, + type, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + mutableMapOf(), + ) + + /** + * @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 bucket(): String = bucket.getRequired("bucket") + + /** + * @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 clientEmail(): String = clientEmail.getRequired("clientEmail") + + /** + * Display name of the origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun privateKey(): String = privateKey.getRequired("privateKey") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("GCS") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * URL used in the Canonical header (if enabled). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun baseUrlForCanonicalHeader(): Optional = + baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") + + /** + * Whether to send a Canonical header. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun prefix(): Optional = prefix.getOptional("prefix") + + /** + * Returns the raw JSON value of [bucket]. + * + * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket + + /** + * Returns the raw JSON value of [clientEmail]. + * + * Unlike [clientEmail], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("clientEmail") + @ExcludeMissing + fun _clientEmail(): JsonField = clientEmail + + /** + * 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 [privateKey]. + * + * Unlike [privateKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("privateKey") + @ExcludeMissing + fun _privateKey(): JsonField = privateKey + + /** + * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + + /** + * Returns the raw JSON value of [includeCanonicalHeader]. + * + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + + /** + * Returns the raw JSON value of [prefix]. + * + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Gcs]. + * + * The following fields are required: + * ```java + * .bucket() + * .clientEmail() + * .name() + * .privateKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Gcs]. */ + class Builder internal constructor() { + + private var bucket: JsonField? = null + private var clientEmail: JsonField? = null + private var name: JsonField? = null + private var privateKey: JsonField? = null + private var type: JsonValue = JsonValue.from("GCS") + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var includeCanonicalHeader: JsonField = JsonMissing.of() + private var prefix: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(gcs: Gcs) = apply { + bucket = gcs.bucket + clientEmail = gcs.clientEmail + name = gcs.name + privateKey = gcs.privateKey + type = gcs.type + baseUrlForCanonicalHeader = gcs.baseUrlForCanonicalHeader + includeCanonicalHeader = gcs.includeCanonicalHeader + prefix = gcs.prefix + additionalProperties = gcs.additionalProperties.toMutableMap() + } + + fun bucket(bucket: String) = bucket(JsonField.of(bucket)) + + /** + * Sets [Builder.bucket] to an arbitrary JSON value. + * + * You should usually call [Builder.bucket] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bucket(bucket: JsonField) = apply { this.bucket = bucket } + + fun clientEmail(clientEmail: String) = clientEmail(JsonField.of(clientEmail)) + + /** + * Sets [Builder.clientEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.clientEmail] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun clientEmail(clientEmail: JsonField) = apply { + this.clientEmail = clientEmail + } + + /** Display name of the origin. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun privateKey(privateKey: String) = privateKey(JsonField.of(privateKey)) + + /** + * Sets [Builder.privateKey] to an arbitrary JSON value. + * + * You should usually call [Builder.privateKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun privateKey(privateKey: JsonField) = apply { this.privateKey = privateKey } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("GCS") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** URL used in the Canonical header (if enabled). */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = + baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) + + /** + * Sets [Builder.baseUrlForCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrlForCanonicalHeader] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } + + /** Whether to send a Canonical header. */ + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + + /** + * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.includeCanonicalHeader] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader + } + + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + + /** + * Sets [Builder.prefix] to an arbitrary JSON value. + * + * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Gcs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bucket() + * .clientEmail() + * .name() + * .privateKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Gcs = + Gcs( + checkRequired("bucket", bucket), + checkRequired("clientEmail", clientEmail), + checkRequired("name", name), + checkRequired("privateKey", privateKey), + type, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Gcs = apply { + if (validated) { + return@apply + } + + bucket() + clientEmail() + name() + privateKey() + _type().let { + if (it != JsonValue.from("GCS")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() + 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 (bucket.asKnown().isPresent) 1 else 0) + + (if (clientEmail.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (privateKey.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("GCS")) 1 else 0 } + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Gcs && + bucket == other.bucket && + clientEmail == other.clientEmail && + name == other.name && + privateKey == other.privateKey && + type == other.type && + baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bucket, + clientEmail, + name, + privateKey, + type, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Gcs{bucket=$bucket, clientEmail=$clientEmail, name=$name, privateKey=$privateKey, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + } + + class AzureBlob + private constructor( + private val accountName: JsonField, + private val container: JsonField, + private val name: JsonField, + private val sasToken: JsonField, + private val type: JsonValue, + private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val prefix: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accountName") + @ExcludeMissing + accountName: JsonField = JsonMissing.of(), + @JsonProperty("container") + @ExcludeMissing + container: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("sasToken") + @ExcludeMissing + sasToken: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + ) : this( + accountName, + container, + name, + sasToken, + type, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + mutableMapOf(), + ) + + /** + * @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 accountName(): String = accountName.getRequired("accountName") + + /** + * @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 container(): String = container.getRequired("container") + + /** + * Display name of the origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sasToken(): String = sasToken.getRequired("sasToken") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("AZURE_BLOB") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * URL used in the Canonical header (if enabled). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun baseUrlForCanonicalHeader(): Optional = + baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") + + /** + * Whether to send a Canonical header. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun prefix(): Optional = prefix.getOptional("prefix") + + /** + * Returns the raw JSON value of [accountName]. + * + * Unlike [accountName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("accountName") + @ExcludeMissing + fun _accountName(): JsonField = accountName + + /** + * Returns the raw JSON value of [container]. + * + * Unlike [container], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("container") @ExcludeMissing fun _container(): JsonField = container + + /** + * 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 [sasToken]. + * + * Unlike [sasToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sasToken") @ExcludeMissing fun _sasToken(): JsonField = sasToken + + /** + * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + + /** + * Returns the raw JSON value of [includeCanonicalHeader]. + * + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + + /** + * Returns the raw JSON value of [prefix]. + * + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AzureBlob]. + * + * The following fields are required: + * ```java + * .accountName() + * .container() + * .name() + * .sasToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AzureBlob]. */ + class Builder internal constructor() { + + private var accountName: JsonField? = null + private var container: JsonField? = null + private var name: JsonField? = null + private var sasToken: JsonField? = null + private var type: JsonValue = JsonValue.from("AZURE_BLOB") + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var includeCanonicalHeader: JsonField = JsonMissing.of() + private var prefix: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(azureBlob: AzureBlob) = apply { + accountName = azureBlob.accountName + container = azureBlob.container + name = azureBlob.name + sasToken = azureBlob.sasToken + type = azureBlob.type + baseUrlForCanonicalHeader = azureBlob.baseUrlForCanonicalHeader + includeCanonicalHeader = azureBlob.includeCanonicalHeader + prefix = azureBlob.prefix + additionalProperties = azureBlob.additionalProperties.toMutableMap() + } + + fun accountName(accountName: String) = accountName(JsonField.of(accountName)) + + /** + * Sets [Builder.accountName] to an arbitrary JSON value. + * + * You should usually call [Builder.accountName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accountName(accountName: JsonField) = apply { + this.accountName = accountName + } + + fun container(container: String) = container(JsonField.of(container)) + + /** + * Sets [Builder.container] to an arbitrary JSON value. + * + * You should usually call [Builder.container] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun container(container: JsonField) = apply { this.container = container } + + /** Display name of the origin. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun sasToken(sasToken: String) = sasToken(JsonField.of(sasToken)) + + /** + * Sets [Builder.sasToken] to an arbitrary JSON value. + * + * You should usually call [Builder.sasToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sasToken(sasToken: JsonField) = apply { this.sasToken = sasToken } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("AZURE_BLOB") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** URL used in the Canonical header (if enabled). */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = + baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) + + /** + * Sets [Builder.baseUrlForCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrlForCanonicalHeader] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } + + /** Whether to send a Canonical header. */ + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + + /** + * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.includeCanonicalHeader] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader + } + + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + + /** + * Sets [Builder.prefix] to an arbitrary JSON value. + * + * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AzureBlob]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountName() + * .container() + * .name() + * .sasToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AzureBlob = + AzureBlob( + checkRequired("accountName", accountName), + checkRequired("container", container), + checkRequired("name", name), + checkRequired("sasToken", sasToken), + type, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AzureBlob = apply { + if (validated) { + return@apply + } + + accountName() + container() + name() + sasToken() + _type().let { + if (it != JsonValue.from("AZURE_BLOB")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + baseUrlForCanonicalHeader() + includeCanonicalHeader() + prefix() + 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 (accountName.asKnown().isPresent) 1 else 0) + + (if (container.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (sasToken.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("AZURE_BLOB")) 1 else 0 } + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AzureBlob && + accountName == other.accountName && + container == other.container && + name == other.name && + sasToken == other.sasToken && + type == other.type && + baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + prefix == other.prefix && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accountName, + container, + name, + sasToken, + type, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + prefix, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AzureBlob{accountName=$accountName, container=$container, name=$name, sasToken=$sasToken, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, prefix=$prefix, additionalProperties=$additionalProperties}" + } + + class AkeneoPim + private constructor( + private val baseUrl: JsonField, + private val clientId: JsonField, + private val clientSecret: JsonField, + private val name: JsonField, + private val password: JsonField, + private val type: JsonValue, + private val username: JsonField, + private val baseUrlForCanonicalHeader: JsonField, + private val includeCanonicalHeader: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), + @JsonProperty("clientId") + @ExcludeMissing + clientId: JsonField = JsonMissing.of(), + @JsonProperty("clientSecret") + @ExcludeMissing + clientSecret: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("password") + @ExcludeMissing + password: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("username") + @ExcludeMissing + username: JsonField = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + ) : this( + baseUrl, + clientId, + clientSecret, + name, + password, + type, + username, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + mutableMapOf(), + ) + + /** + * Akeneo instance base URL. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun baseUrl(): String = baseUrl.getRequired("baseUrl") + + /** + * Akeneo API client ID. + * + * @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 clientId(): String = clientId.getRequired("clientId") + + /** + * Akeneo API client secret. + * + * @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 clientSecret(): String = clientSecret.getRequired("clientSecret") + + /** + * Display name of the origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Akeneo API password. + * + * @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 password(): String = password.getRequired("password") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("AKENEO_PIM") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Akeneo API username. + * + * @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 username(): String = username.getRequired("username") + + /** + * URL used in the Canonical header (if enabled). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun baseUrlForCanonicalHeader(): Optional = + baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") + + /** + * Whether to send a Canonical header. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun includeCanonicalHeader(): Optional = + includeCanonicalHeader.getOptional("includeCanonicalHeader") + + /** + * Returns the raw JSON value of [baseUrl]. + * + * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl + + /** + * Returns the raw JSON value of [clientId]. + * + * Unlike [clientId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("clientId") @ExcludeMissing fun _clientId(): JsonField = clientId + + /** + * Returns the raw JSON value of [clientSecret]. + * + * Unlike [clientSecret], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("clientSecret") + @ExcludeMissing + fun _clientSecret(): JsonField = clientSecret + + /** + * 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 [password]. + * + * Unlike [password], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("password") @ExcludeMissing fun _password(): JsonField = password + + /** + * Returns the raw JSON value of [username]. + * + * Unlike [username], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("username") @ExcludeMissing fun _username(): JsonField = username + + /** + * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + + /** + * Returns the raw JSON value of [includeCanonicalHeader]. + * + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AkeneoPim]. + * + * The following fields are required: + * ```java + * .baseUrl() + * .clientId() + * .clientSecret() + * .name() + * .password() + * .username() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AkeneoPim]. */ + class Builder internal constructor() { + + private var baseUrl: JsonField? = null + private var clientId: JsonField? = null + private var clientSecret: JsonField? = null + private var name: JsonField? = null + private var password: JsonField? = null + private var type: JsonValue = JsonValue.from("AKENEO_PIM") + private var username: JsonField? = null + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var includeCanonicalHeader: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(akeneoPim: AkeneoPim) = apply { + baseUrl = akeneoPim.baseUrl + clientId = akeneoPim.clientId + clientSecret = akeneoPim.clientSecret + name = akeneoPim.name + password = akeneoPim.password + type = akeneoPim.type + username = akeneoPim.username + baseUrlForCanonicalHeader = akeneoPim.baseUrlForCanonicalHeader + includeCanonicalHeader = akeneoPim.includeCanonicalHeader + additionalProperties = akeneoPim.additionalProperties.toMutableMap() + } + + /** Akeneo instance base URL. */ + fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) + + /** + * Sets [Builder.baseUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } + + /** Akeneo API client ID. */ + fun clientId(clientId: String) = clientId(JsonField.of(clientId)) + + /** + * Sets [Builder.clientId] to an arbitrary JSON value. + * + * You should usually call [Builder.clientId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun clientId(clientId: JsonField) = apply { this.clientId = clientId } + + /** Akeneo API client secret. */ + fun clientSecret(clientSecret: String) = clientSecret(JsonField.of(clientSecret)) + + /** + * Sets [Builder.clientSecret] to an arbitrary JSON value. + * + * You should usually call [Builder.clientSecret] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun clientSecret(clientSecret: JsonField) = apply { + this.clientSecret = clientSecret + } + + /** Display name of the origin. */ + 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 } + + /** Akeneo API password. */ + fun password(password: String) = password(JsonField.of(password)) + + /** + * Sets [Builder.password] to an arbitrary JSON value. + * + * You should usually call [Builder.password] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun password(password: JsonField) = apply { this.password = password } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("AKENEO_PIM") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Akeneo API username. */ + fun username(username: String) = username(JsonField.of(username)) + + /** + * Sets [Builder.username] to an arbitrary JSON value. + * + * You should usually call [Builder.username] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun username(username: JsonField) = apply { this.username = username } + + /** URL used in the Canonical header (if enabled). */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = + baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) + + /** + * Sets [Builder.baseUrlForCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrlForCanonicalHeader] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } + + /** Whether to send a Canonical header. */ + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + + /** + * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.includeCanonicalHeader] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AkeneoPim]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .baseUrl() + * .clientId() + * .clientSecret() + * .name() + * .password() + * .username() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AkeneoPim = + AkeneoPim( + checkRequired("baseUrl", baseUrl), + checkRequired("clientId", clientId), + checkRequired("clientSecret", clientSecret), + checkRequired("name", name), + checkRequired("password", password), + type, + checkRequired("username", username), + baseUrlForCanonicalHeader, + includeCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AkeneoPim = apply { + if (validated) { + return@apply + } + + baseUrl() + clientId() + clientSecret() + name() + password() + _type().let { + if (it != JsonValue.from("AKENEO_PIM")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + username() + baseUrlForCanonicalHeader() + includeCanonicalHeader() + 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 (baseUrl.asKnown().isPresent) 1 else 0) + + (if (clientId.asKnown().isPresent) 1 else 0) + + (if (clientSecret.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (password.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("AKENEO_PIM")) 1 else 0 } + + (if (username.asKnown().isPresent) 1 else 0) + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AkeneoPim && + baseUrl == other.baseUrl && + clientId == other.clientId && + clientSecret == other.clientSecret && + name == other.name && + password == other.password && + type == other.type && + username == other.username && + baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + includeCanonicalHeader == other.includeCanonicalHeader && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + baseUrl, + clientId, + clientSecret, + name, + password, + type, + username, + baseUrlForCanonicalHeader, + includeCanonicalHeader, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AkeneoPim{baseUrl=$baseUrl, clientId=$clientId, clientSecret=$clientSecret, name=$name, password=$password, type=$type, username=$username, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, includeCanonicalHeader=$includeCanonicalHeader, additionalProperties=$additionalProperties}" + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginResponse.kt new file mode 100644 index 00000000..5f8eed29 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginResponse.kt @@ -0,0 +1,3789 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.origins + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Origin object as returned by the API (sensitive fields removed). */ +@JsonDeserialize(using = OriginResponse.Deserializer::class) +@JsonSerialize(using = OriginResponse.Serializer::class) +class OriginResponse +private constructor( + private val s3: S3? = null, + private val s3Compatible: S3Compatible? = null, + private val cloudinaryBackup: CloudinaryBackup? = null, + private val webFolder: WebFolder? = null, + private val webProxy: WebProxy? = null, + private val gcs: Gcs? = null, + private val azureBlob: AzureBlob? = null, + private val akeneoPim: AkeneoPim? = null, + private val _json: JsonValue? = null, +) { + + fun s3(): Optional = Optional.ofNullable(s3) + + fun s3Compatible(): Optional = Optional.ofNullable(s3Compatible) + + fun cloudinaryBackup(): Optional = Optional.ofNullable(cloudinaryBackup) + + fun webFolder(): Optional = Optional.ofNullable(webFolder) + + fun webProxy(): Optional = Optional.ofNullable(webProxy) + + fun gcs(): Optional = Optional.ofNullable(gcs) + + fun azureBlob(): Optional = Optional.ofNullable(azureBlob) + + fun akeneoPim(): Optional = Optional.ofNullable(akeneoPim) + + fun isS3(): Boolean = s3 != null + + fun isS3Compatible(): Boolean = s3Compatible != null + + fun isCloudinaryBackup(): Boolean = cloudinaryBackup != null + + fun isWebFolder(): Boolean = webFolder != null + + fun isWebProxy(): Boolean = webProxy != null + + fun isGcs(): Boolean = gcs != null + + fun isAzureBlob(): Boolean = azureBlob != null + + fun isAkeneoPim(): Boolean = akeneoPim != null + + fun asS3(): S3 = s3.getOrThrow("s3") + + fun asS3Compatible(): S3Compatible = s3Compatible.getOrThrow("s3Compatible") + + fun asCloudinaryBackup(): CloudinaryBackup = cloudinaryBackup.getOrThrow("cloudinaryBackup") + + fun asWebFolder(): WebFolder = webFolder.getOrThrow("webFolder") + + fun asWebProxy(): WebProxy = webProxy.getOrThrow("webProxy") + + fun asGcs(): Gcs = gcs.getOrThrow("gcs") + + fun asAzureBlob(): AzureBlob = azureBlob.getOrThrow("azureBlob") + + fun asAkeneoPim(): AkeneoPim = akeneoPim.getOrThrow("akeneoPim") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + s3 != null -> visitor.visitS3(s3) + s3Compatible != null -> visitor.visitS3Compatible(s3Compatible) + cloudinaryBackup != null -> visitor.visitCloudinaryBackup(cloudinaryBackup) + webFolder != null -> visitor.visitWebFolder(webFolder) + webProxy != null -> visitor.visitWebProxy(webProxy) + gcs != null -> visitor.visitGcs(gcs) + azureBlob != null -> visitor.visitAzureBlob(azureBlob) + akeneoPim != null -> visitor.visitAkeneoPim(akeneoPim) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): OriginResponse = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitS3(s3: S3) { + s3.validate() + } + + override fun visitS3Compatible(s3Compatible: S3Compatible) { + s3Compatible.validate() + } + + override fun visitCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) { + cloudinaryBackup.validate() + } + + override fun visitWebFolder(webFolder: WebFolder) { + webFolder.validate() + } + + override fun visitWebProxy(webProxy: WebProxy) { + webProxy.validate() + } + + override fun visitGcs(gcs: Gcs) { + gcs.validate() + } + + override fun visitAzureBlob(azureBlob: AzureBlob) { + azureBlob.validate() + } + + override fun visitAkeneoPim(akeneoPim: AkeneoPim) { + akeneoPim.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitS3(s3: S3) = s3.validity() + + override fun visitS3Compatible(s3Compatible: S3Compatible) = s3Compatible.validity() + + override fun visitCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = + cloudinaryBackup.validity() + + override fun visitWebFolder(webFolder: WebFolder) = webFolder.validity() + + override fun visitWebProxy(webProxy: WebProxy) = webProxy.validity() + + override fun visitGcs(gcs: Gcs) = gcs.validity() + + override fun visitAzureBlob(azureBlob: AzureBlob) = azureBlob.validity() + + override fun visitAkeneoPim(akeneoPim: AkeneoPim) = akeneoPim.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OriginResponse && + s3 == other.s3 && + s3Compatible == other.s3Compatible && + cloudinaryBackup == other.cloudinaryBackup && + webFolder == other.webFolder && + webProxy == other.webProxy && + gcs == other.gcs && + azureBlob == other.azureBlob && + akeneoPim == other.akeneoPim + } + + override fun hashCode(): Int = + Objects.hash( + s3, + s3Compatible, + cloudinaryBackup, + webFolder, + webProxy, + gcs, + azureBlob, + akeneoPim, + ) + + override fun toString(): String = + when { + s3 != null -> "OriginResponse{s3=$s3}" + s3Compatible != null -> "OriginResponse{s3Compatible=$s3Compatible}" + cloudinaryBackup != null -> "OriginResponse{cloudinaryBackup=$cloudinaryBackup}" + webFolder != null -> "OriginResponse{webFolder=$webFolder}" + webProxy != null -> "OriginResponse{webProxy=$webProxy}" + gcs != null -> "OriginResponse{gcs=$gcs}" + azureBlob != null -> "OriginResponse{azureBlob=$azureBlob}" + akeneoPim != null -> "OriginResponse{akeneoPim=$akeneoPim}" + _json != null -> "OriginResponse{_unknown=$_json}" + else -> throw IllegalStateException("Invalid OriginResponse") + } + + companion object { + + @JvmStatic fun ofS3(s3: S3) = OriginResponse(s3 = s3) + + @JvmStatic + fun ofS3Compatible(s3Compatible: S3Compatible) = OriginResponse(s3Compatible = s3Compatible) + + @JvmStatic + fun ofCloudinaryBackup(cloudinaryBackup: CloudinaryBackup) = + OriginResponse(cloudinaryBackup = cloudinaryBackup) + + @JvmStatic fun ofWebFolder(webFolder: WebFolder) = OriginResponse(webFolder = webFolder) + + @JvmStatic fun ofWebProxy(webProxy: WebProxy) = OriginResponse(webProxy = webProxy) + + @JvmStatic fun ofGcs(gcs: Gcs) = OriginResponse(gcs = gcs) + + @JvmStatic fun ofAzureBlob(azureBlob: AzureBlob) = OriginResponse(azureBlob = azureBlob) + + @JvmStatic fun ofAkeneoPim(akeneoPim: AkeneoPim) = OriginResponse(akeneoPim = akeneoPim) + } + + /** + * An interface that defines how to map each variant of [OriginResponse] to a value of type [T]. + */ + interface Visitor { + + fun visitS3(s3: S3): T + + fun visitS3Compatible(s3Compatible: S3Compatible): T + + fun visitCloudinaryBackup(cloudinaryBackup: CloudinaryBackup): T + + fun visitWebFolder(webFolder: WebFolder): T + + fun visitWebProxy(webProxy: WebProxy): T + + fun visitGcs(gcs: Gcs): T + + fun visitAzureBlob(azureBlob: AzureBlob): T + + fun visitAkeneoPim(akeneoPim: AkeneoPim): T + + /** + * Maps an unknown variant of [OriginResponse] to a value of type [T]. + * + * An instance of [OriginResponse] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is unaware + * of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown OriginResponse: $json") + } + } + + internal class Deserializer : BaseDeserializer(OriginResponse::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): OriginResponse { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "S3" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginResponse(s3 = it, _json = json) + } ?: OriginResponse(_json = json) + } + "S3_COMPATIBLE" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginResponse(s3Compatible = it, _json = json) + } ?: OriginResponse(_json = json) + } + "CLOUDINARY_BACKUP" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginResponse(cloudinaryBackup = it, _json = json) + } ?: OriginResponse(_json = json) + } + "WEB_FOLDER" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginResponse(webFolder = it, _json = json) + } ?: OriginResponse(_json = json) + } + "WEB_PROXY" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginResponse(webProxy = it, _json = json) + } ?: OriginResponse(_json = json) + } + "GCS" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginResponse(gcs = it, _json = json) + } ?: OriginResponse(_json = json) + } + "AZURE_BLOB" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginResponse(azureBlob = it, _json = json) + } ?: OriginResponse(_json = json) + } + "AKENEO_PIM" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + OriginResponse(akeneoPim = it, _json = json) + } ?: OriginResponse(_json = json) + } + } + + return OriginResponse(_json = json) + } + } + + internal class Serializer : BaseSerializer(OriginResponse::class) { + + override fun serialize( + value: OriginResponse, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.s3 != null -> generator.writeObject(value.s3) + value.s3Compatible != null -> generator.writeObject(value.s3Compatible) + value.cloudinaryBackup != null -> generator.writeObject(value.cloudinaryBackup) + value.webFolder != null -> generator.writeObject(value.webFolder) + value.webProxy != null -> generator.writeObject(value.webProxy) + value.gcs != null -> generator.writeObject(value.gcs) + value.azureBlob != null -> generator.writeObject(value.azureBlob) + value.akeneoPim != null -> generator.writeObject(value.akeneoPim) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid OriginResponse") + } + } + } + + class S3 + private constructor( + private val id: JsonField, + private val bucket: JsonField, + private val includeCanonicalHeader: JsonField, + private val name: JsonField, + private val prefix: JsonField, + private val type: JsonValue, + private val baseUrlForCanonicalHeader: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + ) : this( + id, + bucket, + includeCanonicalHeader, + name, + prefix, + type, + baseUrlForCanonicalHeader, + mutableMapOf(), + ) + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new + * origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * S3 bucket name. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun bucket(): String = bucket.getRequired("bucket") + + /** + * Whether to send a Canonical header. + * + * @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 includeCanonicalHeader(): Boolean = + includeCanonicalHeader.getRequired("includeCanonicalHeader") + + /** + * Display name of the origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Path prefix inside the bucket. + * + * @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 prefix(): String = prefix.getRequired("prefix") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("S3") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * URL used in the Canonical header (if enabled). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun baseUrlForCanonicalHeader(): Optional = + baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") + + /** + * 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 [bucket]. + * + * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket + + /** + * Returns the raw JSON value of [includeCanonicalHeader]. + * + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + + /** + * 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 [prefix]. + * + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + + /** + * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [S3]. + * + * The following fields are required: + * ```java + * .id() + * .bucket() + * .includeCanonicalHeader() + * .name() + * .prefix() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [S3]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var bucket: JsonField? = null + private var includeCanonicalHeader: JsonField? = null + private var name: JsonField? = null + private var prefix: JsonField? = null + private var type: JsonValue = JsonValue.from("S3") + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(s3: S3) = apply { + id = s3.id + bucket = s3.bucket + includeCanonicalHeader = s3.includeCanonicalHeader + name = s3.name + prefix = s3.prefix + type = s3.type + baseUrlForCanonicalHeader = s3.baseUrlForCanonicalHeader + additionalProperties = s3.additionalProperties.toMutableMap() + } + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new + * origin. + */ + 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 } + + /** S3 bucket name. */ + fun bucket(bucket: String) = bucket(JsonField.of(bucket)) + + /** + * Sets [Builder.bucket] to an arbitrary JSON value. + * + * You should usually call [Builder.bucket] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bucket(bucket: JsonField) = apply { this.bucket = bucket } + + /** Whether to send a Canonical header. */ + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + + /** + * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.includeCanonicalHeader] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader + } + + /** Display name of the origin. */ + 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 } + + /** Path prefix inside the bucket. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + + /** + * Sets [Builder.prefix] to an arbitrary JSON value. + * + * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("S3") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** URL used in the Canonical header (if enabled). */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = + baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) + + /** + * Sets [Builder.baseUrlForCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrlForCanonicalHeader] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [S3]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .bucket() + * .includeCanonicalHeader() + * .name() + * .prefix() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): S3 = + S3( + checkRequired("id", id), + checkRequired("bucket", bucket), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("prefix", prefix), + type, + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): S3 = apply { + if (validated) { + return@apply + } + + id() + bucket() + includeCanonicalHeader() + name() + prefix() + _type().let { + if (it != JsonValue.from("S3")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + baseUrlForCanonicalHeader() + 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 (bucket.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("S3")) 1 else 0 } + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is S3 && + id == other.id && + bucket == other.bucket && + includeCanonicalHeader == other.includeCanonicalHeader && + name == other.name && + prefix == other.prefix && + type == other.type && + baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + bucket, + includeCanonicalHeader, + name, + prefix, + type, + baseUrlForCanonicalHeader, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "S3{id=$id, bucket=$bucket, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + } + + class S3Compatible + private constructor( + private val id: JsonField, + private val bucket: JsonField, + private val endpoint: JsonField, + private val includeCanonicalHeader: JsonField, + private val name: JsonField, + private val prefix: JsonField, + private val s3ForcePathStyle: JsonField, + private val type: JsonValue, + private val baseUrlForCanonicalHeader: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), + @JsonProperty("endpoint") + @ExcludeMissing + endpoint: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + @JsonProperty("s3ForcePathStyle") + @ExcludeMissing + s3ForcePathStyle: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + ) : this( + id, + bucket, + endpoint, + includeCanonicalHeader, + name, + prefix, + s3ForcePathStyle, + type, + baseUrlForCanonicalHeader, + mutableMapOf(), + ) + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new + * origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * S3 bucket name. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun bucket(): String = bucket.getRequired("bucket") + + /** + * Custom S3-compatible endpoint. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun endpoint(): String = endpoint.getRequired("endpoint") + + /** + * Whether to send a Canonical header. + * + * @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 includeCanonicalHeader(): Boolean = + includeCanonicalHeader.getRequired("includeCanonicalHeader") + + /** + * Display name of the origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Path prefix inside the bucket. + * + * @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 prefix(): String = prefix.getRequired("prefix") + + /** + * Use path-style S3 URLs? + * + * @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 s3ForcePathStyle(): Boolean = s3ForcePathStyle.getRequired("s3ForcePathStyle") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("S3_COMPATIBLE") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * URL used in the Canonical header (if enabled). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun baseUrlForCanonicalHeader(): Optional = + baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") + + /** + * 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 [bucket]. + * + * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket + + /** + * Returns the raw JSON value of [endpoint]. + * + * Unlike [endpoint], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("endpoint") @ExcludeMissing fun _endpoint(): JsonField = endpoint + + /** + * Returns the raw JSON value of [includeCanonicalHeader]. + * + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + + /** + * 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 [prefix]. + * + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + + /** + * Returns the raw JSON value of [s3ForcePathStyle]. + * + * Unlike [s3ForcePathStyle], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("s3ForcePathStyle") + @ExcludeMissing + fun _s3ForcePathStyle(): JsonField = s3ForcePathStyle + + /** + * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [S3Compatible]. + * + * The following fields are required: + * ```java + * .id() + * .bucket() + * .endpoint() + * .includeCanonicalHeader() + * .name() + * .prefix() + * .s3ForcePathStyle() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [S3Compatible]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var bucket: JsonField? = null + private var endpoint: JsonField? = null + private var includeCanonicalHeader: JsonField? = null + private var name: JsonField? = null + private var prefix: JsonField? = null + private var s3ForcePathStyle: JsonField? = null + private var type: JsonValue = JsonValue.from("S3_COMPATIBLE") + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(s3Compatible: S3Compatible) = apply { + id = s3Compatible.id + bucket = s3Compatible.bucket + endpoint = s3Compatible.endpoint + includeCanonicalHeader = s3Compatible.includeCanonicalHeader + name = s3Compatible.name + prefix = s3Compatible.prefix + s3ForcePathStyle = s3Compatible.s3ForcePathStyle + type = s3Compatible.type + baseUrlForCanonicalHeader = s3Compatible.baseUrlForCanonicalHeader + additionalProperties = s3Compatible.additionalProperties.toMutableMap() + } + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new + * origin. + */ + 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 } + + /** S3 bucket name. */ + fun bucket(bucket: String) = bucket(JsonField.of(bucket)) + + /** + * Sets [Builder.bucket] to an arbitrary JSON value. + * + * You should usually call [Builder.bucket] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bucket(bucket: JsonField) = apply { this.bucket = bucket } + + /** Custom S3-compatible endpoint. */ + fun endpoint(endpoint: String) = endpoint(JsonField.of(endpoint)) + + /** + * Sets [Builder.endpoint] to an arbitrary JSON value. + * + * You should usually call [Builder.endpoint] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endpoint(endpoint: JsonField) = apply { this.endpoint = endpoint } + + /** Whether to send a Canonical header. */ + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + + /** + * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.includeCanonicalHeader] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader + } + + /** Display name of the origin. */ + 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 } + + /** Path prefix inside the bucket. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + + /** + * Sets [Builder.prefix] to an arbitrary JSON value. + * + * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } + + /** Use path-style S3 URLs? */ + fun s3ForcePathStyle(s3ForcePathStyle: Boolean) = + s3ForcePathStyle(JsonField.of(s3ForcePathStyle)) + + /** + * Sets [Builder.s3ForcePathStyle] to an arbitrary JSON value. + * + * You should usually call [Builder.s3ForcePathStyle] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun s3ForcePathStyle(s3ForcePathStyle: JsonField) = apply { + this.s3ForcePathStyle = s3ForcePathStyle + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("S3_COMPATIBLE") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** URL used in the Canonical header (if enabled). */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = + baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) + + /** + * Sets [Builder.baseUrlForCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrlForCanonicalHeader] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [S3Compatible]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .bucket() + * .endpoint() + * .includeCanonicalHeader() + * .name() + * .prefix() + * .s3ForcePathStyle() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): S3Compatible = + S3Compatible( + checkRequired("id", id), + checkRequired("bucket", bucket), + checkRequired("endpoint", endpoint), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("prefix", prefix), + checkRequired("s3ForcePathStyle", s3ForcePathStyle), + type, + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): S3Compatible = apply { + if (validated) { + return@apply + } + + id() + bucket() + endpoint() + includeCanonicalHeader() + name() + prefix() + s3ForcePathStyle() + _type().let { + if (it != JsonValue.from("S3_COMPATIBLE")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + baseUrlForCanonicalHeader() + 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 (bucket.asKnown().isPresent) 1 else 0) + + (if (endpoint.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + (if (s3ForcePathStyle.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("S3_COMPATIBLE")) 1 else 0 } + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is S3Compatible && + id == other.id && + bucket == other.bucket && + endpoint == other.endpoint && + includeCanonicalHeader == other.includeCanonicalHeader && + name == other.name && + prefix == other.prefix && + s3ForcePathStyle == other.s3ForcePathStyle && + type == other.type && + baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + bucket, + endpoint, + includeCanonicalHeader, + name, + prefix, + s3ForcePathStyle, + type, + baseUrlForCanonicalHeader, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "S3Compatible{id=$id, bucket=$bucket, endpoint=$endpoint, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, s3ForcePathStyle=$s3ForcePathStyle, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + } + + class CloudinaryBackup + private constructor( + private val id: JsonField, + private val bucket: JsonField, + private val includeCanonicalHeader: JsonField, + private val name: JsonField, + private val prefix: JsonField, + private val type: JsonValue, + private val baseUrlForCanonicalHeader: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + ) : this( + id, + bucket, + includeCanonicalHeader, + name, + prefix, + type, + baseUrlForCanonicalHeader, + mutableMapOf(), + ) + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new + * origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * S3 bucket name. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun bucket(): String = bucket.getRequired("bucket") + + /** + * Whether to send a Canonical header. + * + * @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 includeCanonicalHeader(): Boolean = + includeCanonicalHeader.getRequired("includeCanonicalHeader") + + /** + * Display name of the origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Path prefix inside the bucket. + * + * @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 prefix(): String = prefix.getRequired("prefix") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("CLOUDINARY_BACKUP") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * URL used in the Canonical header (if enabled). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun baseUrlForCanonicalHeader(): Optional = + baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") + + /** + * 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 [bucket]. + * + * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket + + /** + * Returns the raw JSON value of [includeCanonicalHeader]. + * + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + + /** + * 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 [prefix]. + * + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + + /** + * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CloudinaryBackup]. + * + * The following fields are required: + * ```java + * .id() + * .bucket() + * .includeCanonicalHeader() + * .name() + * .prefix() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CloudinaryBackup]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var bucket: JsonField? = null + private var includeCanonicalHeader: JsonField? = null + private var name: JsonField? = null + private var prefix: JsonField? = null + private var type: JsonValue = JsonValue.from("CLOUDINARY_BACKUP") + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cloudinaryBackup: CloudinaryBackup) = apply { + id = cloudinaryBackup.id + bucket = cloudinaryBackup.bucket + includeCanonicalHeader = cloudinaryBackup.includeCanonicalHeader + name = cloudinaryBackup.name + prefix = cloudinaryBackup.prefix + type = cloudinaryBackup.type + baseUrlForCanonicalHeader = cloudinaryBackup.baseUrlForCanonicalHeader + additionalProperties = cloudinaryBackup.additionalProperties.toMutableMap() + } + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new + * origin. + */ + 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 } + + /** S3 bucket name. */ + fun bucket(bucket: String) = bucket(JsonField.of(bucket)) + + /** + * Sets [Builder.bucket] to an arbitrary JSON value. + * + * You should usually call [Builder.bucket] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bucket(bucket: JsonField) = apply { this.bucket = bucket } + + /** Whether to send a Canonical header. */ + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + + /** + * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.includeCanonicalHeader] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader + } + + /** Display name of the origin. */ + 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 } + + /** Path prefix inside the bucket. */ + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + + /** + * Sets [Builder.prefix] to an arbitrary JSON value. + * + * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("CLOUDINARY_BACKUP") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** URL used in the Canonical header (if enabled). */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = + baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) + + /** + * Sets [Builder.baseUrlForCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrlForCanonicalHeader] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CloudinaryBackup]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .bucket() + * .includeCanonicalHeader() + * .name() + * .prefix() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CloudinaryBackup = + CloudinaryBackup( + checkRequired("id", id), + checkRequired("bucket", bucket), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("prefix", prefix), + type, + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CloudinaryBackup = apply { + if (validated) { + return@apply + } + + id() + bucket() + includeCanonicalHeader() + name() + prefix() + _type().let { + if (it != JsonValue.from("CLOUDINARY_BACKUP")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + baseUrlForCanonicalHeader() + 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 (bucket.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("CLOUDINARY_BACKUP")) 1 else 0 } + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CloudinaryBackup && + id == other.id && + bucket == other.bucket && + includeCanonicalHeader == other.includeCanonicalHeader && + name == other.name && + prefix == other.prefix && + type == other.type && + baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + bucket, + includeCanonicalHeader, + name, + prefix, + type, + baseUrlForCanonicalHeader, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CloudinaryBackup{id=$id, bucket=$bucket, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + } + + class WebFolder + private constructor( + private val id: JsonField, + private val baseUrl: JsonField, + private val forwardHostHeaderToOrigin: JsonField, + private val includeCanonicalHeader: JsonField, + private val name: JsonField, + private val type: JsonValue, + private val baseUrlForCanonicalHeader: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), + @JsonProperty("forwardHostHeaderToOrigin") + @ExcludeMissing + forwardHostHeaderToOrigin: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + ) : this( + id, + baseUrl, + forwardHostHeaderToOrigin, + includeCanonicalHeader, + name, + type, + baseUrlForCanonicalHeader, + mutableMapOf(), + ) + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new + * origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Root URL for the web folder origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun baseUrl(): String = baseUrl.getRequired("baseUrl") + + /** + * Forward the Host header to origin? + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun forwardHostHeaderToOrigin(): Boolean = + forwardHostHeaderToOrigin.getRequired("forwardHostHeaderToOrigin") + + /** + * Whether to send a Canonical header. + * + * @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 includeCanonicalHeader(): Boolean = + includeCanonicalHeader.getRequired("includeCanonicalHeader") + + /** + * Display name of the origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("WEB_FOLDER") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * URL used in the Canonical header (if enabled). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun baseUrlForCanonicalHeader(): Optional = + baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") + + /** + * 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 [baseUrl]. + * + * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl + + /** + * Returns the raw JSON value of [forwardHostHeaderToOrigin]. + * + * Unlike [forwardHostHeaderToOrigin], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("forwardHostHeaderToOrigin") + @ExcludeMissing + fun _forwardHostHeaderToOrigin(): JsonField = forwardHostHeaderToOrigin + + /** + * Returns the raw JSON value of [includeCanonicalHeader]. + * + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + + /** + * 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 [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [WebFolder]. + * + * The following fields are required: + * ```java + * .id() + * .baseUrl() + * .forwardHostHeaderToOrigin() + * .includeCanonicalHeader() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebFolder]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var baseUrl: JsonField? = null + private var forwardHostHeaderToOrigin: JsonField? = null + private var includeCanonicalHeader: JsonField? = null + private var name: JsonField? = null + private var type: JsonValue = JsonValue.from("WEB_FOLDER") + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webFolder: WebFolder) = apply { + id = webFolder.id + baseUrl = webFolder.baseUrl + forwardHostHeaderToOrigin = webFolder.forwardHostHeaderToOrigin + includeCanonicalHeader = webFolder.includeCanonicalHeader + name = webFolder.name + type = webFolder.type + baseUrlForCanonicalHeader = webFolder.baseUrlForCanonicalHeader + additionalProperties = webFolder.additionalProperties.toMutableMap() + } + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new + * origin. + */ + 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 } + + /** Root URL for the web folder origin. */ + fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) + + /** + * Sets [Builder.baseUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } + + /** Forward the Host header to origin? */ + fun forwardHostHeaderToOrigin(forwardHostHeaderToOrigin: Boolean) = + forwardHostHeaderToOrigin(JsonField.of(forwardHostHeaderToOrigin)) + + /** + * Sets [Builder.forwardHostHeaderToOrigin] to an arbitrary JSON value. + * + * You should usually call [Builder.forwardHostHeaderToOrigin] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun forwardHostHeaderToOrigin(forwardHostHeaderToOrigin: JsonField) = apply { + this.forwardHostHeaderToOrigin = forwardHostHeaderToOrigin + } + + /** Whether to send a Canonical header. */ + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + + /** + * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.includeCanonicalHeader] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader + } + + /** Display name of the origin. */ + 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 } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("WEB_FOLDER") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** URL used in the Canonical header (if enabled). */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = + baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) + + /** + * Sets [Builder.baseUrlForCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrlForCanonicalHeader] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [WebFolder]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .baseUrl() + * .forwardHostHeaderToOrigin() + * .includeCanonicalHeader() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WebFolder = + WebFolder( + checkRequired("id", id), + checkRequired("baseUrl", baseUrl), + checkRequired("forwardHostHeaderToOrigin", forwardHostHeaderToOrigin), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + type, + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WebFolder = apply { + if (validated) { + return@apply + } + + id() + baseUrl() + forwardHostHeaderToOrigin() + includeCanonicalHeader() + name() + _type().let { + if (it != JsonValue.from("WEB_FOLDER")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + baseUrlForCanonicalHeader() + 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 (baseUrl.asKnown().isPresent) 1 else 0) + + (if (forwardHostHeaderToOrigin.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("WEB_FOLDER")) 1 else 0 } + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WebFolder && + id == other.id && + baseUrl == other.baseUrl && + forwardHostHeaderToOrigin == other.forwardHostHeaderToOrigin && + includeCanonicalHeader == other.includeCanonicalHeader && + name == other.name && + type == other.type && + baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + baseUrl, + forwardHostHeaderToOrigin, + includeCanonicalHeader, + name, + type, + baseUrlForCanonicalHeader, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "WebFolder{id=$id, baseUrl=$baseUrl, forwardHostHeaderToOrigin=$forwardHostHeaderToOrigin, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + } + + class WebProxy + private constructor( + private val id: JsonField, + private val includeCanonicalHeader: JsonField, + private val name: JsonField, + private val type: JsonValue, + private val baseUrlForCanonicalHeader: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + ) : this(id, includeCanonicalHeader, name, type, baseUrlForCanonicalHeader, mutableMapOf()) + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new + * origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Whether to send a Canonical header. + * + * @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 includeCanonicalHeader(): Boolean = + includeCanonicalHeader.getRequired("includeCanonicalHeader") + + /** + * Display name of the origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("WEB_PROXY") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * URL used in the Canonical header (if enabled). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun baseUrlForCanonicalHeader(): Optional = + baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") + + /** + * 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 [includeCanonicalHeader]. + * + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + + /** + * 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 [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [WebProxy]. + * + * The following fields are required: + * ```java + * .id() + * .includeCanonicalHeader() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebProxy]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var includeCanonicalHeader: JsonField? = null + private var name: JsonField? = null + private var type: JsonValue = JsonValue.from("WEB_PROXY") + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webProxy: WebProxy) = apply { + id = webProxy.id + includeCanonicalHeader = webProxy.includeCanonicalHeader + name = webProxy.name + type = webProxy.type + baseUrlForCanonicalHeader = webProxy.baseUrlForCanonicalHeader + additionalProperties = webProxy.additionalProperties.toMutableMap() + } + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new + * origin. + */ + 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 } + + /** Whether to send a Canonical header. */ + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + + /** + * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.includeCanonicalHeader] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader + } + + /** Display name of the origin. */ + 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 } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("WEB_PROXY") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** URL used in the Canonical header (if enabled). */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = + baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) + + /** + * Sets [Builder.baseUrlForCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrlForCanonicalHeader] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [WebProxy]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .includeCanonicalHeader() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WebProxy = + WebProxy( + checkRequired("id", id), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + type, + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WebProxy = apply { + if (validated) { + return@apply + } + + id() + includeCanonicalHeader() + name() + _type().let { + if (it != JsonValue.from("WEB_PROXY")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + baseUrlForCanonicalHeader() + 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 (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("WEB_PROXY")) 1 else 0 } + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WebProxy && + id == other.id && + includeCanonicalHeader == other.includeCanonicalHeader && + name == other.name && + type == other.type && + baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + includeCanonicalHeader, + name, + type, + baseUrlForCanonicalHeader, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "WebProxy{id=$id, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + } + + class Gcs + private constructor( + private val id: JsonField, + private val bucket: JsonField, + private val clientEmail: JsonField, + private val includeCanonicalHeader: JsonField, + private val name: JsonField, + private val prefix: JsonField, + private val type: JsonValue, + private val baseUrlForCanonicalHeader: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("bucket") @ExcludeMissing bucket: JsonField = JsonMissing.of(), + @JsonProperty("clientEmail") + @ExcludeMissing + clientEmail: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + ) : this( + id, + bucket, + clientEmail, + includeCanonicalHeader, + name, + prefix, + type, + baseUrlForCanonicalHeader, + mutableMapOf(), + ) + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new + * origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @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 bucket(): String = bucket.getRequired("bucket") + + /** + * @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 clientEmail(): String = clientEmail.getRequired("clientEmail") + + /** + * Whether to send a Canonical header. + * + * @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 includeCanonicalHeader(): Boolean = + includeCanonicalHeader.getRequired("includeCanonicalHeader") + + /** + * Display name of the origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun prefix(): String = prefix.getRequired("prefix") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("GCS") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * URL used in the Canonical header (if enabled). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun baseUrlForCanonicalHeader(): Optional = + baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") + + /** + * 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 [bucket]. + * + * Unlike [bucket], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bucket") @ExcludeMissing fun _bucket(): JsonField = bucket + + /** + * Returns the raw JSON value of [clientEmail]. + * + * Unlike [clientEmail], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("clientEmail") + @ExcludeMissing + fun _clientEmail(): JsonField = clientEmail + + /** + * Returns the raw JSON value of [includeCanonicalHeader]. + * + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + + /** + * 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 [prefix]. + * + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + + /** + * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Gcs]. + * + * The following fields are required: + * ```java + * .id() + * .bucket() + * .clientEmail() + * .includeCanonicalHeader() + * .name() + * .prefix() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Gcs]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var bucket: JsonField? = null + private var clientEmail: JsonField? = null + private var includeCanonicalHeader: JsonField? = null + private var name: JsonField? = null + private var prefix: JsonField? = null + private var type: JsonValue = JsonValue.from("GCS") + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(gcs: Gcs) = apply { + id = gcs.id + bucket = gcs.bucket + clientEmail = gcs.clientEmail + includeCanonicalHeader = gcs.includeCanonicalHeader + name = gcs.name + prefix = gcs.prefix + type = gcs.type + baseUrlForCanonicalHeader = gcs.baseUrlForCanonicalHeader + additionalProperties = gcs.additionalProperties.toMutableMap() + } + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new + * origin. + */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun bucket(bucket: String) = bucket(JsonField.of(bucket)) + + /** + * Sets [Builder.bucket] to an arbitrary JSON value. + * + * You should usually call [Builder.bucket] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bucket(bucket: JsonField) = apply { this.bucket = bucket } + + fun clientEmail(clientEmail: String) = clientEmail(JsonField.of(clientEmail)) + + /** + * Sets [Builder.clientEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.clientEmail] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun clientEmail(clientEmail: JsonField) = apply { + this.clientEmail = clientEmail + } + + /** Whether to send a Canonical header. */ + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + + /** + * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.includeCanonicalHeader] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader + } + + /** Display name of the origin. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + + /** + * Sets [Builder.prefix] to an arbitrary JSON value. + * + * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("GCS") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** URL used in the Canonical header (if enabled). */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = + baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) + + /** + * Sets [Builder.baseUrlForCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrlForCanonicalHeader] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Gcs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .bucket() + * .clientEmail() + * .includeCanonicalHeader() + * .name() + * .prefix() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Gcs = + Gcs( + checkRequired("id", id), + checkRequired("bucket", bucket), + checkRequired("clientEmail", clientEmail), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("prefix", prefix), + type, + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Gcs = apply { + if (validated) { + return@apply + } + + id() + bucket() + clientEmail() + includeCanonicalHeader() + name() + prefix() + _type().let { + if (it != JsonValue.from("GCS")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + baseUrlForCanonicalHeader() + 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 (bucket.asKnown().isPresent) 1 else 0) + + (if (clientEmail.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("GCS")) 1 else 0 } + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Gcs && + id == other.id && + bucket == other.bucket && + clientEmail == other.clientEmail && + includeCanonicalHeader == other.includeCanonicalHeader && + name == other.name && + prefix == other.prefix && + type == other.type && + baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + bucket, + clientEmail, + includeCanonicalHeader, + name, + prefix, + type, + baseUrlForCanonicalHeader, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Gcs{id=$id, bucket=$bucket, clientEmail=$clientEmail, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + } + + class AzureBlob + private constructor( + private val id: JsonField, + private val accountName: JsonField, + private val container: JsonField, + private val includeCanonicalHeader: JsonField, + private val name: JsonField, + private val prefix: JsonField, + private val type: JsonValue, + private val baseUrlForCanonicalHeader: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("accountName") + @ExcludeMissing + accountName: JsonField = JsonMissing.of(), + @JsonProperty("container") + @ExcludeMissing + container: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + ) : this( + id, + accountName, + container, + includeCanonicalHeader, + name, + prefix, + type, + baseUrlForCanonicalHeader, + mutableMapOf(), + ) + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new + * origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @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 accountName(): String = accountName.getRequired("accountName") + + /** + * @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 container(): String = container.getRequired("container") + + /** + * Whether to send a Canonical header. + * + * @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 includeCanonicalHeader(): Boolean = + includeCanonicalHeader.getRequired("includeCanonicalHeader") + + /** + * Display name of the origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun prefix(): String = prefix.getRequired("prefix") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("AZURE_BLOB") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * URL used in the Canonical header (if enabled). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun baseUrlForCanonicalHeader(): Optional = + baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") + + /** + * 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 [accountName]. + * + * Unlike [accountName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("accountName") + @ExcludeMissing + fun _accountName(): JsonField = accountName + + /** + * Returns the raw JSON value of [container]. + * + * Unlike [container], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("container") @ExcludeMissing fun _container(): JsonField = container + + /** + * Returns the raw JSON value of [includeCanonicalHeader]. + * + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + + /** + * 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 [prefix]. + * + * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix + + /** + * Returns the raw JSON value of [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AzureBlob]. + * + * The following fields are required: + * ```java + * .id() + * .accountName() + * .container() + * .includeCanonicalHeader() + * .name() + * .prefix() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AzureBlob]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var accountName: JsonField? = null + private var container: JsonField? = null + private var includeCanonicalHeader: JsonField? = null + private var name: JsonField? = null + private var prefix: JsonField? = null + private var type: JsonValue = JsonValue.from("AZURE_BLOB") + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(azureBlob: AzureBlob) = apply { + id = azureBlob.id + accountName = azureBlob.accountName + container = azureBlob.container + includeCanonicalHeader = azureBlob.includeCanonicalHeader + name = azureBlob.name + prefix = azureBlob.prefix + type = azureBlob.type + baseUrlForCanonicalHeader = azureBlob.baseUrlForCanonicalHeader + additionalProperties = azureBlob.additionalProperties.toMutableMap() + } + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new + * origin. + */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun accountName(accountName: String) = accountName(JsonField.of(accountName)) + + /** + * Sets [Builder.accountName] to an arbitrary JSON value. + * + * You should usually call [Builder.accountName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accountName(accountName: JsonField) = apply { + this.accountName = accountName + } + + fun container(container: String) = container(JsonField.of(container)) + + /** + * Sets [Builder.container] to an arbitrary JSON value. + * + * You should usually call [Builder.container] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun container(container: JsonField) = apply { this.container = container } + + /** Whether to send a Canonical header. */ + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + + /** + * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.includeCanonicalHeader] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader + } + + /** Display name of the origin. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun prefix(prefix: String) = prefix(JsonField.of(prefix)) + + /** + * Sets [Builder.prefix] to an arbitrary JSON value. + * + * You should usually call [Builder.prefix] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun prefix(prefix: JsonField) = apply { this.prefix = prefix } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("AZURE_BLOB") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** URL used in the Canonical header (if enabled). */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = + baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) + + /** + * Sets [Builder.baseUrlForCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrlForCanonicalHeader] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AzureBlob]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .accountName() + * .container() + * .includeCanonicalHeader() + * .name() + * .prefix() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AzureBlob = + AzureBlob( + checkRequired("id", id), + checkRequired("accountName", accountName), + checkRequired("container", container), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + checkRequired("prefix", prefix), + type, + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AzureBlob = apply { + if (validated) { + return@apply + } + + id() + accountName() + container() + includeCanonicalHeader() + name() + prefix() + _type().let { + if (it != JsonValue.from("AZURE_BLOB")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + baseUrlForCanonicalHeader() + 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 (accountName.asKnown().isPresent) 1 else 0) + + (if (container.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (prefix.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("AZURE_BLOB")) 1 else 0 } + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AzureBlob && + id == other.id && + accountName == other.accountName && + container == other.container && + includeCanonicalHeader == other.includeCanonicalHeader && + name == other.name && + prefix == other.prefix && + type == other.type && + baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + accountName, + container, + includeCanonicalHeader, + name, + prefix, + type, + baseUrlForCanonicalHeader, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AzureBlob{id=$id, accountName=$accountName, container=$container, includeCanonicalHeader=$includeCanonicalHeader, name=$name, prefix=$prefix, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + } + + class AkeneoPim + private constructor( + private val id: JsonField, + private val baseUrl: JsonField, + private val includeCanonicalHeader: JsonField, + private val name: JsonField, + private val type: JsonValue, + private val baseUrlForCanonicalHeader: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("baseUrl") @ExcludeMissing baseUrl: JsonField = JsonMissing.of(), + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + includeCanonicalHeader: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + baseUrlForCanonicalHeader: JsonField = JsonMissing.of(), + ) : this( + id, + baseUrl, + includeCanonicalHeader, + name, + type, + baseUrlForCanonicalHeader, + mutableMapOf(), + ) + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new + * origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Akeneo instance base URL. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun baseUrl(): String = baseUrl.getRequired("baseUrl") + + /** + * Whether to send a Canonical header. + * + * @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 includeCanonicalHeader(): Boolean = + includeCanonicalHeader.getRequired("includeCanonicalHeader") + + /** + * Display name of the origin. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("AKENEO_PIM") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * URL used in the Canonical header (if enabled). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun baseUrlForCanonicalHeader(): Optional = + baseUrlForCanonicalHeader.getOptional("baseUrlForCanonicalHeader") + + /** + * 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 [baseUrl]. + * + * Unlike [baseUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("baseUrl") @ExcludeMissing fun _baseUrl(): JsonField = baseUrl + + /** + * Returns the raw JSON value of [includeCanonicalHeader]. + * + * Unlike [includeCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeCanonicalHeader") + @ExcludeMissing + fun _includeCanonicalHeader(): JsonField = includeCanonicalHeader + + /** + * 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 [baseUrlForCanonicalHeader]. + * + * Unlike [baseUrlForCanonicalHeader], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("baseUrlForCanonicalHeader") + @ExcludeMissing + fun _baseUrlForCanonicalHeader(): JsonField = baseUrlForCanonicalHeader + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AkeneoPim]. + * + * The following fields are required: + * ```java + * .id() + * .baseUrl() + * .includeCanonicalHeader() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AkeneoPim]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var baseUrl: JsonField? = null + private var includeCanonicalHeader: JsonField? = null + private var name: JsonField? = null + private var type: JsonValue = JsonValue.from("AKENEO_PIM") + private var baseUrlForCanonicalHeader: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(akeneoPim: AkeneoPim) = apply { + id = akeneoPim.id + baseUrl = akeneoPim.baseUrl + includeCanonicalHeader = akeneoPim.includeCanonicalHeader + name = akeneoPim.name + type = akeneoPim.type + baseUrlForCanonicalHeader = akeneoPim.baseUrlForCanonicalHeader + additionalProperties = akeneoPim.additionalProperties.toMutableMap() + } + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new + * origin. + */ + 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 } + + /** Akeneo instance base URL. */ + fun baseUrl(baseUrl: String) = baseUrl(JsonField.of(baseUrl)) + + /** + * Sets [Builder.baseUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun baseUrl(baseUrl: JsonField) = apply { this.baseUrl = baseUrl } + + /** Whether to send a Canonical header. */ + fun includeCanonicalHeader(includeCanonicalHeader: Boolean) = + includeCanonicalHeader(JsonField.of(includeCanonicalHeader)) + + /** + * Sets [Builder.includeCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.includeCanonicalHeader] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeCanonicalHeader(includeCanonicalHeader: JsonField) = apply { + this.includeCanonicalHeader = includeCanonicalHeader + } + + /** Display name of the origin. */ + 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 } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("AKENEO_PIM") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** URL used in the Canonical header (if enabled). */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: String) = + baseUrlForCanonicalHeader(JsonField.of(baseUrlForCanonicalHeader)) + + /** + * Sets [Builder.baseUrlForCanonicalHeader] to an arbitrary JSON value. + * + * You should usually call [Builder.baseUrlForCanonicalHeader] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun baseUrlForCanonicalHeader(baseUrlForCanonicalHeader: JsonField) = apply { + this.baseUrlForCanonicalHeader = baseUrlForCanonicalHeader + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AkeneoPim]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .baseUrl() + * .includeCanonicalHeader() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AkeneoPim = + AkeneoPim( + checkRequired("id", id), + checkRequired("baseUrl", baseUrl), + checkRequired("includeCanonicalHeader", includeCanonicalHeader), + checkRequired("name", name), + type, + baseUrlForCanonicalHeader, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AkeneoPim = apply { + if (validated) { + return@apply + } + + id() + baseUrl() + includeCanonicalHeader() + name() + _type().let { + if (it != JsonValue.from("AKENEO_PIM")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + baseUrlForCanonicalHeader() + 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 (baseUrl.asKnown().isPresent) 1 else 0) + + (if (includeCanonicalHeader.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("AKENEO_PIM")) 1 else 0 } + + (if (baseUrlForCanonicalHeader.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AkeneoPim && + id == other.id && + baseUrl == other.baseUrl && + includeCanonicalHeader == other.includeCanonicalHeader && + name == other.name && + type == other.type && + baseUrlForCanonicalHeader == other.baseUrlForCanonicalHeader && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + baseUrl, + includeCanonicalHeader, + name, + type, + baseUrlForCanonicalHeader, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AkeneoPim{id=$id, baseUrl=$baseUrl, includeCanonicalHeader=$includeCanonicalHeader, name=$name, type=$type, baseUrlForCanonicalHeader=$baseUrlForCanonicalHeader, additionalProperties=$additionalProperties}" + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParams.kt new file mode 100644 index 00000000..3b73cbad --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParams.kt @@ -0,0 +1,270 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.origins + +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * **Note:** This API is currently in beta. Updates the origin identified by `id` and returns the + * updated origin object. + */ +class OriginUpdateParams +private constructor( + private val id: String?, + private val origin: OriginRequest, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new origin. + */ + fun id(): Optional = Optional.ofNullable(id) + + /** Schema for origin request resources. */ + fun origin(): OriginRequest = origin + + /** 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 [OriginUpdateParams]. + * + * The following fields are required: + * ```java + * .origin() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OriginUpdateParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var origin: OriginRequest? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(originUpdateParams: OriginUpdateParams) = apply { + id = originUpdateParams.id + origin = originUpdateParams.origin + additionalHeaders = originUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = originUpdateParams.additionalQueryParams.toBuilder() + } + + /** + * Unique identifier for the origin. This is generated by ImageKit when you create a new + * origin. + */ + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + /** Schema for origin request resources. */ + fun origin(origin: OriginRequest) = apply { this.origin = origin } + + /** Alias for calling [origin] with `OriginRequest.ofS3(s3)`. */ + fun origin(s3: OriginRequest.S3) = origin(OriginRequest.ofS3(s3)) + + /** Alias for calling [origin] with `OriginRequest.ofS3Compatible(s3Compatible)`. */ + fun origin(s3Compatible: OriginRequest.S3Compatible) = + origin(OriginRequest.ofS3Compatible(s3Compatible)) + + /** Alias for calling [origin] with `OriginRequest.ofCloudinaryBackup(cloudinaryBackup)`. */ + fun origin(cloudinaryBackup: OriginRequest.CloudinaryBackup) = + origin(OriginRequest.ofCloudinaryBackup(cloudinaryBackup)) + + /** Alias for calling [origin] with `OriginRequest.ofWebFolder(webFolder)`. */ + fun origin(webFolder: OriginRequest.WebFolder) = + origin(OriginRequest.ofWebFolder(webFolder)) + + /** Alias for calling [origin] with `OriginRequest.ofWebProxy(webProxy)`. */ + fun origin(webProxy: OriginRequest.WebProxy) = origin(OriginRequest.ofWebProxy(webProxy)) + + /** + * Alias for calling [origin] with the following: + * ```java + * OriginRequest.WebProxy.builder() + * .name(name) + * .build() + * ``` + */ + fun webProxyOrigin(name: String) = + origin(OriginRequest.WebProxy.builder().name(name).build()) + + /** Alias for calling [origin] with `OriginRequest.ofGcs(gcs)`. */ + fun origin(gcs: OriginRequest.Gcs) = origin(OriginRequest.ofGcs(gcs)) + + /** Alias for calling [origin] with `OriginRequest.ofAzureBlob(azureBlob)`. */ + fun origin(azureBlob: OriginRequest.AzureBlob) = + origin(OriginRequest.ofAzureBlob(azureBlob)) + + /** Alias for calling [origin] with `OriginRequest.ofAkeneoPim(akeneoPim)`. */ + fun origin(akeneoPim: OriginRequest.AkeneoPim) = + origin(OriginRequest.ofAkeneoPim(akeneoPim)) + + 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 [OriginUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .origin() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OriginUpdateParams = + OriginUpdateParams( + id, + checkRequired("origin", origin), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): OriginRequest = origin + + 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 OriginUpdateParams && + id == other.id && + origin == other.origin && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(id, origin, additionalHeaders, additionalQueryParams) + + override fun toString() = + "OriginUpdateParams{id=$id, origin=$origin, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParams.kt new file mode 100644 index 00000000..82e57e9a --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParams.kt @@ -0,0 +1,209 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.urlendpoints + +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import java.util.Objects + +/** + * **Note:** This API is currently in beta. Creates a new URL‑endpoint and returns the resulting + * object. + */ +class UrlEndpointCreateParams +private constructor( + private val urlEndpointRequest: UrlEndpointRequest, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Schema for URL endpoint resource. */ + fun urlEndpointRequest(): UrlEndpointRequest = urlEndpointRequest + + fun _additionalBodyProperties(): Map = + urlEndpointRequest._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 [UrlEndpointCreateParams]. + * + * The following fields are required: + * ```java + * .urlEndpointRequest() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UrlEndpointCreateParams]. */ + class Builder internal constructor() { + + private var urlEndpointRequest: UrlEndpointRequest? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(urlEndpointCreateParams: UrlEndpointCreateParams) = apply { + urlEndpointRequest = urlEndpointCreateParams.urlEndpointRequest + additionalHeaders = urlEndpointCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = urlEndpointCreateParams.additionalQueryParams.toBuilder() + } + + /** Schema for URL endpoint resource. */ + fun urlEndpointRequest(urlEndpointRequest: UrlEndpointRequest) = apply { + this.urlEndpointRequest = urlEndpointRequest + } + + 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 [UrlEndpointCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .urlEndpointRequest() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UrlEndpointCreateParams = + UrlEndpointCreateParams( + checkRequired("urlEndpointRequest", urlEndpointRequest), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): UrlEndpointRequest = urlEndpointRequest + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UrlEndpointCreateParams && + urlEndpointRequest == other.urlEndpointRequest && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(urlEndpointRequest, additionalHeaders, additionalQueryParams) + + override fun toString() = + "UrlEndpointCreateParams{urlEndpointRequest=$urlEndpointRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt new file mode 100644 index 00000000..754f9291 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt @@ -0,0 +1,241 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.urlendpoints + +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * **Note:** This API is currently in beta. Deletes the URL‑endpoint identified by `id`. You cannot + * delete the default URL‑endpoint created by ImageKit during account creation. + */ +class UrlEndpointDeleteParams +private constructor( + private val id: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + /** + * Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new + * URL-endpoint. For the default URL-endpoint, this is always `default`. + */ + 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(): UrlEndpointDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [UrlEndpointDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UrlEndpointDeleteParams]. */ + 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(urlEndpointDeleteParams: UrlEndpointDeleteParams) = apply { + id = urlEndpointDeleteParams.id + additionalHeaders = urlEndpointDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = urlEndpointDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + urlEndpointDeleteParams.additionalBodyProperties.toMutableMap() + } + + /** + * Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a + * new URL-endpoint. For the default URL-endpoint, this is always `default`. + */ + 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 [UrlEndpointDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UrlEndpointDeleteParams = + UrlEndpointDeleteParams( + 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 UrlEndpointDeleteParams && + 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() = + "UrlEndpointDeleteParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParams.kt new file mode 100644 index 00000000..a07244eb --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParams.kt @@ -0,0 +1,197 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.urlendpoints + +import com.imagekit.api.core.Params +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** **Note:** This API is currently in beta. Retrieves the URL‑endpoint identified by `id`. */ +class UrlEndpointGetParams +private constructor( + private val id: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new + * URL-endpoint. For the default URL-endpoint, this is always `default`. + */ + 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(): UrlEndpointGetParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [UrlEndpointGetParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UrlEndpointGetParams]. */ + 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(urlEndpointGetParams: UrlEndpointGetParams) = apply { + id = urlEndpointGetParams.id + additionalHeaders = urlEndpointGetParams.additionalHeaders.toBuilder() + additionalQueryParams = urlEndpointGetParams.additionalQueryParams.toBuilder() + } + + /** + * Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a + * new URL-endpoint. For the default URL-endpoint, this is always `default`. + */ + 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 [UrlEndpointGetParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UrlEndpointGetParams = + UrlEndpointGetParams(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 UrlEndpointGetParams && + id == other.id && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(id, additionalHeaders, additionalQueryParams) + + override fun toString() = + "UrlEndpointGetParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParams.kt new file mode 100644 index 00000000..a37cdaee --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParams.kt @@ -0,0 +1,173 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.urlendpoints + +import com.imagekit.api.core.Params +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import java.util.Objects + +/** + * **Note:** This API is currently in beta. Returns an array of all URL‑endpoints configured + * including the default URL-endpoint generated by ImageKit during account creation. + */ +class UrlEndpointListParams +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(): UrlEndpointListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [UrlEndpointListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UrlEndpointListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(urlEndpointListParams: UrlEndpointListParams) = apply { + additionalHeaders = urlEndpointListParams.additionalHeaders.toBuilder() + additionalQueryParams = urlEndpointListParams.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 [UrlEndpointListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UrlEndpointListParams = + UrlEndpointListParams(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 UrlEndpointListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "UrlEndpointListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequest.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequest.kt new file mode 100644 index 00000000..40f3d600 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequest.kt @@ -0,0 +1,751 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.urlendpoints + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Schema for URL endpoint resource. */ +class UrlEndpointRequest +private constructor( + private val description: JsonField, + private val origins: JsonField>, + private val urlPrefix: JsonField, + private val urlRewriter: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("origins") + @ExcludeMissing + origins: JsonField> = JsonMissing.of(), + @JsonProperty("urlPrefix") @ExcludeMissing urlPrefix: JsonField = JsonMissing.of(), + @JsonProperty("urlRewriter") + @ExcludeMissing + urlRewriter: JsonField = JsonMissing.of(), + ) : this(description, origins, urlPrefix, urlRewriter, mutableMapOf()) + + /** + * Description of the URL endpoint. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun description(): String = description.getRequired("description") + + /** + * Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks + * them in the sequence provided. Origin must be created before it can be used in a URL + * endpoint. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun origins(): Optional> = origins.getOptional("origins") + + /** + * Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens + * only — or empty for the default endpoint). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun urlPrefix(): Optional = urlPrefix.getOptional("urlPrefix") + + /** + * Configuration for third-party URL rewriting. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun urlRewriter(): Optional = urlRewriter.getOptional("urlRewriter") + + /** + * 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 [origins]. + * + * Unlike [origins], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("origins") @ExcludeMissing fun _origins(): JsonField> = origins + + /** + * Returns the raw JSON value of [urlPrefix]. + * + * Unlike [urlPrefix], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("urlPrefix") @ExcludeMissing fun _urlPrefix(): JsonField = urlPrefix + + /** + * Returns the raw JSON value of [urlRewriter]. + * + * Unlike [urlRewriter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("urlRewriter") + @ExcludeMissing + fun _urlRewriter(): JsonField = urlRewriter + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UrlEndpointRequest]. + * + * The following fields are required: + * ```java + * .description() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UrlEndpointRequest]. */ + class Builder internal constructor() { + + private var description: JsonField? = null + private var origins: JsonField>? = null + private var urlPrefix: JsonField = JsonMissing.of() + private var urlRewriter: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(urlEndpointRequest: UrlEndpointRequest) = apply { + description = urlEndpointRequest.description + origins = urlEndpointRequest.origins.map { it.toMutableList() } + urlPrefix = urlEndpointRequest.urlPrefix + urlRewriter = urlEndpointRequest.urlRewriter + additionalProperties = urlEndpointRequest.additionalProperties.toMutableMap() + } + + /** Description of the URL endpoint. */ + 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 } + + /** + * Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit + * checks them in the sequence provided. Origin must be created before it can be used in a + * URL endpoint. + */ + fun origins(origins: List) = origins(JsonField.of(origins)) + + /** + * Sets [Builder.origins] to an arbitrary JSON value. + * + * You should usually call [Builder.origins] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun origins(origins: JsonField>) = apply { + this.origins = origins.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [origins]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addOrigin(origin: String) = apply { + origins = + (origins ?: JsonField.of(mutableListOf())).also { + checkKnown("origins", it).add(origin) + } + } + + /** + * Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens + * only — or empty for the default endpoint). + */ + fun urlPrefix(urlPrefix: String) = urlPrefix(JsonField.of(urlPrefix)) + + /** + * Sets [Builder.urlPrefix] to an arbitrary JSON value. + * + * You should usually call [Builder.urlPrefix] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun urlPrefix(urlPrefix: JsonField) = apply { this.urlPrefix = urlPrefix } + + /** Configuration for third-party URL rewriting. */ + fun urlRewriter(urlRewriter: UrlRewriter) = urlRewriter(JsonField.of(urlRewriter)) + + /** + * Sets [Builder.urlRewriter] to an arbitrary JSON value. + * + * You should usually call [Builder.urlRewriter] with a well-typed [UrlRewriter] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun urlRewriter(urlRewriter: JsonField) = apply { + this.urlRewriter = urlRewriter + } + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofCloudinary(cloudinary)`. */ + fun urlRewriter(cloudinary: UrlRewriter.Cloudinary) = + urlRewriter(UrlRewriter.ofCloudinary(cloudinary)) + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix()`. */ + fun urlRewriterImgix() = urlRewriter(UrlRewriter.ofImgix()) + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai()`. */ + fun urlRewriterAkamai() = urlRewriter(UrlRewriter.ofAkamai()) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UrlEndpointRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .description() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UrlEndpointRequest = + UrlEndpointRequest( + checkRequired("description", description), + (origins ?: JsonMissing.of()).map { it.toImmutable() }, + urlPrefix, + urlRewriter, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UrlEndpointRequest = apply { + if (validated) { + return@apply + } + + description() + origins() + urlPrefix() + urlRewriter().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (description.asKnown().isPresent) 1 else 0) + + (origins.asKnown().getOrNull()?.size ?: 0) + + (if (urlPrefix.asKnown().isPresent) 1 else 0) + + (urlRewriter.asKnown().getOrNull()?.validity() ?: 0) + + /** Configuration for third-party URL rewriting. */ + @JsonDeserialize(using = UrlRewriter.Deserializer::class) + @JsonSerialize(using = UrlRewriter.Serializer::class) + class UrlRewriter + private constructor( + private val cloudinary: Cloudinary? = null, + private val imgix: JsonValue? = null, + private val akamai: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun cloudinary(): Optional = Optional.ofNullable(cloudinary) + + fun imgix(): Optional = Optional.ofNullable(imgix) + + fun akamai(): Optional = Optional.ofNullable(akamai) + + fun isCloudinary(): Boolean = cloudinary != null + + fun isImgix(): Boolean = imgix != null + + fun isAkamai(): Boolean = akamai != null + + fun asCloudinary(): Cloudinary = cloudinary.getOrThrow("cloudinary") + + fun asImgix(): JsonValue = imgix.getOrThrow("imgix") + + fun asAkamai(): JsonValue = akamai.getOrThrow("akamai") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + cloudinary != null -> visitor.visitCloudinary(cloudinary) + imgix != null -> visitor.visitImgix(imgix) + akamai != null -> visitor.visitAkamai(akamai) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UrlRewriter = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitCloudinary(cloudinary: Cloudinary) { + cloudinary.validate() + } + + override fun visitImgix(imgix: JsonValue) { + imgix.let { + if (it != JsonValue.from(mapOf("type" to "IMGIX"))) { + throw ImageKitInvalidDataException( + "'imgix' is invalid, received $it" + ) + } + } + } + + override fun visitAkamai(akamai: JsonValue) { + akamai.let { + if (it != JsonValue.from(mapOf("type" to "AKAMAI"))) { + throw ImageKitInvalidDataException( + "'akamai' is invalid, received $it" + ) + } + } + } + } + ) + 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 = + accept( + object : Visitor { + override fun visitCloudinary(cloudinary: Cloudinary) = cloudinary.validity() + + override fun visitImgix(imgix: JsonValue) = + imgix.let { if (it == JsonValue.from(mapOf("type" to "IMGIX"))) 1 else 0 } + + override fun visitAkamai(akamai: JsonValue) = + akamai.let { if (it == JsonValue.from(mapOf("type" to "AKAMAI"))) 1 else 0 } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UrlRewriter && + cloudinary == other.cloudinary && + imgix == other.imgix && + akamai == other.akamai + } + + override fun hashCode(): Int = Objects.hash(cloudinary, imgix, akamai) + + override fun toString(): String = + when { + cloudinary != null -> "UrlRewriter{cloudinary=$cloudinary}" + imgix != null -> "UrlRewriter{imgix=$imgix}" + akamai != null -> "UrlRewriter{akamai=$akamai}" + _json != null -> "UrlRewriter{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UrlRewriter") + } + + companion object { + + @JvmStatic + fun ofCloudinary(cloudinary: Cloudinary) = UrlRewriter(cloudinary = cloudinary) + + @JvmStatic fun ofImgix() = UrlRewriter(imgix = JsonValue.from(mapOf("type" to "IMGIX"))) + + @JvmStatic + fun ofAkamai() = UrlRewriter(akamai = JsonValue.from(mapOf("type" to "AKAMAI"))) + } + + /** + * An interface that defines how to map each variant of [UrlRewriter] to a value of type + * [T]. + */ + interface Visitor { + + fun visitCloudinary(cloudinary: Cloudinary): T + + fun visitImgix(imgix: JsonValue): T + + fun visitAkamai(akamai: JsonValue): T + + /** + * Maps an unknown variant of [UrlRewriter] to a value of type [T]. + * + * An instance of [UrlRewriter] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown UrlRewriter: $json") + } + } + + internal class Deserializer : BaseDeserializer(UrlRewriter::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): UrlRewriter { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "CLOUDINARY" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + UrlRewriter(cloudinary = it, _json = json) + } ?: UrlRewriter(_json = json) + } + "IMGIX" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { UrlRewriter(imgix = it, _json = json) } + ?.takeIf { it.isValid() } ?: UrlRewriter(_json = json) + } + "AKAMAI" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { UrlRewriter(akamai = it, _json = json) } + ?.takeIf { it.isValid() } ?: UrlRewriter(_json = json) + } + } + + return UrlRewriter(_json = json) + } + } + + internal class Serializer : BaseSerializer(UrlRewriter::class) { + + override fun serialize( + value: UrlRewriter, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.cloudinary != null -> generator.writeObject(value.cloudinary) + value.imgix != null -> generator.writeObject(value.imgix) + value.akamai != null -> generator.writeObject(value.akamai) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid UrlRewriter") + } + } + } + + class Cloudinary + private constructor( + private val type: JsonValue, + private val preserveAssetDeliveryTypes: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("preserveAssetDeliveryTypes") + @ExcludeMissing + preserveAssetDeliveryTypes: JsonField = JsonMissing.of(), + ) : this(type, preserveAssetDeliveryTypes, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("CLOUDINARY") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Whether to preserve `/` in the rewritten URL. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun preserveAssetDeliveryTypes(): Optional = + preserveAssetDeliveryTypes.getOptional("preserveAssetDeliveryTypes") + + /** + * Returns the raw JSON value of [preserveAssetDeliveryTypes]. + * + * Unlike [preserveAssetDeliveryTypes], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("preserveAssetDeliveryTypes") + @ExcludeMissing + fun _preserveAssetDeliveryTypes(): JsonField = preserveAssetDeliveryTypes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Cloudinary]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Cloudinary]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("CLOUDINARY") + private var preserveAssetDeliveryTypes: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cloudinary: Cloudinary) = apply { + type = cloudinary.type + preserveAssetDeliveryTypes = cloudinary.preserveAssetDeliveryTypes + additionalProperties = cloudinary.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("CLOUDINARY") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Whether to preserve `/` in the rewritten URL. */ + fun preserveAssetDeliveryTypes(preserveAssetDeliveryTypes: Boolean) = + preserveAssetDeliveryTypes(JsonField.of(preserveAssetDeliveryTypes)) + + /** + * Sets [Builder.preserveAssetDeliveryTypes] to an arbitrary JSON value. + * + * You should usually call [Builder.preserveAssetDeliveryTypes] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun preserveAssetDeliveryTypes(preserveAssetDeliveryTypes: JsonField) = + apply { + this.preserveAssetDeliveryTypes = preserveAssetDeliveryTypes + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Cloudinary]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Cloudinary = + Cloudinary( + type, + preserveAssetDeliveryTypes, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Cloudinary = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("CLOUDINARY")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + preserveAssetDeliveryTypes() + 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 = + type.let { if (it == JsonValue.from("CLOUDINARY")) 1 else 0 } + + (if (preserveAssetDeliveryTypes.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cloudinary && + type == other.type && + preserveAssetDeliveryTypes == other.preserveAssetDeliveryTypes && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, preserveAssetDeliveryTypes, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Cloudinary{type=$type, preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UrlEndpointRequest && + description == other.description && + origins == other.origins && + urlPrefix == other.urlPrefix && + urlRewriter == other.urlRewriter && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(description, origins, urlPrefix, urlRewriter, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UrlEndpointRequest{description=$description, origins=$origins, urlPrefix=$urlPrefix, urlRewriter=$urlRewriter, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponse.kt new file mode 100644 index 00000000..e6bbbd71 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponse.kt @@ -0,0 +1,825 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.urlendpoints + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** URL‑endpoint object as returned by the API. */ +class UrlEndpointResponse +private constructor( + private val id: JsonField, + private val description: JsonField, + private val origins: JsonField>, + private val urlPrefix: JsonField, + private val urlRewriter: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("origins") + @ExcludeMissing + origins: JsonField> = JsonMissing.of(), + @JsonProperty("urlPrefix") @ExcludeMissing urlPrefix: JsonField = JsonMissing.of(), + @JsonProperty("urlRewriter") + @ExcludeMissing + urlRewriter: JsonField = JsonMissing.of(), + ) : this(id, description, origins, urlPrefix, urlRewriter, mutableMapOf()) + + /** + * Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new + * URL-endpoint. For the default URL-endpoint, this is always `default`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Description of the URL endpoint. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun description(): String = description.getRequired("description") + + /** + * Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit checks + * them in the sequence provided. Origin must be created before it can be used in a URL + * endpoint. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun origins(): List = origins.getRequired("origins") + + /** + * Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens + * only — or empty for the default endpoint). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun urlPrefix(): String = urlPrefix.getRequired("urlPrefix") + + /** + * Configuration for third-party URL rewriting. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun urlRewriter(): Optional = urlRewriter.getOptional("urlRewriter") + + /** + * 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 [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 [origins]. + * + * Unlike [origins], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("origins") @ExcludeMissing fun _origins(): JsonField> = origins + + /** + * Returns the raw JSON value of [urlPrefix]. + * + * Unlike [urlPrefix], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("urlPrefix") @ExcludeMissing fun _urlPrefix(): JsonField = urlPrefix + + /** + * Returns the raw JSON value of [urlRewriter]. + * + * Unlike [urlRewriter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("urlRewriter") + @ExcludeMissing + fun _urlRewriter(): JsonField = urlRewriter + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UrlEndpointResponse]. + * + * The following fields are required: + * ```java + * .id() + * .description() + * .origins() + * .urlPrefix() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UrlEndpointResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var description: JsonField? = null + private var origins: JsonField>? = null + private var urlPrefix: JsonField? = null + private var urlRewriter: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(urlEndpointResponse: UrlEndpointResponse) = apply { + id = urlEndpointResponse.id + description = urlEndpointResponse.description + origins = urlEndpointResponse.origins.map { it.toMutableList() } + urlPrefix = urlEndpointResponse.urlPrefix + urlRewriter = urlEndpointResponse.urlRewriter + additionalProperties = urlEndpointResponse.additionalProperties.toMutableMap() + } + + /** + * Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a + * new URL-endpoint. For the default URL-endpoint, this is always `default`. + */ + 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 } + + /** Description of the URL endpoint. */ + 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 } + + /** + * Ordered list of origin IDs to try when the file isn’t in the Media Library; ImageKit + * checks them in the sequence provided. Origin must be created before it can be used in a + * URL endpoint. + */ + fun origins(origins: List) = origins(JsonField.of(origins)) + + /** + * Sets [Builder.origins] to an arbitrary JSON value. + * + * You should usually call [Builder.origins] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun origins(origins: JsonField>) = apply { + this.origins = origins.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [origins]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addOrigin(origin: String) = apply { + origins = + (origins ?: JsonField.of(mutableListOf())).also { + checkKnown("origins", it).add(origin) + } + } + + /** + * Path segment appended to your base URL to form the endpoint (letters, digits, and hyphens + * only — or empty for the default endpoint). + */ + fun urlPrefix(urlPrefix: String) = urlPrefix(JsonField.of(urlPrefix)) + + /** + * Sets [Builder.urlPrefix] to an arbitrary JSON value. + * + * You should usually call [Builder.urlPrefix] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun urlPrefix(urlPrefix: JsonField) = apply { this.urlPrefix = urlPrefix } + + /** Configuration for third-party URL rewriting. */ + fun urlRewriter(urlRewriter: UrlRewriter) = urlRewriter(JsonField.of(urlRewriter)) + + /** + * Sets [Builder.urlRewriter] to an arbitrary JSON value. + * + * You should usually call [Builder.urlRewriter] with a well-typed [UrlRewriter] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun urlRewriter(urlRewriter: JsonField) = apply { + this.urlRewriter = urlRewriter + } + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofCloudinary(cloudinary)`. */ + fun urlRewriter(cloudinary: UrlRewriter.Cloudinary) = + urlRewriter(UrlRewriter.ofCloudinary(cloudinary)) + + /** + * Alias for calling [urlRewriter] with the following: + * ```java + * UrlRewriter.Cloudinary.builder() + * .preserveAssetDeliveryTypes(preserveAssetDeliveryTypes) + * .build() + * ``` + */ + fun cloudinaryUrlRewriter(preserveAssetDeliveryTypes: Boolean) = + urlRewriter( + UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(preserveAssetDeliveryTypes) + .build() + ) + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofImgix()`. */ + fun urlRewriterImgix() = urlRewriter(UrlRewriter.ofImgix()) + + /** Alias for calling [urlRewriter] with `UrlRewriter.ofAkamai()`. */ + fun urlRewriterAkamai() = urlRewriter(UrlRewriter.ofAkamai()) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UrlEndpointResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .description() + * .origins() + * .urlPrefix() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UrlEndpointResponse = + UrlEndpointResponse( + checkRequired("id", id), + checkRequired("description", description), + checkRequired("origins", origins).map { it.toImmutable() }, + checkRequired("urlPrefix", urlPrefix), + urlRewriter, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UrlEndpointResponse = apply { + if (validated) { + return@apply + } + + id() + description() + origins() + urlPrefix() + urlRewriter().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (origins.asKnown().getOrNull()?.size ?: 0) + + (if (urlPrefix.asKnown().isPresent) 1 else 0) + + (urlRewriter.asKnown().getOrNull()?.validity() ?: 0) + + /** Configuration for third-party URL rewriting. */ + @JsonDeserialize(using = UrlRewriter.Deserializer::class) + @JsonSerialize(using = UrlRewriter.Serializer::class) + class UrlRewriter + private constructor( + private val cloudinary: Cloudinary? = null, + private val imgix: JsonValue? = null, + private val akamai: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun cloudinary(): Optional = Optional.ofNullable(cloudinary) + + fun imgix(): Optional = Optional.ofNullable(imgix) + + fun akamai(): Optional = Optional.ofNullable(akamai) + + fun isCloudinary(): Boolean = cloudinary != null + + fun isImgix(): Boolean = imgix != null + + fun isAkamai(): Boolean = akamai != null + + fun asCloudinary(): Cloudinary = cloudinary.getOrThrow("cloudinary") + + fun asImgix(): JsonValue = imgix.getOrThrow("imgix") + + fun asAkamai(): JsonValue = akamai.getOrThrow("akamai") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + cloudinary != null -> visitor.visitCloudinary(cloudinary) + imgix != null -> visitor.visitImgix(imgix) + akamai != null -> visitor.visitAkamai(akamai) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UrlRewriter = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitCloudinary(cloudinary: Cloudinary) { + cloudinary.validate() + } + + override fun visitImgix(imgix: JsonValue) { + imgix.let { + if (it != JsonValue.from(mapOf("type" to "IMGIX"))) { + throw ImageKitInvalidDataException( + "'imgix' is invalid, received $it" + ) + } + } + } + + override fun visitAkamai(akamai: JsonValue) { + akamai.let { + if (it != JsonValue.from(mapOf("type" to "AKAMAI"))) { + throw ImageKitInvalidDataException( + "'akamai' is invalid, received $it" + ) + } + } + } + } + ) + 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 = + accept( + object : Visitor { + override fun visitCloudinary(cloudinary: Cloudinary) = cloudinary.validity() + + override fun visitImgix(imgix: JsonValue) = + imgix.let { if (it == JsonValue.from(mapOf("type" to "IMGIX"))) 1 else 0 } + + override fun visitAkamai(akamai: JsonValue) = + akamai.let { if (it == JsonValue.from(mapOf("type" to "AKAMAI"))) 1 else 0 } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UrlRewriter && + cloudinary == other.cloudinary && + imgix == other.imgix && + akamai == other.akamai + } + + override fun hashCode(): Int = Objects.hash(cloudinary, imgix, akamai) + + override fun toString(): String = + when { + cloudinary != null -> "UrlRewriter{cloudinary=$cloudinary}" + imgix != null -> "UrlRewriter{imgix=$imgix}" + akamai != null -> "UrlRewriter{akamai=$akamai}" + _json != null -> "UrlRewriter{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UrlRewriter") + } + + companion object { + + @JvmStatic + fun ofCloudinary(cloudinary: Cloudinary) = UrlRewriter(cloudinary = cloudinary) + + @JvmStatic fun ofImgix() = UrlRewriter(imgix = JsonValue.from(mapOf("type" to "IMGIX"))) + + @JvmStatic + fun ofAkamai() = UrlRewriter(akamai = JsonValue.from(mapOf("type" to "AKAMAI"))) + } + + /** + * An interface that defines how to map each variant of [UrlRewriter] to a value of type + * [T]. + */ + interface Visitor { + + fun visitCloudinary(cloudinary: Cloudinary): T + + fun visitImgix(imgix: JsonValue): T + + fun visitAkamai(akamai: JsonValue): T + + /** + * Maps an unknown variant of [UrlRewriter] to a value of type [T]. + * + * An instance of [UrlRewriter] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown UrlRewriter: $json") + } + } + + internal class Deserializer : BaseDeserializer(UrlRewriter::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): UrlRewriter { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "CLOUDINARY" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + UrlRewriter(cloudinary = it, _json = json) + } ?: UrlRewriter(_json = json) + } + "IMGIX" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { UrlRewriter(imgix = it, _json = json) } + ?.takeIf { it.isValid() } ?: UrlRewriter(_json = json) + } + "AKAMAI" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { UrlRewriter(akamai = it, _json = json) } + ?.takeIf { it.isValid() } ?: UrlRewriter(_json = json) + } + } + + return UrlRewriter(_json = json) + } + } + + internal class Serializer : BaseSerializer(UrlRewriter::class) { + + override fun serialize( + value: UrlRewriter, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.cloudinary != null -> generator.writeObject(value.cloudinary) + value.imgix != null -> generator.writeObject(value.imgix) + value.akamai != null -> generator.writeObject(value.akamai) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid UrlRewriter") + } + } + } + + class Cloudinary + private constructor( + private val preserveAssetDeliveryTypes: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("preserveAssetDeliveryTypes") + @ExcludeMissing + preserveAssetDeliveryTypes: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(preserveAssetDeliveryTypes, type, mutableMapOf()) + + /** + * Whether to preserve `/` in the rewritten URL. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun preserveAssetDeliveryTypes(): Boolean = + preserveAssetDeliveryTypes.getRequired("preserveAssetDeliveryTypes") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("CLOUDINARY") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [preserveAssetDeliveryTypes]. + * + * Unlike [preserveAssetDeliveryTypes], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("preserveAssetDeliveryTypes") + @ExcludeMissing + fun _preserveAssetDeliveryTypes(): JsonField = preserveAssetDeliveryTypes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Cloudinary]. + * + * The following fields are required: + * ```java + * .preserveAssetDeliveryTypes() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Cloudinary]. */ + class Builder internal constructor() { + + private var preserveAssetDeliveryTypes: JsonField? = null + private var type: JsonValue = JsonValue.from("CLOUDINARY") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cloudinary: Cloudinary) = apply { + preserveAssetDeliveryTypes = cloudinary.preserveAssetDeliveryTypes + type = cloudinary.type + additionalProperties = cloudinary.additionalProperties.toMutableMap() + } + + /** Whether to preserve `/` in the rewritten URL. */ + fun preserveAssetDeliveryTypes(preserveAssetDeliveryTypes: Boolean) = + preserveAssetDeliveryTypes(JsonField.of(preserveAssetDeliveryTypes)) + + /** + * Sets [Builder.preserveAssetDeliveryTypes] to an arbitrary JSON value. + * + * You should usually call [Builder.preserveAssetDeliveryTypes] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun preserveAssetDeliveryTypes(preserveAssetDeliveryTypes: JsonField) = + apply { + this.preserveAssetDeliveryTypes = preserveAssetDeliveryTypes + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("CLOUDINARY") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Cloudinary]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .preserveAssetDeliveryTypes() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Cloudinary = + Cloudinary( + checkRequired("preserveAssetDeliveryTypes", preserveAssetDeliveryTypes), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Cloudinary = apply { + if (validated) { + return@apply + } + + preserveAssetDeliveryTypes() + _type().let { + if (it != JsonValue.from("CLOUDINARY")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + 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 (preserveAssetDeliveryTypes.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("CLOUDINARY")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Cloudinary && + preserveAssetDeliveryTypes == other.preserveAssetDeliveryTypes && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(preserveAssetDeliveryTypes, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Cloudinary{preserveAssetDeliveryTypes=$preserveAssetDeliveryTypes, type=$type, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UrlEndpointResponse && + id == other.id && + description == other.description && + origins == other.origins && + urlPrefix == other.urlPrefix && + urlRewriter == other.urlRewriter && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, description, origins, urlPrefix, urlRewriter, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UrlEndpointResponse{id=$id, description=$description, origins=$origins, urlPrefix=$urlPrefix, urlRewriter=$urlRewriter, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt new file mode 100644 index 00000000..0af7b50e --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt @@ -0,0 +1,237 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.urlendpoints + +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * **Note:** This API is currently in beta. Updates the URL‑endpoint identified by `id` and returns + * the updated object. + */ +class UrlEndpointUpdateParams +private constructor( + private val id: String?, + private val urlEndpointRequest: UrlEndpointRequest, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a new + * URL-endpoint. For the default URL-endpoint, this is always `default`. + */ + fun id(): Optional = Optional.ofNullable(id) + + /** Schema for URL endpoint resource. */ + fun urlEndpointRequest(): UrlEndpointRequest = urlEndpointRequest + + fun _additionalBodyProperties(): Map = + urlEndpointRequest._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 [UrlEndpointUpdateParams]. + * + * The following fields are required: + * ```java + * .urlEndpointRequest() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UrlEndpointUpdateParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var urlEndpointRequest: UrlEndpointRequest? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(urlEndpointUpdateParams: UrlEndpointUpdateParams) = apply { + id = urlEndpointUpdateParams.id + urlEndpointRequest = urlEndpointUpdateParams.urlEndpointRequest + additionalHeaders = urlEndpointUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = urlEndpointUpdateParams.additionalQueryParams.toBuilder() + } + + /** + * Unique identifier for the URL-endpoint. This is generated by ImageKit when you create a + * new URL-endpoint. For the default URL-endpoint, this is always `default`. + */ + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + /** Schema for URL endpoint resource. */ + fun urlEndpointRequest(urlEndpointRequest: UrlEndpointRequest) = apply { + this.urlEndpointRequest = urlEndpointRequest + } + + 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 [UrlEndpointUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .urlEndpointRequest() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UrlEndpointUpdateParams = + UrlEndpointUpdateParams( + id, + checkRequired("urlEndpointRequest", urlEndpointRequest), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): UrlEndpointRequest = urlEndpointRequest + + 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 UrlEndpointUpdateParams && + id == other.id && + urlEndpointRequest == other.urlEndpointRequest && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(id, urlEndpointRequest, additionalHeaders, additionalQueryParams) + + override fun toString() = + "UrlEndpointUpdateParams{id=$id, urlEndpointRequest=$urlEndpointRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetParams.kt new file mode 100644 index 00000000..a8e88bf6 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetParams.kt @@ -0,0 +1,235 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.usage + +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import java.time.LocalDate +import java.util.Objects + +/** + * Get the account usage information between two dates. Note that the API response includes data + * from the start date while excluding data from the end date. In other words, the data covers the + * period starting from the specified start date up to, but not including, the end date. + */ +class UsageGetParams +private constructor( + private val endDate: LocalDate, + private val startDate: LocalDate, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. The + * difference between `startDate` and `endDate` should be less than 90 days. + */ + fun endDate(): LocalDate = endDate + + /** + * Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. The + * difference between `startDate` and `endDate` should be less than 90 days. + */ + fun startDate(): LocalDate = startDate + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UsageGetParams]. + * + * The following fields are required: + * ```java + * .endDate() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UsageGetParams]. */ + class Builder internal constructor() { + + private var endDate: LocalDate? = null + private var startDate: LocalDate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(usageGetParams: UsageGetParams) = apply { + endDate = usageGetParams.endDate + startDate = usageGetParams.startDate + additionalHeaders = usageGetParams.additionalHeaders.toBuilder() + additionalQueryParams = usageGetParams.additionalQueryParams.toBuilder() + } + + /** + * Specify a `endDate` in `YYYY-MM-DD` format. It should be after the `startDate`. The + * difference between `startDate` and `endDate` should be less than 90 days. + */ + fun endDate(endDate: LocalDate) = apply { this.endDate = endDate } + + /** + * Specify a `startDate` in `YYYY-MM-DD` format. It should be before the `endDate`. The + * difference between `startDate` and `endDate` should be less than 90 days. + */ + fun startDate(startDate: LocalDate) = apply { this.startDate = startDate } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [UsageGetParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .endDate() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UsageGetParams = + UsageGetParams( + checkRequired("endDate", endDate), + checkRequired("startDate", startDate), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("endDate", endDate.toString()) + put("startDate", startDate.toString()) + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UsageGetParams && + endDate == other.endDate && + startDate == other.startDate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(endDate, startDate, additionalHeaders, additionalQueryParams) + + override fun toString() = + "UsageGetParams{endDate=$endDate, startDate=$startDate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponse.kt new file mode 100644 index 00000000..3239c0ed --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponse.kt @@ -0,0 +1,359 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.usage + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +class UsageGetResponse +private constructor( + private val bandwidthBytes: JsonField, + private val extensionUnitsCount: JsonField, + private val mediaLibraryStorageBytes: JsonField, + private val originalCacheStorageBytes: JsonField, + private val videoProcessingUnitsCount: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("bandwidthBytes") + @ExcludeMissing + bandwidthBytes: JsonField = JsonMissing.of(), + @JsonProperty("extensionUnitsCount") + @ExcludeMissing + extensionUnitsCount: JsonField = JsonMissing.of(), + @JsonProperty("mediaLibraryStorageBytes") + @ExcludeMissing + mediaLibraryStorageBytes: JsonField = JsonMissing.of(), + @JsonProperty("originalCacheStorageBytes") + @ExcludeMissing + originalCacheStorageBytes: JsonField = JsonMissing.of(), + @JsonProperty("videoProcessingUnitsCount") + @ExcludeMissing + videoProcessingUnitsCount: JsonField = JsonMissing.of(), + ) : this( + bandwidthBytes, + extensionUnitsCount, + mediaLibraryStorageBytes, + originalCacheStorageBytes, + videoProcessingUnitsCount, + mutableMapOf(), + ) + + /** + * Amount of bandwidth used in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun bandwidthBytes(): Optional = bandwidthBytes.getOptional("bandwidthBytes") + + /** + * Number of extension units used. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun extensionUnitsCount(): Optional = + extensionUnitsCount.getOptional("extensionUnitsCount") + + /** + * Storage used by media library in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mediaLibraryStorageBytes(): Optional = + mediaLibraryStorageBytes.getOptional("mediaLibraryStorageBytes") + + /** + * Storage used by the original cache in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun originalCacheStorageBytes(): Optional = + originalCacheStorageBytes.getOptional("originalCacheStorageBytes") + + /** + * Number of video processing units used. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun videoProcessingUnitsCount(): Optional = + videoProcessingUnitsCount.getOptional("videoProcessingUnitsCount") + + /** + * Returns the raw JSON value of [bandwidthBytes]. + * + * Unlike [bandwidthBytes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bandwidthBytes") + @ExcludeMissing + fun _bandwidthBytes(): JsonField = bandwidthBytes + + /** + * Returns the raw JSON value of [extensionUnitsCount]. + * + * Unlike [extensionUnitsCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("extensionUnitsCount") + @ExcludeMissing + fun _extensionUnitsCount(): JsonField = extensionUnitsCount + + /** + * Returns the raw JSON value of [mediaLibraryStorageBytes]. + * + * Unlike [mediaLibraryStorageBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mediaLibraryStorageBytes") + @ExcludeMissing + fun _mediaLibraryStorageBytes(): JsonField = mediaLibraryStorageBytes + + /** + * Returns the raw JSON value of [originalCacheStorageBytes]. + * + * Unlike [originalCacheStorageBytes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("originalCacheStorageBytes") + @ExcludeMissing + fun _originalCacheStorageBytes(): JsonField = originalCacheStorageBytes + + /** + * Returns the raw JSON value of [videoProcessingUnitsCount]. + * + * Unlike [videoProcessingUnitsCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("videoProcessingUnitsCount") + @ExcludeMissing + fun _videoProcessingUnitsCount(): JsonField = videoProcessingUnitsCount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UsageGetResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UsageGetResponse]. */ + class Builder internal constructor() { + + private var bandwidthBytes: JsonField = JsonMissing.of() + private var extensionUnitsCount: JsonField = JsonMissing.of() + private var mediaLibraryStorageBytes: JsonField = JsonMissing.of() + private var originalCacheStorageBytes: JsonField = JsonMissing.of() + private var videoProcessingUnitsCount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageGetResponse: UsageGetResponse) = apply { + bandwidthBytes = usageGetResponse.bandwidthBytes + extensionUnitsCount = usageGetResponse.extensionUnitsCount + mediaLibraryStorageBytes = usageGetResponse.mediaLibraryStorageBytes + originalCacheStorageBytes = usageGetResponse.originalCacheStorageBytes + videoProcessingUnitsCount = usageGetResponse.videoProcessingUnitsCount + additionalProperties = usageGetResponse.additionalProperties.toMutableMap() + } + + /** Amount of bandwidth used in bytes. */ + fun bandwidthBytes(bandwidthBytes: Long) = bandwidthBytes(JsonField.of(bandwidthBytes)) + + /** + * Sets [Builder.bandwidthBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.bandwidthBytes] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun bandwidthBytes(bandwidthBytes: JsonField) = apply { + this.bandwidthBytes = bandwidthBytes + } + + /** Number of extension units used. */ + fun extensionUnitsCount(extensionUnitsCount: Long) = + extensionUnitsCount(JsonField.of(extensionUnitsCount)) + + /** + * Sets [Builder.extensionUnitsCount] to an arbitrary JSON value. + * + * You should usually call [Builder.extensionUnitsCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun extensionUnitsCount(extensionUnitsCount: JsonField) = apply { + this.extensionUnitsCount = extensionUnitsCount + } + + /** Storage used by media library in bytes. */ + fun mediaLibraryStorageBytes(mediaLibraryStorageBytes: Long) = + mediaLibraryStorageBytes(JsonField.of(mediaLibraryStorageBytes)) + + /** + * Sets [Builder.mediaLibraryStorageBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.mediaLibraryStorageBytes] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun mediaLibraryStorageBytes(mediaLibraryStorageBytes: JsonField) = apply { + this.mediaLibraryStorageBytes = mediaLibraryStorageBytes + } + + /** Storage used by the original cache in bytes. */ + fun originalCacheStorageBytes(originalCacheStorageBytes: Long) = + originalCacheStorageBytes(JsonField.of(originalCacheStorageBytes)) + + /** + * Sets [Builder.originalCacheStorageBytes] to an arbitrary JSON value. + * + * You should usually call [Builder.originalCacheStorageBytes] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun originalCacheStorageBytes(originalCacheStorageBytes: JsonField) = apply { + this.originalCacheStorageBytes = originalCacheStorageBytes + } + + /** Number of video processing units used. */ + fun videoProcessingUnitsCount(videoProcessingUnitsCount: Long) = + videoProcessingUnitsCount(JsonField.of(videoProcessingUnitsCount)) + + /** + * Sets [Builder.videoProcessingUnitsCount] to an arbitrary JSON value. + * + * You should usually call [Builder.videoProcessingUnitsCount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun videoProcessingUnitsCount(videoProcessingUnitsCount: JsonField) = apply { + this.videoProcessingUnitsCount = videoProcessingUnitsCount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UsageGetResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UsageGetResponse = + UsageGetResponse( + bandwidthBytes, + extensionUnitsCount, + mediaLibraryStorageBytes, + originalCacheStorageBytes, + videoProcessingUnitsCount, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UsageGetResponse = apply { + if (validated) { + return@apply + } + + bandwidthBytes() + extensionUnitsCount() + mediaLibraryStorageBytes() + originalCacheStorageBytes() + videoProcessingUnitsCount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (bandwidthBytes.asKnown().isPresent) 1 else 0) + + (if (extensionUnitsCount.asKnown().isPresent) 1 else 0) + + (if (mediaLibraryStorageBytes.asKnown().isPresent) 1 else 0) + + (if (originalCacheStorageBytes.asKnown().isPresent) 1 else 0) + + (if (videoProcessingUnitsCount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UsageGetResponse && + bandwidthBytes == other.bandwidthBytes && + extensionUnitsCount == other.extensionUnitsCount && + mediaLibraryStorageBytes == other.mediaLibraryStorageBytes && + originalCacheStorageBytes == other.originalCacheStorageBytes && + videoProcessingUnitsCount == other.videoProcessingUnitsCount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bandwidthBytes, + extensionUnitsCount, + mediaLibraryStorageBytes, + originalCacheStorageBytes, + videoProcessingUnitsCount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UsageGetResponse{bandwidthBytes=$bandwidthBytes, extensionUnitsCount=$extensionUnitsCount, mediaLibraryStorageBytes=$mediaLibraryStorageBytes, originalCacheStorageBytes=$originalCacheStorageBytes, videoProcessingUnitsCount=$videoProcessingUnitsCount, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/AssetListParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/AssetListParams.kt new file mode 100644 index 00000000..78ed7c98 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/AssetListParams.kt @@ -0,0 +1,865 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.assets + +import com.fasterxml.jackson.annotation.JsonCreator +import com.imagekit.api.core.Enum +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.Params +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * This API can list all the uploaded files and folders in your ImageKit.io media library. In + * addition, you can fine-tune your query by specifying various filters by generating a query string + * in a Lucene-like syntax and provide this generated string as the value of the `searchQuery`. + */ +class AssetListParams +private constructor( + private val fileType: FileType?, + private val limit: Long?, + private val path: String?, + private val searchQuery: String?, + private val skip: Long?, + private val sort: Sort?, + private val type: Type?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Filter results by file type. + * - `all` — include all file types + * - `image` — include only image files + * - `non-image` — include only non-image files (e.g., JS, CSS, video) + */ + fun fileType(): Optional = Optional.ofNullable(fileType) + + /** The maximum number of results to return in response. */ + fun limit(): Optional = Optional.ofNullable(limit) + + /** + * Folder path if you want to limit the search within a specific folder. For example, + * `/sales-banner/` will only search in folder sales-banner. + * + * Note : If your use case involves searching within a folder as well as its subfolders, you can + * use `path` parameter in `searchQuery` with appropriate operator. Checkout + * [Supported parameters](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#supported-parameters) + * for more information. + */ + fun path(): Optional = Optional.ofNullable(path) + + /** + * Query string in a Lucene-like query language e.g. `createdAt > "7d"`. + * + * Note : When the searchQuery parameter is present, the following query parameters will have no + * effect on the result: + * 1. `tags` + * 2. `type` + * 3. `name` + * + * [Learn + * more](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#advanced-search-queries) + * from examples. + */ + fun searchQuery(): Optional = Optional.ofNullable(searchQuery) + + /** The number of results to skip before returning results. */ + fun skip(): Optional = Optional.ofNullable(skip) + + /** Sort the results by one of the supported fields in ascending or descending order. */ + fun sort(): Optional = Optional.ofNullable(sort) + + /** + * Filter results by asset type. + * - `file` — returns only files + * - `file-version` — returns specific file versions + * - `folder` — returns only folders + * - `all` — returns both files and folders (excludes `file-version`) + */ + fun type(): Optional = Optional.ofNullable(type) + + /** 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(): AssetListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AssetListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AssetListParams]. */ + class Builder internal constructor() { + + private var fileType: FileType? = null + private var limit: Long? = null + private var path: String? = null + private var searchQuery: String? = null + private var skip: Long? = null + private var sort: Sort? = null + private var type: Type? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(assetListParams: AssetListParams) = apply { + fileType = assetListParams.fileType + limit = assetListParams.limit + path = assetListParams.path + searchQuery = assetListParams.searchQuery + skip = assetListParams.skip + sort = assetListParams.sort + type = assetListParams.type + additionalHeaders = assetListParams.additionalHeaders.toBuilder() + additionalQueryParams = assetListParams.additionalQueryParams.toBuilder() + } + + /** + * Filter results by file type. + * - `all` — include all file types + * - `image` — include only image files + * - `non-image` — include only non-image files (e.g., JS, CSS, video) + */ + fun fileType(fileType: FileType?) = apply { this.fileType = fileType } + + /** Alias for calling [Builder.fileType] with `fileType.orElse(null)`. */ + fun fileType(fileType: Optional) = fileType(fileType.getOrNull()) + + /** The maximum number of results to return in response. */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + /** + * Folder path if you want to limit the search within a specific folder. For example, + * `/sales-banner/` will only search in folder sales-banner. + * + * Note : If your use case involves searching within a folder as well as its subfolders, you + * can use `path` parameter in `searchQuery` with appropriate operator. Checkout + * [Supported parameters](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#supported-parameters) + * for more information. + */ + fun path(path: String?) = apply { this.path = path } + + /** Alias for calling [Builder.path] with `path.orElse(null)`. */ + fun path(path: Optional) = path(path.getOrNull()) + + /** + * Query string in a Lucene-like query language e.g. `createdAt > "7d"`. + * + * Note : When the searchQuery parameter is present, the following query parameters will + * have no effect on the result: + * 1. `tags` + * 2. `type` + * 3. `name` + * + * [Learn + * more](/docs/api-reference/digital-asset-management-dam/list-and-search-assets#advanced-search-queries) + * from examples. + */ + fun searchQuery(searchQuery: String?) = apply { this.searchQuery = searchQuery } + + /** Alias for calling [Builder.searchQuery] with `searchQuery.orElse(null)`. */ + fun searchQuery(searchQuery: Optional) = searchQuery(searchQuery.getOrNull()) + + /** The number of results to skip before returning results. */ + fun skip(skip: Long?) = apply { this.skip = skip } + + /** + * Alias for [Builder.skip]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun skip(skip: Long) = skip(skip as Long?) + + /** Alias for calling [Builder.skip] with `skip.orElse(null)`. */ + fun skip(skip: Optional) = skip(skip.getOrNull()) + + /** Sort the results by one of the supported fields in ascending or descending order. */ + fun sort(sort: Sort?) = apply { this.sort = sort } + + /** Alias for calling [Builder.sort] with `sort.orElse(null)`. */ + fun sort(sort: Optional) = sort(sort.getOrNull()) + + /** + * Filter results by asset type. + * - `file` — returns only files + * - `file-version` — returns specific file versions + * - `folder` — returns only folders + * - `all` — returns both files and folders (excludes `file-version`) + */ + fun type(type: Type?) = apply { this.type = type } + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.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 [AssetListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AssetListParams = + AssetListParams( + fileType, + limit, + path, + searchQuery, + skip, + sort, + type, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + fileType?.let { put("fileType", it.toString()) } + limit?.let { put("limit", it.toString()) } + path?.let { put("path", it) } + searchQuery?.let { put("searchQuery", it) } + skip?.let { put("skip", it.toString()) } + sort?.let { put("sort", it.toString()) } + type?.let { put("type", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + /** + * Filter results by file type. + * - `all` — include all file types + * - `image` — include only image files + * - `non-image` — include only non-image files (e.g., JS, CSS, video) + */ + class FileType @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ALL = of("all") + + @JvmField val IMAGE = of("image") + + @JvmField val NON_IMAGE = of("non-image") + + @JvmStatic fun of(value: String) = FileType(JsonField.of(value)) + } + + /** An enum containing [FileType]'s known values. */ + enum class Known { + ALL, + IMAGE, + NON_IMAGE, + } + + /** + * An enum containing [FileType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FileType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ALL, + IMAGE, + NON_IMAGE, + /** An enum member indicating that [FileType] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ALL -> Value.ALL + IMAGE -> Value.IMAGE + NON_IMAGE -> Value.NON_IMAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ALL -> Known.ALL + IMAGE -> Known.IMAGE + NON_IMAGE -> Known.NON_IMAGE + else -> throw ImageKitInvalidDataException("Unknown FileType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): FileType = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FileType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Sort the results by one of the supported fields in ascending or descending order. */ + class Sort @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ASC_NAME = of("ASC_NAME") + + @JvmField val DESC_NAME = of("DESC_NAME") + + @JvmField val ASC_CREATED = of("ASC_CREATED") + + @JvmField val DESC_CREATED = of("DESC_CREATED") + + @JvmField val ASC_UPDATED = of("ASC_UPDATED") + + @JvmField val DESC_UPDATED = of("DESC_UPDATED") + + @JvmField val ASC_HEIGHT = of("ASC_HEIGHT") + + @JvmField val DESC_HEIGHT = of("DESC_HEIGHT") + + @JvmField val ASC_WIDTH = of("ASC_WIDTH") + + @JvmField val DESC_WIDTH = of("DESC_WIDTH") + + @JvmField val ASC_SIZE = of("ASC_SIZE") + + @JvmField val DESC_SIZE = of("DESC_SIZE") + + @JvmField val ASC_RELEVANCE = of("ASC_RELEVANCE") + + @JvmField val DESC_RELEVANCE = of("DESC_RELEVANCE") + + @JvmStatic fun of(value: String) = Sort(JsonField.of(value)) + } + + /** An enum containing [Sort]'s known values. */ + enum class Known { + ASC_NAME, + DESC_NAME, + ASC_CREATED, + DESC_CREATED, + ASC_UPDATED, + DESC_UPDATED, + ASC_HEIGHT, + DESC_HEIGHT, + ASC_WIDTH, + DESC_WIDTH, + ASC_SIZE, + DESC_SIZE, + ASC_RELEVANCE, + DESC_RELEVANCE, + } + + /** + * An enum containing [Sort]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Sort] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ASC_NAME, + DESC_NAME, + ASC_CREATED, + DESC_CREATED, + ASC_UPDATED, + DESC_UPDATED, + ASC_HEIGHT, + DESC_HEIGHT, + ASC_WIDTH, + DESC_WIDTH, + ASC_SIZE, + DESC_SIZE, + ASC_RELEVANCE, + DESC_RELEVANCE, + /** An enum member indicating that [Sort] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ASC_NAME -> Value.ASC_NAME + DESC_NAME -> Value.DESC_NAME + ASC_CREATED -> Value.ASC_CREATED + DESC_CREATED -> Value.DESC_CREATED + ASC_UPDATED -> Value.ASC_UPDATED + DESC_UPDATED -> Value.DESC_UPDATED + ASC_HEIGHT -> Value.ASC_HEIGHT + DESC_HEIGHT -> Value.DESC_HEIGHT + ASC_WIDTH -> Value.ASC_WIDTH + DESC_WIDTH -> Value.DESC_WIDTH + ASC_SIZE -> Value.ASC_SIZE + DESC_SIZE -> Value.DESC_SIZE + ASC_RELEVANCE -> Value.ASC_RELEVANCE + DESC_RELEVANCE -> Value.DESC_RELEVANCE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ASC_NAME -> Known.ASC_NAME + DESC_NAME -> Known.DESC_NAME + ASC_CREATED -> Known.ASC_CREATED + DESC_CREATED -> Known.DESC_CREATED + ASC_UPDATED -> Known.ASC_UPDATED + DESC_UPDATED -> Known.DESC_UPDATED + ASC_HEIGHT -> Known.ASC_HEIGHT + DESC_HEIGHT -> Known.DESC_HEIGHT + ASC_WIDTH -> Known.ASC_WIDTH + DESC_WIDTH -> Known.DESC_WIDTH + ASC_SIZE -> Known.ASC_SIZE + DESC_SIZE -> Known.DESC_SIZE + ASC_RELEVANCE -> Known.ASC_RELEVANCE + DESC_RELEVANCE -> Known.DESC_RELEVANCE + else -> throw ImageKitInvalidDataException("Unknown Sort: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Sort = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Sort && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Filter results by asset type. + * - `file` — returns only files + * - `file-version` — returns specific file versions + * - `folder` — returns only folders + * - `all` — returns both files and folders (excludes `file-version`) + */ + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val FILE = of("file") + + @JvmField val FILE_VERSION = of("file-version") + + @JvmField val FOLDER = of("folder") + + @JvmField val ALL = of("all") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + FILE, + FILE_VERSION, + FOLDER, + ALL, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FILE, + FILE_VERSION, + FOLDER, + ALL, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FILE -> Value.FILE + FILE_VERSION -> Value.FILE_VERSION + FOLDER -> Value.FOLDER + ALL -> Value.ALL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + FILE -> Known.FILE + FILE_VERSION -> Known.FILE_VERSION + FOLDER -> Known.FOLDER + ALL -> Known.ALL + else -> throw ImageKitInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AssetListParams && + fileType == other.fileType && + limit == other.limit && + path == other.path && + searchQuery == other.searchQuery && + skip == other.skip && + sort == other.sort && + type == other.type && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + fileType, + limit, + path, + searchQuery, + skip, + sort, + type, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "AssetListParams{fileType=$fileType, limit=$limit, path=$path, searchQuery=$searchQuery, skip=$skip, sort=$sort, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/AssetListResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/AssetListResponse.kt new file mode 100644 index 00000000..8e1fbee8 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/AssetListResponse.kt @@ -0,0 +1,187 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.assets + +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.files.File +import com.imagekit.api.models.files.Folder +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Object containing details of a file or file version. */ +@JsonDeserialize(using = AssetListResponse.Deserializer::class) +@JsonSerialize(using = AssetListResponse.Serializer::class) +class AssetListResponse +private constructor( + private val file: File? = null, + private val folder: Folder? = null, + private val _json: JsonValue? = null, +) { + + /** Object containing details of a file or file version. */ + fun file(): Optional = Optional.ofNullable(file) + + fun folder(): Optional = Optional.ofNullable(folder) + + fun isFile(): Boolean = file != null + + fun isFolder(): Boolean = folder != null + + /** Object containing details of a file or file version. */ + fun asFile(): File = file.getOrThrow("file") + + fun asFolder(): Folder = folder.getOrThrow("folder") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + file != null -> visitor.visitFile(file) + folder != null -> visitor.visitFolder(folder) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): AssetListResponse = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitFile(file: File) { + file.validate() + } + + override fun visitFolder(folder: Folder) { + folder.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitFile(file: File) = file.validity() + + override fun visitFolder(folder: Folder) = folder.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AssetListResponse && file == other.file && folder == other.folder + } + + override fun hashCode(): Int = Objects.hash(file, folder) + + override fun toString(): String = + when { + file != null -> "AssetListResponse{file=$file}" + folder != null -> "AssetListResponse{folder=$folder}" + _json != null -> "AssetListResponse{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AssetListResponse") + } + + companion object { + + /** Object containing details of a file or file version. */ + @JvmStatic fun ofFile(file: File) = AssetListResponse(file = file) + + @JvmStatic fun ofFolder(folder: Folder) = AssetListResponse(folder = folder) + } + + /** + * An interface that defines how to map each variant of [AssetListResponse] to a value of type + * [T]. + */ + interface Visitor { + + /** Object containing details of a file or file version. */ + fun visitFile(file: File): T + + fun visitFolder(folder: Folder): T + + /** + * Maps an unknown variant of [AssetListResponse] to a value of type [T]. + * + * An instance of [AssetListResponse] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is unaware + * of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown AssetListResponse: $json") + } + } + + internal class Deserializer : BaseDeserializer(AssetListResponse::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AssetListResponse { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + if (type == "folder") { + return tryDeserialize(node, jacksonTypeRef())?.let { + AssetListResponse(folder = it, _json = json) + } ?: AssetListResponse(_json = json) + } + + return tryDeserialize(node, jacksonTypeRef())?.let { + AssetListResponse(file = it, _json = json) + } ?: AssetListResponse(_json = json) + } + } + + internal class Serializer : BaseSerializer(AssetListResponse::class) { + + override fun serialize( + value: AssetListResponse, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.file != null -> generator.writeObject(value.file) + value.folder != null -> generator.writeObject(value.folder) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AssetListResponse") + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt new file mode 100644 index 00000000..a8caac42 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt @@ -0,0 +1,4828 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.beta.v2.files + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.MultipartField +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.io.InputStream +import java.nio.file.Path +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.io.path.inputStream +import kotlin.io.path.name +import kotlin.jvm.optionals.getOrNull + +/** + * The V2 API enhances security by verifying the entire payload using JWT. This API is in beta. + * + * ImageKit.io allows you to upload files directly from both the server and client sides. For + * server-side uploads, private API key authentication is used. For client-side uploads, generate a + * one-time `token` from your secure backend using private API. + * [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) + * about how to implement secure client-side file upload. + * + * **File size limit** \ On the free plan, the maximum upload file sizes are 20MB for images, audio, + * and raw files, and 100MB for videos. On the paid plan, these limits increase to 40MB for images, + * audio, and raw files, and 2GB for videos. These limits can be further increased with higher-tier + * plans. + * + * **Version limit** \ A file can have a maximum of 100 versions. + * + * **Demo applications** + * - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), + * supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. + * - [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies. + */ +class FileUploadParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + * + * @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 file(): InputStream = body.file() + + /** + * The name with which the file has to be uploaded. + * + * @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 fileName(): String = body.fileName() + + /** + * This is the client-generated JSON Web Token (JWT). The ImageKit.io server uses it to + * authenticate and check that the upload request parameters have not been tampered with after + * the token has been generated. Learn how to create the token on the page below. This field is + * only required for authentication when uploading a file from the client side. + * + * **Note**: Sending a JWT that has been used in the past will result in a validation error. + * Even if your previous request resulted in an error, you should always send a new token. + * + * **⚠️Warning**: JWT must be generated on the server-side because it is generated using your + * account's private API key. This field is required for authentication when uploading a file + * from the client-side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun token(): Optional = body.token() + + /** + * Server-side checks to run on the asset. Read more about + * [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun checks(): Optional = body.checks() + + /** + * Define an important area in the image. This is only relevant for image type files. + * - To be passed as a string with the x and y coordinates of the top-left corner, and width and + * height of the area of interest in the format `x,y,width,height`. For example - + * `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates will be + * removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customCoordinates(): Optional = body.customCoordinates() + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields before + * setting these values. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customMetadata(): Optional = body.customMetadata() + + /** + * Optional text to describe the contents of the file. + * + * @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() + + /** + * Array of extensions to be applied to the image. Each extension can be configured with + * specific parameters based on the extension type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun extensions(): Optional> = body.extensions() + + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, + * a new folder(s) is created. Using multiple `/` creates a nested folder. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun folder(): Optional = body.folder() + + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named transformation or + * signed URL. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isPrivateFile(): Optional = body.isPrivateFile() + + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file only via + * the media library. Files in draft or unpublished state can only be publicly accessed after + * being published. + * + * The option to upload in draft state is only available in custom enterprise pricing plans. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isPublished(): Optional = body.isPublished() + + /** + * If set to `true` and a file already exists at the exact location, its AITags will be removed. + * Set `overwriteAITags` to `false` to preserve AITags. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun overwriteAiTags(): Optional = body.overwriteAiTags() + + /** + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun overwriteCustomMetadata(): Optional = body.overwriteCustomMetadata() + + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact + * location, upload API will return an error immediately. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun overwriteFile(): Optional = body.overwriteFile() + + /** + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun overwriteTags(): Optional = body.overwriteTags() + + /** + * Array of response field keys to include in the API response body. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun responseFields(): Optional> = body.responseFields() + + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", + * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the `%` + * character is not allowed. If this field is not specified and the file is overwritten, the + * existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tags(): Optional> = body.tags() + + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing file + * size or applying basic optimizations upfront (e.g., resize, compress). + * - `post` — applied immediately after upload. Ideal for generating transformed versions (like + * video encodes or thumbnails) in advance, so they're ready for delivery without delay. + * + * You can mix and match any combination of post-processing types. + * + * @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() + + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique + * filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any existing + * file with the same name is replaced. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun useUniqueFileName(): Optional = body.useUniqueFileName() + + /** + * The final status of extensions after they have completed execution will be delivered to this + * endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookUrl(): Optional = body.webhookUrl() + + /** + * Returns the raw multipart value of [file]. + * + * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _file(): MultipartField = body._file() + + /** + * Returns the raw multipart value of [fileName]. + * + * Unlike [fileName], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _fileName(): MultipartField = body._fileName() + + /** + * Returns the raw multipart value of [token]. + * + * Unlike [token], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _token(): MultipartField = body._token() + + /** + * Returns the raw multipart value of [checks]. + * + * Unlike [checks], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _checks(): MultipartField = body._checks() + + /** + * Returns the raw multipart value of [customCoordinates]. + * + * Unlike [customCoordinates], this method doesn't throw if the multipart field has an + * unexpected type. + */ + fun _customCoordinates(): MultipartField = body._customCoordinates() + + /** + * Returns the raw multipart value of [customMetadata]. + * + * Unlike [customMetadata], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _customMetadata(): MultipartField = body._customMetadata() + + /** + * Returns the raw multipart value of [description]. + * + * Unlike [description], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _description(): MultipartField = body._description() + + /** + * Returns the raw multipart value of [extensions]. + * + * Unlike [extensions], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _extensions(): MultipartField> = body._extensions() + + /** + * Returns the raw multipart value of [folder]. + * + * Unlike [folder], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _folder(): MultipartField = body._folder() + + /** + * Returns the raw multipart value of [isPrivateFile]. + * + * Unlike [isPrivateFile], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _isPrivateFile(): MultipartField = body._isPrivateFile() + + /** + * Returns the raw multipart value of [isPublished]. + * + * Unlike [isPublished], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _isPublished(): MultipartField = body._isPublished() + + /** + * Returns the raw multipart value of [overwriteAiTags]. + * + * Unlike [overwriteAiTags], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _overwriteAiTags(): MultipartField = body._overwriteAiTags() + + /** + * Returns the raw multipart value of [overwriteCustomMetadata]. + * + * Unlike [overwriteCustomMetadata], this method doesn't throw if the multipart field has an + * unexpected type. + */ + fun _overwriteCustomMetadata(): MultipartField = body._overwriteCustomMetadata() + + /** + * Returns the raw multipart value of [overwriteFile]. + * + * Unlike [overwriteFile], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _overwriteFile(): MultipartField = body._overwriteFile() + + /** + * Returns the raw multipart value of [overwriteTags]. + * + * Unlike [overwriteTags], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _overwriteTags(): MultipartField = body._overwriteTags() + + /** + * Returns the raw multipart value of [responseFields]. + * + * Unlike [responseFields], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _responseFields(): MultipartField> = body._responseFields() + + /** + * Returns the raw multipart value of [tags]. + * + * Unlike [tags], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _tags(): MultipartField> = body._tags() + + /** + * Returns the raw multipart value of [transformation]. + * + * Unlike [transformation], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _transformation(): MultipartField = body._transformation() + + /** + * Returns the raw multipart value of [useUniqueFileName]. + * + * Unlike [useUniqueFileName], this method doesn't throw if the multipart field has an + * unexpected type. + */ + fun _useUniqueFileName(): MultipartField = body._useUniqueFileName() + + /** + * Returns the raw multipart value of [webhookUrl]. + * + * Unlike [webhookUrl], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _webhookUrl(): MultipartField = body._webhookUrl() + + 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 [FileUploadParams]. + * + * The following fields are required: + * ```java + * .file() + * .fileName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileUploadParams]. */ + 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(fileUploadParams: FileUploadParams) = apply { + body = fileUploadParams.body.toBuilder() + additionalHeaders = fileUploadParams.additionalHeaders.toBuilder() + additionalQueryParams = fileUploadParams.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: + * - [file] + * - [fileName] + * - [token] + * - [checks] + * - [customCoordinates] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(file: InputStream) = apply { body.file(file) } + + /** + * Sets [Builder.file] to an arbitrary multipart value. + * + * You should usually call [Builder.file] with a well-typed [InputStream] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun file(file: MultipartField) = apply { body.file(file) } + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(file: ByteArray) = apply { body.file(file) } + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(path: Path) = apply { body.file(path) } + + /** The name with which the file has to be uploaded. */ + fun fileName(fileName: String) = apply { body.fileName(fileName) } + + /** + * Sets [Builder.fileName] to an arbitrary multipart value. + * + * You should usually call [Builder.fileName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fileName(fileName: MultipartField) = apply { body.fileName(fileName) } + + /** + * This is the client-generated JSON Web Token (JWT). The ImageKit.io server uses it to + * authenticate and check that the upload request parameters have not been tampered with + * after the token has been generated. Learn how to create the token on the page below. This + * field is only required for authentication when uploading a file from the client side. + * + * **Note**: Sending a JWT that has been used in the past will result in a validation error. + * Even if your previous request resulted in an error, you should always send a new token. + * + * **⚠️Warning**: JWT must be generated on the server-side because it is generated using + * your account's private API key. This field is required for authentication when uploading + * a file from the client-side. + */ + fun token(token: String) = apply { body.token(token) } + + /** + * Sets [Builder.token] to an arbitrary multipart value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: MultipartField) = apply { body.token(token) } + + /** + * Server-side checks to run on the asset. Read more about + * [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks). + */ + fun checks(checks: String) = apply { body.checks(checks) } + + /** + * Sets [Builder.checks] to an arbitrary multipart value. + * + * You should usually call [Builder.checks] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun checks(checks: MultipartField) = apply { body.checks(checks) } + + /** + * Define an important area in the image. This is only relevant for image type files. + * - To be passed as a string with the x and y coordinates of the top-left corner, and width + * and height of the area of interest in the format `x,y,width,height`. For example - + * `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates will + * be removed. + */ + fun customCoordinates(customCoordinates: String) = apply { + body.customCoordinates(customCoordinates) + } + + /** + * Sets [Builder.customCoordinates] to an arbitrary multipart value. + * + * You should usually call [Builder.customCoordinates] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customCoordinates(customCoordinates: MultipartField) = apply { + body.customCoordinates(customCoordinates) + } + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields + * before setting these values. + */ + fun customMetadata(customMetadata: CustomMetadata) = apply { + body.customMetadata(customMetadata) + } + + /** + * Sets [Builder.customMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.customMetadata] with a well-typed [CustomMetadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customMetadata(customMetadata: MultipartField) = apply { + body.customMetadata(customMetadata) + } + + /** Optional text to describe the contents of the file. */ + fun description(description: String) = apply { body.description(description) } + + /** + * Sets [Builder.description] to an arbitrary multipart 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: MultipartField) = apply { + body.description(description) + } + + /** + * Array of extensions to be applied to the image. Each extension can be configured with + * specific parameters based on the extension type. + */ + fun extensions(extensions: List) = apply { body.extensions(extensions) } + + /** + * Sets [Builder.extensions] to an arbitrary multipart value. + * + * You should usually call [Builder.extensions] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun extensions(extensions: MultipartField>) = apply { + body.extensions(extensions) + } + + /** + * Adds a single [Extension] to [extensions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExtension(extension: Extension) = apply { body.addExtension(extension) } + + /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ + fun addExtension(removeBg: Extension.RemoveBg) = apply { body.addExtension(removeBg) } + + /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = apply { + body.addExtension(autoTagging) + } + + /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ + fun addExtensionAiAutoDescription() = apply { body.addExtensionAiAutoDescription() } + + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't exist + * before, a new folder(s) is created. Using multiple `/` creates a nested folder. + */ + fun folder(folder: String) = apply { body.folder(folder) } + + /** + * Sets [Builder.folder] to an arbitrary multipart value. + * + * You should usually call [Builder.folder] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun folder(folder: MultipartField) = apply { body.folder(folder) } + + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named + * transformation or signed URL. + */ + fun isPrivateFile(isPrivateFile: Boolean) = apply { body.isPrivateFile(isPrivateFile) } + + /** + * Sets [Builder.isPrivateFile] to an arbitrary multipart value. + * + * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPrivateFile(isPrivateFile: MultipartField) = apply { + body.isPrivateFile(isPrivateFile) + } + + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file only + * via the media library. Files in draft or unpublished state can only be publicly accessed + * after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing plans. + */ + fun isPublished(isPublished: Boolean) = apply { body.isPublished(isPublished) } + + /** + * Sets [Builder.isPublished] to an arbitrary multipart value. + * + * You should usually call [Builder.isPublished] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isPublished(isPublished: MultipartField) = apply { + body.isPublished(isPublished) + } + + /** + * If set to `true` and a file already exists at the exact location, its AITags will be + * removed. Set `overwriteAITags` to `false` to preserve AITags. + */ + fun overwriteAiTags(overwriteAiTags: Boolean) = apply { + body.overwriteAiTags(overwriteAiTags) + } + + /** + * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteAiTags] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteAiTags(overwriteAiTags: MultipartField) = apply { + body.overwriteAiTags(overwriteAiTags) + } + + /** + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: Boolean) = apply { + body.overwriteCustomMetadata(overwriteCustomMetadata) + } + + /** + * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteCustomMetadata] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: MultipartField) = apply { + body.overwriteCustomMetadata(overwriteCustomMetadata) + } + + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the + * exact location, upload API will return an error immediately. + */ + fun overwriteFile(overwriteFile: Boolean) = apply { body.overwriteFile(overwriteFile) } + + /** + * Sets [Builder.overwriteFile] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteFile(overwriteFile: MultipartField) = apply { + body.overwriteFile(overwriteFile) + } + + /** + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + */ + fun overwriteTags(overwriteTags: Boolean) = apply { body.overwriteTags(overwriteTags) } + + /** + * Sets [Builder.overwriteTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteTags] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteTags(overwriteTags: MultipartField) = apply { + body.overwriteTags(overwriteTags) + } + + /** Array of response field keys to include in the API response body. */ + fun responseFields(responseFields: List) = apply { + body.responseFields(responseFields) + } + + /** + * Sets [Builder.responseFields] to an arbitrary multipart value. + * + * You should usually call [Builder.responseFields] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun responseFields(responseFields: MultipartField>) = apply { + body.responseFields(responseFields) + } + + /** + * Adds a single [ResponseField] to [responseFields]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResponseField(responseField: ResponseField) = apply { + body.addResponseField(responseField) + } + + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", + * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the + * `%` character is not allowed. If this field is not specified and the file is overwritten, + * the existing tags will be removed. + */ + fun tags(tags: List) = apply { body.tags(tags) } + + /** + * Sets [Builder.tags] to an arbitrary multipart value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: MultipartField>) = apply { body.tags(tags) } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { body.addTag(tag) } + + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing + * file size or applying basic optimizations upfront (e.g., resize, compress). + * - `post` — applied immediately after upload. Ideal for generating transformed versions + * (like video encodes or thumbnails) in advance, so they're ready for delivery without + * delay. + * + * You can mix and match any combination of post-processing types. + */ + fun transformation(transformation: Transformation) = apply { + body.transformation(transformation) + } + + /** + * Sets [Builder.transformation] to an arbitrary multipart value. + * + * You should usually call [Builder.transformation] with a well-typed [Transformation] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun transformation(transformation: MultipartField) = apply { + body.transformation(transformation) + } + + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique + * filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any + * existing file with the same name is replaced. + */ + fun useUniqueFileName(useUniqueFileName: Boolean) = apply { + body.useUniqueFileName(useUniqueFileName) + } + + /** + * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. + * + * You should usually call [Builder.useUniqueFileName] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useUniqueFileName(useUniqueFileName: MultipartField) = apply { + body.useUniqueFileName(useUniqueFileName) + } + + /** + * The final status of extensions after they have completed execution will be delivered to + * this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + */ + fun webhookUrl(webhookUrl: String) = apply { body.webhookUrl(webhookUrl) } + + /** + * Sets [Builder.webhookUrl] to an arbitrary multipart value. + * + * You should usually call [Builder.webhookUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun webhookUrl(webhookUrl: MultipartField) = apply { body.webhookUrl(webhookUrl) } + + 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 [FileUploadParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .file() + * .fileName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FileUploadParams = + FileUploadParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _body(): Map> = + (mapOf( + "file" to _file(), + "fileName" to _fileName(), + "token" to _token(), + "checks" to _checks(), + "customCoordinates" to _customCoordinates(), + "customMetadata" to _customMetadata(), + "description" to _description(), + "extensions" to _extensions(), + "folder" to _folder(), + "isPrivateFile" to _isPrivateFile(), + "isPublished" to _isPublished(), + "overwriteAITags" to _overwriteAiTags(), + "overwriteCustomMetadata" to _overwriteCustomMetadata(), + "overwriteFile" to _overwriteFile(), + "overwriteTags" to _overwriteTags(), + "responseFields" to _responseFields(), + "tags" to _tags(), + "transformation" to _transformation(), + "useUniqueFileName" to _useUniqueFileName(), + "webhookUrl" to _webhookUrl(), + ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) + .toImmutable() + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val file: MultipartField, + private val fileName: MultipartField, + private val token: MultipartField, + private val checks: MultipartField, + private val customCoordinates: MultipartField, + private val customMetadata: MultipartField, + private val description: MultipartField, + private val extensions: MultipartField>, + private val folder: MultipartField, + private val isPrivateFile: MultipartField, + private val isPublished: MultipartField, + private val overwriteAiTags: MultipartField, + private val overwriteCustomMetadata: MultipartField, + private val overwriteFile: MultipartField, + private val overwriteTags: MultipartField, + private val responseFields: MultipartField>, + private val tags: MultipartField>, + private val transformation: MultipartField, + private val useUniqueFileName: MultipartField, + private val webhookUrl: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + * + * @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 file(): InputStream = file.value.getRequired("file") + + /** + * The name with which the file has to be uploaded. + * + * @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 fileName(): String = fileName.value.getRequired("fileName") + + /** + * This is the client-generated JSON Web Token (JWT). The ImageKit.io server uses it to + * authenticate and check that the upload request parameters have not been tampered with + * after the token has been generated. Learn how to create the token on the page below. This + * field is only required for authentication when uploading a file from the client side. + * + * **Note**: Sending a JWT that has been used in the past will result in a validation error. + * Even if your previous request resulted in an error, you should always send a new token. + * + * **⚠️Warning**: JWT must be generated on the server-side because it is generated using + * your account's private API key. This field is required for authentication when uploading + * a file from the client-side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun token(): Optional = token.value.getOptional("token") + + /** + * Server-side checks to run on the asset. Read more about + * [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun checks(): Optional = checks.value.getOptional("checks") + + /** + * Define an important area in the image. This is only relevant for image type files. + * - To be passed as a string with the x and y coordinates of the top-left corner, and width + * and height of the area of interest in the format `x,y,width,height`. For example - + * `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates will + * be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customCoordinates(): Optional = + customCoordinates.value.getOptional("customCoordinates") + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields + * before setting these values. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customMetadata(): Optional = + customMetadata.value.getOptional("customMetadata") + + /** + * Optional text to describe the contents of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.value.getOptional("description") + + /** + * Array of extensions to be applied to the image. Each extension can be configured with + * specific parameters based on the extension type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun extensions(): Optional> = extensions.value.getOptional("extensions") + + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't exist + * before, a new folder(s) is created. Using multiple `/` creates a nested folder. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun folder(): Optional = folder.value.getOptional("folder") + + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named + * transformation or signed URL. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isPrivateFile(): Optional = isPrivateFile.value.getOptional("isPrivateFile") + + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file only + * via the media library. Files in draft or unpublished state can only be publicly accessed + * after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing plans. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isPublished(): Optional = isPublished.value.getOptional("isPublished") + + /** + * If set to `true` and a file already exists at the exact location, its AITags will be + * removed. Set `overwriteAITags` to `false` to preserve AITags. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun overwriteAiTags(): Optional = + overwriteAiTags.value.getOptional("overwriteAITags") + + /** + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun overwriteCustomMetadata(): Optional = + overwriteCustomMetadata.value.getOptional("overwriteCustomMetadata") + + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the + * exact location, upload API will return an error immediately. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun overwriteFile(): Optional = overwriteFile.value.getOptional("overwriteFile") + + /** + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun overwriteTags(): Optional = overwriteTags.value.getOptional("overwriteTags") + + /** + * Array of response field keys to include in the API response body. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun responseFields(): Optional> = + responseFields.value.getOptional("responseFields") + + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", + * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the + * `%` character is not allowed. If this field is not specified and the file is overwritten, + * the existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tags(): Optional> = tags.value.getOptional("tags") + + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing + * file size or applying basic optimizations upfront (e.g., resize, compress). + * - `post` — applied immediately after upload. Ideal for generating transformed versions + * (like video encodes or thumbnails) in advance, so they're ready for delivery without + * delay. + * + * You can mix and match any combination of post-processing types. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun transformation(): Optional = + transformation.value.getOptional("transformation") + + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique + * filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any + * existing file with the same name is replaced. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun useUniqueFileName(): Optional = + useUniqueFileName.value.getOptional("useUniqueFileName") + + /** + * The final status of extensions after they have completed execution will be delivered to + * this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookUrl(): Optional = webhookUrl.value.getOptional("webhookUrl") + + /** + * Returns the raw multipart value of [file]. + * + * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField = file + + /** + * Returns the raw multipart value of [fileName]. + * + * Unlike [fileName], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("fileName") @ExcludeMissing fun _fileName(): MultipartField = fileName + + /** + * Returns the raw multipart value of [token]. + * + * Unlike [token], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): MultipartField = token + + /** + * Returns the raw multipart value of [checks]. + * + * Unlike [checks], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("checks") @ExcludeMissing fun _checks(): MultipartField = checks + + /** + * Returns the raw multipart value of [customCoordinates]. + * + * Unlike [customCoordinates], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("customCoordinates") + @ExcludeMissing + fun _customCoordinates(): MultipartField = customCoordinates + + /** + * Returns the raw multipart value of [customMetadata]. + * + * Unlike [customMetadata], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): MultipartField = customMetadata + + /** + * Returns the raw multipart value of [description]. + * + * Unlike [description], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): MultipartField = description + + /** + * Returns the raw multipart value of [extensions]. + * + * Unlike [extensions], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("extensions") + @ExcludeMissing + fun _extensions(): MultipartField> = extensions + + /** + * Returns the raw multipart value of [folder]. + * + * Unlike [folder], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("folder") @ExcludeMissing fun _folder(): MultipartField = folder + + /** + * Returns the raw multipart value of [isPrivateFile]. + * + * Unlike [isPrivateFile], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("isPrivateFile") + @ExcludeMissing + fun _isPrivateFile(): MultipartField = isPrivateFile + + /** + * Returns the raw multipart value of [isPublished]. + * + * Unlike [isPublished], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("isPublished") + @ExcludeMissing + fun _isPublished(): MultipartField = isPublished + + /** + * Returns the raw multipart value of [overwriteAiTags]. + * + * Unlike [overwriteAiTags], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteAITags") + @ExcludeMissing + fun _overwriteAiTags(): MultipartField = overwriteAiTags + + /** + * Returns the raw multipart value of [overwriteCustomMetadata]. + * + * Unlike [overwriteCustomMetadata], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteCustomMetadata") + @ExcludeMissing + fun _overwriteCustomMetadata(): MultipartField = overwriteCustomMetadata + + /** + * Returns the raw multipart value of [overwriteFile]. + * + * Unlike [overwriteFile], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteFile") + @ExcludeMissing + fun _overwriteFile(): MultipartField = overwriteFile + + /** + * Returns the raw multipart value of [overwriteTags]. + * + * Unlike [overwriteTags], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteTags") + @ExcludeMissing + fun _overwriteTags(): MultipartField = overwriteTags + + /** + * Returns the raw multipart value of [responseFields]. + * + * Unlike [responseFields], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("responseFields") + @ExcludeMissing + fun _responseFields(): MultipartField> = responseFields + + /** + * Returns the raw multipart value of [tags]. + * + * Unlike [tags], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): MultipartField> = tags + + /** + * Returns the raw multipart value of [transformation]. + * + * Unlike [transformation], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("transformation") + @ExcludeMissing + fun _transformation(): MultipartField = transformation + + /** + * Returns the raw multipart value of [useUniqueFileName]. + * + * Unlike [useUniqueFileName], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("useUniqueFileName") + @ExcludeMissing + fun _useUniqueFileName(): MultipartField = useUniqueFileName + + /** + * Returns the raw multipart value of [webhookUrl]. + * + * Unlike [webhookUrl], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("webhookUrl") + @ExcludeMissing + fun _webhookUrl(): MultipartField = webhookUrl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @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 + * .file() + * .fileName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var file: MultipartField? = null + private var fileName: MultipartField? = null + private var token: MultipartField = MultipartField.of(null) + private var checks: MultipartField = MultipartField.of(null) + private var customCoordinates: MultipartField = MultipartField.of(null) + private var customMetadata: MultipartField = MultipartField.of(null) + private var description: MultipartField = MultipartField.of(null) + private var extensions: MultipartField>? = null + private var folder: MultipartField = MultipartField.of(null) + private var isPrivateFile: MultipartField = MultipartField.of(null) + private var isPublished: MultipartField = MultipartField.of(null) + private var overwriteAiTags: MultipartField = MultipartField.of(null) + private var overwriteCustomMetadata: MultipartField = MultipartField.of(null) + private var overwriteFile: MultipartField = MultipartField.of(null) + private var overwriteTags: MultipartField = MultipartField.of(null) + private var responseFields: MultipartField>? = null + private var tags: MultipartField>? = null + private var transformation: MultipartField = MultipartField.of(null) + private var useUniqueFileName: MultipartField = MultipartField.of(null) + private var webhookUrl: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + file = body.file + fileName = body.fileName + token = body.token + checks = body.checks + customCoordinates = body.customCoordinates + customMetadata = body.customMetadata + description = body.description + extensions = body.extensions.map { it.toMutableList() } + folder = body.folder + isPrivateFile = body.isPrivateFile + isPublished = body.isPublished + overwriteAiTags = body.overwriteAiTags + overwriteCustomMetadata = body.overwriteCustomMetadata + overwriteFile = body.overwriteFile + overwriteTags = body.overwriteTags + responseFields = body.responseFields.map { it.toMutableList() } + tags = body.tags.map { it.toMutableList() } + transformation = body.transformation + useUniqueFileName = body.useUniqueFileName + webhookUrl = body.webhookUrl + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(file: InputStream) = file(MultipartField.of(file)) + + /** + * Sets [Builder.file] to an arbitrary multipart value. + * + * You should usually call [Builder.file] with a well-typed [InputStream] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun file(file: MultipartField) = apply { this.file = file } + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(file: ByteArray) = file(file.inputStream()) + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(path: Path) = + file( + MultipartField.builder() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + /** The name with which the file has to be uploaded. */ + fun fileName(fileName: String) = fileName(MultipartField.of(fileName)) + + /** + * Sets [Builder.fileName] to an arbitrary multipart value. + * + * You should usually call [Builder.fileName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fileName(fileName: MultipartField) = apply { this.fileName = fileName } + + /** + * This is the client-generated JSON Web Token (JWT). The ImageKit.io server uses it to + * authenticate and check that the upload request parameters have not been tampered with + * after the token has been generated. Learn how to create the token on the page below. + * This field is only required for authentication when uploading a file from the client + * side. + * + * **Note**: Sending a JWT that has been used in the past will result in a validation + * error. Even if your previous request resulted in an error, you should always send a + * new token. + * + * **⚠️Warning**: JWT must be generated on the server-side because it is generated using + * your account's private API key. This field is required for authentication when + * uploading a file from the client-side. + */ + fun token(token: String) = token(MultipartField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary multipart value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: MultipartField) = apply { this.token = token } + + /** + * Server-side checks to run on the asset. Read more about + * [Upload API checks](/docs/api-reference/upload-file/upload-file-v2#upload-api-checks). + */ + fun checks(checks: String) = checks(MultipartField.of(checks)) + + /** + * Sets [Builder.checks] to an arbitrary multipart value. + * + * You should usually call [Builder.checks] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun checks(checks: MultipartField) = apply { this.checks = checks } + + /** + * Define an important area in the image. This is only relevant for image type files. + * - To be passed as a string with the x and y coordinates of the top-left corner, and + * width and height of the area of interest in the format `x,y,width,height`. For + * example - `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates + * will be removed. + */ + fun customCoordinates(customCoordinates: String) = + customCoordinates(MultipartField.of(customCoordinates)) + + /** + * Sets [Builder.customCoordinates] to an arbitrary multipart value. + * + * You should usually call [Builder.customCoordinates] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customCoordinates(customCoordinates: MultipartField) = apply { + this.customCoordinates = customCoordinates + } + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields + * before setting these values. + */ + fun customMetadata(customMetadata: CustomMetadata) = + customMetadata(MultipartField.of(customMetadata)) + + /** + * Sets [Builder.customMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.customMetadata] with a well-typed [CustomMetadata] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun customMetadata(customMetadata: MultipartField) = apply { + this.customMetadata = customMetadata + } + + /** Optional text to describe the contents of the file. */ + fun description(description: String) = description(MultipartField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary multipart 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: MultipartField) = apply { + this.description = description + } + + /** + * Array of extensions to be applied to the image. Each extension can be configured with + * specific parameters based on the extension type. + */ + fun extensions(extensions: List) = extensions(MultipartField.of(extensions)) + + /** + * Sets [Builder.extensions] to an arbitrary multipart value. + * + * You should usually call [Builder.extensions] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun extensions(extensions: MultipartField>) = apply { + this.extensions = extensions.map { it.toMutableList() } + } + + /** + * Adds a single [Extension] to [extensions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExtension(extension: Extension) = apply { + extensions = + (extensions ?: MultipartField.of(mutableListOf())).also { + checkKnown("extensions", it).add(extension) + } + } + + /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ + fun addExtension(removeBg: Extension.RemoveBg) = + addExtension(Extension.ofRemoveBg(removeBg)) + + /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = + addExtension(Extension.ofAutoTagging(autoTagging)) + + /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ + fun addExtensionAiAutoDescription() = addExtension(Extension.ofAiAutoDescription()) + + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't exist + * before, a new folder(s) is created. Using multiple `/` creates a nested folder. + */ + fun folder(folder: String) = folder(MultipartField.of(folder)) + + /** + * Sets [Builder.folder] to an arbitrary multipart value. + * + * You should usually call [Builder.folder] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun folder(folder: MultipartField) = apply { this.folder = folder } + + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named + * transformation or signed URL. + */ + fun isPrivateFile(isPrivateFile: Boolean) = + isPrivateFile(MultipartField.of(isPrivateFile)) + + /** + * Sets [Builder.isPrivateFile] to an arbitrary multipart value. + * + * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPrivateFile(isPrivateFile: MultipartField) = apply { + this.isPrivateFile = isPrivateFile + } + + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file + * only via the media library. Files in draft or unpublished state can only be publicly + * accessed after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing + * plans. + */ + fun isPublished(isPublished: Boolean) = isPublished(MultipartField.of(isPublished)) + + /** + * Sets [Builder.isPublished] to an arbitrary multipart value. + * + * You should usually call [Builder.isPublished] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPublished(isPublished: MultipartField) = apply { + this.isPublished = isPublished + } + + /** + * If set to `true` and a file already exists at the exact location, its AITags will be + * removed. Set `overwriteAITags` to `false` to preserve AITags. + */ + fun overwriteAiTags(overwriteAiTags: Boolean) = + overwriteAiTags(MultipartField.of(overwriteAiTags)) + + /** + * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteAiTags] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteAiTags(overwriteAiTags: MultipartField) = apply { + this.overwriteAiTags = overwriteAiTags + } + + /** + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: Boolean) = + overwriteCustomMetadata(MultipartField.of(overwriteCustomMetadata)) + + /** + * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteCustomMetadata] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: MultipartField) = apply { + this.overwriteCustomMetadata = overwriteCustomMetadata + } + + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the + * exact location, upload API will return an error immediately. + */ + fun overwriteFile(overwriteFile: Boolean) = + overwriteFile(MultipartField.of(overwriteFile)) + + /** + * Sets [Builder.overwriteFile] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteFile(overwriteFile: MultipartField) = apply { + this.overwriteFile = overwriteFile + } + + /** + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + */ + fun overwriteTags(overwriteTags: Boolean) = + overwriteTags(MultipartField.of(overwriteTags)) + + /** + * Sets [Builder.overwriteTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteTags] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteTags(overwriteTags: MultipartField) = apply { + this.overwriteTags = overwriteTags + } + + /** Array of response field keys to include in the API response body. */ + fun responseFields(responseFields: List) = + responseFields(MultipartField.of(responseFields)) + + /** + * Sets [Builder.responseFields] to an arbitrary multipart value. + * + * You should usually call [Builder.responseFields] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun responseFields(responseFields: MultipartField>) = apply { + this.responseFields = responseFields.map { it.toMutableList() } + } + + /** + * Adds a single [ResponseField] to [responseFields]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResponseField(responseField: ResponseField) = apply { + responseFields = + (responseFields ?: MultipartField.of(mutableListOf())).also { + checkKnown("responseFields", it).add(responseField) + } + } + + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. + * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not + * exceed 500, and the `%` character is not allowed. If this field is not specified and + * the file is overwritten, the existing tags will be removed. + */ + fun tags(tags: List) = tags(MultipartField.of(tags)) + + /** + * Sets [Builder.tags] to an arbitrary multipart value. + * + * You should usually call [Builder.tags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tags(tags: MultipartField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = + (tags ?: MultipartField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } + + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for + * reducing file size or applying basic optimizations upfront (e.g., resize, + * compress). + * - `post` — applied immediately after upload. Ideal for generating transformed + * versions (like video encodes or thumbnails) in advance, so they're ready for + * delivery without delay. + * + * You can mix and match any combination of post-processing types. + */ + fun transformation(transformation: Transformation) = + transformation(MultipartField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary multipart value. + * + * You should usually call [Builder.transformation] with a well-typed [Transformation] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun transformation(transformation: MultipartField) = apply { + this.transformation = transformation + } + + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a + * unique filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any + * existing file with the same name is replaced. + */ + fun useUniqueFileName(useUniqueFileName: Boolean) = + useUniqueFileName(MultipartField.of(useUniqueFileName)) + + /** + * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. + * + * You should usually call [Builder.useUniqueFileName] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useUniqueFileName(useUniqueFileName: MultipartField) = apply { + this.useUniqueFileName = useUniqueFileName + } + + /** + * The final status of extensions after they have completed execution will be delivered + * to this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + */ + fun webhookUrl(webhookUrl: String) = webhookUrl(MultipartField.of(webhookUrl)) + + /** + * Sets [Builder.webhookUrl] to an arbitrary multipart value. + * + * You should usually call [Builder.webhookUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun webhookUrl(webhookUrl: MultipartField) = apply { + this.webhookUrl = webhookUrl + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .file() + * .fileName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("file", file), + checkRequired("fileName", fileName), + token, + checks, + customCoordinates, + customMetadata, + description, + (extensions ?: MultipartField.of(null)).map { it.toImmutable() }, + folder, + isPrivateFile, + isPublished, + overwriteAiTags, + overwriteCustomMetadata, + overwriteFile, + overwriteTags, + (responseFields ?: MultipartField.of(null)).map { it.toImmutable() }, + (tags ?: MultipartField.of(null)).map { it.toImmutable() }, + transformation, + useUniqueFileName, + webhookUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + file() + fileName() + token() + checks() + customCoordinates() + customMetadata().ifPresent { it.validate() } + description() + extensions().ifPresent { it.forEach { it.validate() } } + folder() + isPrivateFile() + isPublished() + overwriteAiTags() + overwriteCustomMetadata() + overwriteFile() + overwriteTags() + responseFields().ifPresent { it.forEach { it.validate() } } + tags() + transformation().ifPresent { it.validate() } + useUniqueFileName() + webhookUrl() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + file == other.file && + fileName == other.fileName && + token == other.token && + checks == other.checks && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + description == other.description && + extensions == other.extensions && + folder == other.folder && + isPrivateFile == other.isPrivateFile && + isPublished == other.isPublished && + overwriteAiTags == other.overwriteAiTags && + overwriteCustomMetadata == other.overwriteCustomMetadata && + overwriteFile == other.overwriteFile && + overwriteTags == other.overwriteTags && + responseFields == other.responseFields && + tags == other.tags && + transformation == other.transformation && + useUniqueFileName == other.useUniqueFileName && + webhookUrl == other.webhookUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + file, + fileName, + token, + checks, + customCoordinates, + customMetadata, + description, + extensions, + folder, + isPrivateFile, + isPublished, + overwriteAiTags, + overwriteCustomMetadata, + overwriteFile, + overwriteTags, + responseFields, + tags, + transformation, + useUniqueFileName, + webhookUrl, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, responseFields=$responseFields, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + } + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields before + * setting these values. + */ + class CustomMetadata + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CustomMetadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customMetadata: CustomMetadata) = apply { + additionalProperties = customMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CustomMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomMetadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Extension.Deserializer::class) + @JsonSerialize(using = Extension.Serializer::class) + class Extension + private constructor( + private val removeBg: RemoveBg? = null, + private val autoTagging: AutoTaggingExtension? = null, + private val aiAutoDescription: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun removeBg(): Optional = Optional.ofNullable(removeBg) + + fun autoTagging(): Optional = Optional.ofNullable(autoTagging) + + fun aiAutoDescription(): Optional = Optional.ofNullable(aiAutoDescription) + + fun isRemoveBg(): Boolean = removeBg != null + + fun isAutoTagging(): Boolean = autoTagging != null + + fun isAiAutoDescription(): Boolean = aiAutoDescription != null + + fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") + + fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") + + fun asAiAutoDescription(): JsonValue = aiAutoDescription.getOrThrow("aiAutoDescription") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + removeBg != null -> visitor.visitRemoveBg(removeBg) + autoTagging != null -> visitor.visitAutoTagging(autoTagging) + aiAutoDescription != null -> visitor.visitAiAutoDescription(aiAutoDescription) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Extension = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) { + removeBg.validate() + } + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { + autoTagging.validate() + } + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { + aiAutoDescription.let { + if (it != JsonValue.from(mapOf("name" to "ai-auto-description"))) { + throw ImageKitInvalidDataException( + "'aiAutoDescription' is invalid, received $it" + ) + } + } + } + } + ) + 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 = + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = + autoTagging.validity() + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = + aiAutoDescription.let { + if (it == JsonValue.from(mapOf("name" to "ai-auto-description"))) 1 + else 0 + } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extension && + removeBg == other.removeBg && + autoTagging == other.autoTagging && + aiAutoDescription == other.aiAutoDescription + } + + override fun hashCode(): Int = Objects.hash(removeBg, autoTagging, aiAutoDescription) + + override fun toString(): String = + when { + removeBg != null -> "Extension{removeBg=$removeBg}" + autoTagging != null -> "Extension{autoTagging=$autoTagging}" + aiAutoDescription != null -> "Extension{aiAutoDescription=$aiAutoDescription}" + _json != null -> "Extension{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Extension") + } + + companion object { + + @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = Extension(removeBg = removeBg) + + @JvmStatic + fun ofAutoTagging(autoTagging: AutoTaggingExtension) = + Extension(autoTagging = autoTagging) + + @JvmStatic + fun ofAiAutoDescription() = + Extension( + aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) + ) + } + + /** + * An interface that defines how to map each variant of [Extension] to a value of type [T]. + */ + interface Visitor { + + fun visitRemoveBg(removeBg: RemoveBg): T + + fun visitAutoTagging(autoTagging: AutoTaggingExtension): T + + fun visitAiAutoDescription(aiAutoDescription: JsonValue): T + + /** + * Maps an unknown variant of [Extension] to a value of type [T]. + * + * An instance of [Extension] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Extension: $json") + } + } + + internal class Deserializer : BaseDeserializer(Extension::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Extension { + val json = JsonValue.fromJsonNode(node) + val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() + + when (name) { + "remove-bg" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Extension(removeBg = it, _json = json) + } ?: Extension(_json = json) + } + "ai-auto-description" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Extension(aiAutoDescription = it, _json = json) } + ?.takeIf { it.isValid() } ?: Extension(_json = json) + } + } + + return tryDeserialize(node, jacksonTypeRef())?.let { + Extension(autoTagging = it, _json = json) + } ?: Extension(_json = json) + } + } + + internal class Serializer : BaseSerializer(Extension::class) { + + override fun serialize( + value: Extension, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.removeBg != null -> generator.writeObject(value.removeBg) + value.autoTagging != null -> generator.writeObject(value.autoTagging) + value.aiAutoDescription != null -> + generator.writeObject(value.aiAutoDescription) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Extension") + } + } + } + + class RemoveBg + private constructor( + private val name: JsonValue, + private val options: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Specifies the background removal extension. + * + * Expected to always return the following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun options(): Optional = options.value.getOptional("options") + + /** + * Returns the raw multipart value of [options]. + * + * Unlike [options], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("options") + @ExcludeMissing + fun _options(): MultipartField = options + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveBg]. */ + class Builder internal constructor() { + + private var name: JsonValue = JsonValue.from("remove-bg") + private var options: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removeBg: RemoveBg) = apply { + name = removeBg.name + options = removeBg.options + additionalProperties = removeBg.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + fun options(options: Options) = options(MultipartField.of(options)) + + /** + * Sets [Builder.options] to an arbitrary multipart value. + * + * You should usually call [Builder.options] with a well-typed [Options] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun options(options: MultipartField) = apply { this.options = options } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemoveBg]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemoveBg = RemoveBg(name, options, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): RemoveBg = apply { + if (validated) { + return@apply + } + + _name().let { + if (it != JsonValue.from("remove-bg")) { + throw ImageKitInvalidDataException("'name' is invalid, received $it") + } + } + options().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + class Options + private constructor( + private val addShadow: MultipartField, + private val bgColor: MultipartField, + private val bgImageUrl: MultipartField, + private val semitransparency: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Whether to add an artificial shadow to the result. Default is false. Note: Adding + * shadows is currently only supported for car photos. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun addShadow(): Optional = addShadow.value.getOptional("add_shadow") + + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or + * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be + * empty. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun bgColor(): Optional = bgColor.value.getOptional("bg_color") + + /** + * Sets a background image from a URL. If this parameter is set, `bg_color` must be + * empty. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun bgImageUrl(): Optional = bgImageUrl.value.getOptional("bg_image_url") + + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun semitransparency(): Optional = + semitransparency.value.getOptional("semitransparency") + + /** + * Returns the raw multipart value of [addShadow]. + * + * Unlike [addShadow], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("add_shadow") + @ExcludeMissing + fun _addShadow(): MultipartField = addShadow + + /** + * Returns the raw multipart value of [bgColor]. + * + * Unlike [bgColor], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("bg_color") + @ExcludeMissing + fun _bgColor(): MultipartField = bgColor + + /** + * Returns the raw multipart value of [bgImageUrl]. + * + * Unlike [bgImageUrl], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("bg_image_url") + @ExcludeMissing + fun _bgImageUrl(): MultipartField = bgImageUrl + + /** + * Returns the raw multipart value of [semitransparency]. + * + * Unlike [semitransparency], this method doesn't throw if the multipart field has + * an unexpected type. + */ + @JsonProperty("semitransparency") + @ExcludeMissing + fun _semitransparency(): MultipartField = semitransparency + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Options]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Options]. */ + class Builder internal constructor() { + + private var addShadow: MultipartField = MultipartField.of(null) + private var bgColor: MultipartField = MultipartField.of(null) + private var bgImageUrl: MultipartField = MultipartField.of(null) + private var semitransparency: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(options: Options) = apply { + addShadow = options.addShadow + bgColor = options.bgColor + bgImageUrl = options.bgImageUrl + semitransparency = options.semitransparency + additionalProperties = options.additionalProperties.toMutableMap() + } + + /** + * Whether to add an artificial shadow to the result. Default is false. Note: + * Adding shadows is currently only supported for car photos. + */ + fun addShadow(addShadow: Boolean) = addShadow(MultipartField.of(addShadow)) + + /** + * Sets [Builder.addShadow] to an arbitrary multipart value. + * + * You should usually call [Builder.addShadow] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun addShadow(addShadow: MultipartField) = apply { + this.addShadow = addShadow + } + + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or + * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be + * empty. + */ + fun bgColor(bgColor: String) = bgColor(MultipartField.of(bgColor)) + + /** + * Sets [Builder.bgColor] to an arbitrary multipart value. + * + * You should usually call [Builder.bgColor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun bgColor(bgColor: MultipartField) = apply { this.bgColor = bgColor } + + /** + * Sets a background image from a URL. If this parameter is set, `bg_color` must + * be empty. + */ + fun bgImageUrl(bgImageUrl: String) = bgImageUrl(MultipartField.of(bgImageUrl)) + + /** + * Sets [Builder.bgImageUrl] to an arbitrary multipart value. + * + * You should usually call [Builder.bgImageUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun bgImageUrl(bgImageUrl: MultipartField) = apply { + this.bgImageUrl = bgImageUrl + } + + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + */ + fun semitransparency(semitransparency: Boolean) = + semitransparency(MultipartField.of(semitransparency)) + + /** + * Sets [Builder.semitransparency] to an arbitrary multipart value. + * + * You should usually call [Builder.semitransparency] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun semitransparency(semitransparency: MultipartField) = apply { + this.semitransparency = semitransparency + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Options]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Options = + Options( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Options = apply { + if (validated) { + return@apply + } + + addShadow() + bgColor() + bgImageUrl() + semitransparency() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Options && + addShadow == other.addShadow && + bgColor == other.bgColor && + bgImageUrl == other.bgImageUrl && + semitransparency == other.semitransparency && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveBg && + name == other.name && + options == other.options && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, options, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" + } + + class AutoTaggingExtension + private constructor( + private val maxTags: MultipartField, + private val minConfidence: MultipartField, + private val name: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Maximum number of tags to attach to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun maxTags(): Long = maxTags.value.getRequired("maxTags") + + /** + * Minimum confidence level for tags to be considered valid. + * + * @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 minConfidence(): Long = minConfidence.value.getRequired("minConfidence") + + /** + * Specifies the auto-tagging extension used. + * + * @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(): Name = name.value.getRequired("name") + + /** + * Returns the raw multipart value of [maxTags]. + * + * Unlike [maxTags], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("maxTags") @ExcludeMissing fun _maxTags(): MultipartField = maxTags + + /** + * Returns the raw multipart value of [minConfidence]. + * + * Unlike [minConfidence], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("minConfidence") + @ExcludeMissing + fun _minConfidence(): MultipartField = minConfidence + + /** + * Returns the raw multipart value of [name]. + * + * Unlike [name], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AutoTaggingExtension]. + * + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutoTaggingExtension]. */ + class Builder internal constructor() { + + private var maxTags: MultipartField? = null + private var minConfidence: MultipartField? = null + private var name: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { + maxTags = autoTaggingExtension.maxTags + minConfidence = autoTaggingExtension.minConfidence + name = autoTaggingExtension.name + additionalProperties = autoTaggingExtension.additionalProperties.toMutableMap() + } + + /** Maximum number of tags to attach to the asset. */ + fun maxTags(maxTags: Long) = maxTags(MultipartField.of(maxTags)) + + /** + * Sets [Builder.maxTags] to an arbitrary multipart value. + * + * You should usually call [Builder.maxTags] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxTags(maxTags: MultipartField) = apply { this.maxTags = maxTags } + + /** Minimum confidence level for tags to be considered valid. */ + fun minConfidence(minConfidence: Long) = + minConfidence(MultipartField.of(minConfidence)) + + /** + * Sets [Builder.minConfidence] to an arbitrary multipart value. + * + * You should usually call [Builder.minConfidence] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun minConfidence(minConfidence: MultipartField) = apply { + this.minConfidence = minConfidence + } + + /** Specifies the auto-tagging extension used. */ + fun name(name: Name) = name(MultipartField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary multipart value. + * + * You should usually call [Builder.name] with a well-typed [Name] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: MultipartField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutoTaggingExtension]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutoTaggingExtension = + AutoTaggingExtension( + checkRequired("maxTags", maxTags), + checkRequired("minConfidence", minConfidence), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutoTaggingExtension = apply { + if (validated) { + return@apply + } + + maxTags() + minConfidence() + name().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Specifies the auto-tagging extension used. */ + class Name @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") + + @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + } + + /** + * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Name] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + /** + * An enum member indicating that [Name] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING + else -> throw ImageKitInvalidDataException("Unknown Name: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Name = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Name && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutoTaggingExtension && + maxTags == other.maxTags && + minConfidence == other.minConfidence && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(maxTags, minConfidence, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" + } + } + + class ResponseField @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TAGS = of("tags") + + @JvmField val CUSTOM_COORDINATES = of("customCoordinates") + + @JvmField val IS_PRIVATE_FILE = of("isPrivateFile") + + @JvmField val EMBEDDED_METADATA = of("embeddedMetadata") + + @JvmField val IS_PUBLISHED = of("isPublished") + + @JvmField val CUSTOM_METADATA = of("customMetadata") + + @JvmField val METADATA = of("metadata") + + @JvmStatic fun of(value: String) = ResponseField(JsonField.of(value)) + } + + /** An enum containing [ResponseField]'s known values. */ + enum class Known { + TAGS, + CUSTOM_COORDINATES, + IS_PRIVATE_FILE, + EMBEDDED_METADATA, + IS_PUBLISHED, + CUSTOM_METADATA, + METADATA, + } + + /** + * An enum containing [ResponseField]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ResponseField] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TAGS, + CUSTOM_COORDINATES, + IS_PRIVATE_FILE, + EMBEDDED_METADATA, + IS_PUBLISHED, + CUSTOM_METADATA, + METADATA, + /** + * An enum member indicating that [ResponseField] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TAGS -> Value.TAGS + CUSTOM_COORDINATES -> Value.CUSTOM_COORDINATES + IS_PRIVATE_FILE -> Value.IS_PRIVATE_FILE + EMBEDDED_METADATA -> Value.EMBEDDED_METADATA + IS_PUBLISHED -> Value.IS_PUBLISHED + CUSTOM_METADATA -> Value.CUSTOM_METADATA + METADATA -> Value.METADATA + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TAGS -> Known.TAGS + CUSTOM_COORDINATES -> Known.CUSTOM_COORDINATES + IS_PRIVATE_FILE -> Known.IS_PRIVATE_FILE + EMBEDDED_METADATA -> Known.EMBEDDED_METADATA + IS_PUBLISHED -> Known.IS_PUBLISHED + CUSTOM_METADATA -> Known.CUSTOM_METADATA + METADATA -> Known.METADATA + else -> throw ImageKitInvalidDataException("Unknown ResponseField: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ResponseField = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResponseField && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing file + * size or applying basic optimizations upfront (e.g., resize, compress). + * - `post` — applied immediately after upload. Ideal for generating transformed versions (like + * video encodes or thumbnails) in advance, so they're ready for delivery without delay. + * + * You can mix and match any combination of post-processing types. + */ + class Transformation + private constructor( + private val post: MultipartField>, + private val pre: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * List of transformations to apply _after_ the file is uploaded. Each item must match one + * of the following types: `transformation`, `gif-to-video`, `thumbnail`, `abs`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun post(): Optional> = post.value.getOptional("post") + + /** + * Transformation string to apply before uploading the file to the Media Library. Useful for + * optimizing files at ingestion. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun pre(): Optional = pre.value.getOptional("pre") + + /** + * Returns the raw multipart value of [post]. + * + * Unlike [post], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("post") @ExcludeMissing fun _post(): MultipartField> = post + + /** + * Returns the raw multipart value of [pre]. + * + * Unlike [pre], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("pre") @ExcludeMissing fun _pre(): MultipartField = pre + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Transformation]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Transformation]. */ + class Builder internal constructor() { + + private var post: MultipartField>? = null + private var pre: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(transformation: Transformation) = apply { + post = transformation.post.map { it.toMutableList() } + pre = transformation.pre + additionalProperties = transformation.additionalProperties.toMutableMap() + } + + /** + * List of transformations to apply _after_ the file is uploaded. Each item must match + * one of the following types: `transformation`, `gif-to-video`, `thumbnail`, `abs`. + */ + fun post(post: List) = post(MultipartField.of(post)) + + /** + * Sets [Builder.post] to an arbitrary multipart value. + * + * You should usually call [Builder.post] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun post(post: MultipartField>) = apply { + this.post = post.map { it.toMutableList() } + } + + /** + * Adds a single [Post] to [Builder.post]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPost(post: Post) = apply { + this.post = + (this.post ?: MultipartField.of(mutableListOf())).also { + checkKnown("post", it).add(post) + } + } + + /** Alias for calling [addPost] with `Post.ofTransformation(transformation)`. */ + fun addPost(transformation: Post.InnerTransformation) = + addPost(Post.ofTransformation(transformation)) + + /** + * Alias for calling [addPost] with the following: + * ```java + * Post.InnerTransformation.builder() + * .value(value) + * .build() + * ``` + */ + fun addTransformationPost(value: String) = + addPost(Post.InnerTransformation.builder().value(value).build()) + + /** Alias for calling [addPost] with `Post.ofGifToVideo(gifToVideo)`. */ + fun addPost(gifToVideo: Post.GifToVideo) = addPost(Post.ofGifToVideo(gifToVideo)) + + /** Alias for calling [addPost] with `Post.ofThumbnail(thumbnail)`. */ + fun addPost(thumbnail: Post.Thumbnail) = addPost(Post.ofThumbnail(thumbnail)) + + /** Alias for calling [addPost] with `Post.ofAbs(abs)`. */ + fun addPost(abs: Post.Abs) = addPost(Post.ofAbs(abs)) + + /** + * Transformation string to apply before uploading the file to the Media Library. Useful + * for optimizing files at ingestion. + */ + fun pre(pre: String) = pre(MultipartField.of(pre)) + + /** + * Sets [Builder.pre] to an arbitrary multipart value. + * + * You should usually call [Builder.pre] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pre(pre: MultipartField) = apply { this.pre = pre } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Transformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Transformation = + Transformation( + (post ?: MultipartField.of(null)).map { it.toImmutable() }, + pre, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Transformation = apply { + if (validated) { + return@apply + } + + post().ifPresent { it.forEach { it.validate() } } + pre() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + @JsonDeserialize(using = Post.Deserializer::class) + @JsonSerialize(using = Post.Serializer::class) + class Post + private constructor( + private val transformation: InnerTransformation? = null, + private val gifToVideo: GifToVideo? = null, + private val thumbnail: Thumbnail? = null, + private val abs: Abs? = null, + private val _json: JsonValue? = null, + ) { + + fun transformation(): Optional = + Optional.ofNullable(transformation) + + fun gifToVideo(): Optional = Optional.ofNullable(gifToVideo) + + fun thumbnail(): Optional = Optional.ofNullable(thumbnail) + + fun abs(): Optional = Optional.ofNullable(abs) + + fun isTransformation(): Boolean = transformation != null + + fun isGifToVideo(): Boolean = gifToVideo != null + + fun isThumbnail(): Boolean = thumbnail != null + + fun isAbs(): Boolean = abs != null + + fun asTransformation(): InnerTransformation = + transformation.getOrThrow("transformation") + + fun asGifToVideo(): GifToVideo = gifToVideo.getOrThrow("gifToVideo") + + fun asThumbnail(): Thumbnail = thumbnail.getOrThrow("thumbnail") + + fun asAbs(): Abs = abs.getOrThrow("abs") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + transformation != null -> visitor.visitTransformation(transformation) + gifToVideo != null -> visitor.visitGifToVideo(gifToVideo) + thumbnail != null -> visitor.visitThumbnail(thumbnail) + abs != null -> visitor.visitAbs(abs) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Post = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTransformation(transformation: InnerTransformation) { + transformation.validate() + } + + override fun visitGifToVideo(gifToVideo: GifToVideo) { + gifToVideo.validate() + } + + override fun visitThumbnail(thumbnail: Thumbnail) { + thumbnail.validate() + } + + override fun visitAbs(abs: Abs) { + abs.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitTransformation(transformation: InnerTransformation) = + transformation.validity() + + override fun visitGifToVideo(gifToVideo: GifToVideo) = gifToVideo.validity() + + override fun visitThumbnail(thumbnail: Thumbnail) = thumbnail.validity() + + override fun visitAbs(abs: Abs) = abs.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Post && + transformation == other.transformation && + gifToVideo == other.gifToVideo && + thumbnail == other.thumbnail && + abs == other.abs + } + + override fun hashCode(): Int = Objects.hash(transformation, gifToVideo, thumbnail, abs) + + override fun toString(): String = + when { + transformation != null -> "Post{transformation=$transformation}" + gifToVideo != null -> "Post{gifToVideo=$gifToVideo}" + thumbnail != null -> "Post{thumbnail=$thumbnail}" + abs != null -> "Post{abs=$abs}" + _json != null -> "Post{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Post") + } + + companion object { + + @JvmStatic + fun ofTransformation(transformation: InnerTransformation) = + Post(transformation = transformation) + + @JvmStatic fun ofGifToVideo(gifToVideo: GifToVideo) = Post(gifToVideo = gifToVideo) + + @JvmStatic fun ofThumbnail(thumbnail: Thumbnail) = Post(thumbnail = thumbnail) + + @JvmStatic fun ofAbs(abs: Abs) = Post(abs = abs) + } + + /** + * An interface that defines how to map each variant of [Post] to a value of type [T]. + */ + interface Visitor { + + fun visitTransformation(transformation: InnerTransformation): T + + fun visitGifToVideo(gifToVideo: GifToVideo): T + + fun visitThumbnail(thumbnail: Thumbnail): T + + fun visitAbs(abs: Abs): T + + /** + * Maps an unknown variant of [Post] to a value of type [T]. + * + * An instance of [Post] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Post: $json") + } + } + + internal class Deserializer : BaseDeserializer(Post::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Post { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "transformation" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Post(transformation = it, _json = json) } + ?: Post(_json = json) + } + "gif-to-video" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(gifToVideo = it, _json = json) + } ?: Post(_json = json) + } + "thumbnail" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(thumbnail = it, _json = json) + } ?: Post(_json = json) + } + "abs" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(abs = it, _json = json) + } ?: Post(_json = json) + } + } + + return Post(_json = json) + } + } + + internal class Serializer : BaseSerializer(Post::class) { + + override fun serialize( + value: Post, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.transformation != null -> generator.writeObject(value.transformation) + value.gifToVideo != null -> generator.writeObject(value.gifToVideo) + value.thumbnail != null -> generator.writeObject(value.thumbnail) + value.abs != null -> generator.writeObject(value.abs) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Post") + } + } + } + + class InnerTransformation + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Transformation type. + * + * Expected to always return the following: + * ```java + * JsonValue.from("transformation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based + * 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 value(): String = value.value.getRequired("value") + + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InnerTransformation]. + * + * The following fields are required: + * ```java + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InnerTransformation]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("transformation") + private var value: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(innerTransformation: InnerTransformation) = apply { + type = innerTransformation.type + value = innerTransformation.value + additionalProperties = + innerTransformation.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("transformation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based + * transformations. + */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InnerTransformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InnerTransformation = + InnerTransformation( + type, + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InnerTransformation = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("transformation")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InnerTransformation && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InnerTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" + } + + class GifToVideo + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Converts an animated GIF into an MP4. + * + * Expected to always return the following: + * ```java + * JsonValue.from("gif-to-video") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Optional transformation string to apply to the output video. **Example**: `q-80` + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.value.getOptional("value") + + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [GifToVideo]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GifToVideo]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("gif-to-video") + private var value: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(gifToVideo: GifToVideo) = apply { + type = gifToVideo.type + value = gifToVideo.value + additionalProperties = gifToVideo.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("gif-to-video") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Optional transformation string to apply to the output video. **Example**: + * `q-80` + */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GifToVideo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GifToVideo = + GifToVideo(type, value, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): GifToVideo = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("gif-to-video")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GifToVideo && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GifToVideo{type=$type, value=$value, additionalProperties=$additionalProperties}" + } + + class Thumbnail + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Generates a thumbnail image. + * + * Expected to always return the following: + * ```java + * JsonValue.from("thumbnail") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Optional transformation string. **Example**: `w-150,h-150` + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.value.getOptional("value") + + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Thumbnail]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Thumbnail]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("thumbnail") + private var value: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(thumbnail: Thumbnail) = apply { + type = thumbnail.type + value = thumbnail.value + additionalProperties = thumbnail.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("thumbnail") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Optional transformation string. **Example**: `w-150,h-150` */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Thumbnail]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Thumbnail = + Thumbnail(type, value, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Thumbnail = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("thumbnail")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Thumbnail && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Thumbnail{type=$type, value=$value, additionalProperties=$additionalProperties}" + } + + class Abs + private constructor( + private val protocol: MultipartField, + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Streaming protocol to use (`hls` or `dash`). + * + * @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 protocol(): Protocol = protocol.value.getRequired("protocol") + + /** + * Adaptive Bitrate Streaming (ABS) setup. + * + * Expected to always return the following: + * ```java + * JsonValue.from("abs") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * List of different representations you want to create separated by an underscore. + * + * @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 value(): String = value.value.getRequired("value") + + /** + * Returns the raw multipart value of [protocol]. + * + * Unlike [protocol], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("protocol") + @ExcludeMissing + fun _protocol(): MultipartField = protocol + + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Abs]. + * + * The following fields are required: + * ```java + * .protocol() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Abs]. */ + class Builder internal constructor() { + + private var protocol: MultipartField? = null + private var type: JsonValue = JsonValue.from("abs") + private var value: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(abs: Abs) = apply { + protocol = abs.protocol + type = abs.type + value = abs.value + additionalProperties = abs.additionalProperties.toMutableMap() + } + + /** Streaming protocol to use (`hls` or `dash`). */ + fun protocol(protocol: Protocol) = protocol(MultipartField.of(protocol)) + + /** + * Sets [Builder.protocol] to an arbitrary multipart value. + * + * You should usually call [Builder.protocol] with a well-typed [Protocol] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun protocol(protocol: MultipartField) = apply { + this.protocol = protocol + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("abs") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * List of different representations you want to create separated by an + * underscore. + */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Abs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .protocol() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Abs = + Abs( + checkRequired("protocol", protocol), + type, + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Abs = apply { + if (validated) { + return@apply + } + + protocol().validate() + _type().let { + if (it != JsonValue.from("abs")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Streaming protocol to use (`hls` or `dash`). */ + class Protocol + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HLS = of("hls") + + @JvmField val DASH = of("dash") + + @JvmStatic fun of(value: String) = Protocol(JsonField.of(value)) + } + + /** An enum containing [Protocol]'s known values. */ + enum class Known { + HLS, + DASH, + } + + /** + * An enum containing [Protocol]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Protocol] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HLS, + DASH, + /** + * An enum member indicating that [Protocol] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HLS -> Value.HLS + DASH -> Value.DASH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HLS -> Known.HLS + DASH -> Known.DASH + else -> throw ImageKitInvalidDataException("Unknown Protocol: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Protocol = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Protocol && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Abs && + protocol == other.protocol && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(protocol, type, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Abs{protocol=$protocol, type=$type, value=$value, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Transformation && + post == other.post && + pre == other.pre && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(post, pre, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Transformation{post=$post, pre=$pre, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FileUploadParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FileUploadParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt new file mode 100644 index 00000000..2b6fd59d --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt @@ -0,0 +1,2620 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.beta.v2.files + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.files.Metadata +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Object containing details of a successful upload. */ +class FileUploadResponse +private constructor( + private val aiTags: JsonField>, + private val audioCodec: JsonField, + private val bitRate: JsonField, + private val customCoordinates: JsonField, + private val customMetadata: JsonField, + private val description: JsonField, + private val duration: JsonField, + private val embeddedMetadata: JsonField, + private val extensionStatus: JsonField, + private val fileId: JsonField, + private val filePath: JsonField, + private val fileType: JsonField, + private val height: JsonField, + private val isPrivateFile: JsonField, + private val isPublished: JsonField, + private val metadata: JsonField, + private val name: JsonField, + private val size: JsonField, + private val tags: JsonField>, + private val thumbnailUrl: JsonField, + private val url: JsonField, + private val versionInfo: JsonField, + private val videoCodec: JsonField, + private val width: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("AITags") @ExcludeMissing aiTags: JsonField> = JsonMissing.of(), + @JsonProperty("audioCodec") + @ExcludeMissing + audioCodec: JsonField = JsonMissing.of(), + @JsonProperty("bitRate") @ExcludeMissing bitRate: JsonField = JsonMissing.of(), + @JsonProperty("customCoordinates") + @ExcludeMissing + customCoordinates: JsonField = JsonMissing.of(), + @JsonProperty("customMetadata") + @ExcludeMissing + customMetadata: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), + @JsonProperty("embeddedMetadata") + @ExcludeMissing + embeddedMetadata: JsonField = JsonMissing.of(), + @JsonProperty("extensionStatus") + @ExcludeMissing + extensionStatus: JsonField = JsonMissing.of(), + @JsonProperty("fileId") @ExcludeMissing fileId: JsonField = JsonMissing.of(), + @JsonProperty("filePath") @ExcludeMissing filePath: JsonField = JsonMissing.of(), + @JsonProperty("fileType") @ExcludeMissing fileType: JsonField = JsonMissing.of(), + @JsonProperty("height") @ExcludeMissing height: JsonField = JsonMissing.of(), + @JsonProperty("isPrivateFile") + @ExcludeMissing + isPrivateFile: JsonField = JsonMissing.of(), + @JsonProperty("isPublished") + @ExcludeMissing + isPublished: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("size") @ExcludeMissing size: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), + @JsonProperty("thumbnailUrl") + @ExcludeMissing + thumbnailUrl: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("versionInfo") + @ExcludeMissing + versionInfo: JsonField = JsonMissing.of(), + @JsonProperty("videoCodec") + @ExcludeMissing + videoCodec: JsonField = JsonMissing.of(), + @JsonProperty("width") @ExcludeMissing width: JsonField = JsonMissing.of(), + ) : this( + aiTags, + audioCodec, + bitRate, + customCoordinates, + customMetadata, + description, + duration, + embeddedMetadata, + extensionStatus, + fileId, + filePath, + fileType, + height, + isPrivateFile, + isPublished, + metadata, + name, + size, + tags, + thumbnailUrl, + url, + versionInfo, + videoCodec, + width, + mutableMapOf(), + ) + + /** + * An array of tags assigned to the uploaded file by auto tagging. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun aiTags(): Optional> = aiTags.getOptional("AITags") + + /** + * The audio codec used in the video (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun audioCodec(): Optional = audioCodec.getOptional("audioCodec") + + /** + * The bit rate of the video in kbps (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun bitRate(): Optional = bitRate.getOptional("bitRate") + + /** + * Value of custom coordinates associated with the image in the format `x,y,width,height`. If + * `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` in + * `responseFields` in API request to get the value of this field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customCoordinates(): Optional = customCoordinates.getOptional("customCoordinates") + + /** + * A key-value data associated with the asset. Use `responseField` in API request to get + * `customMetadata` in the upload API response. Before setting any custom metadata on an asset, + * you have to create the field using custom metadata fields API. Send `customMetadata` in + * `responseFields` in API request to get the value of this field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customMetadata(): Optional = customMetadata.getOptional("customMetadata") + + /** + * Optional text to describe the contents of the file. Can be set by the user or the + * ai-auto-description extension. + * + * @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") + + /** + * The duration of the video in seconds (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun duration(): Optional = duration.getOptional("duration") + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp + * data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata in + * the upload API response. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun embeddedMetadata(): Optional = + embeddedMetadata.getOptional("embeddedMetadata") + + /** + * Extension names with their processing status at the time of completion of the request. It + * could have one of the following status values: + * + * `success`: The extension has been successfully applied. `failed`: The extension has failed + * and will not be retried. `pending`: The extension will finish processing in some time. On + * completion, the final status (success / failed) will be sent to the `webhookUrl` provided. + * + * If no extension was requested, then this parameter is not returned. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun extensionStatus(): Optional = + extensionStatus.getOptional("extensionStatus") + + /** + * Unique fileId. Store this fileld in your database, as this will be used to perform update + * action on this file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fileId(): Optional = fileId.getOptional("fileId") + + /** + * The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun filePath(): Optional = filePath.getOptional("filePath") + + /** + * Type of the uploaded file. Possible values are `image`, `non-image`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fileType(): Optional = fileType.getOptional("fileType") + + /** + * Height of the image in pixels (Only for images) + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun height(): Optional = height.getOptional("height") + + /** + * Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` in + * `responseFields` in API request to get the value of this field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isPrivateFile(): Optional = isPrivateFile.getOptional("isPrivateFile") + + /** + * Is the file published or in draft state. It can be either `true` or `false`. Send + * `isPublished` in `responseFields` in API request to get the value of this field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isPublished(): Optional = isPublished.getOptional("isPublished") + + /** + * Legacy metadata. Send `metadata` in `responseFields` in API request to get metadata in the + * upload API response. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Name of the asset. + * + * @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") + + /** + * Size of the image file in Bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun size(): Optional = size.getOptional("size") + + /** + * The array of tags associated with the asset. If no tags are set, it will be `null`. Send + * `tags` in `responseFields` in API request to get the value of this field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tags(): Optional> = tags.getOptional("tags") + + /** + * In the case of an image, a small thumbnail URL. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun thumbnailUrl(): Optional = thumbnailUrl.getOptional("thumbnailUrl") + + /** + * A publicly accessible URL of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * An object containing the file or file version's `id` (versionId) and `name`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun versionInfo(): Optional = versionInfo.getOptional("versionInfo") + + /** + * The video codec used in the video (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun videoCodec(): Optional = videoCodec.getOptional("videoCodec") + + /** + * Width of the image in pixels (Only for Images) + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun width(): Optional = width.getOptional("width") + + /** + * Returns the raw JSON value of [aiTags]. + * + * Unlike [aiTags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("AITags") @ExcludeMissing fun _aiTags(): JsonField> = aiTags + + /** + * Returns the raw JSON value of [audioCodec]. + * + * Unlike [audioCodec], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("audioCodec") @ExcludeMissing fun _audioCodec(): JsonField = audioCodec + + /** + * Returns the raw JSON value of [bitRate]. + * + * Unlike [bitRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bitRate") @ExcludeMissing fun _bitRate(): JsonField = bitRate + + /** + * Returns the raw JSON value of [customCoordinates]. + * + * Unlike [customCoordinates], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("customCoordinates") + @ExcludeMissing + fun _customCoordinates(): JsonField = customCoordinates + + /** + * Returns the raw JSON value of [customMetadata]. + * + * Unlike [customMetadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): JsonField = customMetadata + + /** + * 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 [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [embeddedMetadata]. + * + * Unlike [embeddedMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("embeddedMetadata") + @ExcludeMissing + fun _embeddedMetadata(): JsonField = embeddedMetadata + + /** + * Returns the raw JSON value of [extensionStatus]. + * + * Unlike [extensionStatus], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extensionStatus") + @ExcludeMissing + fun _extensionStatus(): JsonField = extensionStatus + + /** + * Returns the raw JSON value of [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fileId") @ExcludeMissing fun _fileId(): JsonField = fileId + + /** + * Returns the raw JSON value of [filePath]. + * + * Unlike [filePath], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filePath") @ExcludeMissing fun _filePath(): JsonField = filePath + + /** + * Returns the raw JSON value of [fileType]. + * + * Unlike [fileType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fileType") @ExcludeMissing fun _fileType(): JsonField = fileType + + /** + * Returns the raw JSON value of [height]. + * + * Unlike [height], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("height") @ExcludeMissing fun _height(): JsonField = height + + /** + * Returns the raw JSON value of [isPrivateFile]. + * + * Unlike [isPrivateFile], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isPrivateFile") + @ExcludeMissing + fun _isPrivateFile(): JsonField = isPrivateFile + + /** + * Returns the raw JSON value of [isPublished]. + * + * Unlike [isPublished], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isPublished") + @ExcludeMissing + fun _isPublished(): JsonField = isPublished + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [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 [size]. + * + * Unlike [size], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("size") @ExcludeMissing fun _size(): JsonField = size + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + + /** + * Returns the raw JSON value of [thumbnailUrl]. + * + * Unlike [thumbnailUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("thumbnailUrl") + @ExcludeMissing + fun _thumbnailUrl(): JsonField = thumbnailUrl + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [versionInfo]. + * + * Unlike [versionInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("versionInfo") + @ExcludeMissing + fun _versionInfo(): JsonField = versionInfo + + /** + * Returns the raw JSON value of [videoCodec]. + * + * Unlike [videoCodec], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("videoCodec") @ExcludeMissing fun _videoCodec(): JsonField = videoCodec + + /** + * Returns the raw JSON value of [width]. + * + * Unlike [width], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("width") @ExcludeMissing fun _width(): JsonField = width + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FileUploadResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileUploadResponse]. */ + class Builder internal constructor() { + + private var aiTags: JsonField>? = null + private var audioCodec: JsonField = JsonMissing.of() + private var bitRate: JsonField = JsonMissing.of() + private var customCoordinates: JsonField = JsonMissing.of() + private var customMetadata: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var duration: JsonField = JsonMissing.of() + private var embeddedMetadata: JsonField = JsonMissing.of() + private var extensionStatus: JsonField = JsonMissing.of() + private var fileId: JsonField = JsonMissing.of() + private var filePath: JsonField = JsonMissing.of() + private var fileType: JsonField = JsonMissing.of() + private var height: JsonField = JsonMissing.of() + private var isPrivateFile: JsonField = JsonMissing.of() + private var isPublished: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var size: JsonField = JsonMissing.of() + private var tags: JsonField>? = null + private var thumbnailUrl: JsonField = JsonMissing.of() + private var url: JsonField = JsonMissing.of() + private var versionInfo: JsonField = JsonMissing.of() + private var videoCodec: JsonField = JsonMissing.of() + private var width: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fileUploadResponse: FileUploadResponse) = apply { + aiTags = fileUploadResponse.aiTags.map { it.toMutableList() } + audioCodec = fileUploadResponse.audioCodec + bitRate = fileUploadResponse.bitRate + customCoordinates = fileUploadResponse.customCoordinates + customMetadata = fileUploadResponse.customMetadata + description = fileUploadResponse.description + duration = fileUploadResponse.duration + embeddedMetadata = fileUploadResponse.embeddedMetadata + extensionStatus = fileUploadResponse.extensionStatus + fileId = fileUploadResponse.fileId + filePath = fileUploadResponse.filePath + fileType = fileUploadResponse.fileType + height = fileUploadResponse.height + isPrivateFile = fileUploadResponse.isPrivateFile + isPublished = fileUploadResponse.isPublished + metadata = fileUploadResponse.metadata + name = fileUploadResponse.name + size = fileUploadResponse.size + tags = fileUploadResponse.tags.map { it.toMutableList() } + thumbnailUrl = fileUploadResponse.thumbnailUrl + url = fileUploadResponse.url + versionInfo = fileUploadResponse.versionInfo + videoCodec = fileUploadResponse.videoCodec + width = fileUploadResponse.width + additionalProperties = fileUploadResponse.additionalProperties.toMutableMap() + } + + /** An array of tags assigned to the uploaded file by auto tagging. */ + fun aiTags(aiTags: List?) = aiTags(JsonField.ofNullable(aiTags)) + + /** Alias for calling [Builder.aiTags] with `aiTags.orElse(null)`. */ + fun aiTags(aiTags: Optional>) = aiTags(aiTags.getOrNull()) + + /** + * Sets [Builder.aiTags] to an arbitrary JSON value. + * + * You should usually call [Builder.aiTags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun aiTags(aiTags: JsonField>) = apply { + this.aiTags = aiTags.map { it.toMutableList() } + } + + /** + * Adds a single [AiTag] to [aiTags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAiTag(aiTag: AiTag) = apply { + aiTags = + (aiTags ?: JsonField.of(mutableListOf())).also { + checkKnown("aiTags", it).add(aiTag) + } + } + + /** The audio codec used in the video (only for video). */ + fun audioCodec(audioCodec: String) = audioCodec(JsonField.of(audioCodec)) + + /** + * Sets [Builder.audioCodec] to an arbitrary JSON value. + * + * You should usually call [Builder.audioCodec] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun audioCodec(audioCodec: JsonField) = apply { this.audioCodec = audioCodec } + + /** The bit rate of the video in kbps (only for video). */ + fun bitRate(bitRate: Long) = bitRate(JsonField.of(bitRate)) + + /** + * Sets [Builder.bitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.bitRate] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun bitRate(bitRate: JsonField) = apply { this.bitRate = bitRate } + + /** + * Value of custom coordinates associated with the image in the format `x,y,width,height`. + * If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` in + * `responseFields` in API request to get the value of this field. + */ + fun customCoordinates(customCoordinates: String?) = + customCoordinates(JsonField.ofNullable(customCoordinates)) + + /** Alias for calling [Builder.customCoordinates] with `customCoordinates.orElse(null)`. */ + fun customCoordinates(customCoordinates: Optional) = + customCoordinates(customCoordinates.getOrNull()) + + /** + * Sets [Builder.customCoordinates] to an arbitrary JSON value. + * + * You should usually call [Builder.customCoordinates] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customCoordinates(customCoordinates: JsonField) = apply { + this.customCoordinates = customCoordinates + } + + /** + * A key-value data associated with the asset. Use `responseField` in API request to get + * `customMetadata` in the upload API response. Before setting any custom metadata on an + * asset, you have to create the field using custom metadata fields API. Send + * `customMetadata` in `responseFields` in API request to get the value of this field. + */ + fun customMetadata(customMetadata: CustomMetadata) = + customMetadata(JsonField.of(customMetadata)) + + /** + * Sets [Builder.customMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.customMetadata] with a well-typed [CustomMetadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customMetadata(customMetadata: JsonField) = apply { + this.customMetadata = customMetadata + } + + /** + * Optional text to describe the contents of the file. Can be set by the user or the + * ai-auto-description extension. + */ + 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 } + + /** The duration of the video in seconds (only for video). */ + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp + * data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata + * in the upload API response. + */ + fun embeddedMetadata(embeddedMetadata: EmbeddedMetadata) = + embeddedMetadata(JsonField.of(embeddedMetadata)) + + /** + * Sets [Builder.embeddedMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.embeddedMetadata] with a well-typed [EmbeddedMetadata] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun embeddedMetadata(embeddedMetadata: JsonField) = apply { + this.embeddedMetadata = embeddedMetadata + } + + /** + * Extension names with their processing status at the time of completion of the request. It + * could have one of the following status values: + * + * `success`: The extension has been successfully applied. `failed`: The extension has + * failed and will not be retried. `pending`: The extension will finish processing in some + * time. On completion, the final status (success / failed) will be sent to the `webhookUrl` + * provided. + * + * If no extension was requested, then this parameter is not returned. + */ + fun extensionStatus(extensionStatus: ExtensionStatus) = + extensionStatus(JsonField.of(extensionStatus)) + + /** + * Sets [Builder.extensionStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.extensionStatus] with a well-typed [ExtensionStatus] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun extensionStatus(extensionStatus: JsonField) = apply { + this.extensionStatus = extensionStatus + } + + /** + * Unique fileId. Store this fileld in your database, as this will be used to perform update + * action on this file. + */ + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + + /** + * The relative path of the file in the media library e.g. + * `/marketing-assets/new-banner.jpg`. + */ + fun filePath(filePath: String) = filePath(JsonField.of(filePath)) + + /** + * Sets [Builder.filePath] to an arbitrary JSON value. + * + * You should usually call [Builder.filePath] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filePath(filePath: JsonField) = apply { this.filePath = filePath } + + /** Type of the uploaded file. Possible values are `image`, `non-image`. */ + fun fileType(fileType: String) = fileType(JsonField.of(fileType)) + + /** + * Sets [Builder.fileType] to an arbitrary JSON value. + * + * You should usually call [Builder.fileType] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fileType(fileType: JsonField) = apply { this.fileType = fileType } + + /** Height of the image in pixels (Only for images) */ + fun height(height: Double) = height(JsonField.of(height)) + + /** + * Sets [Builder.height] to an arbitrary JSON value. + * + * You should usually call [Builder.height] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun height(height: JsonField) = apply { this.height = height } + + /** + * Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` + * in `responseFields` in API request to get the value of this field. + */ + fun isPrivateFile(isPrivateFile: Boolean) = isPrivateFile(JsonField.of(isPrivateFile)) + + /** + * Sets [Builder.isPrivateFile] to an arbitrary JSON value. + * + * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPrivateFile(isPrivateFile: JsonField) = apply { + this.isPrivateFile = isPrivateFile + } + + /** + * Is the file published or in draft state. It can be either `true` or `false`. Send + * `isPublished` in `responseFields` in API request to get the value of this field. + */ + fun isPublished(isPublished: Boolean) = isPublished(JsonField.of(isPublished)) + + /** + * Sets [Builder.isPublished] to an arbitrary JSON value. + * + * You should usually call [Builder.isPublished] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isPublished(isPublished: JsonField) = apply { this.isPublished = isPublished } + + /** + * Legacy metadata. Send `metadata` in `responseFields` in API request to get metadata in + * the upload API response. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** Name of the asset. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Size of the image file in Bytes. */ + fun size(size: Double) = size(JsonField.of(size)) + + /** + * Sets [Builder.size] to an arbitrary JSON value. + * + * You should usually call [Builder.size] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun size(size: JsonField) = apply { this.size = size } + + /** + * The array of tags associated with the asset. If no tags are set, it will be `null`. Send + * `tags` in `responseFields` in API request to get the value of this field. + */ + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + /** In the case of an image, a small thumbnail URL. */ + fun thumbnailUrl(thumbnailUrl: String) = thumbnailUrl(JsonField.of(thumbnailUrl)) + + /** + * Sets [Builder.thumbnailUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.thumbnailUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thumbnailUrl(thumbnailUrl: JsonField) = apply { + this.thumbnailUrl = thumbnailUrl + } + + /** A publicly accessible URL of the file. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** An object containing the file or file version's `id` (versionId) and `name`. */ + fun versionInfo(versionInfo: VersionInfo) = versionInfo(JsonField.of(versionInfo)) + + /** + * Sets [Builder.versionInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.versionInfo] with a well-typed [VersionInfo] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun versionInfo(versionInfo: JsonField) = apply { + this.versionInfo = versionInfo + } + + /** The video codec used in the video (only for video). */ + fun videoCodec(videoCodec: String) = videoCodec(JsonField.of(videoCodec)) + + /** + * Sets [Builder.videoCodec] to an arbitrary JSON value. + * + * You should usually call [Builder.videoCodec] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun videoCodec(videoCodec: JsonField) = apply { this.videoCodec = videoCodec } + + /** Width of the image in pixels (Only for Images) */ + fun width(width: Double) = width(JsonField.of(width)) + + /** + * Sets [Builder.width] to an arbitrary JSON value. + * + * You should usually call [Builder.width] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun width(width: JsonField) = apply { this.width = width } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FileUploadResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FileUploadResponse = + FileUploadResponse( + (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, + audioCodec, + bitRate, + customCoordinates, + customMetadata, + description, + duration, + embeddedMetadata, + extensionStatus, + fileId, + filePath, + fileType, + height, + isPrivateFile, + isPublished, + metadata, + name, + size, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + thumbnailUrl, + url, + versionInfo, + videoCodec, + width, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FileUploadResponse = apply { + if (validated) { + return@apply + } + + aiTags().ifPresent { it.forEach { it.validate() } } + audioCodec() + bitRate() + customCoordinates() + customMetadata().ifPresent { it.validate() } + description() + duration() + embeddedMetadata().ifPresent { it.validate() } + extensionStatus().ifPresent { it.validate() } + fileId() + filePath() + fileType() + height() + isPrivateFile() + isPublished() + metadata().ifPresent { it.validate() } + name() + size() + tags() + thumbnailUrl() + url() + versionInfo().ifPresent { it.validate() } + videoCodec() + width() + 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 = + (aiTags.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (audioCodec.asKnown().isPresent) 1 else 0) + + (if (bitRate.asKnown().isPresent) 1 else 0) + + (if (customCoordinates.asKnown().isPresent) 1 else 0) + + (customMetadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (duration.asKnown().isPresent) 1 else 0) + + (embeddedMetadata.asKnown().getOrNull()?.validity() ?: 0) + + (extensionStatus.asKnown().getOrNull()?.validity() ?: 0) + + (if (fileId.asKnown().isPresent) 1 else 0) + + (if (filePath.asKnown().isPresent) 1 else 0) + + (if (fileType.asKnown().isPresent) 1 else 0) + + (if (height.asKnown().isPresent) 1 else 0) + + (if (isPrivateFile.asKnown().isPresent) 1 else 0) + + (if (isPublished.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (size.asKnown().isPresent) 1 else 0) + + (tags.asKnown().getOrNull()?.size ?: 0) + + (if (thumbnailUrl.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (versionInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (videoCodec.asKnown().isPresent) 1 else 0) + + (if (width.asKnown().isPresent) 1 else 0) + + class AiTag + private constructor( + private val confidence: JsonField, + private val name: JsonField, + private val source: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("confidence") + @ExcludeMissing + confidence: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + ) : this(confidence, name, source, mutableMapOf()) + + /** + * Confidence score of the tag. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun confidence(): Optional = confidence.getOptional("confidence") + + /** + * Name of the tag. + * + * @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") + + /** + * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. + * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * Returns the raw JSON value of [confidence]. + * + * Unlike [confidence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("confidence") + @ExcludeMissing + fun _confidence(): JsonField = confidence + + /** + * 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 [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AiTag]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AiTag]. */ + class Builder internal constructor() { + + private var confidence: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var source: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(aiTag: AiTag) = apply { + confidence = aiTag.confidence + name = aiTag.name + source = aiTag.source + additionalProperties = aiTag.additionalProperties.toMutableMap() + } + + /** Confidence score of the tag. */ + fun confidence(confidence: Double) = confidence(JsonField.of(confidence)) + + /** + * Sets [Builder.confidence] to an arbitrary JSON value. + * + * You should usually call [Builder.confidence] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun confidence(confidence: JsonField) = apply { this.confidence = confidence } + + /** Name of the tag. */ + 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 } + + /** + * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. + * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` + * extensions. + */ + fun source(source: String) = source(JsonField.of(source)) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AiTag]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AiTag = + AiTag(confidence, name, source, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): AiTag = apply { + if (validated) { + return@apply + } + + confidence() + name() + source() + 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 (confidence.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (source.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiTag && + confidence == other.confidence && + name == other.name && + source == other.source && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(confidence, name, source, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AiTag{confidence=$confidence, name=$name, source=$source, additionalProperties=$additionalProperties}" + } + + /** + * A key-value data associated with the asset. Use `responseField` in API request to get + * `customMetadata` in the upload API response. Before setting any custom metadata on an asset, + * you have to create the field using custom metadata fields API. Send `customMetadata` in + * `responseFields` in API request to get the value of this field. + */ + class CustomMetadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CustomMetadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customMetadata: CustomMetadata) = apply { + additionalProperties = customMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CustomMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomMetadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" + } + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp + * data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata in + * the upload API response. + */ + class EmbeddedMetadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [EmbeddedMetadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EmbeddedMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(embeddedMetadata: EmbeddedMetadata) = apply { + additionalProperties = embeddedMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EmbeddedMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): EmbeddedMetadata = EmbeddedMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): EmbeddedMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EmbeddedMetadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "EmbeddedMetadata{additionalProperties=$additionalProperties}" + } + + /** + * Extension names with their processing status at the time of completion of the request. It + * could have one of the following status values: + * + * `success`: The extension has been successfully applied. `failed`: The extension has failed + * and will not be retried. `pending`: The extension will finish processing in some time. On + * completion, the final status (success / failed) will be sent to the `webhookUrl` provided. + * + * If no extension was requested, then this parameter is not returned. + */ + class ExtensionStatus + private constructor( + private val aiAutoDescription: JsonField, + private val awsAutoTagging: JsonField, + private val googleAutoTagging: JsonField, + private val removeBg: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("ai-auto-description") + @ExcludeMissing + aiAutoDescription: JsonField = JsonMissing.of(), + @JsonProperty("aws-auto-tagging") + @ExcludeMissing + awsAutoTagging: JsonField = JsonMissing.of(), + @JsonProperty("google-auto-tagging") + @ExcludeMissing + googleAutoTagging: JsonField = JsonMissing.of(), + @JsonProperty("remove-bg") + @ExcludeMissing + removeBg: JsonField = JsonMissing.of(), + ) : this(aiAutoDescription, awsAutoTagging, googleAutoTagging, removeBg, mutableMapOf()) + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun aiAutoDescription(): Optional = + aiAutoDescription.getOptional("ai-auto-description") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun awsAutoTagging(): Optional = + awsAutoTagging.getOptional("aws-auto-tagging") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun googleAutoTagging(): Optional = + googleAutoTagging.getOptional("google-auto-tagging") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun removeBg(): Optional = removeBg.getOptional("remove-bg") + + /** + * Returns the raw JSON value of [aiAutoDescription]. + * + * Unlike [aiAutoDescription], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ai-auto-description") + @ExcludeMissing + fun _aiAutoDescription(): JsonField = aiAutoDescription + + /** + * Returns the raw JSON value of [awsAutoTagging]. + * + * Unlike [awsAutoTagging], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("aws-auto-tagging") + @ExcludeMissing + fun _awsAutoTagging(): JsonField = awsAutoTagging + + /** + * Returns the raw JSON value of [googleAutoTagging]. + * + * Unlike [googleAutoTagging], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("google-auto-tagging") + @ExcludeMissing + fun _googleAutoTagging(): JsonField = googleAutoTagging + + /** + * Returns the raw JSON value of [removeBg]. + * + * Unlike [removeBg], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("remove-bg") @ExcludeMissing fun _removeBg(): JsonField = removeBg + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ExtensionStatus]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExtensionStatus]. */ + class Builder internal constructor() { + + private var aiAutoDescription: JsonField = JsonMissing.of() + private var awsAutoTagging: JsonField = JsonMissing.of() + private var googleAutoTagging: JsonField = JsonMissing.of() + private var removeBg: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extensionStatus: ExtensionStatus) = apply { + aiAutoDescription = extensionStatus.aiAutoDescription + awsAutoTagging = extensionStatus.awsAutoTagging + googleAutoTagging = extensionStatus.googleAutoTagging + removeBg = extensionStatus.removeBg + additionalProperties = extensionStatus.additionalProperties.toMutableMap() + } + + fun aiAutoDescription(aiAutoDescription: AiAutoDescription) = + aiAutoDescription(JsonField.of(aiAutoDescription)) + + /** + * Sets [Builder.aiAutoDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.aiAutoDescription] with a well-typed + * [AiAutoDescription] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun aiAutoDescription(aiAutoDescription: JsonField) = apply { + this.aiAutoDescription = aiAutoDescription + } + + fun awsAutoTagging(awsAutoTagging: AwsAutoTagging) = + awsAutoTagging(JsonField.of(awsAutoTagging)) + + /** + * Sets [Builder.awsAutoTagging] to an arbitrary JSON value. + * + * You should usually call [Builder.awsAutoTagging] with a well-typed [AwsAutoTagging] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun awsAutoTagging(awsAutoTagging: JsonField) = apply { + this.awsAutoTagging = awsAutoTagging + } + + fun googleAutoTagging(googleAutoTagging: GoogleAutoTagging) = + googleAutoTagging(JsonField.of(googleAutoTagging)) + + /** + * Sets [Builder.googleAutoTagging] to an arbitrary JSON value. + * + * You should usually call [Builder.googleAutoTagging] with a well-typed + * [GoogleAutoTagging] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun googleAutoTagging(googleAutoTagging: JsonField) = apply { + this.googleAutoTagging = googleAutoTagging + } + + fun removeBg(removeBg: RemoveBg) = removeBg(JsonField.of(removeBg)) + + /** + * Sets [Builder.removeBg] to an arbitrary JSON value. + * + * You should usually call [Builder.removeBg] with a well-typed [RemoveBg] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun removeBg(removeBg: JsonField) = apply { this.removeBg = removeBg } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ExtensionStatus]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExtensionStatus = + ExtensionStatus( + aiAutoDescription, + awsAutoTagging, + googleAutoTagging, + removeBg, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExtensionStatus = apply { + if (validated) { + return@apply + } + + aiAutoDescription().ifPresent { it.validate() } + awsAutoTagging().ifPresent { it.validate() } + googleAutoTagging().ifPresent { it.validate() } + removeBg().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (aiAutoDescription.asKnown().getOrNull()?.validity() ?: 0) + + (awsAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (googleAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (removeBg.asKnown().getOrNull()?.validity() ?: 0) + + class AiAutoDescription + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val PENDING = of("pending") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = AiAutoDescription(JsonField.of(value)) + } + + /** An enum containing [AiAutoDescription]'s known values. */ + enum class Known { + SUCCESS, + PENDING, + FAILED, + } + + /** + * An enum containing [AiAutoDescription]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AiAutoDescription] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + PENDING, + FAILED, + /** + * An enum member indicating that [AiAutoDescription] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + PENDING -> Value.PENDING + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + PENDING -> Known.PENDING + FAILED -> Known.FAILED + else -> throw ImageKitInvalidDataException("Unknown AiAutoDescription: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AiAutoDescription = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiAutoDescription && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class AwsAutoTagging + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val PENDING = of("pending") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = AwsAutoTagging(JsonField.of(value)) + } + + /** An enum containing [AwsAutoTagging]'s known values. */ + enum class Known { + SUCCESS, + PENDING, + FAILED, + } + + /** + * An enum containing [AwsAutoTagging]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AwsAutoTagging] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + PENDING, + FAILED, + /** + * An enum member indicating that [AwsAutoTagging] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + PENDING -> Value.PENDING + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + PENDING -> Known.PENDING + FAILED -> Known.FAILED + else -> throw ImageKitInvalidDataException("Unknown AwsAutoTagging: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AwsAutoTagging = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AwsAutoTagging && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class GoogleAutoTagging + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val PENDING = of("pending") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = GoogleAutoTagging(JsonField.of(value)) + } + + /** An enum containing [GoogleAutoTagging]'s known values. */ + enum class Known { + SUCCESS, + PENDING, + FAILED, + } + + /** + * An enum containing [GoogleAutoTagging]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [GoogleAutoTagging] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + PENDING, + FAILED, + /** + * An enum member indicating that [GoogleAutoTagging] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + PENDING -> Value.PENDING + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + PENDING -> Known.PENDING + FAILED -> Known.FAILED + else -> throw ImageKitInvalidDataException("Unknown GoogleAutoTagging: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): GoogleAutoTagging = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GoogleAutoTagging && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class RemoveBg @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val PENDING = of("pending") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = RemoveBg(JsonField.of(value)) + } + + /** An enum containing [RemoveBg]'s known values. */ + enum class Known { + SUCCESS, + PENDING, + FAILED, + } + + /** + * An enum containing [RemoveBg]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RemoveBg] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + PENDING, + FAILED, + /** + * An enum member indicating that [RemoveBg] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + PENDING -> Value.PENDING + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + PENDING -> Known.PENDING + FAILED -> Known.FAILED + else -> throw ImageKitInvalidDataException("Unknown RemoveBg: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): RemoveBg = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveBg && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExtensionStatus && + aiAutoDescription == other.aiAutoDescription && + awsAutoTagging == other.awsAutoTagging && + googleAutoTagging == other.googleAutoTagging && + removeBg == other.removeBg && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aiAutoDescription, + awsAutoTagging, + googleAutoTagging, + removeBg, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExtensionStatus{aiAutoDescription=$aiAutoDescription, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" + } + + /** An object containing the file or file version's `id` (versionId) and `name`. */ + class VersionInfo + private constructor( + private val id: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, name, mutableMapOf()) + + /** + * Unique identifier of the file version. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * Name of the file version. + * + * @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") + + /** + * 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 [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [VersionInfo]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VersionInfo]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(versionInfo: VersionInfo) = apply { + id = versionInfo.id + name = versionInfo.name + additionalProperties = versionInfo.additionalProperties.toMutableMap() + } + + /** Unique identifier of the file version. */ + 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 } + + /** Name of the file version. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [VersionInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VersionInfo = VersionInfo(id, name, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): VersionInfo = apply { + if (validated) { + return@apply + } + + id() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VersionInfo && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VersionInfo{id=$id, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FileUploadResponse && + aiTags == other.aiTags && + audioCodec == other.audioCodec && + bitRate == other.bitRate && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + description == other.description && + duration == other.duration && + embeddedMetadata == other.embeddedMetadata && + extensionStatus == other.extensionStatus && + fileId == other.fileId && + filePath == other.filePath && + fileType == other.fileType && + height == other.height && + isPrivateFile == other.isPrivateFile && + isPublished == other.isPublished && + metadata == other.metadata && + name == other.name && + size == other.size && + tags == other.tags && + thumbnailUrl == other.thumbnailUrl && + url == other.url && + versionInfo == other.versionInfo && + videoCodec == other.videoCodec && + width == other.width && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aiTags, + audioCodec, + bitRate, + customCoordinates, + customMetadata, + description, + duration, + embeddedMetadata, + extensionStatus, + fileId, + filePath, + fileType, + height, + isPrivateFile, + isPublished, + metadata, + name, + size, + tags, + thumbnailUrl, + url, + versionInfo, + videoCodec, + width, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FileUploadResponse{aiTags=$aiTags, audioCodec=$audioCodec, bitRate=$bitRate, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, duration=$duration, embeddedMetadata=$embeddedMetadata, extensionStatus=$extensionStatus, fileId=$fileId, filePath=$filePath, fileType=$fileType, height=$height, isPrivateFile=$isPrivateFile, isPublished=$isPublished, metadata=$metadata, name=$name, size=$size, tags=$tags, thumbnailUrl=$thumbnailUrl, url=$url, versionInfo=$versionInfo, videoCodec=$videoCodec, width=$width, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParams.kt new file mode 100644 index 00000000..1fe6f16e --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParams.kt @@ -0,0 +1,415 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.cache.invalidation + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects + +/** + * This API will purge CDN cache and ImageKit.io's internal cache for a file. Note: Purge cache is + * an asynchronous process and it may take some time to reflect the changes. + */ +class InvalidationCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The full URL of the file to be purged. + * + * @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 url(): String = body.url() + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _url(): JsonField = body._url() + + 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 [InvalidationCreateParams]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InvalidationCreateParams]. */ + 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(invalidationCreateParams: InvalidationCreateParams) = apply { + body = invalidationCreateParams.body.toBuilder() + additionalHeaders = invalidationCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = invalidationCreateParams.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: + * - [url] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The full URL of the file to be purged. */ + fun url(url: String) = apply { body.url(url) } + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField) = apply { body.url(url) } + + 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 [InvalidationCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InvalidationCreateParams = + InvalidationCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of() + ) : this(url, mutableMapOf()) + + /** + * The full URL of the file to be purged. + * + * @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 url(): String = url.getRequired("url") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @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 + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var url: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + url = body.url + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The full URL of the file to be purged. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = Body(checkRequired("url", url), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + url() + 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 (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + url == other.url && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(url, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Body{url=$url, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvalidationCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "InvalidationCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponse.kt new file mode 100644 index 00000000..51e74c57 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponse.kt @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.cache.invalidation + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +class InvalidationCreateResponse +private constructor( + private val requestId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("requestId") @ExcludeMissing requestId: JsonField = JsonMissing.of() + ) : this(requestId, mutableMapOf()) + + /** + * Unique identifier of the purge request. This can be used to check the status of the purge + * request. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun requestId(): Optional = requestId.getOptional("requestId") + + /** + * Returns the raw JSON value of [requestId]. + * + * Unlike [requestId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("requestId") @ExcludeMissing fun _requestId(): JsonField = requestId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InvalidationCreateResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InvalidationCreateResponse]. */ + class Builder internal constructor() { + + private var requestId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(invalidationCreateResponse: InvalidationCreateResponse) = apply { + requestId = invalidationCreateResponse.requestId + additionalProperties = invalidationCreateResponse.additionalProperties.toMutableMap() + } + + /** + * Unique identifier of the purge request. This can be used to check the status of the purge + * request. + */ + fun requestId(requestId: String) = requestId(JsonField.of(requestId)) + + /** + * Sets [Builder.requestId] to an arbitrary JSON value. + * + * You should usually call [Builder.requestId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun requestId(requestId: JsonField) = apply { this.requestId = requestId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InvalidationCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InvalidationCreateResponse = + InvalidationCreateResponse(requestId, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): InvalidationCreateResponse = apply { + if (validated) { + return@apply + } + + requestId() + 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 (requestId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvalidationCreateResponse && + requestId == other.requestId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(requestId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InvalidationCreateResponse{requestId=$requestId, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetParams.kt new file mode 100644 index 00000000..38accc77 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetParams.kt @@ -0,0 +1,193 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.cache.invalidation + +import com.imagekit.api.core.Params +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** This API returns the status of a purge cache request. */ +class InvalidationGetParams +private constructor( + private val requestId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun requestId(): Optional = Optional.ofNullable(requestId) + + /** 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(): InvalidationGetParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [InvalidationGetParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InvalidationGetParams]. */ + class Builder internal constructor() { + + private var requestId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(invalidationGetParams: InvalidationGetParams) = apply { + requestId = invalidationGetParams.requestId + additionalHeaders = invalidationGetParams.additionalHeaders.toBuilder() + additionalQueryParams = invalidationGetParams.additionalQueryParams.toBuilder() + } + + fun requestId(requestId: String?) = apply { this.requestId = requestId } + + /** Alias for calling [Builder.requestId] with `requestId.orElse(null)`. */ + fun requestId(requestId: Optional) = requestId(requestId.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 [InvalidationGetParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InvalidationGetParams = + InvalidationGetParams( + requestId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> requestId ?: "" + 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 InvalidationGetParams && + requestId == other.requestId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(requestId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "InvalidationGetParams{requestId=$requestId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponse.kt new file mode 100644 index 00000000..74befb58 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponse.kt @@ -0,0 +1,285 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.cache.invalidation + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class InvalidationGetResponse +private constructor( + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of() + ) : this(status, mutableMapOf()) + + /** + * Status of the purge request. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [InvalidationGetResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InvalidationGetResponse]. */ + class Builder internal constructor() { + + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(invalidationGetResponse: InvalidationGetResponse) = apply { + status = invalidationGetResponse.status + additionalProperties = invalidationGetResponse.additionalProperties.toMutableMap() + } + + /** Status of the purge request. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InvalidationGetResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InvalidationGetResponse = + InvalidationGetResponse(status, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): InvalidationGetResponse = apply { + if (validated) { + return@apply + } + + status().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (status.asKnown().getOrNull()?.validity() ?: 0) + + /** Status of the purge request. */ + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PENDING = of("Pending") + + @JvmField val COMPLETED = of("Completed") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + PENDING, + COMPLETED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PENDING, + COMPLETED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PENDING -> Value.PENDING + COMPLETED -> Value.COMPLETED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + COMPLETED -> Known.COMPLETED + else -> throw ImageKitInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvalidationGetResponse && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(status, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InvalidationGetResponse{status=$status, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt new file mode 100644 index 00000000..f69779fe --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt @@ -0,0 +1,1986 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.custommetadatafields + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.allMaxBy +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Object containing details of a custom metadata field. */ +class CustomMetadataField +private constructor( + private val id: JsonField, + private val label: JsonField, + private val name: JsonField, + private val schema: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @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()) + + /** + * Unique identifier for the custom metadata field. Use this to update the field. + * + * @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") + + /** + * Human readable name of the custom metadata field. This name is displayed as form field label + * to the users while setting field value on the asset in the media library UI. + * + * @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 label(): String = label.getRequired("label") + + /** + * API name of the custom metadata field. This becomes the key while setting `customMetadata` + * (key-value object) for an asset using upload or update API. + * + * @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") + + /** + * An object that describes the rules for the custom metadata field value. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun schema(): Schema = schema.getRequired("schema") + + /** + * 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 [label]. + * + * Unlike [label], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("label") @ExcludeMissing fun _label(): JsonField = label + + /** + * 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 [schema]. + * + * Unlike [schema], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("schema") @ExcludeMissing fun _schema(): JsonField = schema + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomMetadataField]. + * + * The following fields are required: + * ```java + * .id() + * .label() + * .name() + * .schema() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadataField]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var label: JsonField? = null + private var name: JsonField? = null + private var schema: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customMetadataField: CustomMetadataField) = apply { + id = customMetadataField.id + label = customMetadataField.label + name = customMetadataField.name + schema = customMetadataField.schema + additionalProperties = customMetadataField.additionalProperties.toMutableMap() + } + + /** Unique identifier for the custom metadata field. Use this to update the field. */ + 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 } + + /** + * Human readable name of the custom metadata field. This name is displayed as form field + * label to the users while setting field value on the asset in the media library UI. + */ + fun label(label: String) = label(JsonField.of(label)) + + /** + * Sets [Builder.label] to an arbitrary JSON value. + * + * You should usually call [Builder.label] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun label(label: JsonField) = apply { this.label = label } + + /** + * API name of the custom metadata field. This becomes the key while setting + * `customMetadata` (key-value object) for an asset using upload or update API. + */ + 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 } + + /** An object that describes the rules for the custom metadata field value. */ + fun schema(schema: Schema) = schema(JsonField.of(schema)) + + /** + * Sets [Builder.schema] to an arbitrary JSON value. + * + * You should usually call [Builder.schema] with a well-typed [Schema] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun schema(schema: JsonField) = apply { this.schema = schema } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomMetadataField]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .label() + * .name() + * .schema() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomMetadataField = + CustomMetadataField( + checkRequired("id", id), + checkRequired("label", label), + checkRequired("name", name), + checkRequired("schema", schema), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomMetadataField = apply { + if (validated) { + return@apply + } + + id() + label() + name() + schema().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (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) + + /** An object that describes the rules for the custom metadata field value. */ + class Schema + private constructor( + private val type: JsonField, + private val defaultValue: JsonField, + private val isValueRequired: JsonField, + private val maxLength: JsonField, + private val maxValue: JsonField, + private val minLength: JsonField, + private val minValue: JsonField, + private val selectOptions: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("defaultValue") + @ExcludeMissing + defaultValue: JsonField = JsonMissing.of(), + @JsonProperty("isValueRequired") + @ExcludeMissing + isValueRequired: JsonField = JsonMissing.of(), + @JsonProperty("maxLength") + @ExcludeMissing + maxLength: JsonField = JsonMissing.of(), + @JsonProperty("maxValue") + @ExcludeMissing + maxValue: JsonField = JsonMissing.of(), + @JsonProperty("minLength") + @ExcludeMissing + minLength: JsonField = JsonMissing.of(), + @JsonProperty("minValue") + @ExcludeMissing + minValue: JsonField = JsonMissing.of(), + @JsonProperty("selectOptions") + @ExcludeMissing + selectOptions: JsonField> = JsonMissing.of(), + ) : this( + type, + defaultValue, + isValueRequired, + maxLength, + maxValue, + minLength, + minValue, + selectOptions, + mutableMapOf(), + ) + + /** + * Type of the custom metadata field. + * + * @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 type(): Type = type.getRequired("type") + + /** + * The default value for this custom metadata field. Date type of default value depends on + * the field type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultValue(): Optional = defaultValue.getOptional("defaultValue") + + /** + * Specifies if the this custom metadata field is required or not. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isValueRequired(): Optional = isValueRequired.getOptional("isValueRequired") + + /** + * Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maxLength(): Optional = maxLength.getOptional("maxLength") + + /** + * Maximum value of the field. Only set if field type is `Date` or `Number`. For `Date` type + * field, the value will be in ISO8601 string format. For `Number` type field, it will be a + * numeric value. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maxValue(): Optional = maxValue.getOptional("maxValue") + + /** + * Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun minLength(): Optional = minLength.getOptional("minLength") + + /** + * Minimum value of the field. Only set if field type is `Date` or `Number`. For `Date` type + * field, the value will be in ISO8601 string format. For `Number` type field, it will be a + * numeric value. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun minValue(): Optional = minValue.getOptional("minValue") + + /** + * An array of allowed values when field type is `SingleSelect` or `MultiSelect`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun selectOptions(): Optional> = + selectOptions.getOptional("selectOptions") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [defaultValue]. + * + * Unlike [defaultValue], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("defaultValue") + @ExcludeMissing + fun _defaultValue(): JsonField = defaultValue + + /** + * Returns the raw JSON value of [isValueRequired]. + * + * Unlike [isValueRequired], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("isValueRequired") + @ExcludeMissing + fun _isValueRequired(): JsonField = isValueRequired + + /** + * Returns the raw JSON value of [maxLength]. + * + * Unlike [maxLength], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("maxLength") @ExcludeMissing fun _maxLength(): JsonField = maxLength + + /** + * Returns the raw JSON value of [maxValue]. + * + * Unlike [maxValue], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("maxValue") @ExcludeMissing fun _maxValue(): JsonField = maxValue + + /** + * Returns the raw JSON value of [minLength]. + * + * Unlike [minLength], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("minLength") @ExcludeMissing fun _minLength(): JsonField = minLength + + /** + * Returns the raw JSON value of [minValue]. + * + * Unlike [minValue], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("minValue") @ExcludeMissing fun _minValue(): JsonField = minValue + + /** + * Returns the raw JSON value of [selectOptions]. + * + * Unlike [selectOptions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("selectOptions") + @ExcludeMissing + fun _selectOptions(): JsonField> = selectOptions + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Schema]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Schema]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var defaultValue: JsonField = JsonMissing.of() + private var isValueRequired: JsonField = JsonMissing.of() + private var maxLength: JsonField = JsonMissing.of() + private var maxValue: JsonField = JsonMissing.of() + private var minLength: JsonField = JsonMissing.of() + private var minValue: JsonField = JsonMissing.of() + private var selectOptions: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(schema: Schema) = apply { + type = schema.type + defaultValue = schema.defaultValue + isValueRequired = schema.isValueRequired + maxLength = schema.maxLength + maxValue = schema.maxValue + minLength = schema.minLength + minValue = schema.minValue + selectOptions = schema.selectOptions.map { it.toMutableList() } + additionalProperties = schema.additionalProperties.toMutableMap() + } + + /** Type of the custom metadata field. */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** + * The default value for this custom metadata field. Date type of default value depends + * on the field type. + */ + fun defaultValue(defaultValue: DefaultValue) = defaultValue(JsonField.of(defaultValue)) + + /** + * Sets [Builder.defaultValue] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultValue] with a well-typed [DefaultValue] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultValue(defaultValue: JsonField) = apply { + this.defaultValue = defaultValue + } + + /** Alias for calling [defaultValue] with `DefaultValue.ofString(string)`. */ + fun defaultValue(string: String) = defaultValue(DefaultValue.ofString(string)) + + /** Alias for calling [defaultValue] with `DefaultValue.ofNumber(number)`. */ + fun defaultValue(number: Double) = defaultValue(DefaultValue.ofNumber(number)) + + /** Alias for calling [defaultValue] with `DefaultValue.ofBool(bool)`. */ + fun defaultValue(bool: Boolean) = defaultValue(DefaultValue.ofBool(bool)) + + /** Alias for calling [defaultValue] with `DefaultValue.ofMixed(mixed)`. */ + fun defaultValueOfMixed(mixed: List) = + defaultValue(DefaultValue.ofMixed(mixed)) + + /** Specifies if the this custom metadata field is required or not. */ + fun isValueRequired(isValueRequired: Boolean) = + isValueRequired(JsonField.of(isValueRequired)) + + /** + * Sets [Builder.isValueRequired] to an arbitrary JSON value. + * + * You should usually call [Builder.isValueRequired] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isValueRequired(isValueRequired: JsonField) = apply { + this.isValueRequired = isValueRequired + } + + /** Maximum length of string. Only set if `type` is set to `Text` or `Textarea`. */ + fun maxLength(maxLength: Double) = maxLength(JsonField.of(maxLength)) + + /** + * Sets [Builder.maxLength] to an arbitrary JSON value. + * + * You should usually call [Builder.maxLength] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxLength(maxLength: JsonField) = apply { this.maxLength = maxLength } + + /** + * Maximum value of the field. Only set if field type is `Date` or `Number`. For `Date` + * type field, the value will be in ISO8601 string format. For `Number` type field, it + * will be a numeric value. + */ + fun maxValue(maxValue: MaxValue) = maxValue(JsonField.of(maxValue)) + + /** + * Sets [Builder.maxValue] to an arbitrary JSON value. + * + * You should usually call [Builder.maxValue] with a well-typed [MaxValue] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxValue(maxValue: JsonField) = apply { this.maxValue = maxValue } + + /** Alias for calling [maxValue] with `MaxValue.ofString(string)`. */ + fun maxValue(string: String) = maxValue(MaxValue.ofString(string)) + + /** Alias for calling [maxValue] with `MaxValue.ofNumber(number)`. */ + fun maxValue(number: Double) = maxValue(MaxValue.ofNumber(number)) + + /** Minimum length of string. Only set if `type` is set to `Text` or `Textarea`. */ + fun minLength(minLength: Double) = minLength(JsonField.of(minLength)) + + /** + * Sets [Builder.minLength] to an arbitrary JSON value. + * + * You should usually call [Builder.minLength] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minLength(minLength: JsonField) = apply { this.minLength = minLength } + + /** + * Minimum value of the field. Only set if field type is `Date` or `Number`. For `Date` + * type field, the value will be in ISO8601 string format. For `Number` type field, it + * will be a numeric value. + */ + fun minValue(minValue: MinValue) = minValue(JsonField.of(minValue)) + + /** + * Sets [Builder.minValue] to an arbitrary JSON value. + * + * You should usually call [Builder.minValue] with a well-typed [MinValue] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minValue(minValue: JsonField) = apply { this.minValue = minValue } + + /** Alias for calling [minValue] with `MinValue.ofString(string)`. */ + fun minValue(string: String) = minValue(MinValue.ofString(string)) + + /** Alias for calling [minValue] with `MinValue.ofNumber(number)`. */ + fun minValue(number: Double) = minValue(MinValue.ofNumber(number)) + + /** An array of allowed values when field type is `SingleSelect` or `MultiSelect`. */ + fun selectOptions(selectOptions: List) = + selectOptions(JsonField.of(selectOptions)) + + /** + * Sets [Builder.selectOptions] to an arbitrary JSON value. + * + * You should usually call [Builder.selectOptions] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun selectOptions(selectOptions: JsonField>) = apply { + this.selectOptions = selectOptions.map { it.toMutableList() } + } + + /** + * Adds a single [SelectOption] to [selectOptions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSelectOption(selectOption: SelectOption) = apply { + selectOptions = + (selectOptions ?: JsonField.of(mutableListOf())).also { + checkKnown("selectOptions", it).add(selectOption) + } + } + + /** Alias for calling [addSelectOption] with `SelectOption.ofString(string)`. */ + fun addSelectOption(string: String) = addSelectOption(SelectOption.ofString(string)) + + /** Alias for calling [addSelectOption] with `SelectOption.ofNumber(number)`. */ + fun addSelectOption(number: Double) = addSelectOption(SelectOption.ofNumber(number)) + + /** Alias for calling [addSelectOption] with `SelectOption.ofBool(bool)`. */ + fun addSelectOption(bool: Boolean) = addSelectOption(SelectOption.ofBool(bool)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Schema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Schema = + Schema( + checkRequired("type", type), + defaultValue, + isValueRequired, + maxLength, + maxValue, + minLength, + minValue, + (selectOptions ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Schema = apply { + if (validated) { + return@apply + } + + type().validate() + defaultValue().ifPresent { it.validate() } + isValueRequired() + maxLength() + maxValue().ifPresent { it.validate() } + minLength() + minValue().ifPresent { it.validate() } + selectOptions().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (type.asKnown().getOrNull()?.validity() ?: 0) + + (defaultValue.asKnown().getOrNull()?.validity() ?: 0) + + (if (isValueRequired.asKnown().isPresent) 1 else 0) + + (if (maxLength.asKnown().isPresent) 1 else 0) + + (maxValue.asKnown().getOrNull()?.validity() ?: 0) + + (if (minLength.asKnown().isPresent) 1 else 0) + + (minValue.asKnown().getOrNull()?.validity() ?: 0) + + (selectOptions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Type of the custom metadata field. */ + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TEXT = of("Text") + + @JvmField val TEXTAREA = of("Textarea") + + @JvmField val NUMBER = of("Number") + + @JvmField val DATE = of("Date") + + @JvmField val BOOLEAN = of("Boolean") + + @JvmField val SINGLE_SELECT = of("SingleSelect") + + @JvmField val MULTI_SELECT = of("MultiSelect") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TEXT, + TEXTAREA, + NUMBER, + DATE, + BOOLEAN, + SINGLE_SELECT, + MULTI_SELECT, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TEXT, + TEXTAREA, + NUMBER, + DATE, + BOOLEAN, + SINGLE_SELECT, + MULTI_SELECT, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TEXT -> Value.TEXT + TEXTAREA -> Value.TEXTAREA + NUMBER -> Value.NUMBER + DATE -> Value.DATE + BOOLEAN -> Value.BOOLEAN + SINGLE_SELECT -> Value.SINGLE_SELECT + MULTI_SELECT -> Value.MULTI_SELECT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TEXT -> Known.TEXT + TEXTAREA -> Known.TEXTAREA + NUMBER -> Known.NUMBER + DATE -> Known.DATE + BOOLEAN -> Known.BOOLEAN + SINGLE_SELECT -> Known.SINGLE_SELECT + MULTI_SELECT -> Known.MULTI_SELECT + else -> throw ImageKitInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * The default value for this custom metadata field. Date type of default value depends on + * the field type. + */ + @JsonDeserialize(using = DefaultValue.Deserializer::class) + @JsonSerialize(using = DefaultValue.Serializer::class) + class DefaultValue + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val mixed: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + /** + * Default value should be of type array when custom metadata field type is set to + * `MultiSelect`. + */ + fun mixed(): Optional> = Optional.ofNullable(mixed) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isMixed(): Boolean = mixed != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + /** + * Default value should be of type array when custom metadata field type is set to + * `MultiSelect`. + */ + fun asMixed(): List = mixed.getOrThrow("mixed") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + mixed != null -> visitor.visitMixed(mixed) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): DefaultValue = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitMixed(mixed: List) { + mixed.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitMixed(mixed: List) = + mixed.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DefaultValue && + string == other.string && + number == other.number && + bool == other.bool && + mixed == other.mixed + } + + override fun hashCode(): Int = Objects.hash(string, number, bool, mixed) + + override fun toString(): String = + when { + string != null -> "DefaultValue{string=$string}" + number != null -> "DefaultValue{number=$number}" + bool != null -> "DefaultValue{bool=$bool}" + mixed != null -> "DefaultValue{mixed=$mixed}" + _json != null -> "DefaultValue{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DefaultValue") + } + + companion object { + + @JvmStatic fun ofString(string: String) = DefaultValue(string = string) + + @JvmStatic fun ofNumber(number: Double) = DefaultValue(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = DefaultValue(bool = bool) + + /** + * Default value should be of type array when custom metadata field type is set to + * `MultiSelect`. + */ + @JvmStatic + fun ofMixed(mixed: List) = + DefaultValue(mixed = mixed.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [DefaultValue] to a value of + * type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Default value should be of type array when custom metadata field type is set to + * `MultiSelect`. + */ + fun visitMixed(mixed: List): T + + /** + * Maps an unknown variant of [DefaultValue] to a value of type [T]. + * + * An instance of [DefaultValue] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown DefaultValue: $json") + } + } + + internal class Deserializer : BaseDeserializer(DefaultValue::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): DefaultValue { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + DefaultValue(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + DefaultValue(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + DefaultValue(bool = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef>(), + ) + ?.let { DefaultValue(mixed = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> DefaultValue(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(DefaultValue::class) { + + override fun serialize( + value: DefaultValue, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.mixed != null -> generator.writeObject(value.mixed) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DefaultValue") + } + } + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent0.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent0.Serializer::class) + class UnnamedSchemaWithArrayParent0 + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent0 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent0 && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> "UnnamedSchemaWithArrayParent0{string=$string}" + number != null -> "UnnamedSchemaWithArrayParent0{number=$number}" + bool != null -> "UnnamedSchemaWithArrayParent0{bool=$bool}" + _json != null -> "UnnamedSchemaWithArrayParent0{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent0") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = UnnamedSchemaWithArrayParent0(string = string) + + @JvmStatic + fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent0(number = number) + + @JvmStatic + fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent0(bool = bool) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent0] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent0] to a value of type + * [T]. + * + * An instance of [UnnamedSchemaWithArrayParent0] can contain an unknown variant + * if it was deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent0: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent0::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent0 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent0(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent0(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent0(bool = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> UnnamedSchemaWithArrayParent0(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent0::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent0, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent0") + } + } + } + } + } + + /** + * Maximum value of the field. Only set if field type is `Date` or `Number`. For `Date` type + * field, the value will be in ISO8601 string format. For `Number` type field, it will be a + * numeric value. + */ + @JsonDeserialize(using = MaxValue.Deserializer::class) + @JsonSerialize(using = MaxValue.Serializer::class) + class MaxValue + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): MaxValue = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxValue && string == other.string && number == other.number + } + + override fun hashCode(): Int = Objects.hash(string, number) + + override fun toString(): String = + when { + string != null -> "MaxValue{string=$string}" + number != null -> "MaxValue{number=$number}" + _json != null -> "MaxValue{_unknown=$_json}" + else -> throw IllegalStateException("Invalid MaxValue") + } + + companion object { + + @JvmStatic fun ofString(string: String) = MaxValue(string = string) + + @JvmStatic fun ofNumber(number: Double) = MaxValue(number = number) + } + + /** + * An interface that defines how to map each variant of [MaxValue] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + /** + * Maps an unknown variant of [MaxValue] to a value of type [T]. + * + * An instance of [MaxValue] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown MaxValue: $json") + } + } + + internal class Deserializer : BaseDeserializer(MaxValue::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): MaxValue { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + MaxValue(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + MaxValue(number = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> MaxValue(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(MaxValue::class) { + + override fun serialize( + value: MaxValue, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid MaxValue") + } + } + } + } + + /** + * Minimum value of the field. Only set if field type is `Date` or `Number`. For `Date` type + * field, the value will be in ISO8601 string format. For `Number` type field, it will be a + * numeric value. + */ + @JsonDeserialize(using = MinValue.Deserializer::class) + @JsonSerialize(using = MinValue.Serializer::class) + class MinValue + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): MinValue = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinValue && string == other.string && number == other.number + } + + override fun hashCode(): Int = Objects.hash(string, number) + + override fun toString(): String = + when { + string != null -> "MinValue{string=$string}" + number != null -> "MinValue{number=$number}" + _json != null -> "MinValue{_unknown=$_json}" + else -> throw IllegalStateException("Invalid MinValue") + } + + companion object { + + @JvmStatic fun ofString(string: String) = MinValue(string = string) + + @JvmStatic fun ofNumber(number: Double) = MinValue(number = number) + } + + /** + * An interface that defines how to map each variant of [MinValue] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + /** + * Maps an unknown variant of [MinValue] to a value of type [T]. + * + * An instance of [MinValue] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown MinValue: $json") + } + } + + internal class Deserializer : BaseDeserializer(MinValue::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): MinValue { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + MinValue(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + MinValue(number = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> MinValue(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(MinValue::class) { + + override fun serialize( + value: MinValue, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid MinValue") + } + } + } + } + + @JsonDeserialize(using = SelectOption.Deserializer::class) + @JsonSerialize(using = SelectOption.Serializer::class) + class SelectOption + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): SelectOption = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SelectOption && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> "SelectOption{string=$string}" + number != null -> "SelectOption{number=$number}" + bool != null -> "SelectOption{bool=$bool}" + _json != null -> "SelectOption{_unknown=$_json}" + else -> throw IllegalStateException("Invalid SelectOption") + } + + companion object { + + @JvmStatic fun ofString(string: String) = SelectOption(string = string) + + @JvmStatic fun ofNumber(number: Double) = SelectOption(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = SelectOption(bool = bool) + } + + /** + * An interface that defines how to map each variant of [SelectOption] to a value of + * type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [SelectOption] to a value of type [T]. + * + * An instance of [SelectOption] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown SelectOption: $json") + } + } + + internal class Deserializer : BaseDeserializer(SelectOption::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): SelectOption { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + SelectOption(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + SelectOption(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + SelectOption(bool = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> SelectOption(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(SelectOption::class) { + + override fun serialize( + value: SelectOption, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid SelectOption") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Schema && + type == other.type && + defaultValue == other.defaultValue && + isValueRequired == other.isValueRequired && + maxLength == other.maxLength && + maxValue == other.maxValue && + minLength == other.minLength && + minValue == other.minValue && + selectOptions == other.selectOptions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + type, + defaultValue, + isValueRequired, + maxLength, + maxValue, + minLength, + minValue, + selectOptions, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Schema{type=$type, defaultValue=$defaultValue, isValueRequired=$isValueRequired, maxLength=$maxLength, maxValue=$maxValue, minLength=$minLength, minValue=$minValue, selectOptions=$selectOptions, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomMetadataField && + id == other.id && + label == other.label && + name == other.name && + schema == other.schema && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, label, name, schema, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomMetadataField{id=$id, label=$label, name=$name, schema=$schema, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt new file mode 100644 index 00000000..fa4d61fe --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt @@ -0,0 +1,2288 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.custommetadatafields + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.allMaxBy +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * This API creates a new custom metadata field. Once a custom metadata field is created either + * through this API or using the dashboard UI, its value can be set on the assets. The value of a + * field for an asset can be set using the media library UI or programmatically through upload or + * update assets API. + */ +class CustomMetadataFieldCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * 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 + * setting field value on an asset in the media library UI. + * + * @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 label(): String = body.label() + + /** + * API name of the custom metadata field. This should be unique across all (including deleted) + * custom metadata fields. + * + * @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() + + /** + * @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 schema(): Schema = body.schema() + + /** + * Returns the raw JSON value of [label]. + * + * Unlike [label], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _label(): JsonField = body._label() + + /** + * 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 [schema]. + * + * Unlike [schema], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _schema(): JsonField = body._schema() + + 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 + * [CustomMetadataFieldCreateParams]. + * + * The following fields are required: + * ```java + * .label() + * .name() + * .schema() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadataFieldCreateParams]. */ + 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(customMetadataFieldCreateParams: CustomMetadataFieldCreateParams) = + apply { + body = customMetadataFieldCreateParams.body.toBuilder() + additionalHeaders = customMetadataFieldCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = + customMetadataFieldCreateParams.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: + * - [label] + * - [name] + * - [schema] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * 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 setting field value on an asset in the media library UI. + */ + fun label(label: String) = apply { body.label(label) } + + /** + * Sets [Builder.label] to an arbitrary JSON value. + * + * You should usually call [Builder.label] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun label(label: JsonField) = apply { body.label(label) } + + /** + * API name of the custom metadata field. This should be unique across all (including + * deleted) custom metadata fields. + */ + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { body.name(name) } + + fun schema(schema: Schema) = apply { body.schema(schema) } + + /** + * Sets [Builder.schema] to an arbitrary JSON value. + * + * You should usually call [Builder.schema] with a well-typed [Schema] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun schema(schema: JsonField) = apply { body.schema(schema) } + + 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 [CustomMetadataFieldCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .label() + * .name() + * .schema() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomMetadataFieldCreateParams = + CustomMetadataFieldCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val label: JsonField, + private val name: JsonField, + private val schema: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + 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()) + + /** + * 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 setting field value on an asset in the media library UI. + * + * @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 label(): String = label.getRequired("label") + + /** + * API name of the custom metadata field. This should be unique across all (including + * deleted) custom metadata fields. + * + * @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") + + /** + * @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 schema(): Schema = schema.getRequired("schema") + + /** + * Returns the raw JSON value of [label]. + * + * Unlike [label], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("label") @ExcludeMissing fun _label(): JsonField = label + + /** + * 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 [schema]. + * + * Unlike [schema], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("schema") @ExcludeMissing fun _schema(): JsonField = schema + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @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 + * .label() + * .name() + * .schema() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var label: JsonField? = null + private var name: JsonField? = null + private var schema: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + label = body.label + name = body.name + schema = body.schema + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * 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 setting field value on an asset in the media library UI. + */ + fun label(label: String) = label(JsonField.of(label)) + + /** + * Sets [Builder.label] to an arbitrary JSON value. + * + * You should usually call [Builder.label] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun label(label: JsonField) = apply { this.label = label } + + /** + * API name of the custom metadata field. This should be unique across all (including + * deleted) custom metadata fields. + */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun schema(schema: Schema) = schema(JsonField.of(schema)) + + /** + * Sets [Builder.schema] to an arbitrary JSON value. + * + * You should usually call [Builder.schema] with a well-typed [Schema] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun schema(schema: JsonField) = apply { this.schema = schema } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .label() + * .name() + * .schema() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("label", label), + checkRequired("name", name), + checkRequired("schema", schema), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + label() + name() + schema().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (label.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (schema.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + label == other.label && + name == other.name && + schema == other.schema && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(label, name, schema, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{label=$label, name=$name, schema=$schema, additionalProperties=$additionalProperties}" + } + + class Schema + private constructor( + private val type: JsonField, + private val defaultValue: JsonField, + private val isValueRequired: JsonField, + private val maxLength: JsonField, + private val maxValue: JsonField, + private val minLength: JsonField, + private val minValue: JsonField, + private val selectOptions: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("defaultValue") + @ExcludeMissing + defaultValue: JsonField = JsonMissing.of(), + @JsonProperty("isValueRequired") + @ExcludeMissing + isValueRequired: JsonField = JsonMissing.of(), + @JsonProperty("maxLength") + @ExcludeMissing + maxLength: JsonField = JsonMissing.of(), + @JsonProperty("maxValue") + @ExcludeMissing + maxValue: JsonField = JsonMissing.of(), + @JsonProperty("minLength") + @ExcludeMissing + minLength: JsonField = JsonMissing.of(), + @JsonProperty("minValue") + @ExcludeMissing + minValue: JsonField = JsonMissing.of(), + @JsonProperty("selectOptions") + @ExcludeMissing + selectOptions: JsonField> = JsonMissing.of(), + ) : this( + type, + defaultValue, + isValueRequired, + maxLength, + maxValue, + minLength, + minValue, + selectOptions, + mutableMapOf(), + ) + + /** + * Type of the custom metadata field. + * + * @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 type(): Type = type.getRequired("type") + + /** + * The default value for this custom metadata field. This property is only required if + * `isValueRequired` property is set to `true`. The value should match the `type` of custom + * metadata field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultValue(): Optional = defaultValue.getOptional("defaultValue") + + /** + * Sets this custom metadata field as required. Setting custom metadata fields on an asset + * will throw error if the value for all required fields are not present in upload or update + * asset API request body. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isValueRequired(): Optional = isValueRequired.getOptional("isValueRequired") + + /** + * Maximum length of string. Only set this property if `type` is set to `Text` or + * `Textarea`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maxLength(): Optional = maxLength.getOptional("maxLength") + + /** + * Maximum value of the field. Only set this property if field type is `Date` or `Number`. + * For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type + * field, set the minimum numeric value. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maxValue(): Optional = maxValue.getOptional("maxValue") + + /** + * Minimum length of string. Only set this property if `type` is set to `Text` or + * `Textarea`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun minLength(): Optional = minLength.getOptional("minLength") + + /** + * Minimum value of the field. Only set this property if field type is `Date` or `Number`. + * For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type + * field, set the minimum numeric value. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun minValue(): Optional = minValue.getOptional("minValue") + + /** + * An array of allowed values. This property is only required if `type` property is set to + * `SingleSelect` or `MultiSelect`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun selectOptions(): Optional> = + selectOptions.getOptional("selectOptions") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [defaultValue]. + * + * Unlike [defaultValue], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("defaultValue") + @ExcludeMissing + fun _defaultValue(): JsonField = defaultValue + + /** + * Returns the raw JSON value of [isValueRequired]. + * + * Unlike [isValueRequired], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("isValueRequired") + @ExcludeMissing + fun _isValueRequired(): JsonField = isValueRequired + + /** + * Returns the raw JSON value of [maxLength]. + * + * Unlike [maxLength], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("maxLength") @ExcludeMissing fun _maxLength(): JsonField = maxLength + + /** + * Returns the raw JSON value of [maxValue]. + * + * Unlike [maxValue], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("maxValue") @ExcludeMissing fun _maxValue(): JsonField = maxValue + + /** + * Returns the raw JSON value of [minLength]. + * + * Unlike [minLength], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("minLength") @ExcludeMissing fun _minLength(): JsonField = minLength + + /** + * Returns the raw JSON value of [minValue]. + * + * Unlike [minValue], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("minValue") @ExcludeMissing fun _minValue(): JsonField = minValue + + /** + * Returns the raw JSON value of [selectOptions]. + * + * Unlike [selectOptions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("selectOptions") + @ExcludeMissing + fun _selectOptions(): JsonField> = selectOptions + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Schema]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Schema]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var defaultValue: JsonField = JsonMissing.of() + private var isValueRequired: JsonField = JsonMissing.of() + private var maxLength: JsonField = JsonMissing.of() + private var maxValue: JsonField = JsonMissing.of() + private var minLength: JsonField = JsonMissing.of() + private var minValue: JsonField = JsonMissing.of() + private var selectOptions: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(schema: Schema) = apply { + type = schema.type + defaultValue = schema.defaultValue + isValueRequired = schema.isValueRequired + maxLength = schema.maxLength + maxValue = schema.maxValue + minLength = schema.minLength + minValue = schema.minValue + selectOptions = schema.selectOptions.map { it.toMutableList() } + additionalProperties = schema.additionalProperties.toMutableMap() + } + + /** Type of the custom metadata field. */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** + * The default value for this custom metadata field. This property is only required if + * `isValueRequired` property is set to `true`. The value should match the `type` of + * custom metadata field. + */ + fun defaultValue(defaultValue: DefaultValue) = defaultValue(JsonField.of(defaultValue)) + + /** + * Sets [Builder.defaultValue] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultValue] with a well-typed [DefaultValue] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultValue(defaultValue: JsonField) = apply { + this.defaultValue = defaultValue + } + + /** Alias for calling [defaultValue] with `DefaultValue.ofString(string)`. */ + fun defaultValue(string: String) = defaultValue(DefaultValue.ofString(string)) + + /** Alias for calling [defaultValue] with `DefaultValue.ofNumber(number)`. */ + fun defaultValue(number: Double) = defaultValue(DefaultValue.ofNumber(number)) + + /** Alias for calling [defaultValue] with `DefaultValue.ofBool(bool)`. */ + fun defaultValue(bool: Boolean) = defaultValue(DefaultValue.ofBool(bool)) + + /** Alias for calling [defaultValue] with `DefaultValue.ofMixed(mixed)`. */ + fun defaultValueOfMixed(mixed: List) = + defaultValue(DefaultValue.ofMixed(mixed)) + + /** + * Sets this custom metadata field as required. Setting custom metadata fields on an + * asset will throw error if the value for all required fields are not present in upload + * or update asset API request body. + */ + fun isValueRequired(isValueRequired: Boolean) = + isValueRequired(JsonField.of(isValueRequired)) + + /** + * Sets [Builder.isValueRequired] to an arbitrary JSON value. + * + * You should usually call [Builder.isValueRequired] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isValueRequired(isValueRequired: JsonField) = apply { + this.isValueRequired = isValueRequired + } + + /** + * Maximum length of string. Only set this property if `type` is set to `Text` or + * `Textarea`. + */ + fun maxLength(maxLength: Double) = maxLength(JsonField.of(maxLength)) + + /** + * Sets [Builder.maxLength] to an arbitrary JSON value. + * + * You should usually call [Builder.maxLength] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxLength(maxLength: JsonField) = apply { this.maxLength = maxLength } + + /** + * Maximum value of the field. Only set this property if field type is `Date` or + * `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For + * `Number` type field, set the minimum numeric value. + */ + fun maxValue(maxValue: MaxValue) = maxValue(JsonField.of(maxValue)) + + /** + * Sets [Builder.maxValue] to an arbitrary JSON value. + * + * You should usually call [Builder.maxValue] with a well-typed [MaxValue] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxValue(maxValue: JsonField) = apply { this.maxValue = maxValue } + + /** Alias for calling [maxValue] with `MaxValue.ofString(string)`. */ + fun maxValue(string: String) = maxValue(MaxValue.ofString(string)) + + /** Alias for calling [maxValue] with `MaxValue.ofNumber(number)`. */ + fun maxValue(number: Double) = maxValue(MaxValue.ofNumber(number)) + + /** + * Minimum length of string. Only set this property if `type` is set to `Text` or + * `Textarea`. + */ + fun minLength(minLength: Double) = minLength(JsonField.of(minLength)) + + /** + * Sets [Builder.minLength] to an arbitrary JSON value. + * + * You should usually call [Builder.minLength] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minLength(minLength: JsonField) = apply { this.minLength = minLength } + + /** + * Minimum value of the field. Only set this property if field type is `Date` or + * `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For + * `Number` type field, set the minimum numeric value. + */ + fun minValue(minValue: MinValue) = minValue(JsonField.of(minValue)) + + /** + * Sets [Builder.minValue] to an arbitrary JSON value. + * + * You should usually call [Builder.minValue] with a well-typed [MinValue] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minValue(minValue: JsonField) = apply { this.minValue = minValue } + + /** Alias for calling [minValue] with `MinValue.ofString(string)`. */ + fun minValue(string: String) = minValue(MinValue.ofString(string)) + + /** Alias for calling [minValue] with `MinValue.ofNumber(number)`. */ + fun minValue(number: Double) = minValue(MinValue.ofNumber(number)) + + /** + * An array of allowed values. This property is only required if `type` property is set + * to `SingleSelect` or `MultiSelect`. + */ + fun selectOptions(selectOptions: List) = + selectOptions(JsonField.of(selectOptions)) + + /** + * Sets [Builder.selectOptions] to an arbitrary JSON value. + * + * You should usually call [Builder.selectOptions] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun selectOptions(selectOptions: JsonField>) = apply { + this.selectOptions = selectOptions.map { it.toMutableList() } + } + + /** + * Adds a single [SelectOption] to [selectOptions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSelectOption(selectOption: SelectOption) = apply { + selectOptions = + (selectOptions ?: JsonField.of(mutableListOf())).also { + checkKnown("selectOptions", it).add(selectOption) + } + } + + /** Alias for calling [addSelectOption] with `SelectOption.ofString(string)`. */ + fun addSelectOption(string: String) = addSelectOption(SelectOption.ofString(string)) + + /** Alias for calling [addSelectOption] with `SelectOption.ofNumber(number)`. */ + fun addSelectOption(number: Double) = addSelectOption(SelectOption.ofNumber(number)) + + /** Alias for calling [addSelectOption] with `SelectOption.ofBool(bool)`. */ + fun addSelectOption(bool: Boolean) = addSelectOption(SelectOption.ofBool(bool)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Schema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Schema = + Schema( + checkRequired("type", type), + defaultValue, + isValueRequired, + maxLength, + maxValue, + minLength, + minValue, + (selectOptions ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Schema = apply { + if (validated) { + return@apply + } + + type().validate() + defaultValue().ifPresent { it.validate() } + isValueRequired() + maxLength() + maxValue().ifPresent { it.validate() } + minLength() + minValue().ifPresent { it.validate() } + selectOptions().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (type.asKnown().getOrNull()?.validity() ?: 0) + + (defaultValue.asKnown().getOrNull()?.validity() ?: 0) + + (if (isValueRequired.asKnown().isPresent) 1 else 0) + + (if (maxLength.asKnown().isPresent) 1 else 0) + + (maxValue.asKnown().getOrNull()?.validity() ?: 0) + + (if (minLength.asKnown().isPresent) 1 else 0) + + (minValue.asKnown().getOrNull()?.validity() ?: 0) + + (selectOptions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Type of the custom metadata field. */ + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TEXT = of("Text") + + @JvmField val TEXTAREA = of("Textarea") + + @JvmField val NUMBER = of("Number") + + @JvmField val DATE = of("Date") + + @JvmField val BOOLEAN = of("Boolean") + + @JvmField val SINGLE_SELECT = of("SingleSelect") + + @JvmField val MULTI_SELECT = of("MultiSelect") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TEXT, + TEXTAREA, + NUMBER, + DATE, + BOOLEAN, + SINGLE_SELECT, + MULTI_SELECT, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TEXT, + TEXTAREA, + NUMBER, + DATE, + BOOLEAN, + SINGLE_SELECT, + MULTI_SELECT, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TEXT -> Value.TEXT + TEXTAREA -> Value.TEXTAREA + NUMBER -> Value.NUMBER + DATE -> Value.DATE + BOOLEAN -> Value.BOOLEAN + SINGLE_SELECT -> Value.SINGLE_SELECT + MULTI_SELECT -> Value.MULTI_SELECT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TEXT -> Known.TEXT + TEXTAREA -> Known.TEXTAREA + NUMBER -> Known.NUMBER + DATE -> Known.DATE + BOOLEAN -> Known.BOOLEAN + SINGLE_SELECT -> Known.SINGLE_SELECT + MULTI_SELECT -> Known.MULTI_SELECT + else -> throw ImageKitInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * The default value for this custom metadata field. This property is only required if + * `isValueRequired` property is set to `true`. The value should match the `type` of custom + * metadata field. + */ + @JsonDeserialize(using = DefaultValue.Deserializer::class) + @JsonSerialize(using = DefaultValue.Serializer::class) + class DefaultValue + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val mixed: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + /** + * Default value should be of type array when custom metadata field type is set to + * `MultiSelect`. + */ + fun mixed(): Optional> = Optional.ofNullable(mixed) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isMixed(): Boolean = mixed != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + /** + * Default value should be of type array when custom metadata field type is set to + * `MultiSelect`. + */ + fun asMixed(): List = mixed.getOrThrow("mixed") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + mixed != null -> visitor.visitMixed(mixed) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): DefaultValue = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitMixed(mixed: List) { + mixed.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitMixed(mixed: List) = + mixed.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DefaultValue && + string == other.string && + number == other.number && + bool == other.bool && + mixed == other.mixed + } + + override fun hashCode(): Int = Objects.hash(string, number, bool, mixed) + + override fun toString(): String = + when { + string != null -> "DefaultValue{string=$string}" + number != null -> "DefaultValue{number=$number}" + bool != null -> "DefaultValue{bool=$bool}" + mixed != null -> "DefaultValue{mixed=$mixed}" + _json != null -> "DefaultValue{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DefaultValue") + } + + companion object { + + @JvmStatic fun ofString(string: String) = DefaultValue(string = string) + + @JvmStatic fun ofNumber(number: Double) = DefaultValue(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = DefaultValue(bool = bool) + + /** + * Default value should be of type array when custom metadata field type is set to + * `MultiSelect`. + */ + @JvmStatic + fun ofMixed(mixed: List) = + DefaultValue(mixed = mixed.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [DefaultValue] to a value of + * type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Default value should be of type array when custom metadata field type is set to + * `MultiSelect`. + */ + fun visitMixed(mixed: List): T + + /** + * Maps an unknown variant of [DefaultValue] to a value of type [T]. + * + * An instance of [DefaultValue] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown DefaultValue: $json") + } + } + + internal class Deserializer : BaseDeserializer(DefaultValue::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): DefaultValue { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + DefaultValue(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + DefaultValue(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + DefaultValue(bool = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef>(), + ) + ?.let { DefaultValue(mixed = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> DefaultValue(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(DefaultValue::class) { + + override fun serialize( + value: DefaultValue, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.mixed != null -> generator.writeObject(value.mixed) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DefaultValue") + } + } + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent1.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent1.Serializer::class) + class UnnamedSchemaWithArrayParent1 + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent1 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent1 && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> "UnnamedSchemaWithArrayParent1{string=$string}" + number != null -> "UnnamedSchemaWithArrayParent1{number=$number}" + bool != null -> "UnnamedSchemaWithArrayParent1{bool=$bool}" + _json != null -> "UnnamedSchemaWithArrayParent1{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = UnnamedSchemaWithArrayParent1(string = string) + + @JvmStatic + fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent1(number = number) + + @JvmStatic + fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent1(bool = bool) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent1] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent1] to a value of type + * [T]. + * + * An instance of [UnnamedSchemaWithArrayParent1] can contain an unknown variant + * if it was deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent1: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent1::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent1 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent1(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent1(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent1(bool = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> UnnamedSchemaWithArrayParent1(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent1::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent1, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") + } + } + } + } + } + + /** + * Maximum value of the field. Only set this property if field type is `Date` or `Number`. + * For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type + * field, set the minimum numeric value. + */ + @JsonDeserialize(using = MaxValue.Deserializer::class) + @JsonSerialize(using = MaxValue.Serializer::class) + class MaxValue + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): MaxValue = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxValue && string == other.string && number == other.number + } + + override fun hashCode(): Int = Objects.hash(string, number) + + override fun toString(): String = + when { + string != null -> "MaxValue{string=$string}" + number != null -> "MaxValue{number=$number}" + _json != null -> "MaxValue{_unknown=$_json}" + else -> throw IllegalStateException("Invalid MaxValue") + } + + companion object { + + @JvmStatic fun ofString(string: String) = MaxValue(string = string) + + @JvmStatic fun ofNumber(number: Double) = MaxValue(number = number) + } + + /** + * An interface that defines how to map each variant of [MaxValue] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + /** + * Maps an unknown variant of [MaxValue] to a value of type [T]. + * + * An instance of [MaxValue] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown MaxValue: $json") + } + } + + internal class Deserializer : BaseDeserializer(MaxValue::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): MaxValue { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + MaxValue(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + MaxValue(number = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> MaxValue(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(MaxValue::class) { + + override fun serialize( + value: MaxValue, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid MaxValue") + } + } + } + } + + /** + * Minimum value of the field. Only set this property if field type is `Date` or `Number`. + * For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type + * field, set the minimum numeric value. + */ + @JsonDeserialize(using = MinValue.Deserializer::class) + @JsonSerialize(using = MinValue.Serializer::class) + class MinValue + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): MinValue = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinValue && string == other.string && number == other.number + } + + override fun hashCode(): Int = Objects.hash(string, number) + + override fun toString(): String = + when { + string != null -> "MinValue{string=$string}" + number != null -> "MinValue{number=$number}" + _json != null -> "MinValue{_unknown=$_json}" + else -> throw IllegalStateException("Invalid MinValue") + } + + companion object { + + @JvmStatic fun ofString(string: String) = MinValue(string = string) + + @JvmStatic fun ofNumber(number: Double) = MinValue(number = number) + } + + /** + * An interface that defines how to map each variant of [MinValue] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + /** + * Maps an unknown variant of [MinValue] to a value of type [T]. + * + * An instance of [MinValue] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown MinValue: $json") + } + } + + internal class Deserializer : BaseDeserializer(MinValue::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): MinValue { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + MinValue(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + MinValue(number = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> MinValue(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(MinValue::class) { + + override fun serialize( + value: MinValue, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid MinValue") + } + } + } + } + + @JsonDeserialize(using = SelectOption.Deserializer::class) + @JsonSerialize(using = SelectOption.Serializer::class) + class SelectOption + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): SelectOption = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SelectOption && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> "SelectOption{string=$string}" + number != null -> "SelectOption{number=$number}" + bool != null -> "SelectOption{bool=$bool}" + _json != null -> "SelectOption{_unknown=$_json}" + else -> throw IllegalStateException("Invalid SelectOption") + } + + companion object { + + @JvmStatic fun ofString(string: String) = SelectOption(string = string) + + @JvmStatic fun ofNumber(number: Double) = SelectOption(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = SelectOption(bool = bool) + } + + /** + * An interface that defines how to map each variant of [SelectOption] to a value of + * type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [SelectOption] to a value of type [T]. + * + * An instance of [SelectOption] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown SelectOption: $json") + } + } + + internal class Deserializer : BaseDeserializer(SelectOption::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): SelectOption { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + SelectOption(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + SelectOption(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + SelectOption(bool = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> SelectOption(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(SelectOption::class) { + + override fun serialize( + value: SelectOption, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid SelectOption") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Schema && + type == other.type && + defaultValue == other.defaultValue && + isValueRequired == other.isValueRequired && + maxLength == other.maxLength && + maxValue == other.maxValue && + minLength == other.minLength && + minValue == other.minValue && + selectOptions == other.selectOptions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + type, + defaultValue, + isValueRequired, + maxLength, + maxValue, + minLength, + minValue, + selectOptions, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Schema{type=$type, defaultValue=$defaultValue, isValueRequired=$isValueRequired, maxLength=$maxLength, maxValue=$maxValue, minLength=$minLength, minValue=$minValue, selectOptions=$selectOptions, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomMetadataFieldCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CustomMetadataFieldCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt new file mode 100644 index 00000000..6266a56b --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt @@ -0,0 +1,238 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.custommetadatafields + +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * This API deletes a custom metadata field. Even after deleting a custom metadata field, you cannot + * create any new custom metadata field with the same name. + */ +class CustomMetadataFieldDeleteParams +private constructor( + private val id: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CustomMetadataFieldDeleteParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [CustomMetadataFieldDeleteParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadataFieldDeleteParams]. */ + 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(customMetadataFieldDeleteParams: CustomMetadataFieldDeleteParams) = + apply { + id = customMetadataFieldDeleteParams.id + additionalHeaders = customMetadataFieldDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = + customMetadataFieldDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + customMetadataFieldDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [CustomMetadataFieldDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomMetadataFieldDeleteParams = + CustomMetadataFieldDeleteParams( + 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 CustomMetadataFieldDeleteParams && + 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() = + "CustomMetadataFieldDeleteParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt new file mode 100644 index 00000000..7ec2f007 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt @@ -0,0 +1,120 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.custommetadatafields + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects + +class CustomMetadataFieldDeleteResponse +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CustomMetadataFieldDeleteResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadataFieldDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customMetadataFieldDeleteResponse: CustomMetadataFieldDeleteResponse) = + apply { + additionalProperties = + customMetadataFieldDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomMetadataFieldDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomMetadataFieldDeleteResponse = + CustomMetadataFieldDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): CustomMetadataFieldDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomMetadataFieldDeleteResponse && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomMetadataFieldDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParams.kt new file mode 100644 index 00000000..8ae404f5 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParams.kt @@ -0,0 +1,212 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.custommetadatafields + +import com.imagekit.api.core.Params +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * This API returns the array of created custom metadata field objects. By default the API returns + * only non deleted field objects, but you can include deleted fields in the API response. + */ +class CustomMetadataFieldListParams +private constructor( + private val includeDeleted: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Set it to `true` to include deleted field objects in the API response. */ + fun includeDeleted(): Optional = Optional.ofNullable(includeDeleted) + + /** 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(): CustomMetadataFieldListParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [CustomMetadataFieldListParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadataFieldListParams]. */ + class Builder internal constructor() { + + private var includeDeleted: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(customMetadataFieldListParams: CustomMetadataFieldListParams) = apply { + includeDeleted = customMetadataFieldListParams.includeDeleted + additionalHeaders = customMetadataFieldListParams.additionalHeaders.toBuilder() + additionalQueryParams = customMetadataFieldListParams.additionalQueryParams.toBuilder() + } + + /** Set it to `true` to include deleted field objects in the API response. */ + fun includeDeleted(includeDeleted: Boolean?) = apply { + this.includeDeleted = includeDeleted + } + + /** + * Alias for [Builder.includeDeleted]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeDeleted(includeDeleted: Boolean) = includeDeleted(includeDeleted as Boolean?) + + /** Alias for calling [Builder.includeDeleted] with `includeDeleted.orElse(null)`. */ + fun includeDeleted(includeDeleted: Optional) = + includeDeleted(includeDeleted.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 [CustomMetadataFieldListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomMetadataFieldListParams = + CustomMetadataFieldListParams( + includeDeleted, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + includeDeleted?.let { put("includeDeleted", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomMetadataFieldListParams && + includeDeleted == other.includeDeleted && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(includeDeleted, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CustomMetadataFieldListParams{includeDeleted=$includeDeleted, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt new file mode 100644 index 00000000..2cedf446 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt @@ -0,0 +1,2009 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.custommetadatafields + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.allMaxBy +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +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. */ +class CustomMetadataFieldUpdateParams +private constructor( + private val id: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** + * 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 + * setting field value on an asset in the media library UI. This parameter is required if + * `schema` is not provided. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun label(): Optional = body.label() + + /** + * An object that describes the rules for the custom metadata key. This parameter is required if + * `label` is not provided. Note: `type` cannot be updated and will be ignored if sent with the + * `schema`. The schema will be validated as per the existing `type`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun schema(): Optional = body.schema() + + /** + * Returns the raw JSON value of [label]. + * + * Unlike [label], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _label(): JsonField = body._label() + + /** + * Returns the raw JSON value of [schema]. + * + * Unlike [schema], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _schema(): JsonField = body._schema() + + 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(): CustomMetadataFieldUpdateParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [CustomMetadataFieldUpdateParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadataFieldUpdateParams]. */ + 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(customMetadataFieldUpdateParams: CustomMetadataFieldUpdateParams) = + apply { + id = customMetadataFieldUpdateParams.id + body = customMetadataFieldUpdateParams.body.toBuilder() + additionalHeaders = customMetadataFieldUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = + customMetadataFieldUpdateParams.additionalQueryParams.toBuilder() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [label] + * - [schema] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * 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 setting field value on an asset in the media library UI. This parameter is required + * if `schema` is not provided. + */ + fun label(label: String) = apply { body.label(label) } + + /** + * Sets [Builder.label] to an arbitrary JSON value. + * + * You should usually call [Builder.label] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun label(label: JsonField) = apply { body.label(label) } + + /** + * An object that describes the rules for the custom metadata key. This parameter is + * required if `label` is not provided. Note: `type` cannot be updated and will be ignored + * if sent with the `schema`. The schema will be validated as per the existing `type`. + */ + fun schema(schema: Schema) = apply { body.schema(schema) } + + /** + * Sets [Builder.schema] to an arbitrary JSON value. + * + * You should usually call [Builder.schema] with a well-typed [Schema] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun schema(schema: JsonField) = apply { body.schema(schema) } + + 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 [CustomMetadataFieldUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomMetadataFieldUpdateParams = + CustomMetadataFieldUpdateParams( + 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 + private constructor( + private val label: JsonField, + private val schema: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("label") @ExcludeMissing label: JsonField = JsonMissing.of(), + @JsonProperty("schema") @ExcludeMissing schema: JsonField = JsonMissing.of(), + ) : this(label, schema, mutableMapOf()) + + /** + * 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 setting field value on an asset in the media library UI. This parameter is required + * if `schema` is not provided. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun label(): Optional = label.getOptional("label") + + /** + * An object that describes the rules for the custom metadata key. This parameter is + * required if `label` is not provided. Note: `type` cannot be updated and will be ignored + * if sent with the `schema`. The schema will be validated as per the existing `type`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun schema(): Optional = schema.getOptional("schema") + + /** + * Returns the raw JSON value of [label]. + * + * Unlike [label], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("label") @ExcludeMissing fun _label(): JsonField = label + + /** + * Returns the raw JSON value of [schema]. + * + * Unlike [schema], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("schema") @ExcludeMissing fun _schema(): JsonField = schema + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @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 label: JsonField = JsonMissing.of() + private var schema: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + label = body.label + schema = body.schema + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * 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 setting field value on an asset in the media library UI. This parameter + * is required if `schema` is not provided. + */ + fun label(label: String) = label(JsonField.of(label)) + + /** + * Sets [Builder.label] to an arbitrary JSON value. + * + * You should usually call [Builder.label] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun label(label: JsonField) = apply { this.label = label } + + /** + * An object that describes the rules for the custom metadata key. This parameter is + * required if `label` is not provided. Note: `type` cannot be updated and will be + * ignored if sent with the `schema`. The schema will be validated as per the existing + * `type`. + */ + fun schema(schema: Schema) = schema(JsonField.of(schema)) + + /** + * Sets [Builder.schema] to an arbitrary JSON value. + * + * You should usually call [Builder.schema] with a well-typed [Schema] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun schema(schema: JsonField) = apply { this.schema = schema } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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(label, schema, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + label() + schema().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (label.asKnown().isPresent) 1 else 0) + + (schema.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + label == other.label && + schema == other.schema && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(label, schema, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{label=$label, schema=$schema, additionalProperties=$additionalProperties}" + } + + /** + * An object that describes the rules for the custom metadata key. This parameter is required if + * `label` is not provided. Note: `type` cannot be updated and will be ignored if sent with the + * `schema`. The schema will be validated as per the existing `type`. + */ + class Schema + private constructor( + private val defaultValue: JsonField, + private val isValueRequired: JsonField, + private val maxLength: JsonField, + private val maxValue: JsonField, + private val minLength: JsonField, + private val minValue: JsonField, + private val selectOptions: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("defaultValue") + @ExcludeMissing + defaultValue: JsonField = JsonMissing.of(), + @JsonProperty("isValueRequired") + @ExcludeMissing + isValueRequired: JsonField = JsonMissing.of(), + @JsonProperty("maxLength") + @ExcludeMissing + maxLength: JsonField = JsonMissing.of(), + @JsonProperty("maxValue") + @ExcludeMissing + maxValue: JsonField = JsonMissing.of(), + @JsonProperty("minLength") + @ExcludeMissing + minLength: JsonField = JsonMissing.of(), + @JsonProperty("minValue") + @ExcludeMissing + minValue: JsonField = JsonMissing.of(), + @JsonProperty("selectOptions") + @ExcludeMissing + selectOptions: JsonField> = JsonMissing.of(), + ) : this( + defaultValue, + isValueRequired, + maxLength, + maxValue, + minLength, + minValue, + selectOptions, + mutableMapOf(), + ) + + /** + * The default value for this custom metadata field. This property is only required if + * `isValueRequired` property is set to `true`. The value should match the `type` of custom + * metadata field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun defaultValue(): Optional = defaultValue.getOptional("defaultValue") + + /** + * Sets this custom metadata field as required. Setting custom metadata fields on an asset + * will throw error if the value for all required fields are not present in upload or update + * asset API request body. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isValueRequired(): Optional = isValueRequired.getOptional("isValueRequired") + + /** + * Maximum length of string. Only set this property if `type` is set to `Text` or + * `Textarea`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maxLength(): Optional = maxLength.getOptional("maxLength") + + /** + * Maximum value of the field. Only set this property if field type is `Date` or `Number`. + * For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type + * field, set the minimum numeric value. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maxValue(): Optional = maxValue.getOptional("maxValue") + + /** + * Minimum length of string. Only set this property if `type` is set to `Text` or + * `Textarea`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun minLength(): Optional = minLength.getOptional("minLength") + + /** + * Minimum value of the field. Only set this property if field type is `Date` or `Number`. + * For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type + * field, set the minimum numeric value. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun minValue(): Optional = minValue.getOptional("minValue") + + /** + * An array of allowed values. This property is only required if `type` property is set to + * `SingleSelect` or `MultiSelect`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun selectOptions(): Optional> = + selectOptions.getOptional("selectOptions") + + /** + * Returns the raw JSON value of [defaultValue]. + * + * Unlike [defaultValue], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("defaultValue") + @ExcludeMissing + fun _defaultValue(): JsonField = defaultValue + + /** + * Returns the raw JSON value of [isValueRequired]. + * + * Unlike [isValueRequired], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("isValueRequired") + @ExcludeMissing + fun _isValueRequired(): JsonField = isValueRequired + + /** + * Returns the raw JSON value of [maxLength]. + * + * Unlike [maxLength], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("maxLength") @ExcludeMissing fun _maxLength(): JsonField = maxLength + + /** + * Returns the raw JSON value of [maxValue]. + * + * Unlike [maxValue], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("maxValue") @ExcludeMissing fun _maxValue(): JsonField = maxValue + + /** + * Returns the raw JSON value of [minLength]. + * + * Unlike [minLength], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("minLength") @ExcludeMissing fun _minLength(): JsonField = minLength + + /** + * Returns the raw JSON value of [minValue]. + * + * Unlike [minValue], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("minValue") @ExcludeMissing fun _minValue(): JsonField = minValue + + /** + * Returns the raw JSON value of [selectOptions]. + * + * Unlike [selectOptions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("selectOptions") + @ExcludeMissing + fun _selectOptions(): JsonField> = selectOptions + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Schema]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Schema]. */ + class Builder internal constructor() { + + private var defaultValue: JsonField = JsonMissing.of() + private var isValueRequired: JsonField = JsonMissing.of() + private var maxLength: JsonField = JsonMissing.of() + private var maxValue: JsonField = JsonMissing.of() + private var minLength: JsonField = JsonMissing.of() + private var minValue: JsonField = JsonMissing.of() + private var selectOptions: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(schema: Schema) = apply { + defaultValue = schema.defaultValue + isValueRequired = schema.isValueRequired + maxLength = schema.maxLength + maxValue = schema.maxValue + minLength = schema.minLength + minValue = schema.minValue + selectOptions = schema.selectOptions.map { it.toMutableList() } + additionalProperties = schema.additionalProperties.toMutableMap() + } + + /** + * The default value for this custom metadata field. This property is only required if + * `isValueRequired` property is set to `true`. The value should match the `type` of + * custom metadata field. + */ + fun defaultValue(defaultValue: DefaultValue) = defaultValue(JsonField.of(defaultValue)) + + /** + * Sets [Builder.defaultValue] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultValue] with a well-typed [DefaultValue] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultValue(defaultValue: JsonField) = apply { + this.defaultValue = defaultValue + } + + /** Alias for calling [defaultValue] with `DefaultValue.ofString(string)`. */ + fun defaultValue(string: String) = defaultValue(DefaultValue.ofString(string)) + + /** Alias for calling [defaultValue] with `DefaultValue.ofNumber(number)`. */ + fun defaultValue(number: Double) = defaultValue(DefaultValue.ofNumber(number)) + + /** Alias for calling [defaultValue] with `DefaultValue.ofBool(bool)`. */ + fun defaultValue(bool: Boolean) = defaultValue(DefaultValue.ofBool(bool)) + + /** Alias for calling [defaultValue] with `DefaultValue.ofMixed(mixed)`. */ + fun defaultValueOfMixed(mixed: List) = + defaultValue(DefaultValue.ofMixed(mixed)) + + /** + * Sets this custom metadata field as required. Setting custom metadata fields on an + * asset will throw error if the value for all required fields are not present in upload + * or update asset API request body. + */ + fun isValueRequired(isValueRequired: Boolean) = + isValueRequired(JsonField.of(isValueRequired)) + + /** + * Sets [Builder.isValueRequired] to an arbitrary JSON value. + * + * You should usually call [Builder.isValueRequired] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isValueRequired(isValueRequired: JsonField) = apply { + this.isValueRequired = isValueRequired + } + + /** + * Maximum length of string. Only set this property if `type` is set to `Text` or + * `Textarea`. + */ + fun maxLength(maxLength: Double) = maxLength(JsonField.of(maxLength)) + + /** + * Sets [Builder.maxLength] to an arbitrary JSON value. + * + * You should usually call [Builder.maxLength] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxLength(maxLength: JsonField) = apply { this.maxLength = maxLength } + + /** + * Maximum value of the field. Only set this property if field type is `Date` or + * `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For + * `Number` type field, set the minimum numeric value. + */ + fun maxValue(maxValue: MaxValue) = maxValue(JsonField.of(maxValue)) + + /** + * Sets [Builder.maxValue] to an arbitrary JSON value. + * + * You should usually call [Builder.maxValue] with a well-typed [MaxValue] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxValue(maxValue: JsonField) = apply { this.maxValue = maxValue } + + /** Alias for calling [maxValue] with `MaxValue.ofString(string)`. */ + fun maxValue(string: String) = maxValue(MaxValue.ofString(string)) + + /** Alias for calling [maxValue] with `MaxValue.ofNumber(number)`. */ + fun maxValue(number: Double) = maxValue(MaxValue.ofNumber(number)) + + /** + * Minimum length of string. Only set this property if `type` is set to `Text` or + * `Textarea`. + */ + fun minLength(minLength: Double) = minLength(JsonField.of(minLength)) + + /** + * Sets [Builder.minLength] to an arbitrary JSON value. + * + * You should usually call [Builder.minLength] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minLength(minLength: JsonField) = apply { this.minLength = minLength } + + /** + * Minimum value of the field. Only set this property if field type is `Date` or + * `Number`. For `Date` type field, set the minimum date in ISO8601 string format. For + * `Number` type field, set the minimum numeric value. + */ + fun minValue(minValue: MinValue) = minValue(JsonField.of(minValue)) + + /** + * Sets [Builder.minValue] to an arbitrary JSON value. + * + * You should usually call [Builder.minValue] with a well-typed [MinValue] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minValue(minValue: JsonField) = apply { this.minValue = minValue } + + /** Alias for calling [minValue] with `MinValue.ofString(string)`. */ + fun minValue(string: String) = minValue(MinValue.ofString(string)) + + /** Alias for calling [minValue] with `MinValue.ofNumber(number)`. */ + fun minValue(number: Double) = minValue(MinValue.ofNumber(number)) + + /** + * An array of allowed values. This property is only required if `type` property is set + * to `SingleSelect` or `MultiSelect`. + */ + fun selectOptions(selectOptions: List) = + selectOptions(JsonField.of(selectOptions)) + + /** + * Sets [Builder.selectOptions] to an arbitrary JSON value. + * + * You should usually call [Builder.selectOptions] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun selectOptions(selectOptions: JsonField>) = apply { + this.selectOptions = selectOptions.map { it.toMutableList() } + } + + /** + * Adds a single [SelectOption] to [selectOptions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSelectOption(selectOption: SelectOption) = apply { + selectOptions = + (selectOptions ?: JsonField.of(mutableListOf())).also { + checkKnown("selectOptions", it).add(selectOption) + } + } + + /** Alias for calling [addSelectOption] with `SelectOption.ofString(string)`. */ + fun addSelectOption(string: String) = addSelectOption(SelectOption.ofString(string)) + + /** Alias for calling [addSelectOption] with `SelectOption.ofNumber(number)`. */ + fun addSelectOption(number: Double) = addSelectOption(SelectOption.ofNumber(number)) + + /** Alias for calling [addSelectOption] with `SelectOption.ofBool(bool)`. */ + fun addSelectOption(bool: Boolean) = addSelectOption(SelectOption.ofBool(bool)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Schema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Schema = + Schema( + defaultValue, + isValueRequired, + maxLength, + maxValue, + minLength, + minValue, + (selectOptions ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Schema = apply { + if (validated) { + return@apply + } + + defaultValue().ifPresent { it.validate() } + isValueRequired() + maxLength() + maxValue().ifPresent { it.validate() } + minLength() + minValue().ifPresent { it.validate() } + selectOptions().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (defaultValue.asKnown().getOrNull()?.validity() ?: 0) + + (if (isValueRequired.asKnown().isPresent) 1 else 0) + + (if (maxLength.asKnown().isPresent) 1 else 0) + + (maxValue.asKnown().getOrNull()?.validity() ?: 0) + + (if (minLength.asKnown().isPresent) 1 else 0) + + (minValue.asKnown().getOrNull()?.validity() ?: 0) + + (selectOptions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** + * The default value for this custom metadata field. This property is only required if + * `isValueRequired` property is set to `true`. The value should match the `type` of custom + * metadata field. + */ + @JsonDeserialize(using = DefaultValue.Deserializer::class) + @JsonSerialize(using = DefaultValue.Serializer::class) + class DefaultValue + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val mixed: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + /** + * Default value should be of type array when custom metadata field type is set to + * `MultiSelect`. + */ + fun mixed(): Optional> = Optional.ofNullable(mixed) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isMixed(): Boolean = mixed != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + /** + * Default value should be of type array when custom metadata field type is set to + * `MultiSelect`. + */ + fun asMixed(): List = mixed.getOrThrow("mixed") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + mixed != null -> visitor.visitMixed(mixed) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): DefaultValue = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitMixed(mixed: List) { + mixed.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitMixed(mixed: List) = + mixed.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DefaultValue && + string == other.string && + number == other.number && + bool == other.bool && + mixed == other.mixed + } + + override fun hashCode(): Int = Objects.hash(string, number, bool, mixed) + + override fun toString(): String = + when { + string != null -> "DefaultValue{string=$string}" + number != null -> "DefaultValue{number=$number}" + bool != null -> "DefaultValue{bool=$bool}" + mixed != null -> "DefaultValue{mixed=$mixed}" + _json != null -> "DefaultValue{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DefaultValue") + } + + companion object { + + @JvmStatic fun ofString(string: String) = DefaultValue(string = string) + + @JvmStatic fun ofNumber(number: Double) = DefaultValue(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = DefaultValue(bool = bool) + + /** + * Default value should be of type array when custom metadata field type is set to + * `MultiSelect`. + */ + @JvmStatic + fun ofMixed(mixed: List) = + DefaultValue(mixed = mixed.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [DefaultValue] to a value of + * type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Default value should be of type array when custom metadata field type is set to + * `MultiSelect`. + */ + fun visitMixed(mixed: List): T + + /** + * Maps an unknown variant of [DefaultValue] to a value of type [T]. + * + * An instance of [DefaultValue] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown DefaultValue: $json") + } + } + + internal class Deserializer : BaseDeserializer(DefaultValue::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): DefaultValue { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + DefaultValue(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + DefaultValue(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + DefaultValue(bool = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef>(), + ) + ?.let { DefaultValue(mixed = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> DefaultValue(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(DefaultValue::class) { + + override fun serialize( + value: DefaultValue, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.mixed != null -> generator.writeObject(value.mixed) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DefaultValue") + } + } + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent2.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent2.Serializer::class) + class UnnamedSchemaWithArrayParent2 + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent2 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent2 && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> "UnnamedSchemaWithArrayParent2{string=$string}" + number != null -> "UnnamedSchemaWithArrayParent2{number=$number}" + bool != null -> "UnnamedSchemaWithArrayParent2{bool=$bool}" + _json != null -> "UnnamedSchemaWithArrayParent2{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent2") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = UnnamedSchemaWithArrayParent2(string = string) + + @JvmStatic + fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent2(number = number) + + @JvmStatic + fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent2(bool = bool) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent2] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent2] to a value of type + * [T]. + * + * An instance of [UnnamedSchemaWithArrayParent2] can contain an unknown variant + * if it was deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent2: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent2::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent2 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent2(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent2(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent2(bool = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> UnnamedSchemaWithArrayParent2(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent2::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent2, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent2") + } + } + } + } + } + + /** + * Maximum value of the field. Only set this property if field type is `Date` or `Number`. + * For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type + * field, set the minimum numeric value. + */ + @JsonDeserialize(using = MaxValue.Deserializer::class) + @JsonSerialize(using = MaxValue.Serializer::class) + class MaxValue + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): MaxValue = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxValue && string == other.string && number == other.number + } + + override fun hashCode(): Int = Objects.hash(string, number) + + override fun toString(): String = + when { + string != null -> "MaxValue{string=$string}" + number != null -> "MaxValue{number=$number}" + _json != null -> "MaxValue{_unknown=$_json}" + else -> throw IllegalStateException("Invalid MaxValue") + } + + companion object { + + @JvmStatic fun ofString(string: String) = MaxValue(string = string) + + @JvmStatic fun ofNumber(number: Double) = MaxValue(number = number) + } + + /** + * An interface that defines how to map each variant of [MaxValue] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + /** + * Maps an unknown variant of [MaxValue] to a value of type [T]. + * + * An instance of [MaxValue] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown MaxValue: $json") + } + } + + internal class Deserializer : BaseDeserializer(MaxValue::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): MaxValue { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + MaxValue(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + MaxValue(number = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> MaxValue(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(MaxValue::class) { + + override fun serialize( + value: MaxValue, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid MaxValue") + } + } + } + } + + /** + * Minimum value of the field. Only set this property if field type is `Date` or `Number`. + * For `Date` type field, set the minimum date in ISO8601 string format. For `Number` type + * field, set the minimum numeric value. + */ + @JsonDeserialize(using = MinValue.Deserializer::class) + @JsonSerialize(using = MinValue.Serializer::class) + class MinValue + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): MinValue = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MinValue && string == other.string && number == other.number + } + + override fun hashCode(): Int = Objects.hash(string, number) + + override fun toString(): String = + when { + string != null -> "MinValue{string=$string}" + number != null -> "MinValue{number=$number}" + _json != null -> "MinValue{_unknown=$_json}" + else -> throw IllegalStateException("Invalid MinValue") + } + + companion object { + + @JvmStatic fun ofString(string: String) = MinValue(string = string) + + @JvmStatic fun ofNumber(number: Double) = MinValue(number = number) + } + + /** + * An interface that defines how to map each variant of [MinValue] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + /** + * Maps an unknown variant of [MinValue] to a value of type [T]. + * + * An instance of [MinValue] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown MinValue: $json") + } + } + + internal class Deserializer : BaseDeserializer(MinValue::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): MinValue { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + MinValue(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + MinValue(number = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> MinValue(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(MinValue::class) { + + override fun serialize( + value: MinValue, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid MinValue") + } + } + } + } + + @JsonDeserialize(using = SelectOption.Deserializer::class) + @JsonSerialize(using = SelectOption.Serializer::class) + class SelectOption + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): SelectOption = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SelectOption && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> "SelectOption{string=$string}" + number != null -> "SelectOption{number=$number}" + bool != null -> "SelectOption{bool=$bool}" + _json != null -> "SelectOption{_unknown=$_json}" + else -> throw IllegalStateException("Invalid SelectOption") + } + + companion object { + + @JvmStatic fun ofString(string: String) = SelectOption(string = string) + + @JvmStatic fun ofNumber(number: Double) = SelectOption(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = SelectOption(bool = bool) + } + + /** + * An interface that defines how to map each variant of [SelectOption] to a value of + * type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [SelectOption] to a value of type [T]. + * + * An instance of [SelectOption] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown SelectOption: $json") + } + } + + internal class Deserializer : BaseDeserializer(SelectOption::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): SelectOption { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + SelectOption(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + SelectOption(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + SelectOption(bool = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> SelectOption(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(SelectOption::class) { + + override fun serialize( + value: SelectOption, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid SelectOption") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Schema && + defaultValue == other.defaultValue && + isValueRequired == other.isValueRequired && + maxLength == other.maxLength && + maxValue == other.maxValue && + minLength == other.minLength && + minValue == other.minValue && + selectOptions == other.selectOptions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + defaultValue, + isValueRequired, + maxLength, + maxValue, + minLength, + minValue, + selectOptions, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Schema{defaultValue=$defaultValue, isValueRequired=$isValueRequired, maxLength=$maxLength, maxValue=$maxValue, minLength=$minLength, minValue=$minValue, selectOptions=$selectOptions, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomMetadataFieldUpdateParams && + 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() = + "CustomMetadataFieldUpdateParams{id=$id, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt new file mode 100644 index 00000000..f0b39c85 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt @@ -0,0 +1,1658 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Object containing details of a file or file version. */ +class File +private constructor( + private val aiTags: JsonField>, + private val createdAt: JsonField, + private val customCoordinates: JsonField, + private val customMetadata: JsonField, + private val description: JsonField, + private val fileId: JsonField, + private val filePath: JsonField, + private val fileType: JsonField, + private val hasAlpha: JsonField, + private val height: JsonField, + private val isPrivateFile: JsonField, + private val isPublished: JsonField, + private val mime: JsonField, + private val name: JsonField, + private val size: JsonField, + private val tags: JsonField>, + private val thumbnail: JsonField, + private val type: JsonField, + private val updatedAt: JsonField, + private val url: JsonField, + private val versionInfo: JsonField, + private val width: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("AITags") @ExcludeMissing aiTags: JsonField> = JsonMissing.of(), + @JsonProperty("createdAt") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("customCoordinates") + @ExcludeMissing + customCoordinates: JsonField = JsonMissing.of(), + @JsonProperty("customMetadata") + @ExcludeMissing + customMetadata: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("fileId") @ExcludeMissing fileId: JsonField = JsonMissing.of(), + @JsonProperty("filePath") @ExcludeMissing filePath: JsonField = JsonMissing.of(), + @JsonProperty("fileType") @ExcludeMissing fileType: JsonField = JsonMissing.of(), + @JsonProperty("hasAlpha") @ExcludeMissing hasAlpha: JsonField = JsonMissing.of(), + @JsonProperty("height") @ExcludeMissing height: JsonField = JsonMissing.of(), + @JsonProperty("isPrivateFile") + @ExcludeMissing + isPrivateFile: JsonField = JsonMissing.of(), + @JsonProperty("isPublished") + @ExcludeMissing + isPublished: JsonField = JsonMissing.of(), + @JsonProperty("mime") @ExcludeMissing mime: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("size") @ExcludeMissing size: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), + @JsonProperty("thumbnail") @ExcludeMissing thumbnail: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("updatedAt") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("versionInfo") + @ExcludeMissing + versionInfo: JsonField = JsonMissing.of(), + @JsonProperty("width") @ExcludeMissing width: JsonField = JsonMissing.of(), + ) : this( + aiTags, + createdAt, + customCoordinates, + customMetadata, + description, + fileId, + filePath, + fileType, + hasAlpha, + height, + isPrivateFile, + isPublished, + mime, + name, + size, + tags, + thumbnail, + type, + updatedAt, + url, + versionInfo, + width, + mutableMapOf(), + ) + + /** + * An array of tags assigned to the file by auto tagging. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun aiTags(): Optional> = aiTags.getOptional("AITags") + + /** + * Date and time when the file was uploaded. The date and time is in ISO8601 format. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun createdAt(): Optional = createdAt.getOptional("createdAt") + + /** + * An string with custom coordinates of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customCoordinates(): Optional = customCoordinates.getOptional("customCoordinates") + + /** + * An object with custom metadata for the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customMetadata(): Optional = customMetadata.getOptional("customMetadata") + + /** + * Optional text to describe the contents of the file. Can be set by the user or the + * ai-auto-description extension. + * + * @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") + + /** + * Unique identifier of the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fileId(): Optional = fileId.getOptional("fileId") + + /** + * Path of the file. This is the path you would use in the URL to access the file. For example, + * if the file is at the root of the media library, the path will be `/file.jpg`. If the file is + * inside a folder named `images`, the path will be `/images/file.jpg`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun filePath(): Optional = filePath.getOptional("filePath") + + /** + * Type of the file. Possible values are `image`, `non-image`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fileType(): Optional = fileType.getOptional("fileType") + + /** + * Specifies if the image has an alpha channel. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun hasAlpha(): Optional = hasAlpha.getOptional("hasAlpha") + + /** + * Height of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun height(): Optional = height.getOptional("height") + + /** + * Specifies if the file is private or not. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isPrivateFile(): Optional = isPrivateFile.getOptional("isPrivateFile") + + /** + * Specifies if the file is published or not. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isPublished(): Optional = isPublished.getOptional("isPublished") + + /** + * MIME type of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mime(): Optional = mime.getOptional("mime") + + /** + * Name of the asset. + * + * @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") + + /** + * Size of the file in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun size(): Optional = size.getOptional("size") + + /** + * An array of tags assigned to the file. Tags are used to search files in the media library. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tags(): Optional> = tags.getOptional("tags") + + /** + * URL of the thumbnail image. This URL is used to access the thumbnail image of the file in the + * media library. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun thumbnail(): Optional = thumbnail.getOptional("thumbnail") + + /** + * Type of the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Date and time when the file was last updated. The date and time is in ISO8601 format. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun updatedAt(): Optional = updatedAt.getOptional("updatedAt") + + /** + * URL of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * An object with details of the file version. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun versionInfo(): Optional = versionInfo.getOptional("versionInfo") + + /** + * Width of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun width(): Optional = width.getOptional("width") + + /** + * Returns the raw JSON value of [aiTags]. + * + * Unlike [aiTags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("AITags") @ExcludeMissing fun _aiTags(): JsonField> = aiTags + + /** + * 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 [customCoordinates]. + * + * Unlike [customCoordinates], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("customCoordinates") + @ExcludeMissing + fun _customCoordinates(): JsonField = customCoordinates + + /** + * Returns the raw JSON value of [customMetadata]. + * + * Unlike [customMetadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): JsonField = customMetadata + + /** + * 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 [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fileId") @ExcludeMissing fun _fileId(): JsonField = fileId + + /** + * Returns the raw JSON value of [filePath]. + * + * Unlike [filePath], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filePath") @ExcludeMissing fun _filePath(): JsonField = filePath + + /** + * Returns the raw JSON value of [fileType]. + * + * Unlike [fileType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fileType") @ExcludeMissing fun _fileType(): JsonField = fileType + + /** + * Returns the raw JSON value of [hasAlpha]. + * + * Unlike [hasAlpha], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("hasAlpha") @ExcludeMissing fun _hasAlpha(): JsonField = hasAlpha + + /** + * Returns the raw JSON value of [height]. + * + * Unlike [height], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("height") @ExcludeMissing fun _height(): JsonField = height + + /** + * Returns the raw JSON value of [isPrivateFile]. + * + * Unlike [isPrivateFile], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isPrivateFile") + @ExcludeMissing + fun _isPrivateFile(): JsonField = isPrivateFile + + /** + * Returns the raw JSON value of [isPublished]. + * + * Unlike [isPublished], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isPublished") + @ExcludeMissing + fun _isPublished(): JsonField = isPublished + + /** + * Returns the raw JSON value of [mime]. + * + * Unlike [mime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mime") @ExcludeMissing fun _mime(): JsonField = mime + + /** + * 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 [size]. + * + * Unlike [size], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("size") @ExcludeMissing fun _size(): JsonField = size + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + + /** + * Returns the raw JSON value of [thumbnail]. + * + * Unlike [thumbnail], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("thumbnail") @ExcludeMissing fun _thumbnail(): JsonField = thumbnail + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updatedAt") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [versionInfo]. + * + * Unlike [versionInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("versionInfo") + @ExcludeMissing + fun _versionInfo(): JsonField = versionInfo + + /** + * Returns the raw JSON value of [width]. + * + * Unlike [width], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("width") @ExcludeMissing fun _width(): JsonField = width + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [File]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [File]. */ + class Builder internal constructor() { + + private var aiTags: JsonField>? = null + private var createdAt: JsonField = JsonMissing.of() + private var customCoordinates: JsonField = JsonMissing.of() + private var customMetadata: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var fileId: JsonField = JsonMissing.of() + private var filePath: JsonField = JsonMissing.of() + private var fileType: JsonField = JsonMissing.of() + private var hasAlpha: JsonField = JsonMissing.of() + private var height: JsonField = JsonMissing.of() + private var isPrivateFile: JsonField = JsonMissing.of() + private var isPublished: JsonField = JsonMissing.of() + private var mime: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var size: JsonField = JsonMissing.of() + private var tags: JsonField>? = null + private var thumbnail: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var url: JsonField = JsonMissing.of() + private var versionInfo: JsonField = JsonMissing.of() + private var width: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(file: File) = apply { + aiTags = file.aiTags.map { it.toMutableList() } + createdAt = file.createdAt + customCoordinates = file.customCoordinates + customMetadata = file.customMetadata + description = file.description + fileId = file.fileId + filePath = file.filePath + fileType = file.fileType + hasAlpha = file.hasAlpha + height = file.height + isPrivateFile = file.isPrivateFile + isPublished = file.isPublished + mime = file.mime + name = file.name + size = file.size + tags = file.tags.map { it.toMutableList() } + thumbnail = file.thumbnail + type = file.type + updatedAt = file.updatedAt + url = file.url + versionInfo = file.versionInfo + width = file.width + additionalProperties = file.additionalProperties.toMutableMap() + } + + /** An array of tags assigned to the file by auto tagging. */ + fun aiTags(aiTags: List?) = aiTags(JsonField.ofNullable(aiTags)) + + /** Alias for calling [Builder.aiTags] with `aiTags.orElse(null)`. */ + fun aiTags(aiTags: Optional>) = aiTags(aiTags.getOrNull()) + + /** + * Sets [Builder.aiTags] to an arbitrary JSON value. + * + * You should usually call [Builder.aiTags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun aiTags(aiTags: JsonField>) = apply { + this.aiTags = aiTags.map { it.toMutableList() } + } + + /** + * Adds a single [AiTag] to [aiTags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAiTag(aiTag: AiTag) = apply { + aiTags = + (aiTags ?: JsonField.of(mutableListOf())).also { + checkKnown("aiTags", it).add(aiTag) + } + } + + /** Date and time when the file was uploaded. The date and time is in ISO8601 format. */ + 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 } + + /** An string with custom coordinates of the file. */ + fun customCoordinates(customCoordinates: String?) = + customCoordinates(JsonField.ofNullable(customCoordinates)) + + /** Alias for calling [Builder.customCoordinates] with `customCoordinates.orElse(null)`. */ + fun customCoordinates(customCoordinates: Optional) = + customCoordinates(customCoordinates.getOrNull()) + + /** + * Sets [Builder.customCoordinates] to an arbitrary JSON value. + * + * You should usually call [Builder.customCoordinates] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customCoordinates(customCoordinates: JsonField) = apply { + this.customCoordinates = customCoordinates + } + + /** An object with custom metadata for the file. */ + fun customMetadata(customMetadata: CustomMetadata) = + customMetadata(JsonField.of(customMetadata)) + + /** + * Sets [Builder.customMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.customMetadata] with a well-typed [CustomMetadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customMetadata(customMetadata: JsonField) = apply { + this.customMetadata = customMetadata + } + + /** + * Optional text to describe the contents of the file. Can be set by the user or the + * ai-auto-description extension. + */ + 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 } + + /** Unique identifier of the asset. */ + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + + /** + * Path of the file. This is the path you would use in the URL to access the file. For + * example, if the file is at the root of the media library, the path will be `/file.jpg`. + * If the file is inside a folder named `images`, the path will be `/images/file.jpg`. + */ + fun filePath(filePath: String) = filePath(JsonField.of(filePath)) + + /** + * Sets [Builder.filePath] to an arbitrary JSON value. + * + * You should usually call [Builder.filePath] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filePath(filePath: JsonField) = apply { this.filePath = filePath } + + /** Type of the file. Possible values are `image`, `non-image`. */ + fun fileType(fileType: String) = fileType(JsonField.of(fileType)) + + /** + * Sets [Builder.fileType] to an arbitrary JSON value. + * + * You should usually call [Builder.fileType] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fileType(fileType: JsonField) = apply { this.fileType = fileType } + + /** Specifies if the image has an alpha channel. */ + fun hasAlpha(hasAlpha: Boolean) = hasAlpha(JsonField.of(hasAlpha)) + + /** + * Sets [Builder.hasAlpha] to an arbitrary JSON value. + * + * You should usually call [Builder.hasAlpha] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hasAlpha(hasAlpha: JsonField) = apply { this.hasAlpha = hasAlpha } + + /** Height of the file. */ + fun height(height: Double) = height(JsonField.of(height)) + + /** + * Sets [Builder.height] to an arbitrary JSON value. + * + * You should usually call [Builder.height] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun height(height: JsonField) = apply { this.height = height } + + /** Specifies if the file is private or not. */ + fun isPrivateFile(isPrivateFile: Boolean) = isPrivateFile(JsonField.of(isPrivateFile)) + + /** + * Sets [Builder.isPrivateFile] to an arbitrary JSON value. + * + * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPrivateFile(isPrivateFile: JsonField) = apply { + this.isPrivateFile = isPrivateFile + } + + /** Specifies if the file is published or not. */ + fun isPublished(isPublished: Boolean) = isPublished(JsonField.of(isPublished)) + + /** + * Sets [Builder.isPublished] to an arbitrary JSON value. + * + * You should usually call [Builder.isPublished] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isPublished(isPublished: JsonField) = apply { this.isPublished = isPublished } + + /** MIME type of the file. */ + fun mime(mime: String) = mime(JsonField.of(mime)) + + /** + * Sets [Builder.mime] to an arbitrary JSON value. + * + * You should usually call [Builder.mime] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun mime(mime: JsonField) = apply { this.mime = mime } + + /** Name of the asset. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Size of the file in bytes. */ + fun size(size: Double) = size(JsonField.of(size)) + + /** + * Sets [Builder.size] to an arbitrary JSON value. + * + * You should usually call [Builder.size] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun size(size: JsonField) = apply { this.size = size } + + /** + * An array of tags assigned to the file. Tags are used to search files in the media + * library. + */ + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + /** + * URL of the thumbnail image. This URL is used to access the thumbnail image of the file in + * the media library. + */ + fun thumbnail(thumbnail: String) = thumbnail(JsonField.of(thumbnail)) + + /** + * Sets [Builder.thumbnail] to an arbitrary JSON value. + * + * You should usually call [Builder.thumbnail] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thumbnail(thumbnail: JsonField) = apply { this.thumbnail = thumbnail } + + /** Type of the asset. */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Date and time when the file was last updated. The date and time is in ISO8601 format. */ + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + + /** URL of the file. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** An object with details of the file version. */ + fun versionInfo(versionInfo: VersionInfo) = versionInfo(JsonField.of(versionInfo)) + + /** + * Sets [Builder.versionInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.versionInfo] with a well-typed [VersionInfo] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun versionInfo(versionInfo: JsonField) = apply { + this.versionInfo = versionInfo + } + + /** Width of the file. */ + fun width(width: Double) = width(JsonField.of(width)) + + /** + * Sets [Builder.width] to an arbitrary JSON value. + * + * You should usually call [Builder.width] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun width(width: JsonField) = apply { this.width = width } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [File]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): File = + File( + (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, + createdAt, + customCoordinates, + customMetadata, + description, + fileId, + filePath, + fileType, + hasAlpha, + height, + isPrivateFile, + isPublished, + mime, + name, + size, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + thumbnail, + type, + updatedAt, + url, + versionInfo, + width, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): File = apply { + if (validated) { + return@apply + } + + aiTags().ifPresent { it.forEach { it.validate() } } + createdAt() + customCoordinates() + customMetadata().ifPresent { it.validate() } + description() + fileId() + filePath() + fileType() + hasAlpha() + height() + isPrivateFile() + isPublished() + mime() + name() + size() + tags() + thumbnail() + type().ifPresent { it.validate() } + updatedAt() + url() + versionInfo().ifPresent { it.validate() } + width() + 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 = + (aiTags.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (customCoordinates.asKnown().isPresent) 1 else 0) + + (customMetadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (fileId.asKnown().isPresent) 1 else 0) + + (if (filePath.asKnown().isPresent) 1 else 0) + + (if (fileType.asKnown().isPresent) 1 else 0) + + (if (hasAlpha.asKnown().isPresent) 1 else 0) + + (if (height.asKnown().isPresent) 1 else 0) + + (if (isPrivateFile.asKnown().isPresent) 1 else 0) + + (if (isPublished.asKnown().isPresent) 1 else 0) + + (if (mime.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (size.asKnown().isPresent) 1 else 0) + + (tags.asKnown().getOrNull()?.size ?: 0) + + (if (thumbnail.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (versionInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (width.asKnown().isPresent) 1 else 0) + + class AiTag + private constructor( + private val confidence: JsonField, + private val name: JsonField, + private val source: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("confidence") + @ExcludeMissing + confidence: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + ) : this(confidence, name, source, mutableMapOf()) + + /** + * Confidence score of the tag. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun confidence(): Optional = confidence.getOptional("confidence") + + /** + * Name of the tag. + * + * @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") + + /** + * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * Returns the raw JSON value of [confidence]. + * + * Unlike [confidence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("confidence") + @ExcludeMissing + fun _confidence(): JsonField = confidence + + /** + * 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 [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AiTag]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AiTag]. */ + class Builder internal constructor() { + + private var confidence: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var source: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(aiTag: AiTag) = apply { + confidence = aiTag.confidence + name = aiTag.name + source = aiTag.source + additionalProperties = aiTag.additionalProperties.toMutableMap() + } + + /** Confidence score of the tag. */ + fun confidence(confidence: Double) = confidence(JsonField.of(confidence)) + + /** + * Sets [Builder.confidence] to an arbitrary JSON value. + * + * You should usually call [Builder.confidence] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun confidence(confidence: JsonField) = apply { this.confidence = confidence } + + /** Name of the tag. */ + 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 } + + /** + * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. + */ + fun source(source: String) = source(JsonField.of(source)) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AiTag]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AiTag = + AiTag(confidence, name, source, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): AiTag = apply { + if (validated) { + return@apply + } + + confidence() + name() + source() + 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 (confidence.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (source.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiTag && + confidence == other.confidence && + name == other.name && + source == other.source && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(confidence, name, source, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AiTag{confidence=$confidence, name=$name, source=$source, additionalProperties=$additionalProperties}" + } + + /** An object with custom metadata for the file. */ + class CustomMetadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CustomMetadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customMetadata: CustomMetadata) = apply { + additionalProperties = customMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CustomMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomMetadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" + } + + /** Type of the asset. */ + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val FILE = of("file") + + @JvmField val FILE_VERSION = of("file-version") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + FILE, + FILE_VERSION, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FILE, + FILE_VERSION, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FILE -> Value.FILE + FILE_VERSION -> Value.FILE_VERSION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + FILE -> Known.FILE + FILE_VERSION -> Known.FILE_VERSION + else -> throw ImageKitInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** An object with details of the file version. */ + class VersionInfo + private constructor( + private val id: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, name, mutableMapOf()) + + /** + * Unique identifier of the file version. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * Name of the file version. + * + * @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") + + /** + * 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 [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [VersionInfo]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VersionInfo]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(versionInfo: VersionInfo) = apply { + id = versionInfo.id + name = versionInfo.name + additionalProperties = versionInfo.additionalProperties.toMutableMap() + } + + /** Unique identifier of the file version. */ + 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 } + + /** Name of the file version. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [VersionInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VersionInfo = VersionInfo(id, name, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): VersionInfo = apply { + if (validated) { + return@apply + } + + id() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VersionInfo && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VersionInfo{id=$id, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is File && + aiTags == other.aiTags && + createdAt == other.createdAt && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + description == other.description && + fileId == other.fileId && + filePath == other.filePath && + fileType == other.fileType && + hasAlpha == other.hasAlpha && + height == other.height && + isPrivateFile == other.isPrivateFile && + isPublished == other.isPublished && + mime == other.mime && + name == other.name && + size == other.size && + tags == other.tags && + thumbnail == other.thumbnail && + type == other.type && + updatedAt == other.updatedAt && + url == other.url && + versionInfo == other.versionInfo && + width == other.width && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aiTags, + createdAt, + customCoordinates, + customMetadata, + description, + fileId, + filePath, + fileType, + hasAlpha, + height, + isPrivateFile, + isPublished, + mime, + name, + size, + tags, + thumbnail, + type, + updatedAt, + url, + versionInfo, + width, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "File{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, fileId=$fileId, filePath=$filePath, fileType=$fileType, hasAlpha=$hasAlpha, height=$height, isPrivateFile=$isPrivateFile, isPublished=$isPublished, mime=$mime, name=$name, size=$size, tags=$tags, thumbnail=$thumbnail, type=$type, updatedAt=$updatedAt, url=$url, versionInfo=$versionInfo, width=$width, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyParams.kt new file mode 100644 index 00000000..7fb1d9df --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyParams.kt @@ -0,0 +1,602 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * This will copy a file from one folder to another. + * + * Note: If any file at the destination has the same name as the source file, then the source file + * and its versions (if `includeFileVersions` is set to true) will be appended to the destination + * file version history. + */ +class FileCopyParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Full path to the folder you want to copy the above file into. + * + * @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 destinationPath(): String = body.destinationPath() + + /** + * The full path of the file you want to copy. + * + * @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 sourceFilePath(): String = body.sourceFilePath() + + /** + * Option to copy all versions of a file. By default, only the current version of the file is + * copied. When set to true, all versions of the file will be copied. Default value - `false`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun includeFileVersions(): Optional = body.includeFileVersions() + + /** + * Returns the raw JSON value of [destinationPath]. + * + * Unlike [destinationPath], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _destinationPath(): JsonField = body._destinationPath() + + /** + * Returns the raw JSON value of [sourceFilePath]. + * + * Unlike [sourceFilePath], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _sourceFilePath(): JsonField = body._sourceFilePath() + + /** + * Returns the raw JSON value of [includeFileVersions]. + * + * Unlike [includeFileVersions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _includeFileVersions(): JsonField = body._includeFileVersions() + + 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 [FileCopyParams]. + * + * The following fields are required: + * ```java + * .destinationPath() + * .sourceFilePath() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileCopyParams]. */ + 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(fileCopyParams: FileCopyParams) = apply { + body = fileCopyParams.body.toBuilder() + additionalHeaders = fileCopyParams.additionalHeaders.toBuilder() + additionalQueryParams = fileCopyParams.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: + * - [destinationPath] + * - [sourceFilePath] + * - [includeFileVersions] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Full path to the folder you want to copy the above file into. */ + fun destinationPath(destinationPath: String) = apply { + body.destinationPath(destinationPath) + } + + /** + * Sets [Builder.destinationPath] to an arbitrary JSON value. + * + * You should usually call [Builder.destinationPath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun destinationPath(destinationPath: JsonField) = apply { + body.destinationPath(destinationPath) + } + + /** The full path of the file you want to copy. */ + fun sourceFilePath(sourceFilePath: String) = apply { body.sourceFilePath(sourceFilePath) } + + /** + * Sets [Builder.sourceFilePath] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceFilePath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceFilePath(sourceFilePath: JsonField) = apply { + body.sourceFilePath(sourceFilePath) + } + + /** + * Option to copy all versions of a file. By default, only the current version of the file + * is copied. When set to true, all versions of the file will be copied. Default value - + * `false`. + */ + fun includeFileVersions(includeFileVersions: Boolean) = apply { + body.includeFileVersions(includeFileVersions) + } + + /** + * Sets [Builder.includeFileVersions] to an arbitrary JSON value. + * + * You should usually call [Builder.includeFileVersions] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun includeFileVersions(includeFileVersions: JsonField) = apply { + body.includeFileVersions(includeFileVersions) + } + + 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 [FileCopyParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .destinationPath() + * .sourceFilePath() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FileCopyParams = + FileCopyParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val destinationPath: JsonField, + private val sourceFilePath: JsonField, + private val includeFileVersions: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("destinationPath") + @ExcludeMissing + destinationPath: JsonField = JsonMissing.of(), + @JsonProperty("sourceFilePath") + @ExcludeMissing + sourceFilePath: JsonField = JsonMissing.of(), + @JsonProperty("includeFileVersions") + @ExcludeMissing + includeFileVersions: JsonField = JsonMissing.of(), + ) : this(destinationPath, sourceFilePath, includeFileVersions, mutableMapOf()) + + /** + * Full path to the folder you want to copy the above file into. + * + * @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 destinationPath(): String = destinationPath.getRequired("destinationPath") + + /** + * The full path of the file you want to copy. + * + * @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 sourceFilePath(): String = sourceFilePath.getRequired("sourceFilePath") + + /** + * Option to copy all versions of a file. By default, only the current version of the file + * is copied. When set to true, all versions of the file will be copied. Default value - + * `false`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun includeFileVersions(): Optional = + includeFileVersions.getOptional("includeFileVersions") + + /** + * Returns the raw JSON value of [destinationPath]. + * + * Unlike [destinationPath], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("destinationPath") + @ExcludeMissing + fun _destinationPath(): JsonField = destinationPath + + /** + * Returns the raw JSON value of [sourceFilePath]. + * + * Unlike [sourceFilePath], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sourceFilePath") + @ExcludeMissing + fun _sourceFilePath(): JsonField = sourceFilePath + + /** + * Returns the raw JSON value of [includeFileVersions]. + * + * Unlike [includeFileVersions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeFileVersions") + @ExcludeMissing + fun _includeFileVersions(): JsonField = includeFileVersions + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @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 + * .destinationPath() + * .sourceFilePath() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var destinationPath: JsonField? = null + private var sourceFilePath: JsonField? = null + private var includeFileVersions: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + destinationPath = body.destinationPath + sourceFilePath = body.sourceFilePath + includeFileVersions = body.includeFileVersions + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Full path to the folder you want to copy the above file into. */ + fun destinationPath(destinationPath: String) = + destinationPath(JsonField.of(destinationPath)) + + /** + * Sets [Builder.destinationPath] to an arbitrary JSON value. + * + * You should usually call [Builder.destinationPath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun destinationPath(destinationPath: JsonField) = apply { + this.destinationPath = destinationPath + } + + /** The full path of the file you want to copy. */ + fun sourceFilePath(sourceFilePath: String) = + sourceFilePath(JsonField.of(sourceFilePath)) + + /** + * Sets [Builder.sourceFilePath] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceFilePath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceFilePath(sourceFilePath: JsonField) = apply { + this.sourceFilePath = sourceFilePath + } + + /** + * Option to copy all versions of a file. By default, only the current version of the + * file is copied. When set to true, all versions of the file will be copied. Default + * value - `false`. + */ + fun includeFileVersions(includeFileVersions: Boolean) = + includeFileVersions(JsonField.of(includeFileVersions)) + + /** + * Sets [Builder.includeFileVersions] to an arbitrary JSON value. + * + * You should usually call [Builder.includeFileVersions] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeFileVersions(includeFileVersions: JsonField) = apply { + this.includeFileVersions = includeFileVersions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .destinationPath() + * .sourceFilePath() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("destinationPath", destinationPath), + checkRequired("sourceFilePath", sourceFilePath), + includeFileVersions, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + destinationPath() + sourceFilePath() + includeFileVersions() + 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 (destinationPath.asKnown().isPresent) 1 else 0) + + (if (sourceFilePath.asKnown().isPresent) 1 else 0) + + (if (includeFileVersions.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + destinationPath == other.destinationPath && + sourceFilePath == other.sourceFilePath && + includeFileVersions == other.includeFileVersions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(destinationPath, sourceFilePath, includeFileVersions, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{destinationPath=$destinationPath, sourceFilePath=$sourceFilePath, includeFileVersions=$includeFileVersions, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FileCopyParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FileCopyParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyResponse.kt new file mode 100644 index 00000000..b3b4affb --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyResponse.kt @@ -0,0 +1,112 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects + +class FileCopyResponse +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FileCopyResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileCopyResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fileCopyResponse: FileCopyResponse) = apply { + additionalProperties = fileCopyResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FileCopyResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FileCopyResponse = FileCopyResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): FileCopyResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FileCopyResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "FileCopyResponse{additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileDeleteParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileDeleteParams.kt new file mode 100644 index 00000000..16ae1104 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileDeleteParams.kt @@ -0,0 +1,234 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * This API deletes the file and all its file versions permanently. + * + * Note: If a file or specific transformation has been requested in the past, then the response is + * cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API. + */ +class FileDeleteParams +private constructor( + private val fileId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun fileId(): Optional = Optional.ofNullable(fileId) + + /** 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(): FileDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [FileDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileDeleteParams]. */ + class Builder internal constructor() { + + private var fileId: 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(fileDeleteParams: FileDeleteParams) = apply { + fileId = fileDeleteParams.fileId + additionalHeaders = fileDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = fileDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = fileDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun fileId(fileId: String?) = apply { this.fileId = fileId } + + /** Alias for calling [Builder.fileId] with `fileId.orElse(null)`. */ + fun fileId(fileId: Optional) = fileId(fileId.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 [FileDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FileDeleteParams = + FileDeleteParams( + fileId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> fileId ?: "" + 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 FileDeleteParams && + fileId == other.fileId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(fileId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "FileDeleteParams{fileId=$fileId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetParams.kt new file mode 100644 index 00000000..e5a88219 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.imagekit.api.core.Params +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** This API returns an object with details or attributes about the current version of the file. */ +class FileGetParams +private constructor( + private val fileId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun fileId(): Optional = Optional.ofNullable(fileId) + + /** 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(): FileGetParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [FileGetParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileGetParams]. */ + class Builder internal constructor() { + + private var fileId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(fileGetParams: FileGetParams) = apply { + fileId = fileGetParams.fileId + additionalHeaders = fileGetParams.additionalHeaders.toBuilder() + additionalQueryParams = fileGetParams.additionalQueryParams.toBuilder() + } + + fun fileId(fileId: String?) = apply { this.fileId = fileId } + + /** Alias for calling [Builder.fileId] with `fileId.orElse(null)`. */ + fun fileId(fileId: Optional) = fileId(fileId.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 [FileGetParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FileGetParams = + FileGetParams(fileId, additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> fileId ?: "" + 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 FileGetParams && + fileId == other.fileId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(fileId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FileGetParams{fileId=$fileId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveParams.kt new file mode 100644 index 00000000..f4e3c64a --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveParams.kt @@ -0,0 +1,512 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects + +/** + * This will move a file and all its versions from one folder to another. + * + * Note: If any file at the destination has the same name as the source file, then the source file + * and its versions will be appended to the destination file. + */ +class FileMoveParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Full path to the folder you want to move the above file into. + * + * @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 destinationPath(): String = body.destinationPath() + + /** + * The full path of the file you want to move. + * + * @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 sourceFilePath(): String = body.sourceFilePath() + + /** + * Returns the raw JSON value of [destinationPath]. + * + * Unlike [destinationPath], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _destinationPath(): JsonField = body._destinationPath() + + /** + * Returns the raw JSON value of [sourceFilePath]. + * + * Unlike [sourceFilePath], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _sourceFilePath(): JsonField = body._sourceFilePath() + + 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 [FileMoveParams]. + * + * The following fields are required: + * ```java + * .destinationPath() + * .sourceFilePath() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileMoveParams]. */ + 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(fileMoveParams: FileMoveParams) = apply { + body = fileMoveParams.body.toBuilder() + additionalHeaders = fileMoveParams.additionalHeaders.toBuilder() + additionalQueryParams = fileMoveParams.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: + * - [destinationPath] + * - [sourceFilePath] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Full path to the folder you want to move the above file into. */ + fun destinationPath(destinationPath: String) = apply { + body.destinationPath(destinationPath) + } + + /** + * Sets [Builder.destinationPath] to an arbitrary JSON value. + * + * You should usually call [Builder.destinationPath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun destinationPath(destinationPath: JsonField) = apply { + body.destinationPath(destinationPath) + } + + /** The full path of the file you want to move. */ + fun sourceFilePath(sourceFilePath: String) = apply { body.sourceFilePath(sourceFilePath) } + + /** + * Sets [Builder.sourceFilePath] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceFilePath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceFilePath(sourceFilePath: JsonField) = apply { + body.sourceFilePath(sourceFilePath) + } + + 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 [FileMoveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .destinationPath() + * .sourceFilePath() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FileMoveParams = + FileMoveParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val destinationPath: JsonField, + private val sourceFilePath: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("destinationPath") + @ExcludeMissing + destinationPath: JsonField = JsonMissing.of(), + @JsonProperty("sourceFilePath") + @ExcludeMissing + sourceFilePath: JsonField = JsonMissing.of(), + ) : this(destinationPath, sourceFilePath, mutableMapOf()) + + /** + * Full path to the folder you want to move the above file into. + * + * @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 destinationPath(): String = destinationPath.getRequired("destinationPath") + + /** + * The full path of the file you want to move. + * + * @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 sourceFilePath(): String = sourceFilePath.getRequired("sourceFilePath") + + /** + * Returns the raw JSON value of [destinationPath]. + * + * Unlike [destinationPath], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("destinationPath") + @ExcludeMissing + fun _destinationPath(): JsonField = destinationPath + + /** + * Returns the raw JSON value of [sourceFilePath]. + * + * Unlike [sourceFilePath], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sourceFilePath") + @ExcludeMissing + fun _sourceFilePath(): JsonField = sourceFilePath + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @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 + * .destinationPath() + * .sourceFilePath() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var destinationPath: JsonField? = null + private var sourceFilePath: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + destinationPath = body.destinationPath + sourceFilePath = body.sourceFilePath + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Full path to the folder you want to move the above file into. */ + fun destinationPath(destinationPath: String) = + destinationPath(JsonField.of(destinationPath)) + + /** + * Sets [Builder.destinationPath] to an arbitrary JSON value. + * + * You should usually call [Builder.destinationPath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun destinationPath(destinationPath: JsonField) = apply { + this.destinationPath = destinationPath + } + + /** The full path of the file you want to move. */ + fun sourceFilePath(sourceFilePath: String) = + sourceFilePath(JsonField.of(sourceFilePath)) + + /** + * Sets [Builder.sourceFilePath] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceFilePath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceFilePath(sourceFilePath: JsonField) = apply { + this.sourceFilePath = sourceFilePath + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .destinationPath() + * .sourceFilePath() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("destinationPath", destinationPath), + checkRequired("sourceFilePath", sourceFilePath), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + destinationPath() + sourceFilePath() + 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 (destinationPath.asKnown().isPresent) 1 else 0) + + (if (sourceFilePath.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + destinationPath == other.destinationPath && + sourceFilePath == other.sourceFilePath && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(destinationPath, sourceFilePath, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{destinationPath=$destinationPath, sourceFilePath=$sourceFilePath, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FileMoveParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FileMoveParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveResponse.kt new file mode 100644 index 00000000..726f9e26 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveResponse.kt @@ -0,0 +1,112 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects + +class FileMoveResponse +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FileMoveResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileMoveResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fileMoveResponse: FileMoveResponse) = apply { + additionalProperties = fileMoveResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FileMoveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FileMoveResponse = FileMoveResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): FileMoveResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FileMoveResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "FileMoveResponse{additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameParams.kt new file mode 100644 index 00000000..2b7b4b57 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameParams.kt @@ -0,0 +1,649 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * You can rename an already existing file in the media library using rename file API. This + * operation would rename all file versions of the file. + * + * Note: The old URLs will stop working. The file/file version URLs cached on CDN will continue to + * work unless a purge is requested. + */ +class FileRenameParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The full path of the file you want to rename. + * + * @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 filePath(): String = body.filePath() + + /** + * The new name of the file. A filename can contain: + * + * Alphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, marks, and numerals + * in other languages). Special Characters: `.`, `_`, and `-`. + * + * Any other character, including space, will be replaced by `_`. + * + * @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 newFileName(): String = body.newFileName() + + /** + * Option to purge cache for the old file and its versions' URLs. + * + * When set to true, it will internally issue a purge cache request on CDN to remove cached + * content of old file and its versions. This purge request is counted against your monthly + * purge quota. + * + * Note: If the old file were accessible at `https://ik.imagekit.io/demo/old-filename.jpg`, a + * purge cache request would be issued against `https://ik.imagekit.io/demo/old-filename.jpg*` + * (with a wildcard at the end). It will remove the file and its versions' URLs and any + * transformations made using query parameters on this file or its versions. However, the cache + * for file transformations made using path parameters will persist. You can purge them using + * the purge API. For more details, refer to the purge API documentation. + * + * Default value - `false` + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun purgeCache(): Optional = body.purgeCache() + + /** + * Returns the raw JSON value of [filePath]. + * + * Unlike [filePath], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _filePath(): JsonField = body._filePath() + + /** + * Returns the raw JSON value of [newFileName]. + * + * Unlike [newFileName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _newFileName(): JsonField = body._newFileName() + + /** + * Returns the raw JSON value of [purgeCache]. + * + * Unlike [purgeCache], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _purgeCache(): JsonField = body._purgeCache() + + 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 [FileRenameParams]. + * + * The following fields are required: + * ```java + * .filePath() + * .newFileName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileRenameParams]. */ + 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(fileRenameParams: FileRenameParams) = apply { + body = fileRenameParams.body.toBuilder() + additionalHeaders = fileRenameParams.additionalHeaders.toBuilder() + additionalQueryParams = fileRenameParams.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: + * - [filePath] + * - [newFileName] + * - [purgeCache] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The full path of the file you want to rename. */ + fun filePath(filePath: String) = apply { body.filePath(filePath) } + + /** + * Sets [Builder.filePath] to an arbitrary JSON value. + * + * You should usually call [Builder.filePath] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filePath(filePath: JsonField) = apply { body.filePath(filePath) } + + /** + * The new name of the file. A filename can contain: + * + * Alphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, marks, and + * numerals in other languages). Special Characters: `.`, `_`, and `-`. + * + * Any other character, including space, will be replaced by `_`. + */ + fun newFileName(newFileName: String) = apply { body.newFileName(newFileName) } + + /** + * Sets [Builder.newFileName] to an arbitrary JSON value. + * + * You should usually call [Builder.newFileName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun newFileName(newFileName: JsonField) = apply { body.newFileName(newFileName) } + + /** + * Option to purge cache for the old file and its versions' URLs. + * + * When set to true, it will internally issue a purge cache request on CDN to remove cached + * content of old file and its versions. This purge request is counted against your monthly + * purge quota. + * + * Note: If the old file were accessible at `https://ik.imagekit.io/demo/old-filename.jpg`, + * a purge cache request would be issued against + * `https://ik.imagekit.io/demo/old-filename.jpg*` (with a wildcard at the end). It will + * remove the file and its versions' URLs and any transformations made using query + * parameters on this file or its versions. However, the cache for file transformations made + * using path parameters will persist. You can purge them using the purge API. For more + * details, refer to the purge API documentation. + * + * Default value - `false` + */ + fun purgeCache(purgeCache: Boolean) = apply { body.purgeCache(purgeCache) } + + /** + * Sets [Builder.purgeCache] to an arbitrary JSON value. + * + * You should usually call [Builder.purgeCache] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun purgeCache(purgeCache: JsonField) = apply { body.purgeCache(purgeCache) } + + 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 [FileRenameParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .filePath() + * .newFileName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FileRenameParams = + FileRenameParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val filePath: JsonField, + private val newFileName: JsonField, + private val purgeCache: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filePath") + @ExcludeMissing + filePath: JsonField = JsonMissing.of(), + @JsonProperty("newFileName") + @ExcludeMissing + newFileName: JsonField = JsonMissing.of(), + @JsonProperty("purgeCache") + @ExcludeMissing + purgeCache: JsonField = JsonMissing.of(), + ) : this(filePath, newFileName, purgeCache, mutableMapOf()) + + /** + * The full path of the file you want to rename. + * + * @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 filePath(): String = filePath.getRequired("filePath") + + /** + * The new name of the file. A filename can contain: + * + * Alphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, marks, and + * numerals in other languages). Special Characters: `.`, `_`, and `-`. + * + * Any other character, including space, will be replaced by `_`. + * + * @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 newFileName(): String = newFileName.getRequired("newFileName") + + /** + * Option to purge cache for the old file and its versions' URLs. + * + * When set to true, it will internally issue a purge cache request on CDN to remove cached + * content of old file and its versions. This purge request is counted against your monthly + * purge quota. + * + * Note: If the old file were accessible at `https://ik.imagekit.io/demo/old-filename.jpg`, + * a purge cache request would be issued against + * `https://ik.imagekit.io/demo/old-filename.jpg*` (with a wildcard at the end). It will + * remove the file and its versions' URLs and any transformations made using query + * parameters on this file or its versions. However, the cache for file transformations made + * using path parameters will persist. You can purge them using the purge API. For more + * details, refer to the purge API documentation. + * + * Default value - `false` + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun purgeCache(): Optional = purgeCache.getOptional("purgeCache") + + /** + * Returns the raw JSON value of [filePath]. + * + * Unlike [filePath], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filePath") @ExcludeMissing fun _filePath(): JsonField = filePath + + /** + * Returns the raw JSON value of [newFileName]. + * + * Unlike [newFileName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("newFileName") + @ExcludeMissing + fun _newFileName(): JsonField = newFileName + + /** + * Returns the raw JSON value of [purgeCache]. + * + * Unlike [purgeCache], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("purgeCache") + @ExcludeMissing + fun _purgeCache(): JsonField = purgeCache + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @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 + * .filePath() + * .newFileName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var filePath: JsonField? = null + private var newFileName: JsonField? = null + private var purgeCache: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + filePath = body.filePath + newFileName = body.newFileName + purgeCache = body.purgeCache + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The full path of the file you want to rename. */ + fun filePath(filePath: String) = filePath(JsonField.of(filePath)) + + /** + * Sets [Builder.filePath] to an arbitrary JSON value. + * + * You should usually call [Builder.filePath] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun filePath(filePath: JsonField) = apply { this.filePath = filePath } + + /** + * The new name of the file. A filename can contain: + * + * Alphanumeric Characters: `a-z`, `A-Z`, `0-9` (including Unicode letters, marks, and + * numerals in other languages). Special Characters: `.`, `_`, and `-`. + * + * Any other character, including space, will be replaced by `_`. + */ + fun newFileName(newFileName: String) = newFileName(JsonField.of(newFileName)) + + /** + * Sets [Builder.newFileName] to an arbitrary JSON value. + * + * You should usually call [Builder.newFileName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun newFileName(newFileName: JsonField) = apply { + this.newFileName = newFileName + } + + /** + * Option to purge cache for the old file and its versions' URLs. + * + * When set to true, it will internally issue a purge cache request on CDN to remove + * cached content of old file and its versions. This purge request is counted against + * your monthly purge quota. + * + * Note: If the old file were accessible at + * `https://ik.imagekit.io/demo/old-filename.jpg`, a purge cache request would be issued + * against `https://ik.imagekit.io/demo/old-filename.jpg*` (with a wildcard at the end). + * It will remove the file and its versions' URLs and any transformations made using + * query parameters on this file or its versions. However, the cache for file + * transformations made using path parameters will persist. You can purge them using the + * purge API. For more details, refer to the purge API documentation. + * + * Default value - `false` + */ + fun purgeCache(purgeCache: Boolean) = purgeCache(JsonField.of(purgeCache)) + + /** + * Sets [Builder.purgeCache] to an arbitrary JSON value. + * + * You should usually call [Builder.purgeCache] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun purgeCache(purgeCache: JsonField) = apply { this.purgeCache = purgeCache } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .filePath() + * .newFileName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("filePath", filePath), + checkRequired("newFileName", newFileName), + purgeCache, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + filePath() + newFileName() + purgeCache() + 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 (filePath.asKnown().isPresent) 1 else 0) + + (if (newFileName.asKnown().isPresent) 1 else 0) + + (if (purgeCache.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + filePath == other.filePath && + newFileName == other.newFileName && + purgeCache == other.purgeCache && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(filePath, newFileName, purgeCache, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{filePath=$filePath, newFileName=$newFileName, purgeCache=$purgeCache, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FileRenameParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FileRenameParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameResponse.kt new file mode 100644 index 00000000..3f9dc4c5 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameResponse.kt @@ -0,0 +1,166 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +class FileRenameResponse +private constructor( + private val purgeRequestId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("purgeRequestId") + @ExcludeMissing + purgeRequestId: JsonField = JsonMissing.of() + ) : this(purgeRequestId, mutableMapOf()) + + /** + * Unique identifier of the purge request. This can be used to check the status of the purge + * request. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun purgeRequestId(): Optional = purgeRequestId.getOptional("purgeRequestId") + + /** + * Returns the raw JSON value of [purgeRequestId]. + * + * Unlike [purgeRequestId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("purgeRequestId") + @ExcludeMissing + fun _purgeRequestId(): JsonField = purgeRequestId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FileRenameResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileRenameResponse]. */ + class Builder internal constructor() { + + private var purgeRequestId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fileRenameResponse: FileRenameResponse) = apply { + purgeRequestId = fileRenameResponse.purgeRequestId + additionalProperties = fileRenameResponse.additionalProperties.toMutableMap() + } + + /** + * Unique identifier of the purge request. This can be used to check the status of the purge + * request. + */ + fun purgeRequestId(purgeRequestId: String) = purgeRequestId(JsonField.of(purgeRequestId)) + + /** + * Sets [Builder.purgeRequestId] to an arbitrary JSON value. + * + * You should usually call [Builder.purgeRequestId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun purgeRequestId(purgeRequestId: JsonField) = apply { + this.purgeRequestId = purgeRequestId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FileRenameResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FileRenameResponse = + FileRenameResponse(purgeRequestId, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): FileRenameResponse = apply { + if (validated) { + return@apply + } + + purgeRequestId() + 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 (purgeRequestId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FileRenameResponse && + purgeRequestId == other.purgeRequestId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(purgeRequestId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FileRenameResponse{purgeRequestId=$purgeRequestId, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt new file mode 100644 index 00000000..2f8a39b0 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt @@ -0,0 +1,2759 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.allMaxBy +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * This API updates the details or attributes of the current version of the file. You can update + * `tags`, `customCoordinates`, `customMetadata`, publication status, remove existing `AITags` and + * apply extensions using this API. + */ +class FileUpdateParams +private constructor( + private val fileId: String?, + private val update: Update?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun fileId(): Optional = Optional.ofNullable(fileId) + + fun update(): Optional = Optional.ofNullable(update) + + /** 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(): FileUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [FileUpdateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileUpdateParams]. */ + class Builder internal constructor() { + + private var fileId: String? = null + private var update: Update? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(fileUpdateParams: FileUpdateParams) = apply { + fileId = fileUpdateParams.fileId + update = fileUpdateParams.update + additionalHeaders = fileUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = fileUpdateParams.additionalQueryParams.toBuilder() + } + + fun fileId(fileId: String?) = apply { this.fileId = fileId } + + /** Alias for calling [Builder.fileId] with `fileId.orElse(null)`. */ + fun fileId(fileId: Optional) = fileId(fileId.getOrNull()) + + fun update(update: Update?) = apply { this.update = update } + + /** Alias for calling [Builder.update] with `update.orElse(null)`. */ + fun update(update: Optional) = update(update.getOrNull()) + + /** Alias for calling [update] with `Update.ofFileDetails(fileDetails)`. */ + fun update(fileDetails: Update.UpdateFileDetails) = + update(Update.ofFileDetails(fileDetails)) + + /** + * Alias for calling [update] with + * `Update.ofChangePublicationStatus(changePublicationStatus)`. + */ + fun update(changePublicationStatus: Update.ChangePublicationStatus) = + update(Update.ofChangePublicationStatus(changePublicationStatus)) + + 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 [FileUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FileUpdateParams = + FileUpdateParams( + fileId, + update, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Optional = Optional.ofNullable(update) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> fileId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + @JsonDeserialize(using = Update.Deserializer::class) + @JsonSerialize(using = Update.Serializer::class) + class Update + private constructor( + private val fileDetails: UpdateFileDetails? = null, + private val changePublicationStatus: ChangePublicationStatus? = null, + private val _json: JsonValue? = null, + ) { + + fun fileDetails(): Optional = Optional.ofNullable(fileDetails) + + fun changePublicationStatus(): Optional = + Optional.ofNullable(changePublicationStatus) + + fun isFileDetails(): Boolean = fileDetails != null + + fun isChangePublicationStatus(): Boolean = changePublicationStatus != null + + fun asFileDetails(): UpdateFileDetails = fileDetails.getOrThrow("fileDetails") + + fun asChangePublicationStatus(): ChangePublicationStatus = + changePublicationStatus.getOrThrow("changePublicationStatus") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + fileDetails != null -> visitor.visitFileDetails(fileDetails) + changePublicationStatus != null -> + visitor.visitChangePublicationStatus(changePublicationStatus) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Update = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitFileDetails(fileDetails: UpdateFileDetails) { + fileDetails.validate() + } + + override fun visitChangePublicationStatus( + changePublicationStatus: ChangePublicationStatus + ) { + changePublicationStatus.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitFileDetails(fileDetails: UpdateFileDetails) = + fileDetails.validity() + + override fun visitChangePublicationStatus( + changePublicationStatus: ChangePublicationStatus + ) = changePublicationStatus.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Update && + fileDetails == other.fileDetails && + changePublicationStatus == other.changePublicationStatus + } + + override fun hashCode(): Int = Objects.hash(fileDetails, changePublicationStatus) + + override fun toString(): String = + when { + fileDetails != null -> "Update{fileDetails=$fileDetails}" + changePublicationStatus != null -> + "Update{changePublicationStatus=$changePublicationStatus}" + _json != null -> "Update{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Update") + } + + companion object { + + @JvmStatic + fun ofFileDetails(fileDetails: UpdateFileDetails) = Update(fileDetails = fileDetails) + + @JvmStatic + fun ofChangePublicationStatus(changePublicationStatus: ChangePublicationStatus) = + Update(changePublicationStatus = changePublicationStatus) + } + + /** An interface that defines how to map each variant of [Update] to a value of type [T]. */ + interface Visitor { + + fun visitFileDetails(fileDetails: UpdateFileDetails): T + + fun visitChangePublicationStatus(changePublicationStatus: ChangePublicationStatus): T + + /** + * Maps an unknown variant of [Update] to a value of type [T]. + * + * An instance of [Update] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Update: $json") + } + } + + internal class Deserializer : BaseDeserializer(Update::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Update { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Update(fileDetails = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Update(changePublicationStatus = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Update(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Update::class) { + + override fun serialize( + value: Update, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.fileDetails != null -> generator.writeObject(value.fileDetails) + value.changePublicationStatus != null -> + generator.writeObject(value.changePublicationStatus) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Update") + } + } + } + + class UpdateFileDetails + private constructor( + private val customCoordinates: JsonField, + private val customMetadata: JsonField, + private val description: JsonField, + private val extensions: JsonField>, + private val removeAiTags: JsonField, + private val tags: JsonField>, + private val webhookUrl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("customCoordinates") + @ExcludeMissing + customCoordinates: JsonField = JsonMissing.of(), + @JsonProperty("customMetadata") + @ExcludeMissing + customMetadata: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("extensions") + @ExcludeMissing + extensions: JsonField> = JsonMissing.of(), + @JsonProperty("removeAITags") + @ExcludeMissing + removeAiTags: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + tags: JsonField> = JsonMissing.of(), + @JsonProperty("webhookUrl") + @ExcludeMissing + webhookUrl: JsonField = JsonMissing.of(), + ) : this( + customCoordinates, + customMetadata, + description, + extensions, + removeAiTags, + tags, + webhookUrl, + mutableMapOf(), + ) + + /** + * Define an important area in the image in the format `x,y,width,height` e.g. + * `10,10,100,100`. Send `null` to unset this value. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun customCoordinates(): Optional = + customCoordinates.getOptional("customCoordinates") + + /** + * A key-value data to be associated with the asset. To unset a key, send `null` value + * for that key. Before setting any custom metadata on an asset you have to create the + * field using custom metadata fields API. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun customMetadata(): Optional = + customMetadata.getOptional("customMetadata") + + /** + * Optional text to describe the contents of the file. + * + * @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") + + /** + * Array of extensions to be applied to the asset. Each extension can be configured with + * specific parameters based on the extension type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun extensions(): Optional> = extensions.getOptional("extensions") + + /** + * An array of AITags associated with the file that you want to remove, e.g. `["car", + * "vehicle", "motorsports"]`. + * + * If you want to remove all AITags associated with the file, send a string - "all". + * + * Note: The remove operation for `AITags` executes before any of the `extensions` are + * processed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun removeAiTags(): Optional = removeAiTags.getOptional("removeAITags") + + /** + * An array of tags associated with the file, such as `["tag1", "tag2"]`. Send `null` to + * unset all tags associated with the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tags(): Optional> = tags.getOptional("tags") + + /** + * The final status of extensions after they have completed execution will be delivered + * to this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun webhookUrl(): Optional = webhookUrl.getOptional("webhookUrl") + + /** + * Returns the raw JSON value of [customCoordinates]. + * + * Unlike [customCoordinates], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("customCoordinates") + @ExcludeMissing + fun _customCoordinates(): JsonField = customCoordinates + + /** + * Returns the raw JSON value of [customMetadata]. + * + * Unlike [customMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): JsonField = customMetadata + + /** + * 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 [extensions]. + * + * Unlike [extensions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("extensions") + @ExcludeMissing + fun _extensions(): JsonField> = extensions + + /** + * Returns the raw JSON value of [removeAiTags]. + * + * Unlike [removeAiTags], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("removeAITags") + @ExcludeMissing + fun _removeAiTags(): JsonField = removeAiTags + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + + /** + * Returns the raw JSON value of [webhookUrl]. + * + * Unlike [webhookUrl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("webhookUrl") + @ExcludeMissing + fun _webhookUrl(): JsonField = webhookUrl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UpdateFileDetails]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UpdateFileDetails]. */ + class Builder internal constructor() { + + private var customCoordinates: JsonField = JsonMissing.of() + private var customMetadata: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var extensions: JsonField>? = null + private var removeAiTags: JsonField = JsonMissing.of() + private var tags: JsonField>? = null + private var webhookUrl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(updateFileDetails: UpdateFileDetails) = apply { + customCoordinates = updateFileDetails.customCoordinates + customMetadata = updateFileDetails.customMetadata + description = updateFileDetails.description + extensions = updateFileDetails.extensions.map { it.toMutableList() } + removeAiTags = updateFileDetails.removeAiTags + tags = updateFileDetails.tags.map { it.toMutableList() } + webhookUrl = updateFileDetails.webhookUrl + additionalProperties = updateFileDetails.additionalProperties.toMutableMap() + } + + /** + * Define an important area in the image in the format `x,y,width,height` e.g. + * `10,10,100,100`. Send `null` to unset this value. + */ + fun customCoordinates(customCoordinates: String?) = + customCoordinates(JsonField.ofNullable(customCoordinates)) + + /** + * Alias for calling [Builder.customCoordinates] with + * `customCoordinates.orElse(null)`. + */ + fun customCoordinates(customCoordinates: Optional) = + customCoordinates(customCoordinates.getOrNull()) + + /** + * Sets [Builder.customCoordinates] to an arbitrary JSON value. + * + * You should usually call [Builder.customCoordinates] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun customCoordinates(customCoordinates: JsonField) = apply { + this.customCoordinates = customCoordinates + } + + /** + * A key-value data to be associated with the asset. To unset a key, send `null` + * value for that key. Before setting any custom metadata on an asset you have to + * create the field using custom metadata fields API. + */ + fun customMetadata(customMetadata: CustomMetadata) = + customMetadata(JsonField.of(customMetadata)) + + /** + * Sets [Builder.customMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.customMetadata] with a well-typed + * [CustomMetadata] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun customMetadata(customMetadata: JsonField) = apply { + this.customMetadata = customMetadata + } + + /** Optional text to describe the contents of the file. */ + 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 + } + + /** + * Array of extensions to be applied to the asset. Each extension can be configured + * with specific parameters based on the extension type. + */ + fun extensions(extensions: List) = extensions(JsonField.of(extensions)) + + /** + * Sets [Builder.extensions] to an arbitrary JSON value. + * + * You should usually call [Builder.extensions] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun extensions(extensions: JsonField>) = apply { + this.extensions = extensions.map { it.toMutableList() } + } + + /** + * Adds a single [Extension] to [extensions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExtension(extension: Extension) = apply { + extensions = + (extensions ?: JsonField.of(mutableListOf())).also { + checkKnown("extensions", it).add(extension) + } + } + + /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ + fun addExtension(removeBg: Extension.RemoveBg) = + addExtension(Extension.ofRemoveBg(removeBg)) + + /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = + addExtension(Extension.ofAutoTagging(autoTagging)) + + /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ + fun addExtensionAiAutoDescription() = addExtension(Extension.ofAiAutoDescription()) + + /** + * An array of AITags associated with the file that you want to remove, e.g. + * `["car", "vehicle", "motorsports"]`. + * + * If you want to remove all AITags associated with the file, send a string - "all". + * + * Note: The remove operation for `AITags` executes before any of the `extensions` + * are processed. + */ + fun removeAiTags(removeAiTags: RemoveAiTags) = + removeAiTags(JsonField.of(removeAiTags)) + + /** + * Sets [Builder.removeAiTags] to an arbitrary JSON value. + * + * You should usually call [Builder.removeAiTags] with a well-typed [RemoveAiTags] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun removeAiTags(removeAiTags: JsonField) = apply { + this.removeAiTags = removeAiTags + } + + /** Alias for calling [removeAiTags] with `RemoveAiTags.ofStrings(strings)`. */ + fun removeAiTagsOfStrings(strings: List) = + removeAiTags(RemoveAiTags.ofStrings(strings)) + + /** Alias for calling [removeAiTags] with `RemoveAiTags.ofAll()`. */ + fun removeAiTagsAll() = removeAiTags(RemoveAiTags.ofAll()) + + /** + * An array of tags associated with the file, such as `["tag1", "tag2"]`. Send + * `null` to unset all tags associated with the file. + */ + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } + + /** + * The final status of extensions after they have completed execution will be + * delivered to this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + */ + fun webhookUrl(webhookUrl: String) = webhookUrl(JsonField.of(webhookUrl)) + + /** + * Sets [Builder.webhookUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun webhookUrl(webhookUrl: JsonField) = apply { + this.webhookUrl = webhookUrl + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UpdateFileDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UpdateFileDetails = + UpdateFileDetails( + customCoordinates, + customMetadata, + description, + (extensions ?: JsonMissing.of()).map { it.toImmutable() }, + removeAiTags, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + webhookUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UpdateFileDetails = apply { + if (validated) { + return@apply + } + + customCoordinates() + customMetadata().ifPresent { it.validate() } + description() + extensions().ifPresent { it.forEach { it.validate() } } + removeAiTags().ifPresent { it.validate() } + tags() + webhookUrl() + 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 (customCoordinates.asKnown().isPresent) 1 else 0) + + (customMetadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (extensions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (removeAiTags.asKnown().getOrNull()?.validity() ?: 0) + + (tags.asKnown().getOrNull()?.size ?: 0) + + (if (webhookUrl.asKnown().isPresent) 1 else 0) + + /** + * A key-value data to be associated with the asset. To unset a key, send `null` value + * for that key. Before setting any custom metadata on an asset you have to create the + * field using custom metadata fields API. + */ + class CustomMetadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomMetadata]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customMetadata: CustomMetadata) = apply { + additionalProperties = customMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CustomMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomMetadata{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Extension.Deserializer::class) + @JsonSerialize(using = Extension.Serializer::class) + class Extension + private constructor( + private val removeBg: RemoveBg? = null, + private val autoTagging: AutoTaggingExtension? = null, + private val aiAutoDescription: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun removeBg(): Optional = Optional.ofNullable(removeBg) + + fun autoTagging(): Optional = Optional.ofNullable(autoTagging) + + fun aiAutoDescription(): Optional = + Optional.ofNullable(aiAutoDescription) + + fun isRemoveBg(): Boolean = removeBg != null + + fun isAutoTagging(): Boolean = autoTagging != null + + fun isAiAutoDescription(): Boolean = aiAutoDescription != null + + fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") + + fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") + + fun asAiAutoDescription(): JsonValue = + aiAutoDescription.getOrThrow("aiAutoDescription") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + removeBg != null -> visitor.visitRemoveBg(removeBg) + autoTagging != null -> visitor.visitAutoTagging(autoTagging) + aiAutoDescription != null -> + visitor.visitAiAutoDescription(aiAutoDescription) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Extension = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) { + removeBg.validate() + } + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { + autoTagging.validate() + } + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { + aiAutoDescription.let { + if ( + it != JsonValue.from(mapOf("name" to "ai-auto-description")) + ) { + throw ImageKitInvalidDataException( + "'aiAutoDescription' is invalid, received $it" + ) + } + } + } + } + ) + 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 = + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = + autoTagging.validity() + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = + aiAutoDescription.let { + if ( + it == JsonValue.from(mapOf("name" to "ai-auto-description")) + ) + 1 + else 0 + } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extension && + removeBg == other.removeBg && + autoTagging == other.autoTagging && + aiAutoDescription == other.aiAutoDescription + } + + override fun hashCode(): Int = + Objects.hash(removeBg, autoTagging, aiAutoDescription) + + override fun toString(): String = + when { + removeBg != null -> "Extension{removeBg=$removeBg}" + autoTagging != null -> "Extension{autoTagging=$autoTagging}" + aiAutoDescription != null -> + "Extension{aiAutoDescription=$aiAutoDescription}" + _json != null -> "Extension{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Extension") + } + + companion object { + + @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = Extension(removeBg = removeBg) + + @JvmStatic + fun ofAutoTagging(autoTagging: AutoTaggingExtension) = + Extension(autoTagging = autoTagging) + + @JvmStatic + fun ofAiAutoDescription() = + Extension( + aiAutoDescription = + JsonValue.from(mapOf("name" to "ai-auto-description")) + ) + } + + /** + * An interface that defines how to map each variant of [Extension] to a value of + * type [T]. + */ + interface Visitor { + + fun visitRemoveBg(removeBg: RemoveBg): T + + fun visitAutoTagging(autoTagging: AutoTaggingExtension): T + + fun visitAiAutoDescription(aiAutoDescription: JsonValue): T + + /** + * Maps an unknown variant of [Extension] to a value of type [T]. + * + * An instance of [Extension] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Extension: $json") + } + } + + internal class Deserializer : BaseDeserializer(Extension::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Extension { + val json = JsonValue.fromJsonNode(node) + val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() + + when (name) { + "remove-bg" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Extension(removeBg = it, _json = json) + } ?: Extension(_json = json) + } + "ai-auto-description" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Extension(aiAutoDescription = it, _json = json) } + ?.takeIf { it.isValid() } ?: Extension(_json = json) + } + } + + return tryDeserialize(node, jacksonTypeRef())?.let { + Extension(autoTagging = it, _json = json) + } ?: Extension(_json = json) + } + } + + internal class Serializer : BaseSerializer(Extension::class) { + + override fun serialize( + value: Extension, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.removeBg != null -> generator.writeObject(value.removeBg) + value.autoTagging != null -> generator.writeObject(value.autoTagging) + value.aiAutoDescription != null -> + generator.writeObject(value.aiAutoDescription) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Extension") + } + } + } + + class RemoveBg + private constructor( + private val name: JsonValue, + private val options: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + options: JsonField = JsonMissing.of(), + ) : this(name, options, mutableMapOf()) + + /** + * Specifies the background removal extension. + * + * Expected to always return the following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun options(): Optional = options.getOptional("options") + + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("options") + @ExcludeMissing + fun _options(): JsonField = options + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveBg]. */ + class Builder internal constructor() { + + private var name: JsonValue = JsonValue.from("remove-bg") + private var options: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(removeBg: RemoveBg) = apply { + name = removeBg.name + options = removeBg.options + additionalProperties = removeBg.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + fun options(options: Options) = options(JsonField.of(options)) + + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [Options] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun options(options: JsonField) = apply { this.options = options } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemoveBg]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemoveBg = + RemoveBg(name, options, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): RemoveBg = apply { + if (validated) { + return@apply + } + + _name().let { + if (it != JsonValue.from("remove-bg")) { + throw ImageKitInvalidDataException( + "'name' is invalid, received $it" + ) + } + } + options().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + name.let { if (it == JsonValue.from("remove-bg")) 1 else 0 } + + (options.asKnown().getOrNull()?.validity() ?: 0) + + class Options + private constructor( + private val addShadow: JsonField, + private val bgColor: JsonField, + private val bgImageUrl: JsonField, + private val semitransparency: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("add_shadow") + @ExcludeMissing + addShadow: JsonField = JsonMissing.of(), + @JsonProperty("bg_color") + @ExcludeMissing + bgColor: JsonField = JsonMissing.of(), + @JsonProperty("bg_image_url") + @ExcludeMissing + bgImageUrl: JsonField = JsonMissing.of(), + @JsonProperty("semitransparency") + @ExcludeMissing + semitransparency: JsonField = JsonMissing.of(), + ) : this(addShadow, bgColor, bgImageUrl, semitransparency, mutableMapOf()) + + /** + * Whether to add an artificial shadow to the result. Default is false. + * Note: Adding shadows is currently only supported for car photos. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun addShadow(): Optional = addShadow.getOptional("add_shadow") + + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") + * or color name (e.g., "green"). If this parameter is set, `bg_image_url` + * must be empty. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun bgColor(): Optional = bgColor.getOptional("bg_color") + + /** + * Sets a background image from a URL. If this parameter is set, `bg_color` + * must be empty. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun bgImageUrl(): Optional = bgImageUrl.getOptional("bg_image_url") + + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun semitransparency(): Optional = + semitransparency.getOptional("semitransparency") + + /** + * Returns the raw JSON value of [addShadow]. + * + * Unlike [addShadow], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_shadow") + @ExcludeMissing + fun _addShadow(): JsonField = addShadow + + /** + * Returns the raw JSON value of [bgColor]. + * + * Unlike [bgColor], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bg_color") + @ExcludeMissing + fun _bgColor(): JsonField = bgColor + + /** + * Returns the raw JSON value of [bgImageUrl]. + * + * Unlike [bgImageUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bg_image_url") + @ExcludeMissing + fun _bgImageUrl(): JsonField = bgImageUrl + + /** + * Returns the raw JSON value of [semitransparency]. + * + * Unlike [semitransparency], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("semitransparency") + @ExcludeMissing + fun _semitransparency(): JsonField = semitransparency + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Options]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Options]. */ + class Builder internal constructor() { + + private var addShadow: JsonField = JsonMissing.of() + private var bgColor: JsonField = JsonMissing.of() + private var bgImageUrl: JsonField = JsonMissing.of() + private var semitransparency: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(options: Options) = apply { + addShadow = options.addShadow + bgColor = options.bgColor + bgImageUrl = options.bgImageUrl + semitransparency = options.semitransparency + additionalProperties = options.additionalProperties.toMutableMap() + } + + /** + * Whether to add an artificial shadow to the result. Default is false. + * Note: Adding shadows is currently only supported for car photos. + */ + fun addShadow(addShadow: Boolean) = addShadow(JsonField.of(addShadow)) + + /** + * Sets [Builder.addShadow] to an arbitrary JSON value. + * + * You should usually call [Builder.addShadow] with a well-typed + * [Boolean] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun addShadow(addShadow: JsonField) = apply { + this.addShadow = addShadow + } + + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", + * "fff") or color name (e.g., "green"). If this parameter is set, + * `bg_image_url` must be empty. + */ + fun bgColor(bgColor: String) = bgColor(JsonField.of(bgColor)) + + /** + * Sets [Builder.bgColor] to an arbitrary JSON value. + * + * You should usually call [Builder.bgColor] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun bgColor(bgColor: JsonField) = apply { + this.bgColor = bgColor + } + + /** + * Sets a background image from a URL. If this parameter is set, + * `bg_color` must be empty. + */ + fun bgImageUrl(bgImageUrl: String) = + bgImageUrl(JsonField.of(bgImageUrl)) + + /** + * Sets [Builder.bgImageUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.bgImageUrl] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun bgImageUrl(bgImageUrl: JsonField) = apply { + this.bgImageUrl = bgImageUrl + } + + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + */ + fun semitransparency(semitransparency: Boolean) = + semitransparency(JsonField.of(semitransparency)) + + /** + * Sets [Builder.semitransparency] to an arbitrary JSON value. + * + * You should usually call [Builder.semitransparency] with a well-typed + * [Boolean] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun semitransparency(semitransparency: JsonField) = apply { + this.semitransparency = semitransparency + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Options]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): Options = + Options( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Options = apply { + if (validated) { + return@apply + } + + addShadow() + bgColor() + bgImageUrl() + semitransparency() + 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 (addShadow.asKnown().isPresent) 1 else 0) + + (if (bgColor.asKnown().isPresent) 1 else 0) + + (if (bgImageUrl.asKnown().isPresent) 1 else 0) + + (if (semitransparency.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Options && + addShadow == other.addShadow && + bgColor == other.bgColor && + bgImageUrl == other.bgImageUrl && + semitransparency == other.semitransparency && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveBg && + name == other.name && + options == other.options && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(name, options, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" + } + + class AutoTaggingExtension + private constructor( + private val maxTags: JsonField, + private val minConfidence: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("maxTags") + @ExcludeMissing + maxTags: JsonField = JsonMissing.of(), + @JsonProperty("minConfidence") + @ExcludeMissing + minConfidence: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + ) : this(maxTags, minConfidence, name, mutableMapOf()) + + /** + * Maximum number of tags to attach to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maxTags(): Long = maxTags.getRequired("maxTags") + + /** + * Minimum confidence level for tags to be considered valid. + * + * @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 minConfidence(): Long = minConfidence.getRequired("minConfidence") + + /** + * Specifies the auto-tagging extension used. + * + * @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(): Name = name.getRequired("name") + + /** + * Returns the raw JSON value of [maxTags]. + * + * Unlike [maxTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maxTags") + @ExcludeMissing + fun _maxTags(): JsonField = maxTags + + /** + * Returns the raw JSON value of [minConfidence]. + * + * Unlike [minConfidence], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minConfidence") + @ExcludeMissing + fun _minConfidence(): JsonField = minConfidence + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AutoTaggingExtension]. + * + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutoTaggingExtension]. */ + class Builder internal constructor() { + + private var maxTags: JsonField? = null + private var minConfidence: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { + maxTags = autoTaggingExtension.maxTags + minConfidence = autoTaggingExtension.minConfidence + name = autoTaggingExtension.name + additionalProperties = + autoTaggingExtension.additionalProperties.toMutableMap() + } + + /** Maximum number of tags to attach to the asset. */ + fun maxTags(maxTags: Long) = maxTags(JsonField.of(maxTags)) + + /** + * Sets [Builder.maxTags] to an arbitrary JSON value. + * + * You should usually call [Builder.maxTags] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun maxTags(maxTags: JsonField) = apply { this.maxTags = maxTags } + + /** Minimum confidence level for tags to be considered valid. */ + fun minConfidence(minConfidence: Long) = + minConfidence(JsonField.of(minConfidence)) + + /** + * Sets [Builder.minConfidence] to an arbitrary JSON value. + * + * You should usually call [Builder.minConfidence] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minConfidence(minConfidence: JsonField) = apply { + this.minConfidence = minConfidence + } + + /** Specifies the auto-tagging extension used. */ + fun name(name: Name) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [Name] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutoTaggingExtension]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutoTaggingExtension = + AutoTaggingExtension( + checkRequired("maxTags", maxTags), + checkRequired("minConfidence", minConfidence), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutoTaggingExtension = apply { + if (validated) { + return@apply + } + + maxTags() + minConfidence() + name().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (maxTags.asKnown().isPresent) 1 else 0) + + (if (minConfidence.asKnown().isPresent) 1 else 0) + + (name.asKnown().getOrNull()?.validity() ?: 0) + + /** Specifies the auto-tagging extension used. */ + class Name + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") + + @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + } + + /** + * An enum containing [Name]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Name] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + /** + * An enum member indicating that [Name] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING + else -> throw ImageKitInvalidDataException("Unknown Name: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Name = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Name && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutoTaggingExtension && + maxTags == other.maxTags && + minConfidence == other.minConfidence && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(maxTags, minConfidence, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" + } + } + + /** + * An array of AITags associated with the file that you want to remove, e.g. `["car", + * "vehicle", "motorsports"]`. + * + * If you want to remove all AITags associated with the file, send a string - "all". + * + * Note: The remove operation for `AITags` executes before any of the `extensions` are + * processed. + */ + @JsonDeserialize(using = RemoveAiTags.Deserializer::class) + @JsonSerialize(using = RemoveAiTags.Serializer::class) + class RemoveAiTags + private constructor( + private val strings: List? = null, + private val all: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun strings(): Optional> = Optional.ofNullable(strings) + + fun all(): Optional = Optional.ofNullable(all) + + fun isStrings(): Boolean = strings != null + + fun isAll(): Boolean = all != null + + fun asStrings(): List = strings.getOrThrow("strings") + + fun asAll(): JsonValue = all.getOrThrow("all") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + strings != null -> visitor.visitStrings(strings) + all != null -> visitor.visitAll(all) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): RemoveAiTags = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitStrings(strings: List) {} + + override fun visitAll(all: JsonValue) { + all.let { + if (it != JsonValue.from("all")) { + throw ImageKitInvalidDataException( + "'all' is invalid, received $it" + ) + } + } + } + } + ) + 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 = + accept( + object : Visitor { + override fun visitStrings(strings: List) = strings.size + + override fun visitAll(all: JsonValue) = + all.let { if (it == JsonValue.from("all")) 1 else 0 } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveAiTags && strings == other.strings && all == other.all + } + + override fun hashCode(): Int = Objects.hash(strings, all) + + override fun toString(): String = + when { + strings != null -> "RemoveAiTags{strings=$strings}" + all != null -> "RemoveAiTags{all=$all}" + _json != null -> "RemoveAiTags{_unknown=$_json}" + else -> throw IllegalStateException("Invalid RemoveAiTags") + } + + companion object { + + @JvmStatic + fun ofStrings(strings: List) = + RemoveAiTags(strings = strings.toImmutable()) + + @JvmStatic fun ofAll() = RemoveAiTags(all = JsonValue.from("all")) + } + + /** + * An interface that defines how to map each variant of [RemoveAiTags] to a value of + * type [T]. + */ + interface Visitor { + + fun visitStrings(strings: List): T + + fun visitAll(all: JsonValue): T + + /** + * Maps an unknown variant of [RemoveAiTags] to a value of type [T]. + * + * An instance of [RemoveAiTags] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown RemoveAiTags: $json") + } + } + + internal class Deserializer : BaseDeserializer(RemoveAiTags::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): RemoveAiTags { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { RemoveAiTags(all = it, _json = json) } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef>())?.let { + RemoveAiTags(strings = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> RemoveAiTags(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(RemoveAiTags::class) { + + override fun serialize( + value: RemoveAiTags, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.strings != null -> generator.writeObject(value.strings) + value.all != null -> generator.writeObject(value.all) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid RemoveAiTags") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UpdateFileDetails && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + description == other.description && + extensions == other.extensions && + removeAiTags == other.removeAiTags && + tags == other.tags && + webhookUrl == other.webhookUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + customCoordinates, + customMetadata, + description, + extensions, + removeAiTags, + tags, + webhookUrl, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UpdateFileDetails{customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, extensions=$extensions, removeAiTags=$removeAiTags, tags=$tags, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + } + + class ChangePublicationStatus + private constructor( + private val publish: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("publish") + @ExcludeMissing + publish: JsonField = JsonMissing.of() + ) : this(publish, mutableMapOf()) + + /** + * Configure the publication status of a file and its versions. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun publish(): Optional = publish.getOptional("publish") + + /** + * Returns the raw JSON value of [publish]. + * + * Unlike [publish], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("publish") @ExcludeMissing fun _publish(): JsonField = publish + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ChangePublicationStatus]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChangePublicationStatus]. */ + class Builder internal constructor() { + + private var publish: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(changePublicationStatus: ChangePublicationStatus) = apply { + publish = changePublicationStatus.publish + additionalProperties = + changePublicationStatus.additionalProperties.toMutableMap() + } + + /** Configure the publication status of a file and its versions. */ + fun publish(publish: Publish) = publish(JsonField.of(publish)) + + /** + * Sets [Builder.publish] to an arbitrary JSON value. + * + * You should usually call [Builder.publish] with a well-typed [Publish] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun publish(publish: JsonField) = apply { this.publish = publish } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChangePublicationStatus]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ChangePublicationStatus = + ChangePublicationStatus(publish, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ChangePublicationStatus = apply { + if (validated) { + return@apply + } + + publish().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (publish.asKnown().getOrNull()?.validity() ?: 0) + + /** Configure the publication status of a file and its versions. */ + class Publish + private constructor( + private val isPublished: JsonField, + private val includeFileVersions: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("isPublished") + @ExcludeMissing + isPublished: JsonField = JsonMissing.of(), + @JsonProperty("includeFileVersions") + @ExcludeMissing + includeFileVersions: JsonField = JsonMissing.of(), + ) : this(isPublished, includeFileVersions, mutableMapOf()) + + /** + * Set to `true` to publish the file. Set to `false` to unpublish the file. + * + * @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 isPublished(): Boolean = isPublished.getRequired("isPublished") + + /** + * Set to `true` to publish/unpublish all versions of the file. Set to `false` to + * publish/unpublish only the current version of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun includeFileVersions(): Optional = + includeFileVersions.getOptional("includeFileVersions") + + /** + * Returns the raw JSON value of [isPublished]. + * + * Unlike [isPublished], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("isPublished") + @ExcludeMissing + fun _isPublished(): JsonField = isPublished + + /** + * Returns the raw JSON value of [includeFileVersions]. + * + * Unlike [includeFileVersions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeFileVersions") + @ExcludeMissing + fun _includeFileVersions(): JsonField = includeFileVersions + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Publish]. + * + * The following fields are required: + * ```java + * .isPublished() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Publish]. */ + class Builder internal constructor() { + + private var isPublished: JsonField? = null + private var includeFileVersions: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(publish: Publish) = apply { + isPublished = publish.isPublished + includeFileVersions = publish.includeFileVersions + additionalProperties = publish.additionalProperties.toMutableMap() + } + + /** Set to `true` to publish the file. Set to `false` to unpublish the file. */ + fun isPublished(isPublished: Boolean) = isPublished(JsonField.of(isPublished)) + + /** + * Sets [Builder.isPublished] to an arbitrary JSON value. + * + * You should usually call [Builder.isPublished] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun isPublished(isPublished: JsonField) = apply { + this.isPublished = isPublished + } + + /** + * Set to `true` to publish/unpublish all versions of the file. Set to `false` + * to publish/unpublish only the current version of the file. + */ + fun includeFileVersions(includeFileVersions: Boolean) = + includeFileVersions(JsonField.of(includeFileVersions)) + + /** + * Sets [Builder.includeFileVersions] to an arbitrary JSON value. + * + * You should usually call [Builder.includeFileVersions] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun includeFileVersions(includeFileVersions: JsonField) = apply { + this.includeFileVersions = includeFileVersions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Publish]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .isPublished() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Publish = + Publish( + checkRequired("isPublished", isPublished), + includeFileVersions, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Publish = apply { + if (validated) { + return@apply + } + + isPublished() + includeFileVersions() + 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 (isPublished.asKnown().isPresent) 1 else 0) + + (if (includeFileVersions.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Publish && + isPublished == other.isPublished && + includeFileVersions == other.includeFileVersions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(isPublished, includeFileVersions, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Publish{isPublished=$isPublished, includeFileVersions=$includeFileVersions, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChangePublicationStatus && + publish == other.publish && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(publish, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChangePublicationStatus{publish=$publish, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FileUpdateParams && + fileId == other.fileId && + update == other.update && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(fileId, update, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FileUpdateParams{fileId=$fileId, update=$update, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt new file mode 100644 index 00000000..d8ecc3ec --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt @@ -0,0 +1,1934 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Object containing details of a file or file version. */ +class FileUpdateResponse +private constructor( + private val aiTags: JsonField>, + private val createdAt: JsonField, + private val customCoordinates: JsonField, + private val customMetadata: JsonField, + private val description: JsonField, + private val fileId: JsonField, + private val filePath: JsonField, + private val fileType: JsonField, + private val hasAlpha: JsonField, + private val height: JsonField, + private val isPrivateFile: JsonField, + private val isPublished: JsonField, + private val mime: JsonField, + private val name: JsonField, + private val size: JsonField, + private val tags: JsonField>, + private val thumbnail: JsonField, + private val type: JsonField, + private val updatedAt: JsonField, + private val url: JsonField, + private val versionInfo: JsonField, + private val width: JsonField, + private val extensionStatus: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("AITags") + @ExcludeMissing + aiTags: JsonField> = JsonMissing.of(), + @JsonProperty("createdAt") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("customCoordinates") + @ExcludeMissing + customCoordinates: JsonField = JsonMissing.of(), + @JsonProperty("customMetadata") + @ExcludeMissing + customMetadata: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("fileId") @ExcludeMissing fileId: JsonField = JsonMissing.of(), + @JsonProperty("filePath") @ExcludeMissing filePath: JsonField = JsonMissing.of(), + @JsonProperty("fileType") @ExcludeMissing fileType: JsonField = JsonMissing.of(), + @JsonProperty("hasAlpha") @ExcludeMissing hasAlpha: JsonField = JsonMissing.of(), + @JsonProperty("height") @ExcludeMissing height: JsonField = JsonMissing.of(), + @JsonProperty("isPrivateFile") + @ExcludeMissing + isPrivateFile: JsonField = JsonMissing.of(), + @JsonProperty("isPublished") + @ExcludeMissing + isPublished: JsonField = JsonMissing.of(), + @JsonProperty("mime") @ExcludeMissing mime: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("size") @ExcludeMissing size: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), + @JsonProperty("thumbnail") @ExcludeMissing thumbnail: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("updatedAt") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("versionInfo") + @ExcludeMissing + versionInfo: JsonField = JsonMissing.of(), + @JsonProperty("width") @ExcludeMissing width: JsonField = JsonMissing.of(), + @JsonProperty("extensionStatus") + @ExcludeMissing + extensionStatus: JsonField = JsonMissing.of(), + ) : this( + aiTags, + createdAt, + customCoordinates, + customMetadata, + description, + fileId, + filePath, + fileType, + hasAlpha, + height, + isPrivateFile, + isPublished, + mime, + name, + size, + tags, + thumbnail, + type, + updatedAt, + url, + versionInfo, + width, + extensionStatus, + mutableMapOf(), + ) + + fun toFile(): File = + File.builder() + .aiTags(aiTags) + .createdAt(createdAt) + .customCoordinates(customCoordinates) + .customMetadata(customMetadata) + .description(description) + .fileId(fileId) + .filePath(filePath) + .fileType(fileType) + .hasAlpha(hasAlpha) + .height(height) + .isPrivateFile(isPrivateFile) + .isPublished(isPublished) + .mime(mime) + .name(name) + .size(size) + .tags(tags) + .thumbnail(thumbnail) + .type(type) + .updatedAt(updatedAt) + .url(url) + .versionInfo(versionInfo) + .width(width) + .build() + + /** + * An array of tags assigned to the file by auto tagging. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun aiTags(): Optional> = aiTags.getOptional("AITags") + + /** + * Date and time when the file was uploaded. The date and time is in ISO8601 format. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun createdAt(): Optional = createdAt.getOptional("createdAt") + + /** + * An string with custom coordinates of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customCoordinates(): Optional = customCoordinates.getOptional("customCoordinates") + + /** + * An object with custom metadata for the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customMetadata(): Optional = + customMetadata.getOptional("customMetadata") + + /** + * Optional text to describe the contents of the file. Can be set by the user or the + * ai-auto-description extension. + * + * @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") + + /** + * Unique identifier of the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fileId(): Optional = fileId.getOptional("fileId") + + /** + * Path of the file. This is the path you would use in the URL to access the file. For example, + * if the file is at the root of the media library, the path will be `/file.jpg`. If the file is + * inside a folder named `images`, the path will be `/images/file.jpg`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun filePath(): Optional = filePath.getOptional("filePath") + + /** + * Type of the file. Possible values are `image`, `non-image`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fileType(): Optional = fileType.getOptional("fileType") + + /** + * Specifies if the image has an alpha channel. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun hasAlpha(): Optional = hasAlpha.getOptional("hasAlpha") + + /** + * Height of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun height(): Optional = height.getOptional("height") + + /** + * Specifies if the file is private or not. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isPrivateFile(): Optional = isPrivateFile.getOptional("isPrivateFile") + + /** + * Specifies if the file is published or not. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isPublished(): Optional = isPublished.getOptional("isPublished") + + /** + * MIME type of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mime(): Optional = mime.getOptional("mime") + + /** + * Name of the asset. + * + * @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") + + /** + * Size of the file in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun size(): Optional = size.getOptional("size") + + /** + * An array of tags assigned to the file. Tags are used to search files in the media library. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tags(): Optional> = tags.getOptional("tags") + + /** + * URL of the thumbnail image. This URL is used to access the thumbnail image of the file in the + * media library. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun thumbnail(): Optional = thumbnail.getOptional("thumbnail") + + /** + * Type of the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Date and time when the file was last updated. The date and time is in ISO8601 format. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun updatedAt(): Optional = updatedAt.getOptional("updatedAt") + + /** + * URL of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * An object with details of the file version. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun versionInfo(): Optional = versionInfo.getOptional("versionInfo") + + /** + * Width of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun width(): Optional = width.getOptional("width") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun extensionStatus(): Optional = + extensionStatus.getOptional("extensionStatus") + + /** + * Returns the raw JSON value of [aiTags]. + * + * Unlike [aiTags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("AITags") @ExcludeMissing fun _aiTags(): JsonField> = aiTags + + /** + * 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 [customCoordinates]. + * + * Unlike [customCoordinates], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("customCoordinates") + @ExcludeMissing + fun _customCoordinates(): JsonField = customCoordinates + + /** + * Returns the raw JSON value of [customMetadata]. + * + * Unlike [customMetadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): JsonField = customMetadata + + /** + * 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 [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fileId") @ExcludeMissing fun _fileId(): JsonField = fileId + + /** + * Returns the raw JSON value of [filePath]. + * + * Unlike [filePath], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filePath") @ExcludeMissing fun _filePath(): JsonField = filePath + + /** + * Returns the raw JSON value of [fileType]. + * + * Unlike [fileType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fileType") @ExcludeMissing fun _fileType(): JsonField = fileType + + /** + * Returns the raw JSON value of [hasAlpha]. + * + * Unlike [hasAlpha], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("hasAlpha") @ExcludeMissing fun _hasAlpha(): JsonField = hasAlpha + + /** + * Returns the raw JSON value of [height]. + * + * Unlike [height], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("height") @ExcludeMissing fun _height(): JsonField = height + + /** + * Returns the raw JSON value of [isPrivateFile]. + * + * Unlike [isPrivateFile], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isPrivateFile") + @ExcludeMissing + fun _isPrivateFile(): JsonField = isPrivateFile + + /** + * Returns the raw JSON value of [isPublished]. + * + * Unlike [isPublished], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isPublished") + @ExcludeMissing + fun _isPublished(): JsonField = isPublished + + /** + * Returns the raw JSON value of [mime]. + * + * Unlike [mime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mime") @ExcludeMissing fun _mime(): JsonField = mime + + /** + * 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 [size]. + * + * Unlike [size], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("size") @ExcludeMissing fun _size(): JsonField = size + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + + /** + * Returns the raw JSON value of [thumbnail]. + * + * Unlike [thumbnail], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("thumbnail") @ExcludeMissing fun _thumbnail(): JsonField = thumbnail + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updatedAt") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [versionInfo]. + * + * Unlike [versionInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("versionInfo") + @ExcludeMissing + fun _versionInfo(): JsonField = versionInfo + + /** + * Returns the raw JSON value of [width]. + * + * Unlike [width], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("width") @ExcludeMissing fun _width(): JsonField = width + + /** + * Returns the raw JSON value of [extensionStatus]. + * + * Unlike [extensionStatus], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extensionStatus") + @ExcludeMissing + fun _extensionStatus(): JsonField = extensionStatus + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FileUpdateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileUpdateResponse]. */ + class Builder internal constructor() { + + private var aiTags: JsonField>? = null + private var createdAt: JsonField = JsonMissing.of() + private var customCoordinates: JsonField = JsonMissing.of() + private var customMetadata: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var fileId: JsonField = JsonMissing.of() + private var filePath: JsonField = JsonMissing.of() + private var fileType: JsonField = JsonMissing.of() + private var hasAlpha: JsonField = JsonMissing.of() + private var height: JsonField = JsonMissing.of() + private var isPrivateFile: JsonField = JsonMissing.of() + private var isPublished: JsonField = JsonMissing.of() + private var mime: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var size: JsonField = JsonMissing.of() + private var tags: JsonField>? = null + private var thumbnail: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var url: JsonField = JsonMissing.of() + private var versionInfo: JsonField = JsonMissing.of() + private var width: JsonField = JsonMissing.of() + private var extensionStatus: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fileUpdateResponse: FileUpdateResponse) = apply { + aiTags = fileUpdateResponse.aiTags.map { it.toMutableList() } + createdAt = fileUpdateResponse.createdAt + customCoordinates = fileUpdateResponse.customCoordinates + customMetadata = fileUpdateResponse.customMetadata + description = fileUpdateResponse.description + fileId = fileUpdateResponse.fileId + filePath = fileUpdateResponse.filePath + fileType = fileUpdateResponse.fileType + hasAlpha = fileUpdateResponse.hasAlpha + height = fileUpdateResponse.height + isPrivateFile = fileUpdateResponse.isPrivateFile + isPublished = fileUpdateResponse.isPublished + mime = fileUpdateResponse.mime + name = fileUpdateResponse.name + size = fileUpdateResponse.size + tags = fileUpdateResponse.tags.map { it.toMutableList() } + thumbnail = fileUpdateResponse.thumbnail + type = fileUpdateResponse.type + updatedAt = fileUpdateResponse.updatedAt + url = fileUpdateResponse.url + versionInfo = fileUpdateResponse.versionInfo + width = fileUpdateResponse.width + extensionStatus = fileUpdateResponse.extensionStatus + additionalProperties = fileUpdateResponse.additionalProperties.toMutableMap() + } + + /** An array of tags assigned to the file by auto tagging. */ + fun aiTags(aiTags: List?) = aiTags(JsonField.ofNullable(aiTags)) + + /** Alias for calling [Builder.aiTags] with `aiTags.orElse(null)`. */ + fun aiTags(aiTags: Optional>) = aiTags(aiTags.getOrNull()) + + /** + * Sets [Builder.aiTags] to an arbitrary JSON value. + * + * You should usually call [Builder.aiTags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun aiTags(aiTags: JsonField>) = apply { + this.aiTags = aiTags.map { it.toMutableList() } + } + + /** + * Adds a single [File.AiTag] to [aiTags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAiTag(aiTag: File.AiTag) = apply { + aiTags = + (aiTags ?: JsonField.of(mutableListOf())).also { + checkKnown("aiTags", it).add(aiTag) + } + } + + /** Date and time when the file was uploaded. The date and time is in ISO8601 format. */ + 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 } + + /** An string with custom coordinates of the file. */ + fun customCoordinates(customCoordinates: String?) = + customCoordinates(JsonField.ofNullable(customCoordinates)) + + /** Alias for calling [Builder.customCoordinates] with `customCoordinates.orElse(null)`. */ + fun customCoordinates(customCoordinates: Optional) = + customCoordinates(customCoordinates.getOrNull()) + + /** + * Sets [Builder.customCoordinates] to an arbitrary JSON value. + * + * You should usually call [Builder.customCoordinates] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customCoordinates(customCoordinates: JsonField) = apply { + this.customCoordinates = customCoordinates + } + + /** An object with custom metadata for the file. */ + fun customMetadata(customMetadata: File.CustomMetadata) = + customMetadata(JsonField.of(customMetadata)) + + /** + * Sets [Builder.customMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.customMetadata] with a well-typed [File.CustomMetadata] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun customMetadata(customMetadata: JsonField) = apply { + this.customMetadata = customMetadata + } + + /** + * Optional text to describe the contents of the file. Can be set by the user or the + * ai-auto-description extension. + */ + 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 } + + /** Unique identifier of the asset. */ + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + + /** + * Path of the file. This is the path you would use in the URL to access the file. For + * example, if the file is at the root of the media library, the path will be `/file.jpg`. + * If the file is inside a folder named `images`, the path will be `/images/file.jpg`. + */ + fun filePath(filePath: String) = filePath(JsonField.of(filePath)) + + /** + * Sets [Builder.filePath] to an arbitrary JSON value. + * + * You should usually call [Builder.filePath] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filePath(filePath: JsonField) = apply { this.filePath = filePath } + + /** Type of the file. Possible values are `image`, `non-image`. */ + fun fileType(fileType: String) = fileType(JsonField.of(fileType)) + + /** + * Sets [Builder.fileType] to an arbitrary JSON value. + * + * You should usually call [Builder.fileType] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fileType(fileType: JsonField) = apply { this.fileType = fileType } + + /** Specifies if the image has an alpha channel. */ + fun hasAlpha(hasAlpha: Boolean) = hasAlpha(JsonField.of(hasAlpha)) + + /** + * Sets [Builder.hasAlpha] to an arbitrary JSON value. + * + * You should usually call [Builder.hasAlpha] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hasAlpha(hasAlpha: JsonField) = apply { this.hasAlpha = hasAlpha } + + /** Height of the file. */ + fun height(height: Double) = height(JsonField.of(height)) + + /** + * Sets [Builder.height] to an arbitrary JSON value. + * + * You should usually call [Builder.height] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun height(height: JsonField) = apply { this.height = height } + + /** Specifies if the file is private or not. */ + fun isPrivateFile(isPrivateFile: Boolean) = isPrivateFile(JsonField.of(isPrivateFile)) + + /** + * Sets [Builder.isPrivateFile] to an arbitrary JSON value. + * + * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPrivateFile(isPrivateFile: JsonField) = apply { + this.isPrivateFile = isPrivateFile + } + + /** Specifies if the file is published or not. */ + fun isPublished(isPublished: Boolean) = isPublished(JsonField.of(isPublished)) + + /** + * Sets [Builder.isPublished] to an arbitrary JSON value. + * + * You should usually call [Builder.isPublished] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isPublished(isPublished: JsonField) = apply { this.isPublished = isPublished } + + /** MIME type of the file. */ + fun mime(mime: String) = mime(JsonField.of(mime)) + + /** + * Sets [Builder.mime] to an arbitrary JSON value. + * + * You should usually call [Builder.mime] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun mime(mime: JsonField) = apply { this.mime = mime } + + /** Name of the asset. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Size of the file in bytes. */ + fun size(size: Double) = size(JsonField.of(size)) + + /** + * Sets [Builder.size] to an arbitrary JSON value. + * + * You should usually call [Builder.size] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun size(size: JsonField) = apply { this.size = size } + + /** + * An array of tags assigned to the file. Tags are used to search files in the media + * library. + */ + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + /** + * URL of the thumbnail image. This URL is used to access the thumbnail image of the file in + * the media library. + */ + fun thumbnail(thumbnail: String) = thumbnail(JsonField.of(thumbnail)) + + /** + * Sets [Builder.thumbnail] to an arbitrary JSON value. + * + * You should usually call [Builder.thumbnail] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thumbnail(thumbnail: JsonField) = apply { this.thumbnail = thumbnail } + + /** Type of the asset. */ + fun type(type: File.Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [File.Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Date and time when the file was last updated. The date and time is in ISO8601 format. */ + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + + /** URL of the file. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** An object with details of the file version. */ + fun versionInfo(versionInfo: File.VersionInfo) = versionInfo(JsonField.of(versionInfo)) + + /** + * Sets [Builder.versionInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.versionInfo] with a well-typed [File.VersionInfo] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun versionInfo(versionInfo: JsonField) = apply { + this.versionInfo = versionInfo + } + + /** Width of the file. */ + fun width(width: Double) = width(JsonField.of(width)) + + /** + * Sets [Builder.width] to an arbitrary JSON value. + * + * You should usually call [Builder.width] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun width(width: JsonField) = apply { this.width = width } + + fun extensionStatus(extensionStatus: ExtensionStatus) = + extensionStatus(JsonField.of(extensionStatus)) + + /** + * Sets [Builder.extensionStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.extensionStatus] with a well-typed [ExtensionStatus] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun extensionStatus(extensionStatus: JsonField) = apply { + this.extensionStatus = extensionStatus + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FileUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FileUpdateResponse = + FileUpdateResponse( + (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, + createdAt, + customCoordinates, + customMetadata, + description, + fileId, + filePath, + fileType, + hasAlpha, + height, + isPrivateFile, + isPublished, + mime, + name, + size, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + thumbnail, + type, + updatedAt, + url, + versionInfo, + width, + extensionStatus, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FileUpdateResponse = apply { + if (validated) { + return@apply + } + + aiTags().ifPresent { it.forEach { it.validate() } } + createdAt() + customCoordinates() + customMetadata().ifPresent { it.validate() } + description() + fileId() + filePath() + fileType() + hasAlpha() + height() + isPrivateFile() + isPublished() + mime() + name() + size() + tags() + thumbnail() + type().ifPresent { it.validate() } + updatedAt() + url() + versionInfo().ifPresent { it.validate() } + width() + extensionStatus().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (aiTags.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (customCoordinates.asKnown().isPresent) 1 else 0) + + (customMetadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (fileId.asKnown().isPresent) 1 else 0) + + (if (filePath.asKnown().isPresent) 1 else 0) + + (if (fileType.asKnown().isPresent) 1 else 0) + + (if (hasAlpha.asKnown().isPresent) 1 else 0) + + (if (height.asKnown().isPresent) 1 else 0) + + (if (isPrivateFile.asKnown().isPresent) 1 else 0) + + (if (isPublished.asKnown().isPresent) 1 else 0) + + (if (mime.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (size.asKnown().isPresent) 1 else 0) + + (tags.asKnown().getOrNull()?.size ?: 0) + + (if (thumbnail.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (versionInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (width.asKnown().isPresent) 1 else 0) + + (extensionStatus.asKnown().getOrNull()?.validity() ?: 0) + + class ExtensionStatus + private constructor( + private val aiAutoDescription: JsonField, + private val awsAutoTagging: JsonField, + private val googleAutoTagging: JsonField, + private val removeBg: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("ai-auto-description") + @ExcludeMissing + aiAutoDescription: JsonField = JsonMissing.of(), + @JsonProperty("aws-auto-tagging") + @ExcludeMissing + awsAutoTagging: JsonField = JsonMissing.of(), + @JsonProperty("google-auto-tagging") + @ExcludeMissing + googleAutoTagging: JsonField = JsonMissing.of(), + @JsonProperty("remove-bg") + @ExcludeMissing + removeBg: JsonField = JsonMissing.of(), + ) : this(aiAutoDescription, awsAutoTagging, googleAutoTagging, removeBg, mutableMapOf()) + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun aiAutoDescription(): Optional = + aiAutoDescription.getOptional("ai-auto-description") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun awsAutoTagging(): Optional = + awsAutoTagging.getOptional("aws-auto-tagging") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun googleAutoTagging(): Optional = + googleAutoTagging.getOptional("google-auto-tagging") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun removeBg(): Optional = removeBg.getOptional("remove-bg") + + /** + * Returns the raw JSON value of [aiAutoDescription]. + * + * Unlike [aiAutoDescription], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ai-auto-description") + @ExcludeMissing + fun _aiAutoDescription(): JsonField = aiAutoDescription + + /** + * Returns the raw JSON value of [awsAutoTagging]. + * + * Unlike [awsAutoTagging], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("aws-auto-tagging") + @ExcludeMissing + fun _awsAutoTagging(): JsonField = awsAutoTagging + + /** + * Returns the raw JSON value of [googleAutoTagging]. + * + * Unlike [googleAutoTagging], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("google-auto-tagging") + @ExcludeMissing + fun _googleAutoTagging(): JsonField = googleAutoTagging + + /** + * Returns the raw JSON value of [removeBg]. + * + * Unlike [removeBg], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("remove-bg") @ExcludeMissing fun _removeBg(): JsonField = removeBg + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ExtensionStatus]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExtensionStatus]. */ + class Builder internal constructor() { + + private var aiAutoDescription: JsonField = JsonMissing.of() + private var awsAutoTagging: JsonField = JsonMissing.of() + private var googleAutoTagging: JsonField = JsonMissing.of() + private var removeBg: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extensionStatus: ExtensionStatus) = apply { + aiAutoDescription = extensionStatus.aiAutoDescription + awsAutoTagging = extensionStatus.awsAutoTagging + googleAutoTagging = extensionStatus.googleAutoTagging + removeBg = extensionStatus.removeBg + additionalProperties = extensionStatus.additionalProperties.toMutableMap() + } + + fun aiAutoDescription(aiAutoDescription: AiAutoDescription) = + aiAutoDescription(JsonField.of(aiAutoDescription)) + + /** + * Sets [Builder.aiAutoDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.aiAutoDescription] with a well-typed + * [AiAutoDescription] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun aiAutoDescription(aiAutoDescription: JsonField) = apply { + this.aiAutoDescription = aiAutoDescription + } + + fun awsAutoTagging(awsAutoTagging: AwsAutoTagging) = + awsAutoTagging(JsonField.of(awsAutoTagging)) + + /** + * Sets [Builder.awsAutoTagging] to an arbitrary JSON value. + * + * You should usually call [Builder.awsAutoTagging] with a well-typed [AwsAutoTagging] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun awsAutoTagging(awsAutoTagging: JsonField) = apply { + this.awsAutoTagging = awsAutoTagging + } + + fun googleAutoTagging(googleAutoTagging: GoogleAutoTagging) = + googleAutoTagging(JsonField.of(googleAutoTagging)) + + /** + * Sets [Builder.googleAutoTagging] to an arbitrary JSON value. + * + * You should usually call [Builder.googleAutoTagging] with a well-typed + * [GoogleAutoTagging] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun googleAutoTagging(googleAutoTagging: JsonField) = apply { + this.googleAutoTagging = googleAutoTagging + } + + fun removeBg(removeBg: RemoveBg) = removeBg(JsonField.of(removeBg)) + + /** + * Sets [Builder.removeBg] to an arbitrary JSON value. + * + * You should usually call [Builder.removeBg] with a well-typed [RemoveBg] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun removeBg(removeBg: JsonField) = apply { this.removeBg = removeBg } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ExtensionStatus]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExtensionStatus = + ExtensionStatus( + aiAutoDescription, + awsAutoTagging, + googleAutoTagging, + removeBg, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExtensionStatus = apply { + if (validated) { + return@apply + } + + aiAutoDescription().ifPresent { it.validate() } + awsAutoTagging().ifPresent { it.validate() } + googleAutoTagging().ifPresent { it.validate() } + removeBg().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (aiAutoDescription.asKnown().getOrNull()?.validity() ?: 0) + + (awsAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (googleAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (removeBg.asKnown().getOrNull()?.validity() ?: 0) + + class AiAutoDescription + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val PENDING = of("pending") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = AiAutoDescription(JsonField.of(value)) + } + + /** An enum containing [AiAutoDescription]'s known values. */ + enum class Known { + SUCCESS, + PENDING, + FAILED, + } + + /** + * An enum containing [AiAutoDescription]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AiAutoDescription] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + PENDING, + FAILED, + /** + * An enum member indicating that [AiAutoDescription] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + PENDING -> Value.PENDING + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + PENDING -> Known.PENDING + FAILED -> Known.FAILED + else -> throw ImageKitInvalidDataException("Unknown AiAutoDescription: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AiAutoDescription = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiAutoDescription && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class AwsAutoTagging + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val PENDING = of("pending") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = AwsAutoTagging(JsonField.of(value)) + } + + /** An enum containing [AwsAutoTagging]'s known values. */ + enum class Known { + SUCCESS, + PENDING, + FAILED, + } + + /** + * An enum containing [AwsAutoTagging]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AwsAutoTagging] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + PENDING, + FAILED, + /** + * An enum member indicating that [AwsAutoTagging] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + PENDING -> Value.PENDING + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + PENDING -> Known.PENDING + FAILED -> Known.FAILED + else -> throw ImageKitInvalidDataException("Unknown AwsAutoTagging: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AwsAutoTagging = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AwsAutoTagging && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class GoogleAutoTagging + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val PENDING = of("pending") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = GoogleAutoTagging(JsonField.of(value)) + } + + /** An enum containing [GoogleAutoTagging]'s known values. */ + enum class Known { + SUCCESS, + PENDING, + FAILED, + } + + /** + * An enum containing [GoogleAutoTagging]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [GoogleAutoTagging] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + PENDING, + FAILED, + /** + * An enum member indicating that [GoogleAutoTagging] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + PENDING -> Value.PENDING + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + PENDING -> Known.PENDING + FAILED -> Known.FAILED + else -> throw ImageKitInvalidDataException("Unknown GoogleAutoTagging: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): GoogleAutoTagging = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GoogleAutoTagging && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class RemoveBg @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val PENDING = of("pending") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = RemoveBg(JsonField.of(value)) + } + + /** An enum containing [RemoveBg]'s known values. */ + enum class Known { + SUCCESS, + PENDING, + FAILED, + } + + /** + * An enum containing [RemoveBg]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RemoveBg] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + PENDING, + FAILED, + /** + * An enum member indicating that [RemoveBg] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + PENDING -> Value.PENDING + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + PENDING -> Known.PENDING + FAILED -> Known.FAILED + else -> throw ImageKitInvalidDataException("Unknown RemoveBg: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): RemoveBg = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveBg && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExtensionStatus && + aiAutoDescription == other.aiAutoDescription && + awsAutoTagging == other.awsAutoTagging && + googleAutoTagging == other.googleAutoTagging && + removeBg == other.removeBg && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aiAutoDescription, + awsAutoTagging, + googleAutoTagging, + removeBg, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExtensionStatus{aiAutoDescription=$aiAutoDescription, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FileUpdateResponse && + aiTags == other.aiTags && + createdAt == other.createdAt && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + description == other.description && + fileId == other.fileId && + filePath == other.filePath && + fileType == other.fileType && + hasAlpha == other.hasAlpha && + height == other.height && + isPrivateFile == other.isPrivateFile && + isPublished == other.isPublished && + mime == other.mime && + name == other.name && + size == other.size && + tags == other.tags && + thumbnail == other.thumbnail && + type == other.type && + updatedAt == other.updatedAt && + url == other.url && + versionInfo == other.versionInfo && + width == other.width && + extensionStatus == other.extensionStatus && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aiTags, + createdAt, + customCoordinates, + customMetadata, + description, + fileId, + filePath, + fileType, + hasAlpha, + height, + isPrivateFile, + isPublished, + mime, + name, + size, + tags, + thumbnail, + type, + updatedAt, + url, + versionInfo, + width, + extensionStatus, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FileUpdateResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, fileId=$fileId, filePath=$filePath, fileType=$fileType, hasAlpha=$hasAlpha, height=$height, isPrivateFile=$isPrivateFile, isPublished=$isPublished, mime=$mime, name=$name, size=$size, tags=$tags, thumbnail=$thumbnail, type=$type, updatedAt=$updatedAt, url=$url, versionInfo=$versionInfo, width=$width, extensionStatus=$extensionStatus, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt new file mode 100644 index 00000000..e50852f0 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -0,0 +1,5094 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.MultipartField +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.io.InputStream +import java.nio.file.Path +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.io.path.inputStream +import kotlin.io.path.name +import kotlin.jvm.optionals.getOrNull + +/** + * ImageKit.io allows you to upload files directly from both the server and client sides. For + * server-side uploads, private API key authentication is used. For client-side uploads, generate a + * one-time `token`, `signature`, and `expire` from your secure backend using private API. + * [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) + * about how to implement client-side file upload. + * + * The [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security by verifying the + * entire payload using JWT. + * + * **File size limit** \ On the free plan, the maximum upload file sizes are 20MB for images, audio, + * and raw files and 100MB for videos. On the paid plan, these limits increase to 40MB for images, + * audio, and raw files and 2GB for videos. These limits can be further increased with higher-tier + * plans. + * + * **Version limit** \ A file can have a maximum of 100 versions. + * + * **Demo applications** + * - A full-fledged [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), + * supporting file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. + * - [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies. + */ +class FileUploadParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + * + * @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 file(): InputStream = body.file() + + /** + * The name with which the file has to be uploaded. The file name can contain: + * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + * - Special Characters: `.`, `-` + * + * Any other character including space will be replaced by `_` + * + * @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 fileName(): String = body.fileName() + + /** + * A unique value that the ImageKit.io server will use to recognize and prevent subsequent + * retries for the same request. We suggest using V4 UUIDs, or another random string with enough + * entropy to avoid collisions. This field is only required for authentication when uploading a + * file from the client side. + * + * **Note**: Sending a value that has been used in the past will result in a validation error. + * Even if your previous request resulted in an error, you should always send a new value for + * this field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun token(): Optional = body.token() + + /** + * Server-side checks to run on the asset. Read more about + * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun checks(): Optional = body.checks() + + /** + * Define an important area in the image. This is only relevant for image type files. + * - To be passed as a string with the x and y coordinates of the top-left corner, and width and + * height of the area of interest in the format `x,y,width,height`. For example - + * `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates will be + * removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customCoordinates(): Optional = body.customCoordinates() + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields before + * setting these values. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customMetadata(): Optional = body.customMetadata() + + /** + * Optional text to describe the contents of the file. + * + * @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() + + /** + * The time until your signature is valid. It must be a + * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. It + * should be in seconds. This field is only required for authentication when uploading a file + * from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expire(): Optional = body.expire() + + /** + * Array of extensions to be applied to the image. Each extension can be configured with + * specific parameters based on the extension type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun extensions(): Optional> = body.extensions() + + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, + * a new folder(s) is created. + * + * The folder name can contain: + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun folder(): Optional = body.folder() + + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named transformation or + * signed URL. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isPrivateFile(): Optional = body.isPrivateFile() + + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file only via + * the media library. Files in draft or unpublished state can only be publicly accessed after + * being published. + * + * The option to upload in draft state is only available in custom enterprise pricing plans. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isPublished(): Optional = body.isPublished() + + /** + * If set to `true` and a file already exists at the exact location, its AITags will be removed. + * Set `overwriteAITags` to `false` to preserve AITags. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun overwriteAiTags(): Optional = body.overwriteAiTags() + + /** + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun overwriteCustomMetadata(): Optional = body.overwriteCustomMetadata() + + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact + * location, upload API will return an error immediately. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun overwriteFile(): Optional = body.overwriteFile() + + /** + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun overwriteTags(): Optional = body.overwriteTags() + + /** + * Your ImageKit.io public key. This field is only required for authentication when uploading a + * file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun publicKey(): Optional = body.publicKey() + + /** + * Array of response field keys to include in the API response body. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun responseFields(): Optional> = body.responseFields() + + /** + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. Learn + * how to create a signature on the page below. This should be in lowercase. + * + * Signature must be calculated on the server-side. This field is only required for + * authentication when uploading a file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun signature(): Optional = body.signature() + + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", + * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the `%` + * character is not allowed. If this field is not specified and the file is overwritten, the + * existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tags(): Optional> = body.tags() + + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing file + * size or applying basic optimizations upfront (e.g., resize, compress). + * - `post` — applied immediately after upload. Ideal for generating transformed versions (like + * video encodes or thumbnails) in advance, so they're ready for delivery without delay. + * + * You can mix and match any combination of post-processing types. + * + * @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() + + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique + * filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any existing + * file with the same name is replaced. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun useUniqueFileName(): Optional = body.useUniqueFileName() + + /** + * The final status of extensions after they have completed execution will be delivered to this + * endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookUrl(): Optional = body.webhookUrl() + + /** + * Returns the raw multipart value of [file]. + * + * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _file(): MultipartField = body._file() + + /** + * Returns the raw multipart value of [fileName]. + * + * Unlike [fileName], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _fileName(): MultipartField = body._fileName() + + /** + * Returns the raw multipart value of [token]. + * + * Unlike [token], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _token(): MultipartField = body._token() + + /** + * Returns the raw multipart value of [checks]. + * + * Unlike [checks], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _checks(): MultipartField = body._checks() + + /** + * Returns the raw multipart value of [customCoordinates]. + * + * Unlike [customCoordinates], this method doesn't throw if the multipart field has an + * unexpected type. + */ + fun _customCoordinates(): MultipartField = body._customCoordinates() + + /** + * Returns the raw multipart value of [customMetadata]. + * + * Unlike [customMetadata], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _customMetadata(): MultipartField = body._customMetadata() + + /** + * Returns the raw multipart value of [description]. + * + * Unlike [description], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _description(): MultipartField = body._description() + + /** + * Returns the raw multipart value of [expire]. + * + * Unlike [expire], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _expire(): MultipartField = body._expire() + + /** + * Returns the raw multipart value of [extensions]. + * + * Unlike [extensions], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _extensions(): MultipartField> = body._extensions() + + /** + * Returns the raw multipart value of [folder]. + * + * Unlike [folder], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _folder(): MultipartField = body._folder() + + /** + * Returns the raw multipart value of [isPrivateFile]. + * + * Unlike [isPrivateFile], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _isPrivateFile(): MultipartField = body._isPrivateFile() + + /** + * Returns the raw multipart value of [isPublished]. + * + * Unlike [isPublished], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _isPublished(): MultipartField = body._isPublished() + + /** + * Returns the raw multipart value of [overwriteAiTags]. + * + * Unlike [overwriteAiTags], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _overwriteAiTags(): MultipartField = body._overwriteAiTags() + + /** + * Returns the raw multipart value of [overwriteCustomMetadata]. + * + * Unlike [overwriteCustomMetadata], this method doesn't throw if the multipart field has an + * unexpected type. + */ + fun _overwriteCustomMetadata(): MultipartField = body._overwriteCustomMetadata() + + /** + * Returns the raw multipart value of [overwriteFile]. + * + * Unlike [overwriteFile], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _overwriteFile(): MultipartField = body._overwriteFile() + + /** + * Returns the raw multipart value of [overwriteTags]. + * + * Unlike [overwriteTags], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _overwriteTags(): MultipartField = body._overwriteTags() + + /** + * Returns the raw multipart value of [publicKey]. + * + * Unlike [publicKey], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _publicKey(): MultipartField = body._publicKey() + + /** + * Returns the raw multipart value of [responseFields]. + * + * Unlike [responseFields], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _responseFields(): MultipartField> = body._responseFields() + + /** + * Returns the raw multipart value of [signature]. + * + * Unlike [signature], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _signature(): MultipartField = body._signature() + + /** + * Returns the raw multipart value of [tags]. + * + * Unlike [tags], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _tags(): MultipartField> = body._tags() + + /** + * Returns the raw multipart value of [transformation]. + * + * Unlike [transformation], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _transformation(): MultipartField = body._transformation() + + /** + * Returns the raw multipart value of [useUniqueFileName]. + * + * Unlike [useUniqueFileName], this method doesn't throw if the multipart field has an + * unexpected type. + */ + fun _useUniqueFileName(): MultipartField = body._useUniqueFileName() + + /** + * Returns the raw multipart value of [webhookUrl]. + * + * Unlike [webhookUrl], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _webhookUrl(): MultipartField = body._webhookUrl() + + 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 [FileUploadParams]. + * + * The following fields are required: + * ```java + * .file() + * .fileName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileUploadParams]. */ + 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(fileUploadParams: FileUploadParams) = apply { + body = fileUploadParams.body.toBuilder() + additionalHeaders = fileUploadParams.additionalHeaders.toBuilder() + additionalQueryParams = fileUploadParams.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: + * - [file] + * - [fileName] + * - [token] + * - [checks] + * - [customCoordinates] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(file: InputStream) = apply { body.file(file) } + + /** + * Sets [Builder.file] to an arbitrary multipart value. + * + * You should usually call [Builder.file] with a well-typed [InputStream] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun file(file: MultipartField) = apply { body.file(file) } + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(file: ByteArray) = apply { body.file(file) } + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(path: Path) = apply { body.file(path) } + + /** + * The name with which the file has to be uploaded. The file name can contain: + * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + * - Special Characters: `.`, `-` + * + * Any other character including space will be replaced by `_` + */ + fun fileName(fileName: String) = apply { body.fileName(fileName) } + + /** + * Sets [Builder.fileName] to an arbitrary multipart value. + * + * You should usually call [Builder.fileName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fileName(fileName: MultipartField) = apply { body.fileName(fileName) } + + /** + * A unique value that the ImageKit.io server will use to recognize and prevent subsequent + * retries for the same request. We suggest using V4 UUIDs, or another random string with + * enough entropy to avoid collisions. This field is only required for authentication when + * uploading a file from the client side. + * + * **Note**: Sending a value that has been used in the past will result in a validation + * error. Even if your previous request resulted in an error, you should always send a new + * value for this field. + */ + fun token(token: String) = apply { body.token(token) } + + /** + * Sets [Builder.token] to an arbitrary multipart value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: MultipartField) = apply { body.token(token) } + + /** + * Server-side checks to run on the asset. Read more about + * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + */ + fun checks(checks: String) = apply { body.checks(checks) } + + /** + * Sets [Builder.checks] to an arbitrary multipart value. + * + * You should usually call [Builder.checks] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun checks(checks: MultipartField) = apply { body.checks(checks) } + + /** + * Define an important area in the image. This is only relevant for image type files. + * - To be passed as a string with the x and y coordinates of the top-left corner, and width + * and height of the area of interest in the format `x,y,width,height`. For example - + * `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates will + * be removed. + */ + fun customCoordinates(customCoordinates: String) = apply { + body.customCoordinates(customCoordinates) + } + + /** + * Sets [Builder.customCoordinates] to an arbitrary multipart value. + * + * You should usually call [Builder.customCoordinates] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customCoordinates(customCoordinates: MultipartField) = apply { + body.customCoordinates(customCoordinates) + } + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields + * before setting these values. + */ + fun customMetadata(customMetadata: CustomMetadata) = apply { + body.customMetadata(customMetadata) + } + + /** + * Sets [Builder.customMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.customMetadata] with a well-typed [CustomMetadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customMetadata(customMetadata: MultipartField) = apply { + body.customMetadata(customMetadata) + } + + /** Optional text to describe the contents of the file. */ + fun description(description: String) = apply { body.description(description) } + + /** + * Sets [Builder.description] to an arbitrary multipart 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: MultipartField) = apply { + body.description(description) + } + + /** + * The time until your signature is valid. It must be a + * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. + * It should be in seconds. This field is only required for authentication when uploading a + * file from the client side. + */ + fun expire(expire: Long) = apply { body.expire(expire) } + + /** + * Sets [Builder.expire] to an arbitrary multipart value. + * + * You should usually call [Builder.expire] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun expire(expire: MultipartField) = apply { body.expire(expire) } + + /** + * Array of extensions to be applied to the image. Each extension can be configured with + * specific parameters based on the extension type. + */ + fun extensions(extensions: List) = apply { body.extensions(extensions) } + + /** + * Sets [Builder.extensions] to an arbitrary multipart value. + * + * You should usually call [Builder.extensions] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun extensions(extensions: MultipartField>) = apply { + body.extensions(extensions) + } + + /** + * Adds a single [Extension] to [extensions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExtension(extension: Extension) = apply { body.addExtension(extension) } + + /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ + fun addExtension(removeBg: Extension.RemoveBg) = apply { body.addExtension(removeBg) } + + /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = apply { + body.addExtension(autoTagging) + } + + /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ + fun addExtensionAiAutoDescription() = apply { body.addExtensionAiAutoDescription() } + + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't exist + * before, a new folder(s) is created. + * + * The folder name can contain: + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. + */ + fun folder(folder: String) = apply { body.folder(folder) } + + /** + * Sets [Builder.folder] to an arbitrary multipart value. + * + * You should usually call [Builder.folder] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun folder(folder: MultipartField) = apply { body.folder(folder) } + + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named + * transformation or signed URL. + */ + fun isPrivateFile(isPrivateFile: Boolean) = apply { body.isPrivateFile(isPrivateFile) } + + /** + * Sets [Builder.isPrivateFile] to an arbitrary multipart value. + * + * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPrivateFile(isPrivateFile: MultipartField) = apply { + body.isPrivateFile(isPrivateFile) + } + + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file only + * via the media library. Files in draft or unpublished state can only be publicly accessed + * after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing plans. + */ + fun isPublished(isPublished: Boolean) = apply { body.isPublished(isPublished) } + + /** + * Sets [Builder.isPublished] to an arbitrary multipart value. + * + * You should usually call [Builder.isPublished] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isPublished(isPublished: MultipartField) = apply { + body.isPublished(isPublished) + } + + /** + * If set to `true` and a file already exists at the exact location, its AITags will be + * removed. Set `overwriteAITags` to `false` to preserve AITags. + */ + fun overwriteAiTags(overwriteAiTags: Boolean) = apply { + body.overwriteAiTags(overwriteAiTags) + } + + /** + * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteAiTags] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteAiTags(overwriteAiTags: MultipartField) = apply { + body.overwriteAiTags(overwriteAiTags) + } + + /** + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: Boolean) = apply { + body.overwriteCustomMetadata(overwriteCustomMetadata) + } + + /** + * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteCustomMetadata] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: MultipartField) = apply { + body.overwriteCustomMetadata(overwriteCustomMetadata) + } + + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the + * exact location, upload API will return an error immediately. + */ + fun overwriteFile(overwriteFile: Boolean) = apply { body.overwriteFile(overwriteFile) } + + /** + * Sets [Builder.overwriteFile] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteFile(overwriteFile: MultipartField) = apply { + body.overwriteFile(overwriteFile) + } + + /** + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + */ + fun overwriteTags(overwriteTags: Boolean) = apply { body.overwriteTags(overwriteTags) } + + /** + * Sets [Builder.overwriteTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteTags] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteTags(overwriteTags: MultipartField) = apply { + body.overwriteTags(overwriteTags) + } + + /** + * Your ImageKit.io public key. This field is only required for authentication when + * uploading a file from the client side. + */ + fun publicKey(publicKey: String) = apply { body.publicKey(publicKey) } + + /** + * Sets [Builder.publicKey] to an arbitrary multipart value. + * + * You should usually call [Builder.publicKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun publicKey(publicKey: MultipartField) = apply { body.publicKey(publicKey) } + + /** Array of response field keys to include in the API response body. */ + fun responseFields(responseFields: List) = apply { + body.responseFields(responseFields) + } + + /** + * Sets [Builder.responseFields] to an arbitrary multipart value. + * + * You should usually call [Builder.responseFields] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun responseFields(responseFields: MultipartField>) = apply { + body.responseFields(responseFields) + } + + /** + * Adds a single [ResponseField] to [responseFields]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResponseField(responseField: ResponseField) = apply { + body.addResponseField(responseField) + } + + /** + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. + * Learn how to create a signature on the page below. This should be in lowercase. + * + * Signature must be calculated on the server-side. This field is only required for + * authentication when uploading a file from the client side. + */ + fun signature(signature: String) = apply { body.signature(signature) } + + /** + * Sets [Builder.signature] to an arbitrary multipart value. + * + * You should usually call [Builder.signature] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun signature(signature: MultipartField) = apply { body.signature(signature) } + + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", + * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the + * `%` character is not allowed. If this field is not specified and the file is overwritten, + * the existing tags will be removed. + */ + fun tags(tags: List) = apply { body.tags(tags) } + + /** + * Sets [Builder.tags] to an arbitrary multipart value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: MultipartField>) = apply { body.tags(tags) } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { body.addTag(tag) } + + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing + * file size or applying basic optimizations upfront (e.g., resize, compress). + * - `post` — applied immediately after upload. Ideal for generating transformed versions + * (like video encodes or thumbnails) in advance, so they're ready for delivery without + * delay. + * + * You can mix and match any combination of post-processing types. + */ + fun transformation(transformation: Transformation) = apply { + body.transformation(transformation) + } + + /** + * Sets [Builder.transformation] to an arbitrary multipart value. + * + * You should usually call [Builder.transformation] with a well-typed [Transformation] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun transformation(transformation: MultipartField) = apply { + body.transformation(transformation) + } + + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique + * filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any + * existing file with the same name is replaced. + */ + fun useUniqueFileName(useUniqueFileName: Boolean) = apply { + body.useUniqueFileName(useUniqueFileName) + } + + /** + * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. + * + * You should usually call [Builder.useUniqueFileName] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useUniqueFileName(useUniqueFileName: MultipartField) = apply { + body.useUniqueFileName(useUniqueFileName) + } + + /** + * The final status of extensions after they have completed execution will be delivered to + * this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + */ + fun webhookUrl(webhookUrl: String) = apply { body.webhookUrl(webhookUrl) } + + /** + * Sets [Builder.webhookUrl] to an arbitrary multipart value. + * + * You should usually call [Builder.webhookUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun webhookUrl(webhookUrl: MultipartField) = apply { body.webhookUrl(webhookUrl) } + + 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 [FileUploadParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .file() + * .fileName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FileUploadParams = + FileUploadParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _body(): Map> = + (mapOf( + "file" to _file(), + "fileName" to _fileName(), + "token" to _token(), + "checks" to _checks(), + "customCoordinates" to _customCoordinates(), + "customMetadata" to _customMetadata(), + "description" to _description(), + "expire" to _expire(), + "extensions" to _extensions(), + "folder" to _folder(), + "isPrivateFile" to _isPrivateFile(), + "isPublished" to _isPublished(), + "overwriteAITags" to _overwriteAiTags(), + "overwriteCustomMetadata" to _overwriteCustomMetadata(), + "overwriteFile" to _overwriteFile(), + "overwriteTags" to _overwriteTags(), + "publicKey" to _publicKey(), + "responseFields" to _responseFields(), + "signature" to _signature(), + "tags" to _tags(), + "transformation" to _transformation(), + "useUniqueFileName" to _useUniqueFileName(), + "webhookUrl" to _webhookUrl(), + ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) + .toImmutable() + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val file: MultipartField, + private val fileName: MultipartField, + private val token: MultipartField, + private val checks: MultipartField, + private val customCoordinates: MultipartField, + private val customMetadata: MultipartField, + private val description: MultipartField, + private val expire: MultipartField, + private val extensions: MultipartField>, + private val folder: MultipartField, + private val isPrivateFile: MultipartField, + private val isPublished: MultipartField, + private val overwriteAiTags: MultipartField, + private val overwriteCustomMetadata: MultipartField, + private val overwriteFile: MultipartField, + private val overwriteTags: MultipartField, + private val publicKey: MultipartField, + private val responseFields: MultipartField>, + private val signature: MultipartField, + private val tags: MultipartField>, + private val transformation: MultipartField, + private val useUniqueFileName: MultipartField, + private val webhookUrl: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + * + * @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 file(): InputStream = file.value.getRequired("file") + + /** + * The name with which the file has to be uploaded. The file name can contain: + * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + * - Special Characters: `.`, `-` + * + * Any other character including space will be replaced by `_` + * + * @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 fileName(): String = fileName.value.getRequired("fileName") + + /** + * A unique value that the ImageKit.io server will use to recognize and prevent subsequent + * retries for the same request. We suggest using V4 UUIDs, or another random string with + * enough entropy to avoid collisions. This field is only required for authentication when + * uploading a file from the client side. + * + * **Note**: Sending a value that has been used in the past will result in a validation + * error. Even if your previous request resulted in an error, you should always send a new + * value for this field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun token(): Optional = token.value.getOptional("token") + + /** + * Server-side checks to run on the asset. Read more about + * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun checks(): Optional = checks.value.getOptional("checks") + + /** + * Define an important area in the image. This is only relevant for image type files. + * - To be passed as a string with the x and y coordinates of the top-left corner, and width + * and height of the area of interest in the format `x,y,width,height`. For example - + * `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates will + * be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customCoordinates(): Optional = + customCoordinates.value.getOptional("customCoordinates") + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields + * before setting these values. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customMetadata(): Optional = + customMetadata.value.getOptional("customMetadata") + + /** + * Optional text to describe the contents of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.value.getOptional("description") + + /** + * The time until your signature is valid. It must be a + * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. + * It should be in seconds. This field is only required for authentication when uploading a + * file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun expire(): Optional = expire.value.getOptional("expire") + + /** + * Array of extensions to be applied to the image. Each extension can be configured with + * specific parameters based on the extension type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun extensions(): Optional> = extensions.value.getOptional("extensions") + + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't exist + * before, a new folder(s) is created. + * + * The folder name can contain: + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun folder(): Optional = folder.value.getOptional("folder") + + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named + * transformation or signed URL. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isPrivateFile(): Optional = isPrivateFile.value.getOptional("isPrivateFile") + + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file only + * via the media library. Files in draft or unpublished state can only be publicly accessed + * after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing plans. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isPublished(): Optional = isPublished.value.getOptional("isPublished") + + /** + * If set to `true` and a file already exists at the exact location, its AITags will be + * removed. Set `overwriteAITags` to `false` to preserve AITags. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun overwriteAiTags(): Optional = + overwriteAiTags.value.getOptional("overwriteAITags") + + /** + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun overwriteCustomMetadata(): Optional = + overwriteCustomMetadata.value.getOptional("overwriteCustomMetadata") + + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the + * exact location, upload API will return an error immediately. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun overwriteFile(): Optional = overwriteFile.value.getOptional("overwriteFile") + + /** + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun overwriteTags(): Optional = overwriteTags.value.getOptional("overwriteTags") + + /** + * Your ImageKit.io public key. This field is only required for authentication when + * uploading a file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun publicKey(): Optional = publicKey.value.getOptional("publicKey") + + /** + * Array of response field keys to include in the API response body. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun responseFields(): Optional> = + responseFields.value.getOptional("responseFields") + + /** + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. + * Learn how to create a signature on the page below. This should be in lowercase. + * + * Signature must be calculated on the server-side. This field is only required for + * authentication when uploading a file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun signature(): Optional = signature.value.getOptional("signature") + + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", + * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the + * `%` character is not allowed. If this field is not specified and the file is overwritten, + * the existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tags(): Optional> = tags.value.getOptional("tags") + + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing + * file size or applying basic optimizations upfront (e.g., resize, compress). + * - `post` — applied immediately after upload. Ideal for generating transformed versions + * (like video encodes or thumbnails) in advance, so they're ready for delivery without + * delay. + * + * You can mix and match any combination of post-processing types. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun transformation(): Optional = + transformation.value.getOptional("transformation") + + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique + * filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any + * existing file with the same name is replaced. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun useUniqueFileName(): Optional = + useUniqueFileName.value.getOptional("useUniqueFileName") + + /** + * The final status of extensions after they have completed execution will be delivered to + * this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookUrl(): Optional = webhookUrl.value.getOptional("webhookUrl") + + /** + * Returns the raw multipart value of [file]. + * + * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField = file + + /** + * Returns the raw multipart value of [fileName]. + * + * Unlike [fileName], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("fileName") @ExcludeMissing fun _fileName(): MultipartField = fileName + + /** + * Returns the raw multipart value of [token]. + * + * Unlike [token], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): MultipartField = token + + /** + * Returns the raw multipart value of [checks]. + * + * Unlike [checks], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("checks") @ExcludeMissing fun _checks(): MultipartField = checks + + /** + * Returns the raw multipart value of [customCoordinates]. + * + * Unlike [customCoordinates], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("customCoordinates") + @ExcludeMissing + fun _customCoordinates(): MultipartField = customCoordinates + + /** + * Returns the raw multipart value of [customMetadata]. + * + * Unlike [customMetadata], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): MultipartField = customMetadata + + /** + * Returns the raw multipart value of [description]. + * + * Unlike [description], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): MultipartField = description + + /** + * Returns the raw multipart value of [expire]. + * + * Unlike [expire], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("expire") @ExcludeMissing fun _expire(): MultipartField = expire + + /** + * Returns the raw multipart value of [extensions]. + * + * Unlike [extensions], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("extensions") + @ExcludeMissing + fun _extensions(): MultipartField> = extensions + + /** + * Returns the raw multipart value of [folder]. + * + * Unlike [folder], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("folder") @ExcludeMissing fun _folder(): MultipartField = folder + + /** + * Returns the raw multipart value of [isPrivateFile]. + * + * Unlike [isPrivateFile], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("isPrivateFile") + @ExcludeMissing + fun _isPrivateFile(): MultipartField = isPrivateFile + + /** + * Returns the raw multipart value of [isPublished]. + * + * Unlike [isPublished], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("isPublished") + @ExcludeMissing + fun _isPublished(): MultipartField = isPublished + + /** + * Returns the raw multipart value of [overwriteAiTags]. + * + * Unlike [overwriteAiTags], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteAITags") + @ExcludeMissing + fun _overwriteAiTags(): MultipartField = overwriteAiTags + + /** + * Returns the raw multipart value of [overwriteCustomMetadata]. + * + * Unlike [overwriteCustomMetadata], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteCustomMetadata") + @ExcludeMissing + fun _overwriteCustomMetadata(): MultipartField = overwriteCustomMetadata + + /** + * Returns the raw multipart value of [overwriteFile]. + * + * Unlike [overwriteFile], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteFile") + @ExcludeMissing + fun _overwriteFile(): MultipartField = overwriteFile + + /** + * Returns the raw multipart value of [overwriteTags]. + * + * Unlike [overwriteTags], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteTags") + @ExcludeMissing + fun _overwriteTags(): MultipartField = overwriteTags + + /** + * Returns the raw multipart value of [publicKey]. + * + * Unlike [publicKey], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("publicKey") + @ExcludeMissing + fun _publicKey(): MultipartField = publicKey + + /** + * Returns the raw multipart value of [responseFields]. + * + * Unlike [responseFields], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("responseFields") + @ExcludeMissing + fun _responseFields(): MultipartField> = responseFields + + /** + * Returns the raw multipart value of [signature]. + * + * Unlike [signature], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("signature") + @ExcludeMissing + fun _signature(): MultipartField = signature + + /** + * Returns the raw multipart value of [tags]. + * + * Unlike [tags], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): MultipartField> = tags + + /** + * Returns the raw multipart value of [transformation]. + * + * Unlike [transformation], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("transformation") + @ExcludeMissing + fun _transformation(): MultipartField = transformation + + /** + * Returns the raw multipart value of [useUniqueFileName]. + * + * Unlike [useUniqueFileName], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("useUniqueFileName") + @ExcludeMissing + fun _useUniqueFileName(): MultipartField = useUniqueFileName + + /** + * Returns the raw multipart value of [webhookUrl]. + * + * Unlike [webhookUrl], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("webhookUrl") + @ExcludeMissing + fun _webhookUrl(): MultipartField = webhookUrl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @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 + * .file() + * .fileName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var file: MultipartField? = null + private var fileName: MultipartField? = null + private var token: MultipartField = MultipartField.of(null) + private var checks: MultipartField = MultipartField.of(null) + private var customCoordinates: MultipartField = MultipartField.of(null) + private var customMetadata: MultipartField = MultipartField.of(null) + private var description: MultipartField = MultipartField.of(null) + private var expire: MultipartField = MultipartField.of(null) + private var extensions: MultipartField>? = null + private var folder: MultipartField = MultipartField.of(null) + private var isPrivateFile: MultipartField = MultipartField.of(null) + private var isPublished: MultipartField = MultipartField.of(null) + private var overwriteAiTags: MultipartField = MultipartField.of(null) + private var overwriteCustomMetadata: MultipartField = MultipartField.of(null) + private var overwriteFile: MultipartField = MultipartField.of(null) + private var overwriteTags: MultipartField = MultipartField.of(null) + private var publicKey: MultipartField = MultipartField.of(null) + private var responseFields: MultipartField>? = null + private var signature: MultipartField = MultipartField.of(null) + private var tags: MultipartField>? = null + private var transformation: MultipartField = MultipartField.of(null) + private var useUniqueFileName: MultipartField = MultipartField.of(null) + private var webhookUrl: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + file = body.file + fileName = body.fileName + token = body.token + checks = body.checks + customCoordinates = body.customCoordinates + customMetadata = body.customMetadata + description = body.description + expire = body.expire + extensions = body.extensions.map { it.toMutableList() } + folder = body.folder + isPrivateFile = body.isPrivateFile + isPublished = body.isPublished + overwriteAiTags = body.overwriteAiTags + overwriteCustomMetadata = body.overwriteCustomMetadata + overwriteFile = body.overwriteFile + overwriteTags = body.overwriteTags + publicKey = body.publicKey + responseFields = body.responseFields.map { it.toMutableList() } + signature = body.signature + tags = body.tags.map { it.toMutableList() } + transformation = body.transformation + useUniqueFileName = body.useUniqueFileName + webhookUrl = body.webhookUrl + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(file: InputStream) = file(MultipartField.of(file)) + + /** + * Sets [Builder.file] to an arbitrary multipart value. + * + * You should usually call [Builder.file] with a well-typed [InputStream] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun file(file: MultipartField) = apply { this.file = file } + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(file: ByteArray) = file(file.inputStream()) + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(path: Path) = + file( + MultipartField.builder() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + /** + * The name with which the file has to be uploaded. The file name can contain: + * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + * - Special Characters: `.`, `-` + * + * Any other character including space will be replaced by `_` + */ + fun fileName(fileName: String) = fileName(MultipartField.of(fileName)) + + /** + * Sets [Builder.fileName] to an arbitrary multipart value. + * + * You should usually call [Builder.fileName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fileName(fileName: MultipartField) = apply { this.fileName = fileName } + + /** + * A unique value that the ImageKit.io server will use to recognize and prevent + * subsequent retries for the same request. We suggest using V4 UUIDs, or another random + * string with enough entropy to avoid collisions. This field is only required for + * authentication when uploading a file from the client side. + * + * **Note**: Sending a value that has been used in the past will result in a validation + * error. Even if your previous request resulted in an error, you should always send a + * new value for this field. + */ + fun token(token: String) = token(MultipartField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary multipart value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: MultipartField) = apply { this.token = token } + + /** + * Server-side checks to run on the asset. Read more about + * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + */ + fun checks(checks: String) = checks(MultipartField.of(checks)) + + /** + * Sets [Builder.checks] to an arbitrary multipart value. + * + * You should usually call [Builder.checks] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun checks(checks: MultipartField) = apply { this.checks = checks } + + /** + * Define an important area in the image. This is only relevant for image type files. + * - To be passed as a string with the x and y coordinates of the top-left corner, and + * width and height of the area of interest in the format `x,y,width,height`. For + * example - `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates + * will be removed. + */ + fun customCoordinates(customCoordinates: String) = + customCoordinates(MultipartField.of(customCoordinates)) + + /** + * Sets [Builder.customCoordinates] to an arbitrary multipart value. + * + * You should usually call [Builder.customCoordinates] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customCoordinates(customCoordinates: MultipartField) = apply { + this.customCoordinates = customCoordinates + } + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields + * before setting these values. + */ + fun customMetadata(customMetadata: CustomMetadata) = + customMetadata(MultipartField.of(customMetadata)) + + /** + * Sets [Builder.customMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.customMetadata] with a well-typed [CustomMetadata] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun customMetadata(customMetadata: MultipartField) = apply { + this.customMetadata = customMetadata + } + + /** Optional text to describe the contents of the file. */ + fun description(description: String) = description(MultipartField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary multipart 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: MultipartField) = apply { + this.description = description + } + + /** + * The time until your signature is valid. It must be a + * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the + * future. It should be in seconds. This field is only required for authentication when + * uploading a file from the client side. + */ + fun expire(expire: Long) = expire(MultipartField.of(expire)) + + /** + * Sets [Builder.expire] to an arbitrary multipart value. + * + * You should usually call [Builder.expire] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun expire(expire: MultipartField) = apply { this.expire = expire } + + /** + * Array of extensions to be applied to the image. Each extension can be configured with + * specific parameters based on the extension type. + */ + fun extensions(extensions: List) = extensions(MultipartField.of(extensions)) + + /** + * Sets [Builder.extensions] to an arbitrary multipart value. + * + * You should usually call [Builder.extensions] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun extensions(extensions: MultipartField>) = apply { + this.extensions = extensions.map { it.toMutableList() } + } + + /** + * Adds a single [Extension] to [extensions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExtension(extension: Extension) = apply { + extensions = + (extensions ?: MultipartField.of(mutableListOf())).also { + checkKnown("extensions", it).add(extension) + } + } + + /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ + fun addExtension(removeBg: Extension.RemoveBg) = + addExtension(Extension.ofRemoveBg(removeBg)) + + /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = + addExtension(Extension.ofAutoTagging(autoTagging)) + + /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ + fun addExtensionAiAutoDescription() = addExtension(Extension.ofAiAutoDescription()) + + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't exist + * before, a new folder(s) is created. + * + * The folder name can contain: + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. + */ + fun folder(folder: String) = folder(MultipartField.of(folder)) + + /** + * Sets [Builder.folder] to an arbitrary multipart value. + * + * You should usually call [Builder.folder] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun folder(folder: MultipartField) = apply { this.folder = folder } + + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named + * transformation or signed URL. + */ + fun isPrivateFile(isPrivateFile: Boolean) = + isPrivateFile(MultipartField.of(isPrivateFile)) + + /** + * Sets [Builder.isPrivateFile] to an arbitrary multipart value. + * + * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPrivateFile(isPrivateFile: MultipartField) = apply { + this.isPrivateFile = isPrivateFile + } + + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file + * only via the media library. Files in draft or unpublished state can only be publicly + * accessed after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing + * plans. + */ + fun isPublished(isPublished: Boolean) = isPublished(MultipartField.of(isPublished)) + + /** + * Sets [Builder.isPublished] to an arbitrary multipart value. + * + * You should usually call [Builder.isPublished] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPublished(isPublished: MultipartField) = apply { + this.isPublished = isPublished + } + + /** + * If set to `true` and a file already exists at the exact location, its AITags will be + * removed. Set `overwriteAITags` to `false` to preserve AITags. + */ + fun overwriteAiTags(overwriteAiTags: Boolean) = + overwriteAiTags(MultipartField.of(overwriteAiTags)) + + /** + * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteAiTags] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteAiTags(overwriteAiTags: MultipartField) = apply { + this.overwriteAiTags = overwriteAiTags + } + + /** + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: Boolean) = + overwriteCustomMetadata(MultipartField.of(overwriteCustomMetadata)) + + /** + * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteCustomMetadata] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: MultipartField) = apply { + this.overwriteCustomMetadata = overwriteCustomMetadata + } + + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the + * exact location, upload API will return an error immediately. + */ + fun overwriteFile(overwriteFile: Boolean) = + overwriteFile(MultipartField.of(overwriteFile)) + + /** + * Sets [Builder.overwriteFile] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteFile(overwriteFile: MultipartField) = apply { + this.overwriteFile = overwriteFile + } + + /** + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + */ + fun overwriteTags(overwriteTags: Boolean) = + overwriteTags(MultipartField.of(overwriteTags)) + + /** + * Sets [Builder.overwriteTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteTags] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteTags(overwriteTags: MultipartField) = apply { + this.overwriteTags = overwriteTags + } + + /** + * Your ImageKit.io public key. This field is only required for authentication when + * uploading a file from the client side. + */ + fun publicKey(publicKey: String) = publicKey(MultipartField.of(publicKey)) + + /** + * Sets [Builder.publicKey] to an arbitrary multipart value. + * + * You should usually call [Builder.publicKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun publicKey(publicKey: MultipartField) = apply { this.publicKey = publicKey } + + /** Array of response field keys to include in the API response body. */ + fun responseFields(responseFields: List) = + responseFields(MultipartField.of(responseFields)) + + /** + * Sets [Builder.responseFields] to an arbitrary multipart value. + * + * You should usually call [Builder.responseFields] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun responseFields(responseFields: MultipartField>) = apply { + this.responseFields = responseFields.map { it.toMutableList() } + } + + /** + * Adds a single [ResponseField] to [responseFields]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResponseField(responseField: ResponseField) = apply { + responseFields = + (responseFields ?: MultipartField.of(mutableListOf())).also { + checkKnown("responseFields", it).add(responseField) + } + } + + /** + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. + * Learn how to create a signature on the page below. This should be in lowercase. + * + * Signature must be calculated on the server-side. This field is only required for + * authentication when uploading a file from the client side. + */ + fun signature(signature: String) = signature(MultipartField.of(signature)) + + /** + * Sets [Builder.signature] to an arbitrary multipart value. + * + * You should usually call [Builder.signature] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun signature(signature: MultipartField) = apply { this.signature = signature } + + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. + * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not + * exceed 500, and the `%` character is not allowed. If this field is not specified and + * the file is overwritten, the existing tags will be removed. + */ + fun tags(tags: List) = tags(MultipartField.of(tags)) + + /** + * Sets [Builder.tags] to an arbitrary multipart value. + * + * You should usually call [Builder.tags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tags(tags: MultipartField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = + (tags ?: MultipartField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } + + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for + * reducing file size or applying basic optimizations upfront (e.g., resize, + * compress). + * - `post` — applied immediately after upload. Ideal for generating transformed + * versions (like video encodes or thumbnails) in advance, so they're ready for + * delivery without delay. + * + * You can mix and match any combination of post-processing types. + */ + fun transformation(transformation: Transformation) = + transformation(MultipartField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary multipart value. + * + * You should usually call [Builder.transformation] with a well-typed [Transformation] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun transformation(transformation: MultipartField) = apply { + this.transformation = transformation + } + + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a + * unique filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any + * existing file with the same name is replaced. + */ + fun useUniqueFileName(useUniqueFileName: Boolean) = + useUniqueFileName(MultipartField.of(useUniqueFileName)) + + /** + * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. + * + * You should usually call [Builder.useUniqueFileName] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useUniqueFileName(useUniqueFileName: MultipartField) = apply { + this.useUniqueFileName = useUniqueFileName + } + + /** + * The final status of extensions after they have completed execution will be delivered + * to this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + */ + fun webhookUrl(webhookUrl: String) = webhookUrl(MultipartField.of(webhookUrl)) + + /** + * Sets [Builder.webhookUrl] to an arbitrary multipart value. + * + * You should usually call [Builder.webhookUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun webhookUrl(webhookUrl: MultipartField) = apply { + this.webhookUrl = webhookUrl + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .file() + * .fileName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("file", file), + checkRequired("fileName", fileName), + token, + checks, + customCoordinates, + customMetadata, + description, + expire, + (extensions ?: MultipartField.of(null)).map { it.toImmutable() }, + folder, + isPrivateFile, + isPublished, + overwriteAiTags, + overwriteCustomMetadata, + overwriteFile, + overwriteTags, + publicKey, + (responseFields ?: MultipartField.of(null)).map { it.toImmutable() }, + signature, + (tags ?: MultipartField.of(null)).map { it.toImmutable() }, + transformation, + useUniqueFileName, + webhookUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + file() + fileName() + token() + checks() + customCoordinates() + customMetadata().ifPresent { it.validate() } + description() + expire() + extensions().ifPresent { it.forEach { it.validate() } } + folder() + isPrivateFile() + isPublished() + overwriteAiTags() + overwriteCustomMetadata() + overwriteFile() + overwriteTags() + publicKey() + responseFields().ifPresent { it.forEach { it.validate() } } + signature() + tags() + transformation().ifPresent { it.validate() } + useUniqueFileName() + webhookUrl() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + file == other.file && + fileName == other.fileName && + token == other.token && + checks == other.checks && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + description == other.description && + expire == other.expire && + extensions == other.extensions && + folder == other.folder && + isPrivateFile == other.isPrivateFile && + isPublished == other.isPublished && + overwriteAiTags == other.overwriteAiTags && + overwriteCustomMetadata == other.overwriteCustomMetadata && + overwriteFile == other.overwriteFile && + overwriteTags == other.overwriteTags && + publicKey == other.publicKey && + responseFields == other.responseFields && + signature == other.signature && + tags == other.tags && + transformation == other.transformation && + useUniqueFileName == other.useUniqueFileName && + webhookUrl == other.webhookUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + file, + fileName, + token, + checks, + customCoordinates, + customMetadata, + description, + expire, + extensions, + folder, + isPrivateFile, + isPublished, + overwriteAiTags, + overwriteCustomMetadata, + overwriteFile, + overwriteTags, + publicKey, + responseFields, + signature, + tags, + transformation, + useUniqueFileName, + webhookUrl, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, expire=$expire, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, publicKey=$publicKey, responseFields=$responseFields, signature=$signature, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + } + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields before + * setting these values. + */ + class CustomMetadata + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CustomMetadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customMetadata: CustomMetadata) = apply { + additionalProperties = customMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CustomMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomMetadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Extension.Deserializer::class) + @JsonSerialize(using = Extension.Serializer::class) + class Extension + private constructor( + private val removeBg: RemoveBg? = null, + private val autoTagging: AutoTaggingExtension? = null, + private val aiAutoDescription: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun removeBg(): Optional = Optional.ofNullable(removeBg) + + fun autoTagging(): Optional = Optional.ofNullable(autoTagging) + + fun aiAutoDescription(): Optional = Optional.ofNullable(aiAutoDescription) + + fun isRemoveBg(): Boolean = removeBg != null + + fun isAutoTagging(): Boolean = autoTagging != null + + fun isAiAutoDescription(): Boolean = aiAutoDescription != null + + fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") + + fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") + + fun asAiAutoDescription(): JsonValue = aiAutoDescription.getOrThrow("aiAutoDescription") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + removeBg != null -> visitor.visitRemoveBg(removeBg) + autoTagging != null -> visitor.visitAutoTagging(autoTagging) + aiAutoDescription != null -> visitor.visitAiAutoDescription(aiAutoDescription) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Extension = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) { + removeBg.validate() + } + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { + autoTagging.validate() + } + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { + aiAutoDescription.let { + if (it != JsonValue.from(mapOf("name" to "ai-auto-description"))) { + throw ImageKitInvalidDataException( + "'aiAutoDescription' is invalid, received $it" + ) + } + } + } + } + ) + 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 = + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = + autoTagging.validity() + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = + aiAutoDescription.let { + if (it == JsonValue.from(mapOf("name" to "ai-auto-description"))) 1 + else 0 + } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extension && + removeBg == other.removeBg && + autoTagging == other.autoTagging && + aiAutoDescription == other.aiAutoDescription + } + + override fun hashCode(): Int = Objects.hash(removeBg, autoTagging, aiAutoDescription) + + override fun toString(): String = + when { + removeBg != null -> "Extension{removeBg=$removeBg}" + autoTagging != null -> "Extension{autoTagging=$autoTagging}" + aiAutoDescription != null -> "Extension{aiAutoDescription=$aiAutoDescription}" + _json != null -> "Extension{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Extension") + } + + companion object { + + @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = Extension(removeBg = removeBg) + + @JvmStatic + fun ofAutoTagging(autoTagging: AutoTaggingExtension) = + Extension(autoTagging = autoTagging) + + @JvmStatic + fun ofAiAutoDescription() = + Extension( + aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) + ) + } + + /** + * An interface that defines how to map each variant of [Extension] to a value of type [T]. + */ + interface Visitor { + + fun visitRemoveBg(removeBg: RemoveBg): T + + fun visitAutoTagging(autoTagging: AutoTaggingExtension): T + + fun visitAiAutoDescription(aiAutoDescription: JsonValue): T + + /** + * Maps an unknown variant of [Extension] to a value of type [T]. + * + * An instance of [Extension] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Extension: $json") + } + } + + internal class Deserializer : BaseDeserializer(Extension::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Extension { + val json = JsonValue.fromJsonNode(node) + val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() + + when (name) { + "remove-bg" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Extension(removeBg = it, _json = json) + } ?: Extension(_json = json) + } + "ai-auto-description" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Extension(aiAutoDescription = it, _json = json) } + ?.takeIf { it.isValid() } ?: Extension(_json = json) + } + } + + return tryDeserialize(node, jacksonTypeRef())?.let { + Extension(autoTagging = it, _json = json) + } ?: Extension(_json = json) + } + } + + internal class Serializer : BaseSerializer(Extension::class) { + + override fun serialize( + value: Extension, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.removeBg != null -> generator.writeObject(value.removeBg) + value.autoTagging != null -> generator.writeObject(value.autoTagging) + value.aiAutoDescription != null -> + generator.writeObject(value.aiAutoDescription) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Extension") + } + } + } + + class RemoveBg + private constructor( + private val name: JsonValue, + private val options: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Specifies the background removal extension. + * + * Expected to always return the following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun options(): Optional = options.value.getOptional("options") + + /** + * Returns the raw multipart value of [options]. + * + * Unlike [options], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("options") + @ExcludeMissing + fun _options(): MultipartField = options + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveBg]. */ + class Builder internal constructor() { + + private var name: JsonValue = JsonValue.from("remove-bg") + private var options: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removeBg: RemoveBg) = apply { + name = removeBg.name + options = removeBg.options + additionalProperties = removeBg.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + fun options(options: Options) = options(MultipartField.of(options)) + + /** + * Sets [Builder.options] to an arbitrary multipart value. + * + * You should usually call [Builder.options] with a well-typed [Options] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun options(options: MultipartField) = apply { this.options = options } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemoveBg]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemoveBg = RemoveBg(name, options, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): RemoveBg = apply { + if (validated) { + return@apply + } + + _name().let { + if (it != JsonValue.from("remove-bg")) { + throw ImageKitInvalidDataException("'name' is invalid, received $it") + } + } + options().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + class Options + private constructor( + private val addShadow: MultipartField, + private val bgColor: MultipartField, + private val bgImageUrl: MultipartField, + private val semitransparency: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Whether to add an artificial shadow to the result. Default is false. Note: Adding + * shadows is currently only supported for car photos. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun addShadow(): Optional = addShadow.value.getOptional("add_shadow") + + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or + * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be + * empty. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun bgColor(): Optional = bgColor.value.getOptional("bg_color") + + /** + * Sets a background image from a URL. If this parameter is set, `bg_color` must be + * empty. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun bgImageUrl(): Optional = bgImageUrl.value.getOptional("bg_image_url") + + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun semitransparency(): Optional = + semitransparency.value.getOptional("semitransparency") + + /** + * Returns the raw multipart value of [addShadow]. + * + * Unlike [addShadow], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("add_shadow") + @ExcludeMissing + fun _addShadow(): MultipartField = addShadow + + /** + * Returns the raw multipart value of [bgColor]. + * + * Unlike [bgColor], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("bg_color") + @ExcludeMissing + fun _bgColor(): MultipartField = bgColor + + /** + * Returns the raw multipart value of [bgImageUrl]. + * + * Unlike [bgImageUrl], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("bg_image_url") + @ExcludeMissing + fun _bgImageUrl(): MultipartField = bgImageUrl + + /** + * Returns the raw multipart value of [semitransparency]. + * + * Unlike [semitransparency], this method doesn't throw if the multipart field has + * an unexpected type. + */ + @JsonProperty("semitransparency") + @ExcludeMissing + fun _semitransparency(): MultipartField = semitransparency + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Options]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Options]. */ + class Builder internal constructor() { + + private var addShadow: MultipartField = MultipartField.of(null) + private var bgColor: MultipartField = MultipartField.of(null) + private var bgImageUrl: MultipartField = MultipartField.of(null) + private var semitransparency: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(options: Options) = apply { + addShadow = options.addShadow + bgColor = options.bgColor + bgImageUrl = options.bgImageUrl + semitransparency = options.semitransparency + additionalProperties = options.additionalProperties.toMutableMap() + } + + /** + * Whether to add an artificial shadow to the result. Default is false. Note: + * Adding shadows is currently only supported for car photos. + */ + fun addShadow(addShadow: Boolean) = addShadow(MultipartField.of(addShadow)) + + /** + * Sets [Builder.addShadow] to an arbitrary multipart value. + * + * You should usually call [Builder.addShadow] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun addShadow(addShadow: MultipartField) = apply { + this.addShadow = addShadow + } + + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or + * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be + * empty. + */ + fun bgColor(bgColor: String) = bgColor(MultipartField.of(bgColor)) + + /** + * Sets [Builder.bgColor] to an arbitrary multipart value. + * + * You should usually call [Builder.bgColor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun bgColor(bgColor: MultipartField) = apply { this.bgColor = bgColor } + + /** + * Sets a background image from a URL. If this parameter is set, `bg_color` must + * be empty. + */ + fun bgImageUrl(bgImageUrl: String) = bgImageUrl(MultipartField.of(bgImageUrl)) + + /** + * Sets [Builder.bgImageUrl] to an arbitrary multipart value. + * + * You should usually call [Builder.bgImageUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun bgImageUrl(bgImageUrl: MultipartField) = apply { + this.bgImageUrl = bgImageUrl + } + + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + */ + fun semitransparency(semitransparency: Boolean) = + semitransparency(MultipartField.of(semitransparency)) + + /** + * Sets [Builder.semitransparency] to an arbitrary multipart value. + * + * You should usually call [Builder.semitransparency] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun semitransparency(semitransparency: MultipartField) = apply { + this.semitransparency = semitransparency + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Options]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Options = + Options( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Options = apply { + if (validated) { + return@apply + } + + addShadow() + bgColor() + bgImageUrl() + semitransparency() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Options && + addShadow == other.addShadow && + bgColor == other.bgColor && + bgImageUrl == other.bgImageUrl && + semitransparency == other.semitransparency && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveBg && + name == other.name && + options == other.options && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, options, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" + } + + class AutoTaggingExtension + private constructor( + private val maxTags: MultipartField, + private val minConfidence: MultipartField, + private val name: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Maximum number of tags to attach to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun maxTags(): Long = maxTags.value.getRequired("maxTags") + + /** + * Minimum confidence level for tags to be considered valid. + * + * @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 minConfidence(): Long = minConfidence.value.getRequired("minConfidence") + + /** + * Specifies the auto-tagging extension used. + * + * @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(): Name = name.value.getRequired("name") + + /** + * Returns the raw multipart value of [maxTags]. + * + * Unlike [maxTags], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("maxTags") @ExcludeMissing fun _maxTags(): MultipartField = maxTags + + /** + * Returns the raw multipart value of [minConfidence]. + * + * Unlike [minConfidence], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("minConfidence") + @ExcludeMissing + fun _minConfidence(): MultipartField = minConfidence + + /** + * Returns the raw multipart value of [name]. + * + * Unlike [name], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AutoTaggingExtension]. + * + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutoTaggingExtension]. */ + class Builder internal constructor() { + + private var maxTags: MultipartField? = null + private var minConfidence: MultipartField? = null + private var name: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { + maxTags = autoTaggingExtension.maxTags + minConfidence = autoTaggingExtension.minConfidence + name = autoTaggingExtension.name + additionalProperties = autoTaggingExtension.additionalProperties.toMutableMap() + } + + /** Maximum number of tags to attach to the asset. */ + fun maxTags(maxTags: Long) = maxTags(MultipartField.of(maxTags)) + + /** + * Sets [Builder.maxTags] to an arbitrary multipart value. + * + * You should usually call [Builder.maxTags] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxTags(maxTags: MultipartField) = apply { this.maxTags = maxTags } + + /** Minimum confidence level for tags to be considered valid. */ + fun minConfidence(minConfidence: Long) = + minConfidence(MultipartField.of(minConfidence)) + + /** + * Sets [Builder.minConfidence] to an arbitrary multipart value. + * + * You should usually call [Builder.minConfidence] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun minConfidence(minConfidence: MultipartField) = apply { + this.minConfidence = minConfidence + } + + /** Specifies the auto-tagging extension used. */ + fun name(name: Name) = name(MultipartField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary multipart value. + * + * You should usually call [Builder.name] with a well-typed [Name] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: MultipartField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutoTaggingExtension]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutoTaggingExtension = + AutoTaggingExtension( + checkRequired("maxTags", maxTags), + checkRequired("minConfidence", minConfidence), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutoTaggingExtension = apply { + if (validated) { + return@apply + } + + maxTags() + minConfidence() + name().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Specifies the auto-tagging extension used. */ + class Name @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") + + @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + } + + /** + * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Name] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + /** + * An enum member indicating that [Name] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING + else -> throw ImageKitInvalidDataException("Unknown Name: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Name = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Name && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutoTaggingExtension && + maxTags == other.maxTags && + minConfidence == other.minConfidence && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(maxTags, minConfidence, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" + } + } + + class ResponseField @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TAGS = of("tags") + + @JvmField val CUSTOM_COORDINATES = of("customCoordinates") + + @JvmField val IS_PRIVATE_FILE = of("isPrivateFile") + + @JvmField val EMBEDDED_METADATA = of("embeddedMetadata") + + @JvmField val IS_PUBLISHED = of("isPublished") + + @JvmField val CUSTOM_METADATA = of("customMetadata") + + @JvmField val METADATA = of("metadata") + + @JvmStatic fun of(value: String) = ResponseField(JsonField.of(value)) + } + + /** An enum containing [ResponseField]'s known values. */ + enum class Known { + TAGS, + CUSTOM_COORDINATES, + IS_PRIVATE_FILE, + EMBEDDED_METADATA, + IS_PUBLISHED, + CUSTOM_METADATA, + METADATA, + } + + /** + * An enum containing [ResponseField]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ResponseField] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TAGS, + CUSTOM_COORDINATES, + IS_PRIVATE_FILE, + EMBEDDED_METADATA, + IS_PUBLISHED, + CUSTOM_METADATA, + METADATA, + /** + * An enum member indicating that [ResponseField] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TAGS -> Value.TAGS + CUSTOM_COORDINATES -> Value.CUSTOM_COORDINATES + IS_PRIVATE_FILE -> Value.IS_PRIVATE_FILE + EMBEDDED_METADATA -> Value.EMBEDDED_METADATA + IS_PUBLISHED -> Value.IS_PUBLISHED + CUSTOM_METADATA -> Value.CUSTOM_METADATA + METADATA -> Value.METADATA + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TAGS -> Known.TAGS + CUSTOM_COORDINATES -> Known.CUSTOM_COORDINATES + IS_PRIVATE_FILE -> Known.IS_PRIVATE_FILE + EMBEDDED_METADATA -> Known.EMBEDDED_METADATA + IS_PUBLISHED -> Known.IS_PUBLISHED + CUSTOM_METADATA -> Known.CUSTOM_METADATA + METADATA -> Known.METADATA + else -> throw ImageKitInvalidDataException("Unknown ResponseField: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ResponseField = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResponseField && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing file + * size or applying basic optimizations upfront (e.g., resize, compress). + * - `post` — applied immediately after upload. Ideal for generating transformed versions (like + * video encodes or thumbnails) in advance, so they're ready for delivery without delay. + * + * You can mix and match any combination of post-processing types. + */ + class Transformation + private constructor( + private val post: MultipartField>, + private val pre: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * List of transformations to apply _after_ the file is uploaded. Each item must match one + * of the following types: `transformation`, `gif-to-video`, `thumbnail`, `abs`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun post(): Optional> = post.value.getOptional("post") + + /** + * Transformation string to apply before uploading the file to the Media Library. Useful for + * optimizing files at ingestion. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun pre(): Optional = pre.value.getOptional("pre") + + /** + * Returns the raw multipart value of [post]. + * + * Unlike [post], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("post") @ExcludeMissing fun _post(): MultipartField> = post + + /** + * Returns the raw multipart value of [pre]. + * + * Unlike [pre], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("pre") @ExcludeMissing fun _pre(): MultipartField = pre + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Transformation]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Transformation]. */ + class Builder internal constructor() { + + private var post: MultipartField>? = null + private var pre: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(transformation: Transformation) = apply { + post = transformation.post.map { it.toMutableList() } + pre = transformation.pre + additionalProperties = transformation.additionalProperties.toMutableMap() + } + + /** + * List of transformations to apply _after_ the file is uploaded. Each item must match + * one of the following types: `transformation`, `gif-to-video`, `thumbnail`, `abs`. + */ + fun post(post: List) = post(MultipartField.of(post)) + + /** + * Sets [Builder.post] to an arbitrary multipart value. + * + * You should usually call [Builder.post] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun post(post: MultipartField>) = apply { + this.post = post.map { it.toMutableList() } + } + + /** + * Adds a single [Post] to [Builder.post]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPost(post: Post) = apply { + this.post = + (this.post ?: MultipartField.of(mutableListOf())).also { + checkKnown("post", it).add(post) + } + } + + /** Alias for calling [addPost] with `Post.ofTransformation(transformation)`. */ + fun addPost(transformation: Post.InnerTransformation) = + addPost(Post.ofTransformation(transformation)) + + /** + * Alias for calling [addPost] with the following: + * ```java + * Post.InnerTransformation.builder() + * .value(value) + * .build() + * ``` + */ + fun addTransformationPost(value: String) = + addPost(Post.InnerTransformation.builder().value(value).build()) + + /** Alias for calling [addPost] with `Post.ofGifToVideo(gifToVideo)`. */ + fun addPost(gifToVideo: Post.GifToVideo) = addPost(Post.ofGifToVideo(gifToVideo)) + + /** Alias for calling [addPost] with `Post.ofThumbnail(thumbnail)`. */ + fun addPost(thumbnail: Post.Thumbnail) = addPost(Post.ofThumbnail(thumbnail)) + + /** Alias for calling [addPost] with `Post.ofAbs(abs)`. */ + fun addPost(abs: Post.Abs) = addPost(Post.ofAbs(abs)) + + /** + * Transformation string to apply before uploading the file to the Media Library. Useful + * for optimizing files at ingestion. + */ + fun pre(pre: String) = pre(MultipartField.of(pre)) + + /** + * Sets [Builder.pre] to an arbitrary multipart value. + * + * You should usually call [Builder.pre] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pre(pre: MultipartField) = apply { this.pre = pre } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Transformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Transformation = + Transformation( + (post ?: MultipartField.of(null)).map { it.toImmutable() }, + pre, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Transformation = apply { + if (validated) { + return@apply + } + + post().ifPresent { it.forEach { it.validate() } } + pre() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + @JsonDeserialize(using = Post.Deserializer::class) + @JsonSerialize(using = Post.Serializer::class) + class Post + private constructor( + private val transformation: InnerTransformation? = null, + private val gifToVideo: GifToVideo? = null, + private val thumbnail: Thumbnail? = null, + private val abs: Abs? = null, + private val _json: JsonValue? = null, + ) { + + fun transformation(): Optional = + Optional.ofNullable(transformation) + + fun gifToVideo(): Optional = Optional.ofNullable(gifToVideo) + + fun thumbnail(): Optional = Optional.ofNullable(thumbnail) + + fun abs(): Optional = Optional.ofNullable(abs) + + fun isTransformation(): Boolean = transformation != null + + fun isGifToVideo(): Boolean = gifToVideo != null + + fun isThumbnail(): Boolean = thumbnail != null + + fun isAbs(): Boolean = abs != null + + fun asTransformation(): InnerTransformation = + transformation.getOrThrow("transformation") + + fun asGifToVideo(): GifToVideo = gifToVideo.getOrThrow("gifToVideo") + + fun asThumbnail(): Thumbnail = thumbnail.getOrThrow("thumbnail") + + fun asAbs(): Abs = abs.getOrThrow("abs") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + transformation != null -> visitor.visitTransformation(transformation) + gifToVideo != null -> visitor.visitGifToVideo(gifToVideo) + thumbnail != null -> visitor.visitThumbnail(thumbnail) + abs != null -> visitor.visitAbs(abs) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Post = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTransformation(transformation: InnerTransformation) { + transformation.validate() + } + + override fun visitGifToVideo(gifToVideo: GifToVideo) { + gifToVideo.validate() + } + + override fun visitThumbnail(thumbnail: Thumbnail) { + thumbnail.validate() + } + + override fun visitAbs(abs: Abs) { + abs.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitTransformation(transformation: InnerTransformation) = + transformation.validity() + + override fun visitGifToVideo(gifToVideo: GifToVideo) = gifToVideo.validity() + + override fun visitThumbnail(thumbnail: Thumbnail) = thumbnail.validity() + + override fun visitAbs(abs: Abs) = abs.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Post && + transformation == other.transformation && + gifToVideo == other.gifToVideo && + thumbnail == other.thumbnail && + abs == other.abs + } + + override fun hashCode(): Int = Objects.hash(transformation, gifToVideo, thumbnail, abs) + + override fun toString(): String = + when { + transformation != null -> "Post{transformation=$transformation}" + gifToVideo != null -> "Post{gifToVideo=$gifToVideo}" + thumbnail != null -> "Post{thumbnail=$thumbnail}" + abs != null -> "Post{abs=$abs}" + _json != null -> "Post{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Post") + } + + companion object { + + @JvmStatic + fun ofTransformation(transformation: InnerTransformation) = + Post(transformation = transformation) + + @JvmStatic fun ofGifToVideo(gifToVideo: GifToVideo) = Post(gifToVideo = gifToVideo) + + @JvmStatic fun ofThumbnail(thumbnail: Thumbnail) = Post(thumbnail = thumbnail) + + @JvmStatic fun ofAbs(abs: Abs) = Post(abs = abs) + } + + /** + * An interface that defines how to map each variant of [Post] to a value of type [T]. + */ + interface Visitor { + + fun visitTransformation(transformation: InnerTransformation): T + + fun visitGifToVideo(gifToVideo: GifToVideo): T + + fun visitThumbnail(thumbnail: Thumbnail): T + + fun visitAbs(abs: Abs): T + + /** + * Maps an unknown variant of [Post] to a value of type [T]. + * + * An instance of [Post] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Post: $json") + } + } + + internal class Deserializer : BaseDeserializer(Post::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Post { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "transformation" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Post(transformation = it, _json = json) } + ?: Post(_json = json) + } + "gif-to-video" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(gifToVideo = it, _json = json) + } ?: Post(_json = json) + } + "thumbnail" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(thumbnail = it, _json = json) + } ?: Post(_json = json) + } + "abs" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(abs = it, _json = json) + } ?: Post(_json = json) + } + } + + return Post(_json = json) + } + } + + internal class Serializer : BaseSerializer(Post::class) { + + override fun serialize( + value: Post, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.transformation != null -> generator.writeObject(value.transformation) + value.gifToVideo != null -> generator.writeObject(value.gifToVideo) + value.thumbnail != null -> generator.writeObject(value.thumbnail) + value.abs != null -> generator.writeObject(value.abs) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Post") + } + } + } + + class InnerTransformation + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Transformation type. + * + * Expected to always return the following: + * ```java + * JsonValue.from("transformation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based + * 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 value(): String = value.value.getRequired("value") + + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InnerTransformation]. + * + * The following fields are required: + * ```java + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InnerTransformation]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("transformation") + private var value: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(innerTransformation: InnerTransformation) = apply { + type = innerTransformation.type + value = innerTransformation.value + additionalProperties = + innerTransformation.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("transformation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based + * transformations. + */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InnerTransformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InnerTransformation = + InnerTransformation( + type, + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InnerTransformation = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("transformation")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InnerTransformation && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InnerTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" + } + + class GifToVideo + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Converts an animated GIF into an MP4. + * + * Expected to always return the following: + * ```java + * JsonValue.from("gif-to-video") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Optional transformation string to apply to the output video. **Example**: `q-80` + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.value.getOptional("value") + + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [GifToVideo]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GifToVideo]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("gif-to-video") + private var value: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(gifToVideo: GifToVideo) = apply { + type = gifToVideo.type + value = gifToVideo.value + additionalProperties = gifToVideo.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("gif-to-video") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Optional transformation string to apply to the output video. **Example**: + * `q-80` + */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GifToVideo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GifToVideo = + GifToVideo(type, value, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): GifToVideo = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("gif-to-video")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GifToVideo && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GifToVideo{type=$type, value=$value, additionalProperties=$additionalProperties}" + } + + class Thumbnail + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Generates a thumbnail image. + * + * Expected to always return the following: + * ```java + * JsonValue.from("thumbnail") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Optional transformation string. **Example**: `w-150,h-150` + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.value.getOptional("value") + + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Thumbnail]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Thumbnail]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("thumbnail") + private var value: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(thumbnail: Thumbnail) = apply { + type = thumbnail.type + value = thumbnail.value + additionalProperties = thumbnail.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("thumbnail") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Optional transformation string. **Example**: `w-150,h-150` */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Thumbnail]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Thumbnail = + Thumbnail(type, value, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Thumbnail = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("thumbnail")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Thumbnail && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Thumbnail{type=$type, value=$value, additionalProperties=$additionalProperties}" + } + + class Abs + private constructor( + private val protocol: MultipartField, + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Streaming protocol to use (`hls` or `dash`). + * + * @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 protocol(): Protocol = protocol.value.getRequired("protocol") + + /** + * Adaptive Bitrate Streaming (ABS) setup. + * + * Expected to always return the following: + * ```java + * JsonValue.from("abs") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * List of different representations you want to create separated by an underscore. + * + * @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 value(): String = value.value.getRequired("value") + + /** + * Returns the raw multipart value of [protocol]. + * + * Unlike [protocol], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("protocol") + @ExcludeMissing + fun _protocol(): MultipartField = protocol + + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Abs]. + * + * The following fields are required: + * ```java + * .protocol() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Abs]. */ + class Builder internal constructor() { + + private var protocol: MultipartField? = null + private var type: JsonValue = JsonValue.from("abs") + private var value: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(abs: Abs) = apply { + protocol = abs.protocol + type = abs.type + value = abs.value + additionalProperties = abs.additionalProperties.toMutableMap() + } + + /** Streaming protocol to use (`hls` or `dash`). */ + fun protocol(protocol: Protocol) = protocol(MultipartField.of(protocol)) + + /** + * Sets [Builder.protocol] to an arbitrary multipart value. + * + * You should usually call [Builder.protocol] with a well-typed [Protocol] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun protocol(protocol: MultipartField) = apply { + this.protocol = protocol + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("abs") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * List of different representations you want to create separated by an + * underscore. + */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Abs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .protocol() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Abs = + Abs( + checkRequired("protocol", protocol), + type, + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Abs = apply { + if (validated) { + return@apply + } + + protocol().validate() + _type().let { + if (it != JsonValue.from("abs")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Streaming protocol to use (`hls` or `dash`). */ + class Protocol + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HLS = of("hls") + + @JvmField val DASH = of("dash") + + @JvmStatic fun of(value: String) = Protocol(JsonField.of(value)) + } + + /** An enum containing [Protocol]'s known values. */ + enum class Known { + HLS, + DASH, + } + + /** + * An enum containing [Protocol]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Protocol] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HLS, + DASH, + /** + * An enum member indicating that [Protocol] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HLS -> Value.HLS + DASH -> Value.DASH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HLS -> Known.HLS + DASH -> Known.DASH + else -> throw ImageKitInvalidDataException("Unknown Protocol: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Protocol = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Protocol && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Abs && + protocol == other.protocol && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(protocol, type, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Abs{protocol=$protocol, type=$type, value=$value, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Transformation && + post == other.post && + pre == other.pre && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(post, pre, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Transformation{post=$post, pre=$pre, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FileUploadParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FileUploadParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt new file mode 100644 index 00000000..3323941e --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt @@ -0,0 +1,2619 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Object containing details of a successful upload. */ +class FileUploadResponse +private constructor( + private val aiTags: JsonField>, + private val audioCodec: JsonField, + private val bitRate: JsonField, + private val customCoordinates: JsonField, + private val customMetadata: JsonField, + private val description: JsonField, + private val duration: JsonField, + private val embeddedMetadata: JsonField, + private val extensionStatus: JsonField, + private val fileId: JsonField, + private val filePath: JsonField, + private val fileType: JsonField, + private val height: JsonField, + private val isPrivateFile: JsonField, + private val isPublished: JsonField, + private val metadata: JsonField, + private val name: JsonField, + private val size: JsonField, + private val tags: JsonField>, + private val thumbnailUrl: JsonField, + private val url: JsonField, + private val versionInfo: JsonField, + private val videoCodec: JsonField, + private val width: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("AITags") @ExcludeMissing aiTags: JsonField> = JsonMissing.of(), + @JsonProperty("audioCodec") + @ExcludeMissing + audioCodec: JsonField = JsonMissing.of(), + @JsonProperty("bitRate") @ExcludeMissing bitRate: JsonField = JsonMissing.of(), + @JsonProperty("customCoordinates") + @ExcludeMissing + customCoordinates: JsonField = JsonMissing.of(), + @JsonProperty("customMetadata") + @ExcludeMissing + customMetadata: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), + @JsonProperty("embeddedMetadata") + @ExcludeMissing + embeddedMetadata: JsonField = JsonMissing.of(), + @JsonProperty("extensionStatus") + @ExcludeMissing + extensionStatus: JsonField = JsonMissing.of(), + @JsonProperty("fileId") @ExcludeMissing fileId: JsonField = JsonMissing.of(), + @JsonProperty("filePath") @ExcludeMissing filePath: JsonField = JsonMissing.of(), + @JsonProperty("fileType") @ExcludeMissing fileType: JsonField = JsonMissing.of(), + @JsonProperty("height") @ExcludeMissing height: JsonField = JsonMissing.of(), + @JsonProperty("isPrivateFile") + @ExcludeMissing + isPrivateFile: JsonField = JsonMissing.of(), + @JsonProperty("isPublished") + @ExcludeMissing + isPublished: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("size") @ExcludeMissing size: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), + @JsonProperty("thumbnailUrl") + @ExcludeMissing + thumbnailUrl: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("versionInfo") + @ExcludeMissing + versionInfo: JsonField = JsonMissing.of(), + @JsonProperty("videoCodec") + @ExcludeMissing + videoCodec: JsonField = JsonMissing.of(), + @JsonProperty("width") @ExcludeMissing width: JsonField = JsonMissing.of(), + ) : this( + aiTags, + audioCodec, + bitRate, + customCoordinates, + customMetadata, + description, + duration, + embeddedMetadata, + extensionStatus, + fileId, + filePath, + fileType, + height, + isPrivateFile, + isPublished, + metadata, + name, + size, + tags, + thumbnailUrl, + url, + versionInfo, + videoCodec, + width, + mutableMapOf(), + ) + + /** + * An array of tags assigned to the uploaded file by auto tagging. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun aiTags(): Optional> = aiTags.getOptional("AITags") + + /** + * The audio codec used in the video (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun audioCodec(): Optional = audioCodec.getOptional("audioCodec") + + /** + * The bit rate of the video in kbps (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun bitRate(): Optional = bitRate.getOptional("bitRate") + + /** + * Value of custom coordinates associated with the image in the format `x,y,width,height`. If + * `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` in + * `responseFields` in API request to get the value of this field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customCoordinates(): Optional = customCoordinates.getOptional("customCoordinates") + + /** + * A key-value data associated with the asset. Use `responseField` in API request to get + * `customMetadata` in the upload API response. Before setting any custom metadata on an asset, + * you have to create the field using custom metadata fields API. Send `customMetadata` in + * `responseFields` in API request to get the value of this field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customMetadata(): Optional = customMetadata.getOptional("customMetadata") + + /** + * Optional text to describe the contents of the file. Can be set by the user or the + * ai-auto-description extension. + * + * @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") + + /** + * The duration of the video in seconds (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun duration(): Optional = duration.getOptional("duration") + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp + * data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata in + * the upload API response. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun embeddedMetadata(): Optional = + embeddedMetadata.getOptional("embeddedMetadata") + + /** + * Extension names with their processing status at the time of completion of the request. It + * could have one of the following status values: + * + * `success`: The extension has been successfully applied. `failed`: The extension has failed + * and will not be retried. `pending`: The extension will finish processing in some time. On + * completion, the final status (success / failed) will be sent to the `webhookUrl` provided. + * + * If no extension was requested, then this parameter is not returned. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun extensionStatus(): Optional = + extensionStatus.getOptional("extensionStatus") + + /** + * Unique fileId. Store this fileld in your database, as this will be used to perform update + * action on this file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fileId(): Optional = fileId.getOptional("fileId") + + /** + * The relative path of the file in the media library e.g. `/marketing-assets/new-banner.jpg`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun filePath(): Optional = filePath.getOptional("filePath") + + /** + * Type of the uploaded file. Possible values are `image`, `non-image`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fileType(): Optional = fileType.getOptional("fileType") + + /** + * Height of the image in pixels (Only for images) + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun height(): Optional = height.getOptional("height") + + /** + * Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` in + * `responseFields` in API request to get the value of this field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isPrivateFile(): Optional = isPrivateFile.getOptional("isPrivateFile") + + /** + * Is the file published or in draft state. It can be either `true` or `false`. Send + * `isPublished` in `responseFields` in API request to get the value of this field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isPublished(): Optional = isPublished.getOptional("isPublished") + + /** + * Legacy metadata. Send `metadata` in `responseFields` in API request to get metadata in the + * upload API response. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Name of the asset. + * + * @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") + + /** + * Size of the image file in Bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun size(): Optional = size.getOptional("size") + + /** + * The array of tags associated with the asset. If no tags are set, it will be `null`. Send + * `tags` in `responseFields` in API request to get the value of this field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tags(): Optional> = tags.getOptional("tags") + + /** + * In the case of an image, a small thumbnail URL. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun thumbnailUrl(): Optional = thumbnailUrl.getOptional("thumbnailUrl") + + /** + * A publicly accessible URL of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * An object containing the file or file version's `id` (versionId) and `name`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun versionInfo(): Optional = versionInfo.getOptional("versionInfo") + + /** + * The video codec used in the video (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun videoCodec(): Optional = videoCodec.getOptional("videoCodec") + + /** + * Width of the image in pixels (Only for Images) + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun width(): Optional = width.getOptional("width") + + /** + * Returns the raw JSON value of [aiTags]. + * + * Unlike [aiTags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("AITags") @ExcludeMissing fun _aiTags(): JsonField> = aiTags + + /** + * Returns the raw JSON value of [audioCodec]. + * + * Unlike [audioCodec], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("audioCodec") @ExcludeMissing fun _audioCodec(): JsonField = audioCodec + + /** + * Returns the raw JSON value of [bitRate]. + * + * Unlike [bitRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bitRate") @ExcludeMissing fun _bitRate(): JsonField = bitRate + + /** + * Returns the raw JSON value of [customCoordinates]. + * + * Unlike [customCoordinates], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("customCoordinates") + @ExcludeMissing + fun _customCoordinates(): JsonField = customCoordinates + + /** + * Returns the raw JSON value of [customMetadata]. + * + * Unlike [customMetadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): JsonField = customMetadata + + /** + * 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 [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [embeddedMetadata]. + * + * Unlike [embeddedMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("embeddedMetadata") + @ExcludeMissing + fun _embeddedMetadata(): JsonField = embeddedMetadata + + /** + * Returns the raw JSON value of [extensionStatus]. + * + * Unlike [extensionStatus], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extensionStatus") + @ExcludeMissing + fun _extensionStatus(): JsonField = extensionStatus + + /** + * Returns the raw JSON value of [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fileId") @ExcludeMissing fun _fileId(): JsonField = fileId + + /** + * Returns the raw JSON value of [filePath]. + * + * Unlike [filePath], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filePath") @ExcludeMissing fun _filePath(): JsonField = filePath + + /** + * Returns the raw JSON value of [fileType]. + * + * Unlike [fileType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fileType") @ExcludeMissing fun _fileType(): JsonField = fileType + + /** + * Returns the raw JSON value of [height]. + * + * Unlike [height], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("height") @ExcludeMissing fun _height(): JsonField = height + + /** + * Returns the raw JSON value of [isPrivateFile]. + * + * Unlike [isPrivateFile], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isPrivateFile") + @ExcludeMissing + fun _isPrivateFile(): JsonField = isPrivateFile + + /** + * Returns the raw JSON value of [isPublished]. + * + * Unlike [isPublished], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isPublished") + @ExcludeMissing + fun _isPublished(): JsonField = isPublished + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [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 [size]. + * + * Unlike [size], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("size") @ExcludeMissing fun _size(): JsonField = size + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + + /** + * Returns the raw JSON value of [thumbnailUrl]. + * + * Unlike [thumbnailUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("thumbnailUrl") + @ExcludeMissing + fun _thumbnailUrl(): JsonField = thumbnailUrl + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [versionInfo]. + * + * Unlike [versionInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("versionInfo") + @ExcludeMissing + fun _versionInfo(): JsonField = versionInfo + + /** + * Returns the raw JSON value of [videoCodec]. + * + * Unlike [videoCodec], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("videoCodec") @ExcludeMissing fun _videoCodec(): JsonField = videoCodec + + /** + * Returns the raw JSON value of [width]. + * + * Unlike [width], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("width") @ExcludeMissing fun _width(): JsonField = width + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FileUploadResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileUploadResponse]. */ + class Builder internal constructor() { + + private var aiTags: JsonField>? = null + private var audioCodec: JsonField = JsonMissing.of() + private var bitRate: JsonField = JsonMissing.of() + private var customCoordinates: JsonField = JsonMissing.of() + private var customMetadata: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var duration: JsonField = JsonMissing.of() + private var embeddedMetadata: JsonField = JsonMissing.of() + private var extensionStatus: JsonField = JsonMissing.of() + private var fileId: JsonField = JsonMissing.of() + private var filePath: JsonField = JsonMissing.of() + private var fileType: JsonField = JsonMissing.of() + private var height: JsonField = JsonMissing.of() + private var isPrivateFile: JsonField = JsonMissing.of() + private var isPublished: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var size: JsonField = JsonMissing.of() + private var tags: JsonField>? = null + private var thumbnailUrl: JsonField = JsonMissing.of() + private var url: JsonField = JsonMissing.of() + private var versionInfo: JsonField = JsonMissing.of() + private var videoCodec: JsonField = JsonMissing.of() + private var width: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fileUploadResponse: FileUploadResponse) = apply { + aiTags = fileUploadResponse.aiTags.map { it.toMutableList() } + audioCodec = fileUploadResponse.audioCodec + bitRate = fileUploadResponse.bitRate + customCoordinates = fileUploadResponse.customCoordinates + customMetadata = fileUploadResponse.customMetadata + description = fileUploadResponse.description + duration = fileUploadResponse.duration + embeddedMetadata = fileUploadResponse.embeddedMetadata + extensionStatus = fileUploadResponse.extensionStatus + fileId = fileUploadResponse.fileId + filePath = fileUploadResponse.filePath + fileType = fileUploadResponse.fileType + height = fileUploadResponse.height + isPrivateFile = fileUploadResponse.isPrivateFile + isPublished = fileUploadResponse.isPublished + metadata = fileUploadResponse.metadata + name = fileUploadResponse.name + size = fileUploadResponse.size + tags = fileUploadResponse.tags.map { it.toMutableList() } + thumbnailUrl = fileUploadResponse.thumbnailUrl + url = fileUploadResponse.url + versionInfo = fileUploadResponse.versionInfo + videoCodec = fileUploadResponse.videoCodec + width = fileUploadResponse.width + additionalProperties = fileUploadResponse.additionalProperties.toMutableMap() + } + + /** An array of tags assigned to the uploaded file by auto tagging. */ + fun aiTags(aiTags: List?) = aiTags(JsonField.ofNullable(aiTags)) + + /** Alias for calling [Builder.aiTags] with `aiTags.orElse(null)`. */ + fun aiTags(aiTags: Optional>) = aiTags(aiTags.getOrNull()) + + /** + * Sets [Builder.aiTags] to an arbitrary JSON value. + * + * You should usually call [Builder.aiTags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun aiTags(aiTags: JsonField>) = apply { + this.aiTags = aiTags.map { it.toMutableList() } + } + + /** + * Adds a single [AiTag] to [aiTags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAiTag(aiTag: AiTag) = apply { + aiTags = + (aiTags ?: JsonField.of(mutableListOf())).also { + checkKnown("aiTags", it).add(aiTag) + } + } + + /** The audio codec used in the video (only for video). */ + fun audioCodec(audioCodec: String) = audioCodec(JsonField.of(audioCodec)) + + /** + * Sets [Builder.audioCodec] to an arbitrary JSON value. + * + * You should usually call [Builder.audioCodec] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun audioCodec(audioCodec: JsonField) = apply { this.audioCodec = audioCodec } + + /** The bit rate of the video in kbps (only for video). */ + fun bitRate(bitRate: Long) = bitRate(JsonField.of(bitRate)) + + /** + * Sets [Builder.bitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.bitRate] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun bitRate(bitRate: JsonField) = apply { this.bitRate = bitRate } + + /** + * Value of custom coordinates associated with the image in the format `x,y,width,height`. + * If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` in + * `responseFields` in API request to get the value of this field. + */ + fun customCoordinates(customCoordinates: String?) = + customCoordinates(JsonField.ofNullable(customCoordinates)) + + /** Alias for calling [Builder.customCoordinates] with `customCoordinates.orElse(null)`. */ + fun customCoordinates(customCoordinates: Optional) = + customCoordinates(customCoordinates.getOrNull()) + + /** + * Sets [Builder.customCoordinates] to an arbitrary JSON value. + * + * You should usually call [Builder.customCoordinates] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customCoordinates(customCoordinates: JsonField) = apply { + this.customCoordinates = customCoordinates + } + + /** + * A key-value data associated with the asset. Use `responseField` in API request to get + * `customMetadata` in the upload API response. Before setting any custom metadata on an + * asset, you have to create the field using custom metadata fields API. Send + * `customMetadata` in `responseFields` in API request to get the value of this field. + */ + fun customMetadata(customMetadata: CustomMetadata) = + customMetadata(JsonField.of(customMetadata)) + + /** + * Sets [Builder.customMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.customMetadata] with a well-typed [CustomMetadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customMetadata(customMetadata: JsonField) = apply { + this.customMetadata = customMetadata + } + + /** + * Optional text to describe the contents of the file. Can be set by the user or the + * ai-auto-description extension. + */ + 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 } + + /** The duration of the video in seconds (only for video). */ + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp + * data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata + * in the upload API response. + */ + fun embeddedMetadata(embeddedMetadata: EmbeddedMetadata) = + embeddedMetadata(JsonField.of(embeddedMetadata)) + + /** + * Sets [Builder.embeddedMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.embeddedMetadata] with a well-typed [EmbeddedMetadata] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun embeddedMetadata(embeddedMetadata: JsonField) = apply { + this.embeddedMetadata = embeddedMetadata + } + + /** + * Extension names with their processing status at the time of completion of the request. It + * could have one of the following status values: + * + * `success`: The extension has been successfully applied. `failed`: The extension has + * failed and will not be retried. `pending`: The extension will finish processing in some + * time. On completion, the final status (success / failed) will be sent to the `webhookUrl` + * provided. + * + * If no extension was requested, then this parameter is not returned. + */ + fun extensionStatus(extensionStatus: ExtensionStatus) = + extensionStatus(JsonField.of(extensionStatus)) + + /** + * Sets [Builder.extensionStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.extensionStatus] with a well-typed [ExtensionStatus] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun extensionStatus(extensionStatus: JsonField) = apply { + this.extensionStatus = extensionStatus + } + + /** + * Unique fileId. Store this fileld in your database, as this will be used to perform update + * action on this file. + */ + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + + /** + * The relative path of the file in the media library e.g. + * `/marketing-assets/new-banner.jpg`. + */ + fun filePath(filePath: String) = filePath(JsonField.of(filePath)) + + /** + * Sets [Builder.filePath] to an arbitrary JSON value. + * + * You should usually call [Builder.filePath] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filePath(filePath: JsonField) = apply { this.filePath = filePath } + + /** Type of the uploaded file. Possible values are `image`, `non-image`. */ + fun fileType(fileType: String) = fileType(JsonField.of(fileType)) + + /** + * Sets [Builder.fileType] to an arbitrary JSON value. + * + * You should usually call [Builder.fileType] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fileType(fileType: JsonField) = apply { this.fileType = fileType } + + /** Height of the image in pixels (Only for images) */ + fun height(height: Double) = height(JsonField.of(height)) + + /** + * Sets [Builder.height] to an arbitrary JSON value. + * + * You should usually call [Builder.height] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun height(height: JsonField) = apply { this.height = height } + + /** + * Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` + * in `responseFields` in API request to get the value of this field. + */ + fun isPrivateFile(isPrivateFile: Boolean) = isPrivateFile(JsonField.of(isPrivateFile)) + + /** + * Sets [Builder.isPrivateFile] to an arbitrary JSON value. + * + * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPrivateFile(isPrivateFile: JsonField) = apply { + this.isPrivateFile = isPrivateFile + } + + /** + * Is the file published or in draft state. It can be either `true` or `false`. Send + * `isPublished` in `responseFields` in API request to get the value of this field. + */ + fun isPublished(isPublished: Boolean) = isPublished(JsonField.of(isPublished)) + + /** + * Sets [Builder.isPublished] to an arbitrary JSON value. + * + * You should usually call [Builder.isPublished] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isPublished(isPublished: JsonField) = apply { this.isPublished = isPublished } + + /** + * Legacy metadata. Send `metadata` in `responseFields` in API request to get metadata in + * the upload API response. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** Name of the asset. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Size of the image file in Bytes. */ + fun size(size: Double) = size(JsonField.of(size)) + + /** + * Sets [Builder.size] to an arbitrary JSON value. + * + * You should usually call [Builder.size] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun size(size: JsonField) = apply { this.size = size } + + /** + * The array of tags associated with the asset. If no tags are set, it will be `null`. Send + * `tags` in `responseFields` in API request to get the value of this field. + */ + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + /** In the case of an image, a small thumbnail URL. */ + fun thumbnailUrl(thumbnailUrl: String) = thumbnailUrl(JsonField.of(thumbnailUrl)) + + /** + * Sets [Builder.thumbnailUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.thumbnailUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thumbnailUrl(thumbnailUrl: JsonField) = apply { + this.thumbnailUrl = thumbnailUrl + } + + /** A publicly accessible URL of the file. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** An object containing the file or file version's `id` (versionId) and `name`. */ + fun versionInfo(versionInfo: VersionInfo) = versionInfo(JsonField.of(versionInfo)) + + /** + * Sets [Builder.versionInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.versionInfo] with a well-typed [VersionInfo] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun versionInfo(versionInfo: JsonField) = apply { + this.versionInfo = versionInfo + } + + /** The video codec used in the video (only for video). */ + fun videoCodec(videoCodec: String) = videoCodec(JsonField.of(videoCodec)) + + /** + * Sets [Builder.videoCodec] to an arbitrary JSON value. + * + * You should usually call [Builder.videoCodec] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun videoCodec(videoCodec: JsonField) = apply { this.videoCodec = videoCodec } + + /** Width of the image in pixels (Only for Images) */ + fun width(width: Double) = width(JsonField.of(width)) + + /** + * Sets [Builder.width] to an arbitrary JSON value. + * + * You should usually call [Builder.width] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun width(width: JsonField) = apply { this.width = width } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FileUploadResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FileUploadResponse = + FileUploadResponse( + (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, + audioCodec, + bitRate, + customCoordinates, + customMetadata, + description, + duration, + embeddedMetadata, + extensionStatus, + fileId, + filePath, + fileType, + height, + isPrivateFile, + isPublished, + metadata, + name, + size, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + thumbnailUrl, + url, + versionInfo, + videoCodec, + width, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FileUploadResponse = apply { + if (validated) { + return@apply + } + + aiTags().ifPresent { it.forEach { it.validate() } } + audioCodec() + bitRate() + customCoordinates() + customMetadata().ifPresent { it.validate() } + description() + duration() + embeddedMetadata().ifPresent { it.validate() } + extensionStatus().ifPresent { it.validate() } + fileId() + filePath() + fileType() + height() + isPrivateFile() + isPublished() + metadata().ifPresent { it.validate() } + name() + size() + tags() + thumbnailUrl() + url() + versionInfo().ifPresent { it.validate() } + videoCodec() + width() + 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 = + (aiTags.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (audioCodec.asKnown().isPresent) 1 else 0) + + (if (bitRate.asKnown().isPresent) 1 else 0) + + (if (customCoordinates.asKnown().isPresent) 1 else 0) + + (customMetadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (duration.asKnown().isPresent) 1 else 0) + + (embeddedMetadata.asKnown().getOrNull()?.validity() ?: 0) + + (extensionStatus.asKnown().getOrNull()?.validity() ?: 0) + + (if (fileId.asKnown().isPresent) 1 else 0) + + (if (filePath.asKnown().isPresent) 1 else 0) + + (if (fileType.asKnown().isPresent) 1 else 0) + + (if (height.asKnown().isPresent) 1 else 0) + + (if (isPrivateFile.asKnown().isPresent) 1 else 0) + + (if (isPublished.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (size.asKnown().isPresent) 1 else 0) + + (tags.asKnown().getOrNull()?.size ?: 0) + + (if (thumbnailUrl.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (versionInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (videoCodec.asKnown().isPresent) 1 else 0) + + (if (width.asKnown().isPresent) 1 else 0) + + class AiTag + private constructor( + private val confidence: JsonField, + private val name: JsonField, + private val source: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("confidence") + @ExcludeMissing + confidence: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + ) : this(confidence, name, source, mutableMapOf()) + + /** + * Confidence score of the tag. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun confidence(): Optional = confidence.getOptional("confidence") + + /** + * Name of the tag. + * + * @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") + + /** + * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. + * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * Returns the raw JSON value of [confidence]. + * + * Unlike [confidence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("confidence") + @ExcludeMissing + fun _confidence(): JsonField = confidence + + /** + * 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 [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AiTag]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AiTag]. */ + class Builder internal constructor() { + + private var confidence: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var source: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(aiTag: AiTag) = apply { + confidence = aiTag.confidence + name = aiTag.name + source = aiTag.source + additionalProperties = aiTag.additionalProperties.toMutableMap() + } + + /** Confidence score of the tag. */ + fun confidence(confidence: Double) = confidence(JsonField.of(confidence)) + + /** + * Sets [Builder.confidence] to an arbitrary JSON value. + * + * You should usually call [Builder.confidence] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun confidence(confidence: JsonField) = apply { this.confidence = confidence } + + /** Name of the tag. */ + 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 } + + /** + * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. + * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` + * extensions. + */ + fun source(source: String) = source(JsonField.of(source)) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AiTag]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AiTag = + AiTag(confidence, name, source, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): AiTag = apply { + if (validated) { + return@apply + } + + confidence() + name() + source() + 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 (confidence.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (source.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiTag && + confidence == other.confidence && + name == other.name && + source == other.source && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(confidence, name, source, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AiTag{confidence=$confidence, name=$name, source=$source, additionalProperties=$additionalProperties}" + } + + /** + * A key-value data associated with the asset. Use `responseField` in API request to get + * `customMetadata` in the upload API response. Before setting any custom metadata on an asset, + * you have to create the field using custom metadata fields API. Send `customMetadata` in + * `responseFields` in API request to get the value of this field. + */ + class CustomMetadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CustomMetadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customMetadata: CustomMetadata) = apply { + additionalProperties = customMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CustomMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomMetadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" + } + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp + * data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata in + * the upload API response. + */ + class EmbeddedMetadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [EmbeddedMetadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EmbeddedMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(embeddedMetadata: EmbeddedMetadata) = apply { + additionalProperties = embeddedMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EmbeddedMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): EmbeddedMetadata = EmbeddedMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): EmbeddedMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EmbeddedMetadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "EmbeddedMetadata{additionalProperties=$additionalProperties}" + } + + /** + * Extension names with their processing status at the time of completion of the request. It + * could have one of the following status values: + * + * `success`: The extension has been successfully applied. `failed`: The extension has failed + * and will not be retried. `pending`: The extension will finish processing in some time. On + * completion, the final status (success / failed) will be sent to the `webhookUrl` provided. + * + * If no extension was requested, then this parameter is not returned. + */ + class ExtensionStatus + private constructor( + private val aiAutoDescription: JsonField, + private val awsAutoTagging: JsonField, + private val googleAutoTagging: JsonField, + private val removeBg: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("ai-auto-description") + @ExcludeMissing + aiAutoDescription: JsonField = JsonMissing.of(), + @JsonProperty("aws-auto-tagging") + @ExcludeMissing + awsAutoTagging: JsonField = JsonMissing.of(), + @JsonProperty("google-auto-tagging") + @ExcludeMissing + googleAutoTagging: JsonField = JsonMissing.of(), + @JsonProperty("remove-bg") + @ExcludeMissing + removeBg: JsonField = JsonMissing.of(), + ) : this(aiAutoDescription, awsAutoTagging, googleAutoTagging, removeBg, mutableMapOf()) + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun aiAutoDescription(): Optional = + aiAutoDescription.getOptional("ai-auto-description") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun awsAutoTagging(): Optional = + awsAutoTagging.getOptional("aws-auto-tagging") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun googleAutoTagging(): Optional = + googleAutoTagging.getOptional("google-auto-tagging") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun removeBg(): Optional = removeBg.getOptional("remove-bg") + + /** + * Returns the raw JSON value of [aiAutoDescription]. + * + * Unlike [aiAutoDescription], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ai-auto-description") + @ExcludeMissing + fun _aiAutoDescription(): JsonField = aiAutoDescription + + /** + * Returns the raw JSON value of [awsAutoTagging]. + * + * Unlike [awsAutoTagging], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("aws-auto-tagging") + @ExcludeMissing + fun _awsAutoTagging(): JsonField = awsAutoTagging + + /** + * Returns the raw JSON value of [googleAutoTagging]. + * + * Unlike [googleAutoTagging], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("google-auto-tagging") + @ExcludeMissing + fun _googleAutoTagging(): JsonField = googleAutoTagging + + /** + * Returns the raw JSON value of [removeBg]. + * + * Unlike [removeBg], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("remove-bg") @ExcludeMissing fun _removeBg(): JsonField = removeBg + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ExtensionStatus]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExtensionStatus]. */ + class Builder internal constructor() { + + private var aiAutoDescription: JsonField = JsonMissing.of() + private var awsAutoTagging: JsonField = JsonMissing.of() + private var googleAutoTagging: JsonField = JsonMissing.of() + private var removeBg: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extensionStatus: ExtensionStatus) = apply { + aiAutoDescription = extensionStatus.aiAutoDescription + awsAutoTagging = extensionStatus.awsAutoTagging + googleAutoTagging = extensionStatus.googleAutoTagging + removeBg = extensionStatus.removeBg + additionalProperties = extensionStatus.additionalProperties.toMutableMap() + } + + fun aiAutoDescription(aiAutoDescription: AiAutoDescription) = + aiAutoDescription(JsonField.of(aiAutoDescription)) + + /** + * Sets [Builder.aiAutoDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.aiAutoDescription] with a well-typed + * [AiAutoDescription] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun aiAutoDescription(aiAutoDescription: JsonField) = apply { + this.aiAutoDescription = aiAutoDescription + } + + fun awsAutoTagging(awsAutoTagging: AwsAutoTagging) = + awsAutoTagging(JsonField.of(awsAutoTagging)) + + /** + * Sets [Builder.awsAutoTagging] to an arbitrary JSON value. + * + * You should usually call [Builder.awsAutoTagging] with a well-typed [AwsAutoTagging] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun awsAutoTagging(awsAutoTagging: JsonField) = apply { + this.awsAutoTagging = awsAutoTagging + } + + fun googleAutoTagging(googleAutoTagging: GoogleAutoTagging) = + googleAutoTagging(JsonField.of(googleAutoTagging)) + + /** + * Sets [Builder.googleAutoTagging] to an arbitrary JSON value. + * + * You should usually call [Builder.googleAutoTagging] with a well-typed + * [GoogleAutoTagging] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun googleAutoTagging(googleAutoTagging: JsonField) = apply { + this.googleAutoTagging = googleAutoTagging + } + + fun removeBg(removeBg: RemoveBg) = removeBg(JsonField.of(removeBg)) + + /** + * Sets [Builder.removeBg] to an arbitrary JSON value. + * + * You should usually call [Builder.removeBg] with a well-typed [RemoveBg] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun removeBg(removeBg: JsonField) = apply { this.removeBg = removeBg } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ExtensionStatus]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExtensionStatus = + ExtensionStatus( + aiAutoDescription, + awsAutoTagging, + googleAutoTagging, + removeBg, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExtensionStatus = apply { + if (validated) { + return@apply + } + + aiAutoDescription().ifPresent { it.validate() } + awsAutoTagging().ifPresent { it.validate() } + googleAutoTagging().ifPresent { it.validate() } + removeBg().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (aiAutoDescription.asKnown().getOrNull()?.validity() ?: 0) + + (awsAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (googleAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (removeBg.asKnown().getOrNull()?.validity() ?: 0) + + class AiAutoDescription + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val PENDING = of("pending") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = AiAutoDescription(JsonField.of(value)) + } + + /** An enum containing [AiAutoDescription]'s known values. */ + enum class Known { + SUCCESS, + PENDING, + FAILED, + } + + /** + * An enum containing [AiAutoDescription]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AiAutoDescription] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + PENDING, + FAILED, + /** + * An enum member indicating that [AiAutoDescription] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + PENDING -> Value.PENDING + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + PENDING -> Known.PENDING + FAILED -> Known.FAILED + else -> throw ImageKitInvalidDataException("Unknown AiAutoDescription: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AiAutoDescription = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiAutoDescription && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class AwsAutoTagging + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val PENDING = of("pending") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = AwsAutoTagging(JsonField.of(value)) + } + + /** An enum containing [AwsAutoTagging]'s known values. */ + enum class Known { + SUCCESS, + PENDING, + FAILED, + } + + /** + * An enum containing [AwsAutoTagging]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AwsAutoTagging] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + PENDING, + FAILED, + /** + * An enum member indicating that [AwsAutoTagging] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + PENDING -> Value.PENDING + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + PENDING -> Known.PENDING + FAILED -> Known.FAILED + else -> throw ImageKitInvalidDataException("Unknown AwsAutoTagging: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AwsAutoTagging = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AwsAutoTagging && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class GoogleAutoTagging + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val PENDING = of("pending") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = GoogleAutoTagging(JsonField.of(value)) + } + + /** An enum containing [GoogleAutoTagging]'s known values. */ + enum class Known { + SUCCESS, + PENDING, + FAILED, + } + + /** + * An enum containing [GoogleAutoTagging]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [GoogleAutoTagging] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + PENDING, + FAILED, + /** + * An enum member indicating that [GoogleAutoTagging] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + PENDING -> Value.PENDING + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + PENDING -> Known.PENDING + FAILED -> Known.FAILED + else -> throw ImageKitInvalidDataException("Unknown GoogleAutoTagging: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): GoogleAutoTagging = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GoogleAutoTagging && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class RemoveBg @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val PENDING = of("pending") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = RemoveBg(JsonField.of(value)) + } + + /** An enum containing [RemoveBg]'s known values. */ + enum class Known { + SUCCESS, + PENDING, + FAILED, + } + + /** + * An enum containing [RemoveBg]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RemoveBg] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + PENDING, + FAILED, + /** + * An enum member indicating that [RemoveBg] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + PENDING -> Value.PENDING + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + PENDING -> Known.PENDING + FAILED -> Known.FAILED + else -> throw ImageKitInvalidDataException("Unknown RemoveBg: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): RemoveBg = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveBg && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExtensionStatus && + aiAutoDescription == other.aiAutoDescription && + awsAutoTagging == other.awsAutoTagging && + googleAutoTagging == other.googleAutoTagging && + removeBg == other.removeBg && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aiAutoDescription, + awsAutoTagging, + googleAutoTagging, + removeBg, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExtensionStatus{aiAutoDescription=$aiAutoDescription, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" + } + + /** An object containing the file or file version's `id` (versionId) and `name`. */ + class VersionInfo + private constructor( + private val id: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, name, mutableMapOf()) + + /** + * Unique identifier of the file version. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * Name of the file version. + * + * @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") + + /** + * 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 [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [VersionInfo]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VersionInfo]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(versionInfo: VersionInfo) = apply { + id = versionInfo.id + name = versionInfo.name + additionalProperties = versionInfo.additionalProperties.toMutableMap() + } + + /** Unique identifier of the file version. */ + 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 } + + /** Name of the file version. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [VersionInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VersionInfo = VersionInfo(id, name, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): VersionInfo = apply { + if (validated) { + return@apply + } + + id() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VersionInfo && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VersionInfo{id=$id, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FileUploadResponse && + aiTags == other.aiTags && + audioCodec == other.audioCodec && + bitRate == other.bitRate && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + description == other.description && + duration == other.duration && + embeddedMetadata == other.embeddedMetadata && + extensionStatus == other.extensionStatus && + fileId == other.fileId && + filePath == other.filePath && + fileType == other.fileType && + height == other.height && + isPrivateFile == other.isPrivateFile && + isPublished == other.isPublished && + metadata == other.metadata && + name == other.name && + size == other.size && + tags == other.tags && + thumbnailUrl == other.thumbnailUrl && + url == other.url && + versionInfo == other.versionInfo && + videoCodec == other.videoCodec && + width == other.width && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aiTags, + audioCodec, + bitRate, + customCoordinates, + customMetadata, + description, + duration, + embeddedMetadata, + extensionStatus, + fileId, + filePath, + fileType, + height, + isPrivateFile, + isPublished, + metadata, + name, + size, + tags, + thumbnailUrl, + url, + versionInfo, + videoCodec, + width, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FileUploadResponse{aiTags=$aiTags, audioCodec=$audioCodec, bitRate=$bitRate, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, duration=$duration, embeddedMetadata=$embeddedMetadata, extensionStatus=$extensionStatus, fileId=$fileId, filePath=$filePath, fileType=$fileType, height=$height, isPrivateFile=$isPrivateFile, isPublished=$isPublished, metadata=$metadata, name=$name, size=$size, tags=$tags, thumbnailUrl=$thumbnailUrl, url=$url, versionInfo=$versionInfo, videoCodec=$videoCodec, width=$width, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Folder.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Folder.kt new file mode 100644 index 00000000..3e7c9a34 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Folder.kt @@ -0,0 +1,478 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class Folder +private constructor( + private val createdAt: JsonField, + private val folderId: JsonField, + private val folderPath: JsonField, + private val name: JsonField, + private val type: JsonField, + private val updatedAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("createdAt") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("folderId") @ExcludeMissing folderId: JsonField = JsonMissing.of(), + @JsonProperty("folderPath") + @ExcludeMissing + folderPath: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("updatedAt") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this(createdAt, folderId, folderPath, name, type, updatedAt, mutableMapOf()) + + /** + * Date and time when the folder was created. The date and time is in ISO8601 format. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun createdAt(): Optional = createdAt.getOptional("createdAt") + + /** + * Unique identifier of the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun folderId(): Optional = folderId.getOptional("folderId") + + /** + * Path of the folder. This is the path you would use in the URL to access the folder. For + * example, if the folder is at the root of the media library, the path will be /folder. If the + * folder is inside another folder named images, the path will be /images/folder. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun folderPath(): Optional = folderPath.getOptional("folderPath") + + /** + * Name of the asset. + * + * @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") + + /** + * Type of the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Date and time when the folder was last updated. The date and time is in ISO8601 format. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun updatedAt(): Optional = updatedAt.getOptional("updatedAt") + + /** + * 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 [folderId]. + * + * Unlike [folderId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("folderId") @ExcludeMissing fun _folderId(): JsonField = folderId + + /** + * Returns the raw JSON value of [folderPath]. + * + * Unlike [folderPath], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("folderPath") @ExcludeMissing fun _folderPath(): JsonField = folderPath + + /** + * 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 [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updatedAt") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Folder]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Folder]. */ + class Builder internal constructor() { + + private var createdAt: JsonField = JsonMissing.of() + private var folderId: JsonField = JsonMissing.of() + private var folderPath: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(folder: Folder) = apply { + createdAt = folder.createdAt + folderId = folder.folderId + folderPath = folder.folderPath + name = folder.name + type = folder.type + updatedAt = folder.updatedAt + additionalProperties = folder.additionalProperties.toMutableMap() + } + + /** Date and time when the folder was created. The date and time is in ISO8601 format. */ + 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 } + + /** Unique identifier of the asset. */ + fun folderId(folderId: String) = folderId(JsonField.of(folderId)) + + /** + * Sets [Builder.folderId] to an arbitrary JSON value. + * + * You should usually call [Builder.folderId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun folderId(folderId: JsonField) = apply { this.folderId = folderId } + + /** + * Path of the folder. This is the path you would use in the URL to access the folder. For + * example, if the folder is at the root of the media library, the path will be /folder. If + * the folder is inside another folder named images, the path will be /images/folder. + */ + fun folderPath(folderPath: String) = folderPath(JsonField.of(folderPath)) + + /** + * Sets [Builder.folderPath] to an arbitrary JSON value. + * + * You should usually call [Builder.folderPath] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun folderPath(folderPath: JsonField) = apply { this.folderPath = folderPath } + + /** Name of the asset. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Type of the asset. */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** + * Date and time when the folder was last updated. The date and time is in ISO8601 format. + */ + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Folder]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Folder = + Folder( + createdAt, + folderId, + folderPath, + name, + type, + updatedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Folder = apply { + if (validated) { + return@apply + } + + createdAt() + folderId() + folderPath() + name() + type().ifPresent { it.validate() } + updatedAt() + 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 (createdAt.asKnown().isPresent) 1 else 0) + + (if (folderId.asKnown().isPresent) 1 else 0) + + (if (folderPath.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + /** Type of the asset. */ + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val FOLDER = of("folder") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + FOLDER + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FOLDER, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FOLDER -> Value.FOLDER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + FOLDER -> Known.FOLDER + else -> throw ImageKitInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Folder && + createdAt == other.createdAt && + folderId == other.folderId && + folderPath == other.folderPath && + name == other.name && + type == other.type && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(createdAt, folderId, folderPath, name, type, updatedAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Folder{createdAt=$createdAt, folderId=$folderId, folderPath=$folderPath, name=$name, type=$type, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Metadata.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Metadata.kt new file mode 100644 index 00000000..69891ec1 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Metadata.kt @@ -0,0 +1,3574 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** JSON object containing metadata. */ +class Metadata +private constructor( + private val audioCodec: JsonField, + private val bitRate: JsonField, + private val density: JsonField, + private val duration: JsonField, + private val exif: JsonField, + private val format: JsonField, + private val hasColorProfile: JsonField, + private val hasTransparency: JsonField, + private val height: JsonField, + private val pHash: JsonField, + private val quality: JsonField, + private val size: JsonField, + private val videoCodec: JsonField, + private val width: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("audioCodec") + @ExcludeMissing + audioCodec: JsonField = JsonMissing.of(), + @JsonProperty("bitRate") @ExcludeMissing bitRate: JsonField = JsonMissing.of(), + @JsonProperty("density") @ExcludeMissing density: JsonField = JsonMissing.of(), + @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), + @JsonProperty("exif") @ExcludeMissing exif: JsonField = JsonMissing.of(), + @JsonProperty("format") @ExcludeMissing format: JsonField = JsonMissing.of(), + @JsonProperty("hasColorProfile") + @ExcludeMissing + hasColorProfile: JsonField = JsonMissing.of(), + @JsonProperty("hasTransparency") + @ExcludeMissing + hasTransparency: JsonField = JsonMissing.of(), + @JsonProperty("height") @ExcludeMissing height: JsonField = JsonMissing.of(), + @JsonProperty("pHash") @ExcludeMissing pHash: JsonField = JsonMissing.of(), + @JsonProperty("quality") @ExcludeMissing quality: JsonField = JsonMissing.of(), + @JsonProperty("size") @ExcludeMissing size: JsonField = JsonMissing.of(), + @JsonProperty("videoCodec") + @ExcludeMissing + videoCodec: JsonField = JsonMissing.of(), + @JsonProperty("width") @ExcludeMissing width: JsonField = JsonMissing.of(), + ) : this( + audioCodec, + bitRate, + density, + duration, + exif, + format, + hasColorProfile, + hasTransparency, + height, + pHash, + quality, + size, + videoCodec, + width, + mutableMapOf(), + ) + + /** + * The audio codec used in the video (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun audioCodec(): Optional = audioCodec.getOptional("audioCodec") + + /** + * The bit rate of the video in kbps (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun bitRate(): Optional = bitRate.getOptional("bitRate") + + /** + * The density of the image in DPI. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun density(): Optional = density.getOptional("density") + + /** + * The duration of the video in seconds (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun duration(): Optional = duration.getOptional("duration") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun exif(): Optional = exif.getOptional("exif") + + /** + * The format of the file (e.g., 'jpg', 'mp4'). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun format(): Optional = format.getOptional("format") + + /** + * Indicates if the image has a color profile. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun hasColorProfile(): Optional = hasColorProfile.getOptional("hasColorProfile") + + /** + * Indicates if the image contains transparent areas. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun hasTransparency(): Optional = hasTransparency.getOptional("hasTransparency") + + /** + * The height of the image or video in pixels. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun height(): Optional = height.getOptional("height") + + /** + * Perceptual hash of the image. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pHash(): Optional = pHash.getOptional("pHash") + + /** + * The quality indicator of the image. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun quality(): Optional = quality.getOptional("quality") + + /** + * The file size in bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun size(): Optional = size.getOptional("size") + + /** + * The video codec used in the video (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun videoCodec(): Optional = videoCodec.getOptional("videoCodec") + + /** + * The width of the image or video in pixels. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun width(): Optional = width.getOptional("width") + + /** + * Returns the raw JSON value of [audioCodec]. + * + * Unlike [audioCodec], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("audioCodec") @ExcludeMissing fun _audioCodec(): JsonField = audioCodec + + /** + * Returns the raw JSON value of [bitRate]. + * + * Unlike [bitRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bitRate") @ExcludeMissing fun _bitRate(): JsonField = bitRate + + /** + * Returns the raw JSON value of [density]. + * + * Unlike [density], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("density") @ExcludeMissing fun _density(): JsonField = density + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [exif]. + * + * Unlike [exif], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("exif") @ExcludeMissing fun _exif(): JsonField = exif + + /** + * Returns the raw JSON value of [format]. + * + * Unlike [format], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("format") @ExcludeMissing fun _format(): JsonField = format + + /** + * Returns the raw JSON value of [hasColorProfile]. + * + * Unlike [hasColorProfile], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("hasColorProfile") + @ExcludeMissing + fun _hasColorProfile(): JsonField = hasColorProfile + + /** + * Returns the raw JSON value of [hasTransparency]. + * + * Unlike [hasTransparency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("hasTransparency") + @ExcludeMissing + fun _hasTransparency(): JsonField = hasTransparency + + /** + * Returns the raw JSON value of [height]. + * + * Unlike [height], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("height") @ExcludeMissing fun _height(): JsonField = height + + /** + * Returns the raw JSON value of [pHash]. + * + * Unlike [pHash], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pHash") @ExcludeMissing fun _pHash(): JsonField = pHash + + /** + * Returns the raw JSON value of [quality]. + * + * Unlike [quality], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("quality") @ExcludeMissing fun _quality(): JsonField = quality + + /** + * Returns the raw JSON value of [size]. + * + * Unlike [size], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("size") @ExcludeMissing fun _size(): JsonField = size + + /** + * Returns the raw JSON value of [videoCodec]. + * + * Unlike [videoCodec], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("videoCodec") @ExcludeMissing fun _videoCodec(): JsonField = videoCodec + + /** + * Returns the raw JSON value of [width]. + * + * Unlike [width], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("width") @ExcludeMissing fun _width(): JsonField = width + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var audioCodec: JsonField = JsonMissing.of() + private var bitRate: JsonField = JsonMissing.of() + private var density: JsonField = JsonMissing.of() + private var duration: JsonField = JsonMissing.of() + private var exif: JsonField = JsonMissing.of() + private var format: JsonField = JsonMissing.of() + private var hasColorProfile: JsonField = JsonMissing.of() + private var hasTransparency: JsonField = JsonMissing.of() + private var height: JsonField = JsonMissing.of() + private var pHash: JsonField = JsonMissing.of() + private var quality: JsonField = JsonMissing.of() + private var size: JsonField = JsonMissing.of() + private var videoCodec: JsonField = JsonMissing.of() + private var width: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + audioCodec = metadata.audioCodec + bitRate = metadata.bitRate + density = metadata.density + duration = metadata.duration + exif = metadata.exif + format = metadata.format + hasColorProfile = metadata.hasColorProfile + hasTransparency = metadata.hasTransparency + height = metadata.height + pHash = metadata.pHash + quality = metadata.quality + size = metadata.size + videoCodec = metadata.videoCodec + width = metadata.width + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + /** The audio codec used in the video (only for video). */ + fun audioCodec(audioCodec: String) = audioCodec(JsonField.of(audioCodec)) + + /** + * Sets [Builder.audioCodec] to an arbitrary JSON value. + * + * You should usually call [Builder.audioCodec] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun audioCodec(audioCodec: JsonField) = apply { this.audioCodec = audioCodec } + + /** The bit rate of the video in kbps (only for video). */ + fun bitRate(bitRate: Long) = bitRate(JsonField.of(bitRate)) + + /** + * Sets [Builder.bitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.bitRate] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun bitRate(bitRate: JsonField) = apply { this.bitRate = bitRate } + + /** The density of the image in DPI. */ + fun density(density: Long) = density(JsonField.of(density)) + + /** + * Sets [Builder.density] to an arbitrary JSON value. + * + * You should usually call [Builder.density] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun density(density: JsonField) = apply { this.density = density } + + /** The duration of the video in seconds (only for video). */ + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + fun exif(exif: Exif) = exif(JsonField.of(exif)) + + /** + * Sets [Builder.exif] to an arbitrary JSON value. + * + * You should usually call [Builder.exif] with a well-typed [Exif] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun exif(exif: JsonField) = apply { this.exif = exif } + + /** The format of the file (e.g., 'jpg', 'mp4'). */ + fun format(format: String) = format(JsonField.of(format)) + + /** + * Sets [Builder.format] to an arbitrary JSON value. + * + * You should usually call [Builder.format] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun format(format: JsonField) = apply { this.format = format } + + /** Indicates if the image has a color profile. */ + fun hasColorProfile(hasColorProfile: Boolean) = + hasColorProfile(JsonField.of(hasColorProfile)) + + /** + * Sets [Builder.hasColorProfile] to an arbitrary JSON value. + * + * You should usually call [Builder.hasColorProfile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun hasColorProfile(hasColorProfile: JsonField) = apply { + this.hasColorProfile = hasColorProfile + } + + /** Indicates if the image contains transparent areas. */ + fun hasTransparency(hasTransparency: Boolean) = + hasTransparency(JsonField.of(hasTransparency)) + + /** + * Sets [Builder.hasTransparency] to an arbitrary JSON value. + * + * You should usually call [Builder.hasTransparency] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun hasTransparency(hasTransparency: JsonField) = apply { + this.hasTransparency = hasTransparency + } + + /** The height of the image or video in pixels. */ + fun height(height: Long) = height(JsonField.of(height)) + + /** + * Sets [Builder.height] to an arbitrary JSON value. + * + * You should usually call [Builder.height] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun height(height: JsonField) = apply { this.height = height } + + /** Perceptual hash of the image. */ + fun pHash(pHash: String) = pHash(JsonField.of(pHash)) + + /** + * Sets [Builder.pHash] to an arbitrary JSON value. + * + * You should usually call [Builder.pHash] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun pHash(pHash: JsonField) = apply { this.pHash = pHash } + + /** The quality indicator of the image. */ + fun quality(quality: Long) = quality(JsonField.of(quality)) + + /** + * Sets [Builder.quality] to an arbitrary JSON value. + * + * You should usually call [Builder.quality] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun quality(quality: JsonField) = apply { this.quality = quality } + + /** The file size in bytes. */ + fun size(size: Long) = size(JsonField.of(size)) + + /** + * Sets [Builder.size] to an arbitrary JSON value. + * + * You should usually call [Builder.size] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun size(size: JsonField) = apply { this.size = size } + + /** The video codec used in the video (only for video). */ + fun videoCodec(videoCodec: String) = videoCodec(JsonField.of(videoCodec)) + + /** + * Sets [Builder.videoCodec] to an arbitrary JSON value. + * + * You should usually call [Builder.videoCodec] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun videoCodec(videoCodec: JsonField) = apply { this.videoCodec = videoCodec } + + /** The width of the image or video in pixels. */ + fun width(width: Long) = width(JsonField.of(width)) + + /** + * Sets [Builder.width] to an arbitrary JSON value. + * + * You should usually call [Builder.width] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun width(width: JsonField) = apply { this.width = width } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = + Metadata( + audioCodec, + bitRate, + density, + duration, + exif, + format, + hasColorProfile, + hasTransparency, + height, + pHash, + quality, + size, + videoCodec, + width, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + audioCodec() + bitRate() + density() + duration() + exif().ifPresent { it.validate() } + format() + hasColorProfile() + hasTransparency() + height() + pHash() + quality() + size() + videoCodec() + width() + 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 (audioCodec.asKnown().isPresent) 1 else 0) + + (if (bitRate.asKnown().isPresent) 1 else 0) + + (if (density.asKnown().isPresent) 1 else 0) + + (if (duration.asKnown().isPresent) 1 else 0) + + (exif.asKnown().getOrNull()?.validity() ?: 0) + + (if (format.asKnown().isPresent) 1 else 0) + + (if (hasColorProfile.asKnown().isPresent) 1 else 0) + + (if (hasTransparency.asKnown().isPresent) 1 else 0) + + (if (height.asKnown().isPresent) 1 else 0) + + (if (pHash.asKnown().isPresent) 1 else 0) + + (if (quality.asKnown().isPresent) 1 else 0) + + (if (size.asKnown().isPresent) 1 else 0) + + (if (videoCodec.asKnown().isPresent) 1 else 0) + + (if (width.asKnown().isPresent) 1 else 0) + + class Exif + private constructor( + private val exif: JsonField, + private val gps: JsonField, + private val image: JsonField, + private val interoperability: JsonField, + private val makernote: JsonField, + private val thumbnail: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("exif") @ExcludeMissing exif: JsonField = JsonMissing.of(), + @JsonProperty("gps") @ExcludeMissing gps: JsonField = JsonMissing.of(), + @JsonProperty("image") @ExcludeMissing image: JsonField = JsonMissing.of(), + @JsonProperty("interoperability") + @ExcludeMissing + interoperability: JsonField = JsonMissing.of(), + @JsonProperty("makernote") + @ExcludeMissing + makernote: JsonField = JsonMissing.of(), + @JsonProperty("thumbnail") + @ExcludeMissing + thumbnail: JsonField = JsonMissing.of(), + ) : this(exif, gps, image, interoperability, makernote, thumbnail, mutableMapOf()) + + /** + * Object containing Exif details. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun exif(): Optional = exif.getOptional("exif") + + /** + * Object containing GPS information. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun gps(): Optional = gps.getOptional("gps") + + /** + * Object containing EXIF image information. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun image(): Optional = image.getOptional("image") + + /** + * JSON object. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun interoperability(): Optional = + interoperability.getOptional("interoperability") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun makernote(): Optional = makernote.getOptional("makernote") + + /** + * Object containing Thumbnail information. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun thumbnail(): Optional = thumbnail.getOptional("thumbnail") + + /** + * Returns the raw JSON value of [exif]. + * + * Unlike [exif], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("exif") @ExcludeMissing fun _exif(): JsonField = exif + + /** + * Returns the raw JSON value of [gps]. + * + * Unlike [gps], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gps") @ExcludeMissing fun _gps(): JsonField = gps + + /** + * Returns the raw JSON value of [image]. + * + * Unlike [image], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("image") @ExcludeMissing fun _image(): JsonField = image + + /** + * Returns the raw JSON value of [interoperability]. + * + * Unlike [interoperability], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("interoperability") + @ExcludeMissing + fun _interoperability(): JsonField = interoperability + + /** + * Returns the raw JSON value of [makernote]. + * + * Unlike [makernote], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("makernote") + @ExcludeMissing + fun _makernote(): JsonField = makernote + + /** + * Returns the raw JSON value of [thumbnail]. + * + * Unlike [thumbnail], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("thumbnail") + @ExcludeMissing + fun _thumbnail(): JsonField = thumbnail + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Exif]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Exif]. */ + class Builder internal constructor() { + + private var exif: JsonField = JsonMissing.of() + private var gps: JsonField = JsonMissing.of() + private var image: JsonField = JsonMissing.of() + private var interoperability: JsonField = JsonMissing.of() + private var makernote: JsonField = JsonMissing.of() + private var thumbnail: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(exif: Exif) = apply { + this.exif = exif.exif + gps = exif.gps + image = exif.image + interoperability = exif.interoperability + makernote = exif.makernote + thumbnail = exif.thumbnail + additionalProperties = exif.additionalProperties.toMutableMap() + } + + /** Object containing Exif details. */ + fun exif(exif: InnerExif) = exif(JsonField.of(exif)) + + /** + * Sets [Builder.exif] to an arbitrary JSON value. + * + * You should usually call [Builder.exif] with a well-typed [InnerExif] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun exif(exif: JsonField) = apply { this.exif = exif } + + /** Object containing GPS information. */ + fun gps(gps: Gps) = gps(JsonField.of(gps)) + + /** + * Sets [Builder.gps] to an arbitrary JSON value. + * + * You should usually call [Builder.gps] with a well-typed [Gps] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun gps(gps: JsonField) = apply { this.gps = gps } + + /** Object containing EXIF image information. */ + fun image(image: Image) = image(JsonField.of(image)) + + /** + * Sets [Builder.image] to an arbitrary JSON value. + * + * You should usually call [Builder.image] with a well-typed [Image] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun image(image: JsonField) = apply { this.image = image } + + /** JSON object. */ + fun interoperability(interoperability: Interoperability) = + interoperability(JsonField.of(interoperability)) + + /** + * Sets [Builder.interoperability] to an arbitrary JSON value. + * + * You should usually call [Builder.interoperability] with a well-typed + * [Interoperability] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun interoperability(interoperability: JsonField) = apply { + this.interoperability = interoperability + } + + fun makernote(makernote: Makernote) = makernote(JsonField.of(makernote)) + + /** + * Sets [Builder.makernote] to an arbitrary JSON value. + * + * You should usually call [Builder.makernote] with a well-typed [Makernote] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun makernote(makernote: JsonField) = apply { this.makernote = makernote } + + /** Object containing Thumbnail information. */ + fun thumbnail(thumbnail: Thumbnail) = thumbnail(JsonField.of(thumbnail)) + + /** + * Sets [Builder.thumbnail] to an arbitrary JSON value. + * + * You should usually call [Builder.thumbnail] with a well-typed [Thumbnail] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun thumbnail(thumbnail: JsonField) = apply { this.thumbnail = thumbnail } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Exif]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Exif = + Exif( + exif, + gps, + image, + interoperability, + makernote, + thumbnail, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Exif = apply { + if (validated) { + return@apply + } + + exif().ifPresent { it.validate() } + gps().ifPresent { it.validate() } + image().ifPresent { it.validate() } + interoperability().ifPresent { it.validate() } + makernote().ifPresent { it.validate() } + thumbnail().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (exif.asKnown().getOrNull()?.validity() ?: 0) + + (gps.asKnown().getOrNull()?.validity() ?: 0) + + (image.asKnown().getOrNull()?.validity() ?: 0) + + (interoperability.asKnown().getOrNull()?.validity() ?: 0) + + (makernote.asKnown().getOrNull()?.validity() ?: 0) + + (thumbnail.asKnown().getOrNull()?.validity() ?: 0) + + /** Object containing Exif details. */ + class InnerExif + private constructor( + private val apertureValue: JsonField, + private val colorSpace: JsonField, + private val createDate: JsonField, + private val customRendered: JsonField, + private val dateTimeOriginal: JsonField, + private val exifImageHeight: JsonField, + private val exifImageWidth: JsonField, + private val exifVersion: JsonField, + private val exposureCompensation: JsonField, + private val exposureMode: JsonField, + private val exposureProgram: JsonField, + private val exposureTime: JsonField, + private val flash: JsonField, + private val flashpixVersion: JsonField, + private val fNumber: JsonField, + private val focalLength: JsonField, + private val focalPlaneResolutionUnit: JsonField, + private val focalPlaneXResolution: JsonField, + private val focalPlaneYResolution: JsonField, + private val interopOffset: JsonField, + private val iso: JsonField, + private val meteringMode: JsonField, + private val sceneCaptureType: JsonField, + private val shutterSpeedValue: JsonField, + private val subSecTime: JsonField, + private val whiteBalance: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("ApertureValue") + @ExcludeMissing + apertureValue: JsonField = JsonMissing.of(), + @JsonProperty("ColorSpace") + @ExcludeMissing + colorSpace: JsonField = JsonMissing.of(), + @JsonProperty("CreateDate") + @ExcludeMissing + createDate: JsonField = JsonMissing.of(), + @JsonProperty("CustomRendered") + @ExcludeMissing + customRendered: JsonField = JsonMissing.of(), + @JsonProperty("DateTimeOriginal") + @ExcludeMissing + dateTimeOriginal: JsonField = JsonMissing.of(), + @JsonProperty("ExifImageHeight") + @ExcludeMissing + exifImageHeight: JsonField = JsonMissing.of(), + @JsonProperty("ExifImageWidth") + @ExcludeMissing + exifImageWidth: JsonField = JsonMissing.of(), + @JsonProperty("ExifVersion") + @ExcludeMissing + exifVersion: JsonField = JsonMissing.of(), + @JsonProperty("ExposureCompensation") + @ExcludeMissing + exposureCompensation: JsonField = JsonMissing.of(), + @JsonProperty("ExposureMode") + @ExcludeMissing + exposureMode: JsonField = JsonMissing.of(), + @JsonProperty("ExposureProgram") + @ExcludeMissing + exposureProgram: JsonField = JsonMissing.of(), + @JsonProperty("ExposureTime") + @ExcludeMissing + exposureTime: JsonField = JsonMissing.of(), + @JsonProperty("Flash") @ExcludeMissing flash: JsonField = JsonMissing.of(), + @JsonProperty("FlashpixVersion") + @ExcludeMissing + flashpixVersion: JsonField = JsonMissing.of(), + @JsonProperty("FNumber") + @ExcludeMissing + fNumber: JsonField = JsonMissing.of(), + @JsonProperty("FocalLength") + @ExcludeMissing + focalLength: JsonField = JsonMissing.of(), + @JsonProperty("FocalPlaneResolutionUnit") + @ExcludeMissing + focalPlaneResolutionUnit: JsonField = JsonMissing.of(), + @JsonProperty("FocalPlaneXResolution") + @ExcludeMissing + focalPlaneXResolution: JsonField = JsonMissing.of(), + @JsonProperty("FocalPlaneYResolution") + @ExcludeMissing + focalPlaneYResolution: JsonField = JsonMissing.of(), + @JsonProperty("InteropOffset") + @ExcludeMissing + interopOffset: JsonField = JsonMissing.of(), + @JsonProperty("ISO") @ExcludeMissing iso: JsonField = JsonMissing.of(), + @JsonProperty("MeteringMode") + @ExcludeMissing + meteringMode: JsonField = JsonMissing.of(), + @JsonProperty("SceneCaptureType") + @ExcludeMissing + sceneCaptureType: JsonField = JsonMissing.of(), + @JsonProperty("ShutterSpeedValue") + @ExcludeMissing + shutterSpeedValue: JsonField = JsonMissing.of(), + @JsonProperty("SubSecTime") + @ExcludeMissing + subSecTime: JsonField = JsonMissing.of(), + @JsonProperty("WhiteBalance") + @ExcludeMissing + whiteBalance: JsonField = JsonMissing.of(), + ) : this( + apertureValue, + colorSpace, + createDate, + customRendered, + dateTimeOriginal, + exifImageHeight, + exifImageWidth, + exifVersion, + exposureCompensation, + exposureMode, + exposureProgram, + exposureTime, + flash, + flashpixVersion, + fNumber, + focalLength, + focalPlaneResolutionUnit, + focalPlaneXResolution, + focalPlaneYResolution, + interopOffset, + iso, + meteringMode, + sceneCaptureType, + shutterSpeedValue, + subSecTime, + whiteBalance, + mutableMapOf(), + ) + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun apertureValue(): Optional = apertureValue.getOptional("ApertureValue") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun colorSpace(): Optional = colorSpace.getOptional("ColorSpace") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun createDate(): Optional = createDate.getOptional("CreateDate") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun customRendered(): Optional = customRendered.getOptional("CustomRendered") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun dateTimeOriginal(): Optional = + dateTimeOriginal.getOptional("DateTimeOriginal") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun exifImageHeight(): Optional = exifImageHeight.getOptional("ExifImageHeight") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun exifImageWidth(): Optional = exifImageWidth.getOptional("ExifImageWidth") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun exifVersion(): Optional = exifVersion.getOptional("ExifVersion") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun exposureCompensation(): Optional = + exposureCompensation.getOptional("ExposureCompensation") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun exposureMode(): Optional = exposureMode.getOptional("ExposureMode") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun exposureProgram(): Optional = exposureProgram.getOptional("ExposureProgram") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun exposureTime(): Optional = exposureTime.getOptional("ExposureTime") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun flash(): Optional = flash.getOptional("Flash") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun flashpixVersion(): Optional = flashpixVersion.getOptional("FlashpixVersion") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun fNumber(): Optional = fNumber.getOptional("FNumber") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun focalLength(): Optional = focalLength.getOptional("FocalLength") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun focalPlaneResolutionUnit(): Optional = + focalPlaneResolutionUnit.getOptional("FocalPlaneResolutionUnit") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun focalPlaneXResolution(): Optional = + focalPlaneXResolution.getOptional("FocalPlaneXResolution") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun focalPlaneYResolution(): Optional = + focalPlaneYResolution.getOptional("FocalPlaneYResolution") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun interopOffset(): Optional = interopOffset.getOptional("InteropOffset") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun iso(): Optional = iso.getOptional("ISO") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun meteringMode(): Optional = meteringMode.getOptional("MeteringMode") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sceneCaptureType(): Optional = + sceneCaptureType.getOptional("SceneCaptureType") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun shutterSpeedValue(): Optional = + shutterSpeedValue.getOptional("ShutterSpeedValue") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun subSecTime(): Optional = subSecTime.getOptional("SubSecTime") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun whiteBalance(): Optional = whiteBalance.getOptional("WhiteBalance") + + /** + * Returns the raw JSON value of [apertureValue]. + * + * Unlike [apertureValue], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ApertureValue") + @ExcludeMissing + fun _apertureValue(): JsonField = apertureValue + + /** + * Returns the raw JSON value of [colorSpace]. + * + * Unlike [colorSpace], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ColorSpace") + @ExcludeMissing + fun _colorSpace(): JsonField = colorSpace + + /** + * Returns the raw JSON value of [createDate]. + * + * Unlike [createDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("CreateDate") + @ExcludeMissing + fun _createDate(): JsonField = createDate + + /** + * Returns the raw JSON value of [customRendered]. + * + * Unlike [customRendered], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("CustomRendered") + @ExcludeMissing + fun _customRendered(): JsonField = customRendered + + /** + * Returns the raw JSON value of [dateTimeOriginal]. + * + * Unlike [dateTimeOriginal], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("DateTimeOriginal") + @ExcludeMissing + fun _dateTimeOriginal(): JsonField = dateTimeOriginal + + /** + * Returns the raw JSON value of [exifImageHeight]. + * + * Unlike [exifImageHeight], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ExifImageHeight") + @ExcludeMissing + fun _exifImageHeight(): JsonField = exifImageHeight + + /** + * Returns the raw JSON value of [exifImageWidth]. + * + * Unlike [exifImageWidth], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ExifImageWidth") + @ExcludeMissing + fun _exifImageWidth(): JsonField = exifImageWidth + + /** + * Returns the raw JSON value of [exifVersion]. + * + * Unlike [exifVersion], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ExifVersion") + @ExcludeMissing + fun _exifVersion(): JsonField = exifVersion + + /** + * Returns the raw JSON value of [exposureCompensation]. + * + * Unlike [exposureCompensation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ExposureCompensation") + @ExcludeMissing + fun _exposureCompensation(): JsonField = exposureCompensation + + /** + * Returns the raw JSON value of [exposureMode]. + * + * Unlike [exposureMode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ExposureMode") + @ExcludeMissing + fun _exposureMode(): JsonField = exposureMode + + /** + * Returns the raw JSON value of [exposureProgram]. + * + * Unlike [exposureProgram], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ExposureProgram") + @ExcludeMissing + fun _exposureProgram(): JsonField = exposureProgram + + /** + * Returns the raw JSON value of [exposureTime]. + * + * Unlike [exposureTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ExposureTime") + @ExcludeMissing + fun _exposureTime(): JsonField = exposureTime + + /** + * Returns the raw JSON value of [flash]. + * + * Unlike [flash], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Flash") @ExcludeMissing fun _flash(): JsonField = flash + + /** + * Returns the raw JSON value of [flashpixVersion]. + * + * Unlike [flashpixVersion], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("FlashpixVersion") + @ExcludeMissing + fun _flashpixVersion(): JsonField = flashpixVersion + + /** + * Returns the raw JSON value of [fNumber]. + * + * Unlike [fNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("FNumber") @ExcludeMissing fun _fNumber(): JsonField = fNumber + + /** + * Returns the raw JSON value of [focalLength]. + * + * Unlike [focalLength], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("FocalLength") + @ExcludeMissing + fun _focalLength(): JsonField = focalLength + + /** + * Returns the raw JSON value of [focalPlaneResolutionUnit]. + * + * Unlike [focalPlaneResolutionUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("FocalPlaneResolutionUnit") + @ExcludeMissing + fun _focalPlaneResolutionUnit(): JsonField = focalPlaneResolutionUnit + + /** + * Returns the raw JSON value of [focalPlaneXResolution]. + * + * Unlike [focalPlaneXResolution], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("FocalPlaneXResolution") + @ExcludeMissing + fun _focalPlaneXResolution(): JsonField = focalPlaneXResolution + + /** + * Returns the raw JSON value of [focalPlaneYResolution]. + * + * Unlike [focalPlaneYResolution], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("FocalPlaneYResolution") + @ExcludeMissing + fun _focalPlaneYResolution(): JsonField = focalPlaneYResolution + + /** + * Returns the raw JSON value of [interopOffset]. + * + * Unlike [interopOffset], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("InteropOffset") + @ExcludeMissing + fun _interopOffset(): JsonField = interopOffset + + /** + * Returns the raw JSON value of [iso]. + * + * Unlike [iso], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ISO") @ExcludeMissing fun _iso(): JsonField = iso + + /** + * Returns the raw JSON value of [meteringMode]. + * + * Unlike [meteringMode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("MeteringMode") + @ExcludeMissing + fun _meteringMode(): JsonField = meteringMode + + /** + * Returns the raw JSON value of [sceneCaptureType]. + * + * Unlike [sceneCaptureType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("SceneCaptureType") + @ExcludeMissing + fun _sceneCaptureType(): JsonField = sceneCaptureType + + /** + * Returns the raw JSON value of [shutterSpeedValue]. + * + * Unlike [shutterSpeedValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ShutterSpeedValue") + @ExcludeMissing + fun _shutterSpeedValue(): JsonField = shutterSpeedValue + + /** + * Returns the raw JSON value of [subSecTime]. + * + * Unlike [subSecTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("SubSecTime") + @ExcludeMissing + fun _subSecTime(): JsonField = subSecTime + + /** + * Returns the raw JSON value of [whiteBalance]. + * + * Unlike [whiteBalance], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("WhiteBalance") + @ExcludeMissing + fun _whiteBalance(): JsonField = whiteBalance + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [InnerExif]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InnerExif]. */ + class Builder internal constructor() { + + private var apertureValue: JsonField = JsonMissing.of() + private var colorSpace: JsonField = JsonMissing.of() + private var createDate: JsonField = JsonMissing.of() + private var customRendered: JsonField = JsonMissing.of() + private var dateTimeOriginal: JsonField = JsonMissing.of() + private var exifImageHeight: JsonField = JsonMissing.of() + private var exifImageWidth: JsonField = JsonMissing.of() + private var exifVersion: JsonField = JsonMissing.of() + private var exposureCompensation: JsonField = JsonMissing.of() + private var exposureMode: JsonField = JsonMissing.of() + private var exposureProgram: JsonField = JsonMissing.of() + private var exposureTime: JsonField = JsonMissing.of() + private var flash: JsonField = JsonMissing.of() + private var flashpixVersion: JsonField = JsonMissing.of() + private var fNumber: JsonField = JsonMissing.of() + private var focalLength: JsonField = JsonMissing.of() + private var focalPlaneResolutionUnit: JsonField = JsonMissing.of() + private var focalPlaneXResolution: JsonField = JsonMissing.of() + private var focalPlaneYResolution: JsonField = JsonMissing.of() + private var interopOffset: JsonField = JsonMissing.of() + private var iso: JsonField = JsonMissing.of() + private var meteringMode: JsonField = JsonMissing.of() + private var sceneCaptureType: JsonField = JsonMissing.of() + private var shutterSpeedValue: JsonField = JsonMissing.of() + private var subSecTime: JsonField = JsonMissing.of() + private var whiteBalance: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(innerExif: InnerExif) = apply { + apertureValue = innerExif.apertureValue + colorSpace = innerExif.colorSpace + createDate = innerExif.createDate + customRendered = innerExif.customRendered + dateTimeOriginal = innerExif.dateTimeOriginal + exifImageHeight = innerExif.exifImageHeight + exifImageWidth = innerExif.exifImageWidth + exifVersion = innerExif.exifVersion + exposureCompensation = innerExif.exposureCompensation + exposureMode = innerExif.exposureMode + exposureProgram = innerExif.exposureProgram + exposureTime = innerExif.exposureTime + flash = innerExif.flash + flashpixVersion = innerExif.flashpixVersion + fNumber = innerExif.fNumber + focalLength = innerExif.focalLength + focalPlaneResolutionUnit = innerExif.focalPlaneResolutionUnit + focalPlaneXResolution = innerExif.focalPlaneXResolution + focalPlaneYResolution = innerExif.focalPlaneYResolution + interopOffset = innerExif.interopOffset + iso = innerExif.iso + meteringMode = innerExif.meteringMode + sceneCaptureType = innerExif.sceneCaptureType + shutterSpeedValue = innerExif.shutterSpeedValue + subSecTime = innerExif.subSecTime + whiteBalance = innerExif.whiteBalance + additionalProperties = innerExif.additionalProperties.toMutableMap() + } + + fun apertureValue(apertureValue: Double) = + apertureValue(JsonField.of(apertureValue)) + + /** + * Sets [Builder.apertureValue] to an arbitrary JSON value. + * + * You should usually call [Builder.apertureValue] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun apertureValue(apertureValue: JsonField) = apply { + this.apertureValue = apertureValue + } + + fun colorSpace(colorSpace: Long) = colorSpace(JsonField.of(colorSpace)) + + /** + * Sets [Builder.colorSpace] to an arbitrary JSON value. + * + * You should usually call [Builder.colorSpace] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun colorSpace(colorSpace: JsonField) = apply { this.colorSpace = colorSpace } + + fun createDate(createDate: String) = createDate(JsonField.of(createDate)) + + /** + * Sets [Builder.createDate] to an arbitrary JSON value. + * + * You should usually call [Builder.createDate] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun createDate(createDate: JsonField) = apply { + this.createDate = createDate + } + + fun customRendered(customRendered: Long) = + customRendered(JsonField.of(customRendered)) + + /** + * Sets [Builder.customRendered] to an arbitrary JSON value. + * + * You should usually call [Builder.customRendered] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun customRendered(customRendered: JsonField) = apply { + this.customRendered = customRendered + } + + fun dateTimeOriginal(dateTimeOriginal: String) = + dateTimeOriginal(JsonField.of(dateTimeOriginal)) + + /** + * Sets [Builder.dateTimeOriginal] to an arbitrary JSON value. + * + * You should usually call [Builder.dateTimeOriginal] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun dateTimeOriginal(dateTimeOriginal: JsonField) = apply { + this.dateTimeOriginal = dateTimeOriginal + } + + fun exifImageHeight(exifImageHeight: Long) = + exifImageHeight(JsonField.of(exifImageHeight)) + + /** + * Sets [Builder.exifImageHeight] to an arbitrary JSON value. + * + * You should usually call [Builder.exifImageHeight] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun exifImageHeight(exifImageHeight: JsonField) = apply { + this.exifImageHeight = exifImageHeight + } + + fun exifImageWidth(exifImageWidth: Long) = + exifImageWidth(JsonField.of(exifImageWidth)) + + /** + * Sets [Builder.exifImageWidth] to an arbitrary JSON value. + * + * You should usually call [Builder.exifImageWidth] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun exifImageWidth(exifImageWidth: JsonField) = apply { + this.exifImageWidth = exifImageWidth + } + + fun exifVersion(exifVersion: String) = exifVersion(JsonField.of(exifVersion)) + + /** + * Sets [Builder.exifVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.exifVersion] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun exifVersion(exifVersion: JsonField) = apply { + this.exifVersion = exifVersion + } + + fun exposureCompensation(exposureCompensation: Double) = + exposureCompensation(JsonField.of(exposureCompensation)) + + /** + * Sets [Builder.exposureCompensation] to an arbitrary JSON value. + * + * You should usually call [Builder.exposureCompensation] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun exposureCompensation(exposureCompensation: JsonField) = apply { + this.exposureCompensation = exposureCompensation + } + + fun exposureMode(exposureMode: Long) = exposureMode(JsonField.of(exposureMode)) + + /** + * Sets [Builder.exposureMode] to an arbitrary JSON value. + * + * You should usually call [Builder.exposureMode] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun exposureMode(exposureMode: JsonField) = apply { + this.exposureMode = exposureMode + } + + fun exposureProgram(exposureProgram: Long) = + exposureProgram(JsonField.of(exposureProgram)) + + /** + * Sets [Builder.exposureProgram] to an arbitrary JSON value. + * + * You should usually call [Builder.exposureProgram] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun exposureProgram(exposureProgram: JsonField) = apply { + this.exposureProgram = exposureProgram + } + + fun exposureTime(exposureTime: Double) = exposureTime(JsonField.of(exposureTime)) + + /** + * Sets [Builder.exposureTime] to an arbitrary JSON value. + * + * You should usually call [Builder.exposureTime] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun exposureTime(exposureTime: JsonField) = apply { + this.exposureTime = exposureTime + } + + fun flash(flash: Long) = flash(JsonField.of(flash)) + + /** + * Sets [Builder.flash] to an arbitrary JSON value. + * + * You should usually call [Builder.flash] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun flash(flash: JsonField) = apply { this.flash = flash } + + fun flashpixVersion(flashpixVersion: String) = + flashpixVersion(JsonField.of(flashpixVersion)) + + /** + * Sets [Builder.flashpixVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.flashpixVersion] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun flashpixVersion(flashpixVersion: JsonField) = apply { + this.flashpixVersion = flashpixVersion + } + + fun fNumber(fNumber: Double) = fNumber(JsonField.of(fNumber)) + + /** + * Sets [Builder.fNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.fNumber] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun fNumber(fNumber: JsonField) = apply { this.fNumber = fNumber } + + fun focalLength(focalLength: Long) = focalLength(JsonField.of(focalLength)) + + /** + * Sets [Builder.focalLength] to an arbitrary JSON value. + * + * You should usually call [Builder.focalLength] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun focalLength(focalLength: JsonField) = apply { + this.focalLength = focalLength + } + + fun focalPlaneResolutionUnit(focalPlaneResolutionUnit: Long) = + focalPlaneResolutionUnit(JsonField.of(focalPlaneResolutionUnit)) + + /** + * Sets [Builder.focalPlaneResolutionUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.focalPlaneResolutionUnit] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun focalPlaneResolutionUnit(focalPlaneResolutionUnit: JsonField) = apply { + this.focalPlaneResolutionUnit = focalPlaneResolutionUnit + } + + fun focalPlaneXResolution(focalPlaneXResolution: Double) = + focalPlaneXResolution(JsonField.of(focalPlaneXResolution)) + + /** + * Sets [Builder.focalPlaneXResolution] to an arbitrary JSON value. + * + * You should usually call [Builder.focalPlaneXResolution] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun focalPlaneXResolution(focalPlaneXResolution: JsonField) = apply { + this.focalPlaneXResolution = focalPlaneXResolution + } + + fun focalPlaneYResolution(focalPlaneYResolution: Double) = + focalPlaneYResolution(JsonField.of(focalPlaneYResolution)) + + /** + * Sets [Builder.focalPlaneYResolution] to an arbitrary JSON value. + * + * You should usually call [Builder.focalPlaneYResolution] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun focalPlaneYResolution(focalPlaneYResolution: JsonField) = apply { + this.focalPlaneYResolution = focalPlaneYResolution + } + + fun interopOffset(interopOffset: Long) = interopOffset(JsonField.of(interopOffset)) + + /** + * Sets [Builder.interopOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.interopOffset] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun interopOffset(interopOffset: JsonField) = apply { + this.interopOffset = interopOffset + } + + fun iso(iso: Long) = iso(JsonField.of(iso)) + + /** + * Sets [Builder.iso] to an arbitrary JSON value. + * + * You should usually call [Builder.iso] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun iso(iso: JsonField) = apply { this.iso = iso } + + fun meteringMode(meteringMode: Long) = meteringMode(JsonField.of(meteringMode)) + + /** + * Sets [Builder.meteringMode] to an arbitrary JSON value. + * + * You should usually call [Builder.meteringMode] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun meteringMode(meteringMode: JsonField) = apply { + this.meteringMode = meteringMode + } + + fun sceneCaptureType(sceneCaptureType: Long) = + sceneCaptureType(JsonField.of(sceneCaptureType)) + + /** + * Sets [Builder.sceneCaptureType] to an arbitrary JSON value. + * + * You should usually call [Builder.sceneCaptureType] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun sceneCaptureType(sceneCaptureType: JsonField) = apply { + this.sceneCaptureType = sceneCaptureType + } + + fun shutterSpeedValue(shutterSpeedValue: Double) = + shutterSpeedValue(JsonField.of(shutterSpeedValue)) + + /** + * Sets [Builder.shutterSpeedValue] to an arbitrary JSON value. + * + * You should usually call [Builder.shutterSpeedValue] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun shutterSpeedValue(shutterSpeedValue: JsonField) = apply { + this.shutterSpeedValue = shutterSpeedValue + } + + fun subSecTime(subSecTime: String) = subSecTime(JsonField.of(subSecTime)) + + /** + * Sets [Builder.subSecTime] to an arbitrary JSON value. + * + * You should usually call [Builder.subSecTime] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun subSecTime(subSecTime: JsonField) = apply { + this.subSecTime = subSecTime + } + + fun whiteBalance(whiteBalance: Long) = whiteBalance(JsonField.of(whiteBalance)) + + /** + * Sets [Builder.whiteBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.whiteBalance] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun whiteBalance(whiteBalance: JsonField) = apply { + this.whiteBalance = whiteBalance + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InnerExif]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InnerExif = + InnerExif( + apertureValue, + colorSpace, + createDate, + customRendered, + dateTimeOriginal, + exifImageHeight, + exifImageWidth, + exifVersion, + exposureCompensation, + exposureMode, + exposureProgram, + exposureTime, + flash, + flashpixVersion, + fNumber, + focalLength, + focalPlaneResolutionUnit, + focalPlaneXResolution, + focalPlaneYResolution, + interopOffset, + iso, + meteringMode, + sceneCaptureType, + shutterSpeedValue, + subSecTime, + whiteBalance, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InnerExif = apply { + if (validated) { + return@apply + } + + apertureValue() + colorSpace() + createDate() + customRendered() + dateTimeOriginal() + exifImageHeight() + exifImageWidth() + exifVersion() + exposureCompensation() + exposureMode() + exposureProgram() + exposureTime() + flash() + flashpixVersion() + fNumber() + focalLength() + focalPlaneResolutionUnit() + focalPlaneXResolution() + focalPlaneYResolution() + interopOffset() + iso() + meteringMode() + sceneCaptureType() + shutterSpeedValue() + subSecTime() + whiteBalance() + 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 (apertureValue.asKnown().isPresent) 1 else 0) + + (if (colorSpace.asKnown().isPresent) 1 else 0) + + (if (createDate.asKnown().isPresent) 1 else 0) + + (if (customRendered.asKnown().isPresent) 1 else 0) + + (if (dateTimeOriginal.asKnown().isPresent) 1 else 0) + + (if (exifImageHeight.asKnown().isPresent) 1 else 0) + + (if (exifImageWidth.asKnown().isPresent) 1 else 0) + + (if (exifVersion.asKnown().isPresent) 1 else 0) + + (if (exposureCompensation.asKnown().isPresent) 1 else 0) + + (if (exposureMode.asKnown().isPresent) 1 else 0) + + (if (exposureProgram.asKnown().isPresent) 1 else 0) + + (if (exposureTime.asKnown().isPresent) 1 else 0) + + (if (flash.asKnown().isPresent) 1 else 0) + + (if (flashpixVersion.asKnown().isPresent) 1 else 0) + + (if (fNumber.asKnown().isPresent) 1 else 0) + + (if (focalLength.asKnown().isPresent) 1 else 0) + + (if (focalPlaneResolutionUnit.asKnown().isPresent) 1 else 0) + + (if (focalPlaneXResolution.asKnown().isPresent) 1 else 0) + + (if (focalPlaneYResolution.asKnown().isPresent) 1 else 0) + + (if (interopOffset.asKnown().isPresent) 1 else 0) + + (if (iso.asKnown().isPresent) 1 else 0) + + (if (meteringMode.asKnown().isPresent) 1 else 0) + + (if (sceneCaptureType.asKnown().isPresent) 1 else 0) + + (if (shutterSpeedValue.asKnown().isPresent) 1 else 0) + + (if (subSecTime.asKnown().isPresent) 1 else 0) + + (if (whiteBalance.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InnerExif && + apertureValue == other.apertureValue && + colorSpace == other.colorSpace && + createDate == other.createDate && + customRendered == other.customRendered && + dateTimeOriginal == other.dateTimeOriginal && + exifImageHeight == other.exifImageHeight && + exifImageWidth == other.exifImageWidth && + exifVersion == other.exifVersion && + exposureCompensation == other.exposureCompensation && + exposureMode == other.exposureMode && + exposureProgram == other.exposureProgram && + exposureTime == other.exposureTime && + flash == other.flash && + flashpixVersion == other.flashpixVersion && + fNumber == other.fNumber && + focalLength == other.focalLength && + focalPlaneResolutionUnit == other.focalPlaneResolutionUnit && + focalPlaneXResolution == other.focalPlaneXResolution && + focalPlaneYResolution == other.focalPlaneYResolution && + interopOffset == other.interopOffset && + iso == other.iso && + meteringMode == other.meteringMode && + sceneCaptureType == other.sceneCaptureType && + shutterSpeedValue == other.shutterSpeedValue && + subSecTime == other.subSecTime && + whiteBalance == other.whiteBalance && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + apertureValue, + colorSpace, + createDate, + customRendered, + dateTimeOriginal, + exifImageHeight, + exifImageWidth, + exifVersion, + exposureCompensation, + exposureMode, + exposureProgram, + exposureTime, + flash, + flashpixVersion, + fNumber, + focalLength, + focalPlaneResolutionUnit, + focalPlaneXResolution, + focalPlaneYResolution, + interopOffset, + iso, + meteringMode, + sceneCaptureType, + shutterSpeedValue, + subSecTime, + whiteBalance, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InnerExif{apertureValue=$apertureValue, colorSpace=$colorSpace, createDate=$createDate, customRendered=$customRendered, dateTimeOriginal=$dateTimeOriginal, exifImageHeight=$exifImageHeight, exifImageWidth=$exifImageWidth, exifVersion=$exifVersion, exposureCompensation=$exposureCompensation, exposureMode=$exposureMode, exposureProgram=$exposureProgram, exposureTime=$exposureTime, flash=$flash, flashpixVersion=$flashpixVersion, fNumber=$fNumber, focalLength=$focalLength, focalPlaneResolutionUnit=$focalPlaneResolutionUnit, focalPlaneXResolution=$focalPlaneXResolution, focalPlaneYResolution=$focalPlaneYResolution, interopOffset=$interopOffset, iso=$iso, meteringMode=$meteringMode, sceneCaptureType=$sceneCaptureType, shutterSpeedValue=$shutterSpeedValue, subSecTime=$subSecTime, whiteBalance=$whiteBalance, additionalProperties=$additionalProperties}" + } + + /** Object containing GPS information. */ + class Gps + private constructor( + private val gpsVersionId: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("GPSVersionID") + @ExcludeMissing + gpsVersionId: JsonField> = JsonMissing.of() + ) : this(gpsVersionId, mutableMapOf()) + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun gpsVersionId(): Optional> = gpsVersionId.getOptional("GPSVersionID") + + /** + * Returns the raw JSON value of [gpsVersionId]. + * + * Unlike [gpsVersionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("GPSVersionID") + @ExcludeMissing + fun _gpsVersionId(): JsonField> = gpsVersionId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Gps]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Gps]. */ + class Builder internal constructor() { + + private var gpsVersionId: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(gps: Gps) = apply { + gpsVersionId = gps.gpsVersionId.map { it.toMutableList() } + additionalProperties = gps.additionalProperties.toMutableMap() + } + + fun gpsVersionId(gpsVersionId: List) = + gpsVersionId(JsonField.of(gpsVersionId)) + + /** + * Sets [Builder.gpsVersionId] to an arbitrary JSON value. + * + * You should usually call [Builder.gpsVersionId] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun gpsVersionId(gpsVersionId: JsonField>) = apply { + this.gpsVersionId = gpsVersionId.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.gpsVersionId]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addGpsVersionId(gpsVersionId: Long) = apply { + this.gpsVersionId = + (this.gpsVersionId ?: JsonField.of(mutableListOf())).also { + checkKnown("gpsVersionId", it).add(gpsVersionId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Gps]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Gps = + Gps( + (gpsVersionId ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Gps = apply { + if (validated) { + return@apply + } + + gpsVersionId() + 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 = (gpsVersionId.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Gps && + gpsVersionId == other.gpsVersionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(gpsVersionId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Gps{gpsVersionId=$gpsVersionId, additionalProperties=$additionalProperties}" + } + + /** Object containing EXIF image information. */ + class Image + private constructor( + private val exifOffset: JsonField, + private val gpsInfo: JsonField, + private val make: JsonField, + private val model: JsonField, + private val modifyDate: JsonField, + private val orientation: JsonField, + private val resolutionUnit: JsonField, + private val software: JsonField, + private val xResolution: JsonField, + private val yCbCrPositioning: JsonField, + private val yResolution: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("ExifOffset") + @ExcludeMissing + exifOffset: JsonField = JsonMissing.of(), + @JsonProperty("GPSInfo") + @ExcludeMissing + gpsInfo: JsonField = JsonMissing.of(), + @JsonProperty("Make") @ExcludeMissing make: JsonField = JsonMissing.of(), + @JsonProperty("Model") @ExcludeMissing model: JsonField = JsonMissing.of(), + @JsonProperty("ModifyDate") + @ExcludeMissing + modifyDate: JsonField = JsonMissing.of(), + @JsonProperty("Orientation") + @ExcludeMissing + orientation: JsonField = JsonMissing.of(), + @JsonProperty("ResolutionUnit") + @ExcludeMissing + resolutionUnit: JsonField = JsonMissing.of(), + @JsonProperty("Software") + @ExcludeMissing + software: JsonField = JsonMissing.of(), + @JsonProperty("XResolution") + @ExcludeMissing + xResolution: JsonField = JsonMissing.of(), + @JsonProperty("YCbCrPositioning") + @ExcludeMissing + yCbCrPositioning: JsonField = JsonMissing.of(), + @JsonProperty("YResolution") + @ExcludeMissing + yResolution: JsonField = JsonMissing.of(), + ) : this( + exifOffset, + gpsInfo, + make, + model, + modifyDate, + orientation, + resolutionUnit, + software, + xResolution, + yCbCrPositioning, + yResolution, + mutableMapOf(), + ) + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun exifOffset(): Optional = exifOffset.getOptional("ExifOffset") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun gpsInfo(): Optional = gpsInfo.getOptional("GPSInfo") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun make(): Optional = make.getOptional("Make") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun model(): Optional = model.getOptional("Model") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun modifyDate(): Optional = modifyDate.getOptional("ModifyDate") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun orientation(): Optional = orientation.getOptional("Orientation") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun resolutionUnit(): Optional = resolutionUnit.getOptional("ResolutionUnit") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun software(): Optional = software.getOptional("Software") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun xResolution(): Optional = xResolution.getOptional("XResolution") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun yCbCrPositioning(): Optional = + yCbCrPositioning.getOptional("YCbCrPositioning") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun yResolution(): Optional = yResolution.getOptional("YResolution") + + /** + * Returns the raw JSON value of [exifOffset]. + * + * Unlike [exifOffset], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ExifOffset") + @ExcludeMissing + fun _exifOffset(): JsonField = exifOffset + + /** + * Returns the raw JSON value of [gpsInfo]. + * + * Unlike [gpsInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("GPSInfo") @ExcludeMissing fun _gpsInfo(): JsonField = gpsInfo + + /** + * Returns the raw JSON value of [make]. + * + * Unlike [make], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Make") @ExcludeMissing fun _make(): JsonField = make + + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("Model") @ExcludeMissing fun _model(): JsonField = model + + /** + * Returns the raw JSON value of [modifyDate]. + * + * Unlike [modifyDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ModifyDate") + @ExcludeMissing + fun _modifyDate(): JsonField = modifyDate + + /** + * Returns the raw JSON value of [orientation]. + * + * Unlike [orientation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("Orientation") + @ExcludeMissing + fun _orientation(): JsonField = orientation + + /** + * Returns the raw JSON value of [resolutionUnit]. + * + * Unlike [resolutionUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ResolutionUnit") + @ExcludeMissing + fun _resolutionUnit(): JsonField = resolutionUnit + + /** + * Returns the raw JSON value of [software]. + * + * Unlike [software], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("Software") @ExcludeMissing fun _software(): JsonField = software + + /** + * Returns the raw JSON value of [xResolution]. + * + * Unlike [xResolution], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("XResolution") + @ExcludeMissing + fun _xResolution(): JsonField = xResolution + + /** + * Returns the raw JSON value of [yCbCrPositioning]. + * + * Unlike [yCbCrPositioning], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("YCbCrPositioning") + @ExcludeMissing + fun _yCbCrPositioning(): JsonField = yCbCrPositioning + + /** + * Returns the raw JSON value of [yResolution]. + * + * Unlike [yResolution], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("YResolution") + @ExcludeMissing + fun _yResolution(): JsonField = yResolution + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Image]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Image]. */ + class Builder internal constructor() { + + private var exifOffset: JsonField = JsonMissing.of() + private var gpsInfo: JsonField = JsonMissing.of() + private var make: JsonField = JsonMissing.of() + private var model: JsonField = JsonMissing.of() + private var modifyDate: JsonField = JsonMissing.of() + private var orientation: JsonField = JsonMissing.of() + private var resolutionUnit: JsonField = JsonMissing.of() + private var software: JsonField = JsonMissing.of() + private var xResolution: JsonField = JsonMissing.of() + private var yCbCrPositioning: JsonField = JsonMissing.of() + private var yResolution: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(image: Image) = apply { + exifOffset = image.exifOffset + gpsInfo = image.gpsInfo + make = image.make + model = image.model + modifyDate = image.modifyDate + orientation = image.orientation + resolutionUnit = image.resolutionUnit + software = image.software + xResolution = image.xResolution + yCbCrPositioning = image.yCbCrPositioning + yResolution = image.yResolution + additionalProperties = image.additionalProperties.toMutableMap() + } + + fun exifOffset(exifOffset: Long) = exifOffset(JsonField.of(exifOffset)) + + /** + * Sets [Builder.exifOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.exifOffset] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun exifOffset(exifOffset: JsonField) = apply { this.exifOffset = exifOffset } + + fun gpsInfo(gpsInfo: Long) = gpsInfo(JsonField.of(gpsInfo)) + + /** + * Sets [Builder.gpsInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.gpsInfo] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gpsInfo(gpsInfo: JsonField) = apply { this.gpsInfo = gpsInfo } + + fun make(make: String) = make(JsonField.of(make)) + + /** + * Sets [Builder.make] to an arbitrary JSON value. + * + * You should usually call [Builder.make] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun make(make: JsonField) = apply { this.make = make } + + fun model(model: String) = model(JsonField.of(model)) + + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun model(model: JsonField) = apply { this.model = model } + + fun modifyDate(modifyDate: String) = modifyDate(JsonField.of(modifyDate)) + + /** + * Sets [Builder.modifyDate] to an arbitrary JSON value. + * + * You should usually call [Builder.modifyDate] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun modifyDate(modifyDate: JsonField) = apply { + this.modifyDate = modifyDate + } + + fun orientation(orientation: Long) = orientation(JsonField.of(orientation)) + + /** + * Sets [Builder.orientation] to an arbitrary JSON value. + * + * You should usually call [Builder.orientation] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun orientation(orientation: JsonField) = apply { + this.orientation = orientation + } + + fun resolutionUnit(resolutionUnit: Long) = + resolutionUnit(JsonField.of(resolutionUnit)) + + /** + * Sets [Builder.resolutionUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.resolutionUnit] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun resolutionUnit(resolutionUnit: JsonField) = apply { + this.resolutionUnit = resolutionUnit + } + + fun software(software: String) = software(JsonField.of(software)) + + /** + * Sets [Builder.software] to an arbitrary JSON value. + * + * You should usually call [Builder.software] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun software(software: JsonField) = apply { this.software = software } + + fun xResolution(xResolution: Long) = xResolution(JsonField.of(xResolution)) + + /** + * Sets [Builder.xResolution] to an arbitrary JSON value. + * + * You should usually call [Builder.xResolution] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun xResolution(xResolution: JsonField) = apply { + this.xResolution = xResolution + } + + fun yCbCrPositioning(yCbCrPositioning: Long) = + yCbCrPositioning(JsonField.of(yCbCrPositioning)) + + /** + * Sets [Builder.yCbCrPositioning] to an arbitrary JSON value. + * + * You should usually call [Builder.yCbCrPositioning] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun yCbCrPositioning(yCbCrPositioning: JsonField) = apply { + this.yCbCrPositioning = yCbCrPositioning + } + + fun yResolution(yResolution: Long) = yResolution(JsonField.of(yResolution)) + + /** + * Sets [Builder.yResolution] to an arbitrary JSON value. + * + * You should usually call [Builder.yResolution] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun yResolution(yResolution: JsonField) = apply { + this.yResolution = yResolution + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Image]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Image = + Image( + exifOffset, + gpsInfo, + make, + model, + modifyDate, + orientation, + resolutionUnit, + software, + xResolution, + yCbCrPositioning, + yResolution, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Image = apply { + if (validated) { + return@apply + } + + exifOffset() + gpsInfo() + make() + model() + modifyDate() + orientation() + resolutionUnit() + software() + xResolution() + yCbCrPositioning() + yResolution() + 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 (exifOffset.asKnown().isPresent) 1 else 0) + + (if (gpsInfo.asKnown().isPresent) 1 else 0) + + (if (make.asKnown().isPresent) 1 else 0) + + (if (model.asKnown().isPresent) 1 else 0) + + (if (modifyDate.asKnown().isPresent) 1 else 0) + + (if (orientation.asKnown().isPresent) 1 else 0) + + (if (resolutionUnit.asKnown().isPresent) 1 else 0) + + (if (software.asKnown().isPresent) 1 else 0) + + (if (xResolution.asKnown().isPresent) 1 else 0) + + (if (yCbCrPositioning.asKnown().isPresent) 1 else 0) + + (if (yResolution.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Image && + exifOffset == other.exifOffset && + gpsInfo == other.gpsInfo && + make == other.make && + model == other.model && + modifyDate == other.modifyDate && + orientation == other.orientation && + resolutionUnit == other.resolutionUnit && + software == other.software && + xResolution == other.xResolution && + yCbCrPositioning == other.yCbCrPositioning && + yResolution == other.yResolution && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + exifOffset, + gpsInfo, + make, + model, + modifyDate, + orientation, + resolutionUnit, + software, + xResolution, + yCbCrPositioning, + yResolution, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Image{exifOffset=$exifOffset, gpsInfo=$gpsInfo, make=$make, model=$model, modifyDate=$modifyDate, orientation=$orientation, resolutionUnit=$resolutionUnit, software=$software, xResolution=$xResolution, yCbCrPositioning=$yCbCrPositioning, yResolution=$yResolution, additionalProperties=$additionalProperties}" + } + + /** JSON object. */ + class Interoperability + private constructor( + private val interopIndex: JsonField, + private val interopVersion: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("InteropIndex") + @ExcludeMissing + interopIndex: JsonField = JsonMissing.of(), + @JsonProperty("InteropVersion") + @ExcludeMissing + interopVersion: JsonField = JsonMissing.of(), + ) : this(interopIndex, interopVersion, mutableMapOf()) + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun interopIndex(): Optional = interopIndex.getOptional("InteropIndex") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun interopVersion(): Optional = interopVersion.getOptional("InteropVersion") + + /** + * Returns the raw JSON value of [interopIndex]. + * + * Unlike [interopIndex], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("InteropIndex") + @ExcludeMissing + fun _interopIndex(): JsonField = interopIndex + + /** + * Returns the raw JSON value of [interopVersion]. + * + * Unlike [interopVersion], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("InteropVersion") + @ExcludeMissing + fun _interopVersion(): JsonField = interopVersion + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Interoperability]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Interoperability]. */ + class Builder internal constructor() { + + private var interopIndex: JsonField = JsonMissing.of() + private var interopVersion: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(interoperability: Interoperability) = apply { + interopIndex = interoperability.interopIndex + interopVersion = interoperability.interopVersion + additionalProperties = interoperability.additionalProperties.toMutableMap() + } + + fun interopIndex(interopIndex: String) = interopIndex(JsonField.of(interopIndex)) + + /** + * Sets [Builder.interopIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.interopIndex] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun interopIndex(interopIndex: JsonField) = apply { + this.interopIndex = interopIndex + } + + fun interopVersion(interopVersion: String) = + interopVersion(JsonField.of(interopVersion)) + + /** + * Sets [Builder.interopVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.interopVersion] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun interopVersion(interopVersion: JsonField) = apply { + this.interopVersion = interopVersion + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Interoperability]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Interoperability = + Interoperability( + interopIndex, + interopVersion, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Interoperability = apply { + if (validated) { + return@apply + } + + interopIndex() + interopVersion() + 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 (interopIndex.asKnown().isPresent) 1 else 0) + + (if (interopVersion.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Interoperability && + interopIndex == other.interopIndex && + interopVersion == other.interopVersion && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(interopIndex, interopVersion, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Interoperability{interopIndex=$interopIndex, interopVersion=$interopVersion, additionalProperties=$additionalProperties}" + } + + class Makernote + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Makernote]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Makernote]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(makernote: Makernote) = apply { + additionalProperties = makernote.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Makernote]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Makernote = Makernote(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Makernote = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Makernote && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Makernote{additionalProperties=$additionalProperties}" + } + + /** Object containing Thumbnail information. */ + class Thumbnail + private constructor( + private val compression: JsonField, + private val resolutionUnit: JsonField, + private val thumbnailLength: JsonField, + private val thumbnailOffset: JsonField, + private val xResolution: JsonField, + private val yResolution: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("Compression") + @ExcludeMissing + compression: JsonField = JsonMissing.of(), + @JsonProperty("ResolutionUnit") + @ExcludeMissing + resolutionUnit: JsonField = JsonMissing.of(), + @JsonProperty("ThumbnailLength") + @ExcludeMissing + thumbnailLength: JsonField = JsonMissing.of(), + @JsonProperty("ThumbnailOffset") + @ExcludeMissing + thumbnailOffset: JsonField = JsonMissing.of(), + @JsonProperty("XResolution") + @ExcludeMissing + xResolution: JsonField = JsonMissing.of(), + @JsonProperty("YResolution") + @ExcludeMissing + yResolution: JsonField = JsonMissing.of(), + ) : this( + compression, + resolutionUnit, + thumbnailLength, + thumbnailOffset, + xResolution, + yResolution, + mutableMapOf(), + ) + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun compression(): Optional = compression.getOptional("Compression") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun resolutionUnit(): Optional = resolutionUnit.getOptional("ResolutionUnit") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun thumbnailLength(): Optional = thumbnailLength.getOptional("ThumbnailLength") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun thumbnailOffset(): Optional = thumbnailOffset.getOptional("ThumbnailOffset") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun xResolution(): Optional = xResolution.getOptional("XResolution") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun yResolution(): Optional = yResolution.getOptional("YResolution") + + /** + * Returns the raw JSON value of [compression]. + * + * Unlike [compression], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("Compression") + @ExcludeMissing + fun _compression(): JsonField = compression + + /** + * Returns the raw JSON value of [resolutionUnit]. + * + * Unlike [resolutionUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ResolutionUnit") + @ExcludeMissing + fun _resolutionUnit(): JsonField = resolutionUnit + + /** + * Returns the raw JSON value of [thumbnailLength]. + * + * Unlike [thumbnailLength], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ThumbnailLength") + @ExcludeMissing + fun _thumbnailLength(): JsonField = thumbnailLength + + /** + * Returns the raw JSON value of [thumbnailOffset]. + * + * Unlike [thumbnailOffset], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ThumbnailOffset") + @ExcludeMissing + fun _thumbnailOffset(): JsonField = thumbnailOffset + + /** + * Returns the raw JSON value of [xResolution]. + * + * Unlike [xResolution], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("XResolution") + @ExcludeMissing + fun _xResolution(): JsonField = xResolution + + /** + * Returns the raw JSON value of [yResolution]. + * + * Unlike [yResolution], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("YResolution") + @ExcludeMissing + fun _yResolution(): JsonField = yResolution + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Thumbnail]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Thumbnail]. */ + class Builder internal constructor() { + + private var compression: JsonField = JsonMissing.of() + private var resolutionUnit: JsonField = JsonMissing.of() + private var thumbnailLength: JsonField = JsonMissing.of() + private var thumbnailOffset: JsonField = JsonMissing.of() + private var xResolution: JsonField = JsonMissing.of() + private var yResolution: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(thumbnail: Thumbnail) = apply { + compression = thumbnail.compression + resolutionUnit = thumbnail.resolutionUnit + thumbnailLength = thumbnail.thumbnailLength + thumbnailOffset = thumbnail.thumbnailOffset + xResolution = thumbnail.xResolution + yResolution = thumbnail.yResolution + additionalProperties = thumbnail.additionalProperties.toMutableMap() + } + + fun compression(compression: Long) = compression(JsonField.of(compression)) + + /** + * Sets [Builder.compression] to an arbitrary JSON value. + * + * You should usually call [Builder.compression] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun compression(compression: JsonField) = apply { + this.compression = compression + } + + fun resolutionUnit(resolutionUnit: Long) = + resolutionUnit(JsonField.of(resolutionUnit)) + + /** + * Sets [Builder.resolutionUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.resolutionUnit] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun resolutionUnit(resolutionUnit: JsonField) = apply { + this.resolutionUnit = resolutionUnit + } + + fun thumbnailLength(thumbnailLength: Long) = + thumbnailLength(JsonField.of(thumbnailLength)) + + /** + * Sets [Builder.thumbnailLength] to an arbitrary JSON value. + * + * You should usually call [Builder.thumbnailLength] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun thumbnailLength(thumbnailLength: JsonField) = apply { + this.thumbnailLength = thumbnailLength + } + + fun thumbnailOffset(thumbnailOffset: Long) = + thumbnailOffset(JsonField.of(thumbnailOffset)) + + /** + * Sets [Builder.thumbnailOffset] to an arbitrary JSON value. + * + * You should usually call [Builder.thumbnailOffset] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun thumbnailOffset(thumbnailOffset: JsonField) = apply { + this.thumbnailOffset = thumbnailOffset + } + + fun xResolution(xResolution: Long) = xResolution(JsonField.of(xResolution)) + + /** + * Sets [Builder.xResolution] to an arbitrary JSON value. + * + * You should usually call [Builder.xResolution] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun xResolution(xResolution: JsonField) = apply { + this.xResolution = xResolution + } + + fun yResolution(yResolution: Long) = yResolution(JsonField.of(yResolution)) + + /** + * Sets [Builder.yResolution] to an arbitrary JSON value. + * + * You should usually call [Builder.yResolution] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun yResolution(yResolution: JsonField) = apply { + this.yResolution = yResolution + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Thumbnail]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Thumbnail = + Thumbnail( + compression, + resolutionUnit, + thumbnailLength, + thumbnailOffset, + xResolution, + yResolution, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Thumbnail = apply { + if (validated) { + return@apply + } + + compression() + resolutionUnit() + thumbnailLength() + thumbnailOffset() + xResolution() + yResolution() + 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 (compression.asKnown().isPresent) 1 else 0) + + (if (resolutionUnit.asKnown().isPresent) 1 else 0) + + (if (thumbnailLength.asKnown().isPresent) 1 else 0) + + (if (thumbnailOffset.asKnown().isPresent) 1 else 0) + + (if (xResolution.asKnown().isPresent) 1 else 0) + + (if (yResolution.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Thumbnail && + compression == other.compression && + resolutionUnit == other.resolutionUnit && + thumbnailLength == other.thumbnailLength && + thumbnailOffset == other.thumbnailOffset && + xResolution == other.xResolution && + yResolution == other.yResolution && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + compression, + resolutionUnit, + thumbnailLength, + thumbnailOffset, + xResolution, + yResolution, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Thumbnail{compression=$compression, resolutionUnit=$resolutionUnit, thumbnailLength=$thumbnailLength, thumbnailOffset=$thumbnailOffset, xResolution=$xResolution, yResolution=$yResolution, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Exif && + exif == other.exif && + gps == other.gps && + image == other.image && + interoperability == other.interoperability && + makernote == other.makernote && + thumbnail == other.thumbnail && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + exif, + gps, + image, + interoperability, + makernote, + thumbnail, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Exif{exif=$exif, gps=$gps, image=$image, interoperability=$interoperability, makernote=$makernote, thumbnail=$thumbnail, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + audioCodec == other.audioCodec && + bitRate == other.bitRate && + density == other.density && + duration == other.duration && + exif == other.exif && + format == other.format && + hasColorProfile == other.hasColorProfile && + hasTransparency == other.hasTransparency && + height == other.height && + pHash == other.pHash && + quality == other.quality && + size == other.size && + videoCodec == other.videoCodec && + width == other.width && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + audioCodec, + bitRate, + density, + duration, + exif, + format, + hasColorProfile, + hasTransparency, + height, + pHash, + quality, + size, + videoCodec, + width, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Metadata{audioCodec=$audioCodec, bitRate=$bitRate, density=$density, duration=$duration, exif=$exif, format=$format, hasColorProfile=$hasColorProfile, hasTransparency=$hasTransparency, height=$height, pHash=$pHash, quality=$quality, size=$size, videoCodec=$videoCodec, width=$width, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParams.kt new file mode 100644 index 00000000..c59c5207 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParams.kt @@ -0,0 +1,533 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.bulk + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * This API adds tags to multiple files in bulk. A maximum of 50 files can be specified at a time. + */ +class BulkAddTagsParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * An array of fileIds to which you want to add tags. + * + * @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 fileIds(): List = body.fileIds() + + /** + * An array of tags that you want to add to the files. + * + * @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 tags(): List = body.tags() + + /** + * Returns the raw JSON value of [fileIds]. + * + * Unlike [fileIds], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _fileIds(): JsonField> = body._fileIds() + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _tags(): JsonField> = body._tags() + + 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 [BulkAddTagsParams]. + * + * The following fields are required: + * ```java + * .fileIds() + * .tags() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkAddTagsParams]. */ + 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(bulkAddTagsParams: BulkAddTagsParams) = apply { + body = bulkAddTagsParams.body.toBuilder() + additionalHeaders = bulkAddTagsParams.additionalHeaders.toBuilder() + additionalQueryParams = bulkAddTagsParams.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: + * - [fileIds] + * - [tags] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** An array of fileIds to which you want to add tags. */ + fun fileIds(fileIds: List) = apply { body.fileIds(fileIds) } + + /** + * Sets [Builder.fileIds] to an arbitrary JSON value. + * + * You should usually call [Builder.fileIds] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun fileIds(fileIds: JsonField>) = apply { body.fileIds(fileIds) } + + /** + * Adds a single [String] to [fileIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFileId(fileId: String) = apply { body.addFileId(fileId) } + + /** An array of tags that you want to add to the files. */ + fun tags(tags: List) = apply { body.tags(tags) } + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: JsonField>) = apply { body.tags(tags) } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { body.addTag(tag) } + + 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 [BulkAddTagsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fileIds() + * .tags() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkAddTagsParams = + BulkAddTagsParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val fileIds: JsonField>, + private val tags: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("fileIds") + @ExcludeMissing + fileIds: JsonField> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), + ) : this(fileIds, tags, mutableMapOf()) + + /** + * An array of fileIds to which you want to add tags. + * + * @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 fileIds(): List = fileIds.getRequired("fileIds") + + /** + * An array of tags that you want to add to the files. + * + * @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 tags(): List = tags.getRequired("tags") + + /** + * Returns the raw JSON value of [fileIds]. + * + * Unlike [fileIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fileIds") @ExcludeMissing fun _fileIds(): JsonField> = fileIds + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @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 + * .fileIds() + * .tags() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var fileIds: JsonField>? = null + private var tags: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + fileIds = body.fileIds.map { it.toMutableList() } + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** An array of fileIds to which you want to add tags. */ + fun fileIds(fileIds: List) = fileIds(JsonField.of(fileIds)) + + /** + * Sets [Builder.fileIds] to an arbitrary JSON value. + * + * You should usually call [Builder.fileIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fileIds(fileIds: JsonField>) = apply { + this.fileIds = fileIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [fileIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFileId(fileId: String) = apply { + fileIds = + (fileIds ?: JsonField.of(mutableListOf())).also { + checkKnown("fileIds", it).add(fileId) + } + } + + /** An array of tags that you want to add to the files. */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .fileIds() + * .tags() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("fileIds", fileIds).map { it.toImmutable() }, + checkRequired("tags", tags).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + fileIds() + tags() + 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 = + (fileIds.asKnown().getOrNull()?.size ?: 0) + (tags.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + fileIds == other.fileIds && + tags == other.tags && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(fileIds, tags, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{fileIds=$fileIds, tags=$tags, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkAddTagsParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BulkAddTagsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponse.kt new file mode 100644 index 00000000..2cfbf744 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponse.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.bulk + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BulkAddTagsResponse +private constructor( + private val successfullyUpdatedFileIds: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("successfullyUpdatedFileIds") + @ExcludeMissing + successfullyUpdatedFileIds: JsonField> = JsonMissing.of() + ) : this(successfullyUpdatedFileIds, mutableMapOf()) + + /** + * An array of fileIds that in which tags were successfully added. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun successfullyUpdatedFileIds(): Optional> = + successfullyUpdatedFileIds.getOptional("successfullyUpdatedFileIds") + + /** + * Returns the raw JSON value of [successfullyUpdatedFileIds]. + * + * Unlike [successfullyUpdatedFileIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("successfullyUpdatedFileIds") + @ExcludeMissing + fun _successfullyUpdatedFileIds(): JsonField> = successfullyUpdatedFileIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [BulkAddTagsResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkAddTagsResponse]. */ + class Builder internal constructor() { + + private var successfullyUpdatedFileIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkAddTagsResponse: BulkAddTagsResponse) = apply { + successfullyUpdatedFileIds = + bulkAddTagsResponse.successfullyUpdatedFileIds.map { it.toMutableList() } + additionalProperties = bulkAddTagsResponse.additionalProperties.toMutableMap() + } + + /** An array of fileIds that in which tags were successfully added. */ + fun successfullyUpdatedFileIds(successfullyUpdatedFileIds: List) = + successfullyUpdatedFileIds(JsonField.of(successfullyUpdatedFileIds)) + + /** + * Sets [Builder.successfullyUpdatedFileIds] to an arbitrary JSON value. + * + * You should usually call [Builder.successfullyUpdatedFileIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun successfullyUpdatedFileIds(successfullyUpdatedFileIds: JsonField>) = + apply { + this.successfullyUpdatedFileIds = + successfullyUpdatedFileIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [successfullyUpdatedFileIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSuccessfullyUpdatedFileId(successfullyUpdatedFileId: String) = apply { + successfullyUpdatedFileIds = + (successfullyUpdatedFileIds ?: JsonField.of(mutableListOf())).also { + checkKnown("successfullyUpdatedFileIds", it).add(successfullyUpdatedFileId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkAddTagsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BulkAddTagsResponse = + BulkAddTagsResponse( + (successfullyUpdatedFileIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkAddTagsResponse = apply { + if (validated) { + return@apply + } + + successfullyUpdatedFileIds() + 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 = (successfullyUpdatedFileIds.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkAddTagsResponse && + successfullyUpdatedFileIds == other.successfullyUpdatedFileIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(successfullyUpdatedFileIds, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkAddTagsResponse{successfullyUpdatedFileIds=$successfullyUpdatedFileIds, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParams.kt new file mode 100644 index 00000000..e27e8f49 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParams.kt @@ -0,0 +1,447 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.bulk + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * This API deletes multiple files and all their file versions permanently. + * + * Note: If a file or specific transformation has been requested in the past, then the response is + * cached. Deleting a file does not purge the cache. You can purge the cache using purge cache API. + * + * A maximum of 100 files can be deleted at a time. + */ +class BulkDeleteParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * An array of fileIds which you want to delete. + * + * @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 fileIds(): List = body.fileIds() + + /** + * Returns the raw JSON value of [fileIds]. + * + * Unlike [fileIds], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _fileIds(): JsonField> = body._fileIds() + + 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 [BulkDeleteParams]. + * + * The following fields are required: + * ```java + * .fileIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkDeleteParams]. */ + 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(bulkDeleteParams: BulkDeleteParams) = apply { + body = bulkDeleteParams.body.toBuilder() + additionalHeaders = bulkDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = bulkDeleteParams.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: + * - [fileIds] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** An array of fileIds which you want to delete. */ + fun fileIds(fileIds: List) = apply { body.fileIds(fileIds) } + + /** + * Sets [Builder.fileIds] to an arbitrary JSON value. + * + * You should usually call [Builder.fileIds] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun fileIds(fileIds: JsonField>) = apply { body.fileIds(fileIds) } + + /** + * Adds a single [String] to [fileIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFileId(fileId: String) = apply { body.addFileId(fileId) } + + 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 [BulkDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fileIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkDeleteParams = + BulkDeleteParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val fileIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("fileIds") + @ExcludeMissing + fileIds: JsonField> = JsonMissing.of() + ) : this(fileIds, mutableMapOf()) + + /** + * An array of fileIds which you want to delete. + * + * @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 fileIds(): List = fileIds.getRequired("fileIds") + + /** + * Returns the raw JSON value of [fileIds]. + * + * Unlike [fileIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fileIds") @ExcludeMissing fun _fileIds(): JsonField> = fileIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @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 + * .fileIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var fileIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + fileIds = body.fileIds.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** An array of fileIds which you want to delete. */ + fun fileIds(fileIds: List) = fileIds(JsonField.of(fileIds)) + + /** + * Sets [Builder.fileIds] to an arbitrary JSON value. + * + * You should usually call [Builder.fileIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fileIds(fileIds: JsonField>) = apply { + this.fileIds = fileIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [fileIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFileId(fileId: String) = apply { + fileIds = + (fileIds ?: JsonField.of(mutableListOf())).also { + checkKnown("fileIds", it).add(fileId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .fileIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("fileIds", fileIds).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + fileIds() + 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 = (fileIds.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + fileIds == other.fileIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(fileIds, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{fileIds=$fileIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkDeleteParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BulkDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponse.kt new file mode 100644 index 00000000..10b9af28 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponse.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.bulk + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BulkDeleteResponse +private constructor( + private val successfullyDeletedFileIds: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("successfullyDeletedFileIds") + @ExcludeMissing + successfullyDeletedFileIds: JsonField> = JsonMissing.of() + ) : this(successfullyDeletedFileIds, mutableMapOf()) + + /** + * An array of fileIds that were successfully deleted. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun successfullyDeletedFileIds(): Optional> = + successfullyDeletedFileIds.getOptional("successfullyDeletedFileIds") + + /** + * Returns the raw JSON value of [successfullyDeletedFileIds]. + * + * Unlike [successfullyDeletedFileIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("successfullyDeletedFileIds") + @ExcludeMissing + fun _successfullyDeletedFileIds(): JsonField> = successfullyDeletedFileIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [BulkDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkDeleteResponse]. */ + class Builder internal constructor() { + + private var successfullyDeletedFileIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkDeleteResponse: BulkDeleteResponse) = apply { + successfullyDeletedFileIds = + bulkDeleteResponse.successfullyDeletedFileIds.map { it.toMutableList() } + additionalProperties = bulkDeleteResponse.additionalProperties.toMutableMap() + } + + /** An array of fileIds that were successfully deleted. */ + fun successfullyDeletedFileIds(successfullyDeletedFileIds: List) = + successfullyDeletedFileIds(JsonField.of(successfullyDeletedFileIds)) + + /** + * Sets [Builder.successfullyDeletedFileIds] to an arbitrary JSON value. + * + * You should usually call [Builder.successfullyDeletedFileIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun successfullyDeletedFileIds(successfullyDeletedFileIds: JsonField>) = + apply { + this.successfullyDeletedFileIds = + successfullyDeletedFileIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [successfullyDeletedFileIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSuccessfullyDeletedFileId(successfullyDeletedFileId: String) = apply { + successfullyDeletedFileIds = + (successfullyDeletedFileIds ?: JsonField.of(mutableListOf())).also { + checkKnown("successfullyDeletedFileIds", it).add(successfullyDeletedFileId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BulkDeleteResponse = + BulkDeleteResponse( + (successfullyDeletedFileIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkDeleteResponse = apply { + if (validated) { + return@apply + } + + successfullyDeletedFileIds() + 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 = (successfullyDeletedFileIds.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkDeleteResponse && + successfullyDeletedFileIds == other.successfullyDeletedFileIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(successfullyDeletedFileIds, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkDeleteResponse{successfullyDeletedFileIds=$successfullyDeletedFileIds, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParams.kt new file mode 100644 index 00000000..f22a019e --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParams.kt @@ -0,0 +1,538 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.bulk + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * This API removes AITags from multiple files in bulk. A maximum of 50 files can be specified at a + * time. + */ +class BulkRemoveAiTagsParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * An array of AITags that you want to remove from the files. + * + * @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 aiTags(): List = body.aiTags() + + /** + * An array of fileIds from which you want to remove AITags. + * + * @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 fileIds(): List = body.fileIds() + + /** + * Returns the raw JSON value of [aiTags]. + * + * Unlike [aiTags], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _aiTags(): JsonField> = body._aiTags() + + /** + * Returns the raw JSON value of [fileIds]. + * + * Unlike [fileIds], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _fileIds(): JsonField> = body._fileIds() + + 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 [BulkRemoveAiTagsParams]. + * + * The following fields are required: + * ```java + * .aiTags() + * .fileIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkRemoveAiTagsParams]. */ + 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(bulkRemoveAiTagsParams: BulkRemoveAiTagsParams) = apply { + body = bulkRemoveAiTagsParams.body.toBuilder() + additionalHeaders = bulkRemoveAiTagsParams.additionalHeaders.toBuilder() + additionalQueryParams = bulkRemoveAiTagsParams.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: + * - [aiTags] + * - [fileIds] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** An array of AITags that you want to remove from the files. */ + fun aiTags(aiTags: List) = apply { body.aiTags(aiTags) } + + /** + * Sets [Builder.aiTags] to an arbitrary JSON value. + * + * You should usually call [Builder.aiTags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun aiTags(aiTags: JsonField>) = apply { body.aiTags(aiTags) } + + /** + * Adds a single [String] to [aiTags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAiTag(aiTag: String) = apply { body.addAiTag(aiTag) } + + /** An array of fileIds from which you want to remove AITags. */ + fun fileIds(fileIds: List) = apply { body.fileIds(fileIds) } + + /** + * Sets [Builder.fileIds] to an arbitrary JSON value. + * + * You should usually call [Builder.fileIds] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun fileIds(fileIds: JsonField>) = apply { body.fileIds(fileIds) } + + /** + * Adds a single [String] to [fileIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFileId(fileId: String) = apply { body.addFileId(fileId) } + + 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 [BulkRemoveAiTagsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .aiTags() + * .fileIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkRemoveAiTagsParams = + BulkRemoveAiTagsParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val aiTags: JsonField>, + private val fileIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("AITags") + @ExcludeMissing + aiTags: JsonField> = JsonMissing.of(), + @JsonProperty("fileIds") + @ExcludeMissing + fileIds: JsonField> = JsonMissing.of(), + ) : this(aiTags, fileIds, mutableMapOf()) + + /** + * An array of AITags that you want to remove from the files. + * + * @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 aiTags(): List = aiTags.getRequired("AITags") + + /** + * An array of fileIds from which you want to remove AITags. + * + * @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 fileIds(): List = fileIds.getRequired("fileIds") + + /** + * Returns the raw JSON value of [aiTags]. + * + * Unlike [aiTags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("AITags") @ExcludeMissing fun _aiTags(): JsonField> = aiTags + + /** + * Returns the raw JSON value of [fileIds]. + * + * Unlike [fileIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fileIds") @ExcludeMissing fun _fileIds(): JsonField> = fileIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @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 + * .aiTags() + * .fileIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var aiTags: JsonField>? = null + private var fileIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + aiTags = body.aiTags.map { it.toMutableList() } + fileIds = body.fileIds.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** An array of AITags that you want to remove from the files. */ + fun aiTags(aiTags: List) = aiTags(JsonField.of(aiTags)) + + /** + * Sets [Builder.aiTags] to an arbitrary JSON value. + * + * You should usually call [Builder.aiTags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun aiTags(aiTags: JsonField>) = apply { + this.aiTags = aiTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [aiTags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAiTag(aiTag: String) = apply { + aiTags = + (aiTags ?: JsonField.of(mutableListOf())).also { + checkKnown("aiTags", it).add(aiTag) + } + } + + /** An array of fileIds from which you want to remove AITags. */ + fun fileIds(fileIds: List) = fileIds(JsonField.of(fileIds)) + + /** + * Sets [Builder.fileIds] to an arbitrary JSON value. + * + * You should usually call [Builder.fileIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fileIds(fileIds: JsonField>) = apply { + this.fileIds = fileIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [fileIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFileId(fileId: String) = apply { + fileIds = + (fileIds ?: JsonField.of(mutableListOf())).also { + checkKnown("fileIds", it).add(fileId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .aiTags() + * .fileIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("aiTags", aiTags).map { it.toImmutable() }, + checkRequired("fileIds", fileIds).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + aiTags() + fileIds() + 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 = + (aiTags.asKnown().getOrNull()?.size ?: 0) + (fileIds.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + aiTags == other.aiTags && + fileIds == other.fileIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(aiTags, fileIds, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{aiTags=$aiTags, fileIds=$fileIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkRemoveAiTagsParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BulkRemoveAiTagsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponse.kt new file mode 100644 index 00000000..9d467351 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponse.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.bulk + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BulkRemoveAiTagsResponse +private constructor( + private val successfullyUpdatedFileIds: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("successfullyUpdatedFileIds") + @ExcludeMissing + successfullyUpdatedFileIds: JsonField> = JsonMissing.of() + ) : this(successfullyUpdatedFileIds, mutableMapOf()) + + /** + * An array of fileIds that in which AITags were successfully removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun successfullyUpdatedFileIds(): Optional> = + successfullyUpdatedFileIds.getOptional("successfullyUpdatedFileIds") + + /** + * Returns the raw JSON value of [successfullyUpdatedFileIds]. + * + * Unlike [successfullyUpdatedFileIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("successfullyUpdatedFileIds") + @ExcludeMissing + fun _successfullyUpdatedFileIds(): JsonField> = successfullyUpdatedFileIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [BulkRemoveAiTagsResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkRemoveAiTagsResponse]. */ + class Builder internal constructor() { + + private var successfullyUpdatedFileIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkRemoveAiTagsResponse: BulkRemoveAiTagsResponse) = apply { + successfullyUpdatedFileIds = + bulkRemoveAiTagsResponse.successfullyUpdatedFileIds.map { it.toMutableList() } + additionalProperties = bulkRemoveAiTagsResponse.additionalProperties.toMutableMap() + } + + /** An array of fileIds that in which AITags were successfully removed. */ + fun successfullyUpdatedFileIds(successfullyUpdatedFileIds: List) = + successfullyUpdatedFileIds(JsonField.of(successfullyUpdatedFileIds)) + + /** + * Sets [Builder.successfullyUpdatedFileIds] to an arbitrary JSON value. + * + * You should usually call [Builder.successfullyUpdatedFileIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun successfullyUpdatedFileIds(successfullyUpdatedFileIds: JsonField>) = + apply { + this.successfullyUpdatedFileIds = + successfullyUpdatedFileIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [successfullyUpdatedFileIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSuccessfullyUpdatedFileId(successfullyUpdatedFileId: String) = apply { + successfullyUpdatedFileIds = + (successfullyUpdatedFileIds ?: JsonField.of(mutableListOf())).also { + checkKnown("successfullyUpdatedFileIds", it).add(successfullyUpdatedFileId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkRemoveAiTagsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BulkRemoveAiTagsResponse = + BulkRemoveAiTagsResponse( + (successfullyUpdatedFileIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkRemoveAiTagsResponse = apply { + if (validated) { + return@apply + } + + successfullyUpdatedFileIds() + 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 = (successfullyUpdatedFileIds.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkRemoveAiTagsResponse && + successfullyUpdatedFileIds == other.successfullyUpdatedFileIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(successfullyUpdatedFileIds, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkRemoveAiTagsResponse{successfullyUpdatedFileIds=$successfullyUpdatedFileIds, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParams.kt new file mode 100644 index 00000000..f72a4520 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParams.kt @@ -0,0 +1,534 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.bulk + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * This API removes tags from multiple files in bulk. A maximum of 50 files can be specified at a + * time. + */ +class BulkRemoveTagsParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * An array of fileIds from which you want to remove tags. + * + * @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 fileIds(): List = body.fileIds() + + /** + * An array of tags that you want to remove from the files. + * + * @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 tags(): List = body.tags() + + /** + * Returns the raw JSON value of [fileIds]. + * + * Unlike [fileIds], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _fileIds(): JsonField> = body._fileIds() + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _tags(): JsonField> = body._tags() + + 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 [BulkRemoveTagsParams]. + * + * The following fields are required: + * ```java + * .fileIds() + * .tags() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkRemoveTagsParams]. */ + 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(bulkRemoveTagsParams: BulkRemoveTagsParams) = apply { + body = bulkRemoveTagsParams.body.toBuilder() + additionalHeaders = bulkRemoveTagsParams.additionalHeaders.toBuilder() + additionalQueryParams = bulkRemoveTagsParams.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: + * - [fileIds] + * - [tags] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** An array of fileIds from which you want to remove tags. */ + fun fileIds(fileIds: List) = apply { body.fileIds(fileIds) } + + /** + * Sets [Builder.fileIds] to an arbitrary JSON value. + * + * You should usually call [Builder.fileIds] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun fileIds(fileIds: JsonField>) = apply { body.fileIds(fileIds) } + + /** + * Adds a single [String] to [fileIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFileId(fileId: String) = apply { body.addFileId(fileId) } + + /** An array of tags that you want to remove from the files. */ + fun tags(tags: List) = apply { body.tags(tags) } + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: JsonField>) = apply { body.tags(tags) } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { body.addTag(tag) } + + 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 [BulkRemoveTagsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fileIds() + * .tags() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkRemoveTagsParams = + BulkRemoveTagsParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val fileIds: JsonField>, + private val tags: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("fileIds") + @ExcludeMissing + fileIds: JsonField> = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), + ) : this(fileIds, tags, mutableMapOf()) + + /** + * An array of fileIds from which you want to remove tags. + * + * @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 fileIds(): List = fileIds.getRequired("fileIds") + + /** + * An array of tags that you want to remove from the files. + * + * @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 tags(): List = tags.getRequired("tags") + + /** + * Returns the raw JSON value of [fileIds]. + * + * Unlike [fileIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fileIds") @ExcludeMissing fun _fileIds(): JsonField> = fileIds + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @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 + * .fileIds() + * .tags() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var fileIds: JsonField>? = null + private var tags: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + fileIds = body.fileIds.map { it.toMutableList() } + tags = body.tags.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** An array of fileIds from which you want to remove tags. */ + fun fileIds(fileIds: List) = fileIds(JsonField.of(fileIds)) + + /** + * Sets [Builder.fileIds] to an arbitrary JSON value. + * + * You should usually call [Builder.fileIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fileIds(fileIds: JsonField>) = apply { + this.fileIds = fileIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [fileIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFileId(fileId: String) = apply { + fileIds = + (fileIds ?: JsonField.of(mutableListOf())).also { + checkKnown("fileIds", it).add(fileId) + } + } + + /** An array of tags that you want to remove from the files. */ + fun tags(tags: List) = tags(JsonField.of(tags)) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .fileIds() + * .tags() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("fileIds", fileIds).map { it.toImmutable() }, + checkRequired("tags", tags).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + fileIds() + tags() + 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 = + (fileIds.asKnown().getOrNull()?.size ?: 0) + (tags.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + fileIds == other.fileIds && + tags == other.tags && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(fileIds, tags, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{fileIds=$fileIds, tags=$tags, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkRemoveTagsParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BulkRemoveTagsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponse.kt new file mode 100644 index 00000000..0a23ecda --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponse.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.bulk + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BulkRemoveTagsResponse +private constructor( + private val successfullyUpdatedFileIds: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("successfullyUpdatedFileIds") + @ExcludeMissing + successfullyUpdatedFileIds: JsonField> = JsonMissing.of() + ) : this(successfullyUpdatedFileIds, mutableMapOf()) + + /** + * An array of fileIds that in which tags were successfully removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun successfullyUpdatedFileIds(): Optional> = + successfullyUpdatedFileIds.getOptional("successfullyUpdatedFileIds") + + /** + * Returns the raw JSON value of [successfullyUpdatedFileIds]. + * + * Unlike [successfullyUpdatedFileIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("successfullyUpdatedFileIds") + @ExcludeMissing + fun _successfullyUpdatedFileIds(): JsonField> = successfullyUpdatedFileIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [BulkRemoveTagsResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkRemoveTagsResponse]. */ + class Builder internal constructor() { + + private var successfullyUpdatedFileIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkRemoveTagsResponse: BulkRemoveTagsResponse) = apply { + successfullyUpdatedFileIds = + bulkRemoveTagsResponse.successfullyUpdatedFileIds.map { it.toMutableList() } + additionalProperties = bulkRemoveTagsResponse.additionalProperties.toMutableMap() + } + + /** An array of fileIds that in which tags were successfully removed. */ + fun successfullyUpdatedFileIds(successfullyUpdatedFileIds: List) = + successfullyUpdatedFileIds(JsonField.of(successfullyUpdatedFileIds)) + + /** + * Sets [Builder.successfullyUpdatedFileIds] to an arbitrary JSON value. + * + * You should usually call [Builder.successfullyUpdatedFileIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun successfullyUpdatedFileIds(successfullyUpdatedFileIds: JsonField>) = + apply { + this.successfullyUpdatedFileIds = + successfullyUpdatedFileIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [successfullyUpdatedFileIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSuccessfullyUpdatedFileId(successfullyUpdatedFileId: String) = apply { + successfullyUpdatedFileIds = + (successfullyUpdatedFileIds ?: JsonField.of(mutableListOf())).also { + checkKnown("successfullyUpdatedFileIds", it).add(successfullyUpdatedFileId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkRemoveTagsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BulkRemoveTagsResponse = + BulkRemoveTagsResponse( + (successfullyUpdatedFileIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkRemoveTagsResponse = apply { + if (validated) { + return@apply + } + + successfullyUpdatedFileIds() + 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 = (successfullyUpdatedFileIds.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkRemoveTagsResponse && + successfullyUpdatedFileIds == other.successfullyUpdatedFileIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(successfullyUpdatedFileIds, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkRemoveTagsResponse{successfullyUpdatedFileIds=$successfullyUpdatedFileIds, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlParams.kt new file mode 100644 index 00000000..a5131a3d --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlParams.kt @@ -0,0 +1,203 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.metadata + +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import java.util.Objects + +/** Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API. */ +class MetadataGetFromUrlParams +private constructor( + private val url: String, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Should be a valid file URL. It should be accessible using your ImageKit.io account. */ + fun url(): String = url + + /** 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 [MetadataGetFromUrlParams]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetadataGetFromUrlParams]. */ + class Builder internal constructor() { + + private var url: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(metadataGetFromUrlParams: MetadataGetFromUrlParams) = apply { + url = metadataGetFromUrlParams.url + additionalHeaders = metadataGetFromUrlParams.additionalHeaders.toBuilder() + additionalQueryParams = metadataGetFromUrlParams.additionalQueryParams.toBuilder() + } + + /** Should be a valid file URL. It should be accessible using your ImageKit.io account. */ + fun url(url: String) = apply { this.url = url } + + 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 [MetadataGetFromUrlParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MetadataGetFromUrlParams = + MetadataGetFromUrlParams( + checkRequired("url", url), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("url", url) + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetadataGetFromUrlParams && + url == other.url && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(url, additionalHeaders, additionalQueryParams) + + override fun toString() = + "MetadataGetFromUrlParams{url=$url, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetParams.kt new file mode 100644 index 00000000..cab27ba0 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetParams.kt @@ -0,0 +1,195 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.metadata + +import com.imagekit.api.core.Params +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * You can programmatically get image EXIF, pHash, and other metadata for uploaded files in the + * ImageKit.io media library using this API. + * + * You can also get the metadata in upload API response by passing `metadata` in `responseFields` + * parameter. + */ +class MetadataGetParams +private constructor( + private val fileId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun fileId(): Optional = Optional.ofNullable(fileId) + + /** 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(): MetadataGetParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [MetadataGetParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MetadataGetParams]. */ + class Builder internal constructor() { + + private var fileId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(metadataGetParams: MetadataGetParams) = apply { + fileId = metadataGetParams.fileId + additionalHeaders = metadataGetParams.additionalHeaders.toBuilder() + additionalQueryParams = metadataGetParams.additionalQueryParams.toBuilder() + } + + fun fileId(fileId: String?) = apply { this.fileId = fileId } + + /** Alias for calling [Builder.fileId] with `fileId.orElse(null)`. */ + fun fileId(fileId: Optional) = fileId(fileId.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 [MetadataGetParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MetadataGetParams = + MetadataGetParams(fileId, additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> fileId ?: "" + 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 MetadataGetParams && + fileId == other.fileId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(fileId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "MetadataGetParams{fileId=$fileId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionDeleteParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionDeleteParams.kt new file mode 100644 index 00000000..f43c5223 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionDeleteParams.kt @@ -0,0 +1,262 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.versions + +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * This API deletes a non-current file version permanently. The API returns an empty response. + * + * Note: If you want to delete all versions of a file, use the delete file API. + */ +class VersionDeleteParams +private constructor( + private val fileId: String, + private val versionId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun fileId(): String = fileId + + fun versionId(): Optional = Optional.ofNullable(versionId) + + /** 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 { + + /** + * Returns a mutable builder for constructing an instance of [VersionDeleteParams]. + * + * The following fields are required: + * ```java + * .fileId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VersionDeleteParams]. */ + class Builder internal constructor() { + + private var fileId: String? = null + private var versionId: 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(versionDeleteParams: VersionDeleteParams) = apply { + fileId = versionDeleteParams.fileId + versionId = versionDeleteParams.versionId + additionalHeaders = versionDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = versionDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = versionDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun fileId(fileId: String) = apply { this.fileId = fileId } + + fun versionId(versionId: String?) = apply { this.versionId = versionId } + + /** Alias for calling [Builder.versionId] with `versionId.orElse(null)`. */ + fun versionId(versionId: Optional) = versionId(versionId.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 [VersionDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fileId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VersionDeleteParams = + VersionDeleteParams( + checkRequired("fileId", fileId), + versionId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> fileId + 1 -> versionId ?: "" + 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 VersionDeleteParams && + fileId == other.fileId && + versionId == other.versionId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + fileId, + versionId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "VersionDeleteParams{fileId=$fileId, versionId=$versionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionDeleteResponse.kt new file mode 100644 index 00000000..1b41f618 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionDeleteResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.versions + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects + +class VersionDeleteResponse +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [VersionDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VersionDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(versionDeleteResponse: VersionDeleteResponse) = apply { + additionalProperties = versionDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [VersionDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VersionDeleteResponse = + VersionDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): VersionDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VersionDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "VersionDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetParams.kt new file mode 100644 index 00000000..fd71f44e --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetParams.kt @@ -0,0 +1,217 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.versions + +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** This API returns an object with details or attributes of a file version. */ +class VersionGetParams +private constructor( + private val fileId: String, + private val versionId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun fileId(): String = fileId + + fun versionId(): Optional = Optional.ofNullable(versionId) + + /** 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 [VersionGetParams]. + * + * The following fields are required: + * ```java + * .fileId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VersionGetParams]. */ + class Builder internal constructor() { + + private var fileId: String? = null + private var versionId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(versionGetParams: VersionGetParams) = apply { + fileId = versionGetParams.fileId + versionId = versionGetParams.versionId + additionalHeaders = versionGetParams.additionalHeaders.toBuilder() + additionalQueryParams = versionGetParams.additionalQueryParams.toBuilder() + } + + fun fileId(fileId: String) = apply { this.fileId = fileId } + + fun versionId(versionId: String?) = apply { this.versionId = versionId } + + /** Alias for calling [Builder.versionId] with `versionId.orElse(null)`. */ + fun versionId(versionId: Optional) = versionId(versionId.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 [VersionGetParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fileId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VersionGetParams = + VersionGetParams( + checkRequired("fileId", fileId), + versionId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> fileId + 1 -> versionId ?: "" + 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 VersionGetParams && + fileId == other.fileId && + versionId == other.versionId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(fileId, versionId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "VersionGetParams{fileId=$fileId, versionId=$versionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionListParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionListParams.kt new file mode 100644 index 00000000..92b5d691 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionListParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.versions + +import com.imagekit.api.core.Params +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** This API returns details of all versions of a file. */ +class VersionListParams +private constructor( + private val fileId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun fileId(): Optional = Optional.ofNullable(fileId) + + /** 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(): VersionListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [VersionListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VersionListParams]. */ + class Builder internal constructor() { + + private var fileId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(versionListParams: VersionListParams) = apply { + fileId = versionListParams.fileId + additionalHeaders = versionListParams.additionalHeaders.toBuilder() + additionalQueryParams = versionListParams.additionalQueryParams.toBuilder() + } + + fun fileId(fileId: String?) = apply { this.fileId = fileId } + + /** Alias for calling [Builder.fileId] with `fileId.orElse(null)`. */ + fun fileId(fileId: Optional) = fileId(fileId.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 [VersionListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VersionListParams = + VersionListParams(fileId, additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> fileId ?: "" + 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 VersionListParams && + fileId == other.fileId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(fileId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "VersionListParams{fileId=$fileId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRestoreParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRestoreParams.kt new file mode 100644 index 00000000..6edc115f --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRestoreParams.kt @@ -0,0 +1,258 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.versions + +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** This API restores a file version as the current file version. */ +class VersionRestoreParams +private constructor( + private val fileId: String, + private val versionId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun fileId(): String = fileId + + fun versionId(): Optional = Optional.ofNullable(versionId) + + /** 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 { + + /** + * Returns a mutable builder for constructing an instance of [VersionRestoreParams]. + * + * The following fields are required: + * ```java + * .fileId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VersionRestoreParams]. */ + class Builder internal constructor() { + + private var fileId: String? = null + private var versionId: 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(versionRestoreParams: VersionRestoreParams) = apply { + fileId = versionRestoreParams.fileId + versionId = versionRestoreParams.versionId + additionalHeaders = versionRestoreParams.additionalHeaders.toBuilder() + additionalQueryParams = versionRestoreParams.additionalQueryParams.toBuilder() + additionalBodyProperties = versionRestoreParams.additionalBodyProperties.toMutableMap() + } + + fun fileId(fileId: String) = apply { this.fileId = fileId } + + fun versionId(versionId: String?) = apply { this.versionId = versionId } + + /** Alias for calling [Builder.versionId] with `versionId.orElse(null)`. */ + fun versionId(versionId: Optional) = versionId(versionId.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 [VersionRestoreParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fileId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VersionRestoreParams = + VersionRestoreParams( + checkRequired("fileId", fileId), + versionId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> fileId + 1 -> versionId ?: "" + 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 VersionRestoreParams && + fileId == other.fileId && + versionId == other.versionId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + fileId, + versionId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "VersionRestoreParams{fileId=$fileId, versionId=$versionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyParams.kt new file mode 100644 index 00000000..92cb7933 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyParams.kt @@ -0,0 +1,605 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * This will copy one folder into another. The selected folder, its nested folders, files, and their + * versions (in `includeVersions` is set to true) are copied in this operation. Note: If any file at + * the destination has the same name as the source file, then the source file and its versions will + * be appended to the destination file version history. + */ +class FolderCopyParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Full path to the destination folder where you want to copy the source folder into. + * + * @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 destinationPath(): String = body.destinationPath() + + /** + * The full path to the source folder you want to copy. + * + * @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 sourceFolderPath(): String = body.sourceFolderPath() + + /** + * Option to copy all versions of files that are nested inside the selected folder. By default, + * only the current version of each file will be copied. When set to true, all versions of each + * file will be copied. Default value - `false`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun includeVersions(): Optional = body.includeVersions() + + /** + * Returns the raw JSON value of [destinationPath]. + * + * Unlike [destinationPath], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _destinationPath(): JsonField = body._destinationPath() + + /** + * Returns the raw JSON value of [sourceFolderPath]. + * + * Unlike [sourceFolderPath], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _sourceFolderPath(): JsonField = body._sourceFolderPath() + + /** + * Returns the raw JSON value of [includeVersions]. + * + * Unlike [includeVersions], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _includeVersions(): JsonField = body._includeVersions() + + 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 [FolderCopyParams]. + * + * The following fields are required: + * ```java + * .destinationPath() + * .sourceFolderPath() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FolderCopyParams]. */ + 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(folderCopyParams: FolderCopyParams) = apply { + body = folderCopyParams.body.toBuilder() + additionalHeaders = folderCopyParams.additionalHeaders.toBuilder() + additionalQueryParams = folderCopyParams.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: + * - [destinationPath] + * - [sourceFolderPath] + * - [includeVersions] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Full path to the destination folder where you want to copy the source folder into. */ + fun destinationPath(destinationPath: String) = apply { + body.destinationPath(destinationPath) + } + + /** + * Sets [Builder.destinationPath] to an arbitrary JSON value. + * + * You should usually call [Builder.destinationPath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun destinationPath(destinationPath: JsonField) = apply { + body.destinationPath(destinationPath) + } + + /** The full path to the source folder you want to copy. */ + fun sourceFolderPath(sourceFolderPath: String) = apply { + body.sourceFolderPath(sourceFolderPath) + } + + /** + * Sets [Builder.sourceFolderPath] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceFolderPath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceFolderPath(sourceFolderPath: JsonField) = apply { + body.sourceFolderPath(sourceFolderPath) + } + + /** + * Option to copy all versions of files that are nested inside the selected folder. By + * default, only the current version of each file will be copied. When set to true, all + * versions of each file will be copied. Default value - `false`. + */ + fun includeVersions(includeVersions: Boolean) = apply { + body.includeVersions(includeVersions) + } + + /** + * Sets [Builder.includeVersions] to an arbitrary JSON value. + * + * You should usually call [Builder.includeVersions] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun includeVersions(includeVersions: JsonField) = apply { + body.includeVersions(includeVersions) + } + + 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 [FolderCopyParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .destinationPath() + * .sourceFolderPath() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FolderCopyParams = + FolderCopyParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val destinationPath: JsonField, + private val sourceFolderPath: JsonField, + private val includeVersions: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("destinationPath") + @ExcludeMissing + destinationPath: JsonField = JsonMissing.of(), + @JsonProperty("sourceFolderPath") + @ExcludeMissing + sourceFolderPath: JsonField = JsonMissing.of(), + @JsonProperty("includeVersions") + @ExcludeMissing + includeVersions: JsonField = JsonMissing.of(), + ) : this(destinationPath, sourceFolderPath, includeVersions, mutableMapOf()) + + /** + * Full path to the destination folder where you want to copy the source folder into. + * + * @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 destinationPath(): String = destinationPath.getRequired("destinationPath") + + /** + * The full path to the source folder you want to copy. + * + * @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 sourceFolderPath(): String = sourceFolderPath.getRequired("sourceFolderPath") + + /** + * Option to copy all versions of files that are nested inside the selected folder. By + * default, only the current version of each file will be copied. When set to true, all + * versions of each file will be copied. Default value - `false`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun includeVersions(): Optional = includeVersions.getOptional("includeVersions") + + /** + * Returns the raw JSON value of [destinationPath]. + * + * Unlike [destinationPath], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("destinationPath") + @ExcludeMissing + fun _destinationPath(): JsonField = destinationPath + + /** + * Returns the raw JSON value of [sourceFolderPath]. + * + * Unlike [sourceFolderPath], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sourceFolderPath") + @ExcludeMissing + fun _sourceFolderPath(): JsonField = sourceFolderPath + + /** + * Returns the raw JSON value of [includeVersions]. + * + * Unlike [includeVersions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("includeVersions") + @ExcludeMissing + fun _includeVersions(): JsonField = includeVersions + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @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 + * .destinationPath() + * .sourceFolderPath() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var destinationPath: JsonField? = null + private var sourceFolderPath: JsonField? = null + private var includeVersions: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + destinationPath = body.destinationPath + sourceFolderPath = body.sourceFolderPath + includeVersions = body.includeVersions + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * Full path to the destination folder where you want to copy the source folder into. + */ + fun destinationPath(destinationPath: String) = + destinationPath(JsonField.of(destinationPath)) + + /** + * Sets [Builder.destinationPath] to an arbitrary JSON value. + * + * You should usually call [Builder.destinationPath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun destinationPath(destinationPath: JsonField) = apply { + this.destinationPath = destinationPath + } + + /** The full path to the source folder you want to copy. */ + fun sourceFolderPath(sourceFolderPath: String) = + sourceFolderPath(JsonField.of(sourceFolderPath)) + + /** + * Sets [Builder.sourceFolderPath] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceFolderPath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceFolderPath(sourceFolderPath: JsonField) = apply { + this.sourceFolderPath = sourceFolderPath + } + + /** + * Option to copy all versions of files that are nested inside the selected folder. By + * default, only the current version of each file will be copied. When set to true, all + * versions of each file will be copied. Default value - `false`. + */ + fun includeVersions(includeVersions: Boolean) = + includeVersions(JsonField.of(includeVersions)) + + /** + * Sets [Builder.includeVersions] to an arbitrary JSON value. + * + * You should usually call [Builder.includeVersions] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun includeVersions(includeVersions: JsonField) = apply { + this.includeVersions = includeVersions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .destinationPath() + * .sourceFolderPath() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("destinationPath", destinationPath), + checkRequired("sourceFolderPath", sourceFolderPath), + includeVersions, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + destinationPath() + sourceFolderPath() + includeVersions() + 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 (destinationPath.asKnown().isPresent) 1 else 0) + + (if (sourceFolderPath.asKnown().isPresent) 1 else 0) + + (if (includeVersions.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + destinationPath == other.destinationPath && + sourceFolderPath == other.sourceFolderPath && + includeVersions == other.includeVersions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(destinationPath, sourceFolderPath, includeVersions, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{destinationPath=$destinationPath, sourceFolderPath=$sourceFolderPath, includeVersions=$includeVersions, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FolderCopyParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FolderCopyParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyResponse.kt new file mode 100644 index 00000000..3373e268 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyResponse.kt @@ -0,0 +1,172 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Job submitted successfully. A `jobId` will be returned. */ +class FolderCopyResponse +private constructor( + private val jobId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("jobId") @ExcludeMissing jobId: JsonField = JsonMissing.of() + ) : this(jobId, mutableMapOf()) + + /** + * Unique identifier of the bulk job. This can be used to check the status of the bulk job. + * + * @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 jobId(): String = jobId.getRequired("jobId") + + /** + * Returns the raw JSON value of [jobId]. + * + * Unlike [jobId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("jobId") @ExcludeMissing fun _jobId(): JsonField = jobId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FolderCopyResponse]. + * + * The following fields are required: + * ```java + * .jobId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FolderCopyResponse]. */ + class Builder internal constructor() { + + private var jobId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(folderCopyResponse: FolderCopyResponse) = apply { + jobId = folderCopyResponse.jobId + additionalProperties = folderCopyResponse.additionalProperties.toMutableMap() + } + + /** + * Unique identifier of the bulk job. This can be used to check the status of the bulk job. + */ + fun jobId(jobId: String) = jobId(JsonField.of(jobId)) + + /** + * Sets [Builder.jobId] to an arbitrary JSON value. + * + * You should usually call [Builder.jobId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun jobId(jobId: JsonField) = apply { this.jobId = jobId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FolderCopyResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .jobId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FolderCopyResponse = + FolderCopyResponse(checkRequired("jobId", jobId), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): FolderCopyResponse = apply { + if (validated) { + return@apply + } + + jobId() + 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 (jobId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FolderCopyResponse && + jobId == other.jobId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(jobId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FolderCopyResponse{jobId=$jobId, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateParams.kt new file mode 100644 index 00000000..3976d1ed --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateParams.kt @@ -0,0 +1,550 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects + +/** + * This will create a new folder. You can specify the folder name and location of the parent folder + * where this new folder should be created. + */ +class FolderCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The folder will be created with this name. + * + * All characters except alphabets and numbers (inclusive of unicode letters, marks, and + * numerals in other languages) will be replaced by an underscore i.e. `_`. + * + * @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 folderName(): String = body.folderName() + + /** + * The folder where the new folder should be created, for root use `/` else the path e.g. + * `containing/folder/`. + * + * Note: If any folder(s) is not present in the parentFolderPath parameter, it will be + * automatically created. For example, if you pass `/product/images/summer`, then `product`, + * `images`, and `summer` folders will be created if they don't already exist. + * + * @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 parentFolderPath(): String = body.parentFolderPath() + + /** + * Returns the raw JSON value of [folderName]. + * + * Unlike [folderName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _folderName(): JsonField = body._folderName() + + /** + * Returns the raw JSON value of [parentFolderPath]. + * + * Unlike [parentFolderPath], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _parentFolderPath(): JsonField = body._parentFolderPath() + + 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 [FolderCreateParams]. + * + * The following fields are required: + * ```java + * .folderName() + * .parentFolderPath() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FolderCreateParams]. */ + 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(folderCreateParams: FolderCreateParams) = apply { + body = folderCreateParams.body.toBuilder() + additionalHeaders = folderCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = folderCreateParams.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: + * - [folderName] + * - [parentFolderPath] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * The folder will be created with this name. + * + * All characters except alphabets and numbers (inclusive of unicode letters, marks, and + * numerals in other languages) will be replaced by an underscore i.e. `_`. + */ + fun folderName(folderName: String) = apply { body.folderName(folderName) } + + /** + * Sets [Builder.folderName] to an arbitrary JSON value. + * + * You should usually call [Builder.folderName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun folderName(folderName: JsonField) = apply { body.folderName(folderName) } + + /** + * The folder where the new folder should be created, for root use `/` else the path e.g. + * `containing/folder/`. + * + * Note: If any folder(s) is not present in the parentFolderPath parameter, it will be + * automatically created. For example, if you pass `/product/images/summer`, then `product`, + * `images`, and `summer` folders will be created if they don't already exist. + */ + fun parentFolderPath(parentFolderPath: String) = apply { + body.parentFolderPath(parentFolderPath) + } + + /** + * Sets [Builder.parentFolderPath] to an arbitrary JSON value. + * + * You should usually call [Builder.parentFolderPath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parentFolderPath(parentFolderPath: JsonField) = apply { + body.parentFolderPath(parentFolderPath) + } + + 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 [FolderCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .folderName() + * .parentFolderPath() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FolderCreateParams = + FolderCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val folderName: JsonField, + private val parentFolderPath: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("folderName") + @ExcludeMissing + folderName: JsonField = JsonMissing.of(), + @JsonProperty("parentFolderPath") + @ExcludeMissing + parentFolderPath: JsonField = JsonMissing.of(), + ) : this(folderName, parentFolderPath, mutableMapOf()) + + /** + * The folder will be created with this name. + * + * All characters except alphabets and numbers (inclusive of unicode letters, marks, and + * numerals in other languages) will be replaced by an underscore i.e. `_`. + * + * @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 folderName(): String = folderName.getRequired("folderName") + + /** + * The folder where the new folder should be created, for root use `/` else the path e.g. + * `containing/folder/`. + * + * Note: If any folder(s) is not present in the parentFolderPath parameter, it will be + * automatically created. For example, if you pass `/product/images/summer`, then `product`, + * `images`, and `summer` folders will be created if they don't already exist. + * + * @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 parentFolderPath(): String = parentFolderPath.getRequired("parentFolderPath") + + /** + * Returns the raw JSON value of [folderName]. + * + * Unlike [folderName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("folderName") + @ExcludeMissing + fun _folderName(): JsonField = folderName + + /** + * Returns the raw JSON value of [parentFolderPath]. + * + * Unlike [parentFolderPath], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("parentFolderPath") + @ExcludeMissing + fun _parentFolderPath(): JsonField = parentFolderPath + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @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 + * .folderName() + * .parentFolderPath() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var folderName: JsonField? = null + private var parentFolderPath: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + folderName = body.folderName + parentFolderPath = body.parentFolderPath + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * The folder will be created with this name. + * + * All characters except alphabets and numbers (inclusive of unicode letters, marks, and + * numerals in other languages) will be replaced by an underscore i.e. `_`. + */ + fun folderName(folderName: String) = folderName(JsonField.of(folderName)) + + /** + * Sets [Builder.folderName] to an arbitrary JSON value. + * + * You should usually call [Builder.folderName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun folderName(folderName: JsonField) = apply { this.folderName = folderName } + + /** + * The folder where the new folder should be created, for root use `/` else the path + * e.g. `containing/folder/`. + * + * Note: If any folder(s) is not present in the parentFolderPath parameter, it will be + * automatically created. For example, if you pass `/product/images/summer`, then + * `product`, `images`, and `summer` folders will be created if they don't already + * exist. + */ + fun parentFolderPath(parentFolderPath: String) = + parentFolderPath(JsonField.of(parentFolderPath)) + + /** + * Sets [Builder.parentFolderPath] to an arbitrary JSON value. + * + * You should usually call [Builder.parentFolderPath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parentFolderPath(parentFolderPath: JsonField) = apply { + this.parentFolderPath = parentFolderPath + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .folderName() + * .parentFolderPath() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("folderName", folderName), + checkRequired("parentFolderPath", parentFolderPath), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + folderName() + parentFolderPath() + 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 (folderName.asKnown().isPresent) 1 else 0) + + (if (parentFolderPath.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + folderName == other.folderName && + parentFolderPath == other.parentFolderPath && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(folderName, parentFolderPath, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{folderName=$folderName, parentFolderPath=$parentFolderPath, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FolderCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FolderCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateResponse.kt new file mode 100644 index 00000000..ca1aebd1 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects + +class FolderCreateResponse +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FolderCreateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FolderCreateResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(folderCreateResponse: FolderCreateResponse) = apply { + additionalProperties = folderCreateResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FolderCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FolderCreateResponse = + FolderCreateResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): FolderCreateResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FolderCreateResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "FolderCreateResponse{additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteParams.kt new file mode 100644 index 00000000..0cdc8516 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteParams.kt @@ -0,0 +1,421 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects + +/** + * This will delete a folder and all its contents permanently. The API returns an empty response. + */ +class FolderDeleteParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Full path to the folder you want to delete. For example `/folder/to/delete/`. + * + * @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 folderPath(): String = body.folderPath() + + /** + * Returns the raw JSON value of [folderPath]. + * + * Unlike [folderPath], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _folderPath(): JsonField = body._folderPath() + + 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 [FolderDeleteParams]. + * + * The following fields are required: + * ```java + * .folderPath() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FolderDeleteParams]. */ + 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(folderDeleteParams: FolderDeleteParams) = apply { + body = folderDeleteParams.body.toBuilder() + additionalHeaders = folderDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = folderDeleteParams.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: + * - [folderPath] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Full path to the folder you want to delete. For example `/folder/to/delete/`. */ + fun folderPath(folderPath: String) = apply { body.folderPath(folderPath) } + + /** + * Sets [Builder.folderPath] to an arbitrary JSON value. + * + * You should usually call [Builder.folderPath] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun folderPath(folderPath: JsonField) = apply { body.folderPath(folderPath) } + + 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 [FolderDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .folderPath() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FolderDeleteParams = + FolderDeleteParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val folderPath: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("folderPath") + @ExcludeMissing + folderPath: JsonField = JsonMissing.of() + ) : this(folderPath, mutableMapOf()) + + /** + * Full path to the folder you want to delete. For example `/folder/to/delete/`. + * + * @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 folderPath(): String = folderPath.getRequired("folderPath") + + /** + * Returns the raw JSON value of [folderPath]. + * + * Unlike [folderPath], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("folderPath") + @ExcludeMissing + fun _folderPath(): JsonField = folderPath + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @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 + * .folderPath() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var folderPath: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + folderPath = body.folderPath + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Full path to the folder you want to delete. For example `/folder/to/delete/`. */ + fun folderPath(folderPath: String) = folderPath(JsonField.of(folderPath)) + + /** + * Sets [Builder.folderPath] to an arbitrary JSON value. + * + * You should usually call [Builder.folderPath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun folderPath(folderPath: JsonField) = apply { this.folderPath = folderPath } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .folderPath() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("folderPath", folderPath), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + folderPath() + 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 (folderPath.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + folderPath == other.folderPath && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(folderPath, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{folderPath=$folderPath, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FolderDeleteParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FolderDeleteParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteResponse.kt new file mode 100644 index 00000000..b9d17cd6 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteResponse.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects + +class FolderDeleteResponse +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FolderDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FolderDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(folderDeleteResponse: FolderDeleteResponse) = apply { + additionalProperties = folderDeleteResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FolderDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FolderDeleteResponse = + FolderDeleteResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): FolderDeleteResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FolderDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "FolderDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveParams.kt new file mode 100644 index 00000000..26539737 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveParams.kt @@ -0,0 +1,517 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects + +/** + * This will move one folder into another. The selected folder, its nested folders, files, and their + * versions are moved in this operation. Note: If any file at the destination has the same name as + * the source file, then the source file and its versions will be appended to the destination file + * version history. + */ +class FolderMoveParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Full path to the destination folder where you want to move the source folder into. + * + * @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 destinationPath(): String = body.destinationPath() + + /** + * The full path to the source folder you want to move. + * + * @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 sourceFolderPath(): String = body.sourceFolderPath() + + /** + * Returns the raw JSON value of [destinationPath]. + * + * Unlike [destinationPath], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _destinationPath(): JsonField = body._destinationPath() + + /** + * Returns the raw JSON value of [sourceFolderPath]. + * + * Unlike [sourceFolderPath], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _sourceFolderPath(): JsonField = body._sourceFolderPath() + + 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 [FolderMoveParams]. + * + * The following fields are required: + * ```java + * .destinationPath() + * .sourceFolderPath() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FolderMoveParams]. */ + 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(folderMoveParams: FolderMoveParams) = apply { + body = folderMoveParams.body.toBuilder() + additionalHeaders = folderMoveParams.additionalHeaders.toBuilder() + additionalQueryParams = folderMoveParams.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: + * - [destinationPath] + * - [sourceFolderPath] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Full path to the destination folder where you want to move the source folder into. */ + fun destinationPath(destinationPath: String) = apply { + body.destinationPath(destinationPath) + } + + /** + * Sets [Builder.destinationPath] to an arbitrary JSON value. + * + * You should usually call [Builder.destinationPath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun destinationPath(destinationPath: JsonField) = apply { + body.destinationPath(destinationPath) + } + + /** The full path to the source folder you want to move. */ + fun sourceFolderPath(sourceFolderPath: String) = apply { + body.sourceFolderPath(sourceFolderPath) + } + + /** + * Sets [Builder.sourceFolderPath] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceFolderPath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceFolderPath(sourceFolderPath: JsonField) = apply { + body.sourceFolderPath(sourceFolderPath) + } + + 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 [FolderMoveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .destinationPath() + * .sourceFolderPath() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FolderMoveParams = + FolderMoveParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val destinationPath: JsonField, + private val sourceFolderPath: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("destinationPath") + @ExcludeMissing + destinationPath: JsonField = JsonMissing.of(), + @JsonProperty("sourceFolderPath") + @ExcludeMissing + sourceFolderPath: JsonField = JsonMissing.of(), + ) : this(destinationPath, sourceFolderPath, mutableMapOf()) + + /** + * Full path to the destination folder where you want to move the source folder into. + * + * @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 destinationPath(): String = destinationPath.getRequired("destinationPath") + + /** + * The full path to the source folder you want to move. + * + * @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 sourceFolderPath(): String = sourceFolderPath.getRequired("sourceFolderPath") + + /** + * Returns the raw JSON value of [destinationPath]. + * + * Unlike [destinationPath], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("destinationPath") + @ExcludeMissing + fun _destinationPath(): JsonField = destinationPath + + /** + * Returns the raw JSON value of [sourceFolderPath]. + * + * Unlike [sourceFolderPath], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sourceFolderPath") + @ExcludeMissing + fun _sourceFolderPath(): JsonField = sourceFolderPath + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @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 + * .destinationPath() + * .sourceFolderPath() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var destinationPath: JsonField? = null + private var sourceFolderPath: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + destinationPath = body.destinationPath + sourceFolderPath = body.sourceFolderPath + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * Full path to the destination folder where you want to move the source folder into. + */ + fun destinationPath(destinationPath: String) = + destinationPath(JsonField.of(destinationPath)) + + /** + * Sets [Builder.destinationPath] to an arbitrary JSON value. + * + * You should usually call [Builder.destinationPath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun destinationPath(destinationPath: JsonField) = apply { + this.destinationPath = destinationPath + } + + /** The full path to the source folder you want to move. */ + fun sourceFolderPath(sourceFolderPath: String) = + sourceFolderPath(JsonField.of(sourceFolderPath)) + + /** + * Sets [Builder.sourceFolderPath] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceFolderPath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceFolderPath(sourceFolderPath: JsonField) = apply { + this.sourceFolderPath = sourceFolderPath + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .destinationPath() + * .sourceFolderPath() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("destinationPath", destinationPath), + checkRequired("sourceFolderPath", sourceFolderPath), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + destinationPath() + sourceFolderPath() + 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 (destinationPath.asKnown().isPresent) 1 else 0) + + (if (sourceFolderPath.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + destinationPath == other.destinationPath && + sourceFolderPath == other.sourceFolderPath && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(destinationPath, sourceFolderPath, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{destinationPath=$destinationPath, sourceFolderPath=$sourceFolderPath, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FolderMoveParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FolderMoveParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveResponse.kt new file mode 100644 index 00000000..7df902cc --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveResponse.kt @@ -0,0 +1,172 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Job submitted successfully. A `jobId` will be returned. */ +class FolderMoveResponse +private constructor( + private val jobId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("jobId") @ExcludeMissing jobId: JsonField = JsonMissing.of() + ) : this(jobId, mutableMapOf()) + + /** + * Unique identifier of the bulk job. This can be used to check the status of the bulk job. + * + * @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 jobId(): String = jobId.getRequired("jobId") + + /** + * Returns the raw JSON value of [jobId]. + * + * Unlike [jobId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("jobId") @ExcludeMissing fun _jobId(): JsonField = jobId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FolderMoveResponse]. + * + * The following fields are required: + * ```java + * .jobId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FolderMoveResponse]. */ + class Builder internal constructor() { + + private var jobId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(folderMoveResponse: FolderMoveResponse) = apply { + jobId = folderMoveResponse.jobId + additionalProperties = folderMoveResponse.additionalProperties.toMutableMap() + } + + /** + * Unique identifier of the bulk job. This can be used to check the status of the bulk job. + */ + fun jobId(jobId: String) = jobId(JsonField.of(jobId)) + + /** + * Sets [Builder.jobId] to an arbitrary JSON value. + * + * You should usually call [Builder.jobId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun jobId(jobId: JsonField) = apply { this.jobId = jobId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FolderMoveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .jobId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FolderMoveResponse = + FolderMoveResponse(checkRequired("jobId", jobId), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): FolderMoveResponse = apply { + if (validated) { + return@apply + } + + jobId() + 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 (jobId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FolderMoveResponse && + jobId == other.jobId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(jobId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FolderMoveResponse{jobId=$jobId, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameParams.kt new file mode 100644 index 00000000..c6564c80 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameParams.kt @@ -0,0 +1,646 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * This API allows you to rename an existing folder. The folder and all its nested assets and + * sub-folders will remain unchanged, but their paths will be updated to reflect the new folder + * name. + */ +class FolderRenameParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The full path to the folder you want to rename. + * + * @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 folderPath(): String = body.folderPath() + + /** + * The new name for the folder. + * + * All characters except alphabets and numbers (inclusive of unicode letters, marks, and + * numerals in other languages) and `-` will be replaced by an underscore i.e. `_`. + * + * @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 newFolderName(): String = body.newFolderName() + + /** + * Option to purge cache for the old nested files and their versions' URLs. + * + * When set to true, it will internally issue a purge cache request on CDN to remove the cached + * content of the old nested files and their versions. There will only be one purge request for + * all the nested files, which will be counted against your monthly purge quota. + * + * Note: A purge cache request will be issued against `https://ik.imagekit.io/old/folder/path*` + * (with a wildcard at the end). This will remove all nested files, their versions' URLs, and + * any transformations made using query parameters on these files or their versions. However, + * the cache for file transformations made using path parameters will persist. You can purge + * them using the purge API. For more details, refer to the purge API documentation. + * + * Default value - `false` + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun purgeCache(): Optional = body.purgeCache() + + /** + * Returns the raw JSON value of [folderPath]. + * + * Unlike [folderPath], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _folderPath(): JsonField = body._folderPath() + + /** + * Returns the raw JSON value of [newFolderName]. + * + * Unlike [newFolderName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _newFolderName(): JsonField = body._newFolderName() + + /** + * Returns the raw JSON value of [purgeCache]. + * + * Unlike [purgeCache], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _purgeCache(): JsonField = body._purgeCache() + + 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 [FolderRenameParams]. + * + * The following fields are required: + * ```java + * .folderPath() + * .newFolderName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FolderRenameParams]. */ + 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(folderRenameParams: FolderRenameParams) = apply { + body = folderRenameParams.body.toBuilder() + additionalHeaders = folderRenameParams.additionalHeaders.toBuilder() + additionalQueryParams = folderRenameParams.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: + * - [folderPath] + * - [newFolderName] + * - [purgeCache] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The full path to the folder you want to rename. */ + fun folderPath(folderPath: String) = apply { body.folderPath(folderPath) } + + /** + * Sets [Builder.folderPath] to an arbitrary JSON value. + * + * You should usually call [Builder.folderPath] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun folderPath(folderPath: JsonField) = apply { body.folderPath(folderPath) } + + /** + * The new name for the folder. + * + * All characters except alphabets and numbers (inclusive of unicode letters, marks, and + * numerals in other languages) and `-` will be replaced by an underscore i.e. `_`. + */ + fun newFolderName(newFolderName: String) = apply { body.newFolderName(newFolderName) } + + /** + * Sets [Builder.newFolderName] to an arbitrary JSON value. + * + * You should usually call [Builder.newFolderName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun newFolderName(newFolderName: JsonField) = apply { + body.newFolderName(newFolderName) + } + + /** + * Option to purge cache for the old nested files and their versions' URLs. + * + * When set to true, it will internally issue a purge cache request on CDN to remove the + * cached content of the old nested files and their versions. There will only be one purge + * request for all the nested files, which will be counted against your monthly purge quota. + * + * Note: A purge cache request will be issued against + * `https://ik.imagekit.io/old/folder/path*` (with a wildcard at the end). This will remove + * all nested files, their versions' URLs, and any transformations made using query + * parameters on these files or their versions. However, the cache for file transformations + * made using path parameters will persist. You can purge them using the purge API. For more + * details, refer to the purge API documentation. + * + * Default value - `false` + */ + fun purgeCache(purgeCache: Boolean) = apply { body.purgeCache(purgeCache) } + + /** + * Sets [Builder.purgeCache] to an arbitrary JSON value. + * + * You should usually call [Builder.purgeCache] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun purgeCache(purgeCache: JsonField) = apply { body.purgeCache(purgeCache) } + + 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 [FolderRenameParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .folderPath() + * .newFolderName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FolderRenameParams = + FolderRenameParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val folderPath: JsonField, + private val newFolderName: JsonField, + private val purgeCache: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("folderPath") + @ExcludeMissing + folderPath: JsonField = JsonMissing.of(), + @JsonProperty("newFolderName") + @ExcludeMissing + newFolderName: JsonField = JsonMissing.of(), + @JsonProperty("purgeCache") + @ExcludeMissing + purgeCache: JsonField = JsonMissing.of(), + ) : this(folderPath, newFolderName, purgeCache, mutableMapOf()) + + /** + * The full path to the folder you want to rename. + * + * @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 folderPath(): String = folderPath.getRequired("folderPath") + + /** + * The new name for the folder. + * + * All characters except alphabets and numbers (inclusive of unicode letters, marks, and + * numerals in other languages) and `-` will be replaced by an underscore i.e. `_`. + * + * @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 newFolderName(): String = newFolderName.getRequired("newFolderName") + + /** + * Option to purge cache for the old nested files and their versions' URLs. + * + * When set to true, it will internally issue a purge cache request on CDN to remove the + * cached content of the old nested files and their versions. There will only be one purge + * request for all the nested files, which will be counted against your monthly purge quota. + * + * Note: A purge cache request will be issued against + * `https://ik.imagekit.io/old/folder/path*` (with a wildcard at the end). This will remove + * all nested files, their versions' URLs, and any transformations made using query + * parameters on these files or their versions. However, the cache for file transformations + * made using path parameters will persist. You can purge them using the purge API. For more + * details, refer to the purge API documentation. + * + * Default value - `false` + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun purgeCache(): Optional = purgeCache.getOptional("purgeCache") + + /** + * Returns the raw JSON value of [folderPath]. + * + * Unlike [folderPath], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("folderPath") + @ExcludeMissing + fun _folderPath(): JsonField = folderPath + + /** + * Returns the raw JSON value of [newFolderName]. + * + * Unlike [newFolderName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("newFolderName") + @ExcludeMissing + fun _newFolderName(): JsonField = newFolderName + + /** + * Returns the raw JSON value of [purgeCache]. + * + * Unlike [purgeCache], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("purgeCache") + @ExcludeMissing + fun _purgeCache(): JsonField = purgeCache + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @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 + * .folderPath() + * .newFolderName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var folderPath: JsonField? = null + private var newFolderName: JsonField? = null + private var purgeCache: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + folderPath = body.folderPath + newFolderName = body.newFolderName + purgeCache = body.purgeCache + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The full path to the folder you want to rename. */ + fun folderPath(folderPath: String) = folderPath(JsonField.of(folderPath)) + + /** + * Sets [Builder.folderPath] to an arbitrary JSON value. + * + * You should usually call [Builder.folderPath] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun folderPath(folderPath: JsonField) = apply { this.folderPath = folderPath } + + /** + * The new name for the folder. + * + * All characters except alphabets and numbers (inclusive of unicode letters, marks, and + * numerals in other languages) and `-` will be replaced by an underscore i.e. `_`. + */ + fun newFolderName(newFolderName: String) = newFolderName(JsonField.of(newFolderName)) + + /** + * Sets [Builder.newFolderName] to an arbitrary JSON value. + * + * You should usually call [Builder.newFolderName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun newFolderName(newFolderName: JsonField) = apply { + this.newFolderName = newFolderName + } + + /** + * Option to purge cache for the old nested files and their versions' URLs. + * + * When set to true, it will internally issue a purge cache request on CDN to remove the + * cached content of the old nested files and their versions. There will only be one + * purge request for all the nested files, which will be counted against your monthly + * purge quota. + * + * Note: A purge cache request will be issued against + * `https://ik.imagekit.io/old/folder/path*` (with a wildcard at the end). This will + * remove all nested files, their versions' URLs, and any transformations made using + * query parameters on these files or their versions. However, the cache for file + * transformations made using path parameters will persist. You can purge them using the + * purge API. For more details, refer to the purge API documentation. + * + * Default value - `false` + */ + fun purgeCache(purgeCache: Boolean) = purgeCache(JsonField.of(purgeCache)) + + /** + * Sets [Builder.purgeCache] to an arbitrary JSON value. + * + * You should usually call [Builder.purgeCache] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun purgeCache(purgeCache: JsonField) = apply { this.purgeCache = purgeCache } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .folderPath() + * .newFolderName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("folderPath", folderPath), + checkRequired("newFolderName", newFolderName), + purgeCache, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + folderPath() + newFolderName() + purgeCache() + 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 (folderPath.asKnown().isPresent) 1 else 0) + + (if (newFolderName.asKnown().isPresent) 1 else 0) + + (if (purgeCache.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + folderPath == other.folderPath && + newFolderName == other.newFolderName && + purgeCache == other.purgeCache && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(folderPath, newFolderName, purgeCache, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{folderPath=$folderPath, newFolderName=$newFolderName, purgeCache=$purgeCache, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FolderRenameParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FolderRenameParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameResponse.kt new file mode 100644 index 00000000..96bd156a --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameResponse.kt @@ -0,0 +1,172 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects + +/** Job submitted successfully. A `jobId` will be returned. */ +class FolderRenameResponse +private constructor( + private val jobId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("jobId") @ExcludeMissing jobId: JsonField = JsonMissing.of() + ) : this(jobId, mutableMapOf()) + + /** + * Unique identifier of the bulk job. This can be used to check the status of the bulk job. + * + * @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 jobId(): String = jobId.getRequired("jobId") + + /** + * Returns the raw JSON value of [jobId]. + * + * Unlike [jobId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("jobId") @ExcludeMissing fun _jobId(): JsonField = jobId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FolderRenameResponse]. + * + * The following fields are required: + * ```java + * .jobId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FolderRenameResponse]. */ + class Builder internal constructor() { + + private var jobId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(folderRenameResponse: FolderRenameResponse) = apply { + jobId = folderRenameResponse.jobId + additionalProperties = folderRenameResponse.additionalProperties.toMutableMap() + } + + /** + * Unique identifier of the bulk job. This can be used to check the status of the bulk job. + */ + fun jobId(jobId: String) = jobId(JsonField.of(jobId)) + + /** + * Sets [Builder.jobId] to an arbitrary JSON value. + * + * You should usually call [Builder.jobId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun jobId(jobId: JsonField) = apply { this.jobId = jobId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FolderRenameResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .jobId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FolderRenameResponse = + FolderRenameResponse(checkRequired("jobId", jobId), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): FolderRenameResponse = apply { + if (validated) { + return@apply + } + + jobId() + 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 (jobId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FolderRenameResponse && + jobId == other.jobId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(jobId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FolderRenameResponse{jobId=$jobId, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetParams.kt new file mode 100644 index 00000000..6e87f9b0 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders.job + +import com.imagekit.api.core.Params +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** This API returns the status of a bulk job like copy and move folder operations. */ +class JobGetParams +private constructor( + private val jobId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun jobId(): Optional = Optional.ofNullable(jobId) + + /** 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(): JobGetParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [JobGetParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [JobGetParams]. */ + class Builder internal constructor() { + + private var jobId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(jobGetParams: JobGetParams) = apply { + jobId = jobGetParams.jobId + additionalHeaders = jobGetParams.additionalHeaders.toBuilder() + additionalQueryParams = jobGetParams.additionalQueryParams.toBuilder() + } + + fun jobId(jobId: String?) = apply { this.jobId = jobId } + + /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ + fun jobId(jobId: Optional) = jobId(jobId.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 [JobGetParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): JobGetParams = + JobGetParams(jobId, additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> jobId ?: "" + 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 JobGetParams && + jobId == other.jobId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(jobId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "JobGetParams{jobId=$jobId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetResponse.kt new file mode 100644 index 00000000..b6ed81c2 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetResponse.kt @@ -0,0 +1,533 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders.job + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class JobGetResponse +private constructor( + private val jobId: JsonField, + private val purgeRequestId: JsonField, + private val status: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("jobId") @ExcludeMissing jobId: JsonField = JsonMissing.of(), + @JsonProperty("purgeRequestId") + @ExcludeMissing + purgeRequestId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(jobId, purgeRequestId, status, type, mutableMapOf()) + + /** + * Unique identifier of the bulk job. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun jobId(): Optional = jobId.getOptional("jobId") + + /** + * Unique identifier of the purge request. This will be present only if `purgeCache` is set to + * `true` in the rename folder API request. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun purgeRequestId(): Optional = purgeRequestId.getOptional("purgeRequestId") + + /** + * Status of the bulk job. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Type of the bulk job. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [jobId]. + * + * Unlike [jobId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("jobId") @ExcludeMissing fun _jobId(): JsonField = jobId + + /** + * Returns the raw JSON value of [purgeRequestId]. + * + * Unlike [purgeRequestId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("purgeRequestId") + @ExcludeMissing + fun _purgeRequestId(): JsonField = purgeRequestId + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [JobGetResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [JobGetResponse]. */ + class Builder internal constructor() { + + private var jobId: JsonField = JsonMissing.of() + private var purgeRequestId: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(jobGetResponse: JobGetResponse) = apply { + jobId = jobGetResponse.jobId + purgeRequestId = jobGetResponse.purgeRequestId + status = jobGetResponse.status + type = jobGetResponse.type + additionalProperties = jobGetResponse.additionalProperties.toMutableMap() + } + + /** Unique identifier of the bulk job. */ + fun jobId(jobId: String) = jobId(JsonField.of(jobId)) + + /** + * Sets [Builder.jobId] to an arbitrary JSON value. + * + * You should usually call [Builder.jobId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun jobId(jobId: JsonField) = apply { this.jobId = jobId } + + /** + * Unique identifier of the purge request. This will be present only if `purgeCache` is set + * to `true` in the rename folder API request. + */ + fun purgeRequestId(purgeRequestId: String) = purgeRequestId(JsonField.of(purgeRequestId)) + + /** + * Sets [Builder.purgeRequestId] to an arbitrary JSON value. + * + * You should usually call [Builder.purgeRequestId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun purgeRequestId(purgeRequestId: JsonField) = apply { + this.purgeRequestId = purgeRequestId + } + + /** Status of the bulk job. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** Type of the bulk job. */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [JobGetResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): JobGetResponse = + JobGetResponse(jobId, purgeRequestId, status, type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): JobGetResponse = apply { + if (validated) { + return@apply + } + + jobId() + purgeRequestId() + status().ifPresent { it.validate() } + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (jobId.asKnown().isPresent) 1 else 0) + + (if (purgeRequestId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** Status of the bulk job. */ + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PENDING = of("Pending") + + @JvmField val COMPLETED = of("Completed") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + PENDING, + COMPLETED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PENDING, + COMPLETED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PENDING -> Value.PENDING + COMPLETED -> Value.COMPLETED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + COMPLETED -> Known.COMPLETED + else -> throw ImageKitInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Type of the bulk job. */ + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val COPY_FOLDER = of("COPY_FOLDER") + + @JvmField val MOVE_FOLDER = of("MOVE_FOLDER") + + @JvmField val RENAME_FOLDER = of("RENAME_FOLDER") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + COPY_FOLDER, + MOVE_FOLDER, + RENAME_FOLDER, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COPY_FOLDER, + MOVE_FOLDER, + RENAME_FOLDER, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COPY_FOLDER -> Value.COPY_FOLDER + MOVE_FOLDER -> Value.MOVE_FOLDER + RENAME_FOLDER -> Value.RENAME_FOLDER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + COPY_FOLDER -> Known.COPY_FOLDER + MOVE_FOLDER -> Known.MOVE_FOLDER + RENAME_FOLDER -> Known.RENAME_FOLDER + else -> throw ImageKitInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JobGetResponse && + jobId == other.jobId && + purgeRequestId == other.purgeRequestId && + status == other.status && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(jobId, purgeRequestId, status, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "JobGetResponse{jobId=$jobId, purgeRequestId=$purgeRequestId, status=$status, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt new file mode 100644 index 00000000..a989564a --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt @@ -0,0 +1,560 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.allMaxBy +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Objects +import java.util.Optional + +/** + * Triggered when a new video transformation request is accepted for processing. This event confirms + * that ImageKit has received and queued your transformation request. Use this for debugging and + * tracking transformation lifecycle. + */ +@JsonDeserialize(using = UnsafeUnwrapWebhookEvent.Deserializer::class) +@JsonSerialize(using = UnsafeUnwrapWebhookEvent.Serializer::class) +class UnsafeUnwrapWebhookEvent +private constructor( + private val videoTransformationAccepted: VideoTransformationAcceptedEvent? = null, + private val videoTransformationReady: VideoTransformationReadyEvent? = null, + private val videoTransformationError: VideoTransformationErrorEvent? = null, + private val uploadPreTransformSuccess: UploadPreTransformSuccessEvent? = null, + private val uploadPreTransformError: UploadPreTransformErrorEvent? = null, + private val uploadPostTransformSuccess: UploadPostTransformSuccessEvent? = null, + private val uploadPostTransformError: UploadPostTransformErrorEvent? = null, + private val _json: JsonValue? = null, +) { + + /** + * Triggered when a new video transformation request is accepted for processing. This event + * confirms that ImageKit has received and queued your transformation request. Use this for + * debugging and tracking transformation lifecycle. + */ + fun videoTransformationAccepted(): Optional = + Optional.ofNullable(videoTransformationAccepted) + + /** + * Triggered when video encoding is finished and the transformed resource is ready to be served. + * This is the key event to listen for - update your database or CMS flags when you receive this + * so your application can start showing the transformed video to users. + */ + fun videoTransformationReady(): Optional = + Optional.ofNullable(videoTransformationReady) + + /** + * Triggered when an error occurs during video encoding. Listen to this webhook to log error + * reasons and debug issues. Check your origin and URL endpoint settings if the reason is + * related to download failure. For other errors, contact ImageKit support. + */ + fun videoTransformationError(): Optional = + Optional.ofNullable(videoTransformationError) + + /** + * Triggered when a pre-transformation completes successfully. The file has been processed with + * the requested transformation and is now available in the Media Library. + */ + fun uploadPreTransformSuccess(): Optional = + Optional.ofNullable(uploadPreTransformSuccess) + + /** + * Triggered when a pre-transformation fails. The file upload may have been accepted, but the + * requested transformation could not be applied. + */ + fun uploadPreTransformError(): Optional = + Optional.ofNullable(uploadPreTransformError) + + /** + * Triggered when a post-transformation completes successfully. The transformed version of the + * file is now ready and can be accessed via the provided URL. Note that each + * post-transformation generates a separate webhook event. + */ + fun uploadPostTransformSuccess(): Optional = + Optional.ofNullable(uploadPostTransformSuccess) + + /** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ + fun uploadPostTransformError(): Optional = + Optional.ofNullable(uploadPostTransformError) + + fun isVideoTransformationAccepted(): Boolean = videoTransformationAccepted != null + + fun isVideoTransformationReady(): Boolean = videoTransformationReady != null + + fun isVideoTransformationError(): Boolean = videoTransformationError != null + + fun isUploadPreTransformSuccess(): Boolean = uploadPreTransformSuccess != null + + fun isUploadPreTransformError(): Boolean = uploadPreTransformError != null + + fun isUploadPostTransformSuccess(): Boolean = uploadPostTransformSuccess != null + + fun isUploadPostTransformError(): Boolean = uploadPostTransformError != null + + /** + * Triggered when a new video transformation request is accepted for processing. This event + * confirms that ImageKit has received and queued your transformation request. Use this for + * debugging and tracking transformation lifecycle. + */ + fun asVideoTransformationAccepted(): VideoTransformationAcceptedEvent = + videoTransformationAccepted.getOrThrow("videoTransformationAccepted") + + /** + * Triggered when video encoding is finished and the transformed resource is ready to be served. + * This is the key event to listen for - update your database or CMS flags when you receive this + * so your application can start showing the transformed video to users. + */ + fun asVideoTransformationReady(): VideoTransformationReadyEvent = + videoTransformationReady.getOrThrow("videoTransformationReady") + + /** + * Triggered when an error occurs during video encoding. Listen to this webhook to log error + * reasons and debug issues. Check your origin and URL endpoint settings if the reason is + * related to download failure. For other errors, contact ImageKit support. + */ + fun asVideoTransformationError(): VideoTransformationErrorEvent = + videoTransformationError.getOrThrow("videoTransformationError") + + /** + * Triggered when a pre-transformation completes successfully. The file has been processed with + * the requested transformation and is now available in the Media Library. + */ + fun asUploadPreTransformSuccess(): UploadPreTransformSuccessEvent = + uploadPreTransformSuccess.getOrThrow("uploadPreTransformSuccess") + + /** + * Triggered when a pre-transformation fails. The file upload may have been accepted, but the + * requested transformation could not be applied. + */ + fun asUploadPreTransformError(): UploadPreTransformErrorEvent = + uploadPreTransformError.getOrThrow("uploadPreTransformError") + + /** + * Triggered when a post-transformation completes successfully. The transformed version of the + * file is now ready and can be accessed via the provided URL. Note that each + * post-transformation generates a separate webhook event. + */ + fun asUploadPostTransformSuccess(): UploadPostTransformSuccessEvent = + uploadPostTransformSuccess.getOrThrow("uploadPostTransformSuccess") + + /** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ + fun asUploadPostTransformError(): UploadPostTransformErrorEvent = + uploadPostTransformError.getOrThrow("uploadPostTransformError") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + videoTransformationAccepted != null -> + visitor.visitVideoTransformationAccepted(videoTransformationAccepted) + videoTransformationReady != null -> + visitor.visitVideoTransformationReady(videoTransformationReady) + videoTransformationError != null -> + visitor.visitVideoTransformationError(videoTransformationError) + uploadPreTransformSuccess != null -> + visitor.visitUploadPreTransformSuccess(uploadPreTransformSuccess) + uploadPreTransformError != null -> + visitor.visitUploadPreTransformError(uploadPreTransformError) + uploadPostTransformSuccess != null -> + visitor.visitUploadPostTransformSuccess(uploadPostTransformSuccess) + uploadPostTransformError != null -> + visitor.visitUploadPostTransformError(uploadPostTransformError) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnsafeUnwrapWebhookEvent = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitVideoTransformationAccepted( + videoTransformationAccepted: VideoTransformationAcceptedEvent + ) { + videoTransformationAccepted.validate() + } + + override fun visitVideoTransformationReady( + videoTransformationReady: VideoTransformationReadyEvent + ) { + videoTransformationReady.validate() + } + + override fun visitVideoTransformationError( + videoTransformationError: VideoTransformationErrorEvent + ) { + videoTransformationError.validate() + } + + override fun visitUploadPreTransformSuccess( + uploadPreTransformSuccess: UploadPreTransformSuccessEvent + ) { + uploadPreTransformSuccess.validate() + } + + override fun visitUploadPreTransformError( + uploadPreTransformError: UploadPreTransformErrorEvent + ) { + uploadPreTransformError.validate() + } + + override fun visitUploadPostTransformSuccess( + uploadPostTransformSuccess: UploadPostTransformSuccessEvent + ) { + uploadPostTransformSuccess.validate() + } + + override fun visitUploadPostTransformError( + uploadPostTransformError: UploadPostTransformErrorEvent + ) { + uploadPostTransformError.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitVideoTransformationAccepted( + videoTransformationAccepted: VideoTransformationAcceptedEvent + ) = videoTransformationAccepted.validity() + + override fun visitVideoTransformationReady( + videoTransformationReady: VideoTransformationReadyEvent + ) = videoTransformationReady.validity() + + override fun visitVideoTransformationError( + videoTransformationError: VideoTransformationErrorEvent + ) = videoTransformationError.validity() + + override fun visitUploadPreTransformSuccess( + uploadPreTransformSuccess: UploadPreTransformSuccessEvent + ) = uploadPreTransformSuccess.validity() + + override fun visitUploadPreTransformError( + uploadPreTransformError: UploadPreTransformErrorEvent + ) = uploadPreTransformError.validity() + + override fun visitUploadPostTransformSuccess( + uploadPostTransformSuccess: UploadPostTransformSuccessEvent + ) = uploadPostTransformSuccess.validity() + + override fun visitUploadPostTransformError( + uploadPostTransformError: UploadPostTransformErrorEvent + ) = uploadPostTransformError.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnsafeUnwrapWebhookEvent && + videoTransformationAccepted == other.videoTransformationAccepted && + videoTransformationReady == other.videoTransformationReady && + videoTransformationError == other.videoTransformationError && + uploadPreTransformSuccess == other.uploadPreTransformSuccess && + uploadPreTransformError == other.uploadPreTransformError && + uploadPostTransformSuccess == other.uploadPostTransformSuccess && + uploadPostTransformError == other.uploadPostTransformError + } + + override fun hashCode(): Int = + Objects.hash( + videoTransformationAccepted, + videoTransformationReady, + videoTransformationError, + uploadPreTransformSuccess, + uploadPreTransformError, + uploadPostTransformSuccess, + uploadPostTransformError, + ) + + override fun toString(): String = + when { + videoTransformationAccepted != null -> + "UnsafeUnwrapWebhookEvent{videoTransformationAccepted=$videoTransformationAccepted}" + videoTransformationReady != null -> + "UnsafeUnwrapWebhookEvent{videoTransformationReady=$videoTransformationReady}" + videoTransformationError != null -> + "UnsafeUnwrapWebhookEvent{videoTransformationError=$videoTransformationError}" + uploadPreTransformSuccess != null -> + "UnsafeUnwrapWebhookEvent{uploadPreTransformSuccess=$uploadPreTransformSuccess}" + uploadPreTransformError != null -> + "UnsafeUnwrapWebhookEvent{uploadPreTransformError=$uploadPreTransformError}" + uploadPostTransformSuccess != null -> + "UnsafeUnwrapWebhookEvent{uploadPostTransformSuccess=$uploadPostTransformSuccess}" + uploadPostTransformError != null -> + "UnsafeUnwrapWebhookEvent{uploadPostTransformError=$uploadPostTransformError}" + _json != null -> "UnsafeUnwrapWebhookEvent{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnsafeUnwrapWebhookEvent") + } + + companion object { + + /** + * Triggered when a new video transformation request is accepted for processing. This event + * confirms that ImageKit has received and queued your transformation request. Use this for + * debugging and tracking transformation lifecycle. + */ + @JvmStatic + fun ofVideoTransformationAccepted( + videoTransformationAccepted: VideoTransformationAcceptedEvent + ) = UnsafeUnwrapWebhookEvent(videoTransformationAccepted = videoTransformationAccepted) + + /** + * Triggered when video encoding is finished and the transformed resource is ready to be + * served. This is the key event to listen for - update your database or CMS flags when you + * receive this so your application can start showing the transformed video to users. + */ + @JvmStatic + fun ofVideoTransformationReady(videoTransformationReady: VideoTransformationReadyEvent) = + UnsafeUnwrapWebhookEvent(videoTransformationReady = videoTransformationReady) + + /** + * Triggered when an error occurs during video encoding. Listen to this webhook to log error + * reasons and debug issues. Check your origin and URL endpoint settings if the reason is + * related to download failure. For other errors, contact ImageKit support. + */ + @JvmStatic + fun ofVideoTransformationError(videoTransformationError: VideoTransformationErrorEvent) = + UnsafeUnwrapWebhookEvent(videoTransformationError = videoTransformationError) + + /** + * Triggered when a pre-transformation completes successfully. The file has been processed + * with the requested transformation and is now available in the Media Library. + */ + @JvmStatic + fun ofUploadPreTransformSuccess(uploadPreTransformSuccess: UploadPreTransformSuccessEvent) = + UnsafeUnwrapWebhookEvent(uploadPreTransformSuccess = uploadPreTransformSuccess) + + /** + * Triggered when a pre-transformation fails. The file upload may have been accepted, but + * the requested transformation could not be applied. + */ + @JvmStatic + fun ofUploadPreTransformError(uploadPreTransformError: UploadPreTransformErrorEvent) = + UnsafeUnwrapWebhookEvent(uploadPreTransformError = uploadPreTransformError) + + /** + * Triggered when a post-transformation completes successfully. The transformed version of + * the file is now ready and can be accessed via the provided URL. Note that each + * post-transformation generates a separate webhook event. + */ + @JvmStatic + fun ofUploadPostTransformSuccess( + uploadPostTransformSuccess: UploadPostTransformSuccessEvent + ) = UnsafeUnwrapWebhookEvent(uploadPostTransformSuccess = uploadPostTransformSuccess) + + /** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ + @JvmStatic + fun ofUploadPostTransformError(uploadPostTransformError: UploadPostTransformErrorEvent) = + UnsafeUnwrapWebhookEvent(uploadPostTransformError = uploadPostTransformError) + } + + /** + * An interface that defines how to map each variant of [UnsafeUnwrapWebhookEvent] to a value of + * type [T]. + */ + interface Visitor { + + /** + * Triggered when a new video transformation request is accepted for processing. This event + * confirms that ImageKit has received and queued your transformation request. Use this for + * debugging and tracking transformation lifecycle. + */ + fun visitVideoTransformationAccepted( + videoTransformationAccepted: VideoTransformationAcceptedEvent + ): T + + /** + * Triggered when video encoding is finished and the transformed resource is ready to be + * served. This is the key event to listen for - update your database or CMS flags when you + * receive this so your application can start showing the transformed video to users. + */ + fun visitVideoTransformationReady( + videoTransformationReady: VideoTransformationReadyEvent + ): T + + /** + * Triggered when an error occurs during video encoding. Listen to this webhook to log error + * reasons and debug issues. Check your origin and URL endpoint settings if the reason is + * related to download failure. For other errors, contact ImageKit support. + */ + fun visitVideoTransformationError( + videoTransformationError: VideoTransformationErrorEvent + ): T + + /** + * Triggered when a pre-transformation completes successfully. The file has been processed + * with the requested transformation and is now available in the Media Library. + */ + fun visitUploadPreTransformSuccess( + uploadPreTransformSuccess: UploadPreTransformSuccessEvent + ): T + + /** + * Triggered when a pre-transformation fails. The file upload may have been accepted, but + * the requested transformation could not be applied. + */ + fun visitUploadPreTransformError(uploadPreTransformError: UploadPreTransformErrorEvent): T + + /** + * Triggered when a post-transformation completes successfully. The transformed version of + * the file is now ready and can be accessed via the provided URL. Note that each + * post-transformation generates a separate webhook event. + */ + fun visitUploadPostTransformSuccess( + uploadPostTransformSuccess: UploadPostTransformSuccessEvent + ): T + + /** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ + fun visitUploadPostTransformError( + uploadPostTransformError: UploadPostTransformErrorEvent + ): T + + /** + * Maps an unknown variant of [UnsafeUnwrapWebhookEvent] to a value of type [T]. + * + * An instance of [UnsafeUnwrapWebhookEvent] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK is + * on an older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown UnsafeUnwrapWebhookEvent: $json") + } + } + + internal class Deserializer : + BaseDeserializer(UnsafeUnwrapWebhookEvent::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): UnsafeUnwrapWebhookEvent { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnsafeUnwrapWebhookEvent( + videoTransformationAccepted = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnsafeUnwrapWebhookEvent(videoTransformationReady = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnsafeUnwrapWebhookEvent(videoTransformationError = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnsafeUnwrapWebhookEvent( + uploadPreTransformSuccess = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnsafeUnwrapWebhookEvent(uploadPreTransformError = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnsafeUnwrapWebhookEvent( + uploadPostTransformSuccess = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnsafeUnwrapWebhookEvent(uploadPostTransformError = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> UnsafeUnwrapWebhookEvent(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(UnsafeUnwrapWebhookEvent::class) { + + override fun serialize( + value: UnsafeUnwrapWebhookEvent, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.videoTransformationAccepted != null -> + generator.writeObject(value.videoTransformationAccepted) + value.videoTransformationReady != null -> + generator.writeObject(value.videoTransformationReady) + value.videoTransformationError != null -> + generator.writeObject(value.videoTransformationError) + value.uploadPreTransformSuccess != null -> + generator.writeObject(value.uploadPreTransformSuccess) + value.uploadPreTransformError != null -> + generator.writeObject(value.uploadPreTransformError) + value.uploadPostTransformSuccess != null -> + generator.writeObject(value.uploadPostTransformSuccess) + value.uploadPostTransformError != null -> + generator.writeObject(value.uploadPostTransformError) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid UnsafeUnwrapWebhookEvent") + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt new file mode 100644 index 00000000..8e1eab97 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt @@ -0,0 +1,549 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.allMaxBy +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Objects +import java.util.Optional + +/** + * Triggered when a new video transformation request is accepted for processing. This event confirms + * that ImageKit has received and queued your transformation request. Use this for debugging and + * tracking transformation lifecycle. + */ +@JsonDeserialize(using = UnwrapWebhookEvent.Deserializer::class) +@JsonSerialize(using = UnwrapWebhookEvent.Serializer::class) +class UnwrapWebhookEvent +private constructor( + private val videoTransformationAccepted: VideoTransformationAcceptedEvent? = null, + private val videoTransformationReady: VideoTransformationReadyEvent? = null, + private val videoTransformationError: VideoTransformationErrorEvent? = null, + private val uploadPreTransformSuccess: UploadPreTransformSuccessEvent? = null, + private val uploadPreTransformError: UploadPreTransformErrorEvent? = null, + private val uploadPostTransformSuccess: UploadPostTransformSuccessEvent? = null, + private val uploadPostTransformError: UploadPostTransformErrorEvent? = null, + private val _json: JsonValue? = null, +) { + + /** + * Triggered when a new video transformation request is accepted for processing. This event + * confirms that ImageKit has received and queued your transformation request. Use this for + * debugging and tracking transformation lifecycle. + */ + fun videoTransformationAccepted(): Optional = + Optional.ofNullable(videoTransformationAccepted) + + /** + * Triggered when video encoding is finished and the transformed resource is ready to be served. + * This is the key event to listen for - update your database or CMS flags when you receive this + * so your application can start showing the transformed video to users. + */ + fun videoTransformationReady(): Optional = + Optional.ofNullable(videoTransformationReady) + + /** + * Triggered when an error occurs during video encoding. Listen to this webhook to log error + * reasons and debug issues. Check your origin and URL endpoint settings if the reason is + * related to download failure. For other errors, contact ImageKit support. + */ + fun videoTransformationError(): Optional = + Optional.ofNullable(videoTransformationError) + + /** + * Triggered when a pre-transformation completes successfully. The file has been processed with + * the requested transformation and is now available in the Media Library. + */ + fun uploadPreTransformSuccess(): Optional = + Optional.ofNullable(uploadPreTransformSuccess) + + /** + * Triggered when a pre-transformation fails. The file upload may have been accepted, but the + * requested transformation could not be applied. + */ + fun uploadPreTransformError(): Optional = + Optional.ofNullable(uploadPreTransformError) + + /** + * Triggered when a post-transformation completes successfully. The transformed version of the + * file is now ready and can be accessed via the provided URL. Note that each + * post-transformation generates a separate webhook event. + */ + fun uploadPostTransformSuccess(): Optional = + Optional.ofNullable(uploadPostTransformSuccess) + + /** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ + fun uploadPostTransformError(): Optional = + Optional.ofNullable(uploadPostTransformError) + + fun isVideoTransformationAccepted(): Boolean = videoTransformationAccepted != null + + fun isVideoTransformationReady(): Boolean = videoTransformationReady != null + + fun isVideoTransformationError(): Boolean = videoTransformationError != null + + fun isUploadPreTransformSuccess(): Boolean = uploadPreTransformSuccess != null + + fun isUploadPreTransformError(): Boolean = uploadPreTransformError != null + + fun isUploadPostTransformSuccess(): Boolean = uploadPostTransformSuccess != null + + fun isUploadPostTransformError(): Boolean = uploadPostTransformError != null + + /** + * Triggered when a new video transformation request is accepted for processing. This event + * confirms that ImageKit has received and queued your transformation request. Use this for + * debugging and tracking transformation lifecycle. + */ + fun asVideoTransformationAccepted(): VideoTransformationAcceptedEvent = + videoTransformationAccepted.getOrThrow("videoTransformationAccepted") + + /** + * Triggered when video encoding is finished and the transformed resource is ready to be served. + * This is the key event to listen for - update your database or CMS flags when you receive this + * so your application can start showing the transformed video to users. + */ + fun asVideoTransformationReady(): VideoTransformationReadyEvent = + videoTransformationReady.getOrThrow("videoTransformationReady") + + /** + * Triggered when an error occurs during video encoding. Listen to this webhook to log error + * reasons and debug issues. Check your origin and URL endpoint settings if the reason is + * related to download failure. For other errors, contact ImageKit support. + */ + fun asVideoTransformationError(): VideoTransformationErrorEvent = + videoTransformationError.getOrThrow("videoTransformationError") + + /** + * Triggered when a pre-transformation completes successfully. The file has been processed with + * the requested transformation and is now available in the Media Library. + */ + fun asUploadPreTransformSuccess(): UploadPreTransformSuccessEvent = + uploadPreTransformSuccess.getOrThrow("uploadPreTransformSuccess") + + /** + * Triggered when a pre-transformation fails. The file upload may have been accepted, but the + * requested transformation could not be applied. + */ + fun asUploadPreTransformError(): UploadPreTransformErrorEvent = + uploadPreTransformError.getOrThrow("uploadPreTransformError") + + /** + * Triggered when a post-transformation completes successfully. The transformed version of the + * file is now ready and can be accessed via the provided URL. Note that each + * post-transformation generates a separate webhook event. + */ + fun asUploadPostTransformSuccess(): UploadPostTransformSuccessEvent = + uploadPostTransformSuccess.getOrThrow("uploadPostTransformSuccess") + + /** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ + fun asUploadPostTransformError(): UploadPostTransformErrorEvent = + uploadPostTransformError.getOrThrow("uploadPostTransformError") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + videoTransformationAccepted != null -> + visitor.visitVideoTransformationAccepted(videoTransformationAccepted) + videoTransformationReady != null -> + visitor.visitVideoTransformationReady(videoTransformationReady) + videoTransformationError != null -> + visitor.visitVideoTransformationError(videoTransformationError) + uploadPreTransformSuccess != null -> + visitor.visitUploadPreTransformSuccess(uploadPreTransformSuccess) + uploadPreTransformError != null -> + visitor.visitUploadPreTransformError(uploadPreTransformError) + uploadPostTransformSuccess != null -> + visitor.visitUploadPostTransformSuccess(uploadPostTransformSuccess) + uploadPostTransformError != null -> + visitor.visitUploadPostTransformError(uploadPostTransformError) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnwrapWebhookEvent = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitVideoTransformationAccepted( + videoTransformationAccepted: VideoTransformationAcceptedEvent + ) { + videoTransformationAccepted.validate() + } + + override fun visitVideoTransformationReady( + videoTransformationReady: VideoTransformationReadyEvent + ) { + videoTransformationReady.validate() + } + + override fun visitVideoTransformationError( + videoTransformationError: VideoTransformationErrorEvent + ) { + videoTransformationError.validate() + } + + override fun visitUploadPreTransformSuccess( + uploadPreTransformSuccess: UploadPreTransformSuccessEvent + ) { + uploadPreTransformSuccess.validate() + } + + override fun visitUploadPreTransformError( + uploadPreTransformError: UploadPreTransformErrorEvent + ) { + uploadPreTransformError.validate() + } + + override fun visitUploadPostTransformSuccess( + uploadPostTransformSuccess: UploadPostTransformSuccessEvent + ) { + uploadPostTransformSuccess.validate() + } + + override fun visitUploadPostTransformError( + uploadPostTransformError: UploadPostTransformErrorEvent + ) { + uploadPostTransformError.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitVideoTransformationAccepted( + videoTransformationAccepted: VideoTransformationAcceptedEvent + ) = videoTransformationAccepted.validity() + + override fun visitVideoTransformationReady( + videoTransformationReady: VideoTransformationReadyEvent + ) = videoTransformationReady.validity() + + override fun visitVideoTransformationError( + videoTransformationError: VideoTransformationErrorEvent + ) = videoTransformationError.validity() + + override fun visitUploadPreTransformSuccess( + uploadPreTransformSuccess: UploadPreTransformSuccessEvent + ) = uploadPreTransformSuccess.validity() + + override fun visitUploadPreTransformError( + uploadPreTransformError: UploadPreTransformErrorEvent + ) = uploadPreTransformError.validity() + + override fun visitUploadPostTransformSuccess( + uploadPostTransformSuccess: UploadPostTransformSuccessEvent + ) = uploadPostTransformSuccess.validity() + + override fun visitUploadPostTransformError( + uploadPostTransformError: UploadPostTransformErrorEvent + ) = uploadPostTransformError.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnwrapWebhookEvent && + videoTransformationAccepted == other.videoTransformationAccepted && + videoTransformationReady == other.videoTransformationReady && + videoTransformationError == other.videoTransformationError && + uploadPreTransformSuccess == other.uploadPreTransformSuccess && + uploadPreTransformError == other.uploadPreTransformError && + uploadPostTransformSuccess == other.uploadPostTransformSuccess && + uploadPostTransformError == other.uploadPostTransformError + } + + override fun hashCode(): Int = + Objects.hash( + videoTransformationAccepted, + videoTransformationReady, + videoTransformationError, + uploadPreTransformSuccess, + uploadPreTransformError, + uploadPostTransformSuccess, + uploadPostTransformError, + ) + + override fun toString(): String = + when { + videoTransformationAccepted != null -> + "UnwrapWebhookEvent{videoTransformationAccepted=$videoTransformationAccepted}" + videoTransformationReady != null -> + "UnwrapWebhookEvent{videoTransformationReady=$videoTransformationReady}" + videoTransformationError != null -> + "UnwrapWebhookEvent{videoTransformationError=$videoTransformationError}" + uploadPreTransformSuccess != null -> + "UnwrapWebhookEvent{uploadPreTransformSuccess=$uploadPreTransformSuccess}" + uploadPreTransformError != null -> + "UnwrapWebhookEvent{uploadPreTransformError=$uploadPreTransformError}" + uploadPostTransformSuccess != null -> + "UnwrapWebhookEvent{uploadPostTransformSuccess=$uploadPostTransformSuccess}" + uploadPostTransformError != null -> + "UnwrapWebhookEvent{uploadPostTransformError=$uploadPostTransformError}" + _json != null -> "UnwrapWebhookEvent{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnwrapWebhookEvent") + } + + companion object { + + /** + * Triggered when a new video transformation request is accepted for processing. This event + * confirms that ImageKit has received and queued your transformation request. Use this for + * debugging and tracking transformation lifecycle. + */ + @JvmStatic + fun ofVideoTransformationAccepted( + videoTransformationAccepted: VideoTransformationAcceptedEvent + ) = UnwrapWebhookEvent(videoTransformationAccepted = videoTransformationAccepted) + + /** + * Triggered when video encoding is finished and the transformed resource is ready to be + * served. This is the key event to listen for - update your database or CMS flags when you + * receive this so your application can start showing the transformed video to users. + */ + @JvmStatic + fun ofVideoTransformationReady(videoTransformationReady: VideoTransformationReadyEvent) = + UnwrapWebhookEvent(videoTransformationReady = videoTransformationReady) + + /** + * Triggered when an error occurs during video encoding. Listen to this webhook to log error + * reasons and debug issues. Check your origin and URL endpoint settings if the reason is + * related to download failure. For other errors, contact ImageKit support. + */ + @JvmStatic + fun ofVideoTransformationError(videoTransformationError: VideoTransformationErrorEvent) = + UnwrapWebhookEvent(videoTransformationError = videoTransformationError) + + /** + * Triggered when a pre-transformation completes successfully. The file has been processed + * with the requested transformation and is now available in the Media Library. + */ + @JvmStatic + fun ofUploadPreTransformSuccess(uploadPreTransformSuccess: UploadPreTransformSuccessEvent) = + UnwrapWebhookEvent(uploadPreTransformSuccess = uploadPreTransformSuccess) + + /** + * Triggered when a pre-transformation fails. The file upload may have been accepted, but + * the requested transformation could not be applied. + */ + @JvmStatic + fun ofUploadPreTransformError(uploadPreTransformError: UploadPreTransformErrorEvent) = + UnwrapWebhookEvent(uploadPreTransformError = uploadPreTransformError) + + /** + * Triggered when a post-transformation completes successfully. The transformed version of + * the file is now ready and can be accessed via the provided URL. Note that each + * post-transformation generates a separate webhook event. + */ + @JvmStatic + fun ofUploadPostTransformSuccess( + uploadPostTransformSuccess: UploadPostTransformSuccessEvent + ) = UnwrapWebhookEvent(uploadPostTransformSuccess = uploadPostTransformSuccess) + + /** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ + @JvmStatic + fun ofUploadPostTransformError(uploadPostTransformError: UploadPostTransformErrorEvent) = + UnwrapWebhookEvent(uploadPostTransformError = uploadPostTransformError) + } + + /** + * An interface that defines how to map each variant of [UnwrapWebhookEvent] to a value of type + * [T]. + */ + interface Visitor { + + /** + * Triggered when a new video transformation request is accepted for processing. This event + * confirms that ImageKit has received and queued your transformation request. Use this for + * debugging and tracking transformation lifecycle. + */ + fun visitVideoTransformationAccepted( + videoTransformationAccepted: VideoTransformationAcceptedEvent + ): T + + /** + * Triggered when video encoding is finished and the transformed resource is ready to be + * served. This is the key event to listen for - update your database or CMS flags when you + * receive this so your application can start showing the transformed video to users. + */ + fun visitVideoTransformationReady( + videoTransformationReady: VideoTransformationReadyEvent + ): T + + /** + * Triggered when an error occurs during video encoding. Listen to this webhook to log error + * reasons and debug issues. Check your origin and URL endpoint settings if the reason is + * related to download failure. For other errors, contact ImageKit support. + */ + fun visitVideoTransformationError( + videoTransformationError: VideoTransformationErrorEvent + ): T + + /** + * Triggered when a pre-transformation completes successfully. The file has been processed + * with the requested transformation and is now available in the Media Library. + */ + fun visitUploadPreTransformSuccess( + uploadPreTransformSuccess: UploadPreTransformSuccessEvent + ): T + + /** + * Triggered when a pre-transformation fails. The file upload may have been accepted, but + * the requested transformation could not be applied. + */ + fun visitUploadPreTransformError(uploadPreTransformError: UploadPreTransformErrorEvent): T + + /** + * Triggered when a post-transformation completes successfully. The transformed version of + * the file is now ready and can be accessed via the provided URL. Note that each + * post-transformation generates a separate webhook event. + */ + fun visitUploadPostTransformSuccess( + uploadPostTransformSuccess: UploadPostTransformSuccessEvent + ): T + + /** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ + fun visitUploadPostTransformError( + uploadPostTransformError: UploadPostTransformErrorEvent + ): T + + /** + * Maps an unknown variant of [UnwrapWebhookEvent] to a value of type [T]. + * + * An instance of [UnwrapWebhookEvent] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is unaware + * of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown UnwrapWebhookEvent: $json") + } + } + + internal class Deserializer : BaseDeserializer(UnwrapWebhookEvent::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): UnwrapWebhookEvent { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnwrapWebhookEvent(videoTransformationAccepted = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnwrapWebhookEvent(videoTransformationReady = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnwrapWebhookEvent(videoTransformationError = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnwrapWebhookEvent(uploadPreTransformSuccess = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnwrapWebhookEvent(uploadPreTransformError = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnwrapWebhookEvent(uploadPostTransformSuccess = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnwrapWebhookEvent(uploadPostTransformError = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> UnwrapWebhookEvent(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(UnwrapWebhookEvent::class) { + + override fun serialize( + value: UnwrapWebhookEvent, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.videoTransformationAccepted != null -> + generator.writeObject(value.videoTransformationAccepted) + value.videoTransformationReady != null -> + generator.writeObject(value.videoTransformationReady) + value.videoTransformationError != null -> + generator.writeObject(value.videoTransformationError) + value.uploadPreTransformSuccess != null -> + generator.writeObject(value.uploadPreTransformSuccess) + value.uploadPreTransformError != null -> + generator.writeObject(value.uploadPreTransformError) + value.uploadPostTransformSuccess != null -> + generator.writeObject(value.uploadPostTransformSuccess) + value.uploadPostTransformError != null -> + generator.writeObject(value.uploadPostTransformError) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid UnwrapWebhookEvent") + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt new file mode 100644 index 00000000..f1798541 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt @@ -0,0 +1,1691 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ +class UploadPostTransformErrorEvent +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val data: JsonField, + private val request: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("request") @ExcludeMissing request: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, createdAt, data, request, type, mutableMapOf()) + + /** + * Unique identifier for the event. + * + * @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") + + /** + * Timestamp of when the event occurred in ISO8601 format. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @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 data(): Data = data.getRequired("data") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun request(): Request = request.getRequired("request") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("upload.post-transform.error") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [request]. + * + * Unlike [request], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("request") @ExcludeMissing fun _request(): JsonField = request + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UploadPostTransformErrorEvent]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UploadPostTransformErrorEvent]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var data: JsonField? = null + private var request: JsonField? = null + private var type: JsonValue = JsonValue.from("upload.post-transform.error") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(uploadPostTransformErrorEvent: UploadPostTransformErrorEvent) = apply { + id = uploadPostTransformErrorEvent.id + createdAt = uploadPostTransformErrorEvent.createdAt + data = uploadPostTransformErrorEvent.data + request = uploadPostTransformErrorEvent.request + type = uploadPostTransformErrorEvent.type + additionalProperties = uploadPostTransformErrorEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the event. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** Timestamp of when the event occurred in ISO8601 format. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun request(request: Request) = request(JsonField.of(request)) + + /** + * Sets [Builder.request] to an arbitrary JSON value. + * + * You should usually call [Builder.request] with a well-typed [Request] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun request(request: JsonField) = apply { this.request = request } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("upload.post-transform.error") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UploadPostTransformErrorEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UploadPostTransformErrorEvent = + UploadPostTransformErrorEvent( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("data", data), + checkRequired("request", request), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UploadPostTransformErrorEvent = apply { + if (validated) { + return@apply + } + + id() + createdAt() + data().validate() + request().validate() + _type().let { + if (it != JsonValue.from("upload.post-transform.error")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (request.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("upload.post-transform.error")) 1 else 0 } + + class Data + private constructor( + private val fileId: JsonField, + private val name: JsonField, + private val path: JsonField, + private val transformation: JsonField, + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("fileId") @ExcludeMissing fileId: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + ) : this(fileId, name, path, transformation, url, mutableMapOf()) + + /** + * Unique identifier of the originally uploaded file. + * + * @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 fileId(): String = fileId.getRequired("fileId") + + /** + * Name of the file. + * + * @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") + + /** + * Path of the file. + * + * @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 path(): String = path.getRequired("path") + + /** + * @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(): Transformation = transformation.getRequired("transformation") + + /** + * URL of the attempted post-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 url(): String = url.getRequired("url") + + /** + * Returns the raw JSON value of [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fileId") @ExcludeMissing fun _fileId(): JsonField = fileId + + /** + * 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 [path]. + * + * Unlike [path], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path + + /** + * 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 [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .fileId() + * .name() + * .path() + * .transformation() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var fileId: JsonField? = null + private var name: JsonField? = null + private var path: JsonField? = null + private var transformation: JsonField? = null + private var url: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + fileId = data.fileId + name = data.name + path = data.path + transformation = data.transformation + url = data.url + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** Unique identifier of the originally uploaded file. */ + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + + /** Name of the file. */ + 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 } + + /** Path of the file. */ + fun path(path: String) = path(JsonField.of(path)) + + /** + * Sets [Builder.path] to an arbitrary JSON value. + * + * You should usually call [Builder.path] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun path(path: JsonField) = apply { this.path = path } + + fun transformation(transformation: Transformation) = + transformation(JsonField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary JSON value. + * + * You should usually call [Builder.transformation] with a well-typed [Transformation] + * 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 + } + + /** URL of the attempted post-transformation. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fileId() + * .name() + * .path() + * .transformation() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("fileId", fileId), + checkRequired("name", name), + checkRequired("path", path), + checkRequired("transformation", transformation), + checkRequired("url", url), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + fileId() + name() + path() + transformation().validate() + url() + 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 (fileId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (path.asKnown().isPresent) 1 else 0) + + (transformation.asKnown().getOrNull()?.validity() ?: 0) + + (if (url.asKnown().isPresent) 1 else 0) + + class Transformation + private constructor( + private val error: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of() + ) : this(error, mutableMapOf()) + + /** + * @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 error(): Error = error.getRequired("error") + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Transformation]. + * + * The following fields are required: + * ```java + * .error() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Transformation]. */ + class Builder internal constructor() { + + private var error: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(transformation: Transformation) = apply { + error = transformation.error + additionalProperties = transformation.additionalProperties.toMutableMap() + } + + fun error(error: Error) = error(JsonField.of(error)) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [Error] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun error(error: JsonField) = apply { this.error = error } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Transformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .error() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Transformation = + Transformation( + checkRequired("error", error), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Transformation = apply { + if (validated) { + return@apply + } + + error().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (error.asKnown().getOrNull()?.validity() ?: 0) + + class Error + private constructor( + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of() + ) : this(reason, mutableMapOf()) + + /** + * Reason for the post-transformation failure. + * + * @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 reason(): String = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Error]. + * + * The following fields are required: + * ```java + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Error]. */ + class Builder internal constructor() { + + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(error: Error) = apply { + reason = error.reason + additionalProperties = error.additionalProperties.toMutableMap() + } + + /** Reason for the post-transformation failure. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Error]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Error = + Error(checkRequired("reason", reason), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Error = apply { + if (validated) { + return@apply + } + + reason() + 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 (reason.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Error && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(reason, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Error{reason=$reason, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Transformation && + error == other.error && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(error, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Transformation{error=$error, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + fileId == other.fileId && + name == other.name && + path == other.path && + transformation == other.transformation && + url == other.url && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(fileId, name, path, transformation, url, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{fileId=$fileId, name=$name, path=$path, transformation=$transformation, url=$url, additionalProperties=$additionalProperties}" + } + + class Request + private constructor( + private val transformation: JsonField, + private val xRequestId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField = JsonMissing.of(), + @JsonProperty("x_request_id") + @ExcludeMissing + xRequestId: JsonField = JsonMissing.of(), + ) : this(transformation, xRequestId, mutableMapOf()) + + /** + * @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(): Transformation = transformation.getRequired("transformation") + + /** + * Unique identifier for the originating request. + * + * @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 xRequestId(): String = xRequestId.getRequired("x_request_id") + + /** + * 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 [xRequestId]. + * + * Unlike [xRequestId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("x_request_id") + @ExcludeMissing + fun _xRequestId(): JsonField = xRequestId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Request]. + * + * The following fields are required: + * ```java + * .transformation() + * .xRequestId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Request]. */ + class Builder internal constructor() { + + private var transformation: JsonField? = null + private var xRequestId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(request: Request) = apply { + transformation = request.transformation + xRequestId = request.xRequestId + additionalProperties = request.additionalProperties.toMutableMap() + } + + fun transformation(transformation: Transformation) = + transformation(JsonField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary JSON value. + * + * You should usually call [Builder.transformation] with a well-typed [Transformation] + * 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 + } + + /** Unique identifier for the originating request. */ + fun xRequestId(xRequestId: String) = xRequestId(JsonField.of(xRequestId)) + + /** + * Sets [Builder.xRequestId] to an arbitrary JSON value. + * + * You should usually call [Builder.xRequestId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun xRequestId(xRequestId: JsonField) = apply { this.xRequestId = xRequestId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Request]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .transformation() + * .xRequestId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Request = + Request( + checkRequired("transformation", transformation), + checkRequired("xRequestId", xRequestId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Request = apply { + if (validated) { + return@apply + } + + transformation().validate() + xRequestId() + 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 = + (transformation.asKnown().getOrNull()?.validity() ?: 0) + + (if (xRequestId.asKnown().isPresent) 1 else 0) + + class Transformation + private constructor( + private val type: JsonField, + private val protocol: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("protocol") + @ExcludeMissing + protocol: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(type, protocol, value, mutableMapOf()) + + /** + * Type of the requested post-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 type(): Type = type.getRequired("type") + + /** + * Only applicable if transformation type is 'abs'. Streaming protocol used. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun protocol(): Optional = protocol.getOptional("protocol") + + /** + * Value for the requested transformation type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun value(): Optional = value.getOptional("value") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [protocol]. + * + * Unlike [protocol], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("protocol") + @ExcludeMissing + fun _protocol(): JsonField = protocol + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Transformation]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Transformation]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var protocol: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(transformation: Transformation) = apply { + type = transformation.type + protocol = transformation.protocol + value = transformation.value + additionalProperties = transformation.additionalProperties.toMutableMap() + } + + /** Type of the requested post-transformation. */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Only applicable if transformation type is 'abs'. Streaming protocol used. */ + fun protocol(protocol: Protocol) = protocol(JsonField.of(protocol)) + + /** + * Sets [Builder.protocol] to an arbitrary JSON value. + * + * You should usually call [Builder.protocol] with a well-typed [Protocol] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun protocol(protocol: JsonField) = apply { this.protocol = protocol } + + /** Value for the requested transformation type. */ + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Transformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Transformation = + Transformation( + checkRequired("type", type), + protocol, + value, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Transformation = apply { + if (validated) { + return@apply + } + + type().validate() + protocol().ifPresent { it.validate() } + value() + 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 = + (type.asKnown().getOrNull()?.validity() ?: 0) + + (protocol.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + + /** Type of the requested post-transformation. */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TRANSFORMATION = of("transformation") + + @JvmField val ABS = of("abs") + + @JvmField val GIF_TO_VIDEO = of("gif-to-video") + + @JvmField val THUMBNAIL = of("thumbnail") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TRANSFORMATION, + ABS, + GIF_TO_VIDEO, + THUMBNAIL, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TRANSFORMATION, + ABS, + GIF_TO_VIDEO, + THUMBNAIL, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TRANSFORMATION -> Value.TRANSFORMATION + ABS -> Value.ABS + GIF_TO_VIDEO -> Value.GIF_TO_VIDEO + THUMBNAIL -> Value.THUMBNAIL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + TRANSFORMATION -> Known.TRANSFORMATION + ABS -> Known.ABS + GIF_TO_VIDEO -> Known.GIF_TO_VIDEO + THUMBNAIL -> Known.THUMBNAIL + else -> throw ImageKitInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Only applicable if transformation type is 'abs'. Streaming protocol used. */ + class Protocol @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val HLS = of("hls") + + @JvmField val DASH = of("dash") + + @JvmStatic fun of(value: String) = Protocol(JsonField.of(value)) + } + + /** An enum containing [Protocol]'s known values. */ + enum class Known { + HLS, + DASH, + } + + /** + * An enum containing [Protocol]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Protocol] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HLS, + DASH, + /** + * An enum member indicating that [Protocol] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HLS -> Value.HLS + DASH -> Value.DASH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + HLS -> Known.HLS + DASH -> Known.DASH + else -> throw ImageKitInvalidDataException("Unknown Protocol: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Protocol = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Protocol && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Transformation && + type == other.type && + protocol == other.protocol && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, protocol, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Transformation{type=$type, protocol=$protocol, value=$value, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Request && + transformation == other.transformation && + xRequestId == other.xRequestId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(transformation, xRequestId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Request{transformation=$transformation, xRequestId=$xRequestId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UploadPostTransformErrorEvent && + id == other.id && + createdAt == other.createdAt && + data == other.data && + request == other.request && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, data, request, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UploadPostTransformErrorEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt new file mode 100644 index 00000000..ca9d87d3 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt @@ -0,0 +1,1290 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Triggered when a post-transformation completes successfully. The transformed version of the file + * is now ready and can be accessed via the provided URL. Note that each post-transformation + * generates a separate webhook event. + */ +class UploadPostTransformSuccessEvent +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val data: JsonField, + private val request: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("request") @ExcludeMissing request: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, createdAt, data, request, type, mutableMapOf()) + + /** + * Unique identifier for the event. + * + * @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") + + /** + * Timestamp of when the event occurred in ISO8601 format. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @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 data(): Data = data.getRequired("data") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun request(): Request = request.getRequired("request") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("upload.post-transform.success") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [request]. + * + * Unlike [request], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("request") @ExcludeMissing fun _request(): JsonField = request + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UploadPostTransformSuccessEvent]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UploadPostTransformSuccessEvent]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var data: JsonField? = null + private var request: JsonField? = null + private var type: JsonValue = JsonValue.from("upload.post-transform.success") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(uploadPostTransformSuccessEvent: UploadPostTransformSuccessEvent) = + apply { + id = uploadPostTransformSuccessEvent.id + createdAt = uploadPostTransformSuccessEvent.createdAt + data = uploadPostTransformSuccessEvent.data + request = uploadPostTransformSuccessEvent.request + type = uploadPostTransformSuccessEvent.type + additionalProperties = + uploadPostTransformSuccessEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the event. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** Timestamp of when the event occurred in ISO8601 format. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun request(request: Request) = request(JsonField.of(request)) + + /** + * Sets [Builder.request] to an arbitrary JSON value. + * + * You should usually call [Builder.request] with a well-typed [Request] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun request(request: JsonField) = apply { this.request = request } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("upload.post-transform.success") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UploadPostTransformSuccessEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UploadPostTransformSuccessEvent = + UploadPostTransformSuccessEvent( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("data", data), + checkRequired("request", request), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UploadPostTransformSuccessEvent = apply { + if (validated) { + return@apply + } + + id() + createdAt() + data().validate() + request().validate() + _type().let { + if (it != JsonValue.from("upload.post-transform.success")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (request.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("upload.post-transform.success")) 1 else 0 } + + class Data + private constructor( + private val fileId: JsonField, + private val name: JsonField, + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("fileId") @ExcludeMissing fileId: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + ) : this(fileId, name, url, mutableMapOf()) + + /** + * Unique identifier of the originally uploaded file. + * + * @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 fileId(): String = fileId.getRequired("fileId") + + /** + * Name of the file. + * + * @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") + + /** + * URL of the generated post-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 url(): String = url.getRequired("url") + + /** + * Returns the raw JSON value of [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fileId") @ExcludeMissing fun _fileId(): JsonField = fileId + + /** + * 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 [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .fileId() + * .name() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var fileId: JsonField? = null + private var name: JsonField? = null + private var url: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + fileId = data.fileId + name = data.name + url = data.url + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** Unique identifier of the originally uploaded file. */ + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + + /** Name of the file. */ + 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 } + + /** URL of the generated post-transformation. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fileId() + * .name() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("fileId", fileId), + checkRequired("name", name), + checkRequired("url", url), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + fileId() + name() + url() + 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 (fileId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + fileId == other.fileId && + name == other.name && + url == other.url && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(fileId, name, url, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{fileId=$fileId, name=$name, url=$url, additionalProperties=$additionalProperties}" + } + + class Request + private constructor( + private val transformation: JsonField, + private val xRequestId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField = JsonMissing.of(), + @JsonProperty("x_request_id") + @ExcludeMissing + xRequestId: JsonField = JsonMissing.of(), + ) : this(transformation, xRequestId, mutableMapOf()) + + /** + * @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(): Transformation = transformation.getRequired("transformation") + + /** + * Unique identifier for the originating request. + * + * @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 xRequestId(): String = xRequestId.getRequired("x_request_id") + + /** + * 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 [xRequestId]. + * + * Unlike [xRequestId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("x_request_id") + @ExcludeMissing + fun _xRequestId(): JsonField = xRequestId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Request]. + * + * The following fields are required: + * ```java + * .transformation() + * .xRequestId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Request]. */ + class Builder internal constructor() { + + private var transformation: JsonField? = null + private var xRequestId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(request: Request) = apply { + transformation = request.transformation + xRequestId = request.xRequestId + additionalProperties = request.additionalProperties.toMutableMap() + } + + fun transformation(transformation: Transformation) = + transformation(JsonField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary JSON value. + * + * You should usually call [Builder.transformation] with a well-typed [Transformation] + * 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 + } + + /** Unique identifier for the originating request. */ + fun xRequestId(xRequestId: String) = xRequestId(JsonField.of(xRequestId)) + + /** + * Sets [Builder.xRequestId] to an arbitrary JSON value. + * + * You should usually call [Builder.xRequestId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun xRequestId(xRequestId: JsonField) = apply { this.xRequestId = xRequestId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Request]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .transformation() + * .xRequestId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Request = + Request( + checkRequired("transformation", transformation), + checkRequired("xRequestId", xRequestId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Request = apply { + if (validated) { + return@apply + } + + transformation().validate() + xRequestId() + 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 = + (transformation.asKnown().getOrNull()?.validity() ?: 0) + + (if (xRequestId.asKnown().isPresent) 1 else 0) + + class Transformation + private constructor( + private val type: JsonField, + private val protocol: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("protocol") + @ExcludeMissing + protocol: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(type, protocol, value, mutableMapOf()) + + /** + * Type of the requested post-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 type(): Type = type.getRequired("type") + + /** + * Only applicable if transformation type is 'abs'. Streaming protocol used. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun protocol(): Optional = protocol.getOptional("protocol") + + /** + * Value for the requested transformation type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun value(): Optional = value.getOptional("value") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [protocol]. + * + * Unlike [protocol], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("protocol") + @ExcludeMissing + fun _protocol(): JsonField = protocol + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Transformation]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Transformation]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var protocol: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(transformation: Transformation) = apply { + type = transformation.type + protocol = transformation.protocol + value = transformation.value + additionalProperties = transformation.additionalProperties.toMutableMap() + } + + /** Type of the requested post-transformation. */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Only applicable if transformation type is 'abs'. Streaming protocol used. */ + fun protocol(protocol: Protocol) = protocol(JsonField.of(protocol)) + + /** + * Sets [Builder.protocol] to an arbitrary JSON value. + * + * You should usually call [Builder.protocol] with a well-typed [Protocol] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun protocol(protocol: JsonField) = apply { this.protocol = protocol } + + /** Value for the requested transformation type. */ + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Transformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Transformation = + Transformation( + checkRequired("type", type), + protocol, + value, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Transformation = apply { + if (validated) { + return@apply + } + + type().validate() + protocol().ifPresent { it.validate() } + value() + 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 = + (type.asKnown().getOrNull()?.validity() ?: 0) + + (protocol.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + + /** Type of the requested post-transformation. */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TRANSFORMATION = of("transformation") + + @JvmField val ABS = of("abs") + + @JvmField val GIF_TO_VIDEO = of("gif-to-video") + + @JvmField val THUMBNAIL = of("thumbnail") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TRANSFORMATION, + ABS, + GIF_TO_VIDEO, + THUMBNAIL, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TRANSFORMATION, + ABS, + GIF_TO_VIDEO, + THUMBNAIL, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TRANSFORMATION -> Value.TRANSFORMATION + ABS -> Value.ABS + GIF_TO_VIDEO -> Value.GIF_TO_VIDEO + THUMBNAIL -> Value.THUMBNAIL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + TRANSFORMATION -> Known.TRANSFORMATION + ABS -> Known.ABS + GIF_TO_VIDEO -> Known.GIF_TO_VIDEO + THUMBNAIL -> Known.THUMBNAIL + else -> throw ImageKitInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Only applicable if transformation type is 'abs'. Streaming protocol used. */ + class Protocol @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val HLS = of("hls") + + @JvmField val DASH = of("dash") + + @JvmStatic fun of(value: String) = Protocol(JsonField.of(value)) + } + + /** An enum containing [Protocol]'s known values. */ + enum class Known { + HLS, + DASH, + } + + /** + * An enum containing [Protocol]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Protocol] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HLS, + DASH, + /** + * An enum member indicating that [Protocol] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HLS -> Value.HLS + DASH -> Value.DASH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + HLS -> Known.HLS + DASH -> Known.DASH + else -> throw ImageKitInvalidDataException("Unknown Protocol: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Protocol = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Protocol && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Transformation && + type == other.type && + protocol == other.protocol && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, protocol, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Transformation{type=$type, protocol=$protocol, value=$value, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Request && + transformation == other.transformation && + xRequestId == other.xRequestId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(transformation, xRequestId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Request{transformation=$transformation, xRequestId=$xRequestId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UploadPostTransformSuccessEvent && + id == other.id && + createdAt == other.createdAt && + data == other.data && + request == other.request && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, data, request, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UploadPostTransformSuccessEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt new file mode 100644 index 00000000..40bc5647 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt @@ -0,0 +1,1101 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * Triggered when a pre-transformation fails. The file upload may have been accepted, but the + * requested transformation could not be applied. + */ +class UploadPreTransformErrorEvent +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val data: JsonField, + private val request: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("request") @ExcludeMissing request: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, createdAt, data, request, type, mutableMapOf()) + + /** + * Unique identifier for the event. + * + * @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") + + /** + * Timestamp of when the event occurred in ISO8601 format. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @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 data(): Data = data.getRequired("data") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun request(): Request = request.getRequired("request") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("upload.pre-transform.error") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [request]. + * + * Unlike [request], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("request") @ExcludeMissing fun _request(): JsonField = request + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UploadPreTransformErrorEvent]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UploadPreTransformErrorEvent]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var data: JsonField? = null + private var request: JsonField? = null + private var type: JsonValue = JsonValue.from("upload.pre-transform.error") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(uploadPreTransformErrorEvent: UploadPreTransformErrorEvent) = apply { + id = uploadPreTransformErrorEvent.id + createdAt = uploadPreTransformErrorEvent.createdAt + data = uploadPreTransformErrorEvent.data + request = uploadPreTransformErrorEvent.request + type = uploadPreTransformErrorEvent.type + additionalProperties = uploadPreTransformErrorEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the event. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** Timestamp of when the event occurred in ISO8601 format. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun request(request: Request) = request(JsonField.of(request)) + + /** + * Sets [Builder.request] to an arbitrary JSON value. + * + * You should usually call [Builder.request] with a well-typed [Request] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun request(request: JsonField) = apply { this.request = request } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("upload.pre-transform.error") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UploadPreTransformErrorEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UploadPreTransformErrorEvent = + UploadPreTransformErrorEvent( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("data", data), + checkRequired("request", request), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UploadPreTransformErrorEvent = apply { + if (validated) { + return@apply + } + + id() + createdAt() + data().validate() + request().validate() + _type().let { + if (it != JsonValue.from("upload.pre-transform.error")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (request.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("upload.pre-transform.error")) 1 else 0 } + + class Data + private constructor( + private val name: JsonField, + private val path: JsonField, + private val transformation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField = JsonMissing.of(), + ) : this(name, path, transformation, mutableMapOf()) + + /** + * Name of the file. + * + * @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") + + /** + * Path of the file. + * + * @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 path(): String = path.getRequired("path") + + /** + * @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(): Transformation = transformation.getRequired("transformation") + + /** + * 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 [path]. + * + * Unlike [path], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path + + /** + * 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 [Data]. + * + * The following fields are required: + * ```java + * .name() + * .path() + * .transformation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var path: JsonField? = null + private var transformation: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + name = data.name + path = data.path + transformation = data.transformation + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** Name of the file. */ + 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 } + + /** Path of the file. */ + fun path(path: String) = path(JsonField.of(path)) + + /** + * Sets [Builder.path] to an arbitrary JSON value. + * + * You should usually call [Builder.path] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun path(path: JsonField) = apply { this.path = path } + + fun transformation(transformation: Transformation) = + transformation(JsonField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary JSON value. + * + * You should usually call [Builder.transformation] with a well-typed [Transformation] + * 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 [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .path() + * .transformation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("name", name), + checkRequired("path", path), + checkRequired("transformation", transformation), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + name() + path() + transformation().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + + (if (path.asKnown().isPresent) 1 else 0) + + (transformation.asKnown().getOrNull()?.validity() ?: 0) + + class Transformation + private constructor( + private val error: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of() + ) : this(error, mutableMapOf()) + + /** + * @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 error(): Error = error.getRequired("error") + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Transformation]. + * + * The following fields are required: + * ```java + * .error() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Transformation]. */ + class Builder internal constructor() { + + private var error: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(transformation: Transformation) = apply { + error = transformation.error + additionalProperties = transformation.additionalProperties.toMutableMap() + } + + fun error(error: Error) = error(JsonField.of(error)) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [Error] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun error(error: JsonField) = apply { this.error = error } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Transformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .error() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Transformation = + Transformation( + checkRequired("error", error), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Transformation = apply { + if (validated) { + return@apply + } + + error().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (error.asKnown().getOrNull()?.validity() ?: 0) + + class Error + private constructor( + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of() + ) : this(reason, mutableMapOf()) + + /** + * Reason for the pre-transformation failure. + * + * @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 reason(): String = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Error]. + * + * The following fields are required: + * ```java + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Error]. */ + class Builder internal constructor() { + + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(error: Error) = apply { + reason = error.reason + additionalProperties = error.additionalProperties.toMutableMap() + } + + /** Reason for the pre-transformation failure. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Error]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Error = + Error(checkRequired("reason", reason), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Error = apply { + if (validated) { + return@apply + } + + reason() + 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 (reason.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Error && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(reason, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Error{reason=$reason, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Transformation && + error == other.error && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(error, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Transformation{error=$error, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + name == other.name && + path == other.path && + transformation == other.transformation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(name, path, transformation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{name=$name, path=$path, transformation=$transformation, additionalProperties=$additionalProperties}" + } + + class Request + private constructor( + private val transformation: JsonField, + private val xRequestId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField = JsonMissing.of(), + @JsonProperty("x_request_id") + @ExcludeMissing + xRequestId: JsonField = JsonMissing.of(), + ) : this(transformation, xRequestId, mutableMapOf()) + + /** + * The requested pre-transformation string. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun transformation(): String = transformation.getRequired("transformation") + + /** + * Unique identifier for the originating request. + * + * @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 xRequestId(): String = xRequestId.getRequired("x_request_id") + + /** + * 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 [xRequestId]. + * + * Unlike [xRequestId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("x_request_id") + @ExcludeMissing + fun _xRequestId(): JsonField = xRequestId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Request]. + * + * The following fields are required: + * ```java + * .transformation() + * .xRequestId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Request]. */ + class Builder internal constructor() { + + private var transformation: JsonField? = null + private var xRequestId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(request: Request) = apply { + transformation = request.transformation + xRequestId = request.xRequestId + additionalProperties = request.additionalProperties.toMutableMap() + } + + /** The requested pre-transformation string. */ + 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 + } + + /** Unique identifier for the originating request. */ + fun xRequestId(xRequestId: String) = xRequestId(JsonField.of(xRequestId)) + + /** + * Sets [Builder.xRequestId] to an arbitrary JSON value. + * + * You should usually call [Builder.xRequestId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun xRequestId(xRequestId: JsonField) = apply { this.xRequestId = xRequestId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Request]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .transformation() + * .xRequestId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Request = + Request( + checkRequired("transformation", transformation), + checkRequired("xRequestId", xRequestId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Request = apply { + if (validated) { + return@apply + } + + transformation() + xRequestId() + 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 (transformation.asKnown().isPresent) 1 else 0) + + (if (xRequestId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Request && + transformation == other.transformation && + xRequestId == other.xRequestId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(transformation, xRequestId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Request{transformation=$transformation, xRequestId=$xRequestId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UploadPreTransformErrorEvent && + id == other.id && + createdAt == other.createdAt && + data == other.data && + request == other.request && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, data, request, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UploadPreTransformErrorEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt new file mode 100644 index 00000000..98121db9 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt @@ -0,0 +1,3219 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.files.Metadata +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Triggered when a pre-transformation completes successfully. The file has been processed with the + * requested transformation and is now available in the Media Library. + */ +class UploadPreTransformSuccessEvent +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val data: JsonField, + private val request: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("request") @ExcludeMissing request: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, createdAt, data, request, type, mutableMapOf()) + + /** + * Unique identifier for the event. + * + * @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") + + /** + * Timestamp of when the event occurred in ISO8601 format. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * Object containing details of a successful upload. + * + * @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 data(): Data = data.getRequired("data") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun request(): Request = request.getRequired("request") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("upload.pre-transform.success") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [request]. + * + * Unlike [request], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("request") @ExcludeMissing fun _request(): JsonField = request + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UploadPreTransformSuccessEvent]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UploadPreTransformSuccessEvent]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var data: JsonField? = null + private var request: JsonField? = null + private var type: JsonValue = JsonValue.from("upload.pre-transform.success") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(uploadPreTransformSuccessEvent: UploadPreTransformSuccessEvent) = apply { + id = uploadPreTransformSuccessEvent.id + createdAt = uploadPreTransformSuccessEvent.createdAt + data = uploadPreTransformSuccessEvent.data + request = uploadPreTransformSuccessEvent.request + type = uploadPreTransformSuccessEvent.type + additionalProperties = + uploadPreTransformSuccessEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the event. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** Timestamp of when the event occurred in ISO8601 format. */ + 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 } + + /** Object containing details of a successful upload. */ + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun request(request: Request) = request(JsonField.of(request)) + + /** + * Sets [Builder.request] to an arbitrary JSON value. + * + * You should usually call [Builder.request] with a well-typed [Request] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun request(request: JsonField) = apply { this.request = request } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("upload.pre-transform.success") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UploadPreTransformSuccessEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UploadPreTransformSuccessEvent = + UploadPreTransformSuccessEvent( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("data", data), + checkRequired("request", request), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UploadPreTransformSuccessEvent = apply { + if (validated) { + return@apply + } + + id() + createdAt() + data().validate() + request().validate() + _type().let { + if (it != JsonValue.from("upload.pre-transform.success")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (request.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("upload.pre-transform.success")) 1 else 0 } + + /** Object containing details of a successful upload. */ + class Data + private constructor( + private val aiTags: JsonField>, + private val audioCodec: JsonField, + private val bitRate: JsonField, + private val customCoordinates: JsonField, + private val customMetadata: JsonField, + private val description: JsonField, + private val duration: JsonField, + private val embeddedMetadata: JsonField, + private val extensionStatus: JsonField, + private val fileId: JsonField, + private val filePath: JsonField, + private val fileType: JsonField, + private val height: JsonField, + private val isPrivateFile: JsonField, + private val isPublished: JsonField, + private val metadata: JsonField, + private val name: JsonField, + private val size: JsonField, + private val tags: JsonField>, + private val thumbnailUrl: JsonField, + private val url: JsonField, + private val versionInfo: JsonField, + private val videoCodec: JsonField, + private val width: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("AITags") + @ExcludeMissing + aiTags: JsonField> = JsonMissing.of(), + @JsonProperty("audioCodec") + @ExcludeMissing + audioCodec: JsonField = JsonMissing.of(), + @JsonProperty("bitRate") @ExcludeMissing bitRate: JsonField = JsonMissing.of(), + @JsonProperty("customCoordinates") + @ExcludeMissing + customCoordinates: JsonField = JsonMissing.of(), + @JsonProperty("customMetadata") + @ExcludeMissing + customMetadata: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), + @JsonProperty("embeddedMetadata") + @ExcludeMissing + embeddedMetadata: JsonField = JsonMissing.of(), + @JsonProperty("extensionStatus") + @ExcludeMissing + extensionStatus: JsonField = JsonMissing.of(), + @JsonProperty("fileId") @ExcludeMissing fileId: JsonField = JsonMissing.of(), + @JsonProperty("filePath") + @ExcludeMissing + filePath: JsonField = JsonMissing.of(), + @JsonProperty("fileType") + @ExcludeMissing + fileType: JsonField = JsonMissing.of(), + @JsonProperty("height") @ExcludeMissing height: JsonField = JsonMissing.of(), + @JsonProperty("isPrivateFile") + @ExcludeMissing + isPrivateFile: JsonField = JsonMissing.of(), + @JsonProperty("isPublished") + @ExcludeMissing + isPublished: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("size") @ExcludeMissing size: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), + @JsonProperty("thumbnailUrl") + @ExcludeMissing + thumbnailUrl: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("versionInfo") + @ExcludeMissing + versionInfo: JsonField = JsonMissing.of(), + @JsonProperty("videoCodec") + @ExcludeMissing + videoCodec: JsonField = JsonMissing.of(), + @JsonProperty("width") @ExcludeMissing width: JsonField = JsonMissing.of(), + ) : this( + aiTags, + audioCodec, + bitRate, + customCoordinates, + customMetadata, + description, + duration, + embeddedMetadata, + extensionStatus, + fileId, + filePath, + fileType, + height, + isPrivateFile, + isPublished, + metadata, + name, + size, + tags, + thumbnailUrl, + url, + versionInfo, + videoCodec, + width, + mutableMapOf(), + ) + + /** + * An array of tags assigned to the uploaded file by auto tagging. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun aiTags(): Optional> = aiTags.getOptional("AITags") + + /** + * The audio codec used in the video (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun audioCodec(): Optional = audioCodec.getOptional("audioCodec") + + /** + * The bit rate of the video in kbps (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun bitRate(): Optional = bitRate.getOptional("bitRate") + + /** + * Value of custom coordinates associated with the image in the format `x,y,width,height`. + * If `customCoordinates` are not defined, then it is `null`. Send `customCoordinates` in + * `responseFields` in API request to get the value of this field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customCoordinates(): Optional = + customCoordinates.getOptional("customCoordinates") + + /** + * A key-value data associated with the asset. Use `responseField` in API request to get + * `customMetadata` in the upload API response. Before setting any custom metadata on an + * asset, you have to create the field using custom metadata fields API. Send + * `customMetadata` in `responseFields` in API request to get the value of this field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customMetadata(): Optional = + customMetadata.getOptional("customMetadata") + + /** + * Optional text to describe the contents of the file. Can be set by the user or the + * ai-auto-description extension. + * + * @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") + + /** + * The duration of the video in seconds (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun duration(): Optional = duration.getOptional("duration") + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp + * data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata + * in the upload API response. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun embeddedMetadata(): Optional = + embeddedMetadata.getOptional("embeddedMetadata") + + /** + * Extension names with their processing status at the time of completion of the request. It + * could have one of the following status values: + * + * `success`: The extension has been successfully applied. `failed`: The extension has + * failed and will not be retried. `pending`: The extension will finish processing in some + * time. On completion, the final status (success / failed) will be sent to the `webhookUrl` + * provided. + * + * If no extension was requested, then this parameter is not returned. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun extensionStatus(): Optional = + extensionStatus.getOptional("extensionStatus") + + /** + * Unique fileId. Store this fileld in your database, as this will be used to perform update + * action on this file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fileId(): Optional = fileId.getOptional("fileId") + + /** + * The relative path of the file in the media library e.g. + * `/marketing-assets/new-banner.jpg`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filePath(): Optional = filePath.getOptional("filePath") + + /** + * Type of the uploaded file. Possible values are `image`, `non-image`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fileType(): Optional = fileType.getOptional("fileType") + + /** + * Height of the image in pixels (Only for images) + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun height(): Optional = height.getOptional("height") + + /** + * Is the file marked as private. It can be either `true` or `false`. Send `isPrivateFile` + * in `responseFields` in API request to get the value of this field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isPrivateFile(): Optional = isPrivateFile.getOptional("isPrivateFile") + + /** + * Is the file published or in draft state. It can be either `true` or `false`. Send + * `isPublished` in `responseFields` in API request to get the value of this field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isPublished(): Optional = isPublished.getOptional("isPublished") + + /** + * Legacy metadata. Send `metadata` in `responseFields` in API request to get metadata in + * the upload API response. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Name of the asset. + * + * @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") + + /** + * Size of the image file in Bytes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun size(): Optional = size.getOptional("size") + + /** + * The array of tags associated with the asset. If no tags are set, it will be `null`. Send + * `tags` in `responseFields` in API request to get the value of this field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tags(): Optional> = tags.getOptional("tags") + + /** + * In the case of an image, a small thumbnail URL. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun thumbnailUrl(): Optional = thumbnailUrl.getOptional("thumbnailUrl") + + /** + * A publicly accessible URL of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * An object containing the file or file version's `id` (versionId) and `name`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun versionInfo(): Optional = versionInfo.getOptional("versionInfo") + + /** + * The video codec used in the video (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun videoCodec(): Optional = videoCodec.getOptional("videoCodec") + + /** + * Width of the image in pixels (Only for Images) + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun width(): Optional = width.getOptional("width") + + /** + * Returns the raw JSON value of [aiTags]. + * + * Unlike [aiTags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("AITags") @ExcludeMissing fun _aiTags(): JsonField> = aiTags + + /** + * Returns the raw JSON value of [audioCodec]. + * + * Unlike [audioCodec], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("audioCodec") + @ExcludeMissing + fun _audioCodec(): JsonField = audioCodec + + /** + * Returns the raw JSON value of [bitRate]. + * + * Unlike [bitRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bitRate") @ExcludeMissing fun _bitRate(): JsonField = bitRate + + /** + * Returns the raw JSON value of [customCoordinates]. + * + * Unlike [customCoordinates], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("customCoordinates") + @ExcludeMissing + fun _customCoordinates(): JsonField = customCoordinates + + /** + * Returns the raw JSON value of [customMetadata]. + * + * Unlike [customMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): JsonField = customMetadata + + /** + * 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 [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [embeddedMetadata]. + * + * Unlike [embeddedMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("embeddedMetadata") + @ExcludeMissing + fun _embeddedMetadata(): JsonField = embeddedMetadata + + /** + * Returns the raw JSON value of [extensionStatus]. + * + * Unlike [extensionStatus], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("extensionStatus") + @ExcludeMissing + fun _extensionStatus(): JsonField = extensionStatus + + /** + * Returns the raw JSON value of [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fileId") @ExcludeMissing fun _fileId(): JsonField = fileId + + /** + * Returns the raw JSON value of [filePath]. + * + * Unlike [filePath], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filePath") @ExcludeMissing fun _filePath(): JsonField = filePath + + /** + * Returns the raw JSON value of [fileType]. + * + * Unlike [fileType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fileType") @ExcludeMissing fun _fileType(): JsonField = fileType + + /** + * Returns the raw JSON value of [height]. + * + * Unlike [height], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("height") @ExcludeMissing fun _height(): JsonField = height + + /** + * Returns the raw JSON value of [isPrivateFile]. + * + * Unlike [isPrivateFile], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("isPrivateFile") + @ExcludeMissing + fun _isPrivateFile(): JsonField = isPrivateFile + + /** + * Returns the raw JSON value of [isPublished]. + * + * Unlike [isPublished], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isPublished") + @ExcludeMissing + fun _isPublished(): JsonField = isPublished + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [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 [size]. + * + * Unlike [size], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("size") @ExcludeMissing fun _size(): JsonField = size + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + + /** + * Returns the raw JSON value of [thumbnailUrl]. + * + * Unlike [thumbnailUrl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("thumbnailUrl") + @ExcludeMissing + fun _thumbnailUrl(): JsonField = thumbnailUrl + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [versionInfo]. + * + * Unlike [versionInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("versionInfo") + @ExcludeMissing + fun _versionInfo(): JsonField = versionInfo + + /** + * Returns the raw JSON value of [videoCodec]. + * + * Unlike [videoCodec], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("videoCodec") + @ExcludeMissing + fun _videoCodec(): JsonField = videoCodec + + /** + * Returns the raw JSON value of [width]. + * + * Unlike [width], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("width") @ExcludeMissing fun _width(): JsonField = width + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var aiTags: JsonField>? = null + private var audioCodec: JsonField = JsonMissing.of() + private var bitRate: JsonField = JsonMissing.of() + private var customCoordinates: JsonField = JsonMissing.of() + private var customMetadata: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var duration: JsonField = JsonMissing.of() + private var embeddedMetadata: JsonField = JsonMissing.of() + private var extensionStatus: JsonField = JsonMissing.of() + private var fileId: JsonField = JsonMissing.of() + private var filePath: JsonField = JsonMissing.of() + private var fileType: JsonField = JsonMissing.of() + private var height: JsonField = JsonMissing.of() + private var isPrivateFile: JsonField = JsonMissing.of() + private var isPublished: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var size: JsonField = JsonMissing.of() + private var tags: JsonField>? = null + private var thumbnailUrl: JsonField = JsonMissing.of() + private var url: JsonField = JsonMissing.of() + private var versionInfo: JsonField = JsonMissing.of() + private var videoCodec: JsonField = JsonMissing.of() + private var width: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + aiTags = data.aiTags.map { it.toMutableList() } + audioCodec = data.audioCodec + bitRate = data.bitRate + customCoordinates = data.customCoordinates + customMetadata = data.customMetadata + description = data.description + duration = data.duration + embeddedMetadata = data.embeddedMetadata + extensionStatus = data.extensionStatus + fileId = data.fileId + filePath = data.filePath + fileType = data.fileType + height = data.height + isPrivateFile = data.isPrivateFile + isPublished = data.isPublished + metadata = data.metadata + name = data.name + size = data.size + tags = data.tags.map { it.toMutableList() } + thumbnailUrl = data.thumbnailUrl + url = data.url + versionInfo = data.versionInfo + videoCodec = data.videoCodec + width = data.width + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** An array of tags assigned to the uploaded file by auto tagging. */ + fun aiTags(aiTags: List?) = aiTags(JsonField.ofNullable(aiTags)) + + /** Alias for calling [Builder.aiTags] with `aiTags.orElse(null)`. */ + fun aiTags(aiTags: Optional>) = aiTags(aiTags.getOrNull()) + + /** + * Sets [Builder.aiTags] to an arbitrary JSON value. + * + * You should usually call [Builder.aiTags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun aiTags(aiTags: JsonField>) = apply { + this.aiTags = aiTags.map { it.toMutableList() } + } + + /** + * Adds a single [AiTag] to [aiTags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAiTag(aiTag: AiTag) = apply { + aiTags = + (aiTags ?: JsonField.of(mutableListOf())).also { + checkKnown("aiTags", it).add(aiTag) + } + } + + /** The audio codec used in the video (only for video). */ + fun audioCodec(audioCodec: String) = audioCodec(JsonField.of(audioCodec)) + + /** + * Sets [Builder.audioCodec] to an arbitrary JSON value. + * + * You should usually call [Builder.audioCodec] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun audioCodec(audioCodec: JsonField) = apply { this.audioCodec = audioCodec } + + /** The bit rate of the video in kbps (only for video). */ + fun bitRate(bitRate: Long) = bitRate(JsonField.of(bitRate)) + + /** + * Sets [Builder.bitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.bitRate] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bitRate(bitRate: JsonField) = apply { this.bitRate = bitRate } + + /** + * Value of custom coordinates associated with the image in the format + * `x,y,width,height`. If `customCoordinates` are not defined, then it is `null`. Send + * `customCoordinates` in `responseFields` in API request to get the value of this + * field. + */ + fun customCoordinates(customCoordinates: String?) = + customCoordinates(JsonField.ofNullable(customCoordinates)) + + /** + * Alias for calling [Builder.customCoordinates] with `customCoordinates.orElse(null)`. + */ + fun customCoordinates(customCoordinates: Optional) = + customCoordinates(customCoordinates.getOrNull()) + + /** + * Sets [Builder.customCoordinates] to an arbitrary JSON value. + * + * You should usually call [Builder.customCoordinates] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customCoordinates(customCoordinates: JsonField) = apply { + this.customCoordinates = customCoordinates + } + + /** + * A key-value data associated with the asset. Use `responseField` in API request to get + * `customMetadata` in the upload API response. Before setting any custom metadata on an + * asset, you have to create the field using custom metadata fields API. Send + * `customMetadata` in `responseFields` in API request to get the value of this field. + */ + fun customMetadata(customMetadata: CustomMetadata) = + customMetadata(JsonField.of(customMetadata)) + + /** + * Sets [Builder.customMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.customMetadata] with a well-typed [CustomMetadata] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun customMetadata(customMetadata: JsonField) = apply { + this.customMetadata = customMetadata + } + + /** + * Optional text to describe the contents of the file. Can be set by the user or the + * ai-auto-description extension. + */ + 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 + } + + /** The duration of the video in seconds (only for video). */ + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and + * xmp data. Send `embeddedMetadata` in `responseFields` in API request to get + * embeddedMetadata in the upload API response. + */ + fun embeddedMetadata(embeddedMetadata: EmbeddedMetadata) = + embeddedMetadata(JsonField.of(embeddedMetadata)) + + /** + * Sets [Builder.embeddedMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.embeddedMetadata] with a well-typed + * [EmbeddedMetadata] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun embeddedMetadata(embeddedMetadata: JsonField) = apply { + this.embeddedMetadata = embeddedMetadata + } + + /** + * Extension names with their processing status at the time of completion of the + * request. It could have one of the following status values: + * + * `success`: The extension has been successfully applied. `failed`: The extension has + * failed and will not be retried. `pending`: The extension will finish processing in + * some time. On completion, the final status (success / failed) will be sent to the + * `webhookUrl` provided. + * + * If no extension was requested, then this parameter is not returned. + */ + fun extensionStatus(extensionStatus: ExtensionStatus) = + extensionStatus(JsonField.of(extensionStatus)) + + /** + * Sets [Builder.extensionStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.extensionStatus] with a well-typed [ExtensionStatus] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun extensionStatus(extensionStatus: JsonField) = apply { + this.extensionStatus = extensionStatus + } + + /** + * Unique fileId. Store this fileld in your database, as this will be used to perform + * update action on this file. + */ + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + + /** + * The relative path of the file in the media library e.g. + * `/marketing-assets/new-banner.jpg`. + */ + fun filePath(filePath: String) = filePath(JsonField.of(filePath)) + + /** + * Sets [Builder.filePath] to an arbitrary JSON value. + * + * You should usually call [Builder.filePath] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun filePath(filePath: JsonField) = apply { this.filePath = filePath } + + /** Type of the uploaded file. Possible values are `image`, `non-image`. */ + fun fileType(fileType: String) = fileType(JsonField.of(fileType)) + + /** + * Sets [Builder.fileType] to an arbitrary JSON value. + * + * You should usually call [Builder.fileType] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fileType(fileType: JsonField) = apply { this.fileType = fileType } + + /** Height of the image in pixels (Only for images) */ + fun height(height: Double) = height(JsonField.of(height)) + + /** + * Sets [Builder.height] to an arbitrary JSON value. + * + * You should usually call [Builder.height] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun height(height: JsonField) = apply { this.height = height } + + /** + * Is the file marked as private. It can be either `true` or `false`. Send + * `isPrivateFile` in `responseFields` in API request to get the value of this field. + */ + fun isPrivateFile(isPrivateFile: Boolean) = isPrivateFile(JsonField.of(isPrivateFile)) + + /** + * Sets [Builder.isPrivateFile] to an arbitrary JSON value. + * + * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPrivateFile(isPrivateFile: JsonField) = apply { + this.isPrivateFile = isPrivateFile + } + + /** + * Is the file published or in draft state. It can be either `true` or `false`. Send + * `isPublished` in `responseFields` in API request to get the value of this field. + */ + fun isPublished(isPublished: Boolean) = isPublished(JsonField.of(isPublished)) + + /** + * Sets [Builder.isPublished] to an arbitrary JSON value. + * + * You should usually call [Builder.isPublished] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPublished(isPublished: JsonField) = apply { + this.isPublished = isPublished + } + + /** + * Legacy metadata. Send `metadata` in `responseFields` in API request to get metadata + * in the upload API response. + */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** Name of the asset. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Size of the image file in Bytes. */ + fun size(size: Double) = size(JsonField.of(size)) + + /** + * Sets [Builder.size] to an arbitrary JSON value. + * + * You should usually call [Builder.size] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun size(size: JsonField) = apply { this.size = size } + + /** + * The array of tags associated with the asset. If no tags are set, it will be `null`. + * Send `tags` in `responseFields` in API request to get the value of this field. + */ + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + /** In the case of an image, a small thumbnail URL. */ + fun thumbnailUrl(thumbnailUrl: String) = thumbnailUrl(JsonField.of(thumbnailUrl)) + + /** + * Sets [Builder.thumbnailUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.thumbnailUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun thumbnailUrl(thumbnailUrl: JsonField) = apply { + this.thumbnailUrl = thumbnailUrl + } + + /** A publicly accessible URL of the file. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** An object containing the file or file version's `id` (versionId) and `name`. */ + fun versionInfo(versionInfo: VersionInfo) = versionInfo(JsonField.of(versionInfo)) + + /** + * Sets [Builder.versionInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.versionInfo] with a well-typed [VersionInfo] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun versionInfo(versionInfo: JsonField) = apply { + this.versionInfo = versionInfo + } + + /** The video codec used in the video (only for video). */ + fun videoCodec(videoCodec: String) = videoCodec(JsonField.of(videoCodec)) + + /** + * Sets [Builder.videoCodec] to an arbitrary JSON value. + * + * You should usually call [Builder.videoCodec] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun videoCodec(videoCodec: JsonField) = apply { this.videoCodec = videoCodec } + + /** Width of the image in pixels (Only for Images) */ + fun width(width: Double) = width(JsonField.of(width)) + + /** + * Sets [Builder.width] to an arbitrary JSON value. + * + * You should usually call [Builder.width] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun width(width: JsonField) = apply { this.width = width } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = + Data( + (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, + audioCodec, + bitRate, + customCoordinates, + customMetadata, + description, + duration, + embeddedMetadata, + extensionStatus, + fileId, + filePath, + fileType, + height, + isPrivateFile, + isPublished, + metadata, + name, + size, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + thumbnailUrl, + url, + versionInfo, + videoCodec, + width, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + aiTags().ifPresent { it.forEach { it.validate() } } + audioCodec() + bitRate() + customCoordinates() + customMetadata().ifPresent { it.validate() } + description() + duration() + embeddedMetadata().ifPresent { it.validate() } + extensionStatus().ifPresent { it.validate() } + fileId() + filePath() + fileType() + height() + isPrivateFile() + isPublished() + metadata().ifPresent { it.validate() } + name() + size() + tags() + thumbnailUrl() + url() + versionInfo().ifPresent { it.validate() } + videoCodec() + width() + 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 = + (aiTags.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (audioCodec.asKnown().isPresent) 1 else 0) + + (if (bitRate.asKnown().isPresent) 1 else 0) + + (if (customCoordinates.asKnown().isPresent) 1 else 0) + + (customMetadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (duration.asKnown().isPresent) 1 else 0) + + (embeddedMetadata.asKnown().getOrNull()?.validity() ?: 0) + + (extensionStatus.asKnown().getOrNull()?.validity() ?: 0) + + (if (fileId.asKnown().isPresent) 1 else 0) + + (if (filePath.asKnown().isPresent) 1 else 0) + + (if (fileType.asKnown().isPresent) 1 else 0) + + (if (height.asKnown().isPresent) 1 else 0) + + (if (isPrivateFile.asKnown().isPresent) 1 else 0) + + (if (isPublished.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (size.asKnown().isPresent) 1 else 0) + + (tags.asKnown().getOrNull()?.size ?: 0) + + (if (thumbnailUrl.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (versionInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (videoCodec.asKnown().isPresent) 1 else 0) + + (if (width.asKnown().isPresent) 1 else 0) + + class AiTag + private constructor( + private val confidence: JsonField, + private val name: JsonField, + private val source: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("confidence") + @ExcludeMissing + confidence: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + ) : this(confidence, name, source, mutableMapOf()) + + /** + * Confidence score of the tag. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun confidence(): Optional = confidence.getOptional("confidence") + + /** + * Name of the tag. + * + * @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") + + /** + * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. + * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` + * extensions. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * Returns the raw JSON value of [confidence]. + * + * Unlike [confidence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("confidence") + @ExcludeMissing + fun _confidence(): JsonField = confidence + + /** + * 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 [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AiTag]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AiTag]. */ + class Builder internal constructor() { + + private var confidence: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var source: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(aiTag: AiTag) = apply { + confidence = aiTag.confidence + name = aiTag.name + source = aiTag.source + additionalProperties = aiTag.additionalProperties.toMutableMap() + } + + /** Confidence score of the tag. */ + fun confidence(confidence: Double) = confidence(JsonField.of(confidence)) + + /** + * Sets [Builder.confidence] to an arbitrary JSON value. + * + * You should usually call [Builder.confidence] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun confidence(confidence: JsonField) = apply { + this.confidence = confidence + } + + /** Name of the tag. */ + 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 } + + /** + * Array of `AITags` associated with the image. If no `AITags` are set, it will be + * null. These tags can be added using the `google-auto-tagging` or + * `aws-auto-tagging` extensions. + */ + fun source(source: String) = source(JsonField.of(source)) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AiTag]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AiTag = + AiTag(confidence, name, source, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): AiTag = apply { + if (validated) { + return@apply + } + + confidence() + name() + source() + 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 (confidence.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (source.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiTag && + confidence == other.confidence && + name == other.name && + source == other.source && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(confidence, name, source, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AiTag{confidence=$confidence, name=$name, source=$source, additionalProperties=$additionalProperties}" + } + + /** + * A key-value data associated with the asset. Use `responseField` in API request to get + * `customMetadata` in the upload API response. Before setting any custom metadata on an + * asset, you have to create the field using custom metadata fields API. Send + * `customMetadata` in `responseFields` in API request to get the value of this field. + */ + class CustomMetadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CustomMetadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customMetadata: CustomMetadata) = apply { + additionalProperties = customMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CustomMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomMetadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" + } + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp + * data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata + * in the upload API response. + */ + class EmbeddedMetadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [EmbeddedMetadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EmbeddedMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(embeddedMetadata: EmbeddedMetadata) = apply { + additionalProperties = embeddedMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EmbeddedMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): EmbeddedMetadata = EmbeddedMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): EmbeddedMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EmbeddedMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "EmbeddedMetadata{additionalProperties=$additionalProperties}" + } + + /** + * Extension names with their processing status at the time of completion of the request. It + * could have one of the following status values: + * + * `success`: The extension has been successfully applied. `failed`: The extension has + * failed and will not be retried. `pending`: The extension will finish processing in some + * time. On completion, the final status (success / failed) will be sent to the `webhookUrl` + * provided. + * + * If no extension was requested, then this parameter is not returned. + */ + class ExtensionStatus + private constructor( + private val aiAutoDescription: JsonField, + private val awsAutoTagging: JsonField, + private val googleAutoTagging: JsonField, + private val removeBg: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("ai-auto-description") + @ExcludeMissing + aiAutoDescription: JsonField = JsonMissing.of(), + @JsonProperty("aws-auto-tagging") + @ExcludeMissing + awsAutoTagging: JsonField = JsonMissing.of(), + @JsonProperty("google-auto-tagging") + @ExcludeMissing + googleAutoTagging: JsonField = JsonMissing.of(), + @JsonProperty("remove-bg") + @ExcludeMissing + removeBg: JsonField = JsonMissing.of(), + ) : this(aiAutoDescription, awsAutoTagging, googleAutoTagging, removeBg, mutableMapOf()) + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun aiAutoDescription(): Optional = + aiAutoDescription.getOptional("ai-auto-description") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun awsAutoTagging(): Optional = + awsAutoTagging.getOptional("aws-auto-tagging") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun googleAutoTagging(): Optional = + googleAutoTagging.getOptional("google-auto-tagging") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun removeBg(): Optional = removeBg.getOptional("remove-bg") + + /** + * Returns the raw JSON value of [aiAutoDescription]. + * + * Unlike [aiAutoDescription], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ai-auto-description") + @ExcludeMissing + fun _aiAutoDescription(): JsonField = aiAutoDescription + + /** + * Returns the raw JSON value of [awsAutoTagging]. + * + * Unlike [awsAutoTagging], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("aws-auto-tagging") + @ExcludeMissing + fun _awsAutoTagging(): JsonField = awsAutoTagging + + /** + * Returns the raw JSON value of [googleAutoTagging]. + * + * Unlike [googleAutoTagging], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("google-auto-tagging") + @ExcludeMissing + fun _googleAutoTagging(): JsonField = googleAutoTagging + + /** + * Returns the raw JSON value of [removeBg]. + * + * Unlike [removeBg], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("remove-bg") + @ExcludeMissing + fun _removeBg(): JsonField = removeBg + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ExtensionStatus]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExtensionStatus]. */ + class Builder internal constructor() { + + private var aiAutoDescription: JsonField = JsonMissing.of() + private var awsAutoTagging: JsonField = JsonMissing.of() + private var googleAutoTagging: JsonField = JsonMissing.of() + private var removeBg: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extensionStatus: ExtensionStatus) = apply { + aiAutoDescription = extensionStatus.aiAutoDescription + awsAutoTagging = extensionStatus.awsAutoTagging + googleAutoTagging = extensionStatus.googleAutoTagging + removeBg = extensionStatus.removeBg + additionalProperties = extensionStatus.additionalProperties.toMutableMap() + } + + fun aiAutoDescription(aiAutoDescription: AiAutoDescription) = + aiAutoDescription(JsonField.of(aiAutoDescription)) + + /** + * Sets [Builder.aiAutoDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.aiAutoDescription] with a well-typed + * [AiAutoDescription] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun aiAutoDescription(aiAutoDescription: JsonField) = apply { + this.aiAutoDescription = aiAutoDescription + } + + fun awsAutoTagging(awsAutoTagging: AwsAutoTagging) = + awsAutoTagging(JsonField.of(awsAutoTagging)) + + /** + * Sets [Builder.awsAutoTagging] to an arbitrary JSON value. + * + * You should usually call [Builder.awsAutoTagging] with a well-typed + * [AwsAutoTagging] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun awsAutoTagging(awsAutoTagging: JsonField) = apply { + this.awsAutoTagging = awsAutoTagging + } + + fun googleAutoTagging(googleAutoTagging: GoogleAutoTagging) = + googleAutoTagging(JsonField.of(googleAutoTagging)) + + /** + * Sets [Builder.googleAutoTagging] to an arbitrary JSON value. + * + * You should usually call [Builder.googleAutoTagging] with a well-typed + * [GoogleAutoTagging] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun googleAutoTagging(googleAutoTagging: JsonField) = apply { + this.googleAutoTagging = googleAutoTagging + } + + fun removeBg(removeBg: RemoveBg) = removeBg(JsonField.of(removeBg)) + + /** + * Sets [Builder.removeBg] to an arbitrary JSON value. + * + * You should usually call [Builder.removeBg] with a well-typed [RemoveBg] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun removeBg(removeBg: JsonField) = apply { this.removeBg = removeBg } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ExtensionStatus]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExtensionStatus = + ExtensionStatus( + aiAutoDescription, + awsAutoTagging, + googleAutoTagging, + removeBg, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExtensionStatus = apply { + if (validated) { + return@apply + } + + aiAutoDescription().ifPresent { it.validate() } + awsAutoTagging().ifPresent { it.validate() } + googleAutoTagging().ifPresent { it.validate() } + removeBg().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (aiAutoDescription.asKnown().getOrNull()?.validity() ?: 0) + + (awsAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (googleAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + + (removeBg.asKnown().getOrNull()?.validity() ?: 0) + + class AiAutoDescription + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val PENDING = of("pending") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = AiAutoDescription(JsonField.of(value)) + } + + /** An enum containing [AiAutoDescription]'s known values. */ + enum class Known { + SUCCESS, + PENDING, + FAILED, + } + + /** + * An enum containing [AiAutoDescription]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AiAutoDescription] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + PENDING, + FAILED, + /** + * An enum member indicating that [AiAutoDescription] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + PENDING -> Value.PENDING + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + PENDING -> Known.PENDING + FAILED -> Known.FAILED + else -> + throw ImageKitInvalidDataException("Unknown AiAutoDescription: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AiAutoDescription = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiAutoDescription && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class AwsAutoTagging + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val PENDING = of("pending") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = AwsAutoTagging(JsonField.of(value)) + } + + /** An enum containing [AwsAutoTagging]'s known values. */ + enum class Known { + SUCCESS, + PENDING, + FAILED, + } + + /** + * An enum containing [AwsAutoTagging]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AwsAutoTagging] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + PENDING, + FAILED, + /** + * An enum member indicating that [AwsAutoTagging] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + PENDING -> Value.PENDING + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + PENDING -> Known.PENDING + FAILED -> Known.FAILED + else -> throw ImageKitInvalidDataException("Unknown AwsAutoTagging: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AwsAutoTagging = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AwsAutoTagging && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class GoogleAutoTagging + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val PENDING = of("pending") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = GoogleAutoTagging(JsonField.of(value)) + } + + /** An enum containing [GoogleAutoTagging]'s known values. */ + enum class Known { + SUCCESS, + PENDING, + FAILED, + } + + /** + * An enum containing [GoogleAutoTagging]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [GoogleAutoTagging] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + PENDING, + FAILED, + /** + * An enum member indicating that [GoogleAutoTagging] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + PENDING -> Value.PENDING + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + PENDING -> Known.PENDING + FAILED -> Known.FAILED + else -> + throw ImageKitInvalidDataException("Unknown GoogleAutoTagging: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): GoogleAutoTagging = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GoogleAutoTagging && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class RemoveBg @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val PENDING = of("pending") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = RemoveBg(JsonField.of(value)) + } + + /** An enum containing [RemoveBg]'s known values. */ + enum class Known { + SUCCESS, + PENDING, + FAILED, + } + + /** + * An enum containing [RemoveBg]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RemoveBg] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + PENDING, + FAILED, + /** + * An enum member indicating that [RemoveBg] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + PENDING -> Value.PENDING + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + PENDING -> Known.PENDING + FAILED -> Known.FAILED + else -> throw ImageKitInvalidDataException("Unknown RemoveBg: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): RemoveBg = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveBg && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExtensionStatus && + aiAutoDescription == other.aiAutoDescription && + awsAutoTagging == other.awsAutoTagging && + googleAutoTagging == other.googleAutoTagging && + removeBg == other.removeBg && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aiAutoDescription, + awsAutoTagging, + googleAutoTagging, + removeBg, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExtensionStatus{aiAutoDescription=$aiAutoDescription, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" + } + + /** An object containing the file or file version's `id` (versionId) and `name`. */ + class VersionInfo + private constructor( + private val id: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, name, mutableMapOf()) + + /** + * Unique identifier of the file version. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * Name of the file version. + * + * @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") + + /** + * 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 [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [VersionInfo]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VersionInfo]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(versionInfo: VersionInfo) = apply { + id = versionInfo.id + name = versionInfo.name + additionalProperties = versionInfo.additionalProperties.toMutableMap() + } + + /** Unique identifier of the file version. */ + 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 } + + /** Name of the file version. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [VersionInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VersionInfo = + VersionInfo(id, name, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): VersionInfo = apply { + if (validated) { + return@apply + } + + id() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VersionInfo && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VersionInfo{id=$id, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + aiTags == other.aiTags && + audioCodec == other.audioCodec && + bitRate == other.bitRate && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + description == other.description && + duration == other.duration && + embeddedMetadata == other.embeddedMetadata && + extensionStatus == other.extensionStatus && + fileId == other.fileId && + filePath == other.filePath && + fileType == other.fileType && + height == other.height && + isPrivateFile == other.isPrivateFile && + isPublished == other.isPublished && + metadata == other.metadata && + name == other.name && + size == other.size && + tags == other.tags && + thumbnailUrl == other.thumbnailUrl && + url == other.url && + versionInfo == other.versionInfo && + videoCodec == other.videoCodec && + width == other.width && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + aiTags, + audioCodec, + bitRate, + customCoordinates, + customMetadata, + description, + duration, + embeddedMetadata, + extensionStatus, + fileId, + filePath, + fileType, + height, + isPrivateFile, + isPublished, + metadata, + name, + size, + tags, + thumbnailUrl, + url, + versionInfo, + videoCodec, + width, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{aiTags=$aiTags, audioCodec=$audioCodec, bitRate=$bitRate, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, duration=$duration, embeddedMetadata=$embeddedMetadata, extensionStatus=$extensionStatus, fileId=$fileId, filePath=$filePath, fileType=$fileType, height=$height, isPrivateFile=$isPrivateFile, isPublished=$isPublished, metadata=$metadata, name=$name, size=$size, tags=$tags, thumbnailUrl=$thumbnailUrl, url=$url, versionInfo=$versionInfo, videoCodec=$videoCodec, width=$width, additionalProperties=$additionalProperties}" + } + + class Request + private constructor( + private val transformation: JsonField, + private val xRequestId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField = JsonMissing.of(), + @JsonProperty("x_request_id") + @ExcludeMissing + xRequestId: JsonField = JsonMissing.of(), + ) : this(transformation, xRequestId, mutableMapOf()) + + /** + * The requested pre-transformation string. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun transformation(): String = transformation.getRequired("transformation") + + /** + * Unique identifier for the originating request. + * + * @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 xRequestId(): String = xRequestId.getRequired("x_request_id") + + /** + * 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 [xRequestId]. + * + * Unlike [xRequestId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("x_request_id") + @ExcludeMissing + fun _xRequestId(): JsonField = xRequestId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Request]. + * + * The following fields are required: + * ```java + * .transformation() + * .xRequestId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Request]. */ + class Builder internal constructor() { + + private var transformation: JsonField? = null + private var xRequestId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(request: Request) = apply { + transformation = request.transformation + xRequestId = request.xRequestId + additionalProperties = request.additionalProperties.toMutableMap() + } + + /** The requested pre-transformation string. */ + 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 + } + + /** Unique identifier for the originating request. */ + fun xRequestId(xRequestId: String) = xRequestId(JsonField.of(xRequestId)) + + /** + * Sets [Builder.xRequestId] to an arbitrary JSON value. + * + * You should usually call [Builder.xRequestId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun xRequestId(xRequestId: JsonField) = apply { this.xRequestId = xRequestId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Request]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .transformation() + * .xRequestId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Request = + Request( + checkRequired("transformation", transformation), + checkRequired("xRequestId", xRequestId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Request = apply { + if (validated) { + return@apply + } + + transformation() + xRequestId() + 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 (transformation.asKnown().isPresent) 1 else 0) + + (if (xRequestId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Request && + transformation == other.transformation && + xRequestId == other.xRequestId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(transformation, xRequestId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Request{transformation=$transformation, xRequestId=$xRequestId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UploadPreTransformSuccessEvent && + id == other.id && + createdAt == other.createdAt && + data == other.data && + request == other.request && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, data, request, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UploadPreTransformSuccessEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt new file mode 100644 index 00000000..f31e7f90 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt @@ -0,0 +1,2303 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Triggered when a new video transformation request is accepted for processing. This event confirms + * that ImageKit has received and queued your transformation request. Use this for debugging and + * tracking transformation lifecycle. + */ +class VideoTransformationAcceptedEvent +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val data: JsonField, + private val request: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("request") @ExcludeMissing request: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, createdAt, data, request, type, mutableMapOf()) + + /** + * Unique identifier for the event. + * + * @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") + + /** + * Timestamp when the event was created in ISO8601 format. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @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 data(): Data = data.getRequired("data") + + /** + * Information about the original request that triggered the video 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 request(): Request = request.getRequired("request") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("video.transformation.accepted") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [request]. + * + * Unlike [request], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("request") @ExcludeMissing fun _request(): JsonField = request + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [VideoTransformationAcceptedEvent]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VideoTransformationAcceptedEvent]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var data: JsonField? = null + private var request: JsonField? = null + private var type: JsonValue = JsonValue.from("video.transformation.accepted") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(videoTransformationAcceptedEvent: VideoTransformationAcceptedEvent) = + apply { + id = videoTransformationAcceptedEvent.id + createdAt = videoTransformationAcceptedEvent.createdAt + data = videoTransformationAcceptedEvent.data + request = videoTransformationAcceptedEvent.request + type = videoTransformationAcceptedEvent.type + additionalProperties = + videoTransformationAcceptedEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the event. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** Timestamp when the event was created in ISO8601 format. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + /** Information about the original request that triggered the video transformation. */ + fun request(request: Request) = request(JsonField.of(request)) + + /** + * Sets [Builder.request] to an arbitrary JSON value. + * + * You should usually call [Builder.request] with a well-typed [Request] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun request(request: JsonField) = apply { this.request = request } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("video.transformation.accepted") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [VideoTransformationAcceptedEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VideoTransformationAcceptedEvent = + VideoTransformationAcceptedEvent( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("data", data), + checkRequired("request", request), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): VideoTransformationAcceptedEvent = apply { + if (validated) { + return@apply + } + + id() + createdAt() + data().validate() + request().validate() + _type().let { + if (it != JsonValue.from("video.transformation.accepted")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (request.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("video.transformation.accepted")) 1 else 0 } + + class Data + private constructor( + private val asset: JsonField, + private val transformation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("asset") @ExcludeMissing asset: JsonField = JsonMissing.of(), + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField = JsonMissing.of(), + ) : this(asset, transformation, mutableMapOf()) + + /** + * Information about the source video asset being transformed. + * + * @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 asset(): Asset = asset.getRequired("asset") + + /** + * Base information about a video transformation request. + * + * @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(): Transformation = transformation.getRequired("transformation") + + /** + * Returns the raw JSON value of [asset]. + * + * Unlike [asset], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("asset") @ExcludeMissing fun _asset(): JsonField = asset + + /** + * 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 [Data]. + * + * The following fields are required: + * ```java + * .asset() + * .transformation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var asset: JsonField? = null + private var transformation: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + asset = data.asset + transformation = data.transformation + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** Information about the source video asset being transformed. */ + fun asset(asset: Asset) = asset(JsonField.of(asset)) + + /** + * Sets [Builder.asset] to an arbitrary JSON value. + * + * You should usually call [Builder.asset] with a well-typed [Asset] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun asset(asset: JsonField) = apply { this.asset = asset } + + /** Base information about a video transformation request. */ + fun transformation(transformation: Transformation) = + transformation(JsonField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary JSON value. + * + * You should usually call [Builder.transformation] with a well-typed [Transformation] + * 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 [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .asset() + * .transformation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("asset", asset), + checkRequired("transformation", transformation), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + asset().validate() + transformation().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (asset.asKnown().getOrNull()?.validity() ?: 0) + + (transformation.asKnown().getOrNull()?.validity() ?: 0) + + /** Information about the source video asset being transformed. */ + class Asset + private constructor( + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of() + ) : this(url, mutableMapOf()) + + /** + * URL to download or access the source video file. + * + * @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 url(): String = url.getRequired("url") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Asset]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Asset]. */ + class Builder internal constructor() { + + private var url: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(asset: Asset) = apply { + url = asset.url + additionalProperties = asset.additionalProperties.toMutableMap() + } + + /** URL to download or access the source video file. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Asset]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Asset = + Asset(checkRequired("url", url), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Asset = apply { + if (validated) { + return@apply + } + + url() + 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 (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Asset && + url == other.url && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(url, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Asset{url=$url, additionalProperties=$additionalProperties}" + } + + /** Base information about a video transformation request. */ + class Transformation + private constructor( + private val type: JsonField, + private val options: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + options: JsonField = JsonMissing.of(), + ) : this(type, options, mutableMapOf()) + + /** + * Type of video transformation: + * - `video-transformation`: Standard video processing (resize, format conversion, etc.) + * - `gif-to-video`: Convert animated GIF to video format + * - `video-thumbnail`: Generate thumbnail image from video + * + * @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 type(): Type = type.getRequired("type") + + /** + * Configuration options for video transformations. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun options(): Optional = options.getOptional("options") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Transformation]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Transformation]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var options: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(transformation: Transformation) = apply { + type = transformation.type + options = transformation.options + additionalProperties = transformation.additionalProperties.toMutableMap() + } + + /** + * Type of video transformation: + * - `video-transformation`: Standard video processing (resize, format conversion, + * etc.) + * - `gif-to-video`: Convert animated GIF to video format + * - `video-thumbnail`: Generate thumbnail image from video + */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Configuration options for video transformations. */ + fun options(options: Options) = options(JsonField.of(options)) + + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [Options] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun options(options: JsonField) = apply { this.options = options } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Transformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Transformation = + Transformation( + checkRequired("type", type), + options, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Transformation = apply { + if (validated) { + return@apply + } + + type().validate() + options().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (type.asKnown().getOrNull()?.validity() ?: 0) + + (options.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Type of video transformation: + * - `video-transformation`: Standard video processing (resize, format conversion, etc.) + * - `gif-to-video`: Convert animated GIF to video format + * - `video-thumbnail`: Generate thumbnail image from video + */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val VIDEO_TRANSFORMATION = of("video-transformation") + + @JvmField val GIF_TO_VIDEO = of("gif-to-video") + + @JvmField val VIDEO_THUMBNAIL = of("video-thumbnail") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + VIDEO_TRANSFORMATION, + GIF_TO_VIDEO, + VIDEO_THUMBNAIL, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + VIDEO_TRANSFORMATION, + GIF_TO_VIDEO, + VIDEO_THUMBNAIL, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + VIDEO_TRANSFORMATION -> Value.VIDEO_TRANSFORMATION + GIF_TO_VIDEO -> Value.GIF_TO_VIDEO + VIDEO_THUMBNAIL -> Value.VIDEO_THUMBNAIL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + VIDEO_TRANSFORMATION -> Known.VIDEO_TRANSFORMATION + GIF_TO_VIDEO -> Known.GIF_TO_VIDEO + VIDEO_THUMBNAIL -> Known.VIDEO_THUMBNAIL + else -> throw ImageKitInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration options for video transformations. */ + class Options + private constructor( + private val audioCodec: JsonField, + private val autoRotate: JsonField, + private val format: JsonField, + private val quality: JsonField, + private val streamProtocol: JsonField, + private val variants: JsonField>, + private val videoCodec: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("audio_codec") + @ExcludeMissing + audioCodec: JsonField = JsonMissing.of(), + @JsonProperty("auto_rotate") + @ExcludeMissing + autoRotate: JsonField = JsonMissing.of(), + @JsonProperty("format") + @ExcludeMissing + format: JsonField = JsonMissing.of(), + @JsonProperty("quality") + @ExcludeMissing + quality: JsonField = JsonMissing.of(), + @JsonProperty("stream_protocol") + @ExcludeMissing + streamProtocol: JsonField = JsonMissing.of(), + @JsonProperty("variants") + @ExcludeMissing + variants: JsonField> = JsonMissing.of(), + @JsonProperty("video_codec") + @ExcludeMissing + videoCodec: JsonField = JsonMissing.of(), + ) : this( + audioCodec, + autoRotate, + format, + quality, + streamProtocol, + variants, + videoCodec, + mutableMapOf(), + ) + + /** + * Audio codec used for encoding (aac or opus). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun audioCodec(): Optional = audioCodec.getOptional("audio_codec") + + /** + * Whether to automatically rotate the video based on metadata. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun autoRotate(): Optional = autoRotate.getOptional("auto_rotate") + + /** + * Output format for the transformed video or thumbnail. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun format(): Optional = format.getOptional("format") + + /** + * Quality setting for the output video. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun quality(): Optional = quality.getOptional("quality") + + /** + * Streaming protocol for adaptive bitrate streaming. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun streamProtocol(): Optional = + streamProtocol.getOptional("stream_protocol") + + /** + * Array of quality representations for adaptive bitrate streaming. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun variants(): Optional> = variants.getOptional("variants") + + /** + * Video codec used for encoding (h264, vp9, or av1). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun videoCodec(): Optional = videoCodec.getOptional("video_codec") + + /** + * Returns the raw JSON value of [audioCodec]. + * + * Unlike [audioCodec], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("audio_codec") + @ExcludeMissing + fun _audioCodec(): JsonField = audioCodec + + /** + * Returns the raw JSON value of [autoRotate]. + * + * Unlike [autoRotate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("auto_rotate") + @ExcludeMissing + fun _autoRotate(): JsonField = autoRotate + + /** + * Returns the raw JSON value of [format]. + * + * Unlike [format], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("format") @ExcludeMissing fun _format(): JsonField = format + + /** + * Returns the raw JSON value of [quality]. + * + * Unlike [quality], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quality") @ExcludeMissing fun _quality(): JsonField = quality + + /** + * Returns the raw JSON value of [streamProtocol]. + * + * Unlike [streamProtocol], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stream_protocol") + @ExcludeMissing + fun _streamProtocol(): JsonField = streamProtocol + + /** + * Returns the raw JSON value of [variants]. + * + * Unlike [variants], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("variants") + @ExcludeMissing + fun _variants(): JsonField> = variants + + /** + * Returns the raw JSON value of [videoCodec]. + * + * Unlike [videoCodec], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("video_codec") + @ExcludeMissing + fun _videoCodec(): JsonField = videoCodec + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Options]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Options]. */ + class Builder internal constructor() { + + private var audioCodec: JsonField = JsonMissing.of() + private var autoRotate: JsonField = JsonMissing.of() + private var format: JsonField = JsonMissing.of() + private var quality: JsonField = JsonMissing.of() + private var streamProtocol: JsonField = JsonMissing.of() + private var variants: JsonField>? = null + private var videoCodec: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(options: Options) = apply { + audioCodec = options.audioCodec + autoRotate = options.autoRotate + format = options.format + quality = options.quality + streamProtocol = options.streamProtocol + variants = options.variants.map { it.toMutableList() } + videoCodec = options.videoCodec + additionalProperties = options.additionalProperties.toMutableMap() + } + + /** Audio codec used for encoding (aac or opus). */ + fun audioCodec(audioCodec: AudioCodec) = audioCodec(JsonField.of(audioCodec)) + + /** + * Sets [Builder.audioCodec] to an arbitrary JSON value. + * + * You should usually call [Builder.audioCodec] with a well-typed [AudioCodec] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun audioCodec(audioCodec: JsonField) = apply { + this.audioCodec = audioCodec + } + + /** Whether to automatically rotate the video based on metadata. */ + fun autoRotate(autoRotate: Boolean) = autoRotate(JsonField.of(autoRotate)) + + /** + * Sets [Builder.autoRotate] to an arbitrary JSON value. + * + * You should usually call [Builder.autoRotate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun autoRotate(autoRotate: JsonField) = apply { + this.autoRotate = autoRotate + } + + /** Output format for the transformed video or thumbnail. */ + fun format(format: Format) = format(JsonField.of(format)) + + /** + * Sets [Builder.format] to an arbitrary JSON value. + * + * You should usually call [Builder.format] with a well-typed [Format] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun format(format: JsonField) = apply { this.format = format } + + /** Quality setting for the output video. */ + fun quality(quality: Long) = quality(JsonField.of(quality)) + + /** + * Sets [Builder.quality] to an arbitrary JSON value. + * + * You should usually call [Builder.quality] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun quality(quality: JsonField) = apply { this.quality = quality } + + /** Streaming protocol for adaptive bitrate streaming. */ + fun streamProtocol(streamProtocol: StreamProtocol) = + streamProtocol(JsonField.of(streamProtocol)) + + /** + * Sets [Builder.streamProtocol] to an arbitrary JSON value. + * + * You should usually call [Builder.streamProtocol] with a well-typed + * [StreamProtocol] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun streamProtocol(streamProtocol: JsonField) = apply { + this.streamProtocol = streamProtocol + } + + /** Array of quality representations for adaptive bitrate streaming. */ + fun variants(variants: List) = variants(JsonField.of(variants)) + + /** + * Sets [Builder.variants] to an arbitrary JSON value. + * + * You should usually call [Builder.variants] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun variants(variants: JsonField>) = apply { + this.variants = variants.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [variants]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVariant(variant: String) = apply { + variants = + (variants ?: JsonField.of(mutableListOf())).also { + checkKnown("variants", it).add(variant) + } + } + + /** Video codec used for encoding (h264, vp9, or av1). */ + fun videoCodec(videoCodec: VideoCodec) = videoCodec(JsonField.of(videoCodec)) + + /** + * Sets [Builder.videoCodec] to an arbitrary JSON value. + * + * You should usually call [Builder.videoCodec] with a well-typed [VideoCodec] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun videoCodec(videoCodec: JsonField) = apply { + this.videoCodec = videoCodec + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Options]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Options = + Options( + audioCodec, + autoRotate, + format, + quality, + streamProtocol, + (variants ?: JsonMissing.of()).map { it.toImmutable() }, + videoCodec, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Options = apply { + if (validated) { + return@apply + } + + audioCodec().ifPresent { it.validate() } + autoRotate() + format().ifPresent { it.validate() } + quality() + streamProtocol().ifPresent { it.validate() } + variants() + videoCodec().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (audioCodec.asKnown().getOrNull()?.validity() ?: 0) + + (if (autoRotate.asKnown().isPresent) 1 else 0) + + (format.asKnown().getOrNull()?.validity() ?: 0) + + (if (quality.asKnown().isPresent) 1 else 0) + + (streamProtocol.asKnown().getOrNull()?.validity() ?: 0) + + (variants.asKnown().getOrNull()?.size ?: 0) + + (videoCodec.asKnown().getOrNull()?.validity() ?: 0) + + /** Audio codec used for encoding (aac or opus). */ + class AudioCodec + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val AAC = of("aac") + + @JvmField val OPUS = of("opus") + + @JvmStatic fun of(value: String) = AudioCodec(JsonField.of(value)) + } + + /** An enum containing [AudioCodec]'s known values. */ + enum class Known { + AAC, + OPUS, + } + + /** + * An enum containing [AudioCodec]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AudioCodec] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AAC, + OPUS, + /** + * An enum member indicating that [AudioCodec] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AAC -> Value.AAC + OPUS -> Value.OPUS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + AAC -> Known.AAC + OPUS -> Known.OPUS + else -> throw ImageKitInvalidDataException("Unknown AudioCodec: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AudioCodec = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AudioCodec && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Output format for the transformed video or thumbnail. */ + class Format + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val MP4 = of("mp4") + + @JvmField val WEBM = of("webm") + + @JvmField val JPG = of("jpg") + + @JvmField val PNG = of("png") + + @JvmField val WEBP = of("webp") + + @JvmStatic fun of(value: String) = Format(JsonField.of(value)) + } + + /** An enum containing [Format]'s known values. */ + enum class Known { + MP4, + WEBM, + JPG, + PNG, + WEBP, + } + + /** + * An enum containing [Format]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Format] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MP4, + WEBM, + JPG, + PNG, + WEBP, + /** + * An enum member indicating that [Format] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MP4 -> Value.MP4 + WEBM -> Value.WEBM + JPG -> Value.JPG + PNG -> Value.PNG + WEBP -> Value.WEBP + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + MP4 -> Known.MP4 + WEBM -> Known.WEBM + JPG -> Known.JPG + PNG -> Known.PNG + WEBP -> Known.WEBP + else -> throw ImageKitInvalidDataException("Unknown Format: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Format = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Format && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Streaming protocol for adaptive bitrate streaming. */ + class StreamProtocol + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HLS = of("HLS") + + @JvmField val DASH = of("DASH") + + @JvmStatic fun of(value: String) = StreamProtocol(JsonField.of(value)) + } + + /** An enum containing [StreamProtocol]'s known values. */ + enum class Known { + HLS, + DASH, + } + + /** + * An enum containing [StreamProtocol]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [StreamProtocol] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HLS, + DASH, + /** + * An enum member indicating that [StreamProtocol] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HLS -> Value.HLS + DASH -> Value.DASH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HLS -> Known.HLS + DASH -> Known.DASH + else -> + throw ImageKitInvalidDataException("Unknown StreamProtocol: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): StreamProtocol = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StreamProtocol && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Video codec used for encoding (h264, vp9, or av1). */ + class VideoCodec + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val H264 = of("h264") + + @JvmField val VP9 = of("vp9") + + @JvmField val AV1 = of("av1") + + @JvmStatic fun of(value: String) = VideoCodec(JsonField.of(value)) + } + + /** An enum containing [VideoCodec]'s known values. */ + enum class Known { + H264, + VP9, + AV1, + } + + /** + * An enum containing [VideoCodec]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [VideoCodec] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + H264, + VP9, + AV1, + /** + * An enum member indicating that [VideoCodec] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + H264 -> Value.H264 + VP9 -> Value.VP9 + AV1 -> Value.AV1 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + H264 -> Known.H264 + VP9 -> Known.VP9 + AV1 -> Known.AV1 + else -> throw ImageKitInvalidDataException("Unknown VideoCodec: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): VideoCodec = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VideoCodec && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Options && + audioCodec == other.audioCodec && + autoRotate == other.autoRotate && + format == other.format && + quality == other.quality && + streamProtocol == other.streamProtocol && + variants == other.variants && + videoCodec == other.videoCodec && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + audioCodec, + autoRotate, + format, + quality, + streamProtocol, + variants, + videoCodec, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Options{audioCodec=$audioCodec, autoRotate=$autoRotate, format=$format, quality=$quality, streamProtocol=$streamProtocol, variants=$variants, videoCodec=$videoCodec, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Transformation && + type == other.type && + options == other.options && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, options, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Transformation{type=$type, options=$options, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + asset == other.asset && + transformation == other.transformation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(asset, transformation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{asset=$asset, transformation=$transformation, additionalProperties=$additionalProperties}" + } + + /** Information about the original request that triggered the video transformation. */ + class Request + private constructor( + private val url: JsonField, + private val xRequestId: JsonField, + private val userAgent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("x_request_id") + @ExcludeMissing + xRequestId: JsonField = JsonMissing.of(), + @JsonProperty("user_agent") + @ExcludeMissing + userAgent: JsonField = JsonMissing.of(), + ) : this(url, xRequestId, userAgent, mutableMapOf()) + + /** + * Full URL of the transformation request that was submitted. + * + * @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 url(): String = url.getRequired("url") + + /** + * Unique identifier for the originating transformation request. + * + * @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 xRequestId(): String = xRequestId.getRequired("x_request_id") + + /** + * User-Agent header from the original request that triggered the transformation. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun userAgent(): Optional = userAgent.getOptional("user_agent") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [xRequestId]. + * + * Unlike [xRequestId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("x_request_id") + @ExcludeMissing + fun _xRequestId(): JsonField = xRequestId + + /** + * Returns the raw JSON value of [userAgent]. + * + * Unlike [userAgent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_agent") @ExcludeMissing fun _userAgent(): JsonField = userAgent + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Request]. + * + * The following fields are required: + * ```java + * .url() + * .xRequestId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Request]. */ + class Builder internal constructor() { + + private var url: JsonField? = null + private var xRequestId: JsonField? = null + private var userAgent: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(request: Request) = apply { + url = request.url + xRequestId = request.xRequestId + userAgent = request.userAgent + additionalProperties = request.additionalProperties.toMutableMap() + } + + /** Full URL of the transformation request that was submitted. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** Unique identifier for the originating transformation request. */ + fun xRequestId(xRequestId: String) = xRequestId(JsonField.of(xRequestId)) + + /** + * Sets [Builder.xRequestId] to an arbitrary JSON value. + * + * You should usually call [Builder.xRequestId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun xRequestId(xRequestId: JsonField) = apply { this.xRequestId = xRequestId } + + /** User-Agent header from the original request that triggered the transformation. */ + fun userAgent(userAgent: String) = userAgent(JsonField.of(userAgent)) + + /** + * Sets [Builder.userAgent] to an arbitrary JSON value. + * + * You should usually call [Builder.userAgent] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun userAgent(userAgent: JsonField) = apply { this.userAgent = userAgent } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Request]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .url() + * .xRequestId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Request = + Request( + checkRequired("url", url), + checkRequired("xRequestId", xRequestId), + userAgent, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Request = apply { + if (validated) { + return@apply + } + + url() + xRequestId() + userAgent() + 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 (url.asKnown().isPresent) 1 else 0) + + (if (xRequestId.asKnown().isPresent) 1 else 0) + + (if (userAgent.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Request && + url == other.url && + xRequestId == other.xRequestId && + userAgent == other.userAgent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(url, xRequestId, userAgent, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Request{url=$url, xRequestId=$xRequestId, userAgent=$userAgent, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VideoTransformationAcceptedEvent && + id == other.id && + createdAt == other.createdAt && + data == other.data && + request == other.request && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, data, request, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VideoTransformationAcceptedEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt new file mode 100644 index 00000000..ee6f310c --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt @@ -0,0 +1,2652 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Triggered when an error occurs during video encoding. Listen to this webhook to log error reasons + * and debug issues. Check your origin and URL endpoint settings if the reason is related to + * download failure. For other errors, contact ImageKit support. + */ +class VideoTransformationErrorEvent +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val data: JsonField, + private val request: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("request") @ExcludeMissing request: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, createdAt, data, request, type, mutableMapOf()) + + /** + * Unique identifier for the event. + * + * @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") + + /** + * Timestamp when the event was created in ISO8601 format. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @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 data(): Data = data.getRequired("data") + + /** + * Information about the original request that triggered the video 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 request(): Request = request.getRequired("request") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("video.transformation.error") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [request]. + * + * Unlike [request], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("request") @ExcludeMissing fun _request(): JsonField = request + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [VideoTransformationErrorEvent]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VideoTransformationErrorEvent]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var data: JsonField? = null + private var request: JsonField? = null + private var type: JsonValue = JsonValue.from("video.transformation.error") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(videoTransformationErrorEvent: VideoTransformationErrorEvent) = apply { + id = videoTransformationErrorEvent.id + createdAt = videoTransformationErrorEvent.createdAt + data = videoTransformationErrorEvent.data + request = videoTransformationErrorEvent.request + type = videoTransformationErrorEvent.type + additionalProperties = videoTransformationErrorEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the event. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** Timestamp when the event was created in ISO8601 format. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + /** Information about the original request that triggered the video transformation. */ + fun request(request: Request) = request(JsonField.of(request)) + + /** + * Sets [Builder.request] to an arbitrary JSON value. + * + * You should usually call [Builder.request] with a well-typed [Request] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun request(request: JsonField) = apply { this.request = request } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("video.transformation.error") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [VideoTransformationErrorEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VideoTransformationErrorEvent = + VideoTransformationErrorEvent( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("data", data), + checkRequired("request", request), + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): VideoTransformationErrorEvent = apply { + if (validated) { + return@apply + } + + id() + createdAt() + data().validate() + request().validate() + _type().let { + if (it != JsonValue.from("video.transformation.error")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (request.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("video.transformation.error")) 1 else 0 } + + class Data + private constructor( + private val asset: JsonField, + private val transformation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("asset") @ExcludeMissing asset: JsonField = JsonMissing.of(), + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField = JsonMissing.of(), + ) : this(asset, transformation, mutableMapOf()) + + /** + * Information about the source video asset being transformed. + * + * @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 asset(): Asset = asset.getRequired("asset") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun transformation(): Transformation = transformation.getRequired("transformation") + + /** + * Returns the raw JSON value of [asset]. + * + * Unlike [asset], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("asset") @ExcludeMissing fun _asset(): JsonField = asset + + /** + * 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 [Data]. + * + * The following fields are required: + * ```java + * .asset() + * .transformation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var asset: JsonField? = null + private var transformation: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + asset = data.asset + transformation = data.transformation + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** Information about the source video asset being transformed. */ + fun asset(asset: Asset) = asset(JsonField.of(asset)) + + /** + * Sets [Builder.asset] to an arbitrary JSON value. + * + * You should usually call [Builder.asset] with a well-typed [Asset] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun asset(asset: JsonField) = apply { this.asset = asset } + + fun transformation(transformation: Transformation) = + transformation(JsonField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary JSON value. + * + * You should usually call [Builder.transformation] with a well-typed [Transformation] + * 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 [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .asset() + * .transformation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("asset", asset), + checkRequired("transformation", transformation), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + asset().validate() + transformation().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (asset.asKnown().getOrNull()?.validity() ?: 0) + + (transformation.asKnown().getOrNull()?.validity() ?: 0) + + /** Information about the source video asset being transformed. */ + class Asset + private constructor( + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of() + ) : this(url, mutableMapOf()) + + /** + * URL to download or access the source video file. + * + * @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 url(): String = url.getRequired("url") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Asset]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Asset]. */ + class Builder internal constructor() { + + private var url: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(asset: Asset) = apply { + url = asset.url + additionalProperties = asset.additionalProperties.toMutableMap() + } + + /** URL to download or access the source video file. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Asset]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Asset = + Asset(checkRequired("url", url), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Asset = apply { + if (validated) { + return@apply + } + + url() + 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 (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Asset && + url == other.url && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(url, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Asset{url=$url, additionalProperties=$additionalProperties}" + } + + class Transformation + private constructor( + private val type: JsonField, + private val error: JsonField, + private val options: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + options: JsonField = JsonMissing.of(), + ) : this(type, error, options, mutableMapOf()) + + /** + * Type of video transformation: + * - `video-transformation`: Standard video processing (resize, format conversion, etc.) + * - `gif-to-video`: Convert animated GIF to video format + * - `video-thumbnail`: Generate thumbnail image from video + * + * @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 type(): Type = type.getRequired("type") + + /** + * Details about the transformation error. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun error(): Optional = error.getOptional("error") + + /** + * Configuration options for video transformations. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun options(): Optional = options.getOptional("options") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Transformation]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Transformation]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var error: JsonField = JsonMissing.of() + private var options: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(transformation: Transformation) = apply { + type = transformation.type + error = transformation.error + options = transformation.options + additionalProperties = transformation.additionalProperties.toMutableMap() + } + + /** + * Type of video transformation: + * - `video-transformation`: Standard video processing (resize, format conversion, + * etc.) + * - `gif-to-video`: Convert animated GIF to video format + * - `video-thumbnail`: Generate thumbnail image from video + */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Details about the transformation error. */ + fun error(error: Error) = error(JsonField.of(error)) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [Error] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun error(error: JsonField) = apply { this.error = error } + + /** Configuration options for video transformations. */ + fun options(options: Options) = options(JsonField.of(options)) + + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [Options] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun options(options: JsonField) = apply { this.options = options } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Transformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Transformation = + Transformation( + checkRequired("type", type), + error, + options, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Transformation = apply { + if (validated) { + return@apply + } + + type().validate() + error().ifPresent { it.validate() } + options().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (type.asKnown().getOrNull()?.validity() ?: 0) + + (error.asKnown().getOrNull()?.validity() ?: 0) + + (options.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Type of video transformation: + * - `video-transformation`: Standard video processing (resize, format conversion, etc.) + * - `gif-to-video`: Convert animated GIF to video format + * - `video-thumbnail`: Generate thumbnail image from video + */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val VIDEO_TRANSFORMATION = of("video-transformation") + + @JvmField val GIF_TO_VIDEO = of("gif-to-video") + + @JvmField val VIDEO_THUMBNAIL = of("video-thumbnail") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + VIDEO_TRANSFORMATION, + GIF_TO_VIDEO, + VIDEO_THUMBNAIL, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + VIDEO_TRANSFORMATION, + GIF_TO_VIDEO, + VIDEO_THUMBNAIL, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + VIDEO_TRANSFORMATION -> Value.VIDEO_TRANSFORMATION + GIF_TO_VIDEO -> Value.GIF_TO_VIDEO + VIDEO_THUMBNAIL -> Value.VIDEO_THUMBNAIL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + VIDEO_TRANSFORMATION -> Known.VIDEO_TRANSFORMATION + GIF_TO_VIDEO -> Known.GIF_TO_VIDEO + VIDEO_THUMBNAIL -> Known.VIDEO_THUMBNAIL + else -> throw ImageKitInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Details about the transformation error. */ + class Error + private constructor( + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of() + ) : this(reason, mutableMapOf()) + + /** + * Specific reason for the transformation failure: + * - `encoding_failed`: Error during video encoding process + * - `download_failed`: Could not download source video + * - `internal_server_error`: Unexpected server error + * + * @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 reason(): Reason = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Error]. + * + * The following fields are required: + * ```java + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Error]. */ + class Builder internal constructor() { + + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(error: Error) = apply { + reason = error.reason + additionalProperties = error.additionalProperties.toMutableMap() + } + + /** + * Specific reason for the transformation failure: + * - `encoding_failed`: Error during video encoding process + * - `download_failed`: Could not download source video + * - `internal_server_error`: Unexpected server error + */ + fun reason(reason: Reason) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [Reason] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Error]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Error = + Error(checkRequired("reason", reason), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Error = apply { + if (validated) { + return@apply + } + + reason().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (reason.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Specific reason for the transformation failure: + * - `encoding_failed`: Error during video encoding process + * - `download_failed`: Could not download source video + * - `internal_server_error`: Unexpected server error + */ + class Reason + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ENCODING_FAILED = of("encoding_failed") + + @JvmField val DOWNLOAD_FAILED = of("download_failed") + + @JvmField val INTERNAL_SERVER_ERROR = of("internal_server_error") + + @JvmStatic fun of(value: String) = Reason(JsonField.of(value)) + } + + /** An enum containing [Reason]'s known values. */ + enum class Known { + ENCODING_FAILED, + DOWNLOAD_FAILED, + INTERNAL_SERVER_ERROR, + } + + /** + * An enum containing [Reason]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Reason] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ENCODING_FAILED, + DOWNLOAD_FAILED, + INTERNAL_SERVER_ERROR, + /** + * An enum member indicating that [Reason] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ENCODING_FAILED -> Value.ENCODING_FAILED + DOWNLOAD_FAILED -> Value.DOWNLOAD_FAILED + INTERNAL_SERVER_ERROR -> Value.INTERNAL_SERVER_ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + ENCODING_FAILED -> Known.ENCODING_FAILED + DOWNLOAD_FAILED -> Known.DOWNLOAD_FAILED + INTERNAL_SERVER_ERROR -> Known.INTERNAL_SERVER_ERROR + else -> throw ImageKitInvalidDataException("Unknown Reason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Reason = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Reason && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Error && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(reason, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Error{reason=$reason, additionalProperties=$additionalProperties}" + } + + /** Configuration options for video transformations. */ + class Options + private constructor( + private val audioCodec: JsonField, + private val autoRotate: JsonField, + private val format: JsonField, + private val quality: JsonField, + private val streamProtocol: JsonField, + private val variants: JsonField>, + private val videoCodec: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("audio_codec") + @ExcludeMissing + audioCodec: JsonField = JsonMissing.of(), + @JsonProperty("auto_rotate") + @ExcludeMissing + autoRotate: JsonField = JsonMissing.of(), + @JsonProperty("format") + @ExcludeMissing + format: JsonField = JsonMissing.of(), + @JsonProperty("quality") + @ExcludeMissing + quality: JsonField = JsonMissing.of(), + @JsonProperty("stream_protocol") + @ExcludeMissing + streamProtocol: JsonField = JsonMissing.of(), + @JsonProperty("variants") + @ExcludeMissing + variants: JsonField> = JsonMissing.of(), + @JsonProperty("video_codec") + @ExcludeMissing + videoCodec: JsonField = JsonMissing.of(), + ) : this( + audioCodec, + autoRotate, + format, + quality, + streamProtocol, + variants, + videoCodec, + mutableMapOf(), + ) + + /** + * Audio codec used for encoding (aac or opus). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun audioCodec(): Optional = audioCodec.getOptional("audio_codec") + + /** + * Whether to automatically rotate the video based on metadata. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun autoRotate(): Optional = autoRotate.getOptional("auto_rotate") + + /** + * Output format for the transformed video or thumbnail. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun format(): Optional = format.getOptional("format") + + /** + * Quality setting for the output video. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun quality(): Optional = quality.getOptional("quality") + + /** + * Streaming protocol for adaptive bitrate streaming. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun streamProtocol(): Optional = + streamProtocol.getOptional("stream_protocol") + + /** + * Array of quality representations for adaptive bitrate streaming. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun variants(): Optional> = variants.getOptional("variants") + + /** + * Video codec used for encoding (h264, vp9, or av1). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun videoCodec(): Optional = videoCodec.getOptional("video_codec") + + /** + * Returns the raw JSON value of [audioCodec]. + * + * Unlike [audioCodec], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("audio_codec") + @ExcludeMissing + fun _audioCodec(): JsonField = audioCodec + + /** + * Returns the raw JSON value of [autoRotate]. + * + * Unlike [autoRotate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("auto_rotate") + @ExcludeMissing + fun _autoRotate(): JsonField = autoRotate + + /** + * Returns the raw JSON value of [format]. + * + * Unlike [format], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("format") @ExcludeMissing fun _format(): JsonField = format + + /** + * Returns the raw JSON value of [quality]. + * + * Unlike [quality], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quality") @ExcludeMissing fun _quality(): JsonField = quality + + /** + * Returns the raw JSON value of [streamProtocol]. + * + * Unlike [streamProtocol], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stream_protocol") + @ExcludeMissing + fun _streamProtocol(): JsonField = streamProtocol + + /** + * Returns the raw JSON value of [variants]. + * + * Unlike [variants], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("variants") + @ExcludeMissing + fun _variants(): JsonField> = variants + + /** + * Returns the raw JSON value of [videoCodec]. + * + * Unlike [videoCodec], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("video_codec") + @ExcludeMissing + fun _videoCodec(): JsonField = videoCodec + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Options]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Options]. */ + class Builder internal constructor() { + + private var audioCodec: JsonField = JsonMissing.of() + private var autoRotate: JsonField = JsonMissing.of() + private var format: JsonField = JsonMissing.of() + private var quality: JsonField = JsonMissing.of() + private var streamProtocol: JsonField = JsonMissing.of() + private var variants: JsonField>? = null + private var videoCodec: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(options: Options) = apply { + audioCodec = options.audioCodec + autoRotate = options.autoRotate + format = options.format + quality = options.quality + streamProtocol = options.streamProtocol + variants = options.variants.map { it.toMutableList() } + videoCodec = options.videoCodec + additionalProperties = options.additionalProperties.toMutableMap() + } + + /** Audio codec used for encoding (aac or opus). */ + fun audioCodec(audioCodec: AudioCodec) = audioCodec(JsonField.of(audioCodec)) + + /** + * Sets [Builder.audioCodec] to an arbitrary JSON value. + * + * You should usually call [Builder.audioCodec] with a well-typed [AudioCodec] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun audioCodec(audioCodec: JsonField) = apply { + this.audioCodec = audioCodec + } + + /** Whether to automatically rotate the video based on metadata. */ + fun autoRotate(autoRotate: Boolean) = autoRotate(JsonField.of(autoRotate)) + + /** + * Sets [Builder.autoRotate] to an arbitrary JSON value. + * + * You should usually call [Builder.autoRotate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun autoRotate(autoRotate: JsonField) = apply { + this.autoRotate = autoRotate + } + + /** Output format for the transformed video or thumbnail. */ + fun format(format: Format) = format(JsonField.of(format)) + + /** + * Sets [Builder.format] to an arbitrary JSON value. + * + * You should usually call [Builder.format] with a well-typed [Format] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun format(format: JsonField) = apply { this.format = format } + + /** Quality setting for the output video. */ + fun quality(quality: Long) = quality(JsonField.of(quality)) + + /** + * Sets [Builder.quality] to an arbitrary JSON value. + * + * You should usually call [Builder.quality] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun quality(quality: JsonField) = apply { this.quality = quality } + + /** Streaming protocol for adaptive bitrate streaming. */ + fun streamProtocol(streamProtocol: StreamProtocol) = + streamProtocol(JsonField.of(streamProtocol)) + + /** + * Sets [Builder.streamProtocol] to an arbitrary JSON value. + * + * You should usually call [Builder.streamProtocol] with a well-typed + * [StreamProtocol] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun streamProtocol(streamProtocol: JsonField) = apply { + this.streamProtocol = streamProtocol + } + + /** Array of quality representations for adaptive bitrate streaming. */ + fun variants(variants: List) = variants(JsonField.of(variants)) + + /** + * Sets [Builder.variants] to an arbitrary JSON value. + * + * You should usually call [Builder.variants] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun variants(variants: JsonField>) = apply { + this.variants = variants.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [variants]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVariant(variant: String) = apply { + variants = + (variants ?: JsonField.of(mutableListOf())).also { + checkKnown("variants", it).add(variant) + } + } + + /** Video codec used for encoding (h264, vp9, or av1). */ + fun videoCodec(videoCodec: VideoCodec) = videoCodec(JsonField.of(videoCodec)) + + /** + * Sets [Builder.videoCodec] to an arbitrary JSON value. + * + * You should usually call [Builder.videoCodec] with a well-typed [VideoCodec] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun videoCodec(videoCodec: JsonField) = apply { + this.videoCodec = videoCodec + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Options]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Options = + Options( + audioCodec, + autoRotate, + format, + quality, + streamProtocol, + (variants ?: JsonMissing.of()).map { it.toImmutable() }, + videoCodec, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Options = apply { + if (validated) { + return@apply + } + + audioCodec().ifPresent { it.validate() } + autoRotate() + format().ifPresent { it.validate() } + quality() + streamProtocol().ifPresent { it.validate() } + variants() + videoCodec().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (audioCodec.asKnown().getOrNull()?.validity() ?: 0) + + (if (autoRotate.asKnown().isPresent) 1 else 0) + + (format.asKnown().getOrNull()?.validity() ?: 0) + + (if (quality.asKnown().isPresent) 1 else 0) + + (streamProtocol.asKnown().getOrNull()?.validity() ?: 0) + + (variants.asKnown().getOrNull()?.size ?: 0) + + (videoCodec.asKnown().getOrNull()?.validity() ?: 0) + + /** Audio codec used for encoding (aac or opus). */ + class AudioCodec + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val AAC = of("aac") + + @JvmField val OPUS = of("opus") + + @JvmStatic fun of(value: String) = AudioCodec(JsonField.of(value)) + } + + /** An enum containing [AudioCodec]'s known values. */ + enum class Known { + AAC, + OPUS, + } + + /** + * An enum containing [AudioCodec]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AudioCodec] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AAC, + OPUS, + /** + * An enum member indicating that [AudioCodec] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AAC -> Value.AAC + OPUS -> Value.OPUS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + AAC -> Known.AAC + OPUS -> Known.OPUS + else -> throw ImageKitInvalidDataException("Unknown AudioCodec: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AudioCodec = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AudioCodec && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Output format for the transformed video or thumbnail. */ + class Format + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val MP4 = of("mp4") + + @JvmField val WEBM = of("webm") + + @JvmField val JPG = of("jpg") + + @JvmField val PNG = of("png") + + @JvmField val WEBP = of("webp") + + @JvmStatic fun of(value: String) = Format(JsonField.of(value)) + } + + /** An enum containing [Format]'s known values. */ + enum class Known { + MP4, + WEBM, + JPG, + PNG, + WEBP, + } + + /** + * An enum containing [Format]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Format] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MP4, + WEBM, + JPG, + PNG, + WEBP, + /** + * An enum member indicating that [Format] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MP4 -> Value.MP4 + WEBM -> Value.WEBM + JPG -> Value.JPG + PNG -> Value.PNG + WEBP -> Value.WEBP + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + MP4 -> Known.MP4 + WEBM -> Known.WEBM + JPG -> Known.JPG + PNG -> Known.PNG + WEBP -> Known.WEBP + else -> throw ImageKitInvalidDataException("Unknown Format: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Format = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Format && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Streaming protocol for adaptive bitrate streaming. */ + class StreamProtocol + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HLS = of("HLS") + + @JvmField val DASH = of("DASH") + + @JvmStatic fun of(value: String) = StreamProtocol(JsonField.of(value)) + } + + /** An enum containing [StreamProtocol]'s known values. */ + enum class Known { + HLS, + DASH, + } + + /** + * An enum containing [StreamProtocol]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [StreamProtocol] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HLS, + DASH, + /** + * An enum member indicating that [StreamProtocol] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HLS -> Value.HLS + DASH -> Value.DASH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HLS -> Known.HLS + DASH -> Known.DASH + else -> + throw ImageKitInvalidDataException("Unknown StreamProtocol: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): StreamProtocol = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StreamProtocol && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Video codec used for encoding (h264, vp9, or av1). */ + class VideoCodec + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val H264 = of("h264") + + @JvmField val VP9 = of("vp9") + + @JvmField val AV1 = of("av1") + + @JvmStatic fun of(value: String) = VideoCodec(JsonField.of(value)) + } + + /** An enum containing [VideoCodec]'s known values. */ + enum class Known { + H264, + VP9, + AV1, + } + + /** + * An enum containing [VideoCodec]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [VideoCodec] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + H264, + VP9, + AV1, + /** + * An enum member indicating that [VideoCodec] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + H264 -> Value.H264 + VP9 -> Value.VP9 + AV1 -> Value.AV1 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + H264 -> Known.H264 + VP9 -> Known.VP9 + AV1 -> Known.AV1 + else -> throw ImageKitInvalidDataException("Unknown VideoCodec: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): VideoCodec = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VideoCodec && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Options && + audioCodec == other.audioCodec && + autoRotate == other.autoRotate && + format == other.format && + quality == other.quality && + streamProtocol == other.streamProtocol && + variants == other.variants && + videoCodec == other.videoCodec && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + audioCodec, + autoRotate, + format, + quality, + streamProtocol, + variants, + videoCodec, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Options{audioCodec=$audioCodec, autoRotate=$autoRotate, format=$format, quality=$quality, streamProtocol=$streamProtocol, variants=$variants, videoCodec=$videoCodec, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Transformation && + type == other.type && + error == other.error && + options == other.options && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, error, options, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Transformation{type=$type, error=$error, options=$options, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + asset == other.asset && + transformation == other.transformation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(asset, transformation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{asset=$asset, transformation=$transformation, additionalProperties=$additionalProperties}" + } + + /** Information about the original request that triggered the video transformation. */ + class Request + private constructor( + private val url: JsonField, + private val xRequestId: JsonField, + private val userAgent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("x_request_id") + @ExcludeMissing + xRequestId: JsonField = JsonMissing.of(), + @JsonProperty("user_agent") + @ExcludeMissing + userAgent: JsonField = JsonMissing.of(), + ) : this(url, xRequestId, userAgent, mutableMapOf()) + + /** + * Full URL of the transformation request that was submitted. + * + * @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 url(): String = url.getRequired("url") + + /** + * Unique identifier for the originating transformation request. + * + * @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 xRequestId(): String = xRequestId.getRequired("x_request_id") + + /** + * User-Agent header from the original request that triggered the transformation. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun userAgent(): Optional = userAgent.getOptional("user_agent") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [xRequestId]. + * + * Unlike [xRequestId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("x_request_id") + @ExcludeMissing + fun _xRequestId(): JsonField = xRequestId + + /** + * Returns the raw JSON value of [userAgent]. + * + * Unlike [userAgent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_agent") @ExcludeMissing fun _userAgent(): JsonField = userAgent + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Request]. + * + * The following fields are required: + * ```java + * .url() + * .xRequestId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Request]. */ + class Builder internal constructor() { + + private var url: JsonField? = null + private var xRequestId: JsonField? = null + private var userAgent: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(request: Request) = apply { + url = request.url + xRequestId = request.xRequestId + userAgent = request.userAgent + additionalProperties = request.additionalProperties.toMutableMap() + } + + /** Full URL of the transformation request that was submitted. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** Unique identifier for the originating transformation request. */ + fun xRequestId(xRequestId: String) = xRequestId(JsonField.of(xRequestId)) + + /** + * Sets [Builder.xRequestId] to an arbitrary JSON value. + * + * You should usually call [Builder.xRequestId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun xRequestId(xRequestId: JsonField) = apply { this.xRequestId = xRequestId } + + /** User-Agent header from the original request that triggered the transformation. */ + fun userAgent(userAgent: String) = userAgent(JsonField.of(userAgent)) + + /** + * Sets [Builder.userAgent] to an arbitrary JSON value. + * + * You should usually call [Builder.userAgent] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun userAgent(userAgent: JsonField) = apply { this.userAgent = userAgent } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Request]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .url() + * .xRequestId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Request = + Request( + checkRequired("url", url), + checkRequired("xRequestId", xRequestId), + userAgent, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Request = apply { + if (validated) { + return@apply + } + + url() + xRequestId() + userAgent() + 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 (url.asKnown().isPresent) 1 else 0) + + (if (xRequestId.asKnown().isPresent) 1 else 0) + + (if (userAgent.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Request && + url == other.url && + xRequestId == other.xRequestId && + userAgent == other.userAgent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(url, xRequestId, userAgent, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Request{url=$url, xRequestId=$xRequestId, userAgent=$userAgent, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VideoTransformationErrorEvent && + id == other.id && + createdAt == other.createdAt && + data == other.data && + request == other.request && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, data, request, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VideoTransformationErrorEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt new file mode 100644 index 00000000..82654cde --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt @@ -0,0 +1,3080 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Triggered when video encoding is finished and the transformed resource is ready to be served. + * This is the key event to listen for - update your database or CMS flags when you receive this so + * your application can start showing the transformed video to users. + */ +class VideoTransformationReadyEvent +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val data: JsonField, + private val request: JsonField, + private val type: JsonValue, + private val timings: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("request") @ExcludeMissing request: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("timings") @ExcludeMissing timings: JsonField = JsonMissing.of(), + ) : this(id, createdAt, data, request, type, timings, mutableMapOf()) + + /** + * Unique identifier for the event. + * + * @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") + + /** + * Timestamp when the event was created in ISO8601 format. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @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 data(): Data = data.getRequired("data") + + /** + * Information about the original request that triggered the video 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 request(): Request = request.getRequired("request") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("video.transformation.ready") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Performance metrics for the transformation process. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timings(): Optional = timings.getOptional("timings") + + /** + * 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("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [request]. + * + * Unlike [request], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("request") @ExcludeMissing fun _request(): JsonField = request + + /** + * Returns the raw JSON value of [timings]. + * + * Unlike [timings], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timings") @ExcludeMissing fun _timings(): JsonField = timings + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [VideoTransformationReadyEvent]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VideoTransformationReadyEvent]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var data: JsonField? = null + private var request: JsonField? = null + private var type: JsonValue = JsonValue.from("video.transformation.ready") + private var timings: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(videoTransformationReadyEvent: VideoTransformationReadyEvent) = apply { + id = videoTransformationReadyEvent.id + createdAt = videoTransformationReadyEvent.createdAt + data = videoTransformationReadyEvent.data + request = videoTransformationReadyEvent.request + type = videoTransformationReadyEvent.type + timings = videoTransformationReadyEvent.timings + additionalProperties = videoTransformationReadyEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the event. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** Timestamp when the event was created in ISO8601 format. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + /** Information about the original request that triggered the video transformation. */ + fun request(request: Request) = request(JsonField.of(request)) + + /** + * Sets [Builder.request] to an arbitrary JSON value. + * + * You should usually call [Builder.request] with a well-typed [Request] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun request(request: JsonField) = apply { this.request = request } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("video.transformation.ready") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Performance metrics for the transformation process. */ + fun timings(timings: Timings) = timings(JsonField.of(timings)) + + /** + * Sets [Builder.timings] to an arbitrary JSON value. + * + * You should usually call [Builder.timings] with a well-typed [Timings] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun timings(timings: JsonField) = apply { this.timings = timings } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [VideoTransformationReadyEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .data() + * .request() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VideoTransformationReadyEvent = + VideoTransformationReadyEvent( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("data", data), + checkRequired("request", request), + type, + timings, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): VideoTransformationReadyEvent = apply { + if (validated) { + return@apply + } + + id() + createdAt() + data().validate() + request().validate() + _type().let { + if (it != JsonValue.from("video.transformation.ready")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + timings().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (request.asKnown().getOrNull()?.validity() ?: 0) + + type.let { if (it == JsonValue.from("video.transformation.ready")) 1 else 0 } + + (timings.asKnown().getOrNull()?.validity() ?: 0) + + class Data + private constructor( + private val asset: JsonField, + private val transformation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("asset") @ExcludeMissing asset: JsonField = JsonMissing.of(), + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField = JsonMissing.of(), + ) : this(asset, transformation, mutableMapOf()) + + /** + * Information about the source video asset being transformed. + * + * @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 asset(): Asset = asset.getRequired("asset") + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun transformation(): Transformation = transformation.getRequired("transformation") + + /** + * Returns the raw JSON value of [asset]. + * + * Unlike [asset], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("asset") @ExcludeMissing fun _asset(): JsonField = asset + + /** + * 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 [Data]. + * + * The following fields are required: + * ```java + * .asset() + * .transformation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var asset: JsonField? = null + private var transformation: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + asset = data.asset + transformation = data.transformation + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** Information about the source video asset being transformed. */ + fun asset(asset: Asset) = asset(JsonField.of(asset)) + + /** + * Sets [Builder.asset] to an arbitrary JSON value. + * + * You should usually call [Builder.asset] with a well-typed [Asset] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun asset(asset: JsonField) = apply { this.asset = asset } + + fun transformation(transformation: Transformation) = + transformation(JsonField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary JSON value. + * + * You should usually call [Builder.transformation] with a well-typed [Transformation] + * 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 [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .asset() + * .transformation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("asset", asset), + checkRequired("transformation", transformation), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + asset().validate() + transformation().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (asset.asKnown().getOrNull()?.validity() ?: 0) + + (transformation.asKnown().getOrNull()?.validity() ?: 0) + + /** Information about the source video asset being transformed. */ + class Asset + private constructor( + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of() + ) : this(url, mutableMapOf()) + + /** + * URL to download or access the source video file. + * + * @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 url(): String = url.getRequired("url") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Asset]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Asset]. */ + class Builder internal constructor() { + + private var url: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(asset: Asset) = apply { + url = asset.url + additionalProperties = asset.additionalProperties.toMutableMap() + } + + /** URL to download or access the source video file. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Asset]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Asset = + Asset(checkRequired("url", url), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Asset = apply { + if (validated) { + return@apply + } + + url() + 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 (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Asset && + url == other.url && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(url, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Asset{url=$url, additionalProperties=$additionalProperties}" + } + + class Transformation + private constructor( + private val type: JsonField, + private val options: JsonField, + private val output: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + options: JsonField = JsonMissing.of(), + @JsonProperty("output") @ExcludeMissing output: JsonField = JsonMissing.of(), + ) : this(type, options, output, mutableMapOf()) + + /** + * Type of video transformation: + * - `video-transformation`: Standard video processing (resize, format conversion, etc.) + * - `gif-to-video`: Convert animated GIF to video format + * - `video-thumbnail`: Generate thumbnail image from video + * + * @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 type(): Type = type.getRequired("type") + + /** + * Configuration options for video transformations. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun options(): Optional = options.getOptional("options") + + /** + * Information about the transformed output video. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun output(): Optional = output.getOptional("output") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options + + /** + * Returns the raw JSON value of [output]. + * + * Unlike [output], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("output") @ExcludeMissing fun _output(): JsonField = output + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Transformation]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Transformation]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var options: JsonField = JsonMissing.of() + private var output: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(transformation: Transformation) = apply { + type = transformation.type + options = transformation.options + output = transformation.output + additionalProperties = transformation.additionalProperties.toMutableMap() + } + + /** + * Type of video transformation: + * - `video-transformation`: Standard video processing (resize, format conversion, + * etc.) + * - `gif-to-video`: Convert animated GIF to video format + * - `video-thumbnail`: Generate thumbnail image from video + */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Configuration options for video transformations. */ + fun options(options: Options) = options(JsonField.of(options)) + + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [Options] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun options(options: JsonField) = apply { this.options = options } + + /** Information about the transformed output video. */ + fun output(output: Output) = output(JsonField.of(output)) + + /** + * Sets [Builder.output] to an arbitrary JSON value. + * + * You should usually call [Builder.output] with a well-typed [Output] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun output(output: JsonField) = apply { this.output = output } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Transformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Transformation = + Transformation( + checkRequired("type", type), + options, + output, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Transformation = apply { + if (validated) { + return@apply + } + + type().validate() + options().ifPresent { it.validate() } + output().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (type.asKnown().getOrNull()?.validity() ?: 0) + + (options.asKnown().getOrNull()?.validity() ?: 0) + + (output.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Type of video transformation: + * - `video-transformation`: Standard video processing (resize, format conversion, etc.) + * - `gif-to-video`: Convert animated GIF to video format + * - `video-thumbnail`: Generate thumbnail image from video + */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val VIDEO_TRANSFORMATION = of("video-transformation") + + @JvmField val GIF_TO_VIDEO = of("gif-to-video") + + @JvmField val VIDEO_THUMBNAIL = of("video-thumbnail") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + VIDEO_TRANSFORMATION, + GIF_TO_VIDEO, + VIDEO_THUMBNAIL, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + VIDEO_TRANSFORMATION, + GIF_TO_VIDEO, + VIDEO_THUMBNAIL, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + VIDEO_TRANSFORMATION -> Value.VIDEO_TRANSFORMATION + GIF_TO_VIDEO -> Value.GIF_TO_VIDEO + VIDEO_THUMBNAIL -> Value.VIDEO_THUMBNAIL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + VIDEO_TRANSFORMATION -> Known.VIDEO_TRANSFORMATION + GIF_TO_VIDEO -> Known.GIF_TO_VIDEO + VIDEO_THUMBNAIL -> Known.VIDEO_THUMBNAIL + else -> throw ImageKitInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Configuration options for video transformations. */ + class Options + private constructor( + private val audioCodec: JsonField, + private val autoRotate: JsonField, + private val format: JsonField, + private val quality: JsonField, + private val streamProtocol: JsonField, + private val variants: JsonField>, + private val videoCodec: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("audio_codec") + @ExcludeMissing + audioCodec: JsonField = JsonMissing.of(), + @JsonProperty("auto_rotate") + @ExcludeMissing + autoRotate: JsonField = JsonMissing.of(), + @JsonProperty("format") + @ExcludeMissing + format: JsonField = JsonMissing.of(), + @JsonProperty("quality") + @ExcludeMissing + quality: JsonField = JsonMissing.of(), + @JsonProperty("stream_protocol") + @ExcludeMissing + streamProtocol: JsonField = JsonMissing.of(), + @JsonProperty("variants") + @ExcludeMissing + variants: JsonField> = JsonMissing.of(), + @JsonProperty("video_codec") + @ExcludeMissing + videoCodec: JsonField = JsonMissing.of(), + ) : this( + audioCodec, + autoRotate, + format, + quality, + streamProtocol, + variants, + videoCodec, + mutableMapOf(), + ) + + /** + * Audio codec used for encoding (aac or opus). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun audioCodec(): Optional = audioCodec.getOptional("audio_codec") + + /** + * Whether to automatically rotate the video based on metadata. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun autoRotate(): Optional = autoRotate.getOptional("auto_rotate") + + /** + * Output format for the transformed video or thumbnail. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun format(): Optional = format.getOptional("format") + + /** + * Quality setting for the output video. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun quality(): Optional = quality.getOptional("quality") + + /** + * Streaming protocol for adaptive bitrate streaming. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun streamProtocol(): Optional = + streamProtocol.getOptional("stream_protocol") + + /** + * Array of quality representations for adaptive bitrate streaming. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun variants(): Optional> = variants.getOptional("variants") + + /** + * Video codec used for encoding (h264, vp9, or av1). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun videoCodec(): Optional = videoCodec.getOptional("video_codec") + + /** + * Returns the raw JSON value of [audioCodec]. + * + * Unlike [audioCodec], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("audio_codec") + @ExcludeMissing + fun _audioCodec(): JsonField = audioCodec + + /** + * Returns the raw JSON value of [autoRotate]. + * + * Unlike [autoRotate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("auto_rotate") + @ExcludeMissing + fun _autoRotate(): JsonField = autoRotate + + /** + * Returns the raw JSON value of [format]. + * + * Unlike [format], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("format") @ExcludeMissing fun _format(): JsonField = format + + /** + * Returns the raw JSON value of [quality]. + * + * Unlike [quality], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quality") @ExcludeMissing fun _quality(): JsonField = quality + + /** + * Returns the raw JSON value of [streamProtocol]. + * + * Unlike [streamProtocol], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("stream_protocol") + @ExcludeMissing + fun _streamProtocol(): JsonField = streamProtocol + + /** + * Returns the raw JSON value of [variants]. + * + * Unlike [variants], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("variants") + @ExcludeMissing + fun _variants(): JsonField> = variants + + /** + * Returns the raw JSON value of [videoCodec]. + * + * Unlike [videoCodec], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("video_codec") + @ExcludeMissing + fun _videoCodec(): JsonField = videoCodec + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Options]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Options]. */ + class Builder internal constructor() { + + private var audioCodec: JsonField = JsonMissing.of() + private var autoRotate: JsonField = JsonMissing.of() + private var format: JsonField = JsonMissing.of() + private var quality: JsonField = JsonMissing.of() + private var streamProtocol: JsonField = JsonMissing.of() + private var variants: JsonField>? = null + private var videoCodec: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(options: Options) = apply { + audioCodec = options.audioCodec + autoRotate = options.autoRotate + format = options.format + quality = options.quality + streamProtocol = options.streamProtocol + variants = options.variants.map { it.toMutableList() } + videoCodec = options.videoCodec + additionalProperties = options.additionalProperties.toMutableMap() + } + + /** Audio codec used for encoding (aac or opus). */ + fun audioCodec(audioCodec: AudioCodec) = audioCodec(JsonField.of(audioCodec)) + + /** + * Sets [Builder.audioCodec] to an arbitrary JSON value. + * + * You should usually call [Builder.audioCodec] with a well-typed [AudioCodec] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun audioCodec(audioCodec: JsonField) = apply { + this.audioCodec = audioCodec + } + + /** Whether to automatically rotate the video based on metadata. */ + fun autoRotate(autoRotate: Boolean) = autoRotate(JsonField.of(autoRotate)) + + /** + * Sets [Builder.autoRotate] to an arbitrary JSON value. + * + * You should usually call [Builder.autoRotate] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun autoRotate(autoRotate: JsonField) = apply { + this.autoRotate = autoRotate + } + + /** Output format for the transformed video or thumbnail. */ + fun format(format: Format) = format(JsonField.of(format)) + + /** + * Sets [Builder.format] to an arbitrary JSON value. + * + * You should usually call [Builder.format] with a well-typed [Format] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun format(format: JsonField) = apply { this.format = format } + + /** Quality setting for the output video. */ + fun quality(quality: Long) = quality(JsonField.of(quality)) + + /** + * Sets [Builder.quality] to an arbitrary JSON value. + * + * You should usually call [Builder.quality] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun quality(quality: JsonField) = apply { this.quality = quality } + + /** Streaming protocol for adaptive bitrate streaming. */ + fun streamProtocol(streamProtocol: StreamProtocol) = + streamProtocol(JsonField.of(streamProtocol)) + + /** + * Sets [Builder.streamProtocol] to an arbitrary JSON value. + * + * You should usually call [Builder.streamProtocol] with a well-typed + * [StreamProtocol] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun streamProtocol(streamProtocol: JsonField) = apply { + this.streamProtocol = streamProtocol + } + + /** Array of quality representations for adaptive bitrate streaming. */ + fun variants(variants: List) = variants(JsonField.of(variants)) + + /** + * Sets [Builder.variants] to an arbitrary JSON value. + * + * You should usually call [Builder.variants] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun variants(variants: JsonField>) = apply { + this.variants = variants.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [variants]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVariant(variant: String) = apply { + variants = + (variants ?: JsonField.of(mutableListOf())).also { + checkKnown("variants", it).add(variant) + } + } + + /** Video codec used for encoding (h264, vp9, or av1). */ + fun videoCodec(videoCodec: VideoCodec) = videoCodec(JsonField.of(videoCodec)) + + /** + * Sets [Builder.videoCodec] to an arbitrary JSON value. + * + * You should usually call [Builder.videoCodec] with a well-typed [VideoCodec] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun videoCodec(videoCodec: JsonField) = apply { + this.videoCodec = videoCodec + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Options]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Options = + Options( + audioCodec, + autoRotate, + format, + quality, + streamProtocol, + (variants ?: JsonMissing.of()).map { it.toImmutable() }, + videoCodec, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Options = apply { + if (validated) { + return@apply + } + + audioCodec().ifPresent { it.validate() } + autoRotate() + format().ifPresent { it.validate() } + quality() + streamProtocol().ifPresent { it.validate() } + variants() + videoCodec().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (audioCodec.asKnown().getOrNull()?.validity() ?: 0) + + (if (autoRotate.asKnown().isPresent) 1 else 0) + + (format.asKnown().getOrNull()?.validity() ?: 0) + + (if (quality.asKnown().isPresent) 1 else 0) + + (streamProtocol.asKnown().getOrNull()?.validity() ?: 0) + + (variants.asKnown().getOrNull()?.size ?: 0) + + (videoCodec.asKnown().getOrNull()?.validity() ?: 0) + + /** Audio codec used for encoding (aac or opus). */ + class AudioCodec + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val AAC = of("aac") + + @JvmField val OPUS = of("opus") + + @JvmStatic fun of(value: String) = AudioCodec(JsonField.of(value)) + } + + /** An enum containing [AudioCodec]'s known values. */ + enum class Known { + AAC, + OPUS, + } + + /** + * An enum containing [AudioCodec]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AudioCodec] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AAC, + OPUS, + /** + * An enum member indicating that [AudioCodec] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AAC -> Value.AAC + OPUS -> Value.OPUS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + AAC -> Known.AAC + OPUS -> Known.OPUS + else -> throw ImageKitInvalidDataException("Unknown AudioCodec: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AudioCodec = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AudioCodec && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Output format for the transformed video or thumbnail. */ + class Format + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val MP4 = of("mp4") + + @JvmField val WEBM = of("webm") + + @JvmField val JPG = of("jpg") + + @JvmField val PNG = of("png") + + @JvmField val WEBP = of("webp") + + @JvmStatic fun of(value: String) = Format(JsonField.of(value)) + } + + /** An enum containing [Format]'s known values. */ + enum class Known { + MP4, + WEBM, + JPG, + PNG, + WEBP, + } + + /** + * An enum containing [Format]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Format] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MP4, + WEBM, + JPG, + PNG, + WEBP, + /** + * An enum member indicating that [Format] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MP4 -> Value.MP4 + WEBM -> Value.WEBM + JPG -> Value.JPG + PNG -> Value.PNG + WEBP -> Value.WEBP + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + MP4 -> Known.MP4 + WEBM -> Known.WEBM + JPG -> Known.JPG + PNG -> Known.PNG + WEBP -> Known.WEBP + else -> throw ImageKitInvalidDataException("Unknown Format: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Format = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Format && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Streaming protocol for adaptive bitrate streaming. */ + class StreamProtocol + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val HLS = of("HLS") + + @JvmField val DASH = of("DASH") + + @JvmStatic fun of(value: String) = StreamProtocol(JsonField.of(value)) + } + + /** An enum containing [StreamProtocol]'s known values. */ + enum class Known { + HLS, + DASH, + } + + /** + * An enum containing [StreamProtocol]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [StreamProtocol] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HLS, + DASH, + /** + * An enum member indicating that [StreamProtocol] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HLS -> Value.HLS + DASH -> Value.DASH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HLS -> Known.HLS + DASH -> Known.DASH + else -> + throw ImageKitInvalidDataException("Unknown StreamProtocol: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): StreamProtocol = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StreamProtocol && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Video codec used for encoding (h264, vp9, or av1). */ + class VideoCodec + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val H264 = of("h264") + + @JvmField val VP9 = of("vp9") + + @JvmField val AV1 = of("av1") + + @JvmStatic fun of(value: String) = VideoCodec(JsonField.of(value)) + } + + /** An enum containing [VideoCodec]'s known values. */ + enum class Known { + H264, + VP9, + AV1, + } + + /** + * An enum containing [VideoCodec]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [VideoCodec] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + H264, + VP9, + AV1, + /** + * An enum member indicating that [VideoCodec] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + H264 -> Value.H264 + VP9 -> Value.VP9 + AV1 -> Value.AV1 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + H264 -> Known.H264 + VP9 -> Known.VP9 + AV1 -> Known.AV1 + else -> throw ImageKitInvalidDataException("Unknown VideoCodec: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): VideoCodec = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VideoCodec && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Options && + audioCodec == other.audioCodec && + autoRotate == other.autoRotate && + format == other.format && + quality == other.quality && + streamProtocol == other.streamProtocol && + variants == other.variants && + videoCodec == other.videoCodec && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + audioCodec, + autoRotate, + format, + quality, + streamProtocol, + variants, + videoCodec, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Options{audioCodec=$audioCodec, autoRotate=$autoRotate, format=$format, quality=$quality, streamProtocol=$streamProtocol, variants=$variants, videoCodec=$videoCodec, additionalProperties=$additionalProperties}" + } + + /** Information about the transformed output video. */ + class Output + private constructor( + private val url: JsonField, + private val videoMetadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("video_metadata") + @ExcludeMissing + videoMetadata: JsonField = JsonMissing.of(), + ) : this(url, videoMetadata, mutableMapOf()) + + /** + * URL to access the transformed video. + * + * @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 url(): String = url.getRequired("url") + + /** + * Metadata of the output video file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun videoMetadata(): Optional = + videoMetadata.getOptional("video_metadata") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [videoMetadata]. + * + * Unlike [videoMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("video_metadata") + @ExcludeMissing + fun _videoMetadata(): JsonField = videoMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Output]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Output]. */ + class Builder internal constructor() { + + private var url: JsonField? = null + private var videoMetadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(output: Output) = apply { + url = output.url + videoMetadata = output.videoMetadata + additionalProperties = output.additionalProperties.toMutableMap() + } + + /** URL to access the transformed video. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** Metadata of the output video file. */ + fun videoMetadata(videoMetadata: VideoMetadata) = + videoMetadata(JsonField.of(videoMetadata)) + + /** + * Sets [Builder.videoMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.videoMetadata] with a well-typed + * [VideoMetadata] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun videoMetadata(videoMetadata: JsonField) = apply { + this.videoMetadata = videoMetadata + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Output]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Output = + Output( + checkRequired("url", url), + videoMetadata, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Output = apply { + if (validated) { + return@apply + } + + url() + videoMetadata().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (url.asKnown().isPresent) 1 else 0) + + (videoMetadata.asKnown().getOrNull()?.validity() ?: 0) + + /** Metadata of the output video file. */ + class VideoMetadata + private constructor( + private val bitrate: JsonField, + private val duration: JsonField, + private val height: JsonField, + private val width: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bitrate") + @ExcludeMissing + bitrate: JsonField = JsonMissing.of(), + @JsonProperty("duration") + @ExcludeMissing + duration: JsonField = JsonMissing.of(), + @JsonProperty("height") + @ExcludeMissing + height: JsonField = JsonMissing.of(), + @JsonProperty("width") + @ExcludeMissing + width: JsonField = JsonMissing.of(), + ) : this(bitrate, duration, height, width, mutableMapOf()) + + /** + * Bitrate of the output video in bits per second. + * + * @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 bitrate(): Long = bitrate.getRequired("bitrate") + + /** + * Duration of the output video in seconds. + * + * @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 duration(): Double = duration.getRequired("duration") + + /** + * Height of the output video in pixels. + * + * @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 height(): Long = height.getRequired("height") + + /** + * Width of the output video in pixels. + * + * @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 width(): Long = width.getRequired("width") + + /** + * Returns the raw JSON value of [bitrate]. + * + * Unlike [bitrate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bitrate") + @ExcludeMissing + fun _bitrate(): JsonField = bitrate + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [height]. + * + * Unlike [height], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("height") @ExcludeMissing fun _height(): JsonField = height + + /** + * Returns the raw JSON value of [width]. + * + * Unlike [width], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("width") @ExcludeMissing fun _width(): JsonField = width + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [VideoMetadata]. + * + * The following fields are required: + * ```java + * .bitrate() + * .duration() + * .height() + * .width() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VideoMetadata]. */ + class Builder internal constructor() { + + private var bitrate: JsonField? = null + private var duration: JsonField? = null + private var height: JsonField? = null + private var width: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(videoMetadata: VideoMetadata) = apply { + bitrate = videoMetadata.bitrate + duration = videoMetadata.duration + height = videoMetadata.height + width = videoMetadata.width + additionalProperties = videoMetadata.additionalProperties.toMutableMap() + } + + /** Bitrate of the output video in bits per second. */ + fun bitrate(bitrate: Long) = bitrate(JsonField.of(bitrate)) + + /** + * Sets [Builder.bitrate] to an arbitrary JSON value. + * + * You should usually call [Builder.bitrate] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun bitrate(bitrate: JsonField) = apply { this.bitrate = bitrate } + + /** Duration of the output video in seconds. */ + fun duration(duration: Double) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun duration(duration: JsonField) = apply { + this.duration = duration + } + + /** Height of the output video in pixels. */ + fun height(height: Long) = height(JsonField.of(height)) + + /** + * Sets [Builder.height] to an arbitrary JSON value. + * + * You should usually call [Builder.height] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun height(height: JsonField) = apply { this.height = height } + + /** Width of the output video in pixels. */ + fun width(width: Long) = width(JsonField.of(width)) + + /** + * Sets [Builder.width] to an arbitrary JSON value. + * + * You should usually call [Builder.width] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun width(width: JsonField) = apply { this.width = width } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [VideoMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bitrate() + * .duration() + * .height() + * .width() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): VideoMetadata = + VideoMetadata( + checkRequired("bitrate", bitrate), + checkRequired("duration", duration), + checkRequired("height", height), + checkRequired("width", width), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): VideoMetadata = apply { + if (validated) { + return@apply + } + + bitrate() + duration() + height() + width() + 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 (bitrate.asKnown().isPresent) 1 else 0) + + (if (duration.asKnown().isPresent) 1 else 0) + + (if (height.asKnown().isPresent) 1 else 0) + + (if (width.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VideoMetadata && + bitrate == other.bitrate && + duration == other.duration && + height == other.height && + width == other.width && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(bitrate, duration, height, width, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VideoMetadata{bitrate=$bitrate, duration=$duration, height=$height, width=$width, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Output && + url == other.url && + videoMetadata == other.videoMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(url, videoMetadata, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Output{url=$url, videoMetadata=$videoMetadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Transformation && + type == other.type && + options == other.options && + output == other.output && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, options, output, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Transformation{type=$type, options=$options, output=$output, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + asset == other.asset && + transformation == other.transformation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(asset, transformation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{asset=$asset, transformation=$transformation, additionalProperties=$additionalProperties}" + } + + /** Information about the original request that triggered the video transformation. */ + class Request + private constructor( + private val url: JsonField, + private val xRequestId: JsonField, + private val userAgent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("x_request_id") + @ExcludeMissing + xRequestId: JsonField = JsonMissing.of(), + @JsonProperty("user_agent") + @ExcludeMissing + userAgent: JsonField = JsonMissing.of(), + ) : this(url, xRequestId, userAgent, mutableMapOf()) + + /** + * Full URL of the transformation request that was submitted. + * + * @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 url(): String = url.getRequired("url") + + /** + * Unique identifier for the originating transformation request. + * + * @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 xRequestId(): String = xRequestId.getRequired("x_request_id") + + /** + * User-Agent header from the original request that triggered the transformation. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun userAgent(): Optional = userAgent.getOptional("user_agent") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [xRequestId]. + * + * Unlike [xRequestId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("x_request_id") + @ExcludeMissing + fun _xRequestId(): JsonField = xRequestId + + /** + * Returns the raw JSON value of [userAgent]. + * + * Unlike [userAgent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_agent") @ExcludeMissing fun _userAgent(): JsonField = userAgent + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Request]. + * + * The following fields are required: + * ```java + * .url() + * .xRequestId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Request]. */ + class Builder internal constructor() { + + private var url: JsonField? = null + private var xRequestId: JsonField? = null + private var userAgent: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(request: Request) = apply { + url = request.url + xRequestId = request.xRequestId + userAgent = request.userAgent + additionalProperties = request.additionalProperties.toMutableMap() + } + + /** Full URL of the transformation request that was submitted. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** Unique identifier for the originating transformation request. */ + fun xRequestId(xRequestId: String) = xRequestId(JsonField.of(xRequestId)) + + /** + * Sets [Builder.xRequestId] to an arbitrary JSON value. + * + * You should usually call [Builder.xRequestId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun xRequestId(xRequestId: JsonField) = apply { this.xRequestId = xRequestId } + + /** User-Agent header from the original request that triggered the transformation. */ + fun userAgent(userAgent: String) = userAgent(JsonField.of(userAgent)) + + /** + * Sets [Builder.userAgent] to an arbitrary JSON value. + * + * You should usually call [Builder.userAgent] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun userAgent(userAgent: JsonField) = apply { this.userAgent = userAgent } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Request]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .url() + * .xRequestId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Request = + Request( + checkRequired("url", url), + checkRequired("xRequestId", xRequestId), + userAgent, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Request = apply { + if (validated) { + return@apply + } + + url() + xRequestId() + userAgent() + 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 (url.asKnown().isPresent) 1 else 0) + + (if (xRequestId.asKnown().isPresent) 1 else 0) + + (if (userAgent.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Request && + url == other.url && + xRequestId == other.xRequestId && + userAgent == other.userAgent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(url, xRequestId, userAgent, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Request{url=$url, xRequestId=$xRequestId, userAgent=$userAgent, additionalProperties=$additionalProperties}" + } + + /** Performance metrics for the transformation process. */ + class Timings + private constructor( + private val downloadDuration: JsonField, + private val encodingDuration: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("download_duration") + @ExcludeMissing + downloadDuration: JsonField = JsonMissing.of(), + @JsonProperty("encoding_duration") + @ExcludeMissing + encodingDuration: JsonField = JsonMissing.of(), + ) : this(downloadDuration, encodingDuration, mutableMapOf()) + + /** + * Time spent downloading the source video from your origin or media library, in + * milliseconds. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun downloadDuration(): Optional = downloadDuration.getOptional("download_duration") + + /** + * Time spent encoding the video, in milliseconds. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun encodingDuration(): Optional = encodingDuration.getOptional("encoding_duration") + + /** + * Returns the raw JSON value of [downloadDuration]. + * + * Unlike [downloadDuration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("download_duration") + @ExcludeMissing + fun _downloadDuration(): JsonField = downloadDuration + + /** + * Returns the raw JSON value of [encodingDuration]. + * + * Unlike [encodingDuration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("encoding_duration") + @ExcludeMissing + fun _encodingDuration(): JsonField = encodingDuration + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Timings]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Timings]. */ + class Builder internal constructor() { + + private var downloadDuration: JsonField = JsonMissing.of() + private var encodingDuration: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(timings: Timings) = apply { + downloadDuration = timings.downloadDuration + encodingDuration = timings.encodingDuration + additionalProperties = timings.additionalProperties.toMutableMap() + } + + /** + * Time spent downloading the source video from your origin or media library, in + * milliseconds. + */ + fun downloadDuration(downloadDuration: Long) = + downloadDuration(JsonField.of(downloadDuration)) + + /** + * Sets [Builder.downloadDuration] to an arbitrary JSON value. + * + * You should usually call [Builder.downloadDuration] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun downloadDuration(downloadDuration: JsonField) = apply { + this.downloadDuration = downloadDuration + } + + /** Time spent encoding the video, in milliseconds. */ + fun encodingDuration(encodingDuration: Long) = + encodingDuration(JsonField.of(encodingDuration)) + + /** + * Sets [Builder.encodingDuration] to an arbitrary JSON value. + * + * You should usually call [Builder.encodingDuration] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun encodingDuration(encodingDuration: JsonField) = apply { + this.encodingDuration = encodingDuration + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Timings]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Timings = + Timings(downloadDuration, encodingDuration, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Timings = apply { + if (validated) { + return@apply + } + + downloadDuration() + encodingDuration() + 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 (downloadDuration.asKnown().isPresent) 1 else 0) + + (if (encodingDuration.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Timings && + downloadDuration == other.downloadDuration && + encodingDuration == other.encodingDuration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(downloadDuration, encodingDuration, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Timings{downloadDuration=$downloadDuration, encodingDuration=$encodingDuration, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VideoTransformationReadyEvent && + id == other.id && + createdAt == other.createdAt && + data == other.data && + request == other.request && + type == other.type && + timings == other.timings && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, data, request, type, timings, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VideoTransformationReadyEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, timings=$timings, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AccountServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AccountServiceAsync.kt new file mode 100644 index 00000000..b8387b91 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AccountServiceAsync.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.services.async.accounts.OriginServiceAsync +import com.imagekit.api.services.async.accounts.UrlEndpointServiceAsync +import com.imagekit.api.services.async.accounts.UsageServiceAsync +import java.util.function.Consumer + +interface AccountServiceAsync { + + /** + * 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): AccountServiceAsync + + fun usage(): UsageServiceAsync + + fun origins(): OriginServiceAsync + + fun urlEndpoints(): UrlEndpointServiceAsync + + /** + * A view of [AccountServiceAsync] 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 + ): AccountServiceAsync.WithRawResponse + + fun usage(): UsageServiceAsync.WithRawResponse + + fun origins(): OriginServiceAsync.WithRawResponse + + fun urlEndpoints(): UrlEndpointServiceAsync.WithRawResponse + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AccountServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AccountServiceAsyncImpl.kt new file mode 100644 index 00000000..a6322df0 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AccountServiceAsyncImpl.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.services.async.accounts.OriginServiceAsync +import com.imagekit.api.services.async.accounts.OriginServiceAsyncImpl +import com.imagekit.api.services.async.accounts.UrlEndpointServiceAsync +import com.imagekit.api.services.async.accounts.UrlEndpointServiceAsyncImpl +import com.imagekit.api.services.async.accounts.UsageServiceAsync +import com.imagekit.api.services.async.accounts.UsageServiceAsyncImpl +import java.util.function.Consumer + +class AccountServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + AccountServiceAsync { + + private val withRawResponse: AccountServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val usage: UsageServiceAsync by lazy { UsageServiceAsyncImpl(clientOptions) } + + private val origins: OriginServiceAsync by lazy { OriginServiceAsyncImpl(clientOptions) } + + private val urlEndpoints: UrlEndpointServiceAsync by lazy { + UrlEndpointServiceAsyncImpl(clientOptions) + } + + override fun withRawResponse(): AccountServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): AccountServiceAsync = + AccountServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun usage(): UsageServiceAsync = usage + + override fun origins(): OriginServiceAsync = origins + + override fun urlEndpoints(): UrlEndpointServiceAsync = urlEndpoints + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AccountServiceAsync.WithRawResponse { + + private val usage: UsageServiceAsync.WithRawResponse by lazy { + UsageServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val origins: OriginServiceAsync.WithRawResponse by lazy { + OriginServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val urlEndpoints: UrlEndpointServiceAsync.WithRawResponse by lazy { + UrlEndpointServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): AccountServiceAsync.WithRawResponse = + AccountServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun usage(): UsageServiceAsync.WithRawResponse = usage + + override fun origins(): OriginServiceAsync.WithRawResponse = origins + + override fun urlEndpoints(): UrlEndpointServiceAsync.WithRawResponse = urlEndpoints + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AssetServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AssetServiceAsync.kt new file mode 100644 index 00000000..cd5259cf --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AssetServiceAsync.kt @@ -0,0 +1,87 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.assets.AssetListParams +import com.imagekit.api.models.assets.AssetListResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface AssetServiceAsync { + + /** + * 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): AssetServiceAsync + + /** + * This API can list all the uploaded files and folders in your ImageKit.io media library. In + * addition, you can fine-tune your query by specifying various filters by generating a query + * string in a Lucene-like syntax and provide this generated string as the value of the + * `searchQuery`. + */ + fun list(): CompletableFuture> = list(AssetListParams.none()) + + /** @see list */ + fun list( + params: AssetListParams = AssetListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: AssetListParams = AssetListParams.none() + ): CompletableFuture> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture> = + list(AssetListParams.none(), requestOptions) + + /** A view of [AssetServiceAsync] 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 + ): AssetServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/files`, but is otherwise the same as + * [AssetServiceAsync.list]. + */ + fun list(): CompletableFuture>> = + list(AssetListParams.none()) + + /** @see list */ + fun list( + params: AssetListParams = AssetListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture>> + + /** @see list */ + fun list( + params: AssetListParams = AssetListParams.none() + ): CompletableFuture>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture>> = + list(AssetListParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AssetServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AssetServiceAsyncImpl.kt new file mode 100644 index 00000000..316d3882 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AssetServiceAsyncImpl.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepareAsync +import com.imagekit.api.models.assets.AssetListParams +import com.imagekit.api.models.assets.AssetListResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class AssetServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + AssetServiceAsync { + + private val withRawResponse: AssetServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AssetServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): AssetServiceAsync = + AssetServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: AssetListParams, + requestOptions: RequestOptions, + ): CompletableFuture> = + // get /v1/files + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AssetServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): AssetServiceAsync.WithRawResponse = + AssetServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) + + override fun list( + params: AssetListParams, + requestOptions: RequestOptions, + ): CompletableFuture>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files") + .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() } + } + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BetaServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BetaServiceAsync.kt new file mode 100644 index 00000000..10252777 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BetaServiceAsync.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.services.async.beta.V2ServiceAsync +import java.util.function.Consumer + +interface BetaServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BetaServiceAsync + + fun v2(): V2ServiceAsync + + /** A view of [BetaServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BetaServiceAsync.WithRawResponse + + fun v2(): V2ServiceAsync.WithRawResponse + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BetaServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BetaServiceAsyncImpl.kt new file mode 100644 index 00000000..1ad19f0c --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BetaServiceAsyncImpl.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.services.async.beta.V2ServiceAsync +import com.imagekit.api.services.async.beta.V2ServiceAsyncImpl +import java.util.function.Consumer + +class BetaServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + BetaServiceAsync { + + private val withRawResponse: BetaServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val v2: V2ServiceAsync by lazy { V2ServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): BetaServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): BetaServiceAsync = + BetaServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun v2(): V2ServiceAsync = v2 + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BetaServiceAsync.WithRawResponse { + + private val v2: V2ServiceAsync.WithRawResponse by lazy { + V2ServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): BetaServiceAsync.WithRawResponse = + BetaServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun v2(): V2ServiceAsync.WithRawResponse = v2 + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CacheServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CacheServiceAsync.kt new file mode 100644 index 00000000..76b4415c --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CacheServiceAsync.kt @@ -0,0 +1,39 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.services.async.cache.InvalidationServiceAsync +import java.util.function.Consumer + +interface CacheServiceAsync { + + /** + * 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): CacheServiceAsync + + fun invalidation(): InvalidationServiceAsync + + /** A view of [CacheServiceAsync] 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 + ): CacheServiceAsync.WithRawResponse + + fun invalidation(): InvalidationServiceAsync.WithRawResponse + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CacheServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CacheServiceAsyncImpl.kt new file mode 100644 index 00000000..0690192a --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CacheServiceAsyncImpl.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.services.async.cache.InvalidationServiceAsync +import com.imagekit.api.services.async.cache.InvalidationServiceAsyncImpl +import java.util.function.Consumer + +class CacheServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CacheServiceAsync { + + private val withRawResponse: CacheServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val invalidation: InvalidationServiceAsync by lazy { + InvalidationServiceAsyncImpl(clientOptions) + } + + override fun withRawResponse(): CacheServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CacheServiceAsync = + CacheServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun invalidation(): InvalidationServiceAsync = invalidation + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CacheServiceAsync.WithRawResponse { + + private val invalidation: InvalidationServiceAsync.WithRawResponse by lazy { + InvalidationServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): CacheServiceAsync.WithRawResponse = + CacheServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun invalidation(): InvalidationServiceAsync.WithRawResponse = invalidation + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsync.kt new file mode 100644 index 00000000..6d7d7c13 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsync.kt @@ -0,0 +1,280 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.custommetadatafields.CustomMetadataField +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface CustomMetadataFieldServiceAsync { + + /** + * 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): CustomMetadataFieldServiceAsync + + /** + * This API creates a new custom metadata field. Once a custom metadata field is created either + * through this API or using the dashboard UI, its value can be set on the assets. The value of + * a field for an asset can be set using the media library UI or programmatically through upload + * or update assets API. + */ + fun create(params: CustomMetadataFieldCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: CustomMetadataFieldCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** This API updates the label or schema of an existing custom metadata field. */ + fun update(id: String): CompletableFuture = + update(id, CustomMetadataFieldUpdateParams.none()) + + /** @see update */ + fun update( + id: String, + params: CustomMetadataFieldUpdateParams = CustomMetadataFieldUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update( + id: String, + params: CustomMetadataFieldUpdateParams = CustomMetadataFieldUpdateParams.none(), + ): CompletableFuture = update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: CustomMetadataFieldUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see update */ + fun update(params: CustomMetadataFieldUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update(id: String, requestOptions: RequestOptions): CompletableFuture = + update(id, CustomMetadataFieldUpdateParams.none(), requestOptions) + + /** + * This API returns the array of created custom metadata field objects. By default the API + * returns only non deleted field objects, but you can include deleted fields in the API + * response. + */ + fun list(): CompletableFuture> = + list(CustomMetadataFieldListParams.none()) + + /** @see list */ + fun list( + params: CustomMetadataFieldListParams = CustomMetadataFieldListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: CustomMetadataFieldListParams = CustomMetadataFieldListParams.none() + ): CompletableFuture> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture> = + list(CustomMetadataFieldListParams.none(), requestOptions) + + /** + * This API deletes a custom metadata field. Even after deleting a custom metadata field, you + * cannot create any new custom metadata field with the same name. + */ + fun delete(id: String): CompletableFuture = + delete(id, CustomMetadataFieldDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: CustomMetadataFieldDeleteParams = CustomMetadataFieldDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: CustomMetadataFieldDeleteParams = CustomMetadataFieldDeleteParams.none(), + ): CompletableFuture = + delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: CustomMetadataFieldDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete( + params: CustomMetadataFieldDeleteParams + ): CompletableFuture = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(id, CustomMetadataFieldDeleteParams.none(), requestOptions) + + /** + * A view of [CustomMetadataFieldServiceAsync] 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 + ): CustomMetadataFieldServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/customMetadataFields`, but is otherwise the + * same as [CustomMetadataFieldServiceAsync.create]. + */ + fun create( + params: CustomMetadataFieldCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: CustomMetadataFieldCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `patch /v1/customMetadataFields/{id}`, but is otherwise + * the same as [CustomMetadataFieldServiceAsync.update]. + */ + fun update(id: String): CompletableFuture> = + update(id, CustomMetadataFieldUpdateParams.none()) + + /** @see update */ + fun update( + id: String, + params: CustomMetadataFieldUpdateParams = CustomMetadataFieldUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update( + id: String, + params: CustomMetadataFieldUpdateParams = CustomMetadataFieldUpdateParams.none(), + ): CompletableFuture> = + update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: CustomMetadataFieldUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see update */ + fun update( + params: CustomMetadataFieldUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(id, CustomMetadataFieldUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/customMetadataFields`, but is otherwise the same + * as [CustomMetadataFieldServiceAsync.list]. + */ + fun list(): CompletableFuture>> = + list(CustomMetadataFieldListParams.none()) + + /** @see list */ + fun list( + params: CustomMetadataFieldListParams = CustomMetadataFieldListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture>> + + /** @see list */ + fun list( + params: CustomMetadataFieldListParams = CustomMetadataFieldListParams.none() + ): CompletableFuture>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture>> = + list(CustomMetadataFieldListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/customMetadataFields/{id}`, but is otherwise + * the same as [CustomMetadataFieldServiceAsync.delete]. + */ + fun delete( + id: String + ): CompletableFuture> = + delete(id, CustomMetadataFieldDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: CustomMetadataFieldDeleteParams = CustomMetadataFieldDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: CustomMetadataFieldDeleteParams = CustomMetadataFieldDeleteParams.none(), + ): CompletableFuture> = + delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: CustomMetadataFieldDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see delete */ + fun delete( + params: CustomMetadataFieldDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + delete(id, CustomMetadataFieldDeleteParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncImpl.kt new file mode 100644 index 00000000..35d3ee2c --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncImpl.kt @@ -0,0 +1,216 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.json +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepareAsync +import com.imagekit.api.models.custommetadatafields.CustomMetadataField +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CustomMetadataFieldServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : CustomMetadataFieldServiceAsync { + + private val withRawResponse: CustomMetadataFieldServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CustomMetadataFieldServiceAsync.WithRawResponse = + withRawResponse + + override fun withOptions( + modifier: Consumer + ): CustomMetadataFieldServiceAsync = + CustomMetadataFieldServiceAsyncImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun create( + params: CustomMetadataFieldCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/customMetadataFields + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: CustomMetadataFieldUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // patch /v1/customMetadataFields/{id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: CustomMetadataFieldListParams, + requestOptions: RequestOptions, + ): CompletableFuture> = + // get /v1/customMetadataFields + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: CustomMetadataFieldDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /v1/customMetadataFields/{id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CustomMetadataFieldServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CustomMetadataFieldServiceAsync.WithRawResponse = + CustomMetadataFieldServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: CustomMetadataFieldCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "customMetadataFields") + .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: CustomMetadataFieldUpdateParams, + 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", "customMetadataFields", 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: CustomMetadataFieldListParams, + requestOptions: RequestOptions, + ): CompletableFuture>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "customMetadataFields") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun delete( + params: CustomMetadataFieldDeleteParams, + 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", "customMetadataFields", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt new file mode 100644 index 00000000..f5db6fe3 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt @@ -0,0 +1,420 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.files.File +import com.imagekit.api.models.files.FileCopyParams +import com.imagekit.api.models.files.FileCopyResponse +import com.imagekit.api.models.files.FileDeleteParams +import com.imagekit.api.models.files.FileGetParams +import com.imagekit.api.models.files.FileMoveParams +import com.imagekit.api.models.files.FileMoveResponse +import com.imagekit.api.models.files.FileRenameParams +import com.imagekit.api.models.files.FileRenameResponse +import com.imagekit.api.models.files.FileUpdateParams +import com.imagekit.api.models.files.FileUpdateResponse +import com.imagekit.api.models.files.FileUploadParams +import com.imagekit.api.models.files.FileUploadResponse +import com.imagekit.api.services.async.files.BulkServiceAsync +import com.imagekit.api.services.async.files.MetadataServiceAsync +import com.imagekit.api.services.async.files.VersionServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface FileServiceAsync { + + /** + * 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): FileServiceAsync + + fun bulk(): BulkServiceAsync + + fun versions(): VersionServiceAsync + + fun metadata(): MetadataServiceAsync + + /** + * This API updates the details or attributes of the current version of the file. You can update + * `tags`, `customCoordinates`, `customMetadata`, publication status, remove existing `AITags` + * and apply extensions using this API. + */ + fun update(fileId: String): CompletableFuture = + update(fileId, FileUpdateParams.none()) + + /** @see update */ + fun update( + fileId: String, + params: FileUpdateParams = FileUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see update */ + fun update( + fileId: String, + params: FileUpdateParams = FileUpdateParams.none(), + ): CompletableFuture = update(fileId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: FileUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see update */ + fun update(params: FileUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + fileId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update(fileId, FileUpdateParams.none(), requestOptions) + + /** + * This API deletes the file and all its file versions permanently. + * + * Note: If a file or specific transformation has been requested in the past, then the response + * is cached. Deleting a file does not purge the cache. You can purge the cache using purge + * cache API. + */ + fun delete(fileId: String): CompletableFuture = delete(fileId, FileDeleteParams.none()) + + /** @see delete */ + fun delete( + fileId: String, + params: FileDeleteParams = FileDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = delete(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see delete */ + fun delete( + fileId: String, + params: FileDeleteParams = FileDeleteParams.none(), + ): CompletableFuture = delete(fileId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: FileDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: FileDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(fileId: String, requestOptions: RequestOptions): CompletableFuture = + delete(fileId, FileDeleteParams.none(), requestOptions) + + /** + * This will copy a file from one folder to another. + * + * Note: If any file at the destination has the same name as the source file, then the source + * file and its versions (if `includeFileVersions` is set to true) will be appended to the + * destination file version history. + */ + fun copy(params: FileCopyParams): CompletableFuture = + copy(params, RequestOptions.none()) + + /** @see copy */ + fun copy( + params: FileCopyParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * This API returns an object with details or attributes about the current version of the file. + */ + fun get(fileId: String): CompletableFuture = get(fileId, FileGetParams.none()) + + /** @see get */ + fun get( + fileId: String, + params: FileGetParams = FileGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = get(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see get */ + fun get(fileId: String, params: FileGetParams = FileGetParams.none()): CompletableFuture = + get(fileId, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: FileGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see get */ + fun get(params: FileGetParams): CompletableFuture = get(params, RequestOptions.none()) + + /** @see get */ + fun get(fileId: String, requestOptions: RequestOptions): CompletableFuture = + get(fileId, FileGetParams.none(), requestOptions) + + /** + * This will move a file and all its versions from one folder to another. + * + * Note: If any file at the destination has the same name as the source file, then the source + * file and its versions will be appended to the destination file. + */ + fun move(params: FileMoveParams): CompletableFuture = + move(params, RequestOptions.none()) + + /** @see move */ + fun move( + params: FileMoveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * You can rename an already existing file in the media library using rename file API. This + * operation would rename all file versions of the file. + * + * Note: The old URLs will stop working. The file/file version URLs cached on CDN will continue + * to work unless a purge is requested. + */ + fun rename(params: FileRenameParams): CompletableFuture = + rename(params, RequestOptions.none()) + + /** @see rename */ + fun rename( + params: FileRenameParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * ImageKit.io allows you to upload files directly from both the server and client sides. For + * server-side uploads, private API key authentication is used. For client-side uploads, + * generate a one-time `token`, `signature`, and `expire` from your secure backend using private + * API. + * [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) + * about how to implement client-side file upload. + * + * The [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security by verifying + * the entire payload using JWT. + * + * **File size limit** \ On the free plan, the maximum upload file sizes are 20MB for images, + * audio, and raw files and 100MB for videos. On the paid plan, these limits increase to 40MB + * for images, audio, and raw files and 2GB for videos. These limits can be further increased + * with higher-tier plans. + * + * **Version limit** \ A file can have a maximum of 100 versions. + * + * **Demo applications** + * - A full-fledged + * [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting + * file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. + * - [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies. + */ + fun upload(params: FileUploadParams): CompletableFuture = + upload(params, RequestOptions.none()) + + /** @see upload */ + fun upload( + params: FileUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** A view of [FileServiceAsync] 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): FileServiceAsync.WithRawResponse + + fun bulk(): BulkServiceAsync.WithRawResponse + + fun versions(): VersionServiceAsync.WithRawResponse + + fun metadata(): MetadataServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `patch /v1/files/{fileId}/details`, but is otherwise the + * same as [FileServiceAsync.update]. + */ + fun update(fileId: String): CompletableFuture> = + update(fileId, FileUpdateParams.none()) + + /** @see update */ + fun update( + fileId: String, + params: FileUpdateParams = FileUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see update */ + fun update( + fileId: String, + params: FileUpdateParams = FileUpdateParams.none(), + ): CompletableFuture> = + update(fileId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: FileUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see update */ + fun update( + params: FileUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + fileId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(fileId, FileUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/files/{fileId}`, but is otherwise the same as + * [FileServiceAsync.delete]. + */ + fun delete(fileId: String): CompletableFuture = + delete(fileId, FileDeleteParams.none()) + + /** @see delete */ + fun delete( + fileId: String, + params: FileDeleteParams = FileDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see delete */ + fun delete( + fileId: String, + params: FileDeleteParams = FileDeleteParams.none(), + ): CompletableFuture = delete(fileId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: FileDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: FileDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + fileId: String, + requestOptions: RequestOptions, + ): CompletableFuture = delete(fileId, FileDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /v1/files/copy`, but is otherwise the same as + * [FileServiceAsync.copy]. + */ + fun copy(params: FileCopyParams): CompletableFuture> = + copy(params, RequestOptions.none()) + + /** @see copy */ + fun copy( + params: FileCopyParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/files/{fileId}/details`, but is otherwise the + * same as [FileServiceAsync.get]. + */ + fun get(fileId: String): CompletableFuture> = + get(fileId, FileGetParams.none()) + + /** @see get */ + fun get( + fileId: String, + params: FileGetParams = FileGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + get(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see get */ + fun get( + fileId: String, + params: FileGetParams = FileGetParams.none(), + ): CompletableFuture> = get(fileId, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: FileGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see get */ + fun get(params: FileGetParams): CompletableFuture> = + get(params, RequestOptions.none()) + + /** @see get */ + fun get( + fileId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + get(fileId, FileGetParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /v1/files/move`, but is otherwise the same as + * [FileServiceAsync.move]. + */ + fun move(params: FileMoveParams): CompletableFuture> = + move(params, RequestOptions.none()) + + /** @see move */ + fun move( + params: FileMoveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /v1/files/rename`, but is otherwise the same as + * [FileServiceAsync.rename]. + */ + fun rename( + params: FileRenameParams + ): CompletableFuture> = + rename(params, RequestOptions.none()) + + /** @see rename */ + fun rename( + params: FileRenameParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /api/v1/files/upload`, but is otherwise the same as + * [FileServiceAsync.upload]. + */ + fun upload( + params: FileUploadParams + ): CompletableFuture> = + upload(params, RequestOptions.none()) + + /** @see upload */ + fun upload( + params: FileUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt new file mode 100644 index 00000000..bafc4724 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt @@ -0,0 +1,368 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.handlers.emptyHandler +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.json +import com.imagekit.api.core.http.multipartFormData +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepareAsync +import com.imagekit.api.models.files.File +import com.imagekit.api.models.files.FileCopyParams +import com.imagekit.api.models.files.FileCopyResponse +import com.imagekit.api.models.files.FileDeleteParams +import com.imagekit.api.models.files.FileGetParams +import com.imagekit.api.models.files.FileMoveParams +import com.imagekit.api.models.files.FileMoveResponse +import com.imagekit.api.models.files.FileRenameParams +import com.imagekit.api.models.files.FileRenameResponse +import com.imagekit.api.models.files.FileUpdateParams +import com.imagekit.api.models.files.FileUpdateResponse +import com.imagekit.api.models.files.FileUploadParams +import com.imagekit.api.models.files.FileUploadResponse +import com.imagekit.api.services.async.files.BulkServiceAsync +import com.imagekit.api.services.async.files.BulkServiceAsyncImpl +import com.imagekit.api.services.async.files.MetadataServiceAsync +import com.imagekit.api.services.async.files.MetadataServiceAsyncImpl +import com.imagekit.api.services.async.files.VersionServiceAsync +import com.imagekit.api.services.async.files.VersionServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class FileServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + FileServiceAsync { + + private val withRawResponse: FileServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val bulk: BulkServiceAsync by lazy { BulkServiceAsyncImpl(clientOptions) } + + private val versions: VersionServiceAsync by lazy { VersionServiceAsyncImpl(clientOptions) } + + private val metadata: MetadataServiceAsync by lazy { MetadataServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): FileServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): FileServiceAsync = + FileServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun bulk(): BulkServiceAsync = bulk + + override fun versions(): VersionServiceAsync = versions + + override fun metadata(): MetadataServiceAsync = metadata + + override fun update( + params: FileUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // patch /v1/files/{fileId}/details + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: FileDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /v1/files/{fileId} + withRawResponse().delete(params, requestOptions).thenAccept {} + + override fun copy( + params: FileCopyParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/files/copy + withRawResponse().copy(params, requestOptions).thenApply { it.parse() } + + override fun get( + params: FileGetParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/files/{fileId}/details + withRawResponse().get(params, requestOptions).thenApply { it.parse() } + + override fun move( + params: FileMoveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/files/move + withRawResponse().move(params, requestOptions).thenApply { it.parse() } + + override fun rename( + params: FileRenameParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /v1/files/rename + withRawResponse().rename(params, requestOptions).thenApply { it.parse() } + + override fun upload( + params: FileUploadParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /api/v1/files/upload + withRawResponse().upload(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FileServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val bulk: BulkServiceAsync.WithRawResponse by lazy { + BulkServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val versions: VersionServiceAsync.WithRawResponse by lazy { + VersionServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val metadata: MetadataServiceAsync.WithRawResponse by lazy { + MetadataServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): FileServiceAsync.WithRawResponse = + FileServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun bulk(): BulkServiceAsync.WithRawResponse = bulk + + override fun versions(): VersionServiceAsync.WithRawResponse = versions + + override fun metadata(): MetadataServiceAsync.WithRawResponse = metadata + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: FileUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", params._pathParam(0), "details") + .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 { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: FileDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", 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 copyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun copy( + params: FileCopyParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", "copy") + .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 { copyHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: FileGetParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", params._pathParam(0), "details") + .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() + } + } + } + } + } + + private val moveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun move( + params: FileMoveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", "move") + .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 { moveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val renameHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun rename( + params: FileRenameParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", "rename") + .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 { renameHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val uploadHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun upload( + params: FileUploadParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl( + if (clientOptions.baseUrlOverridden()) clientOptions.baseUrl() + else "https://upload.imagekit.io" + ) + .addPathSegments("api", "v1", "files", "upload") + .body(multipartFormData(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 { uploadHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FolderServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FolderServiceAsync.kt new file mode 100644 index 00000000..aaa08ff2 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FolderServiceAsync.kt @@ -0,0 +1,195 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.folders.FolderCopyParams +import com.imagekit.api.models.folders.FolderCopyResponse +import com.imagekit.api.models.folders.FolderCreateParams +import com.imagekit.api.models.folders.FolderCreateResponse +import com.imagekit.api.models.folders.FolderDeleteParams +import com.imagekit.api.models.folders.FolderDeleteResponse +import com.imagekit.api.models.folders.FolderMoveParams +import com.imagekit.api.models.folders.FolderMoveResponse +import com.imagekit.api.models.folders.FolderRenameParams +import com.imagekit.api.models.folders.FolderRenameResponse +import com.imagekit.api.services.async.folders.JobServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface FolderServiceAsync { + + /** + * 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): FolderServiceAsync + + fun job(): JobServiceAsync + + /** + * This will create a new folder. You can specify the folder name and location of the parent + * folder where this new folder should be created. + */ + fun create(params: FolderCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: FolderCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * This will delete a folder and all its contents permanently. The API returns an empty + * response. + */ + fun delete(params: FolderDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: FolderDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * This will copy one folder into another. The selected folder, its nested folders, files, and + * their versions (in `includeVersions` is set to true) are copied in this operation. Note: If + * any file at the destination has the same name as the source file, then the source file and + * its versions will be appended to the destination file version history. + */ + fun copy(params: FolderCopyParams): CompletableFuture = + copy(params, RequestOptions.none()) + + /** @see copy */ + fun copy( + params: FolderCopyParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * This will move one folder into another. The selected folder, its nested folders, files, and + * their versions are moved in this operation. Note: If any file at the destination has the same + * name as the source file, then the source file and its versions will be appended to the + * destination file version history. + */ + fun move(params: FolderMoveParams): CompletableFuture = + move(params, RequestOptions.none()) + + /** @see move */ + fun move( + params: FolderMoveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * This API allows you to rename an existing folder. The folder and all its nested assets and + * sub-folders will remain unchanged, but their paths will be updated to reflect the new folder + * name. + */ + fun rename(params: FolderRenameParams): CompletableFuture = + rename(params, RequestOptions.none()) + + /** @see rename */ + fun rename( + params: FolderRenameParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [FolderServiceAsync] 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 + ): FolderServiceAsync.WithRawResponse + + fun job(): JobServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/folder`, but is otherwise the same as + * [FolderServiceAsync.create]. + */ + fun create( + params: FolderCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: FolderCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `delete /v1/folder`, but is otherwise the same as + * [FolderServiceAsync.delete]. + */ + fun delete( + params: FolderDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: FolderDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v1/bulkJobs/copyFolder`, but is otherwise the same + * as [FolderServiceAsync.copy]. + */ + fun copy(params: FolderCopyParams): CompletableFuture> = + copy(params, RequestOptions.none()) + + /** @see copy */ + fun copy( + params: FolderCopyParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v1/bulkJobs/moveFolder`, but is otherwise the same + * as [FolderServiceAsync.move]. + */ + fun move(params: FolderMoveParams): CompletableFuture> = + move(params, RequestOptions.none()) + + /** @see move */ + fun move( + params: FolderMoveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v1/bulkJobs/renameFolder`, but is otherwise the + * same as [FolderServiceAsync.rename]. + */ + fun rename( + params: FolderRenameParams + ): CompletableFuture> = + rename(params, RequestOptions.none()) + + /** @see rename */ + fun rename( + params: FolderRenameParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FolderServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FolderServiceAsyncImpl.kt new file mode 100644 index 00000000..426fe095 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FolderServiceAsyncImpl.kt @@ -0,0 +1,258 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.json +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepareAsync +import com.imagekit.api.models.folders.FolderCopyParams +import com.imagekit.api.models.folders.FolderCopyResponse +import com.imagekit.api.models.folders.FolderCreateParams +import com.imagekit.api.models.folders.FolderCreateResponse +import com.imagekit.api.models.folders.FolderDeleteParams +import com.imagekit.api.models.folders.FolderDeleteResponse +import com.imagekit.api.models.folders.FolderMoveParams +import com.imagekit.api.models.folders.FolderMoveResponse +import com.imagekit.api.models.folders.FolderRenameParams +import com.imagekit.api.models.folders.FolderRenameResponse +import com.imagekit.api.services.async.folders.JobServiceAsync +import com.imagekit.api.services.async.folders.JobServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class FolderServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + FolderServiceAsync { + + private val withRawResponse: FolderServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val job: JobServiceAsync by lazy { JobServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): FolderServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): FolderServiceAsync = + FolderServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun job(): JobServiceAsync = job + + override fun create( + params: FolderCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/folder + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: FolderDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /v1/folder + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun copy( + params: FolderCopyParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/bulkJobs/copyFolder + withRawResponse().copy(params, requestOptions).thenApply { it.parse() } + + override fun move( + params: FolderMoveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/bulkJobs/moveFolder + withRawResponse().move(params, requestOptions).thenApply { it.parse() } + + override fun rename( + params: FolderRenameParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/bulkJobs/renameFolder + withRawResponse().rename(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FolderServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val job: JobServiceAsync.WithRawResponse by lazy { + JobServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): FolderServiceAsync.WithRawResponse = + FolderServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun job(): JobServiceAsync.WithRawResponse = job + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: FolderCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "folder") + .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 deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun delete( + params: FolderDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "folder") + .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 { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val copyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun copy( + params: FolderCopyParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "bulkJobs", "copyFolder") + .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 { copyHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val moveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun move( + params: FolderMoveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "bulkJobs", "moveFolder") + .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 { moveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val renameHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun rename( + params: FolderRenameParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "bulkJobs", "renameFolder") + .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 { renameHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsync.kt new file mode 100644 index 00000000..68d16414 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsync.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.webhooks.UnsafeUnwrapWebhookEvent +import com.imagekit.api.models.webhooks.UnwrapWebhookEvent +import java.util.function.Consumer + +interface WebhookServiceAsync { + + /** + * 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): WebhookServiceAsync + + /** + * Unwraps a webhook event from its JSON representation. + * + * @throws ImageKitInvalidDataException if the body could not be parsed. + */ + fun unsafeUnwrap(body: String): UnsafeUnwrapWebhookEvent + + /** + * Unwraps a webhook event from its JSON representation. + * + * @throws ImageKitInvalidDataException if the body could not be parsed. + */ + fun unwrap(body: String): UnwrapWebhookEvent + + /** + * A view of [WebhookServiceAsync] 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 + ): WebhookServiceAsync.WithRawResponse + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncImpl.kt new file mode 100644 index 00000000..b2c9b205 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncImpl.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.webhooks.UnsafeUnwrapWebhookEvent +import com.imagekit.api.models.webhooks.UnwrapWebhookEvent +import com.imagekit.api.services.blocking.WebhookServiceImpl +import java.util.function.Consumer + +class WebhookServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + WebhookServiceAsync { + + private val withRawResponse: WebhookServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): WebhookServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): WebhookServiceAsync = + WebhookServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + /** + * Unwraps a webhook event from its JSON representation. + * + * @throws ImageKitInvalidDataException if the body could not be parsed. + */ + override fun unsafeUnwrap(body: String): UnsafeUnwrapWebhookEvent = + WebhookServiceImpl(clientOptions).unsafeUnwrap(body) + + /** + * Unwraps a webhook event from its JSON representation. + * + * @throws ImageKitInvalidDataException if the body could not be parsed. + */ + override fun unwrap(body: String): UnwrapWebhookEvent = + WebhookServiceImpl(clientOptions).unwrap(body) + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + WebhookServiceAsync.WithRawResponse { + + override fun withOptions( + modifier: Consumer + ): WebhookServiceAsync.WithRawResponse = + WebhookServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsync.kt new file mode 100644 index 00000000..0852af1b --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsync.kt @@ -0,0 +1,306 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.accounts + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.accounts.origins.OriginCreateParams +import com.imagekit.api.models.accounts.origins.OriginDeleteParams +import com.imagekit.api.models.accounts.origins.OriginGetParams +import com.imagekit.api.models.accounts.origins.OriginListParams +import com.imagekit.api.models.accounts.origins.OriginResponse +import com.imagekit.api.models.accounts.origins.OriginUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface OriginServiceAsync { + + /** + * 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): OriginServiceAsync + + /** + * **Note:** This API is currently in beta. Creates a new origin and returns the origin object. + */ + fun create(params: OriginCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: OriginCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * **Note:** This API is currently in beta. Updates the origin identified by `id` and returns + * the updated origin object. + */ + fun update(id: String, params: OriginUpdateParams): CompletableFuture = + update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + id: String, + params: OriginUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update(params: OriginUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: OriginUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * **Note:** This API is currently in beta. Returns an array of all configured origins for the + * current account. + */ + fun list(): CompletableFuture> = list(OriginListParams.none()) + + /** @see list */ + fun list( + params: OriginListParams = OriginListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: OriginListParams = OriginListParams.none() + ): CompletableFuture> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture> = + list(OriginListParams.none(), requestOptions) + + /** + * **Note:** This API is currently in beta. Permanently removes the origin identified by `id`. + * If the origin is in use by any URL‑endpoints, the API will return an error. + */ + fun delete(id: String): CompletableFuture = delete(id, OriginDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: OriginDeleteParams = OriginDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: OriginDeleteParams = OriginDeleteParams.none(), + ): CompletableFuture = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: OriginDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: OriginDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions): CompletableFuture = + delete(id, OriginDeleteParams.none(), requestOptions) + + /** **Note:** This API is currently in beta. Retrieves the origin identified by `id`. */ + fun get(id: String): CompletableFuture = get(id, OriginGetParams.none()) + + /** @see get */ + fun get( + id: String, + params: OriginGetParams = OriginGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = get(params.toBuilder().id(id).build(), requestOptions) + + /** @see get */ + fun get( + id: String, + params: OriginGetParams = OriginGetParams.none(), + ): CompletableFuture = get(id, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: OriginGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see get */ + fun get(params: OriginGetParams): CompletableFuture = + get(params, RequestOptions.none()) + + /** @see get */ + fun get(id: String, requestOptions: RequestOptions): CompletableFuture = + get(id, OriginGetParams.none(), requestOptions) + + /** + * A view of [OriginServiceAsync] 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 + ): OriginServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/accounts/origins`, but is otherwise the same as + * [OriginServiceAsync.create]. + */ + fun create(params: OriginCreateParams): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: OriginCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /v1/accounts/origins/{id}`, but is otherwise the + * same as [OriginServiceAsync.update]. + */ + fun update( + id: String, + params: OriginUpdateParams, + ): CompletableFuture> = + update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + id: String, + params: OriginUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update(params: OriginUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: OriginUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/accounts/origins`, but is otherwise the same as + * [OriginServiceAsync.list]. + */ + fun list(): CompletableFuture>> = + list(OriginListParams.none()) + + /** @see list */ + fun list( + params: OriginListParams = OriginListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture>> + + /** @see list */ + fun list( + params: OriginListParams = OriginListParams.none() + ): CompletableFuture>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture>> = + list(OriginListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/accounts/origins/{id}`, but is otherwise the + * same as [OriginServiceAsync.delete]. + */ + fun delete(id: String): CompletableFuture = + delete(id, OriginDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: OriginDeleteParams = OriginDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: OriginDeleteParams = OriginDeleteParams.none(), + ): CompletableFuture = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: OriginDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: OriginDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions): CompletableFuture = + delete(id, OriginDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/accounts/origins/{id}`, but is otherwise the + * same as [OriginServiceAsync.get]. + */ + fun get(id: String): CompletableFuture> = + get(id, OriginGetParams.none()) + + /** @see get */ + fun get( + id: String, + params: OriginGetParams = OriginGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + get(params.toBuilder().id(id).build(), requestOptions) + + /** @see get */ + fun get( + id: String, + params: OriginGetParams = OriginGetParams.none(), + ): CompletableFuture> = + get(id, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: OriginGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see get */ + fun get(params: OriginGetParams): CompletableFuture> = + get(params, RequestOptions.none()) + + /** @see get */ + fun get( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + get(id, OriginGetParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncImpl.kt new file mode 100644 index 00000000..7b9da703 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncImpl.kt @@ -0,0 +1,245 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.accounts + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.handlers.emptyHandler +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.json +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepareAsync +import com.imagekit.api.models.accounts.origins.OriginCreateParams +import com.imagekit.api.models.accounts.origins.OriginDeleteParams +import com.imagekit.api.models.accounts.origins.OriginGetParams +import com.imagekit.api.models.accounts.origins.OriginListParams +import com.imagekit.api.models.accounts.origins.OriginResponse +import com.imagekit.api.models.accounts.origins.OriginUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class OriginServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + OriginServiceAsync { + + private val withRawResponse: OriginServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): OriginServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): OriginServiceAsync = + OriginServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: OriginCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/accounts/origins + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: OriginUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /v1/accounts/origins/{id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: OriginListParams, + requestOptions: RequestOptions, + ): CompletableFuture> = + // get /v1/accounts/origins + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: OriginDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /v1/accounts/origins/{id} + withRawResponse().delete(params, requestOptions).thenAccept {} + + override fun get( + params: OriginGetParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/accounts/origins/{id} + withRawResponse().get(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OriginServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): OriginServiceAsync.WithRawResponse = + OriginServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: OriginCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "accounts", "origins") + .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: OriginUpdateParams, + 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.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "accounts", "origins", 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: OriginListParams, + requestOptions: RequestOptions, + ): CompletableFuture>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "accounts", "origins") + .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: OriginDeleteParams, + 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", "accounts", "origins", 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: OriginGetParams, + 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", "accounts", "origins", 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/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsync.kt new file mode 100644 index 00000000..334612e2 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsync.kt @@ -0,0 +1,319 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.accounts + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface UrlEndpointServiceAsync { + + /** + * 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): UrlEndpointServiceAsync + + /** + * **Note:** This API is currently in beta. Creates a new URL‑endpoint and returns the resulting + * object. + */ + fun create(params: UrlEndpointCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: UrlEndpointCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * **Note:** This API is currently in beta. Updates the URL‑endpoint identified by `id` and + * returns the updated object. + */ + fun update( + id: String, + params: UrlEndpointUpdateParams, + ): CompletableFuture = update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + id: String, + params: UrlEndpointUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update(params: UrlEndpointUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: UrlEndpointUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * **Note:** This API is currently in beta. Returns an array of all URL‑endpoints configured + * including the default URL-endpoint generated by ImageKit during account creation. + */ + fun list(): CompletableFuture> = list(UrlEndpointListParams.none()) + + /** @see list */ + fun list( + params: UrlEndpointListParams = UrlEndpointListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: UrlEndpointListParams = UrlEndpointListParams.none() + ): CompletableFuture> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture> = + list(UrlEndpointListParams.none(), requestOptions) + + /** + * **Note:** This API is currently in beta. Deletes the URL‑endpoint identified by `id`. You + * cannot delete the default URL‑endpoint created by ImageKit during account creation. + */ + fun delete(id: String): CompletableFuture = delete(id, UrlEndpointDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: UrlEndpointDeleteParams = UrlEndpointDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: UrlEndpointDeleteParams = UrlEndpointDeleteParams.none(), + ): CompletableFuture = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: UrlEndpointDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: UrlEndpointDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions): CompletableFuture = + delete(id, UrlEndpointDeleteParams.none(), requestOptions) + + /** **Note:** This API is currently in beta. Retrieves the URL‑endpoint identified by `id`. */ + fun get(id: String): CompletableFuture = + get(id, UrlEndpointGetParams.none()) + + /** @see get */ + fun get( + id: String, + params: UrlEndpointGetParams = UrlEndpointGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + get(params.toBuilder().id(id).build(), requestOptions) + + /** @see get */ + fun get( + id: String, + params: UrlEndpointGetParams = UrlEndpointGetParams.none(), + ): CompletableFuture = get(id, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: UrlEndpointGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see get */ + fun get(params: UrlEndpointGetParams): CompletableFuture = + get(params, RequestOptions.none()) + + /** @see get */ + fun get(id: String, requestOptions: RequestOptions): CompletableFuture = + get(id, UrlEndpointGetParams.none(), requestOptions) + + /** + * A view of [UrlEndpointServiceAsync] 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 + ): UrlEndpointServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/accounts/url-endpoints`, but is otherwise the + * same as [UrlEndpointServiceAsync.create]. + */ + fun create( + params: UrlEndpointCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: UrlEndpointCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /v1/accounts/url-endpoints/{id}`, but is otherwise + * the same as [UrlEndpointServiceAsync.update]. + */ + fun update( + id: String, + params: UrlEndpointUpdateParams, + ): CompletableFuture> = + update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + id: String, + params: UrlEndpointUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update( + params: UrlEndpointUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: UrlEndpointUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/accounts/url-endpoints`, but is otherwise the + * same as [UrlEndpointServiceAsync.list]. + */ + fun list(): CompletableFuture>> = + list(UrlEndpointListParams.none()) + + /** @see list */ + fun list( + params: UrlEndpointListParams = UrlEndpointListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture>> + + /** @see list */ + fun list( + params: UrlEndpointListParams = UrlEndpointListParams.none() + ): CompletableFuture>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture>> = + list(UrlEndpointListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/accounts/url-endpoints/{id}`, but is + * otherwise the same as [UrlEndpointServiceAsync.delete]. + */ + fun delete(id: String): CompletableFuture = + delete(id, UrlEndpointDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: UrlEndpointDeleteParams = UrlEndpointDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: UrlEndpointDeleteParams = UrlEndpointDeleteParams.none(), + ): CompletableFuture = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: UrlEndpointDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: UrlEndpointDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions): CompletableFuture = + delete(id, UrlEndpointDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/accounts/url-endpoints/{id}`, but is otherwise + * the same as [UrlEndpointServiceAsync.get]. + */ + fun get(id: String): CompletableFuture> = + get(id, UrlEndpointGetParams.none()) + + /** @see get */ + fun get( + id: String, + params: UrlEndpointGetParams = UrlEndpointGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + get(params.toBuilder().id(id).build(), requestOptions) + + /** @see get */ + fun get( + id: String, + params: UrlEndpointGetParams = UrlEndpointGetParams.none(), + ): CompletableFuture> = + get(id, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: UrlEndpointGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see get */ + fun get( + params: UrlEndpointGetParams + ): CompletableFuture> = + get(params, RequestOptions.none()) + + /** @see get */ + fun get( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + get(id, UrlEndpointGetParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncImpl.kt new file mode 100644 index 00000000..de716666 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncImpl.kt @@ -0,0 +1,245 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.accounts + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.handlers.emptyHandler +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.json +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepareAsync +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class UrlEndpointServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + UrlEndpointServiceAsync { + + private val withRawResponse: UrlEndpointServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): UrlEndpointServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): UrlEndpointServiceAsync = + UrlEndpointServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: UrlEndpointCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/accounts/url-endpoints + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: UrlEndpointUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /v1/accounts/url-endpoints/{id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: UrlEndpointListParams, + requestOptions: RequestOptions, + ): CompletableFuture> = + // get /v1/accounts/url-endpoints + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: UrlEndpointDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /v1/accounts/url-endpoints/{id} + withRawResponse().delete(params, requestOptions).thenAccept {} + + override fun get( + params: UrlEndpointGetParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/accounts/url-endpoints/{id} + withRawResponse().get(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UrlEndpointServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): UrlEndpointServiceAsync.WithRawResponse = + UrlEndpointServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: UrlEndpointCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "accounts", "url-endpoints") + .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: UrlEndpointUpdateParams, + 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.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "accounts", "url-endpoints", 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: UrlEndpointListParams, + requestOptions: RequestOptions, + ): CompletableFuture>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "accounts", "url-endpoints") + .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: UrlEndpointDeleteParams, + 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", "accounts", "url-endpoints", 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: UrlEndpointGetParams, + 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", "accounts", "url-endpoints", 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/com/imagekit/api/services/async/accounts/UsageServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsync.kt new file mode 100644 index 00000000..86d7d141 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsync.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.accounts + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.accounts.usage.UsageGetParams +import com.imagekit.api.models.accounts.usage.UsageGetResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface UsageServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UsageServiceAsync + + /** + * Get the account usage information between two dates. Note that the API response includes data + * from the start date while excluding data from the end date. In other words, the data covers + * the period starting from the specified start date up to, but not including, the end date. + */ + fun get(params: UsageGetParams): CompletableFuture = + get(params, RequestOptions.none()) + + /** @see get */ + fun get( + params: UsageGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** A view of [UsageServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): UsageServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/accounts/usage`, but is otherwise the same as + * [UsageServiceAsync.get]. + */ + fun get(params: UsageGetParams): CompletableFuture> = + get(params, RequestOptions.none()) + + /** @see get */ + fun get( + params: UsageGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncImpl.kt new file mode 100644 index 00000000..60ebeddd --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncImpl.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.accounts + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepareAsync +import com.imagekit.api.models.accounts.usage.UsageGetParams +import com.imagekit.api.models.accounts.usage.UsageGetResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class UsageServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + UsageServiceAsync { + + private val withRawResponse: UsageServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): UsageServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): UsageServiceAsync = + UsageServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun get( + params: UsageGetParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/accounts/usage + withRawResponse().get(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UsageServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): UsageServiceAsync.WithRawResponse = + UsageServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: UsageGetParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "accounts", "usage") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { getHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/V2ServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/V2ServiceAsync.kt new file mode 100644 index 00000000..1048ace9 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/V2ServiceAsync.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.beta + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.services.async.beta.v2.FileServiceAsync +import java.util.function.Consumer + +interface V2ServiceAsync { + + /** + * 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): V2ServiceAsync + + fun files(): FileServiceAsync + + /** A view of [V2ServiceAsync] 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): V2ServiceAsync.WithRawResponse + + fun files(): FileServiceAsync.WithRawResponse + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/V2ServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/V2ServiceAsyncImpl.kt new file mode 100644 index 00000000..f07a7a24 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/V2ServiceAsyncImpl.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.beta + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.services.async.beta.v2.FileServiceAsync +import com.imagekit.api.services.async.beta.v2.FileServiceAsyncImpl +import java.util.function.Consumer + +class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + V2ServiceAsync { + + private val withRawResponse: V2ServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val files: FileServiceAsync by lazy { FileServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): V2ServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): V2ServiceAsync = + V2ServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun files(): FileServiceAsync = files + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + V2ServiceAsync.WithRawResponse { + + private val files: FileServiceAsync.WithRawResponse by lazy { + FileServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): V2ServiceAsync.WithRawResponse = + V2ServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun files(): FileServiceAsync.WithRawResponse = files + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsync.kt new file mode 100644 index 00000000..d8db93f4 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsync.kt @@ -0,0 +1,83 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.beta.v2 + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.beta.v2.files.FileUploadParams +import com.imagekit.api.models.beta.v2.files.FileUploadResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface FileServiceAsync { + + /** + * 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): FileServiceAsync + + /** + * The V2 API enhances security by verifying the entire payload using JWT. This API is in beta. + * + * ImageKit.io allows you to upload files directly from both the server and client sides. For + * server-side uploads, private API key authentication is used. For client-side uploads, + * generate a one-time `token` from your secure backend using private API. + * [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) + * about how to implement secure client-side file upload. + * + * **File size limit** \ On the free plan, the maximum upload file sizes are 20MB for images, + * audio, and raw files, and 100MB for videos. On the paid plan, these limits increase to 40MB + * for images, audio, and raw files, and 2GB for videos. These limits can be further increased + * with higher-tier plans. + * + * **Version limit** \ A file can have a maximum of 100 versions. + * + * **Demo applications** + * - A full-fledged + * [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting + * file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. + * - [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies. + */ + fun upload(params: FileUploadParams): CompletableFuture = + upload(params, RequestOptions.none()) + + /** @see upload */ + fun upload( + params: FileUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** A view of [FileServiceAsync] 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): FileServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v2/files/upload`, but is otherwise the same as + * [FileServiceAsync.upload]. + */ + fun upload( + params: FileUploadParams + ): CompletableFuture> = + upload(params, RequestOptions.none()) + + /** @see upload */ + fun upload( + params: FileUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncImpl.kt new file mode 100644 index 00000000..1649f9bb --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncImpl.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.beta.v2 + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.multipartFormData +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepareAsync +import com.imagekit.api.models.beta.v2.files.FileUploadParams +import com.imagekit.api.models.beta.v2.files.FileUploadResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class FileServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + FileServiceAsync { + + private val withRawResponse: FileServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): FileServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): FileServiceAsync = + FileServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun upload( + params: FileUploadParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /api/v2/files/upload + withRawResponse().upload(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FileServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): FileServiceAsync.WithRawResponse = + FileServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val uploadHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun upload( + params: FileUploadParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl( + if (clientOptions.baseUrlOverridden()) clientOptions.baseUrl() + else "https://upload.imagekit.io" + ) + .addPathSegments("api", "v2", "files", "upload") + .body(multipartFormData(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 { uploadHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsync.kt new file mode 100644 index 00000000..49c88616 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsync.kt @@ -0,0 +1,148 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.cache + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.cache.invalidation.InvalidationCreateParams +import com.imagekit.api.models.cache.invalidation.InvalidationCreateResponse +import com.imagekit.api.models.cache.invalidation.InvalidationGetParams +import com.imagekit.api.models.cache.invalidation.InvalidationGetResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface InvalidationServiceAsync { + + /** + * 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): InvalidationServiceAsync + + /** + * This API will purge CDN cache and ImageKit.io's internal cache for a file. Note: Purge cache + * is an asynchronous process and it may take some time to reflect the changes. + */ + fun create(params: InvalidationCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: InvalidationCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** This API returns the status of a purge cache request. */ + fun get(requestId: String): CompletableFuture = + get(requestId, InvalidationGetParams.none()) + + /** @see get */ + fun get( + requestId: String, + params: InvalidationGetParams = InvalidationGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + get(params.toBuilder().requestId(requestId).build(), requestOptions) + + /** @see get */ + fun get( + requestId: String, + params: InvalidationGetParams = InvalidationGetParams.none(), + ): CompletableFuture = get(requestId, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: InvalidationGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see get */ + fun get(params: InvalidationGetParams): CompletableFuture = + get(params, RequestOptions.none()) + + /** @see get */ + fun get( + requestId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + get(requestId, InvalidationGetParams.none(), requestOptions) + + /** + * A view of [InvalidationServiceAsync] 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 + ): InvalidationServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/files/purge`, but is otherwise the same as + * [InvalidationServiceAsync.create]. + */ + fun create( + params: InvalidationCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: InvalidationCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/files/purge/{requestId}`, but is otherwise the + * same as [InvalidationServiceAsync.get]. + */ + fun get(requestId: String): CompletableFuture> = + get(requestId, InvalidationGetParams.none()) + + /** @see get */ + fun get( + requestId: String, + params: InvalidationGetParams = InvalidationGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + get(params.toBuilder().requestId(requestId).build(), requestOptions) + + /** @see get */ + fun get( + requestId: String, + params: InvalidationGetParams = InvalidationGetParams.none(), + ): CompletableFuture> = + get(requestId, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: InvalidationGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see get */ + fun get( + params: InvalidationGetParams + ): CompletableFuture> = + get(params, RequestOptions.none()) + + /** @see get */ + fun get( + requestId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + get(requestId, InvalidationGetParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncImpl.kt new file mode 100644 index 00000000..d7e41771 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncImpl.kt @@ -0,0 +1,130 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.cache + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.json +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepareAsync +import com.imagekit.api.models.cache.invalidation.InvalidationCreateParams +import com.imagekit.api.models.cache.invalidation.InvalidationCreateResponse +import com.imagekit.api.models.cache.invalidation.InvalidationGetParams +import com.imagekit.api.models.cache.invalidation.InvalidationGetResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class InvalidationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + InvalidationServiceAsync { + + private val withRawResponse: InvalidationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): InvalidationServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): InvalidationServiceAsync = + InvalidationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: InvalidationCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/files/purge + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun get( + params: InvalidationGetParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/files/purge/{requestId} + withRawResponse().get(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InvalidationServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): InvalidationServiceAsync.WithRawResponse = + InvalidationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: InvalidationCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", "purge") + .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 getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: InvalidationGetParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("requestId", params.requestId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", "purge", 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/com/imagekit/api/services/async/files/BulkServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BulkServiceAsync.kt new file mode 100644 index 00000000..bab5c67a --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BulkServiceAsync.kt @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.files + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.files.bulk.BulkAddTagsParams +import com.imagekit.api.models.files.bulk.BulkAddTagsResponse +import com.imagekit.api.models.files.bulk.BulkDeleteParams +import com.imagekit.api.models.files.bulk.BulkDeleteResponse +import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams +import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse +import com.imagekit.api.models.files.bulk.BulkRemoveTagsParams +import com.imagekit.api.models.files.bulk.BulkRemoveTagsResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface BulkServiceAsync { + + /** + * 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): BulkServiceAsync + + /** + * This API deletes multiple files and all their file versions permanently. + * + * Note: If a file or specific transformation has been requested in the past, then the response + * is cached. Deleting a file does not purge the cache. You can purge the cache using purge + * cache API. + * + * A maximum of 100 files can be deleted at a time. + */ + fun delete(params: BulkDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: BulkDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * This API adds tags to multiple files in bulk. A maximum of 50 files can be specified at a + * time. + */ + fun addTags(params: BulkAddTagsParams): CompletableFuture = + addTags(params, RequestOptions.none()) + + /** @see addTags */ + fun addTags( + params: BulkAddTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * This API removes AITags from multiple files in bulk. A maximum of 50 files can be specified + * at a time. + */ + fun removeAiTags(params: BulkRemoveAiTagsParams): CompletableFuture = + removeAiTags(params, RequestOptions.none()) + + /** @see removeAiTags */ + fun removeAiTags( + params: BulkRemoveAiTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * This API removes tags from multiple files in bulk. A maximum of 50 files can be specified at + * a time. + */ + fun removeTags(params: BulkRemoveTagsParams): CompletableFuture = + removeTags(params, RequestOptions.none()) + + /** @see removeTags */ + fun removeTags( + params: BulkRemoveTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** A view of [BulkServiceAsync] 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): BulkServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/files/batch/deleteByFileIds`, but is otherwise + * the same as [BulkServiceAsync.delete]. + */ + fun delete( + params: BulkDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: BulkDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v1/files/addTags`, but is otherwise the same as + * [BulkServiceAsync.addTags]. + */ + fun addTags( + params: BulkAddTagsParams + ): CompletableFuture> = + addTags(params, RequestOptions.none()) + + /** @see addTags */ + fun addTags( + params: BulkAddTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v1/files/removeAITags`, but is otherwise the same + * as [BulkServiceAsync.removeAiTags]. + */ + fun removeAiTags( + params: BulkRemoveAiTagsParams + ): CompletableFuture> = + removeAiTags(params, RequestOptions.none()) + + /** @see removeAiTags */ + fun removeAiTags( + params: BulkRemoveAiTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v1/files/removeTags`, but is otherwise the same as + * [BulkServiceAsync.removeTags]. + */ + fun removeTags( + params: BulkRemoveTagsParams + ): CompletableFuture> = + removeTags(params, RequestOptions.none()) + + /** @see removeTags */ + fun removeTags( + params: BulkRemoveTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncImpl.kt new file mode 100644 index 00000000..b4f268d4 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncImpl.kt @@ -0,0 +1,206 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.files + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.json +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepareAsync +import com.imagekit.api.models.files.bulk.BulkAddTagsParams +import com.imagekit.api.models.files.bulk.BulkAddTagsResponse +import com.imagekit.api.models.files.bulk.BulkDeleteParams +import com.imagekit.api.models.files.bulk.BulkDeleteResponse +import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams +import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse +import com.imagekit.api.models.files.bulk.BulkRemoveTagsParams +import com.imagekit.api.models.files.bulk.BulkRemoveTagsResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class BulkServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + BulkServiceAsync { + + private val withRawResponse: BulkServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BulkServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): BulkServiceAsync = + BulkServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun delete( + params: BulkDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/files/batch/deleteByFileIds + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun addTags( + params: BulkAddTagsParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/files/addTags + withRawResponse().addTags(params, requestOptions).thenApply { it.parse() } + + override fun removeAiTags( + params: BulkRemoveAiTagsParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/files/removeAITags + withRawResponse().removeAiTags(params, requestOptions).thenApply { it.parse() } + + override fun removeTags( + params: BulkRemoveTagsParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/files/removeTags + withRawResponse().removeTags(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BulkServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): BulkServiceAsync.WithRawResponse = + BulkServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun delete( + params: BulkDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", "batch", "deleteByFileIds") + .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 { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val addTagsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun addTags( + params: BulkAddTagsParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", "addTags") + .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 { addTagsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val removeAiTagsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun removeAiTags( + params: BulkRemoveAiTagsParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", "removeAITags") + .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 { removeAiTagsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val removeTagsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun removeTags( + params: BulkRemoveTagsParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", "removeTags") + .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 { removeTagsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsync.kt new file mode 100644 index 00000000..1d7f3856 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsync.kt @@ -0,0 +1,142 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.files + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.files.Metadata +import com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams +import com.imagekit.api.models.files.metadata.MetadataGetParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface MetadataServiceAsync { + + /** + * 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): MetadataServiceAsync + + /** + * You can programmatically get image EXIF, pHash, and other metadata for uploaded files in the + * ImageKit.io media library using this API. + * + * You can also get the metadata in upload API response by passing `metadata` in + * `responseFields` parameter. + */ + fun get(fileId: String): CompletableFuture = get(fileId, MetadataGetParams.none()) + + /** @see get */ + fun get( + fileId: String, + params: MetadataGetParams = MetadataGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = get(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see get */ + fun get( + fileId: String, + params: MetadataGetParams = MetadataGetParams.none(), + ): CompletableFuture = get(fileId, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: MetadataGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see get */ + fun get(params: MetadataGetParams): CompletableFuture = + get(params, RequestOptions.none()) + + /** @see get */ + fun get(fileId: String, requestOptions: RequestOptions): CompletableFuture = + get(fileId, MetadataGetParams.none(), requestOptions) + + /** + * Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API. + */ + fun getFromUrl(params: MetadataGetFromUrlParams): CompletableFuture = + getFromUrl(params, RequestOptions.none()) + + /** @see getFromUrl */ + fun getFromUrl( + params: MetadataGetFromUrlParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [MetadataServiceAsync] 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 + ): MetadataServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/files/{fileId}/metadata`, but is otherwise the + * same as [MetadataServiceAsync.get]. + */ + fun get(fileId: String): CompletableFuture> = + get(fileId, MetadataGetParams.none()) + + /** @see get */ + fun get( + fileId: String, + params: MetadataGetParams = MetadataGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + get(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see get */ + fun get( + fileId: String, + params: MetadataGetParams = MetadataGetParams.none(), + ): CompletableFuture> = get(fileId, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: MetadataGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see get */ + fun get(params: MetadataGetParams): CompletableFuture> = + get(params, RequestOptions.none()) + + /** @see get */ + fun get( + fileId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + get(fileId, MetadataGetParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/files/metadata`, but is otherwise the same as + * [MetadataServiceAsync.getFromUrl]. + */ + fun getFromUrl( + params: MetadataGetFromUrlParams + ): CompletableFuture> = getFromUrl(params, RequestOptions.none()) + + /** @see getFromUrl */ + fun getFromUrl( + params: MetadataGetFromUrlParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncImpl.kt new file mode 100644 index 00000000..b9a0336a --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncImpl.kt @@ -0,0 +1,126 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.files + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepareAsync +import com.imagekit.api.models.files.Metadata +import com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams +import com.imagekit.api.models.files.metadata.MetadataGetParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class MetadataServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + MetadataServiceAsync { + + private val withRawResponse: MetadataServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): MetadataServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): MetadataServiceAsync = + MetadataServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun get( + params: MetadataGetParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/files/{fileId}/metadata + withRawResponse().get(params, requestOptions).thenApply { it.parse() } + + override fun getFromUrl( + params: MetadataGetFromUrlParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/files/metadata + withRawResponse().getFromUrl(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + MetadataServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): MetadataServiceAsync.WithRawResponse = + MetadataServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: MetadataGetParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", params._pathParam(0), "metadata") + .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() + } + } + } + } + } + + private val getFromUrlHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getFromUrl( + params: MetadataGetFromUrlParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", "metadata") + .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 { getFromUrlHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/VersionServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/VersionServiceAsync.kt new file mode 100644 index 00000000..62bdd118 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/VersionServiceAsync.kt @@ -0,0 +1,271 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.files + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.files.File +import com.imagekit.api.models.files.versions.VersionDeleteParams +import com.imagekit.api.models.files.versions.VersionDeleteResponse +import com.imagekit.api.models.files.versions.VersionGetParams +import com.imagekit.api.models.files.versions.VersionListParams +import com.imagekit.api.models.files.versions.VersionRestoreParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface VersionServiceAsync { + + /** + * 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): VersionServiceAsync + + /** This API returns details of all versions of a file. */ + fun list(fileId: String): CompletableFuture> = list(fileId, VersionListParams.none()) + + /** @see list */ + fun list( + fileId: String, + params: VersionListParams = VersionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see list */ + fun list( + fileId: String, + params: VersionListParams = VersionListParams.none(), + ): CompletableFuture> = list(fileId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: VersionListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list(params: VersionListParams): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(fileId: String, requestOptions: RequestOptions): CompletableFuture> = + list(fileId, VersionListParams.none(), requestOptions) + + /** + * This API deletes a non-current file version permanently. The API returns an empty response. + * + * Note: If you want to delete all versions of a file, use the delete file API. + */ + fun delete( + versionId: String, + params: VersionDeleteParams, + ): CompletableFuture = delete(versionId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + versionId: String, + params: VersionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().versionId(versionId).build(), requestOptions) + + /** @see delete */ + fun delete(params: VersionDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: VersionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** This API returns an object with details or attributes of a file version. */ + fun get(versionId: String, params: VersionGetParams): CompletableFuture = + get(versionId, params, RequestOptions.none()) + + /** @see get */ + fun get( + versionId: String, + params: VersionGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + get(params.toBuilder().versionId(versionId).build(), requestOptions) + + /** @see get */ + fun get(params: VersionGetParams): CompletableFuture = get(params, RequestOptions.none()) + + /** @see get */ + fun get( + params: VersionGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** This API restores a file version as the current file version. */ + fun restore(versionId: String, params: VersionRestoreParams): CompletableFuture = + restore(versionId, params, RequestOptions.none()) + + /** @see restore */ + fun restore( + versionId: String, + params: VersionRestoreParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + restore(params.toBuilder().versionId(versionId).build(), requestOptions) + + /** @see restore */ + fun restore(params: VersionRestoreParams): CompletableFuture = + restore(params, RequestOptions.none()) + + /** @see restore */ + fun restore( + params: VersionRestoreParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [VersionServiceAsync] 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 + ): VersionServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/files/{fileId}/versions`, but is otherwise the + * same as [VersionServiceAsync.list]. + */ + fun list(fileId: String): CompletableFuture>> = + list(fileId, VersionListParams.none()) + + /** @see list */ + fun list( + fileId: String, + params: VersionListParams = VersionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture>> = + list(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see list */ + fun list( + fileId: String, + params: VersionListParams = VersionListParams.none(), + ): CompletableFuture>> = + list(fileId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: VersionListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture>> + + /** @see list */ + fun list(params: VersionListParams): CompletableFuture>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + fileId: String, + requestOptions: RequestOptions, + ): CompletableFuture>> = + list(fileId, VersionListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/files/{fileId}/versions/{versionId}`, but is + * otherwise the same as [VersionServiceAsync.delete]. + */ + fun delete( + versionId: String, + params: VersionDeleteParams, + ): CompletableFuture> = + delete(versionId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + versionId: String, + params: VersionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + delete(params.toBuilder().versionId(versionId).build(), requestOptions) + + /** @see delete */ + fun delete( + params: VersionDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: VersionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/files/{fileId}/versions/{versionId}`, but is + * otherwise the same as [VersionServiceAsync.get]. + */ + fun get( + versionId: String, + params: VersionGetParams, + ): CompletableFuture> = get(versionId, params, RequestOptions.none()) + + /** @see get */ + fun get( + versionId: String, + params: VersionGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + get(params.toBuilder().versionId(versionId).build(), requestOptions) + + /** @see get */ + fun get(params: VersionGetParams): CompletableFuture> = + get(params, RequestOptions.none()) + + /** @see get */ + fun get( + params: VersionGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /v1/files/{fileId}/versions/{versionId}/restore`, + * but is otherwise the same as [VersionServiceAsync.restore]. + */ + fun restore( + versionId: String, + params: VersionRestoreParams, + ): CompletableFuture> = + restore(versionId, params, RequestOptions.none()) + + /** @see restore */ + fun restore( + versionId: String, + params: VersionRestoreParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + restore(params.toBuilder().versionId(versionId).build(), requestOptions) + + /** @see restore */ + fun restore(params: VersionRestoreParams): CompletableFuture> = + restore(params, RequestOptions.none()) + + /** @see restore */ + fun restore( + params: VersionRestoreParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncImpl.kt new file mode 100644 index 00000000..c601ebe2 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncImpl.kt @@ -0,0 +1,233 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.files + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.json +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepareAsync +import com.imagekit.api.models.files.File +import com.imagekit.api.models.files.versions.VersionDeleteParams +import com.imagekit.api.models.files.versions.VersionDeleteResponse +import com.imagekit.api.models.files.versions.VersionGetParams +import com.imagekit.api.models.files.versions.VersionListParams +import com.imagekit.api.models.files.versions.VersionRestoreParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class VersionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + VersionServiceAsync { + + private val withRawResponse: VersionServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): VersionServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): VersionServiceAsync = + VersionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: VersionListParams, + requestOptions: RequestOptions, + ): CompletableFuture> = + // get /v1/files/{fileId}/versions + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: VersionDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /v1/files/{fileId}/versions/{versionId} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun get( + params: VersionGetParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/files/{fileId}/versions/{versionId} + withRawResponse().get(params, requestOptions).thenApply { it.parse() } + + override fun restore( + params: VersionRestoreParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /v1/files/{fileId}/versions/{versionId}/restore + withRawResponse().restore(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + VersionServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): VersionServiceAsync.WithRawResponse = + VersionServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) + + override fun list( + params: VersionListParams, + requestOptions: RequestOptions, + ): CompletableFuture>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", params._pathParam(0), "versions") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun delete( + params: VersionDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("versionId", params.versionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v1", + "files", + params._pathParam(0), + "versions", + params._pathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: VersionGetParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("versionId", params.versionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v1", + "files", + params._pathParam(0), + "versions", + params._pathParam(1), + ) + .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() + } + } + } + } + } + + private val restoreHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun restore( + params: VersionRestoreParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("versionId", params.versionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v1", + "files", + params._pathParam(0), + "versions", + params._pathParam(1), + "restore", + ) + .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 { restoreHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/folders/JobServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/folders/JobServiceAsync.kt new file mode 100644 index 00000000..48bf8371 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/folders/JobServiceAsync.kt @@ -0,0 +1,107 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.folders + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.folders.job.JobGetParams +import com.imagekit.api.models.folders.job.JobGetResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface JobServiceAsync { + + /** + * 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): JobServiceAsync + + /** This API returns the status of a bulk job like copy and move folder operations. */ + fun get(jobId: String): CompletableFuture = get(jobId, JobGetParams.none()) + + /** @see get */ + fun get( + jobId: String, + params: JobGetParams = JobGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + get(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see get */ + fun get( + jobId: String, + params: JobGetParams = JobGetParams.none(), + ): CompletableFuture = get(jobId, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: JobGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see get */ + fun get(params: JobGetParams): CompletableFuture = + get(params, RequestOptions.none()) + + /** @see get */ + fun get(jobId: String, requestOptions: RequestOptions): CompletableFuture = + get(jobId, JobGetParams.none(), requestOptions) + + /** A view of [JobServiceAsync] 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): JobServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/bulkJobs/{jobId}`, but is otherwise the same as + * [JobServiceAsync.get]. + */ + fun get(jobId: String): CompletableFuture> = + get(jobId, JobGetParams.none()) + + /** @see get */ + fun get( + jobId: String, + params: JobGetParams = JobGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + get(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see get */ + fun get( + jobId: String, + params: JobGetParams = JobGetParams.none(), + ): CompletableFuture> = + get(jobId, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: JobGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see get */ + fun get(params: JobGetParams): CompletableFuture> = + get(params, RequestOptions.none()) + + /** @see get */ + fun get( + jobId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + get(jobId, JobGetParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncImpl.kt new file mode 100644 index 00000000..4f0f7a34 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncImpl.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.folders + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepareAsync +import com.imagekit.api.models.folders.job.JobGetParams +import com.imagekit.api.models.folders.job.JobGetResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class JobServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + JobServiceAsync { + + private val withRawResponse: JobServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): JobServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): JobServiceAsync = + JobServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun get( + params: JobGetParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/bulkJobs/{jobId} + withRawResponse().get(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + JobServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): JobServiceAsync.WithRawResponse = + JobServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: JobGetParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "bulkJobs", 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/com/imagekit/api/services/blocking/AccountService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AccountService.kt new file mode 100644 index 00000000..40a68ccd --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AccountService.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.services.blocking.accounts.OriginService +import com.imagekit.api.services.blocking.accounts.UrlEndpointService +import com.imagekit.api.services.blocking.accounts.UsageService +import java.util.function.Consumer + +interface AccountService { + + /** + * 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): AccountService + + fun usage(): UsageService + + fun origins(): OriginService + + fun urlEndpoints(): UrlEndpointService + + /** A view of [AccountService] 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): AccountService.WithRawResponse + + fun usage(): UsageService.WithRawResponse + + fun origins(): OriginService.WithRawResponse + + fun urlEndpoints(): UrlEndpointService.WithRawResponse + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AccountServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AccountServiceImpl.kt new file mode 100644 index 00000000..3f7a4a19 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AccountServiceImpl.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.services.blocking.accounts.OriginService +import com.imagekit.api.services.blocking.accounts.OriginServiceImpl +import com.imagekit.api.services.blocking.accounts.UrlEndpointService +import com.imagekit.api.services.blocking.accounts.UrlEndpointServiceImpl +import com.imagekit.api.services.blocking.accounts.UsageService +import com.imagekit.api.services.blocking.accounts.UsageServiceImpl +import java.util.function.Consumer + +class AccountServiceImpl internal constructor(private val clientOptions: ClientOptions) : + AccountService { + + private val withRawResponse: AccountService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val usage: UsageService by lazy { UsageServiceImpl(clientOptions) } + + private val origins: OriginService by lazy { OriginServiceImpl(clientOptions) } + + private val urlEndpoints: UrlEndpointService by lazy { UrlEndpointServiceImpl(clientOptions) } + + override fun withRawResponse(): AccountService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): AccountService = + AccountServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun usage(): UsageService = usage + + override fun origins(): OriginService = origins + + override fun urlEndpoints(): UrlEndpointService = urlEndpoints + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AccountService.WithRawResponse { + + private val usage: UsageService.WithRawResponse by lazy { + UsageServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val origins: OriginService.WithRawResponse by lazy { + OriginServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val urlEndpoints: UrlEndpointService.WithRawResponse by lazy { + UrlEndpointServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): AccountService.WithRawResponse = + AccountServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun usage(): UsageService.WithRawResponse = usage + + override fun origins(): OriginService.WithRawResponse = origins + + override fun urlEndpoints(): UrlEndpointService.WithRawResponse = urlEndpoints + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AssetService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AssetService.kt new file mode 100644 index 00000000..0d407ff4 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AssetService.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.assets.AssetListParams +import com.imagekit.api.models.assets.AssetListResponse +import java.util.function.Consumer + +interface AssetService { + + /** + * 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): AssetService + + /** + * This API can list all the uploaded files and folders in your ImageKit.io media library. In + * addition, you can fine-tune your query by specifying various filters by generating a query + * string in a Lucene-like syntax and provide this generated string as the value of the + * `searchQuery`. + */ + fun list(): List = list(AssetListParams.none()) + + /** @see list */ + fun list( + params: AssetListParams = AssetListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List + + /** @see list */ + fun list(params: AssetListParams = AssetListParams.none()): List = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List = + list(AssetListParams.none(), requestOptions) + + /** A view of [AssetService] 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): AssetService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/files`, but is otherwise the same as + * [AssetService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor> = list(AssetListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: AssetListParams = AssetListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor> + + /** @see list */ + @MustBeClosed + fun list( + params: AssetListParams = AssetListParams.none() + ): HttpResponseFor> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor> = + list(AssetListParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AssetServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AssetServiceImpl.kt new file mode 100644 index 00000000..0297ddbc --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AssetServiceImpl.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepare +import com.imagekit.api.models.assets.AssetListParams +import com.imagekit.api.models.assets.AssetListResponse +import java.util.function.Consumer + +class AssetServiceImpl internal constructor(private val clientOptions: ClientOptions) : + AssetService { + + private val withRawResponse: AssetService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AssetService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): AssetService = + AssetServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: AssetListParams, + requestOptions: RequestOptions, + ): List = + // get /v1/files + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AssetService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): AssetService.WithRawResponse = + AssetServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) + + override fun list( + params: AssetListParams, + requestOptions: RequestOptions, + ): HttpResponseFor> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files") + .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() } + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BetaService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BetaService.kt new file mode 100644 index 00000000..4b76e4e6 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BetaService.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.services.blocking.beta.V2Service +import java.util.function.Consumer + +interface BetaService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BetaService + + fun v2(): V2Service + + /** A view of [BetaService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BetaService.WithRawResponse + + fun v2(): V2Service.WithRawResponse + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BetaServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BetaServiceImpl.kt new file mode 100644 index 00000000..89cc1179 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BetaServiceImpl.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.services.blocking.beta.V2Service +import com.imagekit.api.services.blocking.beta.V2ServiceImpl +import java.util.function.Consumer + +class BetaServiceImpl internal constructor(private val clientOptions: ClientOptions) : BetaService { + + private val withRawResponse: BetaService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val v2: V2Service by lazy { V2ServiceImpl(clientOptions) } + + override fun withRawResponse(): BetaService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): BetaService = + BetaServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun v2(): V2Service = v2 + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BetaService.WithRawResponse { + + private val v2: V2Service.WithRawResponse by lazy { + V2ServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): BetaService.WithRawResponse = + BetaServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun v2(): V2Service.WithRawResponse = v2 + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CacheService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CacheService.kt new file mode 100644 index 00000000..f12bf842 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CacheService.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.services.blocking.cache.InvalidationService +import java.util.function.Consumer + +interface CacheService { + + /** + * 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): CacheService + + fun invalidation(): InvalidationService + + /** A view of [CacheService] 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): CacheService.WithRawResponse + + fun invalidation(): InvalidationService.WithRawResponse + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CacheServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CacheServiceImpl.kt new file mode 100644 index 00000000..32e92965 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CacheServiceImpl.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.services.blocking.cache.InvalidationService +import com.imagekit.api.services.blocking.cache.InvalidationServiceImpl +import java.util.function.Consumer + +class CacheServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CacheService { + + private val withRawResponse: CacheService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val invalidation: InvalidationService by lazy { InvalidationServiceImpl(clientOptions) } + + override fun withRawResponse(): CacheService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CacheService = + CacheServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun invalidation(): InvalidationService = invalidation + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CacheService.WithRawResponse { + + private val invalidation: InvalidationService.WithRawResponse by lazy { + InvalidationServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): CacheService.WithRawResponse = + CacheServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun invalidation(): InvalidationService.WithRawResponse = invalidation + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldService.kt new file mode 100644 index 00000000..bd644eeb --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldService.kt @@ -0,0 +1,279 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.custommetadatafields.CustomMetadataField +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +import java.util.function.Consumer + +interface CustomMetadataFieldService { + + /** + * 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): CustomMetadataFieldService + + /** + * This API creates a new custom metadata field. Once a custom metadata field is created either + * through this API or using the dashboard UI, its value can be set on the assets. The value of + * a field for an asset can be set using the media library UI or programmatically through upload + * or update assets API. + */ + fun create(params: CustomMetadataFieldCreateParams): CustomMetadataField = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: CustomMetadataFieldCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomMetadataField + + /** This API updates the label or schema of an existing custom metadata field. */ + fun update(id: String): CustomMetadataField = update(id, CustomMetadataFieldUpdateParams.none()) + + /** @see update */ + fun update( + id: String, + params: CustomMetadataFieldUpdateParams = CustomMetadataFieldUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomMetadataField = update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update( + id: String, + params: CustomMetadataFieldUpdateParams = CustomMetadataFieldUpdateParams.none(), + ): CustomMetadataField = update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: CustomMetadataFieldUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomMetadataField + + /** @see update */ + fun update(params: CustomMetadataFieldUpdateParams): CustomMetadataField = + update(params, RequestOptions.none()) + + /** @see update */ + fun update(id: String, requestOptions: RequestOptions): CustomMetadataField = + update(id, CustomMetadataFieldUpdateParams.none(), requestOptions) + + /** + * This API returns the array of created custom metadata field objects. By default the API + * returns only non deleted field objects, but you can include deleted fields in the API + * response. + */ + fun list(): List = list(CustomMetadataFieldListParams.none()) + + /** @see list */ + fun list( + params: CustomMetadataFieldListParams = CustomMetadataFieldListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List + + /** @see list */ + fun list( + params: CustomMetadataFieldListParams = CustomMetadataFieldListParams.none() + ): List = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List = + list(CustomMetadataFieldListParams.none(), requestOptions) + + /** + * This API deletes a custom metadata field. Even after deleting a custom metadata field, you + * cannot create any new custom metadata field with the same name. + */ + fun delete(id: String): CustomMetadataFieldDeleteResponse = + delete(id, CustomMetadataFieldDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: CustomMetadataFieldDeleteParams = CustomMetadataFieldDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomMetadataFieldDeleteResponse = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: CustomMetadataFieldDeleteParams = CustomMetadataFieldDeleteParams.none(), + ): CustomMetadataFieldDeleteResponse = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: CustomMetadataFieldDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomMetadataFieldDeleteResponse + + /** @see delete */ + fun delete(params: CustomMetadataFieldDeleteParams): CustomMetadataFieldDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions): CustomMetadataFieldDeleteResponse = + delete(id, CustomMetadataFieldDeleteParams.none(), requestOptions) + + /** + * A view of [CustomMetadataFieldService] 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 + ): CustomMetadataFieldService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/customMetadataFields`, but is otherwise the + * same as [CustomMetadataFieldService.create]. + */ + @MustBeClosed + fun create(params: CustomMetadataFieldCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: CustomMetadataFieldCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `patch /v1/customMetadataFields/{id}`, but is otherwise + * the same as [CustomMetadataFieldService.update]. + */ + @MustBeClosed + fun update(id: String): HttpResponseFor = + update(id, CustomMetadataFieldUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + id: String, + params: CustomMetadataFieldUpdateParams = CustomMetadataFieldUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + id: String, + params: CustomMetadataFieldUpdateParams = CustomMetadataFieldUpdateParams.none(), + ): HttpResponseFor = update(id, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: CustomMetadataFieldUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see update */ + @MustBeClosed + fun update(params: CustomMetadataFieldUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(id, CustomMetadataFieldUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/customMetadataFields`, but is otherwise the same + * as [CustomMetadataFieldService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor> = + list(CustomMetadataFieldListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: CustomMetadataFieldListParams = CustomMetadataFieldListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor> + + /** @see list */ + @MustBeClosed + fun list( + params: CustomMetadataFieldListParams = CustomMetadataFieldListParams.none() + ): HttpResponseFor> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor> = + list(CustomMetadataFieldListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/customMetadataFields/{id}`, but is otherwise + * the same as [CustomMetadataFieldService.delete]. + */ + @MustBeClosed + fun delete(id: String): HttpResponseFor = + delete(id, CustomMetadataFieldDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: CustomMetadataFieldDeleteParams = CustomMetadataFieldDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: CustomMetadataFieldDeleteParams = CustomMetadataFieldDeleteParams.none(), + ): HttpResponseFor = + delete(id, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: CustomMetadataFieldDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see delete */ + @MustBeClosed + fun delete( + params: CustomMetadataFieldDeleteParams + ): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + delete(id, CustomMetadataFieldDeleteParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceImpl.kt new file mode 100644 index 00000000..ac2e2357 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceImpl.kt @@ -0,0 +1,200 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.json +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepare +import com.imagekit.api.models.custommetadatafields.CustomMetadataField +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CustomMetadataFieldServiceImpl +internal constructor(private val clientOptions: ClientOptions) : CustomMetadataFieldService { + + private val withRawResponse: CustomMetadataFieldService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CustomMetadataFieldService.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): CustomMetadataFieldService = + CustomMetadataFieldServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: CustomMetadataFieldCreateParams, + requestOptions: RequestOptions, + ): CustomMetadataField = + // post /v1/customMetadataFields + withRawResponse().create(params, requestOptions).parse() + + override fun update( + params: CustomMetadataFieldUpdateParams, + requestOptions: RequestOptions, + ): CustomMetadataField = + // patch /v1/customMetadataFields/{id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: CustomMetadataFieldListParams, + requestOptions: RequestOptions, + ): List = + // get /v1/customMetadataFields + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: CustomMetadataFieldDeleteParams, + requestOptions: RequestOptions, + ): CustomMetadataFieldDeleteResponse = + // delete /v1/customMetadataFields/{id} + withRawResponse().delete(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CustomMetadataFieldService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CustomMetadataFieldService.WithRawResponse = + CustomMetadataFieldServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: CustomMetadataFieldCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "customMetadataFields") + .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: CustomMetadataFieldUpdateParams, + 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", "customMetadataFields", 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: CustomMetadataFieldListParams, + requestOptions: RequestOptions, + ): HttpResponseFor> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "customMetadataFields") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun delete( + params: CustomMetadataFieldDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "customMetadataFields", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt new file mode 100644 index 00000000..8f4e8f80 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt @@ -0,0 +1,409 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.files.File +import com.imagekit.api.models.files.FileCopyParams +import com.imagekit.api.models.files.FileCopyResponse +import com.imagekit.api.models.files.FileDeleteParams +import com.imagekit.api.models.files.FileGetParams +import com.imagekit.api.models.files.FileMoveParams +import com.imagekit.api.models.files.FileMoveResponse +import com.imagekit.api.models.files.FileRenameParams +import com.imagekit.api.models.files.FileRenameResponse +import com.imagekit.api.models.files.FileUpdateParams +import com.imagekit.api.models.files.FileUpdateResponse +import com.imagekit.api.models.files.FileUploadParams +import com.imagekit.api.models.files.FileUploadResponse +import com.imagekit.api.services.blocking.files.BulkService +import com.imagekit.api.services.blocking.files.MetadataService +import com.imagekit.api.services.blocking.files.VersionService +import java.util.function.Consumer + +interface FileService { + + /** + * 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): FileService + + fun bulk(): BulkService + + fun versions(): VersionService + + fun metadata(): MetadataService + + /** + * This API updates the details or attributes of the current version of the file. You can update + * `tags`, `customCoordinates`, `customMetadata`, publication status, remove existing `AITags` + * and apply extensions using this API. + */ + fun update(fileId: String): FileUpdateResponse = update(fileId, FileUpdateParams.none()) + + /** @see update */ + fun update( + fileId: String, + params: FileUpdateParams = FileUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): FileUpdateResponse = update(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see update */ + fun update( + fileId: String, + params: FileUpdateParams = FileUpdateParams.none(), + ): FileUpdateResponse = update(fileId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: FileUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FileUpdateResponse + + /** @see update */ + fun update(params: FileUpdateParams): FileUpdateResponse = update(params, RequestOptions.none()) + + /** @see update */ + fun update(fileId: String, requestOptions: RequestOptions): FileUpdateResponse = + update(fileId, FileUpdateParams.none(), requestOptions) + + /** + * This API deletes the file and all its file versions permanently. + * + * Note: If a file or specific transformation has been requested in the past, then the response + * is cached. Deleting a file does not purge the cache. You can purge the cache using purge + * cache API. + */ + fun delete(fileId: String) = delete(fileId, FileDeleteParams.none()) + + /** @see delete */ + fun delete( + fileId: String, + params: FileDeleteParams = FileDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = delete(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see delete */ + fun delete(fileId: String, params: FileDeleteParams = FileDeleteParams.none()) = + delete(fileId, params, RequestOptions.none()) + + /** @see delete */ + fun delete(params: FileDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) + + /** @see delete */ + fun delete(params: FileDeleteParams) = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(fileId: String, requestOptions: RequestOptions) = + delete(fileId, FileDeleteParams.none(), requestOptions) + + /** + * This will copy a file from one folder to another. + * + * Note: If any file at the destination has the same name as the source file, then the source + * file and its versions (if `includeFileVersions` is set to true) will be appended to the + * destination file version history. + */ + fun copy(params: FileCopyParams): FileCopyResponse = copy(params, RequestOptions.none()) + + /** @see copy */ + fun copy( + params: FileCopyParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FileCopyResponse + + /** + * This API returns an object with details or attributes about the current version of the file. + */ + fun get(fileId: String): File = get(fileId, FileGetParams.none()) + + /** @see get */ + fun get( + fileId: String, + params: FileGetParams = FileGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): File = get(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see get */ + fun get(fileId: String, params: FileGetParams = FileGetParams.none()): File = + get(fileId, params, RequestOptions.none()) + + /** @see get */ + fun get(params: FileGetParams, requestOptions: RequestOptions = RequestOptions.none()): File + + /** @see get */ + fun get(params: FileGetParams): File = get(params, RequestOptions.none()) + + /** @see get */ + fun get(fileId: String, requestOptions: RequestOptions): File = + get(fileId, FileGetParams.none(), requestOptions) + + /** + * This will move a file and all its versions from one folder to another. + * + * Note: If any file at the destination has the same name as the source file, then the source + * file and its versions will be appended to the destination file. + */ + fun move(params: FileMoveParams): FileMoveResponse = move(params, RequestOptions.none()) + + /** @see move */ + fun move( + params: FileMoveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FileMoveResponse + + /** + * You can rename an already existing file in the media library using rename file API. This + * operation would rename all file versions of the file. + * + * Note: The old URLs will stop working. The file/file version URLs cached on CDN will continue + * to work unless a purge is requested. + */ + fun rename(params: FileRenameParams): FileRenameResponse = rename(params, RequestOptions.none()) + + /** @see rename */ + fun rename( + params: FileRenameParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FileRenameResponse + + /** + * ImageKit.io allows you to upload files directly from both the server and client sides. For + * server-side uploads, private API key authentication is used. For client-side uploads, + * generate a one-time `token`, `signature`, and `expire` from your secure backend using private + * API. + * [Learn more](/docs/api-reference/upload-file/upload-file#how-to-implement-client-side-file-upload) + * about how to implement client-side file upload. + * + * The [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security by verifying + * the entire payload using JWT. + * + * **File size limit** \ On the free plan, the maximum upload file sizes are 20MB for images, + * audio, and raw files and 100MB for videos. On the paid plan, these limits increase to 40MB + * for images, audio, and raw files and 2GB for videos. These limits can be further increased + * with higher-tier plans. + * + * **Version limit** \ A file can have a maximum of 100 versions. + * + * **Demo applications** + * - A full-fledged + * [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting + * file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. + * - [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies. + */ + fun upload(params: FileUploadParams): FileUploadResponse = upload(params, RequestOptions.none()) + + /** @see upload */ + fun upload( + params: FileUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FileUploadResponse + + /** A view of [FileService] 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): FileService.WithRawResponse + + fun bulk(): BulkService.WithRawResponse + + fun versions(): VersionService.WithRawResponse + + fun metadata(): MetadataService.WithRawResponse + + /** + * Returns a raw HTTP response for `patch /v1/files/{fileId}/details`, but is otherwise the + * same as [FileService.update]. + */ + @MustBeClosed + fun update(fileId: String): HttpResponseFor = + update(fileId, FileUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + fileId: String, + params: FileUpdateParams = FileUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + fileId: String, + params: FileUpdateParams = FileUpdateParams.none(), + ): HttpResponseFor = update(fileId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: FileUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see update */ + @MustBeClosed + fun update(params: FileUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + fileId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(fileId, FileUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/files/{fileId}`, but is otherwise the same as + * [FileService.delete]. + */ + @MustBeClosed + fun delete(fileId: String): HttpResponse = delete(fileId, FileDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + fileId: String, + params: FileDeleteParams = FileDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = delete(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + fileId: String, + params: FileDeleteParams = FileDeleteParams.none(), + ): HttpResponse = delete(fileId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: FileDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see delete */ + @MustBeClosed + fun delete(params: FileDeleteParams): HttpResponse = delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete(fileId: String, requestOptions: RequestOptions): HttpResponse = + delete(fileId, FileDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /v1/files/copy`, but is otherwise the same as + * [FileService.copy]. + */ + @MustBeClosed + fun copy(params: FileCopyParams): HttpResponseFor = + copy(params, RequestOptions.none()) + + /** @see copy */ + @MustBeClosed + fun copy( + params: FileCopyParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/files/{fileId}/details`, but is otherwise the + * same as [FileService.get]. + */ + @MustBeClosed + fun get(fileId: String): HttpResponseFor = get(fileId, FileGetParams.none()) + + /** @see get */ + @MustBeClosed + fun get( + fileId: String, + params: FileGetParams = FileGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = get(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see get */ + @MustBeClosed + fun get( + fileId: String, + params: FileGetParams = FileGetParams.none(), + ): HttpResponseFor = get(fileId, params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get( + params: FileGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see get */ + @MustBeClosed + fun get(params: FileGetParams): HttpResponseFor = get(params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get(fileId: String, requestOptions: RequestOptions): HttpResponseFor = + get(fileId, FileGetParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /v1/files/move`, but is otherwise the same as + * [FileService.move]. + */ + @MustBeClosed + fun move(params: FileMoveParams): HttpResponseFor = + move(params, RequestOptions.none()) + + /** @see move */ + @MustBeClosed + fun move( + params: FileMoveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /v1/files/rename`, but is otherwise the same as + * [FileService.rename]. + */ + @MustBeClosed + fun rename(params: FileRenameParams): HttpResponseFor = + rename(params, RequestOptions.none()) + + /** @see rename */ + @MustBeClosed + fun rename( + params: FileRenameParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /api/v1/files/upload`, but is otherwise the same as + * [FileService.upload]. + */ + @MustBeClosed + fun upload(params: FileUploadParams): HttpResponseFor = + upload(params, RequestOptions.none()) + + /** @see upload */ + @MustBeClosed + fun upload( + params: FileUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt new file mode 100644 index 00000000..6448f2b3 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt @@ -0,0 +1,334 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.handlers.emptyHandler +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.json +import com.imagekit.api.core.http.multipartFormData +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepare +import com.imagekit.api.models.files.File +import com.imagekit.api.models.files.FileCopyParams +import com.imagekit.api.models.files.FileCopyResponse +import com.imagekit.api.models.files.FileDeleteParams +import com.imagekit.api.models.files.FileGetParams +import com.imagekit.api.models.files.FileMoveParams +import com.imagekit.api.models.files.FileMoveResponse +import com.imagekit.api.models.files.FileRenameParams +import com.imagekit.api.models.files.FileRenameResponse +import com.imagekit.api.models.files.FileUpdateParams +import com.imagekit.api.models.files.FileUpdateResponse +import com.imagekit.api.models.files.FileUploadParams +import com.imagekit.api.models.files.FileUploadResponse +import com.imagekit.api.services.blocking.files.BulkService +import com.imagekit.api.services.blocking.files.BulkServiceImpl +import com.imagekit.api.services.blocking.files.MetadataService +import com.imagekit.api.services.blocking.files.MetadataServiceImpl +import com.imagekit.api.services.blocking.files.VersionService +import com.imagekit.api.services.blocking.files.VersionServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class FileServiceImpl internal constructor(private val clientOptions: ClientOptions) : FileService { + + private val withRawResponse: FileService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val bulk: BulkService by lazy { BulkServiceImpl(clientOptions) } + + private val versions: VersionService by lazy { VersionServiceImpl(clientOptions) } + + private val metadata: MetadataService by lazy { MetadataServiceImpl(clientOptions) } + + override fun withRawResponse(): FileService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): FileService = + FileServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun bulk(): BulkService = bulk + + override fun versions(): VersionService = versions + + override fun metadata(): MetadataService = metadata + + override fun update( + params: FileUpdateParams, + requestOptions: RequestOptions, + ): FileUpdateResponse = + // patch /v1/files/{fileId}/details + withRawResponse().update(params, requestOptions).parse() + + override fun delete(params: FileDeleteParams, requestOptions: RequestOptions) { + // delete /v1/files/{fileId} + withRawResponse().delete(params, requestOptions) + } + + override fun copy(params: FileCopyParams, requestOptions: RequestOptions): FileCopyResponse = + // post /v1/files/copy + withRawResponse().copy(params, requestOptions).parse() + + override fun get(params: FileGetParams, requestOptions: RequestOptions): File = + // get /v1/files/{fileId}/details + withRawResponse().get(params, requestOptions).parse() + + override fun move(params: FileMoveParams, requestOptions: RequestOptions): FileMoveResponse = + // post /v1/files/move + withRawResponse().move(params, requestOptions).parse() + + override fun rename( + params: FileRenameParams, + requestOptions: RequestOptions, + ): FileRenameResponse = + // put /v1/files/rename + withRawResponse().rename(params, requestOptions).parse() + + override fun upload( + params: FileUploadParams, + requestOptions: RequestOptions, + ): FileUploadResponse = + // post /api/v1/files/upload + withRawResponse().upload(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FileService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val bulk: BulkService.WithRawResponse by lazy { + BulkServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val versions: VersionService.WithRawResponse by lazy { + VersionServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val metadata: MetadataService.WithRawResponse by lazy { + MetadataServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): FileService.WithRawResponse = + FileServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun bulk(): BulkService.WithRawResponse = bulk + + override fun versions(): VersionService.WithRawResponse = versions + + override fun metadata(): MetadataService.WithRawResponse = metadata + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: FileUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", params._pathParam(0), "details") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: FileDeleteParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", 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 copyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun copy( + params: FileCopyParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", "copy") + .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 { copyHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: FileGetParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", params._pathParam(0), "details") + .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() + } + } + } + } + + private val moveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun move( + params: FileMoveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", "move") + .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 { moveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val renameHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun rename( + params: FileRenameParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", "rename") + .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 { renameHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val uploadHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun upload( + params: FileUploadParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl( + if (clientOptions.baseUrlOverridden()) clientOptions.baseUrl() + else "https://upload.imagekit.io" + ) + .addPathSegments("api", "v1", "files", "upload") + .body(multipartFormData(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 { uploadHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FolderService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FolderService.kt new file mode 100644 index 00000000..e38020e4 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FolderService.kt @@ -0,0 +1,193 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.folders.FolderCopyParams +import com.imagekit.api.models.folders.FolderCopyResponse +import com.imagekit.api.models.folders.FolderCreateParams +import com.imagekit.api.models.folders.FolderCreateResponse +import com.imagekit.api.models.folders.FolderDeleteParams +import com.imagekit.api.models.folders.FolderDeleteResponse +import com.imagekit.api.models.folders.FolderMoveParams +import com.imagekit.api.models.folders.FolderMoveResponse +import com.imagekit.api.models.folders.FolderRenameParams +import com.imagekit.api.models.folders.FolderRenameResponse +import com.imagekit.api.services.blocking.folders.JobService +import java.util.function.Consumer + +interface FolderService { + + /** + * 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): FolderService + + fun job(): JobService + + /** + * This will create a new folder. You can specify the folder name and location of the parent + * folder where this new folder should be created. + */ + fun create(params: FolderCreateParams): FolderCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: FolderCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FolderCreateResponse + + /** + * This will delete a folder and all its contents permanently. The API returns an empty + * response. + */ + fun delete(params: FolderDeleteParams): FolderDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: FolderDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FolderDeleteResponse + + /** + * This will copy one folder into another. The selected folder, its nested folders, files, and + * their versions (in `includeVersions` is set to true) are copied in this operation. Note: If + * any file at the destination has the same name as the source file, then the source file and + * its versions will be appended to the destination file version history. + */ + fun copy(params: FolderCopyParams): FolderCopyResponse = copy(params, RequestOptions.none()) + + /** @see copy */ + fun copy( + params: FolderCopyParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FolderCopyResponse + + /** + * This will move one folder into another. The selected folder, its nested folders, files, and + * their versions are moved in this operation. Note: If any file at the destination has the same + * name as the source file, then the source file and its versions will be appended to the + * destination file version history. + */ + fun move(params: FolderMoveParams): FolderMoveResponse = move(params, RequestOptions.none()) + + /** @see move */ + fun move( + params: FolderMoveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FolderMoveResponse + + /** + * This API allows you to rename an existing folder. The folder and all its nested assets and + * sub-folders will remain unchanged, but their paths will be updated to reflect the new folder + * name. + */ + fun rename(params: FolderRenameParams): FolderRenameResponse = + rename(params, RequestOptions.none()) + + /** @see rename */ + fun rename( + params: FolderRenameParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FolderRenameResponse + + /** A view of [FolderService] 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): FolderService.WithRawResponse + + fun job(): JobService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/folder`, but is otherwise the same as + * [FolderService.create]. + */ + @MustBeClosed + fun create(params: FolderCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: FolderCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `delete /v1/folder`, but is otherwise the same as + * [FolderService.delete]. + */ + @MustBeClosed + fun delete(params: FolderDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: FolderDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v1/bulkJobs/copyFolder`, but is otherwise the same + * as [FolderService.copy]. + */ + @MustBeClosed + fun copy(params: FolderCopyParams): HttpResponseFor = + copy(params, RequestOptions.none()) + + /** @see copy */ + @MustBeClosed + fun copy( + params: FolderCopyParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v1/bulkJobs/moveFolder`, but is otherwise the same + * as [FolderService.move]. + */ + @MustBeClosed + fun move(params: FolderMoveParams): HttpResponseFor = + move(params, RequestOptions.none()) + + /** @see move */ + @MustBeClosed + fun move( + params: FolderMoveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v1/bulkJobs/renameFolder`, but is otherwise the + * same as [FolderService.rename]. + */ + @MustBeClosed + fun rename(params: FolderRenameParams): HttpResponseFor = + rename(params, RequestOptions.none()) + + /** @see rename */ + @MustBeClosed + fun rename( + params: FolderRenameParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FolderServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FolderServiceImpl.kt new file mode 100644 index 00000000..42a20bf2 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FolderServiceImpl.kt @@ -0,0 +1,242 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.json +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepare +import com.imagekit.api.models.folders.FolderCopyParams +import com.imagekit.api.models.folders.FolderCopyResponse +import com.imagekit.api.models.folders.FolderCreateParams +import com.imagekit.api.models.folders.FolderCreateResponse +import com.imagekit.api.models.folders.FolderDeleteParams +import com.imagekit.api.models.folders.FolderDeleteResponse +import com.imagekit.api.models.folders.FolderMoveParams +import com.imagekit.api.models.folders.FolderMoveResponse +import com.imagekit.api.models.folders.FolderRenameParams +import com.imagekit.api.models.folders.FolderRenameResponse +import com.imagekit.api.services.blocking.folders.JobService +import com.imagekit.api.services.blocking.folders.JobServiceImpl +import java.util.function.Consumer + +class FolderServiceImpl internal constructor(private val clientOptions: ClientOptions) : + FolderService { + + private val withRawResponse: FolderService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val job: JobService by lazy { JobServiceImpl(clientOptions) } + + override fun withRawResponse(): FolderService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): FolderService = + FolderServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun job(): JobService = job + + override fun create( + params: FolderCreateParams, + requestOptions: RequestOptions, + ): FolderCreateResponse = + // post /v1/folder + withRawResponse().create(params, requestOptions).parse() + + override fun delete( + params: FolderDeleteParams, + requestOptions: RequestOptions, + ): FolderDeleteResponse = + // delete /v1/folder + withRawResponse().delete(params, requestOptions).parse() + + override fun copy( + params: FolderCopyParams, + requestOptions: RequestOptions, + ): FolderCopyResponse = + // post /v1/bulkJobs/copyFolder + withRawResponse().copy(params, requestOptions).parse() + + override fun move( + params: FolderMoveParams, + requestOptions: RequestOptions, + ): FolderMoveResponse = + // post /v1/bulkJobs/moveFolder + withRawResponse().move(params, requestOptions).parse() + + override fun rename( + params: FolderRenameParams, + requestOptions: RequestOptions, + ): FolderRenameResponse = + // post /v1/bulkJobs/renameFolder + withRawResponse().rename(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FolderService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val job: JobService.WithRawResponse by lazy { + JobServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): FolderService.WithRawResponse = + FolderServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun job(): JobService.WithRawResponse = job + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: FolderCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "folder") + .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 deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun delete( + params: FolderDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "folder") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val copyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun copy( + params: FolderCopyParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "bulkJobs", "copyFolder") + .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 { copyHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val moveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun move( + params: FolderMoveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "bulkJobs", "moveFolder") + .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 { moveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val renameHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun rename( + params: FolderRenameParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "bulkJobs", "renameFolder") + .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 { renameHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookService.kt new file mode 100644 index 00000000..953d9d20 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookService.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.webhooks.UnsafeUnwrapWebhookEvent +import com.imagekit.api.models.webhooks.UnwrapWebhookEvent +import java.util.function.Consumer + +interface WebhookService { + + /** + * 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): WebhookService + + /** + * Unwraps a webhook event from its JSON representation. + * + * @throws ImageKitInvalidDataException if the body could not be parsed. + */ + fun unsafeUnwrap(body: String): UnsafeUnwrapWebhookEvent + + /** + * Unwraps a webhook event from its JSON representation. + * + * @throws ImageKitInvalidDataException if the body could not be parsed. + */ + fun unwrap(body: String): UnwrapWebhookEvent + + /** A view of [WebhookService] 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): WebhookService.WithRawResponse + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookServiceImpl.kt new file mode 100644 index 00000000..7e81f403 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookServiceImpl.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.webhooks.UnsafeUnwrapWebhookEvent +import com.imagekit.api.models.webhooks.UnwrapWebhookEvent +import java.util.function.Consumer + +class WebhookServiceImpl internal constructor(private val clientOptions: ClientOptions) : + WebhookService { + + private val withRawResponse: WebhookService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): WebhookService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): WebhookService = + WebhookServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + /** + * Unwraps a webhook event from its JSON representation. + * + * @throws ImageKitInvalidDataException if the body could not be parsed. + */ + override fun unsafeUnwrap(body: String): UnsafeUnwrapWebhookEvent = + try { + clientOptions.jsonMapper.readValue(body, jacksonTypeRef()) + } catch (e: Exception) { + throw ImageKitInvalidDataException("Error parsing body", e) + } + + /** + * Unwraps a webhook event from its JSON representation. + * + * @throws ImageKitInvalidDataException if the body could not be parsed. + */ + override fun unwrap(body: String): UnwrapWebhookEvent = + try { + clientOptions.jsonMapper.readValue(body, jacksonTypeRef()) + } catch (e: Exception) { + throw ImageKitInvalidDataException("Error parsing body", e) + } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + WebhookService.WithRawResponse { + + override fun withOptions( + modifier: Consumer + ): WebhookService.WithRawResponse = + WebhookServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginService.kt new file mode 100644 index 00000000..5d735334 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginService.kt @@ -0,0 +1,295 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.accounts + +import com.google.errorprone.annotations.MustBeClosed +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.accounts.origins.OriginCreateParams +import com.imagekit.api.models.accounts.origins.OriginDeleteParams +import com.imagekit.api.models.accounts.origins.OriginGetParams +import com.imagekit.api.models.accounts.origins.OriginListParams +import com.imagekit.api.models.accounts.origins.OriginResponse +import com.imagekit.api.models.accounts.origins.OriginUpdateParams +import java.util.function.Consumer + +interface OriginService { + + /** + * 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): OriginService + + /** + * **Note:** This API is currently in beta. Creates a new origin and returns the origin object. + */ + fun create(params: OriginCreateParams): OriginResponse = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: OriginCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OriginResponse + + /** + * **Note:** This API is currently in beta. Updates the origin identified by `id` and returns + * the updated origin object. + */ + fun update(id: String, params: OriginUpdateParams): OriginResponse = + update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + id: String, + params: OriginUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OriginResponse = update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update(params: OriginUpdateParams): OriginResponse = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: OriginUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OriginResponse + + /** + * **Note:** This API is currently in beta. Returns an array of all configured origins for the + * current account. + */ + fun list(): List = list(OriginListParams.none()) + + /** @see list */ + fun list( + params: OriginListParams = OriginListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List + + /** @see list */ + fun list(params: OriginListParams = OriginListParams.none()): List = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List = + list(OriginListParams.none(), requestOptions) + + /** + * **Note:** This API is currently in beta. Permanently removes the origin identified by `id`. + * If the origin is in use by any URL‑endpoints, the API will return an error. + */ + fun delete(id: String) = delete(id, OriginDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: OriginDeleteParams = OriginDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete(id: String, params: OriginDeleteParams = OriginDeleteParams.none()) = + delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete(params: OriginDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) + + /** @see delete */ + fun delete(params: OriginDeleteParams) = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions) = + delete(id, OriginDeleteParams.none(), requestOptions) + + /** **Note:** This API is currently in beta. Retrieves the origin identified by `id`. */ + fun get(id: String): OriginResponse = get(id, OriginGetParams.none()) + + /** @see get */ + fun get( + id: String, + params: OriginGetParams = OriginGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): OriginResponse = get(params.toBuilder().id(id).build(), requestOptions) + + /** @see get */ + fun get(id: String, params: OriginGetParams = OriginGetParams.none()): OriginResponse = + get(id, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: OriginGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OriginResponse + + /** @see get */ + fun get(params: OriginGetParams): OriginResponse = get(params, RequestOptions.none()) + + /** @see get */ + fun get(id: String, requestOptions: RequestOptions): OriginResponse = + get(id, OriginGetParams.none(), requestOptions) + + /** A view of [OriginService] 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): OriginService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/accounts/origins`, but is otherwise the same as + * [OriginService.create]. + */ + @MustBeClosed + fun create(params: OriginCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: OriginCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /v1/accounts/origins/{id}`, but is otherwise the + * same as [OriginService.update]. + */ + @MustBeClosed + fun update(id: String, params: OriginUpdateParams): HttpResponseFor = + update(id, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + id: String, + params: OriginUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: OriginUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: OriginUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/accounts/origins`, but is otherwise the same as + * [OriginService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor> = list(OriginListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: OriginListParams = OriginListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor> + + /** @see list */ + @MustBeClosed + fun list( + params: OriginListParams = OriginListParams.none() + ): HttpResponseFor> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor> = + list(OriginListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/accounts/origins/{id}`, but is otherwise the + * same as [OriginService.delete]. + */ + @MustBeClosed fun delete(id: String): HttpResponse = delete(id, OriginDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: OriginDeleteParams = OriginDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: OriginDeleteParams = OriginDeleteParams.none(), + ): HttpResponse = delete(id, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: OriginDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see delete */ + @MustBeClosed + fun delete(params: OriginDeleteParams): HttpResponse = delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete(id: String, requestOptions: RequestOptions): HttpResponse = + delete(id, OriginDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/accounts/origins/{id}`, but is otherwise the + * same as [OriginService.get]. + */ + @MustBeClosed + fun get(id: String): HttpResponseFor = get(id, OriginGetParams.none()) + + /** @see get */ + @MustBeClosed + fun get( + id: String, + params: OriginGetParams = OriginGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = get(params.toBuilder().id(id).build(), requestOptions) + + /** @see get */ + @MustBeClosed + fun get( + id: String, + params: OriginGetParams = OriginGetParams.none(), + ): HttpResponseFor = get(id, params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get( + params: OriginGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see get */ + @MustBeClosed + fun get(params: OriginGetParams): HttpResponseFor = + get(params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get(id: String, requestOptions: RequestOptions): HttpResponseFor = + get(id, OriginGetParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceImpl.kt new file mode 100644 index 00000000..bbbd6358 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceImpl.kt @@ -0,0 +1,224 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.accounts + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.handlers.emptyHandler +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.json +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepare +import com.imagekit.api.models.accounts.origins.OriginCreateParams +import com.imagekit.api.models.accounts.origins.OriginDeleteParams +import com.imagekit.api.models.accounts.origins.OriginGetParams +import com.imagekit.api.models.accounts.origins.OriginListParams +import com.imagekit.api.models.accounts.origins.OriginResponse +import com.imagekit.api.models.accounts.origins.OriginUpdateParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class OriginServiceImpl internal constructor(private val clientOptions: ClientOptions) : + OriginService { + + private val withRawResponse: OriginService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): OriginService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): OriginService = + OriginServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: OriginCreateParams, + requestOptions: RequestOptions, + ): OriginResponse = + // post /v1/accounts/origins + withRawResponse().create(params, requestOptions).parse() + + override fun update( + params: OriginUpdateParams, + requestOptions: RequestOptions, + ): OriginResponse = + // put /v1/accounts/origins/{id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: OriginListParams, + requestOptions: RequestOptions, + ): List = + // get /v1/accounts/origins + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: OriginDeleteParams, requestOptions: RequestOptions) { + // delete /v1/accounts/origins/{id} + withRawResponse().delete(params, requestOptions) + } + + override fun get(params: OriginGetParams, requestOptions: RequestOptions): OriginResponse = + // get /v1/accounts/origins/{id} + withRawResponse().get(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OriginService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): OriginService.WithRawResponse = + OriginServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: OriginCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "accounts", "origins") + .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: OriginUpdateParams, + 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.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "accounts", "origins", 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: OriginListParams, + requestOptions: RequestOptions, + ): HttpResponseFor> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "accounts", "origins") + .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: OriginDeleteParams, + 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", "accounts", "origins", 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: OriginGetParams, + 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", "accounts", "origins", 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/main/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointService.kt new file mode 100644 index 00000000..bdd10fd3 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointService.kt @@ -0,0 +1,314 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.accounts + +import com.google.errorprone.annotations.MustBeClosed +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +import java.util.function.Consumer + +interface UrlEndpointService { + + /** + * 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): UrlEndpointService + + /** + * **Note:** This API is currently in beta. Creates a new URL‑endpoint and returns the resulting + * object. + */ + fun create(params: UrlEndpointCreateParams): UrlEndpointResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: UrlEndpointCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): UrlEndpointResponse + + /** + * **Note:** This API is currently in beta. Updates the URL‑endpoint identified by `id` and + * returns the updated object. + */ + fun update(id: String, params: UrlEndpointUpdateParams): UrlEndpointResponse = + update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + id: String, + params: UrlEndpointUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): UrlEndpointResponse = update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update(params: UrlEndpointUpdateParams): UrlEndpointResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: UrlEndpointUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): UrlEndpointResponse + + /** + * **Note:** This API is currently in beta. Returns an array of all URL‑endpoints configured + * including the default URL-endpoint generated by ImageKit during account creation. + */ + fun list(): List = list(UrlEndpointListParams.none()) + + /** @see list */ + fun list( + params: UrlEndpointListParams = UrlEndpointListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List + + /** @see list */ + fun list( + params: UrlEndpointListParams = UrlEndpointListParams.none() + ): List = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List = + list(UrlEndpointListParams.none(), requestOptions) + + /** + * **Note:** This API is currently in beta. Deletes the URL‑endpoint identified by `id`. You + * cannot delete the default URL‑endpoint created by ImageKit during account creation. + */ + fun delete(id: String) = delete(id, UrlEndpointDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: UrlEndpointDeleteParams = UrlEndpointDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete(id: String, params: UrlEndpointDeleteParams = UrlEndpointDeleteParams.none()) = + delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: UrlEndpointDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) + + /** @see delete */ + fun delete(params: UrlEndpointDeleteParams) = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions) = + delete(id, UrlEndpointDeleteParams.none(), requestOptions) + + /** **Note:** This API is currently in beta. Retrieves the URL‑endpoint identified by `id`. */ + fun get(id: String): UrlEndpointResponse = get(id, UrlEndpointGetParams.none()) + + /** @see get */ + fun get( + id: String, + params: UrlEndpointGetParams = UrlEndpointGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): UrlEndpointResponse = get(params.toBuilder().id(id).build(), requestOptions) + + /** @see get */ + fun get( + id: String, + params: UrlEndpointGetParams = UrlEndpointGetParams.none(), + ): UrlEndpointResponse = get(id, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: UrlEndpointGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): UrlEndpointResponse + + /** @see get */ + fun get(params: UrlEndpointGetParams): UrlEndpointResponse = get(params, RequestOptions.none()) + + /** @see get */ + fun get(id: String, requestOptions: RequestOptions): UrlEndpointResponse = + get(id, UrlEndpointGetParams.none(), requestOptions) + + /** + * A view of [UrlEndpointService] 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 + ): UrlEndpointService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/accounts/url-endpoints`, but is otherwise the + * same as [UrlEndpointService.create]. + */ + @MustBeClosed + fun create(params: UrlEndpointCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: UrlEndpointCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /v1/accounts/url-endpoints/{id}`, but is otherwise + * the same as [UrlEndpointService.update]. + */ + @MustBeClosed + fun update( + id: String, + params: UrlEndpointUpdateParams, + ): HttpResponseFor = update(id, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + id: String, + params: UrlEndpointUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: UrlEndpointUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: UrlEndpointUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/accounts/url-endpoints`, but is otherwise the + * same as [UrlEndpointService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor> = list(UrlEndpointListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: UrlEndpointListParams = UrlEndpointListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor> + + /** @see list */ + @MustBeClosed + fun list( + params: UrlEndpointListParams = UrlEndpointListParams.none() + ): HttpResponseFor> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor> = + list(UrlEndpointListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/accounts/url-endpoints/{id}`, but is + * otherwise the same as [UrlEndpointService.delete]. + */ + @MustBeClosed + fun delete(id: String): HttpResponse = delete(id, UrlEndpointDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: UrlEndpointDeleteParams = UrlEndpointDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: UrlEndpointDeleteParams = UrlEndpointDeleteParams.none(), + ): HttpResponse = delete(id, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: UrlEndpointDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see delete */ + @MustBeClosed + fun delete(params: UrlEndpointDeleteParams): HttpResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete(id: String, requestOptions: RequestOptions): HttpResponse = + delete(id, UrlEndpointDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/accounts/url-endpoints/{id}`, but is otherwise + * the same as [UrlEndpointService.get]. + */ + @MustBeClosed + fun get(id: String): HttpResponseFor = + get(id, UrlEndpointGetParams.none()) + + /** @see get */ + @MustBeClosed + fun get( + id: String, + params: UrlEndpointGetParams = UrlEndpointGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + get(params.toBuilder().id(id).build(), requestOptions) + + /** @see get */ + @MustBeClosed + fun get( + id: String, + params: UrlEndpointGetParams = UrlEndpointGetParams.none(), + ): HttpResponseFor = get(id, params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get( + params: UrlEndpointGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see get */ + @MustBeClosed + fun get(params: UrlEndpointGetParams): HttpResponseFor = + get(params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get(id: String, requestOptions: RequestOptions): HttpResponseFor = + get(id, UrlEndpointGetParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceImpl.kt new file mode 100644 index 00000000..5d2e17e0 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceImpl.kt @@ -0,0 +1,227 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.accounts + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.handlers.emptyHandler +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.json +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepare +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class UrlEndpointServiceImpl internal constructor(private val clientOptions: ClientOptions) : + UrlEndpointService { + + private val withRawResponse: UrlEndpointService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): UrlEndpointService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): UrlEndpointService = + UrlEndpointServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: UrlEndpointCreateParams, + requestOptions: RequestOptions, + ): UrlEndpointResponse = + // post /v1/accounts/url-endpoints + withRawResponse().create(params, requestOptions).parse() + + override fun update( + params: UrlEndpointUpdateParams, + requestOptions: RequestOptions, + ): UrlEndpointResponse = + // put /v1/accounts/url-endpoints/{id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: UrlEndpointListParams, + requestOptions: RequestOptions, + ): List = + // get /v1/accounts/url-endpoints + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: UrlEndpointDeleteParams, requestOptions: RequestOptions) { + // delete /v1/accounts/url-endpoints/{id} + withRawResponse().delete(params, requestOptions) + } + + override fun get( + params: UrlEndpointGetParams, + requestOptions: RequestOptions, + ): UrlEndpointResponse = + // get /v1/accounts/url-endpoints/{id} + withRawResponse().get(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UrlEndpointService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): UrlEndpointService.WithRawResponse = + UrlEndpointServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: UrlEndpointCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "accounts", "url-endpoints") + .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: UrlEndpointUpdateParams, + 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.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "accounts", "url-endpoints", 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: UrlEndpointListParams, + requestOptions: RequestOptions, + ): HttpResponseFor> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "accounts", "url-endpoints") + .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: UrlEndpointDeleteParams, + 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", "accounts", "url-endpoints", 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: UrlEndpointGetParams, + 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", "accounts", "url-endpoints", 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/main/kotlin/com/imagekit/api/services/blocking/accounts/UsageService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UsageService.kt new file mode 100644 index 00000000..5cdcc94c --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UsageService.kt @@ -0,0 +1,65 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.accounts + +import com.google.errorprone.annotations.MustBeClosed +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.accounts.usage.UsageGetParams +import com.imagekit.api.models.accounts.usage.UsageGetResponse +import java.util.function.Consumer + +interface UsageService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UsageService + + /** + * Get the account usage information between two dates. Note that the API response includes data + * from the start date while excluding data from the end date. In other words, the data covers + * the period starting from the specified start date up to, but not including, the end date. + */ + fun get(params: UsageGetParams): UsageGetResponse = get(params, RequestOptions.none()) + + /** @see get */ + fun get( + params: UsageGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): UsageGetResponse + + /** A view of [UsageService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UsageService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/accounts/usage`, but is otherwise the same as + * [UsageService.get]. + */ + @MustBeClosed + fun get(params: UsageGetParams): HttpResponseFor = + get(params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get( + params: UsageGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceImpl.kt new file mode 100644 index 00000000..e9884d20 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceImpl.kt @@ -0,0 +1,77 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.accounts + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepare +import com.imagekit.api.models.accounts.usage.UsageGetParams +import com.imagekit.api.models.accounts.usage.UsageGetResponse +import java.util.function.Consumer + +class UsageServiceImpl internal constructor(private val clientOptions: ClientOptions) : + UsageService { + + private val withRawResponse: UsageService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): UsageService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): UsageService = + UsageServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun get(params: UsageGetParams, requestOptions: RequestOptions): UsageGetResponse = + // get /v1/accounts/usage + withRawResponse().get(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UsageService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): UsageService.WithRawResponse = + UsageServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: UsageGetParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "accounts", "usage") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { getHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/V2Service.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/V2Service.kt new file mode 100644 index 00000000..9452e843 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/V2Service.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.beta + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.services.blocking.beta.v2.FileService +import java.util.function.Consumer + +interface V2Service { + + /** + * 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): V2Service + + fun files(): FileService + + /** A view of [V2Service] 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): V2Service.WithRawResponse + + fun files(): FileService.WithRawResponse + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/V2ServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/V2ServiceImpl.kt new file mode 100644 index 00000000..43beea32 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/V2ServiceImpl.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.beta + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.services.blocking.beta.v2.FileService +import com.imagekit.api.services.blocking.beta.v2.FileServiceImpl +import java.util.function.Consumer + +class V2ServiceImpl internal constructor(private val clientOptions: ClientOptions) : V2Service { + + private val withRawResponse: V2Service.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val files: FileService by lazy { FileServiceImpl(clientOptions) } + + override fun withRawResponse(): V2Service.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): V2Service = + V2ServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun files(): FileService = files + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + V2Service.WithRawResponse { + + private val files: FileService.WithRawResponse by lazy { + FileServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): V2Service.WithRawResponse = + V2ServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun files(): FileService.WithRawResponse = files + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/v2/FileService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/v2/FileService.kt new file mode 100644 index 00000000..70d9c464 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/v2/FileService.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.beta.v2 + +import com.google.errorprone.annotations.MustBeClosed +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.beta.v2.files.FileUploadParams +import com.imagekit.api.models.beta.v2.files.FileUploadResponse +import java.util.function.Consumer + +interface FileService { + + /** + * 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): FileService + + /** + * The V2 API enhances security by verifying the entire payload using JWT. This API is in beta. + * + * ImageKit.io allows you to upload files directly from both the server and client sides. For + * server-side uploads, private API key authentication is used. For client-side uploads, + * generate a one-time `token` from your secure backend using private API. + * [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) + * about how to implement secure client-side file upload. + * + * **File size limit** \ On the free plan, the maximum upload file sizes are 20MB for images, + * audio, and raw files, and 100MB for videos. On the paid plan, these limits increase to 40MB + * for images, audio, and raw files, and 2GB for videos. These limits can be further increased + * with higher-tier plans. + * + * **Version limit** \ A file can have a maximum of 100 versions. + * + * **Demo applications** + * - A full-fledged + * [upload widget using Uppy](https://github.com/imagekit-samples/uppy-uploader), supporting + * file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. + * - [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies. + */ + fun upload(params: FileUploadParams): FileUploadResponse = upload(params, RequestOptions.none()) + + /** @see upload */ + fun upload( + params: FileUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FileUploadResponse + + /** A view of [FileService] 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): FileService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v2/files/upload`, but is otherwise the same as + * [FileService.upload]. + */ + @MustBeClosed + fun upload(params: FileUploadParams): HttpResponseFor = + upload(params, RequestOptions.none()) + + /** @see upload */ + @MustBeClosed + fun upload( + params: FileUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceImpl.kt new file mode 100644 index 00000000..17203aee --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceImpl.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.beta.v2 + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.multipartFormData +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepare +import com.imagekit.api.models.beta.v2.files.FileUploadParams +import com.imagekit.api.models.beta.v2.files.FileUploadResponse +import java.util.function.Consumer + +class FileServiceImpl internal constructor(private val clientOptions: ClientOptions) : FileService { + + private val withRawResponse: FileService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): FileService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): FileService = + FileServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun upload( + params: FileUploadParams, + requestOptions: RequestOptions, + ): FileUploadResponse = + // post /api/v2/files/upload + withRawResponse().upload(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FileService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): FileService.WithRawResponse = + FileServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val uploadHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun upload( + params: FileUploadParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl( + if (clientOptions.baseUrlOverridden()) clientOptions.baseUrl() + else "https://upload.imagekit.io" + ) + .addPathSegments("api", "v2", "files", "upload") + .body(multipartFormData(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 { uploadHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/cache/InvalidationService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/cache/InvalidationService.kt new file mode 100644 index 00000000..4a5bd1e0 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/cache/InvalidationService.kt @@ -0,0 +1,147 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.cache + +import com.google.errorprone.annotations.MustBeClosed +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.cache.invalidation.InvalidationCreateParams +import com.imagekit.api.models.cache.invalidation.InvalidationCreateResponse +import com.imagekit.api.models.cache.invalidation.InvalidationGetParams +import com.imagekit.api.models.cache.invalidation.InvalidationGetResponse +import java.util.function.Consumer + +interface InvalidationService { + + /** + * 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): InvalidationService + + /** + * This API will purge CDN cache and ImageKit.io's internal cache for a file. Note: Purge cache + * is an asynchronous process and it may take some time to reflect the changes. + */ + fun create(params: InvalidationCreateParams): InvalidationCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: InvalidationCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InvalidationCreateResponse + + /** This API returns the status of a purge cache request. */ + fun get(requestId: String): InvalidationGetResponse = + get(requestId, InvalidationGetParams.none()) + + /** @see get */ + fun get( + requestId: String, + params: InvalidationGetParams = InvalidationGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): InvalidationGetResponse = + get(params.toBuilder().requestId(requestId).build(), requestOptions) + + /** @see get */ + fun get( + requestId: String, + params: InvalidationGetParams = InvalidationGetParams.none(), + ): InvalidationGetResponse = get(requestId, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: InvalidationGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InvalidationGetResponse + + /** @see get */ + fun get(params: InvalidationGetParams): InvalidationGetResponse = + get(params, RequestOptions.none()) + + /** @see get */ + fun get(requestId: String, requestOptions: RequestOptions): InvalidationGetResponse = + get(requestId, InvalidationGetParams.none(), requestOptions) + + /** + * A view of [InvalidationService] 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 + ): InvalidationService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/files/purge`, but is otherwise the same as + * [InvalidationService.create]. + */ + @MustBeClosed + fun create(params: InvalidationCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: InvalidationCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/files/purge/{requestId}`, but is otherwise the + * same as [InvalidationService.get]. + */ + @MustBeClosed + fun get(requestId: String): HttpResponseFor = + get(requestId, InvalidationGetParams.none()) + + /** @see get */ + @MustBeClosed + fun get( + requestId: String, + params: InvalidationGetParams = InvalidationGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + get(params.toBuilder().requestId(requestId).build(), requestOptions) + + /** @see get */ + @MustBeClosed + fun get( + requestId: String, + params: InvalidationGetParams = InvalidationGetParams.none(), + ): HttpResponseFor = get(requestId, params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get( + params: InvalidationGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see get */ + @MustBeClosed + fun get(params: InvalidationGetParams): HttpResponseFor = + get(params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get( + requestId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + get(requestId, InvalidationGetParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceImpl.kt new file mode 100644 index 00000000..72aee8db --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceImpl.kt @@ -0,0 +1,123 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.cache + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.json +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepare +import com.imagekit.api.models.cache.invalidation.InvalidationCreateParams +import com.imagekit.api.models.cache.invalidation.InvalidationCreateResponse +import com.imagekit.api.models.cache.invalidation.InvalidationGetParams +import com.imagekit.api.models.cache.invalidation.InvalidationGetResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class InvalidationServiceImpl internal constructor(private val clientOptions: ClientOptions) : + InvalidationService { + + private val withRawResponse: InvalidationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): InvalidationService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): InvalidationService = + InvalidationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: InvalidationCreateParams, + requestOptions: RequestOptions, + ): InvalidationCreateResponse = + // post /v1/files/purge + withRawResponse().create(params, requestOptions).parse() + + override fun get( + params: InvalidationGetParams, + requestOptions: RequestOptions, + ): InvalidationGetResponse = + // get /v1/files/purge/{requestId} + withRawResponse().get(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InvalidationService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): InvalidationService.WithRawResponse = + InvalidationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: InvalidationCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", "purge") + .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 getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: InvalidationGetParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("requestId", params.requestId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", "purge", 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/main/kotlin/com/imagekit/api/services/blocking/files/BulkService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BulkService.kt new file mode 100644 index 00000000..dbc0c409 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BulkService.kt @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.files + +import com.google.errorprone.annotations.MustBeClosed +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.files.bulk.BulkAddTagsParams +import com.imagekit.api.models.files.bulk.BulkAddTagsResponse +import com.imagekit.api.models.files.bulk.BulkDeleteParams +import com.imagekit.api.models.files.bulk.BulkDeleteResponse +import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams +import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse +import com.imagekit.api.models.files.bulk.BulkRemoveTagsParams +import com.imagekit.api.models.files.bulk.BulkRemoveTagsResponse +import java.util.function.Consumer + +interface BulkService { + + /** + * 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): BulkService + + /** + * This API deletes multiple files and all their file versions permanently. + * + * Note: If a file or specific transformation has been requested in the past, then the response + * is cached. Deleting a file does not purge the cache. You can purge the cache using purge + * cache API. + * + * A maximum of 100 files can be deleted at a time. + */ + fun delete(params: BulkDeleteParams): BulkDeleteResponse = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: BulkDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkDeleteResponse + + /** + * This API adds tags to multiple files in bulk. A maximum of 50 files can be specified at a + * time. + */ + fun addTags(params: BulkAddTagsParams): BulkAddTagsResponse = + addTags(params, RequestOptions.none()) + + /** @see addTags */ + fun addTags( + params: BulkAddTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkAddTagsResponse + + /** + * This API removes AITags from multiple files in bulk. A maximum of 50 files can be specified + * at a time. + */ + fun removeAiTags(params: BulkRemoveAiTagsParams): BulkRemoveAiTagsResponse = + removeAiTags(params, RequestOptions.none()) + + /** @see removeAiTags */ + fun removeAiTags( + params: BulkRemoveAiTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkRemoveAiTagsResponse + + /** + * This API removes tags from multiple files in bulk. A maximum of 50 files can be specified at + * a time. + */ + fun removeTags(params: BulkRemoveTagsParams): BulkRemoveTagsResponse = + removeTags(params, RequestOptions.none()) + + /** @see removeTags */ + fun removeTags( + params: BulkRemoveTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkRemoveTagsResponse + + /** A view of [BulkService] 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): BulkService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/files/batch/deleteByFileIds`, but is otherwise + * the same as [BulkService.delete]. + */ + @MustBeClosed + fun delete(params: BulkDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: BulkDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v1/files/addTags`, but is otherwise the same as + * [BulkService.addTags]. + */ + @MustBeClosed + fun addTags(params: BulkAddTagsParams): HttpResponseFor = + addTags(params, RequestOptions.none()) + + /** @see addTags */ + @MustBeClosed + fun addTags( + params: BulkAddTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v1/files/removeAITags`, but is otherwise the same + * as [BulkService.removeAiTags]. + */ + @MustBeClosed + fun removeAiTags( + params: BulkRemoveAiTagsParams + ): HttpResponseFor = removeAiTags(params, RequestOptions.none()) + + /** @see removeAiTags */ + @MustBeClosed + fun removeAiTags( + params: BulkRemoveAiTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v1/files/removeTags`, but is otherwise the same as + * [BulkService.removeTags]. + */ + @MustBeClosed + fun removeTags(params: BulkRemoveTagsParams): HttpResponseFor = + removeTags(params, RequestOptions.none()) + + /** @see removeTags */ + @MustBeClosed + fun removeTags( + params: BulkRemoveTagsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BulkServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BulkServiceImpl.kt new file mode 100644 index 00000000..537b3912 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BulkServiceImpl.kt @@ -0,0 +1,192 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.files + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.json +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepare +import com.imagekit.api.models.files.bulk.BulkAddTagsParams +import com.imagekit.api.models.files.bulk.BulkAddTagsResponse +import com.imagekit.api.models.files.bulk.BulkDeleteParams +import com.imagekit.api.models.files.bulk.BulkDeleteResponse +import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams +import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse +import com.imagekit.api.models.files.bulk.BulkRemoveTagsParams +import com.imagekit.api.models.files.bulk.BulkRemoveTagsResponse +import java.util.function.Consumer + +class BulkServiceImpl internal constructor(private val clientOptions: ClientOptions) : BulkService { + + private val withRawResponse: BulkService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BulkService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): BulkService = + BulkServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun delete( + params: BulkDeleteParams, + requestOptions: RequestOptions, + ): BulkDeleteResponse = + // post /v1/files/batch/deleteByFileIds + withRawResponse().delete(params, requestOptions).parse() + + override fun addTags( + params: BulkAddTagsParams, + requestOptions: RequestOptions, + ): BulkAddTagsResponse = + // post /v1/files/addTags + withRawResponse().addTags(params, requestOptions).parse() + + override fun removeAiTags( + params: BulkRemoveAiTagsParams, + requestOptions: RequestOptions, + ): BulkRemoveAiTagsResponse = + // post /v1/files/removeAITags + withRawResponse().removeAiTags(params, requestOptions).parse() + + override fun removeTags( + params: BulkRemoveTagsParams, + requestOptions: RequestOptions, + ): BulkRemoveTagsResponse = + // post /v1/files/removeTags + withRawResponse().removeTags(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BulkService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): BulkService.WithRawResponse = + BulkServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun delete( + params: BulkDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", "batch", "deleteByFileIds") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val addTagsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun addTags( + params: BulkAddTagsParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", "addTags") + .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 { addTagsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val removeAiTagsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun removeAiTags( + params: BulkRemoveAiTagsParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", "removeAITags") + .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 { removeAiTagsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val removeTagsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun removeTags( + params: BulkRemoveTagsParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", "removeTags") + .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 { removeTagsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataService.kt new file mode 100644 index 00000000..d873401f --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataService.kt @@ -0,0 +1,138 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.files + +import com.google.errorprone.annotations.MustBeClosed +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.files.Metadata +import com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams +import com.imagekit.api.models.files.metadata.MetadataGetParams +import java.util.function.Consumer + +interface MetadataService { + + /** + * 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): MetadataService + + /** + * You can programmatically get image EXIF, pHash, and other metadata for uploaded files in the + * ImageKit.io media library using this API. + * + * You can also get the metadata in upload API response by passing `metadata` in + * `responseFields` parameter. + */ + fun get(fileId: String): Metadata = get(fileId, MetadataGetParams.none()) + + /** @see get */ + fun get( + fileId: String, + params: MetadataGetParams = MetadataGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Metadata = get(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see get */ + fun get(fileId: String, params: MetadataGetParams = MetadataGetParams.none()): Metadata = + get(fileId, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: MetadataGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Metadata + + /** @see get */ + fun get(params: MetadataGetParams): Metadata = get(params, RequestOptions.none()) + + /** @see get */ + fun get(fileId: String, requestOptions: RequestOptions): Metadata = + get(fileId, MetadataGetParams.none(), requestOptions) + + /** + * Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API. + */ + fun getFromUrl(params: MetadataGetFromUrlParams): Metadata = + getFromUrl(params, RequestOptions.none()) + + /** @see getFromUrl */ + fun getFromUrl( + params: MetadataGetFromUrlParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Metadata + + /** A view of [MetadataService] 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): MetadataService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/files/{fileId}/metadata`, but is otherwise the + * same as [MetadataService.get]. + */ + @MustBeClosed + fun get(fileId: String): HttpResponseFor = get(fileId, MetadataGetParams.none()) + + /** @see get */ + @MustBeClosed + fun get( + fileId: String, + params: MetadataGetParams = MetadataGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + get(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see get */ + @MustBeClosed + fun get( + fileId: String, + params: MetadataGetParams = MetadataGetParams.none(), + ): HttpResponseFor = get(fileId, params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get( + params: MetadataGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see get */ + @MustBeClosed + fun get(params: MetadataGetParams): HttpResponseFor = + get(params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get(fileId: String, requestOptions: RequestOptions): HttpResponseFor = + get(fileId, MetadataGetParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/files/metadata`, but is otherwise the same as + * [MetadataService.getFromUrl]. + */ + @MustBeClosed + fun getFromUrl(params: MetadataGetFromUrlParams): HttpResponseFor = + getFromUrl(params, RequestOptions.none()) + + /** @see getFromUrl */ + @MustBeClosed + fun getFromUrl( + params: MetadataGetFromUrlParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceImpl.kt new file mode 100644 index 00000000..558676a7 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceImpl.kt @@ -0,0 +1,116 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.files + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepare +import com.imagekit.api.models.files.Metadata +import com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams +import com.imagekit.api.models.files.metadata.MetadataGetParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class MetadataServiceImpl internal constructor(private val clientOptions: ClientOptions) : + MetadataService { + + private val withRawResponse: MetadataService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): MetadataService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): MetadataService = + MetadataServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun get(params: MetadataGetParams, requestOptions: RequestOptions): Metadata = + // get /v1/files/{fileId}/metadata + withRawResponse().get(params, requestOptions).parse() + + override fun getFromUrl( + params: MetadataGetFromUrlParams, + requestOptions: RequestOptions, + ): Metadata = + // get /v1/files/metadata + withRawResponse().getFromUrl(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + MetadataService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): MetadataService.WithRawResponse = + MetadataServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: MetadataGetParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", params._pathParam(0), "metadata") + .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() + } + } + } + } + + private val getFromUrlHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getFromUrl( + params: MetadataGetFromUrlParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", "metadata") + .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 { getFromUrlHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/VersionService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/VersionService.kt new file mode 100644 index 00000000..eb1195eb --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/VersionService.kt @@ -0,0 +1,261 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.files + +import com.google.errorprone.annotations.MustBeClosed +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.files.File +import com.imagekit.api.models.files.versions.VersionDeleteParams +import com.imagekit.api.models.files.versions.VersionDeleteResponse +import com.imagekit.api.models.files.versions.VersionGetParams +import com.imagekit.api.models.files.versions.VersionListParams +import com.imagekit.api.models.files.versions.VersionRestoreParams +import java.util.function.Consumer + +interface VersionService { + + /** + * 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): VersionService + + /** This API returns details of all versions of a file. */ + fun list(fileId: String): List = list(fileId, VersionListParams.none()) + + /** @see list */ + fun list( + fileId: String, + params: VersionListParams = VersionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List = list(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see list */ + fun list(fileId: String, params: VersionListParams = VersionListParams.none()): List = + list(fileId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: VersionListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List + + /** @see list */ + fun list(params: VersionListParams): List = list(params, RequestOptions.none()) + + /** @see list */ + fun list(fileId: String, requestOptions: RequestOptions): List = + list(fileId, VersionListParams.none(), requestOptions) + + /** + * This API deletes a non-current file version permanently. The API returns an empty response. + * + * Note: If you want to delete all versions of a file, use the delete file API. + */ + fun delete(versionId: String, params: VersionDeleteParams): VersionDeleteResponse = + delete(versionId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + versionId: String, + params: VersionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): VersionDeleteResponse = + delete(params.toBuilder().versionId(versionId).build(), requestOptions) + + /** @see delete */ + fun delete(params: VersionDeleteParams): VersionDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: VersionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): VersionDeleteResponse + + /** This API returns an object with details or attributes of a file version. */ + fun get(versionId: String, params: VersionGetParams): File = + get(versionId, params, RequestOptions.none()) + + /** @see get */ + fun get( + versionId: String, + params: VersionGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): File = get(params.toBuilder().versionId(versionId).build(), requestOptions) + + /** @see get */ + fun get(params: VersionGetParams): File = get(params, RequestOptions.none()) + + /** @see get */ + fun get(params: VersionGetParams, requestOptions: RequestOptions = RequestOptions.none()): File + + /** This API restores a file version as the current file version. */ + fun restore(versionId: String, params: VersionRestoreParams): File = + restore(versionId, params, RequestOptions.none()) + + /** @see restore */ + fun restore( + versionId: String, + params: VersionRestoreParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): File = restore(params.toBuilder().versionId(versionId).build(), requestOptions) + + /** @see restore */ + fun restore(params: VersionRestoreParams): File = restore(params, RequestOptions.none()) + + /** @see restore */ + fun restore( + params: VersionRestoreParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): File + + /** A view of [VersionService] 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): VersionService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/files/{fileId}/versions`, but is otherwise the + * same as [VersionService.list]. + */ + @MustBeClosed + fun list(fileId: String): HttpResponseFor> = + list(fileId, VersionListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + fileId: String, + params: VersionListParams = VersionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor> = + list(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list( + fileId: String, + params: VersionListParams = VersionListParams.none(), + ): HttpResponseFor> = list(fileId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: VersionListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor> + + /** @see list */ + @MustBeClosed + fun list(params: VersionListParams): HttpResponseFor> = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(fileId: String, requestOptions: RequestOptions): HttpResponseFor> = + list(fileId, VersionListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/files/{fileId}/versions/{versionId}`, but is + * otherwise the same as [VersionService.delete]. + */ + @MustBeClosed + fun delete( + versionId: String, + params: VersionDeleteParams, + ): HttpResponseFor = delete(versionId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + versionId: String, + params: VersionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + delete(params.toBuilder().versionId(versionId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete(params: VersionDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: VersionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/files/{fileId}/versions/{versionId}`, but is + * otherwise the same as [VersionService.get]. + */ + @MustBeClosed + fun get(versionId: String, params: VersionGetParams): HttpResponseFor = + get(versionId, params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get( + versionId: String, + params: VersionGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + get(params.toBuilder().versionId(versionId).build(), requestOptions) + + /** @see get */ + @MustBeClosed + fun get(params: VersionGetParams): HttpResponseFor = + get(params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get( + params: VersionGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /v1/files/{fileId}/versions/{versionId}/restore`, + * but is otherwise the same as [VersionService.restore]. + */ + @MustBeClosed + fun restore(versionId: String, params: VersionRestoreParams): HttpResponseFor = + restore(versionId, params, RequestOptions.none()) + + /** @see restore */ + @MustBeClosed + fun restore( + versionId: String, + params: VersionRestoreParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + restore(params.toBuilder().versionId(versionId).build(), requestOptions) + + /** @see restore */ + @MustBeClosed + fun restore(params: VersionRestoreParams): HttpResponseFor = + restore(params, RequestOptions.none()) + + /** @see restore */ + @MustBeClosed + fun restore( + params: VersionRestoreParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/VersionServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/VersionServiceImpl.kt new file mode 100644 index 00000000..2637882f --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/VersionServiceImpl.kt @@ -0,0 +1,211 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.files + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.json +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepare +import com.imagekit.api.models.files.File +import com.imagekit.api.models.files.versions.VersionDeleteParams +import com.imagekit.api.models.files.versions.VersionDeleteResponse +import com.imagekit.api.models.files.versions.VersionGetParams +import com.imagekit.api.models.files.versions.VersionListParams +import com.imagekit.api.models.files.versions.VersionRestoreParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class VersionServiceImpl internal constructor(private val clientOptions: ClientOptions) : + VersionService { + + private val withRawResponse: VersionService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): VersionService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): VersionService = + VersionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list(params: VersionListParams, requestOptions: RequestOptions): List = + // get /v1/files/{fileId}/versions + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: VersionDeleteParams, + requestOptions: RequestOptions, + ): VersionDeleteResponse = + // delete /v1/files/{fileId}/versions/{versionId} + withRawResponse().delete(params, requestOptions).parse() + + override fun get(params: VersionGetParams, requestOptions: RequestOptions): File = + // get /v1/files/{fileId}/versions/{versionId} + withRawResponse().get(params, requestOptions).parse() + + override fun restore(params: VersionRestoreParams, requestOptions: RequestOptions): File = + // put /v1/files/{fileId}/versions/{versionId}/restore + withRawResponse().restore(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + VersionService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): VersionService.WithRawResponse = + VersionServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) + + override fun list( + params: VersionListParams, + requestOptions: RequestOptions, + ): HttpResponseFor> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "files", params._pathParam(0), "versions") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun delete( + params: VersionDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("versionId", params.versionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v1", + "files", + params._pathParam(0), + "versions", + params._pathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: VersionGetParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("versionId", params.versionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v1", + "files", + params._pathParam(0), + "versions", + params._pathParam(1), + ) + .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() + } + } + } + } + + private val restoreHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun restore( + params: VersionRestoreParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("versionId", params.versionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "v1", + "files", + params._pathParam(0), + "versions", + params._pathParam(1), + "restore", + ) + .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 { restoreHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/folders/JobService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/folders/JobService.kt new file mode 100644 index 00000000..e40fbfb6 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/folders/JobService.kt @@ -0,0 +1,104 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.folders + +import com.google.errorprone.annotations.MustBeClosed +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.folders.job.JobGetParams +import com.imagekit.api.models.folders.job.JobGetResponse +import java.util.function.Consumer + +interface JobService { + + /** + * 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): JobService + + /** This API returns the status of a bulk job like copy and move folder operations. */ + fun get(jobId: String): JobGetResponse = get(jobId, JobGetParams.none()) + + /** @see get */ + fun get( + jobId: String, + params: JobGetParams = JobGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): JobGetResponse = get(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see get */ + fun get(jobId: String, params: JobGetParams = JobGetParams.none()): JobGetResponse = + get(jobId, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: JobGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): JobGetResponse + + /** @see get */ + fun get(params: JobGetParams): JobGetResponse = get(params, RequestOptions.none()) + + /** @see get */ + fun get(jobId: String, requestOptions: RequestOptions): JobGetResponse = + get(jobId, JobGetParams.none(), requestOptions) + + /** A view of [JobService] 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): JobService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/bulkJobs/{jobId}`, but is otherwise the same as + * [JobService.get]. + */ + @MustBeClosed + fun get(jobId: String): HttpResponseFor = get(jobId, JobGetParams.none()) + + /** @see get */ + @MustBeClosed + fun get( + jobId: String, + params: JobGetParams = JobGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + get(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see get */ + @MustBeClosed + fun get( + jobId: String, + params: JobGetParams = JobGetParams.none(), + ): HttpResponseFor = get(jobId, params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get( + params: JobGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see get */ + @MustBeClosed + fun get(params: JobGetParams): HttpResponseFor = + get(params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get(jobId: String, requestOptions: RequestOptions): HttpResponseFor = + get(jobId, JobGetParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/folders/JobServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/folders/JobServiceImpl.kt new file mode 100644 index 00000000..8be9b5af --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/folders/JobServiceImpl.kt @@ -0,0 +1,81 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.folders + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepare +import com.imagekit.api.models.folders.job.JobGetParams +import com.imagekit.api.models.folders.job.JobGetResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class JobServiceImpl internal constructor(private val clientOptions: ClientOptions) : JobService { + + private val withRawResponse: JobService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): JobService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): JobService = + JobServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun get(params: JobGetParams, requestOptions: RequestOptions): JobGetResponse = + // get /v1/bulkJobs/{jobId} + withRawResponse().get(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + JobService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): JobService.WithRawResponse = + JobServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: JobGetParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "bulkJobs", 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/main/resources/META-INF/proguard/image-kit-java-core.pro b/image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro new file mode 100644 index 00000000..dedf4950 --- /dev/null +++ b/image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro @@ -0,0 +1,32 @@ +# Jackson uses reflection and depends heavily on runtime attributes. +-keepattributes Exceptions,InnerClasses,Signature,Deprecated,*Annotation* + +# Jackson uses Kotlin reflection utilities, which themselves use reflection to access things. +-keep class kotlin.reflect.** { *; } +-keep class kotlin.Metadata { *; } + +# Jackson uses reflection to access enum members (e.g. via `java.lang.Class.getEnumConstants()`). +-keepclassmembers class com.fasterxml.jackson.** extends java.lang.Enum { + ; + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +# Jackson uses reflection to access annotation members. +-keepclassmembers @interface com.fasterxml.jackson.annotation.** { + *; +} + +# Jackson uses reified type information to serialize and deserialize our classes (via `TypeReference`). +-keep class com.fasterxml.jackson.core.type.TypeReference { *; } +-keep class * extends com.fasterxml.jackson.core.type.TypeReference { *; } + +# Jackson uses reflection to access our class serializers and deserializers. +-keep @com.fasterxml.jackson.databind.annotation.JsonSerialize class com.imagekit.api.** { *; } +-keep @com.fasterxml.jackson.databind.annotation.JsonDeserialize class com.imagekit.api.** { *; } + +# Jackson uses reflection to serialize and deserialize our classes based on their constructors and annotated members. +-keepclassmembers class com.imagekit.api.** { + (...); + @com.fasterxml.jackson.annotation.* *; +} \ No newline at end of file diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/TestServerExtension.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/TestServerExtension.kt new file mode 100644 index 00000000..ac78240e --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/TestServerExtension.kt @@ -0,0 +1,62 @@ +package com.imagekit.api + +import java.lang.RuntimeException +import java.net.URL +import org.junit.jupiter.api.extension.BeforeAllCallback +import org.junit.jupiter.api.extension.ConditionEvaluationResult +import org.junit.jupiter.api.extension.ExecutionCondition +import org.junit.jupiter.api.extension.ExtensionContext + +class TestServerExtension : BeforeAllCallback, ExecutionCondition { + + override fun beforeAll(context: ExtensionContext?) { + try { + URL(BASE_URL).openConnection().connect() + } catch (e: Exception) { + throw RuntimeException( + """ + The test suite will not run without a mock Prism server running against your OpenAPI spec. + + You can set the environment variable `SKIP_MOCK_TESTS` to `true` to skip running any tests + that require the mock server. + + To fix: + + 1. Install Prism (requires Node 16+): + + With npm: + $ npm install -g @stoplight/prism-cli + + With yarn: + $ yarn global add @stoplight/prism-cli + + 2. Run the mock server + + To run the server, pass in the path of your OpenAPI spec to the prism command: + $ prism mock path/to/your.openapi.yml + """ + .trimIndent(), + e, + ) + } + } + + override fun evaluateExecutionCondition(context: ExtensionContext): ConditionEvaluationResult { + return if (System.getenv(SKIP_TESTS_ENV).toBoolean()) { + ConditionEvaluationResult.disabled( + "Environment variable $SKIP_TESTS_ENV is set to true" + ) + } else { + ConditionEvaluationResult.enabled( + "Environment variable $SKIP_TESTS_ENV is not set to true" + ) + } + } + + companion object { + + val BASE_URL = System.getenv("TEST_API_BASE_URL") ?: "http://localhost:4010" + + const val SKIP_TESTS_ENV: String = "SKIP_MOCK_TESTS" + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt new file mode 100644 index 00000000..4ce82f36 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.core + +import com.imagekit.api.core.http.HttpClient +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.kotlin.mock +import org.mockito.kotlin.never +import org.mockito.kotlin.verify + +@ExtendWith(MockitoExtension::class) +internal class ClientOptionsTest { + + private val httpClient = mock() + + @Test + fun toBuilder_whenOriginalClientOptionsGarbageCollected_doesNotCloseOriginalClient() { + var clientOptions = + ClientOptions.builder() + .httpClient(httpClient) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + verify(httpClient, never()).close() + + // Overwrite the `clientOptions` variable so that the original `ClientOptions` is GC'd. + clientOptions = clientOptions.toBuilder().build() + System.gc() + Thread.sleep(100) + + verify(httpClient, never()).close() + // This exists so that `clientOptions` is still reachable. + assertThat(clientOptions).isEqualTo(clientOptions) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ObjectMappersTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ObjectMappersTest.kt new file mode 100644 index 00000000..b340cb7d --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ObjectMappersTest.kt @@ -0,0 +1,102 @@ +package com.imagekit.api.core + +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.exc.MismatchedInputException +import com.fasterxml.jackson.module.kotlin.readValue +import java.time.LocalDateTime +import kotlin.reflect.KClass +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.catchThrowable +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertDoesNotThrow +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource +import org.junitpioneer.jupiter.cartesian.CartesianTest + +internal class ObjectMappersTest { + + internal class ClassWithBooleanFieldPrefixedWithIs(private val isActive: JsonField) { + + @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive + } + + @Test + fun write_whenFieldPrefixedWithIs_keepsPrefix() { + val value = ClassWithBooleanFieldPrefixedWithIs(JsonField.of(true)) + + val json = jsonMapper().writeValueAsString(value) + + assertThat(json).isEqualTo("{\"is_active\":true}") + } + + internal class Class(@get:JsonProperty("field") @JsonProperty("field") val field: String) + + enum class ShapeTestCase(val value: Any, val kClass: KClass<*>) { + STRING("Hello World!", String::class), + BOOLEAN(true, Boolean::class), + FLOAT(3.14F, Float::class), + DOUBLE(3.14, Double::class), + INTEGER(42, Int::class), + LONG(42L, Long::class), + MAP(mapOf("property" to "value"), Map::class), + CLASS(Class("Hello World!"), Class::class), + LIST(listOf(1, 2, 3), List::class); + + companion object { + val VALID_CONVERSIONS = + listOf( + FLOAT to DOUBLE, + FLOAT to INTEGER, + FLOAT to LONG, + DOUBLE to FLOAT, + DOUBLE to INTEGER, + DOUBLE to LONG, + INTEGER to FLOAT, + INTEGER to DOUBLE, + INTEGER to LONG, + LONG to FLOAT, + LONG to DOUBLE, + LONG to INTEGER, + CLASS to MAP, + // These aren't actually valid, but coercion configs don't work for String until + // v2.14.0: https://github.com/FasterXML/jackson-databind/issues/3240 + // We currently test on v2.13.4. + BOOLEAN to STRING, + FLOAT to STRING, + DOUBLE to STRING, + INTEGER to STRING, + LONG to STRING, + ) + } + } + + @CartesianTest + fun read(@CartesianTest.Enum shape1: ShapeTestCase, @CartesianTest.Enum shape2: ShapeTestCase) { + val jsonMapper = jsonMapper() + val json = jsonMapper.writeValueAsString(shape1.value) + + val e = catchThrowable { jsonMapper.readValue(json, shape2.kClass.java) } + + if (shape1 == shape2 || shape1 to shape2 in ShapeTestCase.VALID_CONVERSIONS) { + assertThat(e).isNull() + } else { + assertThat(e).isInstanceOf(MismatchedInputException::class.java) + } + } + + enum class LenientLocalDateTimeTestCase(val string: String) { + DATE("1998-04-21"), + DATE_TIME("1998-04-21T04:00:00"), + ZONED_DATE_TIME_1("1998-04-21T04:00:00+03:00"), + ZONED_DATE_TIME_2("1998-04-21T04:00:00Z"), + } + + @ParameterizedTest + @EnumSource + fun readLocalDateTime_lenient(testCase: LenientLocalDateTimeTestCase) { + val jsonMapper = jsonMapper() + val json = jsonMapper.writeValueAsString(testCase.string) + + assertDoesNotThrow { jsonMapper().readValue(json) } + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/PhantomReachableTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/PhantomReachableTest.kt new file mode 100644 index 00000000..8e35e81d --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/PhantomReachableTest.kt @@ -0,0 +1,27 @@ +package com.imagekit.api.core + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PhantomReachableTest { + + @Test + fun closeWhenPhantomReachable_whenObservedIsGarbageCollected_closesCloseable() { + var closed = false + val closeable = AutoCloseable { closed = true } + + closeWhenPhantomReachable( + // Pass an inline object for the object to observe so that it becomes immediately + // unreachable. + Any(), + closeable, + ) + + assertThat(closed).isFalse() + + System.gc() + Thread.sleep(100) + + assertThat(closed).isTrue() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/UtilsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/UtilsTest.kt new file mode 100644 index 00000000..1da50cf8 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/UtilsTest.kt @@ -0,0 +1,33 @@ +package com.imagekit.api.core + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UtilsTest { + @Test + fun contentDeepEquals() { + assertThat(42 contentEquals 42).isTrue() + assertThat(42 contentEquals "Hello World!").isFalse() + assertThat(byteArrayOf(1, 2, 3) contentEquals byteArrayOf(1, 2, 3)).isTrue() + assertThat(byteArrayOf(1, 2, 3) contentEquals byteArrayOf(1, 2, 4)).isFalse() + assertThat( + arrayOf(byteArrayOf(1, 2), byteArrayOf(3)) contentEquals + arrayOf(byteArrayOf(1, 2), byteArrayOf(3)) + ) + .isTrue() + assertThat( + arrayOf(byteArrayOf(1, 2), byteArrayOf(3)) contentEquals + arrayOf(byteArrayOf(1), byteArrayOf(2, 3)) + ) + .isFalse() + } + + @Test + fun contentToString() { + assertThat((42).contentToString()).isEqualTo("42") + assertThat("Hello World!".contentToString()).isEqualTo("Hello World!") + assertThat(byteArrayOf(1, 2, 3).contentToString()).isEqualTo("[1, 2, 3]") + assertThat(arrayOf(byteArrayOf(1, 2), byteArrayOf(3)).contentToString()) + .isEqualTo("[[1, 2], [3]]") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ValuesTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ValuesTest.kt new file mode 100644 index 00000000..e044d52d --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ValuesTest.kt @@ -0,0 +1,144 @@ +package com.imagekit.api.core + +import java.util.Optional +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class ValuesTest { + companion object { + private val NON_JSON = Any() + } + + enum class TestCase( + val value: JsonField<*>, + val expectedIsMissing: Boolean = false, + val expectedIsNull: Boolean = false, + val expectedAsKnown: Optional<*> = Optional.empty(), + val expectedAsBoolean: Optional = Optional.empty(), + val expectedAsNumber: Optional = Optional.empty(), + val expectedAsString: Optional = Optional.empty(), + val expectedAsArray: Optional> = Optional.empty(), + val expectedAsObject: Optional> = Optional.empty(), + ) { + MISSING(JsonMissing.of(), expectedIsMissing = true), + NULL(JsonNull.of(), expectedIsNull = true), + KNOWN(KnownValue.of(NON_JSON), expectedAsKnown = Optional.of(NON_JSON)), + KNOWN_BOOLEAN( + KnownValue.of(true), + expectedAsKnown = Optional.of(true), + expectedAsBoolean = Optional.of(true), + ), + BOOLEAN(JsonBoolean.of(true), expectedAsBoolean = Optional.of(true)), + KNOWN_NUMBER( + KnownValue.of(42), + expectedAsKnown = Optional.of(42), + expectedAsNumber = Optional.of(42), + ), + NUMBER(JsonNumber.of(42), expectedAsNumber = Optional.of(42)), + KNOWN_STRING( + KnownValue.of("hello"), + expectedAsKnown = Optional.of("hello"), + expectedAsString = Optional.of("hello"), + ), + STRING(JsonString.of("hello"), expectedAsString = Optional.of("hello")), + KNOWN_ARRAY_NOT_ALL_JSON( + KnownValue.of(listOf("a", "b", NON_JSON)), + expectedAsKnown = Optional.of(listOf("a", "b", NON_JSON)), + ), + KNOWN_ARRAY( + KnownValue.of(listOf("a", "b", "c")), + expectedAsKnown = Optional.of(listOf("a", "b", "c")), + expectedAsArray = + Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + ), + ARRAY( + JsonArray.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + expectedAsArray = + Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + ), + KNOWN_OBJECT_NOT_ALL_STRING_KEYS( + KnownValue.of(mapOf("a" to "b", 42 to "c")), + expectedAsKnown = Optional.of(mapOf("a" to "b", 42 to "c")), + ), + KNOWN_OBJECT_NOT_ALL_JSON( + KnownValue.of(mapOf("a" to "b", "b" to NON_JSON)), + expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to NON_JSON)), + ), + KNOWN_OBJECT( + KnownValue.of(mapOf("a" to "b", "b" to "c")), + expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to "c")), + expectedAsObject = + Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + ), + OBJECT( + JsonObject.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + expectedAsObject = + Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + ), + } + + @ParameterizedTest + @EnumSource + fun isMissing(testCase: TestCase) { + val isMissing = testCase.value.isMissing() + + assertThat(isMissing).isEqualTo(testCase.expectedIsMissing) + } + + @ParameterizedTest + @EnumSource + fun isNull(testCase: TestCase) { + val isNull = testCase.value.isNull() + + assertThat(isNull).isEqualTo(testCase.expectedIsNull) + } + + @ParameterizedTest + @EnumSource + fun asKnown(testCase: TestCase) { + val known = testCase.value.asKnown() + + assertThat(known).isEqualTo(testCase.expectedAsKnown) + } + + @ParameterizedTest + @EnumSource + fun asBoolean(testCase: TestCase) { + val boolean = testCase.value.asBoolean() + + assertThat(boolean).isEqualTo(testCase.expectedAsBoolean) + } + + @ParameterizedTest + @EnumSource + fun asNumber(testCase: TestCase) { + val number = testCase.value.asNumber() + + assertThat(number).isEqualTo(testCase.expectedAsNumber) + } + + @ParameterizedTest + @EnumSource + fun asString(testCase: TestCase) { + val string = testCase.value.asString() + + assertThat(string).isEqualTo(testCase.expectedAsString) + } + + @ParameterizedTest + @EnumSource + fun asArray(testCase: TestCase) { + val array = testCase.value.asArray() + + assertThat(array).isEqualTo(testCase.expectedAsArray) + } + + @ParameterizedTest + @EnumSource + fun asObject(testCase: TestCase) { + val obj = testCase.value.asObject() + + assertThat(obj).isEqualTo(testCase.expectedAsObject) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/AsyncStreamResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/AsyncStreamResponseTest.kt new file mode 100644 index 00000000..bb36e9b2 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/AsyncStreamResponseTest.kt @@ -0,0 +1,268 @@ +package com.imagekit.api.core.http + +import java.util.* +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.stream.Stream +import kotlin.streams.asStream +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.catchThrowable +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertDoesNotThrow +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.kotlin.* + +@ExtendWith(MockitoExtension::class) +internal class AsyncStreamResponseTest { + + companion object { + private val ERROR = RuntimeException("ERROR!") + } + + private val streamResponse = + spy> { + doReturn(Stream.of("chunk1", "chunk2", "chunk3")).whenever(it).stream() + } + private val erroringStreamResponse = + spy> { + doReturn( + sequence { + yield("chunk1") + yield("chunk2") + throw ERROR + } + .asStream() + ) + .whenever(it) + .stream() + } + private val executor = + spy { + doAnswer { invocation -> invocation.getArgument(0).run() } + .whenever(it) + .execute(any()) + } + private val handler = mock>() + + @Test + fun subscribe_whenAlreadySubscribed_throws() { + val asyncStreamResponse = CompletableFuture>().toAsync(executor) + asyncStreamResponse.subscribe {} + + val throwable = catchThrowable { asyncStreamResponse.subscribe {} } + + assertThat(throwable).isInstanceOf(IllegalStateException::class.java) + assertThat(throwable).hasMessage("Cannot subscribe more than once") + verify(executor, never()).execute(any()) + } + + @Test + fun subscribe_whenClosed_throws() { + val asyncStreamResponse = CompletableFuture>().toAsync(executor) + asyncStreamResponse.close() + + val throwable = catchThrowable { asyncStreamResponse.subscribe {} } + + assertThat(throwable).isInstanceOf(IllegalStateException::class.java) + assertThat(throwable).hasMessage("Cannot subscribe after the response is closed") + verify(executor, never()).execute(any()) + } + + @Test + fun subscribe_whenFutureCompletesAfterClose_doesNothing() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + asyncStreamResponse.close() + + future.complete(streamResponse) + + verify(handler, never()).onNext(any()) + verify(handler, never()).onComplete(any()) + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenFutureErrors_callsOnComplete() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + + future.completeExceptionally(ERROR) + + verify(handler, never()).onNext(any()) + verify(handler, times(1)).onComplete(Optional.of(ERROR)) + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenFutureCompletes_runsHandler() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + + future.complete(streamResponse) + + inOrder(handler, streamResponse) { + verify(handler, times(1)).onNext("chunk1") + verify(handler, times(1)).onNext("chunk2") + verify(handler, times(1)).onNext("chunk3") + verify(handler, times(1)).onComplete(Optional.empty()) + verify(streamResponse, times(1)).close() + } + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenStreamErrors_callsOnCompleteEarly() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + + future.complete(erroringStreamResponse) + + inOrder(handler, erroringStreamResponse) { + verify(handler, times(1)).onNext("chunk1") + verify(handler, times(1)).onNext("chunk2") + verify(handler, times(1)).onComplete(Optional.of(ERROR)) + verify(erroringStreamResponse, times(1)).close() + } + verify(executor, times(1)).execute(any()) + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureNotCompleted_onCompleteFutureNotCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isNotCompleted + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureErrors_onCompleteFutureCompletedExceptionally() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + future.completeExceptionally(ERROR) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureCompletedButStillStreaming_onCompleteFutureNotCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + future.complete(streamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isNotCompleted + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureCompletedAndStreamErrors_onCompleteFutureCompletedExceptionally() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + future.complete(erroringStreamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureCompletedAndStreamCompleted_onCompleteFutureCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + future.complete(streamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } + + @Test + fun onCompleteFuture_whenHandlerOnCompleteWithoutThrowableThrows_onCompleteFutureCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe( + object : AsyncStreamResponse.Handler { + override fun onNext(value: String) {} + + override fun onComplete(error: Optional) = throw ERROR + } + ) + future.complete(streamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } + + @Test + fun onCompleteFuture_whenHandlerOnCompleteWithThrowableThrows_onCompleteFutureCompletedExceptionally() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe( + object : AsyncStreamResponse.Handler { + override fun onNext(value: String) {} + + override fun onComplete(error: Optional) = throw ERROR + } + ) + future.complete(erroringStreamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenClosed_onCompleteFutureCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.close() + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } + + @Test + fun close_whenNotClosed_closesStreamResponse() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + + asyncStreamResponse.close() + future.complete(streamResponse) + + verify(streamResponse, times(1)).close() + } + + @Test + fun close_whenAlreadyClosed_doesNothing() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.close() + future.complete(streamResponse) + + asyncStreamResponse.close() + + verify(streamResponse, times(1)).close() + } + + @Test + fun close_whenFutureErrors_doesNothing() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.close() + + assertDoesNotThrow { future.completeExceptionally(ERROR) } + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/HeadersTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/HeadersTest.kt new file mode 100644 index 00000000..af17ead3 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/HeadersTest.kt @@ -0,0 +1,242 @@ +package com.imagekit.api.core.http + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class HeadersTest { + + enum class TestCase( + val headers: Headers, + val expectedMap: Map>, + val expectedSize: Int, + ) { + EMPTY(Headers.builder().build(), expectedMap = mapOf(), expectedSize = 0), + PUT_ONE( + Headers.builder().put("name", "value").build(), + expectedMap = mapOf("name" to listOf("value")), + expectedSize = 1, + ), + PUT_MULTIPLE( + Headers.builder().put("name", listOf("value1", "value2")).build(), + expectedMap = mapOf("name" to listOf("value1", "value2")), + expectedSize = 2, + ), + MULTIPLE_PUT( + Headers.builder().put("name1", "value").put("name2", "value").build(), + expectedMap = mapOf("name1" to listOf("value"), "name2" to listOf("value")), + expectedSize = 2, + ), + MULTIPLE_PUT_SAME_NAME( + Headers.builder().put("name", "value1").put("name", "value2").build(), + expectedMap = mapOf("name" to listOf("value1", "value2")), + expectedSize = 2, + ), + MULTIPLE_PUT_MULTIPLE( + Headers.builder() + .put("name", listOf("value1", "value2")) + .put("name", listOf("value1", "value2")) + .build(), + expectedMap = mapOf("name" to listOf("value1", "value2", "value1", "value2")), + expectedSize = 4, + ), + PUT_CASE_INSENSITIVE( + Headers.builder() + .put("name", "value1") + .put("NAME", "value2") + .put("nAmE", "value3") + .build(), + expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), + expectedSize = 3, + ), + PUT_ALL_MAP( + Headers.builder() + .putAll( + mapOf( + "name1" to listOf("value1", "value2"), + "name2" to listOf("value1", "value2"), + ) + ) + .build(), + expectedMap = + mapOf("name1" to listOf("value1", "value2"), "name2" to listOf("value1", "value2")), + expectedSize = 4, + ), + PUT_ALL_HEADERS( + Headers.builder().putAll(Headers.builder().put("name", "value").build()).build(), + expectedMap = mapOf("name" to listOf("value")), + expectedSize = 1, + ), + PUT_ALL_CASE_INSENSITIVE( + Headers.builder() + .putAll( + mapOf( + "name" to listOf("value1"), + "NAME" to listOf("value2"), + "nAmE" to listOf("value3"), + ) + ) + .build(), + expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), + expectedSize = 3, + ), + REMOVE_ABSENT( + Headers.builder().remove("name").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_PRESENT_ONE( + Headers.builder().put("name", "value").remove("name").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_PRESENT_MULTIPLE( + Headers.builder().put("name", listOf("value1", "value2")).remove("name").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_CASE_INSENSITIVE( + Headers.builder().put("name", listOf("value1", "value2")).remove("NAME").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_ALL( + Headers.builder() + .put("name1", "value") + .put("name3", "value") + .removeAll(setOf("name1", "name2", "name3")) + .build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_ALL_CASE_INSENSITIVE( + Headers.builder() + .put("name1", "value") + .put("name3", "value") + .removeAll(setOf("NAME1", "nAmE3")) + .build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + CLEAR( + Headers.builder().put("name1", "value").put("name2", "value").clear().build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REPLACE_ONE_ABSENT( + Headers.builder().replace("name", "value").build(), + expectedMap = mapOf("name" to listOf("value")), + expectedSize = 1, + ), + REPLACE_ONE_PRESENT_ONE( + Headers.builder().put("name", "value1").replace("name", "value2").build(), + expectedMap = mapOf("name" to listOf("value2")), + expectedSize = 1, + ), + REPLACE_ONE_PRESENT_MULTIPLE( + Headers.builder() + .put("name", listOf("value1", "value2")) + .replace("name", "value3") + .build(), + expectedMap = mapOf("name" to listOf("value3")), + expectedSize = 1, + ), + REPLACE_MULTIPLE_ABSENT( + Headers.builder().replace("name", listOf("value1", "value2")).build(), + expectedMap = mapOf("name" to listOf("value1", "value2")), + expectedSize = 2, + ), + REPLACE_MULTIPLE_PRESENT_ONE( + Headers.builder() + .put("name", "value1") + .replace("name", listOf("value2", "value3")) + .build(), + expectedMap = mapOf("name" to listOf("value2", "value3")), + expectedSize = 2, + ), + REPLACE_MULTIPLE_PRESENT_MULTIPLE( + Headers.builder() + .put("name", listOf("value1", "value2")) + .replace("name", listOf("value3", "value4")) + .build(), + expectedMap = mapOf("name" to listOf("value3", "value4")), + expectedSize = 2, + ), + REPLACE_CASE_INSENSITIVE( + Headers.builder() + .put("name", "value1") + .replace("NAME", listOf("value2", "value3")) + .build(), + expectedMap = mapOf("NAME" to listOf("value2", "value3")), + expectedSize = 2, + ), + REPLACE_ALL_MAP( + Headers.builder() + .put("name1", "value1") + .put("name2", "value1") + .put("name3", "value1") + .replaceAll(mapOf("name1" to listOf("value2"), "name3" to listOf("value2"))) + .build(), + expectedMap = + mapOf( + "name1" to listOf("value2"), + "name2" to listOf("value1"), + "name3" to listOf("value2"), + ), + expectedSize = 3, + ), + REPLACE_ALL_HEADERS( + Headers.builder() + .put("name1", "value1") + .put("name2", "value1") + .put("name3", "value1") + .replaceAll(Headers.builder().put("name1", "value2").put("name3", "value2").build()) + .build(), + expectedMap = + mapOf( + "name1" to listOf("value2"), + "name2" to listOf("value1"), + "name3" to listOf("value2"), + ), + expectedSize = 3, + ), + REPLACE_ALL_CASE_INSENSITIVE( + Headers.builder() + .put("name1", "value1") + .put("name2", "value1") + .replaceAll(mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2"))) + .build(), + expectedMap = mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2")), + expectedSize = 2, + ), + } + + @ParameterizedTest + @EnumSource + fun namesAndValues(testCase: TestCase) { + val map = mutableMapOf>() + val headers = testCase.headers + headers.names().forEach { name -> map[name] = headers.values(name) } + + assertThat(map).isEqualTo(testCase.expectedMap) + } + + @ParameterizedTest + @EnumSource + fun caseInsensitiveNames(testCase: TestCase) { + val headers = testCase.headers + + for (name in headers.names()) { + assertThat(headers.values(name)).isEqualTo(headers.values(name.lowercase())) + assertThat(headers.values(name)).isEqualTo(headers.values(name.uppercase())) + } + } + + @ParameterizedTest + @EnumSource + fun size(testCase: TestCase) { + val size = testCase.headers.size + + assertThat(size).isEqualTo(testCase.expectedSize) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/QueryParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/QueryParamsTest.kt new file mode 100644 index 00000000..87748918 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/QueryParamsTest.kt @@ -0,0 +1,180 @@ +package com.imagekit.api.core.http + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class QueryParamsTest { + + enum class TestCase( + val queryParams: QueryParams, + val expectedMap: Map>, + val expectedSize: Int, + ) { + EMPTY(QueryParams.builder().build(), expectedMap = mapOf(), expectedSize = 0), + PUT_ONE( + QueryParams.builder().put("key", "value").build(), + expectedMap = mapOf("key" to listOf("value")), + expectedSize = 1, + ), + PUT_MULTIPLE( + QueryParams.builder().put("key", listOf("value1", "value2")).build(), + expectedMap = mapOf("key" to listOf("value1", "value2")), + expectedSize = 2, + ), + MULTIPLE_PUT( + QueryParams.builder().put("key1", "value").put("key2", "value").build(), + expectedMap = mapOf("key1" to listOf("value"), "key2" to listOf("value")), + expectedSize = 2, + ), + MULTIPLE_PUT_SAME_NAME( + QueryParams.builder().put("key", "value1").put("key", "value2").build(), + expectedMap = mapOf("key" to listOf("value1", "value2")), + expectedSize = 2, + ), + MULTIPLE_PUT_MULTIPLE( + QueryParams.builder() + .put("key", listOf("value1", "value2")) + .put("key", listOf("value1", "value2")) + .build(), + expectedMap = mapOf("key" to listOf("value1", "value2", "value1", "value2")), + expectedSize = 4, + ), + PUT_ALL_MAP( + QueryParams.builder() + .putAll( + mapOf( + "key1" to listOf("value1", "value2"), + "key2" to listOf("value1", "value2"), + ) + ) + .build(), + expectedMap = + mapOf("key1" to listOf("value1", "value2"), "key2" to listOf("value1", "value2")), + expectedSize = 4, + ), + PUT_ALL_HEADERS( + QueryParams.builder().putAll(QueryParams.builder().put("key", "value").build()).build(), + expectedMap = mapOf("key" to listOf("value")), + expectedSize = 1, + ), + REMOVE_ABSENT( + QueryParams.builder().remove("key").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_PRESENT_ONE( + QueryParams.builder().put("key", "value").remove("key").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_PRESENT_MULTIPLE( + QueryParams.builder().put("key", listOf("value1", "value2")).remove("key").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_ALL( + QueryParams.builder() + .put("key1", "value") + .put("key3", "value") + .removeAll(setOf("key1", "key2", "key3")) + .build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + CLEAR( + QueryParams.builder().put("key1", "value").put("key2", "value").clear().build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REPLACE_ONE_ABSENT( + QueryParams.builder().replace("key", "value").build(), + expectedMap = mapOf("key" to listOf("value")), + expectedSize = 1, + ), + REPLACE_ONE_PRESENT_ONE( + QueryParams.builder().put("key", "value1").replace("key", "value2").build(), + expectedMap = mapOf("key" to listOf("value2")), + expectedSize = 1, + ), + REPLACE_ONE_PRESENT_MULTIPLE( + QueryParams.builder() + .put("key", listOf("value1", "value2")) + .replace("key", "value3") + .build(), + expectedMap = mapOf("key" to listOf("value3")), + expectedSize = 1, + ), + REPLACE_MULTIPLE_ABSENT( + QueryParams.builder().replace("key", listOf("value1", "value2")).build(), + expectedMap = mapOf("key" to listOf("value1", "value2")), + expectedSize = 2, + ), + REPLACE_MULTIPLE_PRESENT_ONE( + QueryParams.builder() + .put("key", "value1") + .replace("key", listOf("value2", "value3")) + .build(), + expectedMap = mapOf("key" to listOf("value2", "value3")), + expectedSize = 2, + ), + REPLACE_MULTIPLE_PRESENT_MULTIPLE( + QueryParams.builder() + .put("key", listOf("value1", "value2")) + .replace("key", listOf("value3", "value4")) + .build(), + expectedMap = mapOf("key" to listOf("value3", "value4")), + expectedSize = 2, + ), + REPLACE_ALL_MAP( + QueryParams.builder() + .put("key1", "value1") + .put("key2", "value1") + .put("key3", "value1") + .replaceAll(mapOf("key1" to listOf("value2"), "key3" to listOf("value2"))) + .build(), + expectedMap = + mapOf( + "key1" to listOf("value2"), + "key2" to listOf("value1"), + "key3" to listOf("value2"), + ), + expectedSize = 3, + ), + REPLACE_ALL_HEADERS( + QueryParams.builder() + .put("key1", "value1") + .put("key2", "value1") + .put("key3", "value1") + .replaceAll( + QueryParams.builder().put("key1", "value2").put("key3", "value2").build() + ) + .build(), + expectedMap = + mapOf( + "key1" to listOf("value2"), + "key2" to listOf("value1"), + "key3" to listOf("value2"), + ), + expectedSize = 3, + ), + } + + @ParameterizedTest + @EnumSource + fun keysAndValues(testCase: TestCase) { + val map = mutableMapOf>() + val queryParams = testCase.queryParams + queryParams.keys().forEach { key -> map[key] = queryParams.values(key) } + + assertThat(map).isEqualTo(testCase.expectedMap) + } + + @ParameterizedTest + @EnumSource + fun size(testCase: TestCase) { + val size = testCase.queryParams.size + + assertThat(size).isEqualTo(testCase.expectedSize) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt new file mode 100644 index 00000000..732cc289 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt @@ -0,0 +1,351 @@ +package com.imagekit.api.core.http + +import com.github.tomakehurst.wiremock.client.WireMock.* +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest +import com.github.tomakehurst.wiremock.stubbing.Scenario +import com.imagekit.api.client.okhttp.OkHttpClient +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.errors.ImageKitRetryableException +import java.io.InputStream +import java.time.Duration +import java.util.concurrent.CompletableFuture +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.parallel.ResourceLock +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.ValueSource + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class RetryingHttpClientTest { + + private var openResponseCount = 0 + private lateinit var baseUrl: String + private lateinit var httpClient: HttpClient + + @BeforeEach + fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { + baseUrl = wmRuntimeInfo.httpBaseUrl + val okHttpClient = OkHttpClient.builder().build() + httpClient = + object : HttpClient { + + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse = trackClose(okHttpClient.execute(request, requestOptions)) + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture = + okHttpClient.executeAsync(request, requestOptions).thenApply { trackClose(it) } + + override fun close() = okHttpClient.close() + + private fun trackClose(response: HttpResponse): HttpResponse { + openResponseCount++ + return object : HttpResponse { + + private var isClosed = false + + override fun statusCode(): Int = response.statusCode() + + override fun headers(): Headers = response.headers() + + override fun body(): InputStream = response.body() + + override fun close() { + response.close() + if (isClosed) { + return + } + openResponseCount-- + isClosed = true + } + } + } + } + resetAllScenarios() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) + val retryingClient = retryingHttpClientBuilder().build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withIdempotencyHeader(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .withHeader("X-Some-Header", matching("stainless-java-retry-.+")) + .willReturn(ok()) + ) + val retryingClient = + retryingHttpClientBuilder().maxRetries(2).idempotencyHeader("X-Some-Header").build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterHeader(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + // First we fail with a retry after header given as a date + .inScenario("foo") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn( + serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") + ) + .willSetStateTo("RETRY_AFTER_DATE") + ) + stubFor( + post(urlPathEqualTo("/something")) + // Then we fail with a retry after header given as a delay + .inScenario("foo") + .whenScenarioStateIs("RETRY_AFTER_DATE") + .willReturn(serviceUnavailable().withHeader("Retry-After", "1.234")) + .willSetStateTo("RETRY_AFTER_DELAY") + ) + stubFor( + post(urlPathEqualTo("/something")) + // Then we return a success + .inScenario("foo") + .whenScenarioStateIs("RETRY_AFTER_DELAY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify( + 1, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("0")), + ) + verify( + 1, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("1")), + ) + verify( + 1, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("2")), + ) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withOverwrittenRetryCountHeader(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") // first we fail with a retry after header given as a date + .whenScenarioStateIs(Scenario.STARTED) + .willReturn( + serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") + ) + .willSetStateTo("RETRY_AFTER_DATE") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") // then we return a success + .whenScenarioStateIs("RETRY_AFTER_DATE") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .putHeader("x-stainless-retry-count", "42") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify( + 2, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("42")), + ) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterMsHeader(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn(serviceUnavailable().withHeader("Retry-After-Ms", "10")) + .willSetStateTo("RETRY_AFTER_DELAY") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") // then we return a success + .whenScenarioStateIs("RETRY_AFTER_DELAY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val retryingClient = retryingHttpClientBuilder().maxRetries(1).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify(2, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryableException(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) + + var callCount = 0 + val failingHttpClient = + object : HttpClient { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse { + callCount++ + if (callCount == 1) { + throw ImageKitRetryableException("Simulated retryable failure") + } + return httpClient.execute(request, requestOptions) + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + callCount++ + if (callCount == 1) { + val future = CompletableFuture() + future.completeExceptionally( + ImageKitRetryableException("Simulated retryable failure") + ) + return future + } + return httpClient.executeAsync(request, requestOptions) + } + + override fun close() = httpClient.close() + } + + val retryingClient = + RetryingHttpClient.builder() + .httpClient(failingHttpClient) + .maxRetries(2) + .sleeper( + object : RetryingHttpClient.Sleeper { + + override fun sleep(duration: Duration) {} + + override fun sleepAsync(duration: Duration): CompletableFuture = + CompletableFuture.completedFuture(null) + } + ) + .build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify( + 1, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("1")), + ) + verify( + 0, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("0")), + ) + assertNoResponseLeaks() + } + + private fun retryingHttpClientBuilder() = + RetryingHttpClient.builder() + .httpClient(httpClient) + // Use a no-op `Sleeper` to make the test fast. + .sleeper( + object : RetryingHttpClient.Sleeper { + + override fun sleep(duration: Duration) {} + + override fun sleepAsync(duration: Duration): CompletableFuture = + CompletableFuture.completedFuture(null) + } + ) + + private fun HttpClient.execute(request: HttpRequest, async: Boolean): HttpResponse = + if (async) executeAsync(request).get() else execute(request) + + // When retrying, all failed responses should be closed. Only the final returned response should + // be open. + private fun assertNoResponseLeaks() = assertThat(openResponseCount).isEqualTo(1) +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt new file mode 100644 index 00000000..1dab2e00 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BaseOverlayTest { + + @Test + fun create() { + val baseOverlay = + BaseOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .build() + + assertThat(baseOverlay.position()) + .contains( + OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + ) + assertThat(baseOverlay.timing()) + .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val baseOverlay = + BaseOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .build() + + val roundtrippedBaseOverlay = + jsonMapper.readValue( + jsonMapper.writeValueAsString(baseOverlay), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBaseOverlay).isEqualTo(baseOverlay) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt new file mode 100644 index 00000000..934ff3f0 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ImageOverlayTest { + + @Test + fun create() { + val imageOverlay = + ImageOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .input("input") + .encoding(ImageOverlay.Encoding.AUTO) + .transformation(listOf()) + .build() + + assertThat(imageOverlay.position()) + .contains( + OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + ) + assertThat(imageOverlay.timing()) + .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + assertThat(imageOverlay.input()).isEqualTo("input") + assertThat(imageOverlay.encoding()).contains(ImageOverlay.Encoding.AUTO) + assertThat(imageOverlay.transformation().getOrNull()).containsExactly() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val imageOverlay = + ImageOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .input("input") + .encoding(ImageOverlay.Encoding.AUTO) + .transformation(listOf()) + .build() + + val roundtrippedImageOverlay = + jsonMapper.readValue( + jsonMapper.writeValueAsString(imageOverlay), + jacksonTypeRef(), + ) + + assertThat(roundtrippedImageOverlay).isEqualTo(imageOverlay) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayPositionTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayPositionTest.kt new file mode 100644 index 00000000..a39aa652 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayPositionTest.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OverlayPositionTest { + + @Test + fun create() { + val overlayPosition = + OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + + assertThat(overlayPosition.focus()).contains(OverlayPosition.Focus.CENTER) + assertThat(overlayPosition.x()).contains(OverlayPosition.X.ofNumber(0.0)) + assertThat(overlayPosition.y()).contains(OverlayPosition.Y.ofNumber(0.0)) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val overlayPosition = + OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + + val roundtrippedOverlayPosition = + jsonMapper.readValue( + jsonMapper.writeValueAsString(overlayPosition), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOverlayPosition).isEqualTo(overlayPosition) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt new file mode 100644 index 00000000..c55bfc42 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt @@ -0,0 +1,361 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import com.imagekit.api.errors.ImageKitInvalidDataException +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class OverlayTest { + + @Test + fun ofText() { + val text = + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + + val overlay = Overlay.ofText(text) + + assertThat(overlay.text()).contains(text) + assertThat(overlay.image()).isEmpty + assertThat(overlay.video()).isEmpty + assertThat(overlay.subtitle()).isEmpty + assertThat(overlay.solidColor()).isEmpty + } + + @Test + fun ofTextRoundtrip() { + val jsonMapper = jsonMapper() + val overlay = + Overlay.ofText( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + ) + + val roundtrippedOverlay = + jsonMapper.readValue(jsonMapper.writeValueAsString(overlay), jacksonTypeRef()) + + assertThat(roundtrippedOverlay).isEqualTo(overlay) + } + + @Test + fun ofImage() { + val image = + ImageOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .input("input") + .encoding(ImageOverlay.Encoding.AUTO) + .transformation(listOf()) + .build() + + val overlay = Overlay.ofImage(image) + + assertThat(overlay.text()).isEmpty + assertThat(overlay.image()).contains(image) + assertThat(overlay.video()).isEmpty + assertThat(overlay.subtitle()).isEmpty + assertThat(overlay.solidColor()).isEmpty + } + + @Test + fun ofImageRoundtrip() { + val jsonMapper = jsonMapper() + val overlay = + Overlay.ofImage( + ImageOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .input("input") + .encoding(ImageOverlay.Encoding.AUTO) + .transformation(listOf()) + .build() + ) + + val roundtrippedOverlay = + jsonMapper.readValue(jsonMapper.writeValueAsString(overlay), jacksonTypeRef()) + + assertThat(roundtrippedOverlay).isEqualTo(overlay) + } + + @Test + fun ofVideo() { + val video = + VideoOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .input("input") + .encoding(VideoOverlay.Encoding.AUTO) + .transformation(listOf()) + .build() + + val overlay = Overlay.ofVideo(video) + + assertThat(overlay.text()).isEmpty + assertThat(overlay.image()).isEmpty + assertThat(overlay.video()).contains(video) + assertThat(overlay.subtitle()).isEmpty + assertThat(overlay.solidColor()).isEmpty + } + + @Test + fun ofVideoRoundtrip() { + val jsonMapper = jsonMapper() + val overlay = + Overlay.ofVideo( + VideoOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .input("input") + .encoding(VideoOverlay.Encoding.AUTO) + .transformation(listOf()) + .build() + ) + + val roundtrippedOverlay = + jsonMapper.readValue(jsonMapper.writeValueAsString(overlay), jacksonTypeRef()) + + assertThat(roundtrippedOverlay).isEqualTo(overlay) + } + + @Test + fun ofSubtitle() { + val subtitle = + SubtitleOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .input("input") + .encoding(SubtitleOverlay.Encoding.AUTO) + .addTransformation( + SubtitleOverlayTransformation.builder() + .background("background") + .color("color") + .fontFamily("fontFamily") + .fontOutline("fontOutline") + .fontShadow("fontShadow") + .fontSize(0.0) + .typography(SubtitleOverlayTransformation.Typography.B) + .build() + ) + .build() + + val overlay = Overlay.ofSubtitle(subtitle) + + assertThat(overlay.text()).isEmpty + assertThat(overlay.image()).isEmpty + assertThat(overlay.video()).isEmpty + assertThat(overlay.subtitle()).contains(subtitle) + assertThat(overlay.solidColor()).isEmpty + } + + @Test + fun ofSubtitleRoundtrip() { + val jsonMapper = jsonMapper() + val overlay = + Overlay.ofSubtitle( + SubtitleOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .input("input") + .encoding(SubtitleOverlay.Encoding.AUTO) + .addTransformation( + SubtitleOverlayTransformation.builder() + .background("background") + .color("color") + .fontFamily("fontFamily") + .fontOutline("fontOutline") + .fontShadow("fontShadow") + .fontSize(0.0) + .typography(SubtitleOverlayTransformation.Typography.B) + .build() + ) + .build() + ) + + val roundtrippedOverlay = + jsonMapper.readValue(jsonMapper.writeValueAsString(overlay), jacksonTypeRef()) + + assertThat(roundtrippedOverlay).isEqualTo(overlay) + } + + @Test + fun ofSolidColor() { + val solidColor = + SolidColorOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .color("color") + .addTransformation( + SolidColorOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .gradientTrue() + .height(0.0) + .radius(0.0) + .width(0.0) + .build() + ) + .build() + + val overlay = Overlay.ofSolidColor(solidColor) + + assertThat(overlay.text()).isEmpty + assertThat(overlay.image()).isEmpty + assertThat(overlay.video()).isEmpty + assertThat(overlay.subtitle()).isEmpty + assertThat(overlay.solidColor()).contains(solidColor) + } + + @Test + fun ofSolidColorRoundtrip() { + val jsonMapper = jsonMapper() + val overlay = + Overlay.ofSolidColor( + SolidColorOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .color("color") + .addTransformation( + SolidColorOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .gradientTrue() + .height(0.0) + .radius(0.0) + .width(0.0) + .build() + ) + .build() + ) + + val roundtrippedOverlay = + jsonMapper.readValue(jsonMapper.writeValueAsString(overlay), jacksonTypeRef()) + + assertThat(roundtrippedOverlay).isEqualTo(overlay) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val overlay = jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { overlay.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTimingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTimingTest.kt new file mode 100644 index 00000000..b31c4ea4 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTimingTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OverlayTimingTest { + + @Test + fun create() { + val overlayTiming = OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build() + + assertThat(overlayTiming.duration()).contains(OverlayTiming.Duration.ofNumber(0.0)) + assertThat(overlayTiming.end()).contains(OverlayTiming.End.ofNumber(0.0)) + assertThat(overlayTiming.start()).contains(OverlayTiming.Start.ofNumber(0.0)) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val overlayTiming = OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build() + + val roundtrippedOverlayTiming = + jsonMapper.readValue( + jsonMapper.writeValueAsString(overlayTiming), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOverlayTiming).isEqualTo(overlayTiming) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt new file mode 100644 index 00000000..7989cf7e --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt @@ -0,0 +1,92 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SolidColorOverlayTest { + + @Test + fun create() { + val solidColorOverlay = + SolidColorOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .color("color") + .addTransformation( + SolidColorOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .gradientTrue() + .height(0.0) + .radius(0.0) + .width(0.0) + .build() + ) + .build() + + assertThat(solidColorOverlay.position()) + .contains( + OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + ) + assertThat(solidColorOverlay.timing()) + .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + assertThat(solidColorOverlay.color()).isEqualTo("color") + assertThat(solidColorOverlay.transformation().getOrNull()) + .containsExactly( + SolidColorOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .gradientTrue() + .height(0.0) + .radius(0.0) + .width(0.0) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val solidColorOverlay = + SolidColorOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .color("color") + .addTransformation( + SolidColorOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .gradientTrue() + .height(0.0) + .radius(0.0) + .width(0.0) + .build() + ) + .build() + + val roundtrippedSolidColorOverlay = + jsonMapper.readValue( + jsonMapper.writeValueAsString(solidColorOverlay), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSolidColorOverlay).isEqualTo(solidColorOverlay) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTransformationTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTransformationTest.kt new file mode 100644 index 00000000..d5802c92 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTransformationTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SolidColorOverlayTransformationTest { + + @Test + fun create() { + val solidColorOverlayTransformation = + SolidColorOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .gradientTrue() + .height(0.0) + .radius(0.0) + .width(0.0) + .build() + + assertThat(solidColorOverlayTransformation.alpha()).contains(1.0) + assertThat(solidColorOverlayTransformation.background()).contains("background") + assertThat(solidColorOverlayTransformation.gradient()) + .contains(SolidColorOverlayTransformation.Gradient.ofTrue()) + assertThat(solidColorOverlayTransformation.height()) + .contains(SolidColorOverlayTransformation.Height.ofNumber(0.0)) + assertThat(solidColorOverlayTransformation.radius()) + .contains(SolidColorOverlayTransformation.Radius.ofNumber(0.0)) + assertThat(solidColorOverlayTransformation.width()) + .contains(SolidColorOverlayTransformation.Width.ofNumber(0.0)) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val solidColorOverlayTransformation = + SolidColorOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .gradientTrue() + .height(0.0) + .radius(0.0) + .width(0.0) + .build() + + val roundtrippedSolidColorOverlayTransformation = + jsonMapper.readValue( + jsonMapper.writeValueAsString(solidColorOverlayTransformation), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSolidColorOverlayTransformation) + .isEqualTo(solidColorOverlayTransformation) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt new file mode 100644 index 00000000..a475e8e1 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt @@ -0,0 +1,234 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SrcOptionsTest { + + @Test + fun create() { + val srcOptions = + SrcOptions.builder() + .src("/my-image.jpg") + .urlEndpoint("https://ik.imagekit.io/demo") + .expiresIn(0.0) + .queryParameters( + SrcOptions.QueryParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .signed(true) + .addTransformation( + Transformation.builder() + .aiChangeBackground("aiChangeBackground") + .aiDropShadowTrue() + .aiEdit("aiEdit") + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) + .aiRetouch(Transformation.AiRetouch.TRUE) + .aiUpscale(Transformation.AiUpscale.TRUE) + .aiVariation(Transformation.AiVariation.TRUE) + .aspectRatio("4:3") + .audioCodec(Transformation.AudioCodec.AAC) + .background("red") + .blur(10.0) + .border("5_FF0000") + .colorProfile(true) + .contrastStretch(Transformation.ContrastStretch.TRUE) + .crop(Transformation.Crop.FORCE) + .cropMode(Transformation.CropMode.PAD_RESIZE) + .defaultImage("defaultImage") + .dpr(2.0) + .duration(0.0) + .endOffset(0.0) + .flip(Transformation.Flip.H) + .focus("center") + .format(Transformation.Format.AUTO) + .gradientTrue() + .grayscale(Transformation.Grayscale.TRUE) + .height(200.0) + .lossless(true) + .metadata(true) + .named("named") + .opacity(0.0) + .original(true) + .page(0.0) + .progressive(true) + .quality(80.0) + .radius(20.0) + .raw("raw") + .rotation(90.0) + .shadowTrue() + .sharpenTrue() + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trimTrue() + .unsharpMaskTrue() + .videoCodec(Transformation.VideoCodec.H264) + .width(300.0) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .zoom(0.0) + .build() + ) + .transformationPosition(TransformationPosition.PATH) + .build() + + assertThat(srcOptions.src()).isEqualTo("/my-image.jpg") + assertThat(srcOptions.urlEndpoint()).isEqualTo("https://ik.imagekit.io/demo") + assertThat(srcOptions.expiresIn()).contains(0.0) + assertThat(srcOptions.queryParameters()) + .contains( + SrcOptions.QueryParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(srcOptions.signed()).contains(true) + assertThat(srcOptions.transformation().getOrNull()) + .containsExactly( + Transformation.builder() + .aiChangeBackground("aiChangeBackground") + .aiDropShadowTrue() + .aiEdit("aiEdit") + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) + .aiRetouch(Transformation.AiRetouch.TRUE) + .aiUpscale(Transformation.AiUpscale.TRUE) + .aiVariation(Transformation.AiVariation.TRUE) + .aspectRatio("4:3") + .audioCodec(Transformation.AudioCodec.AAC) + .background("red") + .blur(10.0) + .border("5_FF0000") + .colorProfile(true) + .contrastStretch(Transformation.ContrastStretch.TRUE) + .crop(Transformation.Crop.FORCE) + .cropMode(Transformation.CropMode.PAD_RESIZE) + .defaultImage("defaultImage") + .dpr(2.0) + .duration(0.0) + .endOffset(0.0) + .flip(Transformation.Flip.H) + .focus("center") + .format(Transformation.Format.AUTO) + .gradientTrue() + .grayscale(Transformation.Grayscale.TRUE) + .height(200.0) + .lossless(true) + .metadata(true) + .named("named") + .opacity(0.0) + .original(true) + .page(0.0) + .progressive(true) + .quality(80.0) + .radius(20.0) + .raw("raw") + .rotation(90.0) + .shadowTrue() + .sharpenTrue() + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trimTrue() + .unsharpMaskTrue() + .videoCodec(Transformation.VideoCodec.H264) + .width(300.0) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .zoom(0.0) + .build() + ) + assertThat(srcOptions.transformationPosition()).contains(TransformationPosition.PATH) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val srcOptions = + SrcOptions.builder() + .src("/my-image.jpg") + .urlEndpoint("https://ik.imagekit.io/demo") + .expiresIn(0.0) + .queryParameters( + SrcOptions.QueryParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .signed(true) + .addTransformation( + Transformation.builder() + .aiChangeBackground("aiChangeBackground") + .aiDropShadowTrue() + .aiEdit("aiEdit") + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) + .aiRetouch(Transformation.AiRetouch.TRUE) + .aiUpscale(Transformation.AiUpscale.TRUE) + .aiVariation(Transformation.AiVariation.TRUE) + .aspectRatio("4:3") + .audioCodec(Transformation.AudioCodec.AAC) + .background("red") + .blur(10.0) + .border("5_FF0000") + .colorProfile(true) + .contrastStretch(Transformation.ContrastStretch.TRUE) + .crop(Transformation.Crop.FORCE) + .cropMode(Transformation.CropMode.PAD_RESIZE) + .defaultImage("defaultImage") + .dpr(2.0) + .duration(0.0) + .endOffset(0.0) + .flip(Transformation.Flip.H) + .focus("center") + .format(Transformation.Format.AUTO) + .gradientTrue() + .grayscale(Transformation.Grayscale.TRUE) + .height(200.0) + .lossless(true) + .metadata(true) + .named("named") + .opacity(0.0) + .original(true) + .page(0.0) + .progressive(true) + .quality(80.0) + .radius(20.0) + .raw("raw") + .rotation(90.0) + .shadowTrue() + .sharpenTrue() + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trimTrue() + .unsharpMaskTrue() + .videoCodec(Transformation.VideoCodec.H264) + .width(300.0) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .zoom(0.0) + .build() + ) + .transformationPosition(TransformationPosition.PATH) + .build() + + val roundtrippedSrcOptions = + jsonMapper.readValue( + jsonMapper.writeValueAsString(srcOptions), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSrcOptions).isEqualTo(srcOptions) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt new file mode 100644 index 00000000..c0f445a6 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt @@ -0,0 +1,98 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SubtitleOverlayTest { + + @Test + fun create() { + val subtitleOverlay = + SubtitleOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .input("input") + .encoding(SubtitleOverlay.Encoding.AUTO) + .addTransformation( + SubtitleOverlayTransformation.builder() + .background("background") + .color("color") + .fontFamily("fontFamily") + .fontOutline("fontOutline") + .fontShadow("fontShadow") + .fontSize(0.0) + .typography(SubtitleOverlayTransformation.Typography.B) + .build() + ) + .build() + + assertThat(subtitleOverlay.position()) + .contains( + OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + ) + assertThat(subtitleOverlay.timing()) + .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + assertThat(subtitleOverlay.input()).isEqualTo("input") + assertThat(subtitleOverlay.encoding()).contains(SubtitleOverlay.Encoding.AUTO) + assertThat(subtitleOverlay.transformation().getOrNull()) + .containsExactly( + SubtitleOverlayTransformation.builder() + .background("background") + .color("color") + .fontFamily("fontFamily") + .fontOutline("fontOutline") + .fontShadow("fontShadow") + .fontSize(0.0) + .typography(SubtitleOverlayTransformation.Typography.B) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subtitleOverlay = + SubtitleOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .input("input") + .encoding(SubtitleOverlay.Encoding.AUTO) + .addTransformation( + SubtitleOverlayTransformation.builder() + .background("background") + .color("color") + .fontFamily("fontFamily") + .fontOutline("fontOutline") + .fontShadow("fontShadow") + .fontSize(0.0) + .typography(SubtitleOverlayTransformation.Typography.B) + .build() + ) + .build() + + val roundtrippedSubtitleOverlay = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subtitleOverlay), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubtitleOverlay).isEqualTo(subtitleOverlay) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTransformationTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTransformationTest.kt new file mode 100644 index 00000000..1fcf8c66 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTransformationTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SubtitleOverlayTransformationTest { + + @Test + fun create() { + val subtitleOverlayTransformation = + SubtitleOverlayTransformation.builder() + .background("background") + .color("color") + .fontFamily("fontFamily") + .fontOutline("fontOutline") + .fontShadow("fontShadow") + .fontSize(0.0) + .typography(SubtitleOverlayTransformation.Typography.B) + .build() + + assertThat(subtitleOverlayTransformation.background()).contains("background") + assertThat(subtitleOverlayTransformation.color()).contains("color") + assertThat(subtitleOverlayTransformation.fontFamily()).contains("fontFamily") + assertThat(subtitleOverlayTransformation.fontOutline()).contains("fontOutline") + assertThat(subtitleOverlayTransformation.fontShadow()).contains("fontShadow") + assertThat(subtitleOverlayTransformation.fontSize()).contains(0.0) + assertThat(subtitleOverlayTransformation.typography()) + .contains(SubtitleOverlayTransformation.Typography.B) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subtitleOverlayTransformation = + SubtitleOverlayTransformation.builder() + .background("background") + .color("color") + .fontFamily("fontFamily") + .fontOutline("fontOutline") + .fontShadow("fontShadow") + .fontSize(0.0) + .typography(SubtitleOverlayTransformation.Typography.B) + .build() + + val roundtrippedSubtitleOverlayTransformation = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subtitleOverlayTransformation), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubtitleOverlayTransformation) + .isEqualTo(subtitleOverlayTransformation) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt new file mode 100644 index 00000000..6b3a27b4 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt @@ -0,0 +1,116 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TextOverlayTest { + + @Test + fun create() { + val textOverlay = + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + + assertThat(textOverlay.position()) + .contains( + OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + ) + assertThat(textOverlay.timing()) + .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + assertThat(textOverlay.text()).isEqualTo("text") + assertThat(textOverlay.encoding()).contains(TextOverlay.Encoding.AUTO) + assertThat(textOverlay.transformation().getOrNull()) + .containsExactly( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val textOverlay = + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + + val roundtrippedTextOverlay = + jsonMapper.readValue( + jsonMapper.writeValueAsString(textOverlay), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTextOverlay).isEqualTo(textOverlay) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTransformationTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTransformationTest.kt new file mode 100644 index 00000000..f07cd592 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTransformationTest.kt @@ -0,0 +1,81 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TextOverlayTransformationTest { + + @Test + fun create() { + val textOverlayTransformation = + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + + assertThat(textOverlayTransformation.alpha()).contains(1.0) + assertThat(textOverlayTransformation.background()).contains("background") + assertThat(textOverlayTransformation.flip()).contains(TextOverlayTransformation.Flip.H) + assertThat(textOverlayTransformation.fontColor()).contains("fontColor") + assertThat(textOverlayTransformation.fontFamily()).contains("fontFamily") + assertThat(textOverlayTransformation.fontSize()) + .contains(TextOverlayTransformation.FontSize.ofNumber(0.0)) + assertThat(textOverlayTransformation.innerAlignment()) + .contains(TextOverlayTransformation.InnerAlignment.LEFT) + assertThat(textOverlayTransformation.lineHeight()) + .contains(TextOverlayTransformation.LineHeight.ofNumber(0.0)) + assertThat(textOverlayTransformation.padding()) + .contains(TextOverlayTransformation.Padding.ofNumber(0.0)) + assertThat(textOverlayTransformation.radius()) + .contains(TextOverlayTransformation.Radius.ofNumber(0.0)) + assertThat(textOverlayTransformation.rotation()) + .contains(TextOverlayTransformation.Rotation.ofNumber(0.0)) + assertThat(textOverlayTransformation.typography()).contains("typography") + assertThat(textOverlayTransformation.width()) + .contains(TextOverlayTransformation.Width.ofNumber(0.0)) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val textOverlayTransformation = + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + + val roundtrippedTextOverlayTransformation = + jsonMapper.readValue( + jsonMapper.writeValueAsString(textOverlayTransformation), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTextOverlayTransformation).isEqualTo(textOverlayTransformation) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt new file mode 100644 index 00000000..3dee6fd4 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt @@ -0,0 +1,193 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TransformationTest { + + @Test + fun create() { + val transformation = + Transformation.builder() + .aiChangeBackground("aiChangeBackground") + .aiDropShadowTrue() + .aiEdit("aiEdit") + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) + .aiRetouch(Transformation.AiRetouch.TRUE) + .aiUpscale(Transformation.AiUpscale.TRUE) + .aiVariation(Transformation.AiVariation.TRUE) + .aspectRatio("4:3") + .audioCodec(Transformation.AudioCodec.AAC) + .background("red") + .blur(10.0) + .border("5_FF0000") + .colorProfile(true) + .contrastStretch(Transformation.ContrastStretch.TRUE) + .crop(Transformation.Crop.FORCE) + .cropMode(Transformation.CropMode.PAD_RESIZE) + .defaultImage("defaultImage") + .dpr(2.0) + .duration(0.0) + .endOffset(0.0) + .flip(Transformation.Flip.H) + .focus("center") + .format(Transformation.Format.AUTO) + .gradientTrue() + .grayscale(Transformation.Grayscale.TRUE) + .height(200.0) + .lossless(true) + .metadata(true) + .named("named") + .opacity(0.0) + .original(true) + .page(0.0) + .progressive(true) + .quality(80.0) + .radius(20.0) + .raw("raw") + .rotation(90.0) + .shadowTrue() + .sharpenTrue() + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trimTrue() + .unsharpMaskTrue() + .videoCodec(Transformation.VideoCodec.H264) + .width(300.0) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .zoom(0.0) + .build() + + assertThat(transformation.aiChangeBackground()).contains("aiChangeBackground") + assertThat(transformation.aiDropShadow()).contains(Transformation.AiDropShadow.ofTrue()) + assertThat(transformation.aiEdit()).contains("aiEdit") + assertThat(transformation.aiRemoveBackground()) + .contains(Transformation.AiRemoveBackground.TRUE) + assertThat(transformation.aiRemoveBackgroundExternal()) + .contains(Transformation.AiRemoveBackgroundExternal.TRUE) + assertThat(transformation.aiRetouch()).contains(Transformation.AiRetouch.TRUE) + assertThat(transformation.aiUpscale()).contains(Transformation.AiUpscale.TRUE) + assertThat(transformation.aiVariation()).contains(Transformation.AiVariation.TRUE) + assertThat(transformation.aspectRatio()) + .contains(Transformation.AspectRatio.ofString("4:3")) + assertThat(transformation.audioCodec()).contains(Transformation.AudioCodec.AAC) + assertThat(transformation.background()).contains("red") + assertThat(transformation.blur()).contains(10.0) + assertThat(transformation.border()).contains("5_FF0000") + assertThat(transformation.colorProfile()).contains(true) + assertThat(transformation.contrastStretch()).contains(Transformation.ContrastStretch.TRUE) + assertThat(transformation.crop()).contains(Transformation.Crop.FORCE) + assertThat(transformation.cropMode()).contains(Transformation.CropMode.PAD_RESIZE) + assertThat(transformation.defaultImage()).contains("defaultImage") + assertThat(transformation.dpr()).contains(2.0) + assertThat(transformation.duration()).contains(Transformation.Duration.ofNumber(0.0)) + assertThat(transformation.endOffset()).contains(Transformation.EndOffset.ofNumber(0.0)) + assertThat(transformation.flip()).contains(Transformation.Flip.H) + assertThat(transformation.focus()).contains("center") + assertThat(transformation.format()).contains(Transformation.Format.AUTO) + assertThat(transformation.gradient()).contains(Transformation.Gradient.ofTrue()) + assertThat(transformation.grayscale()).contains(Transformation.Grayscale.TRUE) + assertThat(transformation.height()).contains(Transformation.Height.ofNumber(200.0)) + assertThat(transformation.lossless()).contains(true) + assertThat(transformation.metadata()).contains(true) + assertThat(transformation.named()).contains("named") + assertThat(transformation.opacity()).contains(0.0) + assertThat(transformation.original()).contains(true) + assertThat(transformation.page()).contains(Transformation.Page.ofNumber(0.0)) + assertThat(transformation.progressive()).contains(true) + assertThat(transformation.quality()).contains(80.0) + assertThat(transformation.radius()).contains(Transformation.Radius.ofNumber(20.0)) + assertThat(transformation.raw()).contains("raw") + assertThat(transformation.rotation()).contains(Transformation.Rotation.ofNumber(90.0)) + assertThat(transformation.shadow()).contains(Transformation.Shadow.ofTrue()) + assertThat(transformation.sharpen()).contains(Transformation.Sharpen.ofTrue()) + assertThat(transformation.startOffset()).contains(Transformation.StartOffset.ofNumber(0.0)) + assertThat(transformation.streamingResolutions().getOrNull()) + .containsExactly(StreamingResolution._240) + assertThat(transformation.trim()).contains(Transformation.Trim.ofTrue()) + assertThat(transformation.unsharpMask()).contains(Transformation.UnsharpMask.ofTrue()) + assertThat(transformation.videoCodec()).contains(Transformation.VideoCodec.H264) + assertThat(transformation.width()).contains(Transformation.Width.ofNumber(300.0)) + assertThat(transformation.x()).contains(Transformation.X.ofNumber(0.0)) + assertThat(transformation.xCenter()).contains(Transformation.XCenter.ofNumber(0.0)) + assertThat(transformation.y()).contains(Transformation.Y.ofNumber(0.0)) + assertThat(transformation.yCenter()).contains(Transformation.YCenter.ofNumber(0.0)) + assertThat(transformation.zoom()).contains(0.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val transformation = + Transformation.builder() + .aiChangeBackground("aiChangeBackground") + .aiDropShadowTrue() + .aiEdit("aiEdit") + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) + .aiRetouch(Transformation.AiRetouch.TRUE) + .aiUpscale(Transformation.AiUpscale.TRUE) + .aiVariation(Transformation.AiVariation.TRUE) + .aspectRatio("4:3") + .audioCodec(Transformation.AudioCodec.AAC) + .background("red") + .blur(10.0) + .border("5_FF0000") + .colorProfile(true) + .contrastStretch(Transformation.ContrastStretch.TRUE) + .crop(Transformation.Crop.FORCE) + .cropMode(Transformation.CropMode.PAD_RESIZE) + .defaultImage("defaultImage") + .dpr(2.0) + .duration(0.0) + .endOffset(0.0) + .flip(Transformation.Flip.H) + .focus("center") + .format(Transformation.Format.AUTO) + .gradientTrue() + .grayscale(Transformation.Grayscale.TRUE) + .height(200.0) + .lossless(true) + .metadata(true) + .named("named") + .opacity(0.0) + .original(true) + .page(0.0) + .progressive(true) + .quality(80.0) + .radius(20.0) + .raw("raw") + .rotation(90.0) + .shadowTrue() + .sharpenTrue() + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trimTrue() + .unsharpMaskTrue() + .videoCodec(Transformation.VideoCodec.H264) + .width(300.0) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .zoom(0.0) + .build() + + val roundtrippedTransformation = + jsonMapper.readValue( + jsonMapper.writeValueAsString(transformation), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTransformation).isEqualTo(transformation) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt new file mode 100644 index 00000000..caca3a99 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VideoOverlayTest { + + @Test + fun create() { + val videoOverlay = + VideoOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .input("input") + .encoding(VideoOverlay.Encoding.AUTO) + .transformation(listOf()) + .build() + + assertThat(videoOverlay.position()) + .contains( + OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + ) + assertThat(videoOverlay.timing()) + .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + assertThat(videoOverlay.input()).isEqualTo("input") + assertThat(videoOverlay.encoding()).contains(VideoOverlay.Encoding.AUTO) + assertThat(videoOverlay.transformation().getOrNull()).containsExactly() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val videoOverlay = + VideoOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .input("input") + .encoding(VideoOverlay.Encoding.AUTO) + .transformation(listOf()) + .build() + + val roundtrippedVideoOverlay = + jsonMapper.readValue( + jsonMapper.writeValueAsString(videoOverlay), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVideoOverlay).isEqualTo(videoOverlay) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParamsTest.kt new file mode 100644 index 00000000..98b6d47a --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParamsTest.kt @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.origins + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OriginCreateParamsTest { + + @Test + fun create() { + OriginCreateParams.builder() + .origin( + OriginRequest.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + OriginCreateParams.builder() + .origin( + OriginRequest.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + OriginRequest.ofS3( + OriginRequest.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + OriginCreateParams.builder() + .origin( + OriginRequest.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + OriginRequest.ofS3( + OriginRequest.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .build() + ) + ) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginDeleteParamsTest.kt new file mode 100644 index 00000000..ef9d5f33 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginDeleteParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.origins + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OriginDeleteParamsTest { + + @Test + fun create() { + OriginDeleteParams.builder().id("id").build() + } + + @Test + fun pathParams() { + val params = OriginDeleteParams.builder().id("id").build() + + assertThat(params._pathParam(0)).isEqualTo("id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetParamsTest.kt new file mode 100644 index 00000000..e029b05d --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.origins + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OriginGetParamsTest { + + @Test + fun create() { + OriginGetParams.builder().id("id").build() + } + + @Test + fun pathParams() { + val params = OriginGetParams.builder().id("id").build() + + assertThat(params._pathParam(0)).isEqualTo("id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListParamsTest.kt new file mode 100644 index 00000000..4a9eb551 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.origins + +import org.junit.jupiter.api.Test + +internal class OriginListParamsTest { + + @Test + fun create() { + OriginListParams.builder().build() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginRequestTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginRequestTest.kt new file mode 100644 index 00000000..74f88fc9 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginRequestTest.kt @@ -0,0 +1,428 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.origins + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import com.imagekit.api.errors.ImageKitInvalidDataException +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class OriginRequestTest { + + @Test + fun ofS3() { + val s3 = + OriginRequest.S3.builder() + .accessKey("AKIAIOSFODNN7EXAMPLE") + .bucket("product-images") + .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") + .build() + + val originRequest = OriginRequest.ofS3(s3) + + assertThat(originRequest.s3()).contains(s3) + assertThat(originRequest.s3Compatible()).isEmpty + assertThat(originRequest.cloudinaryBackup()).isEmpty + assertThat(originRequest.webFolder()).isEmpty + assertThat(originRequest.webProxy()).isEmpty + assertThat(originRequest.gcs()).isEmpty + assertThat(originRequest.azureBlob()).isEmpty + assertThat(originRequest.akeneoPim()).isEmpty + } + + @Test + fun ofS3Roundtrip() { + val jsonMapper = jsonMapper() + val originRequest = + OriginRequest.ofS3( + OriginRequest.S3.builder() + .accessKey("AKIAIOSFODNN7EXAMPLE") + .bucket("product-images") + .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") + .build() + ) + + val roundtrippedOriginRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originRequest), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginRequest).isEqualTo(originRequest) + } + + @Test + fun ofS3Compatible() { + val s3Compatible = + OriginRequest.S3Compatible.builder() + .accessKey("AKIAIOSFODNN7EXAMPLE") + .bucket("product-images") + .endpoint("https://s3.eu-central-1.wasabisys.com") + .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") + .s3ForcePathStyle(true) + .build() + + val originRequest = OriginRequest.ofS3Compatible(s3Compatible) + + assertThat(originRequest.s3()).isEmpty + assertThat(originRequest.s3Compatible()).contains(s3Compatible) + assertThat(originRequest.cloudinaryBackup()).isEmpty + assertThat(originRequest.webFolder()).isEmpty + assertThat(originRequest.webProxy()).isEmpty + assertThat(originRequest.gcs()).isEmpty + assertThat(originRequest.azureBlob()).isEmpty + assertThat(originRequest.akeneoPim()).isEmpty + } + + @Test + fun ofS3CompatibleRoundtrip() { + val jsonMapper = jsonMapper() + val originRequest = + OriginRequest.ofS3Compatible( + OriginRequest.S3Compatible.builder() + .accessKey("AKIAIOSFODNN7EXAMPLE") + .bucket("product-images") + .endpoint("https://s3.eu-central-1.wasabisys.com") + .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") + .s3ForcePathStyle(true) + .build() + ) + + val roundtrippedOriginRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originRequest), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginRequest).isEqualTo(originRequest) + } + + @Test + fun ofCloudinaryBackup() { + val cloudinaryBackup = + OriginRequest.CloudinaryBackup.builder() + .accessKey("AKIAIOSFODNN7EXAMPLE") + .bucket("product-images") + .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") + .build() + + val originRequest = OriginRequest.ofCloudinaryBackup(cloudinaryBackup) + + assertThat(originRequest.s3()).isEmpty + assertThat(originRequest.s3Compatible()).isEmpty + assertThat(originRequest.cloudinaryBackup()).contains(cloudinaryBackup) + assertThat(originRequest.webFolder()).isEmpty + assertThat(originRequest.webProxy()).isEmpty + assertThat(originRequest.gcs()).isEmpty + assertThat(originRequest.azureBlob()).isEmpty + assertThat(originRequest.akeneoPim()).isEmpty + } + + @Test + fun ofCloudinaryBackupRoundtrip() { + val jsonMapper = jsonMapper() + val originRequest = + OriginRequest.ofCloudinaryBackup( + OriginRequest.CloudinaryBackup.builder() + .accessKey("AKIAIOSFODNN7EXAMPLE") + .bucket("product-images") + .name("US S3 Storage") + .secretKey("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("raw-assets") + .build() + ) + + val roundtrippedOriginRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originRequest), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginRequest).isEqualTo(originRequest) + } + + @Test + fun ofWebFolder() { + val webFolder = + OriginRequest.WebFolder.builder() + .baseUrl("https://images.example.com/assets") + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) + .build() + + val originRequest = OriginRequest.ofWebFolder(webFolder) + + assertThat(originRequest.s3()).isEmpty + assertThat(originRequest.s3Compatible()).isEmpty + assertThat(originRequest.cloudinaryBackup()).isEmpty + assertThat(originRequest.webFolder()).contains(webFolder) + assertThat(originRequest.webProxy()).isEmpty + assertThat(originRequest.gcs()).isEmpty + assertThat(originRequest.azureBlob()).isEmpty + assertThat(originRequest.akeneoPim()).isEmpty + } + + @Test + fun ofWebFolderRoundtrip() { + val jsonMapper = jsonMapper() + val originRequest = + OriginRequest.ofWebFolder( + OriginRequest.WebFolder.builder() + .baseUrl("https://images.example.com/assets") + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) + .build() + ) + + val roundtrippedOriginRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originRequest), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginRequest).isEqualTo(originRequest) + } + + @Test + fun ofWebProxy() { + val webProxy = + OriginRequest.WebProxy.builder() + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .build() + + val originRequest = OriginRequest.ofWebProxy(webProxy) + + assertThat(originRequest.s3()).isEmpty + assertThat(originRequest.s3Compatible()).isEmpty + assertThat(originRequest.cloudinaryBackup()).isEmpty + assertThat(originRequest.webFolder()).isEmpty + assertThat(originRequest.webProxy()).contains(webProxy) + assertThat(originRequest.gcs()).isEmpty + assertThat(originRequest.azureBlob()).isEmpty + assertThat(originRequest.akeneoPim()).isEmpty + } + + @Test + fun ofWebProxyRoundtrip() { + val jsonMapper = jsonMapper() + val originRequest = + OriginRequest.ofWebProxy( + OriginRequest.WebProxy.builder() + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .build() + ) + + val roundtrippedOriginRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originRequest), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginRequest).isEqualTo(originRequest) + } + + @Test + fun ofGcs() { + val gcs = + OriginRequest.Gcs.builder() + .bucket("gcs-media") + .clientEmail("service-account@project.iam.gserviceaccount.com") + .name("US S3 Storage") + .privateKey("-----BEGIN PRIVATE KEY-----\\nMIIEv...") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("products") + .build() + + val originRequest = OriginRequest.ofGcs(gcs) + + assertThat(originRequest.s3()).isEmpty + assertThat(originRequest.s3Compatible()).isEmpty + assertThat(originRequest.cloudinaryBackup()).isEmpty + assertThat(originRequest.webFolder()).isEmpty + assertThat(originRequest.webProxy()).isEmpty + assertThat(originRequest.gcs()).contains(gcs) + assertThat(originRequest.azureBlob()).isEmpty + assertThat(originRequest.akeneoPim()).isEmpty + } + + @Test + fun ofGcsRoundtrip() { + val jsonMapper = jsonMapper() + val originRequest = + OriginRequest.ofGcs( + OriginRequest.Gcs.builder() + .bucket("gcs-media") + .clientEmail("service-account@project.iam.gserviceaccount.com") + .name("US S3 Storage") + .privateKey("-----BEGIN PRIVATE KEY-----\\nMIIEv...") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("products") + .build() + ) + + val roundtrippedOriginRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originRequest), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginRequest).isEqualTo(originRequest) + } + + @Test + fun ofAzureBlob() { + val azureBlob = + OriginRequest.AzureBlob.builder() + .accountName("account123") + .container("images") + .name("US S3 Storage") + .sasToken("?sv=2023-01-03&sr=c&sig=abc123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("uploads") + .build() + + val originRequest = OriginRequest.ofAzureBlob(azureBlob) + + assertThat(originRequest.s3()).isEmpty + assertThat(originRequest.s3Compatible()).isEmpty + assertThat(originRequest.cloudinaryBackup()).isEmpty + assertThat(originRequest.webFolder()).isEmpty + assertThat(originRequest.webProxy()).isEmpty + assertThat(originRequest.gcs()).isEmpty + assertThat(originRequest.azureBlob()).contains(azureBlob) + assertThat(originRequest.akeneoPim()).isEmpty + } + + @Test + fun ofAzureBlobRoundtrip() { + val jsonMapper = jsonMapper() + val originRequest = + OriginRequest.ofAzureBlob( + OriginRequest.AzureBlob.builder() + .accountName("account123") + .container("images") + .name("US S3 Storage") + .sasToken("?sv=2023-01-03&sr=c&sig=abc123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("uploads") + .build() + ) + + val roundtrippedOriginRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originRequest), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginRequest).isEqualTo(originRequest) + } + + @Test + fun ofAkeneoPim() { + val akeneoPim = + OriginRequest.AkeneoPim.builder() + .baseUrl("https://akeneo.company.com") + .clientId("akeneo-client-id") + .clientSecret("akeneo-client-secret") + .name("US S3 Storage") + .password("strongpassword123") + .username("integration-user") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .build() + + val originRequest = OriginRequest.ofAkeneoPim(akeneoPim) + + assertThat(originRequest.s3()).isEmpty + assertThat(originRequest.s3Compatible()).isEmpty + assertThat(originRequest.cloudinaryBackup()).isEmpty + assertThat(originRequest.webFolder()).isEmpty + assertThat(originRequest.webProxy()).isEmpty + assertThat(originRequest.gcs()).isEmpty + assertThat(originRequest.azureBlob()).isEmpty + assertThat(originRequest.akeneoPim()).contains(akeneoPim) + } + + @Test + fun ofAkeneoPimRoundtrip() { + val jsonMapper = jsonMapper() + val originRequest = + OriginRequest.ofAkeneoPim( + OriginRequest.AkeneoPim.builder() + .baseUrl("https://akeneo.company.com") + .clientId("akeneo-client-id") + .clientSecret("akeneo-client-secret") + .name("US S3 Storage") + .password("strongpassword123") + .username("integration-user") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .build() + ) + + val roundtrippedOriginRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originRequest), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginRequest).isEqualTo(originRequest) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val originRequest = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { originRequest.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginResponseTest.kt new file mode 100644 index 00000000..da0a3935 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginResponseTest.kt @@ -0,0 +1,420 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.origins + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import com.imagekit.api.errors.ImageKitInvalidDataException +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class OriginResponseTest { + + @Test + fun ofS3() { + val s3 = + OriginResponse.S3.builder() + .id("id") + .bucket("product-images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix("raw-assets") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originResponse = OriginResponse.ofS3(s3) + + assertThat(originResponse.s3()).contains(s3) + assertThat(originResponse.s3Compatible()).isEmpty + assertThat(originResponse.cloudinaryBackup()).isEmpty + assertThat(originResponse.webFolder()).isEmpty + assertThat(originResponse.webProxy()).isEmpty + assertThat(originResponse.gcs()).isEmpty + assertThat(originResponse.azureBlob()).isEmpty + assertThat(originResponse.akeneoPim()).isEmpty + } + + @Test + fun ofS3Roundtrip() { + val jsonMapper = jsonMapper() + val originResponse = + OriginResponse.ofS3( + OriginResponse.S3.builder() + .id("id") + .bucket("product-images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix("raw-assets") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginResponse).isEqualTo(originResponse) + } + + @Test + fun ofS3Compatible() { + val s3Compatible = + OriginResponse.S3Compatible.builder() + .id("id") + .bucket("product-images") + .endpoint("https://s3.eu-central-1.wasabisys.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix("raw-assets") + .s3ForcePathStyle(true) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originResponse = OriginResponse.ofS3Compatible(s3Compatible) + + assertThat(originResponse.s3()).isEmpty + assertThat(originResponse.s3Compatible()).contains(s3Compatible) + assertThat(originResponse.cloudinaryBackup()).isEmpty + assertThat(originResponse.webFolder()).isEmpty + assertThat(originResponse.webProxy()).isEmpty + assertThat(originResponse.gcs()).isEmpty + assertThat(originResponse.azureBlob()).isEmpty + assertThat(originResponse.akeneoPim()).isEmpty + } + + @Test + fun ofS3CompatibleRoundtrip() { + val jsonMapper = jsonMapper() + val originResponse = + OriginResponse.ofS3Compatible( + OriginResponse.S3Compatible.builder() + .id("id") + .bucket("product-images") + .endpoint("https://s3.eu-central-1.wasabisys.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix("raw-assets") + .s3ForcePathStyle(true) + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginResponse).isEqualTo(originResponse) + } + + @Test + fun ofCloudinaryBackup() { + val cloudinaryBackup = + OriginResponse.CloudinaryBackup.builder() + .id("id") + .bucket("product-images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix("raw-assets") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originResponse = OriginResponse.ofCloudinaryBackup(cloudinaryBackup) + + assertThat(originResponse.s3()).isEmpty + assertThat(originResponse.s3Compatible()).isEmpty + assertThat(originResponse.cloudinaryBackup()).contains(cloudinaryBackup) + assertThat(originResponse.webFolder()).isEmpty + assertThat(originResponse.webProxy()).isEmpty + assertThat(originResponse.gcs()).isEmpty + assertThat(originResponse.azureBlob()).isEmpty + assertThat(originResponse.akeneoPim()).isEmpty + } + + @Test + fun ofCloudinaryBackupRoundtrip() { + val jsonMapper = jsonMapper() + val originResponse = + OriginResponse.ofCloudinaryBackup( + OriginResponse.CloudinaryBackup.builder() + .id("id") + .bucket("product-images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix("raw-assets") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginResponse).isEqualTo(originResponse) + } + + @Test + fun ofWebFolder() { + val webFolder = + OriginResponse.WebFolder.builder() + .id("id") + .baseUrl("https://images.example.com/assets") + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originResponse = OriginResponse.ofWebFolder(webFolder) + + assertThat(originResponse.s3()).isEmpty + assertThat(originResponse.s3Compatible()).isEmpty + assertThat(originResponse.cloudinaryBackup()).isEmpty + assertThat(originResponse.webFolder()).contains(webFolder) + assertThat(originResponse.webProxy()).isEmpty + assertThat(originResponse.gcs()).isEmpty + assertThat(originResponse.azureBlob()).isEmpty + assertThat(originResponse.akeneoPim()).isEmpty + } + + @Test + fun ofWebFolderRoundtrip() { + val jsonMapper = jsonMapper() + val originResponse = + OriginResponse.ofWebFolder( + OriginResponse.WebFolder.builder() + .id("id") + .baseUrl("https://images.example.com/assets") + .forwardHostHeaderToOrigin(false) + .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginResponse).isEqualTo(originResponse) + } + + @Test + fun ofWebProxy() { + val webProxy = + OriginResponse.WebProxy.builder() + .id("id") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originResponse = OriginResponse.ofWebProxy(webProxy) + + assertThat(originResponse.s3()).isEmpty + assertThat(originResponse.s3Compatible()).isEmpty + assertThat(originResponse.cloudinaryBackup()).isEmpty + assertThat(originResponse.webFolder()).isEmpty + assertThat(originResponse.webProxy()).contains(webProxy) + assertThat(originResponse.gcs()).isEmpty + assertThat(originResponse.azureBlob()).isEmpty + assertThat(originResponse.akeneoPim()).isEmpty + } + + @Test + fun ofWebProxyRoundtrip() { + val jsonMapper = jsonMapper() + val originResponse = + OriginResponse.ofWebProxy( + OriginResponse.WebProxy.builder() + .id("id") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginResponse).isEqualTo(originResponse) + } + + @Test + fun ofGcs() { + val gcs = + OriginResponse.Gcs.builder() + .id("id") + .bucket("gcs-media") + .clientEmail("service-account@project.iam.gserviceaccount.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix("products") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originResponse = OriginResponse.ofGcs(gcs) + + assertThat(originResponse.s3()).isEmpty + assertThat(originResponse.s3Compatible()).isEmpty + assertThat(originResponse.cloudinaryBackup()).isEmpty + assertThat(originResponse.webFolder()).isEmpty + assertThat(originResponse.webProxy()).isEmpty + assertThat(originResponse.gcs()).contains(gcs) + assertThat(originResponse.azureBlob()).isEmpty + assertThat(originResponse.akeneoPim()).isEmpty + } + + @Test + fun ofGcsRoundtrip() { + val jsonMapper = jsonMapper() + val originResponse = + OriginResponse.ofGcs( + OriginResponse.Gcs.builder() + .id("id") + .bucket("gcs-media") + .clientEmail("service-account@project.iam.gserviceaccount.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix("products") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginResponse).isEqualTo(originResponse) + } + + @Test + fun ofAzureBlob() { + val azureBlob = + OriginResponse.AzureBlob.builder() + .id("id") + .accountName("account123") + .container("images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix("uploads") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originResponse = OriginResponse.ofAzureBlob(azureBlob) + + assertThat(originResponse.s3()).isEmpty + assertThat(originResponse.s3Compatible()).isEmpty + assertThat(originResponse.cloudinaryBackup()).isEmpty + assertThat(originResponse.webFolder()).isEmpty + assertThat(originResponse.webProxy()).isEmpty + assertThat(originResponse.gcs()).isEmpty + assertThat(originResponse.azureBlob()).contains(azureBlob) + assertThat(originResponse.akeneoPim()).isEmpty + } + + @Test + fun ofAzureBlobRoundtrip() { + val jsonMapper = jsonMapper() + val originResponse = + OriginResponse.ofAzureBlob( + OriginResponse.AzureBlob.builder() + .id("id") + .accountName("account123") + .container("images") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .prefix("uploads") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginResponse).isEqualTo(originResponse) + } + + @Test + fun ofAkeneoPim() { + val akeneoPim = + OriginResponse.AkeneoPim.builder() + .id("id") + .baseUrl("https://akeneo.company.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + + val originResponse = OriginResponse.ofAkeneoPim(akeneoPim) + + assertThat(originResponse.s3()).isEmpty + assertThat(originResponse.s3Compatible()).isEmpty + assertThat(originResponse.cloudinaryBackup()).isEmpty + assertThat(originResponse.webFolder()).isEmpty + assertThat(originResponse.webProxy()).isEmpty + assertThat(originResponse.gcs()).isEmpty + assertThat(originResponse.azureBlob()).isEmpty + assertThat(originResponse.akeneoPim()).contains(akeneoPim) + } + + @Test + fun ofAkeneoPimRoundtrip() { + val jsonMapper = jsonMapper() + val originResponse = + OriginResponse.ofAkeneoPim( + OriginResponse.AkeneoPim.builder() + .id("id") + .baseUrl("https://akeneo.company.com") + .includeCanonicalHeader(false) + .name("US S3 Storage") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .build() + ) + + val roundtrippedOriginResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(originResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedOriginResponse).isEqualTo(originResponse) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val originResponse = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { originResponse.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParamsTest.kt new file mode 100644 index 00000000..f8a57949 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParamsTest.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.origins + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class OriginUpdateParamsTest { + + @Test + fun create() { + OriginUpdateParams.builder() + .id("id") + .origin( + OriginRequest.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + OriginUpdateParams.builder() + .id("id") + .origin( + OriginRequest.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + OriginUpdateParams.builder() + .id("id") + .origin( + OriginRequest.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + OriginRequest.ofS3( + OriginRequest.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + OriginUpdateParams.builder() + .id("id") + .origin( + OriginRequest.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + OriginRequest.ofS3( + OriginRequest.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .build() + ) + ) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt new file mode 100644 index 00000000..93293ea4 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt @@ -0,0 +1,77 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.urlendpoints + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UrlEndpointCreateParamsTest { + + @Test + fun create() { + UrlEndpointCreateParams.builder() + .urlEndpointRequest( + UrlEndpointRequest.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + UrlEndpointCreateParams.builder() + .urlEndpointRequest( + UrlEndpointRequest.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + UrlEndpointRequest.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + UrlEndpointCreateParams.builder() + .urlEndpointRequest( + UrlEndpointRequest.builder().description("My custom URL endpoint").build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo(UrlEndpointRequest.builder().description("My custom URL endpoint").build()) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt new file mode 100644 index 00000000..180ae83e --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.urlendpoints + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UrlEndpointDeleteParamsTest { + + @Test + fun create() { + UrlEndpointDeleteParams.builder().id("id").build() + } + + @Test + fun pathParams() { + val params = UrlEndpointDeleteParams.builder().id("id").build() + + assertThat(params._pathParam(0)).isEqualTo("id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt new file mode 100644 index 00000000..83851559 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.urlendpoints + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UrlEndpointGetParamsTest { + + @Test + fun create() { + UrlEndpointGetParams.builder().id("id").build() + } + + @Test + fun pathParams() { + val params = UrlEndpointGetParams.builder().id("id").build() + + assertThat(params._pathParam(0)).isEqualTo("id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt new file mode 100644 index 00000000..0aa9b747 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.urlendpoints + +import org.junit.jupiter.api.Test + +internal class UrlEndpointListParamsTest { + + @Test + fun create() { + UrlEndpointListParams.builder().build() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequestTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequestTest.kt new file mode 100644 index 00000000..7c2de876 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequestTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.urlendpoints + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UrlEndpointRequestTest { + + @Test + fun create() { + val urlEndpointRequest = + UrlEndpointRequest.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + + assertThat(urlEndpointRequest.description()).isEqualTo("My custom URL endpoint") + assertThat(urlEndpointRequest.origins().getOrNull()).containsExactly("origin-id-1") + assertThat(urlEndpointRequest.urlPrefix()).contains("product-images") + assertThat(urlEndpointRequest.urlRewriter()) + .contains( + UrlEndpointRequest.UrlRewriter.ofCloudinary( + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val urlEndpointRequest = + UrlEndpointRequest.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + + val roundtrippedUrlEndpointRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(urlEndpointRequest), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUrlEndpointRequest).isEqualTo(urlEndpointRequest) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponseTest.kt new file mode 100644 index 00000000..fa5854c1 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponseTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.urlendpoints + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UrlEndpointResponseTest { + + @Test + fun create() { + val urlEndpointResponse = + UrlEndpointResponse.builder() + .id("id") + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .addOrigin("origin-id-2") + .urlPrefix("product-images") + .cloudinaryUrlRewriter(true) + .build() + + assertThat(urlEndpointResponse.id()).isEqualTo("id") + assertThat(urlEndpointResponse.description()).isEqualTo("My custom URL endpoint") + assertThat(urlEndpointResponse.origins()).containsExactly("origin-id-1", "origin-id-2") + assertThat(urlEndpointResponse.urlPrefix()).isEqualTo("product-images") + assertThat(urlEndpointResponse.urlRewriter()) + .contains( + UrlEndpointResponse.UrlRewriter.ofCloudinary( + UrlEndpointResponse.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val urlEndpointResponse = + UrlEndpointResponse.builder() + .id("id") + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .addOrigin("origin-id-2") + .urlPrefix("product-images") + .cloudinaryUrlRewriter(true) + .build() + + val roundtrippedUrlEndpointResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(urlEndpointResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUrlEndpointResponse).isEqualTo(urlEndpointResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt new file mode 100644 index 00000000..434647b2 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt @@ -0,0 +1,95 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.urlendpoints + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UrlEndpointUpdateParamsTest { + + @Test + fun create() { + UrlEndpointUpdateParams.builder() + .id("id") + .urlEndpointRequest( + UrlEndpointRequest.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + UrlEndpointUpdateParams.builder() + .id("id") + .urlEndpointRequest( + UrlEndpointRequest.builder().description("My custom URL endpoint").build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + UrlEndpointUpdateParams.builder() + .id("id") + .urlEndpointRequest( + UrlEndpointRequest.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + UrlEndpointRequest.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + UrlEndpointUpdateParams.builder() + .id("id") + .urlEndpointRequest( + UrlEndpointRequest.builder().description("My custom URL endpoint").build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo(UrlEndpointRequest.builder().description("My custom URL endpoint").build()) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/usage/UsageGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/usage/UsageGetParamsTest.kt new file mode 100644 index 00000000..260fb488 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/usage/UsageGetParamsTest.kt @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.usage + +import com.imagekit.api.core.http.QueryParams +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UsageGetParamsTest { + + @Test + fun create() { + UsageGetParams.builder() + .endDate(LocalDate.parse("2019-12-27")) + .startDate(LocalDate.parse("2019-12-27")) + .build() + } + + @Test + fun queryParams() { + val params = + UsageGetParams.builder() + .endDate(LocalDate.parse("2019-12-27")) + .startDate(LocalDate.parse("2019-12-27")) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("endDate", "2019-12-27") + .put("startDate", "2019-12-27") + .build() + ) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponseTest.kt new file mode 100644 index 00000000..c0b5123a --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponseTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.accounts.usage + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UsageGetResponseTest { + + @Test + fun create() { + val usageGetResponse = + UsageGetResponse.builder() + .bandwidthBytes(0L) + .extensionUnitsCount(0L) + .mediaLibraryStorageBytes(0L) + .originalCacheStorageBytes(0L) + .videoProcessingUnitsCount(0L) + .build() + + assertThat(usageGetResponse.bandwidthBytes()).contains(0L) + assertThat(usageGetResponse.extensionUnitsCount()).contains(0L) + assertThat(usageGetResponse.mediaLibraryStorageBytes()).contains(0L) + assertThat(usageGetResponse.originalCacheStorageBytes()).contains(0L) + assertThat(usageGetResponse.videoProcessingUnitsCount()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val usageGetResponse = + UsageGetResponse.builder() + .bandwidthBytes(0L) + .extensionUnitsCount(0L) + .mediaLibraryStorageBytes(0L) + .originalCacheStorageBytes(0L) + .videoProcessingUnitsCount(0L) + .build() + + val roundtrippedUsageGetResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(usageGetResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUsageGetResponse).isEqualTo(usageGetResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListParamsTest.kt new file mode 100644 index 00000000..711b9e12 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListParamsTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.assets + +import com.imagekit.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AssetListParamsTest { + + @Test + fun create() { + AssetListParams.builder() + .fileType(AssetListParams.FileType.ALL) + .limit(1L) + .path("path") + .searchQuery("searchQuery") + .skip(0L) + .sort(AssetListParams.Sort.ASC_NAME) + .type(AssetListParams.Type.FILE) + .build() + } + + @Test + fun queryParams() { + val params = + AssetListParams.builder() + .fileType(AssetListParams.FileType.ALL) + .limit(1L) + .path("path") + .searchQuery("searchQuery") + .skip(0L) + .sort(AssetListParams.Sort.ASC_NAME) + .type(AssetListParams.Type.FILE) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("fileType", "all") + .put("limit", "1") + .put("path", "path") + .put("searchQuery", "searchQuery") + .put("skip", "0") + .put("sort", "ASC_NAME") + .put("type", "file") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = AssetListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt new file mode 100644 index 00000000..70896711 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt @@ -0,0 +1,165 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.assets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.files.File +import com.imagekit.api.models.files.Folder +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class AssetListResponseTest { + + @Test + fun ofFile() { + val file = + File.builder() + .addAiTag( + File.AiTag.builder().confidence(0.0).name("name").source("source").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .width(0.0) + .build() + + val assetListResponse = AssetListResponse.ofFile(file) + + assertThat(assetListResponse.file()).contains(file) + assertThat(assetListResponse.folder()).isEmpty + } + + @Test + fun ofFileRoundtrip() { + val jsonMapper = jsonMapper() + val assetListResponse = + AssetListResponse.ofFile( + File.builder() + .addAiTag( + File.AiTag.builder().confidence(0.0).name("name").source("source").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .width(0.0) + .build() + ) + + val roundtrippedAssetListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(assetListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAssetListResponse).isEqualTo(assetListResponse) + } + + @Test + fun ofFolder() { + val folder = + Folder.builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .folderId("folderId") + .folderPath("folderPath") + .name("name") + .type(Folder.Type.FOLDER) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val assetListResponse = AssetListResponse.ofFolder(folder) + + assertThat(assetListResponse.file()).isEmpty + assertThat(assetListResponse.folder()).contains(folder) + } + + @Test + fun ofFolderRoundtrip() { + val jsonMapper = jsonMapper() + val assetListResponse = + AssetListResponse.ofFolder( + Folder.builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .folderId("folderId") + .folderPath("folderPath") + .name("name") + .type(Folder.Type.FOLDER) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val roundtrippedAssetListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(assetListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAssetListResponse).isEqualTo(assetListResponse) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val assetListResponse = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { assetListResponse.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt new file mode 100644 index 00000000..89ff5672 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt @@ -0,0 +1,296 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.beta.v2.files + +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.MultipartField +import java.io.InputStream +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileUploadParamsTest { + + @Test + fun create() { + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + } + + @Test + fun body() { + val params = + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + + val body = params._body() + + assertThat(body.filterValues { !it.value.isNull() }) + .usingRecursiveComparison() + // TODO(AssertJ): Replace this and the `mapValues` below with: + // https://github.com/assertj/assertj/issues/3165 + .withEqualsForType( + { a, b -> a.readBytes() contentEquals b.readBytes() }, + InputStream::class.java, + ) + .isEqualTo( + mapOf( + "file" to MultipartField.of("some content".byteInputStream()), + "fileName" to MultipartField.of("fileName"), + "token" to MultipartField.of("token"), + "checks" to MultipartField.of("\"request.folder\" : \"marketing/\"\n"), + "customCoordinates" to MultipartField.of("customCoordinates"), + "customMetadata" to + MultipartField.of( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ), + "description" to MultipartField.of("Running shoes"), + "extensions" to + MultipartField.of( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ), + "folder" to MultipartField.of("folder"), + "isPrivateFile" to MultipartField.of(true), + "isPublished" to MultipartField.of(true), + "overwriteAITags" to MultipartField.of(true), + "overwriteCustomMetadata" to MultipartField.of(true), + "overwriteFile" to MultipartField.of(true), + "overwriteTags" to MultipartField.of(true), + "responseFields" to + MultipartField.of( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ), + "tags" to MultipartField.of(listOf("t-shirt", "round-neck", "men")), + "transformation" to + MultipartField.of( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ), + "useUniqueFileName" to MultipartField.of(true), + "webhookUrl" to MultipartField.of("https://example.com"), + ) + .mapValues { (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .build() + + val body = params._body() + + assertThat(body.filterValues { !it.value.isNull() }) + .usingRecursiveComparison() + // TODO(AssertJ): Replace this and the `mapValues` below with: + // https://github.com/assertj/assertj/issues/3165 + .withEqualsForType( + { a, b -> a.readBytes() contentEquals b.readBytes() }, + InputStream::class.java, + ) + .isEqualTo( + mapOf( + "file" to MultipartField.of("some content".byteInputStream()), + "fileName" to MultipartField.of("fileName"), + ) + .mapValues { (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt new file mode 100644 index 00000000..9c5cab4e --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt @@ -0,0 +1,448 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.beta.v2.files + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import com.imagekit.api.models.files.Metadata +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileUploadResponseTest { + + @Test + fun create() { + val fileUploadResponse = + FileUploadResponse.builder() + .addAiTag( + FileUploadResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + FileUploadResponse.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + FileUploadResponse.ExtensionStatus.builder() + .aiAutoDescription( + FileUploadResponse.ExtensionStatus.AiAutoDescription.SUCCESS + ) + .awsAutoTagging(FileUploadResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) + .googleAutoTagging( + FileUploadResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS + ) + .removeBg(FileUploadResponse.ExtensionStatus.RemoveBg.SUCCESS) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .metadata( + Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + Metadata.Exif.builder() + .exif( + Metadata.Exif.InnerExif.builder() + .apertureValue(0.0) + .colorSpace(0L) + .createDate("CreateDate") + .customRendered(0L) + .dateTimeOriginal("DateTimeOriginal") + .exifImageHeight(0L) + .exifImageWidth(0L) + .exifVersion("ExifVersion") + .exposureCompensation(0.0) + .exposureMode(0L) + .exposureProgram(0L) + .exposureTime(0.0) + .flash(0L) + .flashpixVersion("FlashpixVersion") + .fNumber(0.0) + .focalLength(0L) + .focalPlaneResolutionUnit(0L) + .focalPlaneXResolution(0.0) + .focalPlaneYResolution(0.0) + .interopOffset(0L) + .iso(0L) + .meteringMode(0L) + .sceneCaptureType(0L) + .shutterSpeedValue(0.0) + .subSecTime("SubSecTime") + .whiteBalance(0L) + .build() + ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) + .image( + Metadata.Exif.Image.builder() + .exifOffset(0L) + .gpsInfo(0L) + .make("Make") + .model("Model") + .modifyDate("ModifyDate") + .orientation(0L) + .resolutionUnit(0L) + .software("Software") + .xResolution(0L) + .yCbCrPositioning(0L) + .yResolution(0L) + .build() + ) + .interoperability( + Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + Metadata.Exif.Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + ) + .build() + ) + .format("format") + .hasColorProfile(true) + .hasTransparency(true) + .height(0L) + .pHash("pHash") + .quality(0L) + .size(0L) + .videoCodec("videoCodec") + .width(0L) + .build() + ) + .name("name") + .size(0.0) + .addTag("string") + .thumbnailUrl("thumbnailUrl") + .url("url") + .versionInfo(FileUploadResponse.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + + assertThat(fileUploadResponse.aiTags().getOrNull()) + .containsExactly( + FileUploadResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + assertThat(fileUploadResponse.audioCodec()).contains("audioCodec") + assertThat(fileUploadResponse.bitRate()).contains(0L) + assertThat(fileUploadResponse.customCoordinates()).contains("customCoordinates") + assertThat(fileUploadResponse.customMetadata()) + .contains( + FileUploadResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(fileUploadResponse.description()).contains("description") + assertThat(fileUploadResponse.duration()).contains(0L) + assertThat(fileUploadResponse.embeddedMetadata()) + .contains( + FileUploadResponse.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(fileUploadResponse.extensionStatus()) + .contains( + FileUploadResponse.ExtensionStatus.builder() + .aiAutoDescription(FileUploadResponse.ExtensionStatus.AiAutoDescription.SUCCESS) + .awsAutoTagging(FileUploadResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) + .googleAutoTagging(FileUploadResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS) + .removeBg(FileUploadResponse.ExtensionStatus.RemoveBg.SUCCESS) + .build() + ) + assertThat(fileUploadResponse.fileId()).contains("fileId") + assertThat(fileUploadResponse.filePath()).contains("filePath") + assertThat(fileUploadResponse.fileType()).contains("fileType") + assertThat(fileUploadResponse.height()).contains(0.0) + assertThat(fileUploadResponse.isPrivateFile()).contains(true) + assertThat(fileUploadResponse.isPublished()).contains(true) + assertThat(fileUploadResponse.metadata()) + .contains( + Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + Metadata.Exif.builder() + .exif( + Metadata.Exif.InnerExif.builder() + .apertureValue(0.0) + .colorSpace(0L) + .createDate("CreateDate") + .customRendered(0L) + .dateTimeOriginal("DateTimeOriginal") + .exifImageHeight(0L) + .exifImageWidth(0L) + .exifVersion("ExifVersion") + .exposureCompensation(0.0) + .exposureMode(0L) + .exposureProgram(0L) + .exposureTime(0.0) + .flash(0L) + .flashpixVersion("FlashpixVersion") + .fNumber(0.0) + .focalLength(0L) + .focalPlaneResolutionUnit(0L) + .focalPlaneXResolution(0.0) + .focalPlaneYResolution(0.0) + .interopOffset(0L) + .iso(0L) + .meteringMode(0L) + .sceneCaptureType(0L) + .shutterSpeedValue(0.0) + .subSecTime("SubSecTime") + .whiteBalance(0L) + .build() + ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) + .image( + Metadata.Exif.Image.builder() + .exifOffset(0L) + .gpsInfo(0L) + .make("Make") + .model("Model") + .modifyDate("ModifyDate") + .orientation(0L) + .resolutionUnit(0L) + .software("Software") + .xResolution(0L) + .yCbCrPositioning(0L) + .yResolution(0L) + .build() + ) + .interoperability( + Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + Metadata.Exif.Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + ) + .build() + ) + .format("format") + .hasColorProfile(true) + .hasTransparency(true) + .height(0L) + .pHash("pHash") + .quality(0L) + .size(0L) + .videoCodec("videoCodec") + .width(0L) + .build() + ) + assertThat(fileUploadResponse.name()).contains("name") + assertThat(fileUploadResponse.size()).contains(0.0) + assertThat(fileUploadResponse.tags().getOrNull()).containsExactly("string") + assertThat(fileUploadResponse.thumbnailUrl()).contains("thumbnailUrl") + assertThat(fileUploadResponse.url()).contains("url") + assertThat(fileUploadResponse.versionInfo()) + .contains(FileUploadResponse.VersionInfo.builder().id("id").name("name").build()) + assertThat(fileUploadResponse.videoCodec()).contains("videoCodec") + assertThat(fileUploadResponse.width()).contains(0.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fileUploadResponse = + FileUploadResponse.builder() + .addAiTag( + FileUploadResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + FileUploadResponse.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + FileUploadResponse.ExtensionStatus.builder() + .aiAutoDescription( + FileUploadResponse.ExtensionStatus.AiAutoDescription.SUCCESS + ) + .awsAutoTagging(FileUploadResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) + .googleAutoTagging( + FileUploadResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS + ) + .removeBg(FileUploadResponse.ExtensionStatus.RemoveBg.SUCCESS) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .metadata( + Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + Metadata.Exif.builder() + .exif( + Metadata.Exif.InnerExif.builder() + .apertureValue(0.0) + .colorSpace(0L) + .createDate("CreateDate") + .customRendered(0L) + .dateTimeOriginal("DateTimeOriginal") + .exifImageHeight(0L) + .exifImageWidth(0L) + .exifVersion("ExifVersion") + .exposureCompensation(0.0) + .exposureMode(0L) + .exposureProgram(0L) + .exposureTime(0.0) + .flash(0L) + .flashpixVersion("FlashpixVersion") + .fNumber(0.0) + .focalLength(0L) + .focalPlaneResolutionUnit(0L) + .focalPlaneXResolution(0.0) + .focalPlaneYResolution(0.0) + .interopOffset(0L) + .iso(0L) + .meteringMode(0L) + .sceneCaptureType(0L) + .shutterSpeedValue(0.0) + .subSecTime("SubSecTime") + .whiteBalance(0L) + .build() + ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) + .image( + Metadata.Exif.Image.builder() + .exifOffset(0L) + .gpsInfo(0L) + .make("Make") + .model("Model") + .modifyDate("ModifyDate") + .orientation(0L) + .resolutionUnit(0L) + .software("Software") + .xResolution(0L) + .yCbCrPositioning(0L) + .yResolution(0L) + .build() + ) + .interoperability( + Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + Metadata.Exif.Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + ) + .build() + ) + .format("format") + .hasColorProfile(true) + .hasTransparency(true) + .height(0L) + .pHash("pHash") + .quality(0L) + .size(0L) + .videoCodec("videoCodec") + .width(0L) + .build() + ) + .name("name") + .size(0.0) + .addTag("string") + .thumbnailUrl("thumbnailUrl") + .url("url") + .versionInfo(FileUploadResponse.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + + val roundtrippedFileUploadResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fileUploadResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFileUploadResponse).isEqualTo(fileUploadResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParamsTest.kt new file mode 100644 index 00000000..94ef7b2c --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParamsTest.kt @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.cache.invalidation + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InvalidationCreateParamsTest { + + @Test + fun create() { + InvalidationCreateParams.builder() + .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg") + .build() + } + + @Test + fun body() { + val params = + InvalidationCreateParams.builder() + .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg") + .build() + + val body = params._body() + + assertThat(body.url()) + .isEqualTo("https://ik.imagekit.io/your_imagekit_id/default-image.jpg") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponseTest.kt new file mode 100644 index 00000000..70da7c09 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponseTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.cache.invalidation + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InvalidationCreateResponseTest { + + @Test + fun create() { + val invalidationCreateResponse = + InvalidationCreateResponse.builder().requestId("requestId").build() + + assertThat(invalidationCreateResponse.requestId()).contains("requestId") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val invalidationCreateResponse = + InvalidationCreateResponse.builder().requestId("requestId").build() + + val roundtrippedInvalidationCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(invalidationCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInvalidationCreateResponse).isEqualTo(invalidationCreateResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetParamsTest.kt new file mode 100644 index 00000000..452b8982 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.cache.invalidation + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InvalidationGetParamsTest { + + @Test + fun create() { + InvalidationGetParams.builder().requestId("requestId").build() + } + + @Test + fun pathParams() { + val params = InvalidationGetParams.builder().requestId("requestId").build() + + assertThat(params._pathParam(0)).isEqualTo("requestId") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponseTest.kt new file mode 100644 index 00000000..0bcd4825 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponseTest.kt @@ -0,0 +1,39 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.cache.invalidation + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InvalidationGetResponseTest { + + @Test + fun create() { + val invalidationGetResponse = + InvalidationGetResponse.builder() + .status(InvalidationGetResponse.Status.COMPLETED) + .build() + + assertThat(invalidationGetResponse.status()) + .contains(InvalidationGetResponse.Status.COMPLETED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val invalidationGetResponse = + InvalidationGetResponse.builder() + .status(InvalidationGetResponse.Status.COMPLETED) + .build() + + val roundtrippedInvalidationGetResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(invalidationGetResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInvalidationGetResponse).isEqualTo(invalidationGetResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt new file mode 100644 index 00000000..018fb8c6 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt @@ -0,0 +1,126 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.custommetadatafields + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomMetadataFieldCreateParamsTest { + + @Test + fun create() { + CustomMetadataFieldCreateParams.builder() + .label("price") + .name("price") + .schema( + CustomMetadataFieldCreateParams.Schema.builder() + .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue(3000.0) + .minLength(0.0) + .minValue(1000.0) + .selectOptions( + listOf( + CustomMetadataFieldCreateParams.Schema.SelectOption.ofString("small"), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofString("medium"), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofString("large"), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofNumber(30.0), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofNumber(40.0), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + CustomMetadataFieldCreateParams.builder() + .label("price") + .name("price") + .schema( + CustomMetadataFieldCreateParams.Schema.builder() + .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue(3000.0) + .minLength(0.0) + .minValue(1000.0) + .selectOptions( + listOf( + CustomMetadataFieldCreateParams.Schema.SelectOption.ofString( + "small" + ), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofString( + "medium" + ), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofString( + "large" + ), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofNumber(30.0), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofNumber(40.0), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.label()).isEqualTo("price") + assertThat(body.name()).isEqualTo("price") + assertThat(body.schema()) + .isEqualTo( + CustomMetadataFieldCreateParams.Schema.builder() + .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue(3000.0) + .minLength(0.0) + .minValue(1000.0) + .selectOptions( + listOf( + CustomMetadataFieldCreateParams.Schema.SelectOption.ofString("small"), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofString("medium"), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofString("large"), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofNumber(30.0), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofNumber(40.0), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + CustomMetadataFieldCreateParams.builder() + .label("price") + .name("price") + .schema( + CustomMetadataFieldCreateParams.Schema.builder() + .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.label()).isEqualTo("price") + assertThat(body.name()).isEqualTo("price") + assertThat(body.schema()) + .isEqualTo( + CustomMetadataFieldCreateParams.Schema.builder() + .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) + .build() + ) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt new file mode 100644 index 00000000..1ce51ef0 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.custommetadatafields + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomMetadataFieldDeleteParamsTest { + + @Test + fun create() { + CustomMetadataFieldDeleteParams.builder().id("id").build() + } + + @Test + fun pathParams() { + val params = CustomMetadataFieldDeleteParams.builder().id("id").build() + + assertThat(params._pathParam(0)).isEqualTo("id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt new file mode 100644 index 00000000..3f1974cd --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.custommetadatafields + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomMetadataFieldDeleteResponseTest { + + @Test + fun create() { + val customMetadataFieldDeleteResponse = CustomMetadataFieldDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customMetadataFieldDeleteResponse = CustomMetadataFieldDeleteResponse.builder().build() + + val roundtrippedCustomMetadataFieldDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customMetadataFieldDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomMetadataFieldDeleteResponse) + .isEqualTo(customMetadataFieldDeleteResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt new file mode 100644 index 00000000..df9806ae --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.custommetadatafields + +import com.imagekit.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomMetadataFieldListParamsTest { + + @Test + fun create() { + CustomMetadataFieldListParams.builder().includeDeleted(true).build() + } + + @Test + fun queryParams() { + val params = CustomMetadataFieldListParams.builder().includeDeleted(true).build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("includeDeleted", "true").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = CustomMetadataFieldListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt new file mode 100644 index 00000000..14455b92 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt @@ -0,0 +1,108 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.custommetadatafields + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomMetadataFieldTest { + + @Test + fun create() { + val customMetadataField = + CustomMetadataField.builder() + .id("id") + .label("label") + .name("name") + .schema( + CustomMetadataField.Schema.builder() + .type(CustomMetadataField.Schema.Type.TEXT) + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue("string") + .minLength(0.0) + .minValue("string") + .selectOptions( + listOf( + CustomMetadataField.Schema.SelectOption.ofString("small"), + CustomMetadataField.Schema.SelectOption.ofString("medium"), + CustomMetadataField.Schema.SelectOption.ofString("large"), + CustomMetadataField.Schema.SelectOption.ofNumber(30.0), + CustomMetadataField.Schema.SelectOption.ofNumber(40.0), + CustomMetadataField.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + .build() + + assertThat(customMetadataField.id()).isEqualTo("id") + assertThat(customMetadataField.label()).isEqualTo("label") + assertThat(customMetadataField.name()).isEqualTo("name") + assertThat(customMetadataField.schema()) + .isEqualTo( + CustomMetadataField.Schema.builder() + .type(CustomMetadataField.Schema.Type.TEXT) + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue("string") + .minLength(0.0) + .minValue("string") + .selectOptions( + listOf( + CustomMetadataField.Schema.SelectOption.ofString("small"), + CustomMetadataField.Schema.SelectOption.ofString("medium"), + CustomMetadataField.Schema.SelectOption.ofString("large"), + CustomMetadataField.Schema.SelectOption.ofNumber(30.0), + CustomMetadataField.Schema.SelectOption.ofNumber(40.0), + CustomMetadataField.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customMetadataField = + CustomMetadataField.builder() + .id("id") + .label("label") + .name("name") + .schema( + CustomMetadataField.Schema.builder() + .type(CustomMetadataField.Schema.Type.TEXT) + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue("string") + .minLength(0.0) + .minValue("string") + .selectOptions( + listOf( + CustomMetadataField.Schema.SelectOption.ofString("small"), + CustomMetadataField.Schema.SelectOption.ofString("medium"), + CustomMetadataField.Schema.SelectOption.ofString("large"), + CustomMetadataField.Schema.SelectOption.ofNumber(30.0), + CustomMetadataField.Schema.SelectOption.ofNumber(40.0), + CustomMetadataField.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + .build() + + val roundtrippedCustomMetadataField = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customMetadataField), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomMetadataField).isEqualTo(customMetadataField) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt new file mode 100644 index 00000000..5611af8d --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.custommetadatafields + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomMetadataFieldUpdateParamsTest { + + @Test + fun create() { + CustomMetadataFieldUpdateParams.builder() + .id("id") + .label("price") + .schema( + CustomMetadataFieldUpdateParams.Schema.builder() + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue(3000.0) + .minLength(0.0) + .minValue(1000.0) + .selectOptions( + listOf( + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofString("small"), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofString("medium"), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofString("large"), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofNumber(30.0), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofNumber(40.0), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = CustomMetadataFieldUpdateParams.builder().id("id").build() + + assertThat(params._pathParam(0)).isEqualTo("id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + CustomMetadataFieldUpdateParams.builder() + .id("id") + .label("price") + .schema( + CustomMetadataFieldUpdateParams.Schema.builder() + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue(3000.0) + .minLength(0.0) + .minValue(1000.0) + .selectOptions( + listOf( + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofString( + "small" + ), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofString( + "medium" + ), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofString( + "large" + ), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofNumber(30.0), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofNumber(40.0), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.label()).contains("price") + assertThat(body.schema()) + .contains( + CustomMetadataFieldUpdateParams.Schema.builder() + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue(3000.0) + .minLength(0.0) + .minValue(1000.0) + .selectOptions( + listOf( + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofString("small"), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofString("medium"), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofString("large"), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofNumber(30.0), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofNumber(40.0), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = CustomMetadataFieldUpdateParams.builder().id("id").build() + + val body = params._body() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileCopyParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileCopyParamsTest.kt new file mode 100644 index 00000000..f6e8ba6d --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileCopyParamsTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileCopyParamsTest { + + @Test + fun create() { + FileCopyParams.builder() + .destinationPath("/folder/to/copy/into/") + .sourceFilePath("/path/to/file.jpg") + .includeFileVersions(false) + .build() + } + + @Test + fun body() { + val params = + FileCopyParams.builder() + .destinationPath("/folder/to/copy/into/") + .sourceFilePath("/path/to/file.jpg") + .includeFileVersions(false) + .build() + + val body = params._body() + + assertThat(body.destinationPath()).isEqualTo("/folder/to/copy/into/") + assertThat(body.sourceFilePath()).isEqualTo("/path/to/file.jpg") + assertThat(body.includeFileVersions()).contains(false) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + FileCopyParams.builder() + .destinationPath("/folder/to/copy/into/") + .sourceFilePath("/path/to/file.jpg") + .build() + + val body = params._body() + + assertThat(body.destinationPath()).isEqualTo("/folder/to/copy/into/") + assertThat(body.sourceFilePath()).isEqualTo("/path/to/file.jpg") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileCopyResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileCopyResponseTest.kt new file mode 100644 index 00000000..24b46ab7 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileCopyResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileCopyResponseTest { + + @Test + fun create() { + val fileCopyResponse = FileCopyResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fileCopyResponse = FileCopyResponse.builder().build() + + val roundtrippedFileCopyResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fileCopyResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFileCopyResponse).isEqualTo(fileCopyResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileDeleteParamsTest.kt new file mode 100644 index 00000000..ec09e31f --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileDeleteParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileDeleteParamsTest { + + @Test + fun create() { + FileDeleteParams.builder().fileId("fileId").build() + } + + @Test + fun pathParams() { + val params = FileDeleteParams.builder().fileId("fileId").build() + + assertThat(params._pathParam(0)).isEqualTo("fileId") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetParamsTest.kt new file mode 100644 index 00000000..633e0e5e --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileGetParamsTest { + + @Test + fun create() { + FileGetParams.builder().fileId("fileId").build() + } + + @Test + fun pathParams() { + val params = FileGetParams.builder().fileId("fileId").build() + + assertThat(params._pathParam(0)).isEqualTo("fileId") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileMoveParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileMoveParamsTest.kt new file mode 100644 index 00000000..f0cc0dc1 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileMoveParamsTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileMoveParamsTest { + + @Test + fun create() { + FileMoveParams.builder() + .destinationPath("/folder/to/move/into/") + .sourceFilePath("/path/to/file.jpg") + .build() + } + + @Test + fun body() { + val params = + FileMoveParams.builder() + .destinationPath("/folder/to/move/into/") + .sourceFilePath("/path/to/file.jpg") + .build() + + val body = params._body() + + assertThat(body.destinationPath()).isEqualTo("/folder/to/move/into/") + assertThat(body.sourceFilePath()).isEqualTo("/path/to/file.jpg") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileMoveResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileMoveResponseTest.kt new file mode 100644 index 00000000..d8560b52 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileMoveResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileMoveResponseTest { + + @Test + fun create() { + val fileMoveResponse = FileMoveResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fileMoveResponse = FileMoveResponse.builder().build() + + val roundtrippedFileMoveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fileMoveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFileMoveResponse).isEqualTo(fileMoveResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRenameParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRenameParamsTest.kt new file mode 100644 index 00000000..cd3b78c5 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRenameParamsTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileRenameParamsTest { + + @Test + fun create() { + FileRenameParams.builder() + .filePath("/path/to/file.jpg") + .newFileName("newFileName.jpg") + .purgeCache(true) + .build() + } + + @Test + fun body() { + val params = + FileRenameParams.builder() + .filePath("/path/to/file.jpg") + .newFileName("newFileName.jpg") + .purgeCache(true) + .build() + + val body = params._body() + + assertThat(body.filePath()).isEqualTo("/path/to/file.jpg") + assertThat(body.newFileName()).isEqualTo("newFileName.jpg") + assertThat(body.purgeCache()).contains(true) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + FileRenameParams.builder() + .filePath("/path/to/file.jpg") + .newFileName("newFileName.jpg") + .build() + + val body = params._body() + + assertThat(body.filePath()).isEqualTo("/path/to/file.jpg") + assertThat(body.newFileName()).isEqualTo("newFileName.jpg") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRenameResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRenameResponseTest.kt new file mode 100644 index 00000000..79e2867b --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRenameResponseTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileRenameResponseTest { + + @Test + fun create() { + val fileRenameResponse = + FileRenameResponse.builder().purgeRequestId("purgeRequestId").build() + + assertThat(fileRenameResponse.purgeRequestId()).contains("purgeRequestId") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fileRenameResponse = + FileRenameResponse.builder().purgeRequestId("purgeRequestId").build() + + val roundtrippedFileRenameResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fileRenameResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFileRenameResponse).isEqualTo(fileRenameResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt new file mode 100644 index 00000000..78282e94 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt @@ -0,0 +1,122 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileTest { + + @Test + fun create() { + val file = + File.builder() + .addAiTag( + File.AiTag.builder().confidence(0.0).name("name").source("source").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .width(0.0) + .build() + + assertThat(file.aiTags().getOrNull()) + .containsExactly( + File.AiTag.builder().confidence(0.0).name("name").source("source").build() + ) + assertThat(file.createdAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(file.customCoordinates()).contains("customCoordinates") + assertThat(file.customMetadata()) + .contains( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(file.description()).contains("description") + assertThat(file.fileId()).contains("fileId") + assertThat(file.filePath()).contains("filePath") + assertThat(file.fileType()).contains("fileType") + assertThat(file.hasAlpha()).contains(true) + assertThat(file.height()).contains(0.0) + assertThat(file.isPrivateFile()).contains(true) + assertThat(file.isPublished()).contains(true) + assertThat(file.mime()).contains("mime") + assertThat(file.name()).contains("name") + assertThat(file.size()).contains(0.0) + assertThat(file.tags().getOrNull()).containsExactly("string") + assertThat(file.thumbnail()).contains("https://example.com") + assertThat(file.type()).contains(File.Type.FILE) + assertThat(file.updatedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(file.url()).contains("https://example.com") + assertThat(file.versionInfo()) + .contains(File.VersionInfo.builder().id("id").name("name").build()) + assertThat(file.width()).contains(0.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val file = + File.builder() + .addAiTag( + File.AiTag.builder().confidence(0.0).name("name").source("source").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .width(0.0) + .build() + + val roundtrippedFile = + jsonMapper.readValue(jsonMapper.writeValueAsString(file), jacksonTypeRef()) + + assertThat(roundtrippedFile).isEqualTo(file) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt new file mode 100644 index 00000000..41e97d1c --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt @@ -0,0 +1,245 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.imagekit.api.core.JsonValue +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileUpdateParamsTest { + + @Test + fun create() { + FileUpdateParams.builder() + .fileId("fileId") + .update( + FileUpdateParams.Update.UpdateFileDetails.builder() + .customCoordinates("10,10,100,100") + .customMetadata( + FileUpdateParams.Update.UpdateFileDetails.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("description") + .extensions( + listOf( + FileUpdateParams.Update.UpdateFileDetails.Extension.ofRemoveBg( + FileUpdateParams.Update.UpdateFileDetails.Extension.RemoveBg + .builder() + .options( + FileUpdateParams.Update.UpdateFileDetails.Extension.RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + FileUpdateParams.Update.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + FileUpdateParams.Update.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) + .build() + ), + FileUpdateParams.Update.UpdateFileDetails.Extension + .ofAiAutoDescription(), + ) + ) + .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) + .addTag("tag1") + .addTag("tag2") + .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = FileUpdateParams.builder().fileId("fileId").build() + + assertThat(params._pathParam(0)).isEqualTo("fileId") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + FileUpdateParams.builder() + .fileId("fileId") + .update( + FileUpdateParams.Update.UpdateFileDetails.builder() + .customCoordinates("10,10,100,100") + .customMetadata( + FileUpdateParams.Update.UpdateFileDetails.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("description") + .extensions( + listOf( + FileUpdateParams.Update.UpdateFileDetails.Extension.ofRemoveBg( + FileUpdateParams.Update.UpdateFileDetails.Extension.RemoveBg + .builder() + .options( + FileUpdateParams.Update.UpdateFileDetails.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + FileUpdateParams.Update.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + FileUpdateParams.Update.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) + .build() + ), + FileUpdateParams.Update.UpdateFileDetails.Extension + .ofAiAutoDescription(), + ) + ) + .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) + .addTag("tag1") + .addTag("tag2") + .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") + .build() + ) + .build() + + val body = params._body().getOrNull() + + assertThat(body) + .isEqualTo( + FileUpdateParams.Update.ofFileDetails( + FileUpdateParams.Update.UpdateFileDetails.builder() + .customCoordinates("10,10,100,100") + .customMetadata( + FileUpdateParams.Update.UpdateFileDetails.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("description") + .extensions( + listOf( + FileUpdateParams.Update.UpdateFileDetails.Extension.ofRemoveBg( + FileUpdateParams.Update.UpdateFileDetails.Extension.RemoveBg + .builder() + .options( + FileUpdateParams.Update.UpdateFileDetails.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + FileUpdateParams.Update.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + FileUpdateParams.Update.UpdateFileDetails.Extension + .AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) + .build() + ), + FileUpdateParams.Update.UpdateFileDetails.Extension + .ofAiAutoDescription(), + ) + ) + .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) + .addTag("tag1") + .addTag("tag2") + .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") + .build() + ) + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = FileUpdateParams.builder().fileId("fileId").build() + + val body = params._body().getOrNull() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt new file mode 100644 index 00000000..de6e3a66 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileUpdateResponseTest { + + @Test + fun create() { + val fileUpdateResponse = + FileUpdateResponse.builder() + .addAiTag( + File.AiTag.builder().confidence(0.0).name("name").source("source").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .width(0.0) + .extensionStatus( + FileUpdateResponse.ExtensionStatus.builder() + .aiAutoDescription( + FileUpdateResponse.ExtensionStatus.AiAutoDescription.SUCCESS + ) + .awsAutoTagging(FileUpdateResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) + .googleAutoTagging( + FileUpdateResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS + ) + .removeBg(FileUpdateResponse.ExtensionStatus.RemoveBg.SUCCESS) + .build() + ) + .build() + + assertThat(fileUpdateResponse.aiTags().getOrNull()) + .containsExactly( + File.AiTag.builder().confidence(0.0).name("name").source("source").build() + ) + assertThat(fileUpdateResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(fileUpdateResponse.customCoordinates()).contains("customCoordinates") + assertThat(fileUpdateResponse.customMetadata()) + .contains( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(fileUpdateResponse.description()).contains("description") + assertThat(fileUpdateResponse.fileId()).contains("fileId") + assertThat(fileUpdateResponse.filePath()).contains("filePath") + assertThat(fileUpdateResponse.fileType()).contains("fileType") + assertThat(fileUpdateResponse.hasAlpha()).contains(true) + assertThat(fileUpdateResponse.height()).contains(0.0) + assertThat(fileUpdateResponse.isPrivateFile()).contains(true) + assertThat(fileUpdateResponse.isPublished()).contains(true) + assertThat(fileUpdateResponse.mime()).contains("mime") + assertThat(fileUpdateResponse.name()).contains("name") + assertThat(fileUpdateResponse.size()).contains(0.0) + assertThat(fileUpdateResponse.tags().getOrNull()).containsExactly("string") + assertThat(fileUpdateResponse.thumbnail()).contains("https://example.com") + assertThat(fileUpdateResponse.type()).contains(File.Type.FILE) + assertThat(fileUpdateResponse.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(fileUpdateResponse.url()).contains("https://example.com") + assertThat(fileUpdateResponse.versionInfo()) + .contains(File.VersionInfo.builder().id("id").name("name").build()) + assertThat(fileUpdateResponse.width()).contains(0.0) + assertThat(fileUpdateResponse.extensionStatus()) + .contains( + FileUpdateResponse.ExtensionStatus.builder() + .aiAutoDescription(FileUpdateResponse.ExtensionStatus.AiAutoDescription.SUCCESS) + .awsAutoTagging(FileUpdateResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) + .googleAutoTagging(FileUpdateResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS) + .removeBg(FileUpdateResponse.ExtensionStatus.RemoveBg.SUCCESS) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fileUpdateResponse = + FileUpdateResponse.builder() + .addAiTag( + File.AiTag.builder().confidence(0.0).name("name").source("source").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .width(0.0) + .extensionStatus( + FileUpdateResponse.ExtensionStatus.builder() + .aiAutoDescription( + FileUpdateResponse.ExtensionStatus.AiAutoDescription.SUCCESS + ) + .awsAutoTagging(FileUpdateResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) + .googleAutoTagging( + FileUpdateResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS + ) + .removeBg(FileUpdateResponse.ExtensionStatus.RemoveBg.SUCCESS) + .build() + ) + .build() + + val roundtrippedFileUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fileUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFileUpdateResponse).isEqualTo(fileUpdateResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt new file mode 100644 index 00000000..11752909 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt @@ -0,0 +1,305 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.MultipartField +import java.io.InputStream +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileUploadParamsTest { + + @Test + fun create() { + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + } + + @Test + fun body() { + val params = + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + + val body = params._body() + + assertThat(body.filterValues { !it.value.isNull() }) + .usingRecursiveComparison() + // TODO(AssertJ): Replace this and the `mapValues` below with: + // https://github.com/assertj/assertj/issues/3165 + .withEqualsForType( + { a, b -> a.readBytes() contentEquals b.readBytes() }, + InputStream::class.java, + ) + .isEqualTo( + mapOf( + "file" to MultipartField.of("some content".byteInputStream()), + "fileName" to MultipartField.of("fileName"), + "token" to MultipartField.of("token"), + "checks" to MultipartField.of("\"request.folder\" : \"marketing/\"\n"), + "customCoordinates" to MultipartField.of("customCoordinates"), + "customMetadata" to + MultipartField.of( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ), + "description" to MultipartField.of("Running shoes"), + "expire" to MultipartField.of(0L), + "extensions" to + MultipartField.of( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ), + "folder" to MultipartField.of("folder"), + "isPrivateFile" to MultipartField.of(true), + "isPublished" to MultipartField.of(true), + "overwriteAITags" to MultipartField.of(true), + "overwriteCustomMetadata" to MultipartField.of(true), + "overwriteFile" to MultipartField.of(true), + "overwriteTags" to MultipartField.of(true), + "publicKey" to MultipartField.of("publicKey"), + "responseFields" to + MultipartField.of( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ), + "signature" to MultipartField.of("signature"), + "tags" to MultipartField.of(listOf("t-shirt", "round-neck", "men")), + "transformation" to + MultipartField.of( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ), + "useUniqueFileName" to MultipartField.of(true), + "webhookUrl" to MultipartField.of("https://example.com"), + ) + .mapValues { (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .build() + + val body = params._body() + + assertThat(body.filterValues { !it.value.isNull() }) + .usingRecursiveComparison() + // TODO(AssertJ): Replace this and the `mapValues` below with: + // https://github.com/assertj/assertj/issues/3165 + .withEqualsForType( + { a, b -> a.readBytes() contentEquals b.readBytes() }, + InputStream::class.java, + ) + .isEqualTo( + mapOf( + "file" to MultipartField.of("some content".byteInputStream()), + "fileName" to MultipartField.of("fileName"), + ) + .mapValues { (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt new file mode 100644 index 00000000..48c228e3 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt @@ -0,0 +1,447 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileUploadResponseTest { + + @Test + fun create() { + val fileUploadResponse = + FileUploadResponse.builder() + .addAiTag( + FileUploadResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + FileUploadResponse.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + FileUploadResponse.ExtensionStatus.builder() + .aiAutoDescription( + FileUploadResponse.ExtensionStatus.AiAutoDescription.SUCCESS + ) + .awsAutoTagging(FileUploadResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) + .googleAutoTagging( + FileUploadResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS + ) + .removeBg(FileUploadResponse.ExtensionStatus.RemoveBg.SUCCESS) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .metadata( + Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + Metadata.Exif.builder() + .exif( + Metadata.Exif.InnerExif.builder() + .apertureValue(0.0) + .colorSpace(0L) + .createDate("CreateDate") + .customRendered(0L) + .dateTimeOriginal("DateTimeOriginal") + .exifImageHeight(0L) + .exifImageWidth(0L) + .exifVersion("ExifVersion") + .exposureCompensation(0.0) + .exposureMode(0L) + .exposureProgram(0L) + .exposureTime(0.0) + .flash(0L) + .flashpixVersion("FlashpixVersion") + .fNumber(0.0) + .focalLength(0L) + .focalPlaneResolutionUnit(0L) + .focalPlaneXResolution(0.0) + .focalPlaneYResolution(0.0) + .interopOffset(0L) + .iso(0L) + .meteringMode(0L) + .sceneCaptureType(0L) + .shutterSpeedValue(0.0) + .subSecTime("SubSecTime") + .whiteBalance(0L) + .build() + ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) + .image( + Metadata.Exif.Image.builder() + .exifOffset(0L) + .gpsInfo(0L) + .make("Make") + .model("Model") + .modifyDate("ModifyDate") + .orientation(0L) + .resolutionUnit(0L) + .software("Software") + .xResolution(0L) + .yCbCrPositioning(0L) + .yResolution(0L) + .build() + ) + .interoperability( + Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + Metadata.Exif.Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + ) + .build() + ) + .format("format") + .hasColorProfile(true) + .hasTransparency(true) + .height(0L) + .pHash("pHash") + .quality(0L) + .size(0L) + .videoCodec("videoCodec") + .width(0L) + .build() + ) + .name("name") + .size(0.0) + .addTag("string") + .thumbnailUrl("thumbnailUrl") + .url("url") + .versionInfo(FileUploadResponse.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + + assertThat(fileUploadResponse.aiTags().getOrNull()) + .containsExactly( + FileUploadResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + assertThat(fileUploadResponse.audioCodec()).contains("audioCodec") + assertThat(fileUploadResponse.bitRate()).contains(0L) + assertThat(fileUploadResponse.customCoordinates()).contains("customCoordinates") + assertThat(fileUploadResponse.customMetadata()) + .contains( + FileUploadResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(fileUploadResponse.description()).contains("description") + assertThat(fileUploadResponse.duration()).contains(0L) + assertThat(fileUploadResponse.embeddedMetadata()) + .contains( + FileUploadResponse.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(fileUploadResponse.extensionStatus()) + .contains( + FileUploadResponse.ExtensionStatus.builder() + .aiAutoDescription(FileUploadResponse.ExtensionStatus.AiAutoDescription.SUCCESS) + .awsAutoTagging(FileUploadResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) + .googleAutoTagging(FileUploadResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS) + .removeBg(FileUploadResponse.ExtensionStatus.RemoveBg.SUCCESS) + .build() + ) + assertThat(fileUploadResponse.fileId()).contains("fileId") + assertThat(fileUploadResponse.filePath()).contains("filePath") + assertThat(fileUploadResponse.fileType()).contains("fileType") + assertThat(fileUploadResponse.height()).contains(0.0) + assertThat(fileUploadResponse.isPrivateFile()).contains(true) + assertThat(fileUploadResponse.isPublished()).contains(true) + assertThat(fileUploadResponse.metadata()) + .contains( + Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + Metadata.Exif.builder() + .exif( + Metadata.Exif.InnerExif.builder() + .apertureValue(0.0) + .colorSpace(0L) + .createDate("CreateDate") + .customRendered(0L) + .dateTimeOriginal("DateTimeOriginal") + .exifImageHeight(0L) + .exifImageWidth(0L) + .exifVersion("ExifVersion") + .exposureCompensation(0.0) + .exposureMode(0L) + .exposureProgram(0L) + .exposureTime(0.0) + .flash(0L) + .flashpixVersion("FlashpixVersion") + .fNumber(0.0) + .focalLength(0L) + .focalPlaneResolutionUnit(0L) + .focalPlaneXResolution(0.0) + .focalPlaneYResolution(0.0) + .interopOffset(0L) + .iso(0L) + .meteringMode(0L) + .sceneCaptureType(0L) + .shutterSpeedValue(0.0) + .subSecTime("SubSecTime") + .whiteBalance(0L) + .build() + ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) + .image( + Metadata.Exif.Image.builder() + .exifOffset(0L) + .gpsInfo(0L) + .make("Make") + .model("Model") + .modifyDate("ModifyDate") + .orientation(0L) + .resolutionUnit(0L) + .software("Software") + .xResolution(0L) + .yCbCrPositioning(0L) + .yResolution(0L) + .build() + ) + .interoperability( + Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + Metadata.Exif.Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + ) + .build() + ) + .format("format") + .hasColorProfile(true) + .hasTransparency(true) + .height(0L) + .pHash("pHash") + .quality(0L) + .size(0L) + .videoCodec("videoCodec") + .width(0L) + .build() + ) + assertThat(fileUploadResponse.name()).contains("name") + assertThat(fileUploadResponse.size()).contains(0.0) + assertThat(fileUploadResponse.tags().getOrNull()).containsExactly("string") + assertThat(fileUploadResponse.thumbnailUrl()).contains("thumbnailUrl") + assertThat(fileUploadResponse.url()).contains("url") + assertThat(fileUploadResponse.versionInfo()) + .contains(FileUploadResponse.VersionInfo.builder().id("id").name("name").build()) + assertThat(fileUploadResponse.videoCodec()).contains("videoCodec") + assertThat(fileUploadResponse.width()).contains(0.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fileUploadResponse = + FileUploadResponse.builder() + .addAiTag( + FileUploadResponse.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadResponse.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + FileUploadResponse.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + FileUploadResponse.ExtensionStatus.builder() + .aiAutoDescription( + FileUploadResponse.ExtensionStatus.AiAutoDescription.SUCCESS + ) + .awsAutoTagging(FileUploadResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) + .googleAutoTagging( + FileUploadResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS + ) + .removeBg(FileUploadResponse.ExtensionStatus.RemoveBg.SUCCESS) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .metadata( + Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + Metadata.Exif.builder() + .exif( + Metadata.Exif.InnerExif.builder() + .apertureValue(0.0) + .colorSpace(0L) + .createDate("CreateDate") + .customRendered(0L) + .dateTimeOriginal("DateTimeOriginal") + .exifImageHeight(0L) + .exifImageWidth(0L) + .exifVersion("ExifVersion") + .exposureCompensation(0.0) + .exposureMode(0L) + .exposureProgram(0L) + .exposureTime(0.0) + .flash(0L) + .flashpixVersion("FlashpixVersion") + .fNumber(0.0) + .focalLength(0L) + .focalPlaneResolutionUnit(0L) + .focalPlaneXResolution(0.0) + .focalPlaneYResolution(0.0) + .interopOffset(0L) + .iso(0L) + .meteringMode(0L) + .sceneCaptureType(0L) + .shutterSpeedValue(0.0) + .subSecTime("SubSecTime") + .whiteBalance(0L) + .build() + ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) + .image( + Metadata.Exif.Image.builder() + .exifOffset(0L) + .gpsInfo(0L) + .make("Make") + .model("Model") + .modifyDate("ModifyDate") + .orientation(0L) + .resolutionUnit(0L) + .software("Software") + .xResolution(0L) + .yCbCrPositioning(0L) + .yResolution(0L) + .build() + ) + .interoperability( + Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + Metadata.Exif.Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + ) + .build() + ) + .format("format") + .hasColorProfile(true) + .hasTransparency(true) + .height(0L) + .pHash("pHash") + .quality(0L) + .size(0L) + .videoCodec("videoCodec") + .width(0L) + .build() + ) + .name("name") + .size(0.0) + .addTag("string") + .thumbnailUrl("thumbnailUrl") + .url("url") + .versionInfo(FileUploadResponse.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + + val roundtrippedFileUploadResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fileUploadResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFileUploadResponse).isEqualTo(fileUploadResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FolderTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FolderTest.kt new file mode 100644 index 00000000..e4c406e6 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FolderTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FolderTest { + + @Test + fun create() { + val folder = + Folder.builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .folderId("folderId") + .folderPath("folderPath") + .name("name") + .type(Folder.Type.FOLDER) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(folder.createdAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(folder.folderId()).contains("folderId") + assertThat(folder.folderPath()).contains("folderPath") + assertThat(folder.name()).contains("name") + assertThat(folder.type()).contains(Folder.Type.FOLDER) + assertThat(folder.updatedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val folder = + Folder.builder() + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .folderId("folderId") + .folderPath("folderPath") + .name("name") + .type(Folder.Type.FOLDER) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedFolder = + jsonMapper.readValue(jsonMapper.writeValueAsString(folder), jacksonTypeRef()) + + assertThat(roundtrippedFolder).isEqualTo(folder) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/MetadataTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/MetadataTest.kt new file mode 100644 index 00000000..aacb71cb --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/MetadataTest.kt @@ -0,0 +1,289 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MetadataTest { + + @Test + fun create() { + val metadata = + Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + Metadata.Exif.builder() + .exif( + Metadata.Exif.InnerExif.builder() + .apertureValue(0.0) + .colorSpace(0L) + .createDate("CreateDate") + .customRendered(0L) + .dateTimeOriginal("DateTimeOriginal") + .exifImageHeight(0L) + .exifImageWidth(0L) + .exifVersion("ExifVersion") + .exposureCompensation(0.0) + .exposureMode(0L) + .exposureProgram(0L) + .exposureTime(0.0) + .flash(0L) + .flashpixVersion("FlashpixVersion") + .fNumber(0.0) + .focalLength(0L) + .focalPlaneResolutionUnit(0L) + .focalPlaneXResolution(0.0) + .focalPlaneYResolution(0.0) + .interopOffset(0L) + .iso(0L) + .meteringMode(0L) + .sceneCaptureType(0L) + .shutterSpeedValue(0.0) + .subSecTime("SubSecTime") + .whiteBalance(0L) + .build() + ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) + .image( + Metadata.Exif.Image.builder() + .exifOffset(0L) + .gpsInfo(0L) + .make("Make") + .model("Model") + .modifyDate("ModifyDate") + .orientation(0L) + .resolutionUnit(0L) + .software("Software") + .xResolution(0L) + .yCbCrPositioning(0L) + .yResolution(0L) + .build() + ) + .interoperability( + Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + Metadata.Exif.Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + ) + .build() + ) + .format("format") + .hasColorProfile(true) + .hasTransparency(true) + .height(0L) + .pHash("pHash") + .quality(0L) + .size(0L) + .videoCodec("videoCodec") + .width(0L) + .build() + + assertThat(metadata.audioCodec()).contains("audioCodec") + assertThat(metadata.bitRate()).contains(0L) + assertThat(metadata.density()).contains(0L) + assertThat(metadata.duration()).contains(0L) + assertThat(metadata.exif()) + .contains( + Metadata.Exif.builder() + .exif( + Metadata.Exif.InnerExif.builder() + .apertureValue(0.0) + .colorSpace(0L) + .createDate("CreateDate") + .customRendered(0L) + .dateTimeOriginal("DateTimeOriginal") + .exifImageHeight(0L) + .exifImageWidth(0L) + .exifVersion("ExifVersion") + .exposureCompensation(0.0) + .exposureMode(0L) + .exposureProgram(0L) + .exposureTime(0.0) + .flash(0L) + .flashpixVersion("FlashpixVersion") + .fNumber(0.0) + .focalLength(0L) + .focalPlaneResolutionUnit(0L) + .focalPlaneXResolution(0.0) + .focalPlaneYResolution(0.0) + .interopOffset(0L) + .iso(0L) + .meteringMode(0L) + .sceneCaptureType(0L) + .shutterSpeedValue(0.0) + .subSecTime("SubSecTime") + .whiteBalance(0L) + .build() + ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) + .image( + Metadata.Exif.Image.builder() + .exifOffset(0L) + .gpsInfo(0L) + .make("Make") + .model("Model") + .modifyDate("ModifyDate") + .orientation(0L) + .resolutionUnit(0L) + .software("Software") + .xResolution(0L) + .yCbCrPositioning(0L) + .yResolution(0L) + .build() + ) + .interoperability( + Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + Metadata.Exif.Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + ) + .build() + ) + assertThat(metadata.format()).contains("format") + assertThat(metadata.hasColorProfile()).contains(true) + assertThat(metadata.hasTransparency()).contains(true) + assertThat(metadata.height()).contains(0L) + assertThat(metadata.pHash()).contains("pHash") + assertThat(metadata.quality()).contains(0L) + assertThat(metadata.size()).contains(0L) + assertThat(metadata.videoCodec()).contains("videoCodec") + assertThat(metadata.width()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val metadata = + Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + Metadata.Exif.builder() + .exif( + Metadata.Exif.InnerExif.builder() + .apertureValue(0.0) + .colorSpace(0L) + .createDate("CreateDate") + .customRendered(0L) + .dateTimeOriginal("DateTimeOriginal") + .exifImageHeight(0L) + .exifImageWidth(0L) + .exifVersion("ExifVersion") + .exposureCompensation(0.0) + .exposureMode(0L) + .exposureProgram(0L) + .exposureTime(0.0) + .flash(0L) + .flashpixVersion("FlashpixVersion") + .fNumber(0.0) + .focalLength(0L) + .focalPlaneResolutionUnit(0L) + .focalPlaneXResolution(0.0) + .focalPlaneYResolution(0.0) + .interopOffset(0L) + .iso(0L) + .meteringMode(0L) + .sceneCaptureType(0L) + .shutterSpeedValue(0.0) + .subSecTime("SubSecTime") + .whiteBalance(0L) + .build() + ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) + .image( + Metadata.Exif.Image.builder() + .exifOffset(0L) + .gpsInfo(0L) + .make("Make") + .model("Model") + .modifyDate("ModifyDate") + .orientation(0L) + .resolutionUnit(0L) + .software("Software") + .xResolution(0L) + .yCbCrPositioning(0L) + .yResolution(0L) + .build() + ) + .interoperability( + Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + Metadata.Exif.Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + ) + .build() + ) + .format("format") + .hasColorProfile(true) + .hasTransparency(true) + .height(0L) + .pHash("pHash") + .quality(0L) + .size(0L) + .videoCodec("videoCodec") + .width(0L) + .build() + + val roundtrippedMetadata = + jsonMapper.readValue( + jsonMapper.writeValueAsString(metadata), + jacksonTypeRef(), + ) + + assertThat(roundtrippedMetadata).isEqualTo(metadata) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParamsTest.kt new file mode 100644 index 00000000..e4f87508 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.bulk + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkAddTagsParamsTest { + + @Test + fun create() { + BulkAddTagsParams.builder() + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .tags(listOf("t-shirt", "round-neck", "sale2019")) + .build() + } + + @Test + fun body() { + val params = + BulkAddTagsParams.builder() + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .tags(listOf("t-shirt", "round-neck", "sale2019")) + .build() + + val body = params._body() + + assertThat(body.fileIds()) + .containsExactly("598821f949c0a938d57563bd", "598821f949c0a938d57563be") + assertThat(body.tags()).containsExactly("t-shirt", "round-neck", "sale2019") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponseTest.kt new file mode 100644 index 00000000..78d57ab9 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponseTest.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.bulk + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkAddTagsResponseTest { + + @Test + fun create() { + val bulkAddTagsResponse = + BulkAddTagsResponse.builder().addSuccessfullyUpdatedFileId("string").build() + + assertThat(bulkAddTagsResponse.successfullyUpdatedFileIds().getOrNull()) + .containsExactly("string") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bulkAddTagsResponse = + BulkAddTagsResponse.builder().addSuccessfullyUpdatedFileId("string").build() + + val roundtrippedBulkAddTagsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bulkAddTagsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBulkAddTagsResponse).isEqualTo(bulkAddTagsResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParamsTest.kt new file mode 100644 index 00000000..c7ff4764 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParamsTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.bulk + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkDeleteParamsTest { + + @Test + fun create() { + BulkDeleteParams.builder() + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .build() + } + + @Test + fun body() { + val params = + BulkDeleteParams.builder() + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .build() + + val body = params._body() + + assertThat(body.fileIds()) + .containsExactly("598821f949c0a938d57563bd", "598821f949c0a938d57563be") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponseTest.kt new file mode 100644 index 00000000..f0b7a28f --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponseTest.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.bulk + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkDeleteResponseTest { + + @Test + fun create() { + val bulkDeleteResponse = + BulkDeleteResponse.builder().addSuccessfullyDeletedFileId("string").build() + + assertThat(bulkDeleteResponse.successfullyDeletedFileIds().getOrNull()) + .containsExactly("string") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bulkDeleteResponse = + BulkDeleteResponse.builder().addSuccessfullyDeletedFileId("string").build() + + val roundtrippedBulkDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bulkDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBulkDeleteResponse).isEqualTo(bulkDeleteResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParamsTest.kt new file mode 100644 index 00000000..21a08ec7 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.bulk + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkRemoveAiTagsParamsTest { + + @Test + fun create() { + BulkRemoveAiTagsParams.builder() + .aiTags(listOf("t-shirt", "round-neck", "sale2019")) + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .build() + } + + @Test + fun body() { + val params = + BulkRemoveAiTagsParams.builder() + .aiTags(listOf("t-shirt", "round-neck", "sale2019")) + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .build() + + val body = params._body() + + assertThat(body.aiTags()).containsExactly("t-shirt", "round-neck", "sale2019") + assertThat(body.fileIds()) + .containsExactly("598821f949c0a938d57563bd", "598821f949c0a938d57563be") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponseTest.kt new file mode 100644 index 00000000..f4831008 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponseTest.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.bulk + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkRemoveAiTagsResponseTest { + + @Test + fun create() { + val bulkRemoveAiTagsResponse = + BulkRemoveAiTagsResponse.builder().addSuccessfullyUpdatedFileId("string").build() + + assertThat(bulkRemoveAiTagsResponse.successfullyUpdatedFileIds().getOrNull()) + .containsExactly("string") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bulkRemoveAiTagsResponse = + BulkRemoveAiTagsResponse.builder().addSuccessfullyUpdatedFileId("string").build() + + val roundtrippedBulkRemoveAiTagsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bulkRemoveAiTagsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBulkRemoveAiTagsResponse).isEqualTo(bulkRemoveAiTagsResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParamsTest.kt new file mode 100644 index 00000000..0f1de44e --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.bulk + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkRemoveTagsParamsTest { + + @Test + fun create() { + BulkRemoveTagsParams.builder() + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .tags(listOf("t-shirt", "round-neck", "sale2019")) + .build() + } + + @Test + fun body() { + val params = + BulkRemoveTagsParams.builder() + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .tags(listOf("t-shirt", "round-neck", "sale2019")) + .build() + + val body = params._body() + + assertThat(body.fileIds()) + .containsExactly("598821f949c0a938d57563bd", "598821f949c0a938d57563be") + assertThat(body.tags()).containsExactly("t-shirt", "round-neck", "sale2019") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponseTest.kt new file mode 100644 index 00000000..ce354384 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponseTest.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.bulk + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkRemoveTagsResponseTest { + + @Test + fun create() { + val bulkRemoveTagsResponse = + BulkRemoveTagsResponse.builder().addSuccessfullyUpdatedFileId("string").build() + + assertThat(bulkRemoveTagsResponse.successfullyUpdatedFileIds().getOrNull()) + .containsExactly("string") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bulkRemoveTagsResponse = + BulkRemoveTagsResponse.builder().addSuccessfullyUpdatedFileId("string").build() + + val roundtrippedBulkRemoveTagsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bulkRemoveTagsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBulkRemoveTagsResponse).isEqualTo(bulkRemoveTagsResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlParamsTest.kt new file mode 100644 index 00000000..2d4617b6 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlParamsTest.kt @@ -0,0 +1,25 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.metadata + +import com.imagekit.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MetadataGetFromUrlParamsTest { + + @Test + fun create() { + MetadataGetFromUrlParams.builder().url("https://example.com").build() + } + + @Test + fun queryParams() { + val params = MetadataGetFromUrlParams.builder().url("https://example.com").build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("url", "https://example.com").build()) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetParamsTest.kt new file mode 100644 index 00000000..566257d5 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.metadata + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MetadataGetParamsTest { + + @Test + fun create() { + MetadataGetParams.builder().fileId("fileId").build() + } + + @Test + fun pathParams() { + val params = MetadataGetParams.builder().fileId("fileId").build() + + assertThat(params._pathParam(0)).isEqualTo("fileId") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionDeleteParamsTest.kt new file mode 100644 index 00000000..67e06b93 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.versions + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VersionDeleteParamsTest { + + @Test + fun create() { + VersionDeleteParams.builder().fileId("fileId").versionId("versionId").build() + } + + @Test + fun pathParams() { + val params = VersionDeleteParams.builder().fileId("fileId").versionId("versionId").build() + + assertThat(params._pathParam(0)).isEqualTo("fileId") + assertThat(params._pathParam(1)).isEqualTo("versionId") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionDeleteResponseTest.kt new file mode 100644 index 00000000..c6c6c196 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.versions + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VersionDeleteResponseTest { + + @Test + fun create() { + val versionDeleteResponse = VersionDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val versionDeleteResponse = VersionDeleteResponse.builder().build() + + val roundtrippedVersionDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(versionDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVersionDeleteResponse).isEqualTo(versionDeleteResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetParamsTest.kt new file mode 100644 index 00000000..223c3985 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.versions + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VersionGetParamsTest { + + @Test + fun create() { + VersionGetParams.builder().fileId("fileId").versionId("versionId").build() + } + + @Test + fun pathParams() { + val params = VersionGetParams.builder().fileId("fileId").versionId("versionId").build() + + assertThat(params._pathParam(0)).isEqualTo("fileId") + assertThat(params._pathParam(1)).isEqualTo("versionId") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListParamsTest.kt new file mode 100644 index 00000000..76dcfa05 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.versions + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VersionListParamsTest { + + @Test + fun create() { + VersionListParams.builder().fileId("fileId").build() + } + + @Test + fun pathParams() { + val params = VersionListParams.builder().fileId("fileId").build() + + assertThat(params._pathParam(0)).isEqualTo("fileId") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRestoreParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRestoreParamsTest.kt new file mode 100644 index 00000000..cb877ca2 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRestoreParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files.versions + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VersionRestoreParamsTest { + + @Test + fun create() { + VersionRestoreParams.builder().fileId("fileId").versionId("versionId").build() + } + + @Test + fun pathParams() { + val params = VersionRestoreParams.builder().fileId("fileId").versionId("versionId").build() + + assertThat(params._pathParam(0)).isEqualTo("fileId") + assertThat(params._pathParam(1)).isEqualTo("versionId") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCopyParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCopyParamsTest.kt new file mode 100644 index 00000000..2592d7ab --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCopyParamsTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FolderCopyParamsTest { + + @Test + fun create() { + FolderCopyParams.builder() + .destinationPath("/path/of/destination/folder") + .sourceFolderPath("/path/of/source/folder") + .includeVersions(true) + .build() + } + + @Test + fun body() { + val params = + FolderCopyParams.builder() + .destinationPath("/path/of/destination/folder") + .sourceFolderPath("/path/of/source/folder") + .includeVersions(true) + .build() + + val body = params._body() + + assertThat(body.destinationPath()).isEqualTo("/path/of/destination/folder") + assertThat(body.sourceFolderPath()).isEqualTo("/path/of/source/folder") + assertThat(body.includeVersions()).contains(true) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + FolderCopyParams.builder() + .destinationPath("/path/of/destination/folder") + .sourceFolderPath("/path/of/source/folder") + .build() + + val body = params._body() + + assertThat(body.destinationPath()).isEqualTo("/path/of/destination/folder") + assertThat(body.sourceFolderPath()).isEqualTo("/path/of/source/folder") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCopyResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCopyResponseTest.kt new file mode 100644 index 00000000..43edd665 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCopyResponseTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FolderCopyResponseTest { + + @Test + fun create() { + val folderCopyResponse = FolderCopyResponse.builder().jobId("jobId").build() + + assertThat(folderCopyResponse.jobId()).isEqualTo("jobId") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val folderCopyResponse = FolderCopyResponse.builder().jobId("jobId").build() + + val roundtrippedFolderCopyResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(folderCopyResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFolderCopyResponse).isEqualTo(folderCopyResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCreateParamsTest.kt new file mode 100644 index 00000000..7f8ba557 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCreateParamsTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FolderCreateParamsTest { + + @Test + fun create() { + FolderCreateParams.builder() + .folderName("summer") + .parentFolderPath("/product/images/") + .build() + } + + @Test + fun body() { + val params = + FolderCreateParams.builder() + .folderName("summer") + .parentFolderPath("/product/images/") + .build() + + val body = params._body() + + assertThat(body.folderName()).isEqualTo("summer") + assertThat(body.parentFolderPath()).isEqualTo("/product/images/") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCreateResponseTest.kt new file mode 100644 index 00000000..de873d35 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCreateResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FolderCreateResponseTest { + + @Test + fun create() { + val folderCreateResponse = FolderCreateResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val folderCreateResponse = FolderCreateResponse.builder().build() + + val roundtrippedFolderCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(folderCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFolderCreateResponse).isEqualTo(folderCreateResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderDeleteParamsTest.kt new file mode 100644 index 00000000..7a1a4fca --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderDeleteParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FolderDeleteParamsTest { + + @Test + fun create() { + FolderDeleteParams.builder().folderPath("/folder/to/delete/").build() + } + + @Test + fun body() { + val params = FolderDeleteParams.builder().folderPath("/folder/to/delete/").build() + + val body = params._body() + + assertThat(body.folderPath()).isEqualTo("/folder/to/delete/") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderDeleteResponseTest.kt new file mode 100644 index 00000000..332055e2 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FolderDeleteResponseTest { + + @Test + fun create() { + val folderDeleteResponse = FolderDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val folderDeleteResponse = FolderDeleteResponse.builder().build() + + val roundtrippedFolderDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(folderDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFolderDeleteResponse).isEqualTo(folderDeleteResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderMoveParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderMoveParamsTest.kt new file mode 100644 index 00000000..7df75c01 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderMoveParamsTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FolderMoveParamsTest { + + @Test + fun create() { + FolderMoveParams.builder() + .destinationPath("/path/of/destination/folder") + .sourceFolderPath("/path/of/source/folder") + .build() + } + + @Test + fun body() { + val params = + FolderMoveParams.builder() + .destinationPath("/path/of/destination/folder") + .sourceFolderPath("/path/of/source/folder") + .build() + + val body = params._body() + + assertThat(body.destinationPath()).isEqualTo("/path/of/destination/folder") + assertThat(body.sourceFolderPath()).isEqualTo("/path/of/source/folder") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderMoveResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderMoveResponseTest.kt new file mode 100644 index 00000000..c0bbe474 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderMoveResponseTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FolderMoveResponseTest { + + @Test + fun create() { + val folderMoveResponse = FolderMoveResponse.builder().jobId("jobId").build() + + assertThat(folderMoveResponse.jobId()).isEqualTo("jobId") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val folderMoveResponse = FolderMoveResponse.builder().jobId("jobId").build() + + val roundtrippedFolderMoveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(folderMoveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFolderMoveResponse).isEqualTo(folderMoveResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderRenameParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderRenameParamsTest.kt new file mode 100644 index 00000000..46e46772 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderRenameParamsTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FolderRenameParamsTest { + + @Test + fun create() { + FolderRenameParams.builder() + .folderPath("/path/of/folder") + .newFolderName("new-folder-name") + .purgeCache(true) + .build() + } + + @Test + fun body() { + val params = + FolderRenameParams.builder() + .folderPath("/path/of/folder") + .newFolderName("new-folder-name") + .purgeCache(true) + .build() + + val body = params._body() + + assertThat(body.folderPath()).isEqualTo("/path/of/folder") + assertThat(body.newFolderName()).isEqualTo("new-folder-name") + assertThat(body.purgeCache()).contains(true) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + FolderRenameParams.builder() + .folderPath("/path/of/folder") + .newFolderName("new-folder-name") + .build() + + val body = params._body() + + assertThat(body.folderPath()).isEqualTo("/path/of/folder") + assertThat(body.newFolderName()).isEqualTo("new-folder-name") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderRenameResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderRenameResponseTest.kt new file mode 100644 index 00000000..73535f74 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderRenameResponseTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FolderRenameResponseTest { + + @Test + fun create() { + val folderRenameResponse = FolderRenameResponse.builder().jobId("jobId").build() + + assertThat(folderRenameResponse.jobId()).isEqualTo("jobId") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val folderRenameResponse = FolderRenameResponse.builder().jobId("jobId").build() + + val roundtrippedFolderRenameResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(folderRenameResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFolderRenameResponse).isEqualTo(folderRenameResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/job/JobGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/job/JobGetParamsTest.kt new file mode 100644 index 00000000..0128480f --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/job/JobGetParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders.job + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class JobGetParamsTest { + + @Test + fun create() { + JobGetParams.builder().jobId("jobId").build() + } + + @Test + fun pathParams() { + val params = JobGetParams.builder().jobId("jobId").build() + + assertThat(params._pathParam(0)).isEqualTo("jobId") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/job/JobGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/job/JobGetResponseTest.kt new file mode 100644 index 00000000..502bf546 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/job/JobGetResponseTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.folders.job + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class JobGetResponseTest { + + @Test + fun create() { + val jobGetResponse = + JobGetResponse.builder() + .jobId("5d5b1a9b4c8c4c0001f3e4a2") + .purgeRequestId("purgeRequestId") + .status(JobGetResponse.Status.COMPLETED) + .type(JobGetResponse.Type.COPY_FOLDER) + .build() + + assertThat(jobGetResponse.jobId()).contains("5d5b1a9b4c8c4c0001f3e4a2") + assertThat(jobGetResponse.purgeRequestId()).contains("purgeRequestId") + assertThat(jobGetResponse.status()).contains(JobGetResponse.Status.COMPLETED) + assertThat(jobGetResponse.type()).contains(JobGetResponse.Type.COPY_FOLDER) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val jobGetResponse = + JobGetResponse.builder() + .jobId("5d5b1a9b4c8c4c0001f3e4a2") + .purgeRequestId("purgeRequestId") + .status(JobGetResponse.Status.COMPLETED) + .type(JobGetResponse.Type.COPY_FOLDER) + .build() + + val roundtrippedJobGetResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(jobGetResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedJobGetResponse).isEqualTo(jobGetResponse) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt new file mode 100644 index 00000000..010070a5 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt @@ -0,0 +1,1225 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.files.Metadata +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class UnsafeUnwrapWebhookEventTest { + + @Test + fun ofVideoTransformationAccepted() { + val videoTransformationAccepted = + VideoTransformationAcceptedEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationAcceptedEvent.Data.builder() + .asset( + VideoTransformationAcceptedEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationAcceptedEvent.Data.Transformation.builder() + .type( + VideoTransformationAcceptedEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationAcceptedEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationAcceptedEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .build() + + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofVideoTransformationAccepted(videoTransformationAccepted) + + assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()) + .contains(videoTransformationAccepted) + assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty + } + + @Test + fun ofVideoTransformationAcceptedRoundtrip() { + val jsonMapper = jsonMapper() + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofVideoTransformationAccepted( + VideoTransformationAcceptedEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationAcceptedEvent.Data.builder() + .asset( + VideoTransformationAcceptedEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationAcceptedEvent.Data.Transformation.builder() + .type( + VideoTransformationAcceptedEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationAcceptedEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationAcceptedEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .build() + ) + + val roundtrippedUnsafeUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unsafeUnwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnsafeUnwrapWebhookEvent).isEqualTo(unsafeUnwrapWebhookEvent) + } + + @Test + fun ofVideoTransformationReady() { + val videoTransformationReady = + VideoTransformationReadyEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationReadyEvent.Data.builder() + .asset( + VideoTransformationReadyEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationReadyEvent.Data.Transformation.builder() + .type( + VideoTransformationReadyEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationReadyEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationReadyEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationReadyEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationReadyEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationReadyEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .output( + VideoTransformationReadyEvent.Data.Transformation.Output + .builder() + .url("https://example.com") + .videoMetadata( + VideoTransformationReadyEvent.Data.Transformation.Output + .VideoMetadata + .builder() + .bitrate(0L) + .duration(0.0) + .height(0L) + .width(0L) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationReadyEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .timings( + VideoTransformationReadyEvent.Timings.builder() + .downloadDuration(0L) + .encodingDuration(0L) + .build() + ) + .build() + + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofVideoTransformationReady(videoTransformationReady) + + assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()) + .contains(videoTransformationReady) + assertThat(unsafeUnwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty + } + + @Test + fun ofVideoTransformationReadyRoundtrip() { + val jsonMapper = jsonMapper() + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofVideoTransformationReady( + VideoTransformationReadyEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationReadyEvent.Data.builder() + .asset( + VideoTransformationReadyEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationReadyEvent.Data.Transformation.builder() + .type( + VideoTransformationReadyEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationReadyEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationReadyEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationReadyEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationReadyEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationReadyEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .output( + VideoTransformationReadyEvent.Data.Transformation.Output + .builder() + .url("https://example.com") + .videoMetadata( + VideoTransformationReadyEvent.Data.Transformation + .Output + .VideoMetadata + .builder() + .bitrate(0L) + .duration(0.0) + .height(0L) + .width(0L) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationReadyEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .timings( + VideoTransformationReadyEvent.Timings.builder() + .downloadDuration(0L) + .encodingDuration(0L) + .build() + ) + .build() + ) + + val roundtrippedUnsafeUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unsafeUnwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnsafeUnwrapWebhookEvent).isEqualTo(unsafeUnwrapWebhookEvent) + } + + @Test + fun ofVideoTransformationError() { + val videoTransformationError = + VideoTransformationErrorEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationErrorEvent.Data.builder() + .asset( + VideoTransformationErrorEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationErrorEvent.Data.Transformation.builder() + .type( + VideoTransformationErrorEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .error( + VideoTransformationErrorEvent.Data.Transformation.Error + .builder() + .reason( + VideoTransformationErrorEvent.Data.Transformation.Error + .Reason + .ENCODING_FAILED + ) + .build() + ) + .options( + VideoTransformationErrorEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationErrorEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationErrorEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationErrorEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationErrorEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationErrorEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .build() + + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofVideoTransformationError(videoTransformationError) + + assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationError()) + .contains(videoTransformationError) + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty + } + + @Test + fun ofVideoTransformationErrorRoundtrip() { + val jsonMapper = jsonMapper() + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofVideoTransformationError( + VideoTransformationErrorEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationErrorEvent.Data.builder() + .asset( + VideoTransformationErrorEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationErrorEvent.Data.Transformation.builder() + .type( + VideoTransformationErrorEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .error( + VideoTransformationErrorEvent.Data.Transformation.Error + .builder() + .reason( + VideoTransformationErrorEvent.Data.Transformation + .Error + .Reason + .ENCODING_FAILED + ) + .build() + ) + .options( + VideoTransformationErrorEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationErrorEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationErrorEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationErrorEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationErrorEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationErrorEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .build() + ) + + val roundtrippedUnsafeUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unsafeUnwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnsafeUnwrapWebhookEvent).isEqualTo(unsafeUnwrapWebhookEvent) + } + + @Test + fun ofUploadPreTransformSuccess() { + val uploadPreTransformSuccess = + UploadPreTransformSuccessEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformSuccessEvent.Data.builder() + .addAiTag( + UploadPreTransformSuccessEvent.Data.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata( + UploadPreTransformSuccessEvent.Data.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + UploadPreTransformSuccessEvent.Data.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.builder() + .aiAutoDescription( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .AiAutoDescription + .SUCCESS + ) + .awsAutoTagging( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .AwsAutoTagging + .SUCCESS + ) + .googleAutoTagging( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .GoogleAutoTagging + .SUCCESS + ) + .removeBg( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.RemoveBg + .SUCCESS + ) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .metadata( + Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + Metadata.Exif.builder() + .exif( + Metadata.Exif.InnerExif.builder() + .apertureValue(0.0) + .colorSpace(0L) + .createDate("CreateDate") + .customRendered(0L) + .dateTimeOriginal("DateTimeOriginal") + .exifImageHeight(0L) + .exifImageWidth(0L) + .exifVersion("ExifVersion") + .exposureCompensation(0.0) + .exposureMode(0L) + .exposureProgram(0L) + .exposureTime(0.0) + .flash(0L) + .flashpixVersion("FlashpixVersion") + .fNumber(0.0) + .focalLength(0L) + .focalPlaneResolutionUnit(0L) + .focalPlaneXResolution(0.0) + .focalPlaneYResolution(0.0) + .interopOffset(0L) + .iso(0L) + .meteringMode(0L) + .sceneCaptureType(0L) + .shutterSpeedValue(0.0) + .subSecTime("SubSecTime") + .whiteBalance(0L) + .build() + ) + .gps( + Metadata.Exif.Gps.builder().addGpsVersionId(0L).build() + ) + .image( + Metadata.Exif.Image.builder() + .exifOffset(0L) + .gpsInfo(0L) + .make("Make") + .model("Model") + .modifyDate("ModifyDate") + .orientation(0L) + .resolutionUnit(0L) + .software("Software") + .xResolution(0L) + .yCbCrPositioning(0L) + .yResolution(0L) + .build() + ) + .interoperability( + Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + Metadata.Exif.Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + ) + .build() + ) + .format("format") + .hasColorProfile(true) + .hasTransparency(true) + .height(0L) + .pHash("pHash") + .quality(0L) + .size(0L) + .videoCodec("videoCodec") + .width(0L) + .build() + ) + .name("name") + .size(0.0) + .addTag("string") + .thumbnailUrl("thumbnailUrl") + .url("url") + .versionInfo( + UploadPreTransformSuccessEvent.Data.VersionInfo.builder() + .id("id") + .name("name") + .build() + ) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .request( + UploadPreTransformSuccessEvent.Request.builder() + .transformation("transformation") + .xRequestId("x_request_id") + .build() + ) + .build() + + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofUploadPreTransformSuccess(uploadPreTransformSuccess) + + assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformSuccess()) + .contains(uploadPreTransformSuccess) + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty + } + + @Test + fun ofUploadPreTransformSuccessRoundtrip() { + val jsonMapper = jsonMapper() + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofUploadPreTransformSuccess( + UploadPreTransformSuccessEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformSuccessEvent.Data.builder() + .addAiTag( + UploadPreTransformSuccessEvent.Data.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata( + UploadPreTransformSuccessEvent.Data.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + UploadPreTransformSuccessEvent.Data.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.builder() + .aiAutoDescription( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .AiAutoDescription + .SUCCESS + ) + .awsAutoTagging( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .AwsAutoTagging + .SUCCESS + ) + .googleAutoTagging( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .GoogleAutoTagging + .SUCCESS + ) + .removeBg( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.RemoveBg + .SUCCESS + ) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .metadata( + Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + Metadata.Exif.builder() + .exif( + Metadata.Exif.InnerExif.builder() + .apertureValue(0.0) + .colorSpace(0L) + .createDate("CreateDate") + .customRendered(0L) + .dateTimeOriginal("DateTimeOriginal") + .exifImageHeight(0L) + .exifImageWidth(0L) + .exifVersion("ExifVersion") + .exposureCompensation(0.0) + .exposureMode(0L) + .exposureProgram(0L) + .exposureTime(0.0) + .flash(0L) + .flashpixVersion("FlashpixVersion") + .fNumber(0.0) + .focalLength(0L) + .focalPlaneResolutionUnit(0L) + .focalPlaneXResolution(0.0) + .focalPlaneYResolution(0.0) + .interopOffset(0L) + .iso(0L) + .meteringMode(0L) + .sceneCaptureType(0L) + .shutterSpeedValue(0.0) + .subSecTime("SubSecTime") + .whiteBalance(0L) + .build() + ) + .gps( + Metadata.Exif.Gps.builder() + .addGpsVersionId(0L) + .build() + ) + .image( + Metadata.Exif.Image.builder() + .exifOffset(0L) + .gpsInfo(0L) + .make("Make") + .model("Model") + .modifyDate("ModifyDate") + .orientation(0L) + .resolutionUnit(0L) + .software("Software") + .xResolution(0L) + .yCbCrPositioning(0L) + .yResolution(0L) + .build() + ) + .interoperability( + Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + Metadata.Exif.Makernote.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .thumbnail( + Metadata.Exif.Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + ) + .build() + ) + .format("format") + .hasColorProfile(true) + .hasTransparency(true) + .height(0L) + .pHash("pHash") + .quality(0L) + .size(0L) + .videoCodec("videoCodec") + .width(0L) + .build() + ) + .name("name") + .size(0.0) + .addTag("string") + .thumbnailUrl("thumbnailUrl") + .url("url") + .versionInfo( + UploadPreTransformSuccessEvent.Data.VersionInfo.builder() + .id("id") + .name("name") + .build() + ) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .request( + UploadPreTransformSuccessEvent.Request.builder() + .transformation("transformation") + .xRequestId("x_request_id") + .build() + ) + .build() + ) + + val roundtrippedUnsafeUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unsafeUnwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnsafeUnwrapWebhookEvent).isEqualTo(unsafeUnwrapWebhookEvent) + } + + @Test + fun ofUploadPreTransformError() { + val uploadPreTransformError = + UploadPreTransformErrorEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformErrorEvent.Data.builder() + .name("name") + .path("path") + .transformation( + UploadPreTransformErrorEvent.Data.Transformation.builder() + .error( + UploadPreTransformErrorEvent.Data.Transformation.Error.builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .build() + ) + .request( + UploadPreTransformErrorEvent.Request.builder() + .transformation("transformation") + .xRequestId("x_request_id") + .build() + ) + .build() + + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofUploadPreTransformError(uploadPreTransformError) + + assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()) + .contains(uploadPreTransformError) + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty + } + + @Test + fun ofUploadPreTransformErrorRoundtrip() { + val jsonMapper = jsonMapper() + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofUploadPreTransformError( + UploadPreTransformErrorEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformErrorEvent.Data.builder() + .name("name") + .path("path") + .transformation( + UploadPreTransformErrorEvent.Data.Transformation.builder() + .error( + UploadPreTransformErrorEvent.Data.Transformation.Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .build() + ) + .request( + UploadPreTransformErrorEvent.Request.builder() + .transformation("transformation") + .xRequestId("x_request_id") + .build() + ) + .build() + ) + + val roundtrippedUnsafeUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unsafeUnwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnsafeUnwrapWebhookEvent).isEqualTo(unsafeUnwrapWebhookEvent) + } + + @Test + fun ofUploadPostTransformSuccess() { + val uploadPostTransformSuccess = + UploadPostTransformSuccessEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformSuccessEvent.Data.builder() + .fileId("fileId") + .name("name") + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformSuccessEvent.Request.builder() + .transformation( + UploadPostTransformSuccessEvent.Request.Transformation.builder() + .type( + UploadPostTransformSuccessEvent.Request.Transformation.Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformSuccessEvent.Request.Transformation.Protocol + .HLS + ) + .value("value") + .build() + ) + .xRequestId("x_request_id") + .build() + ) + .build() + + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofUploadPostTransformSuccess(uploadPostTransformSuccess) + + assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()) + .contains(uploadPostTransformSuccess) + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty + } + + @Test + fun ofUploadPostTransformSuccessRoundtrip() { + val jsonMapper = jsonMapper() + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofUploadPostTransformSuccess( + UploadPostTransformSuccessEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformSuccessEvent.Data.builder() + .fileId("fileId") + .name("name") + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformSuccessEvent.Request.builder() + .transformation( + UploadPostTransformSuccessEvent.Request.Transformation.builder() + .type( + UploadPostTransformSuccessEvent.Request.Transformation.Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformSuccessEvent.Request.Transformation + .Protocol + .HLS + ) + .value("value") + .build() + ) + .xRequestId("x_request_id") + .build() + ) + .build() + ) + + val roundtrippedUnsafeUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unsafeUnwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnsafeUnwrapWebhookEvent).isEqualTo(unsafeUnwrapWebhookEvent) + } + + @Test + fun ofUploadPostTransformError() { + val uploadPostTransformError = + UploadPostTransformErrorEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformErrorEvent.Data.builder() + .fileId("fileId") + .name("name") + .path("path") + .transformation( + UploadPostTransformErrorEvent.Data.Transformation.builder() + .error( + UploadPostTransformErrorEvent.Data.Transformation.Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformErrorEvent.Request.builder() + .transformation( + UploadPostTransformErrorEvent.Request.Transformation.builder() + .type( + UploadPostTransformErrorEvent.Request.Transformation.Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformErrorEvent.Request.Transformation.Protocol + .HLS + ) + .value("value") + .build() + ) + .xRequestId("x_request_id") + .build() + ) + .build() + + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofUploadPostTransformError(uploadPostTransformError) + + assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()) + .contains(uploadPostTransformError) + } + + @Test + fun ofUploadPostTransformErrorRoundtrip() { + val jsonMapper = jsonMapper() + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofUploadPostTransformError( + UploadPostTransformErrorEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformErrorEvent.Data.builder() + .fileId("fileId") + .name("name") + .path("path") + .transformation( + UploadPostTransformErrorEvent.Data.Transformation.builder() + .error( + UploadPostTransformErrorEvent.Data.Transformation.Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformErrorEvent.Request.builder() + .transformation( + UploadPostTransformErrorEvent.Request.Transformation.builder() + .type( + UploadPostTransformErrorEvent.Request.Transformation.Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformErrorEvent.Request.Transformation + .Protocol + .HLS + ) + .value("value") + .build() + ) + .xRequestId("x_request_id") + .build() + ) + .build() + ) + + val roundtrippedUnsafeUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unsafeUnwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnsafeUnwrapWebhookEvent).isEqualTo(unsafeUnwrapWebhookEvent) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val unsafeUnwrapWebhookEvent = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { unsafeUnwrapWebhookEvent.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt new file mode 100644 index 00000000..f35cbec4 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt @@ -0,0 +1,1221 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.files.Metadata +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class UnwrapWebhookEventTest { + + @Test + fun ofVideoTransformationAccepted() { + val videoTransformationAccepted = + VideoTransformationAcceptedEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationAcceptedEvent.Data.builder() + .asset( + VideoTransformationAcceptedEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationAcceptedEvent.Data.Transformation.builder() + .type( + VideoTransformationAcceptedEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationAcceptedEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationAcceptedEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .build() + + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofVideoTransformationAccepted(videoTransformationAccepted) + + assertThat(unwrapWebhookEvent.videoTransformationAccepted()) + .contains(videoTransformationAccepted) + assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty + } + + @Test + fun ofVideoTransformationAcceptedRoundtrip() { + val jsonMapper = jsonMapper() + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofVideoTransformationAccepted( + VideoTransformationAcceptedEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationAcceptedEvent.Data.builder() + .asset( + VideoTransformationAcceptedEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationAcceptedEvent.Data.Transformation.builder() + .type( + VideoTransformationAcceptedEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationAcceptedEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationAcceptedEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .build() + ) + + val roundtrippedUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnwrapWebhookEvent).isEqualTo(unwrapWebhookEvent) + } + + @Test + fun ofVideoTransformationReady() { + val videoTransformationReady = + VideoTransformationReadyEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationReadyEvent.Data.builder() + .asset( + VideoTransformationReadyEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationReadyEvent.Data.Transformation.builder() + .type( + VideoTransformationReadyEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationReadyEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationReadyEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationReadyEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationReadyEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationReadyEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .output( + VideoTransformationReadyEvent.Data.Transformation.Output + .builder() + .url("https://example.com") + .videoMetadata( + VideoTransformationReadyEvent.Data.Transformation.Output + .VideoMetadata + .builder() + .bitrate(0L) + .duration(0.0) + .height(0L) + .width(0L) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationReadyEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .timings( + VideoTransformationReadyEvent.Timings.builder() + .downloadDuration(0L) + .encodingDuration(0L) + .build() + ) + .build() + + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofVideoTransformationReady(videoTransformationReady) + + assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationReady()).contains(videoTransformationReady) + assertThat(unwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty + } + + @Test + fun ofVideoTransformationReadyRoundtrip() { + val jsonMapper = jsonMapper() + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofVideoTransformationReady( + VideoTransformationReadyEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationReadyEvent.Data.builder() + .asset( + VideoTransformationReadyEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationReadyEvent.Data.Transformation.builder() + .type( + VideoTransformationReadyEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationReadyEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationReadyEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationReadyEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationReadyEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationReadyEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .output( + VideoTransformationReadyEvent.Data.Transformation.Output + .builder() + .url("https://example.com") + .videoMetadata( + VideoTransformationReadyEvent.Data.Transformation + .Output + .VideoMetadata + .builder() + .bitrate(0L) + .duration(0.0) + .height(0L) + .width(0L) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationReadyEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .timings( + VideoTransformationReadyEvent.Timings.builder() + .downloadDuration(0L) + .encodingDuration(0L) + .build() + ) + .build() + ) + + val roundtrippedUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnwrapWebhookEvent).isEqualTo(unwrapWebhookEvent) + } + + @Test + fun ofVideoTransformationError() { + val videoTransformationError = + VideoTransformationErrorEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationErrorEvent.Data.builder() + .asset( + VideoTransformationErrorEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationErrorEvent.Data.Transformation.builder() + .type( + VideoTransformationErrorEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .error( + VideoTransformationErrorEvent.Data.Transformation.Error + .builder() + .reason( + VideoTransformationErrorEvent.Data.Transformation.Error + .Reason + .ENCODING_FAILED + ) + .build() + ) + .options( + VideoTransformationErrorEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationErrorEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationErrorEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationErrorEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationErrorEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationErrorEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .build() + + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofVideoTransformationError(videoTransformationError) + + assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationError()).contains(videoTransformationError) + assertThat(unwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty + } + + @Test + fun ofVideoTransformationErrorRoundtrip() { + val jsonMapper = jsonMapper() + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofVideoTransformationError( + VideoTransformationErrorEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationErrorEvent.Data.builder() + .asset( + VideoTransformationErrorEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationErrorEvent.Data.Transformation.builder() + .type( + VideoTransformationErrorEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .error( + VideoTransformationErrorEvent.Data.Transformation.Error + .builder() + .reason( + VideoTransformationErrorEvent.Data.Transformation + .Error + .Reason + .ENCODING_FAILED + ) + .build() + ) + .options( + VideoTransformationErrorEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationErrorEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationErrorEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationErrorEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationErrorEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationErrorEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .build() + ) + + val roundtrippedUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnwrapWebhookEvent).isEqualTo(unwrapWebhookEvent) + } + + @Test + fun ofUploadPreTransformSuccess() { + val uploadPreTransformSuccess = + UploadPreTransformSuccessEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformSuccessEvent.Data.builder() + .addAiTag( + UploadPreTransformSuccessEvent.Data.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata( + UploadPreTransformSuccessEvent.Data.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + UploadPreTransformSuccessEvent.Data.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.builder() + .aiAutoDescription( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .AiAutoDescription + .SUCCESS + ) + .awsAutoTagging( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .AwsAutoTagging + .SUCCESS + ) + .googleAutoTagging( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .GoogleAutoTagging + .SUCCESS + ) + .removeBg( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.RemoveBg + .SUCCESS + ) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .metadata( + Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + Metadata.Exif.builder() + .exif( + Metadata.Exif.InnerExif.builder() + .apertureValue(0.0) + .colorSpace(0L) + .createDate("CreateDate") + .customRendered(0L) + .dateTimeOriginal("DateTimeOriginal") + .exifImageHeight(0L) + .exifImageWidth(0L) + .exifVersion("ExifVersion") + .exposureCompensation(0.0) + .exposureMode(0L) + .exposureProgram(0L) + .exposureTime(0.0) + .flash(0L) + .flashpixVersion("FlashpixVersion") + .fNumber(0.0) + .focalLength(0L) + .focalPlaneResolutionUnit(0L) + .focalPlaneXResolution(0.0) + .focalPlaneYResolution(0.0) + .interopOffset(0L) + .iso(0L) + .meteringMode(0L) + .sceneCaptureType(0L) + .shutterSpeedValue(0.0) + .subSecTime("SubSecTime") + .whiteBalance(0L) + .build() + ) + .gps( + Metadata.Exif.Gps.builder().addGpsVersionId(0L).build() + ) + .image( + Metadata.Exif.Image.builder() + .exifOffset(0L) + .gpsInfo(0L) + .make("Make") + .model("Model") + .modifyDate("ModifyDate") + .orientation(0L) + .resolutionUnit(0L) + .software("Software") + .xResolution(0L) + .yCbCrPositioning(0L) + .yResolution(0L) + .build() + ) + .interoperability( + Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + Metadata.Exif.Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + ) + .build() + ) + .format("format") + .hasColorProfile(true) + .hasTransparency(true) + .height(0L) + .pHash("pHash") + .quality(0L) + .size(0L) + .videoCodec("videoCodec") + .width(0L) + .build() + ) + .name("name") + .size(0.0) + .addTag("string") + .thumbnailUrl("thumbnailUrl") + .url("url") + .versionInfo( + UploadPreTransformSuccessEvent.Data.VersionInfo.builder() + .id("id") + .name("name") + .build() + ) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .request( + UploadPreTransformSuccessEvent.Request.builder() + .transformation("transformation") + .xRequestId("x_request_id") + .build() + ) + .build() + + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofUploadPreTransformSuccess(uploadPreTransformSuccess) + + assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformSuccess()) + .contains(uploadPreTransformSuccess) + assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty + } + + @Test + fun ofUploadPreTransformSuccessRoundtrip() { + val jsonMapper = jsonMapper() + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofUploadPreTransformSuccess( + UploadPreTransformSuccessEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformSuccessEvent.Data.builder() + .addAiTag( + UploadPreTransformSuccessEvent.Data.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata( + UploadPreTransformSuccessEvent.Data.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + UploadPreTransformSuccessEvent.Data.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.builder() + .aiAutoDescription( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .AiAutoDescription + .SUCCESS + ) + .awsAutoTagging( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .AwsAutoTagging + .SUCCESS + ) + .googleAutoTagging( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .GoogleAutoTagging + .SUCCESS + ) + .removeBg( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.RemoveBg + .SUCCESS + ) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .metadata( + Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + Metadata.Exif.builder() + .exif( + Metadata.Exif.InnerExif.builder() + .apertureValue(0.0) + .colorSpace(0L) + .createDate("CreateDate") + .customRendered(0L) + .dateTimeOriginal("DateTimeOriginal") + .exifImageHeight(0L) + .exifImageWidth(0L) + .exifVersion("ExifVersion") + .exposureCompensation(0.0) + .exposureMode(0L) + .exposureProgram(0L) + .exposureTime(0.0) + .flash(0L) + .flashpixVersion("FlashpixVersion") + .fNumber(0.0) + .focalLength(0L) + .focalPlaneResolutionUnit(0L) + .focalPlaneXResolution(0.0) + .focalPlaneYResolution(0.0) + .interopOffset(0L) + .iso(0L) + .meteringMode(0L) + .sceneCaptureType(0L) + .shutterSpeedValue(0.0) + .subSecTime("SubSecTime") + .whiteBalance(0L) + .build() + ) + .gps( + Metadata.Exif.Gps.builder() + .addGpsVersionId(0L) + .build() + ) + .image( + Metadata.Exif.Image.builder() + .exifOffset(0L) + .gpsInfo(0L) + .make("Make") + .model("Model") + .modifyDate("ModifyDate") + .orientation(0L) + .resolutionUnit(0L) + .software("Software") + .xResolution(0L) + .yCbCrPositioning(0L) + .yResolution(0L) + .build() + ) + .interoperability( + Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + Metadata.Exif.Makernote.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .thumbnail( + Metadata.Exif.Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + ) + .build() + ) + .format("format") + .hasColorProfile(true) + .hasTransparency(true) + .height(0L) + .pHash("pHash") + .quality(0L) + .size(0L) + .videoCodec("videoCodec") + .width(0L) + .build() + ) + .name("name") + .size(0.0) + .addTag("string") + .thumbnailUrl("thumbnailUrl") + .url("url") + .versionInfo( + UploadPreTransformSuccessEvent.Data.VersionInfo.builder() + .id("id") + .name("name") + .build() + ) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .request( + UploadPreTransformSuccessEvent.Request.builder() + .transformation("transformation") + .xRequestId("x_request_id") + .build() + ) + .build() + ) + + val roundtrippedUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnwrapWebhookEvent).isEqualTo(unwrapWebhookEvent) + } + + @Test + fun ofUploadPreTransformError() { + val uploadPreTransformError = + UploadPreTransformErrorEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformErrorEvent.Data.builder() + .name("name") + .path("path") + .transformation( + UploadPreTransformErrorEvent.Data.Transformation.builder() + .error( + UploadPreTransformErrorEvent.Data.Transformation.Error.builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .build() + ) + .request( + UploadPreTransformErrorEvent.Request.builder() + .transformation("transformation") + .xRequestId("x_request_id") + .build() + ) + .build() + + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofUploadPreTransformError(uploadPreTransformError) + + assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformError()).contains(uploadPreTransformError) + assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty + } + + @Test + fun ofUploadPreTransformErrorRoundtrip() { + val jsonMapper = jsonMapper() + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofUploadPreTransformError( + UploadPreTransformErrorEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformErrorEvent.Data.builder() + .name("name") + .path("path") + .transformation( + UploadPreTransformErrorEvent.Data.Transformation.builder() + .error( + UploadPreTransformErrorEvent.Data.Transformation.Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .build() + ) + .request( + UploadPreTransformErrorEvent.Request.builder() + .transformation("transformation") + .xRequestId("x_request_id") + .build() + ) + .build() + ) + + val roundtrippedUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnwrapWebhookEvent).isEqualTo(unwrapWebhookEvent) + } + + @Test + fun ofUploadPostTransformSuccess() { + val uploadPostTransformSuccess = + UploadPostTransformSuccessEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformSuccessEvent.Data.builder() + .fileId("fileId") + .name("name") + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformSuccessEvent.Request.builder() + .transformation( + UploadPostTransformSuccessEvent.Request.Transformation.builder() + .type( + UploadPostTransformSuccessEvent.Request.Transformation.Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformSuccessEvent.Request.Transformation.Protocol + .HLS + ) + .value("value") + .build() + ) + .xRequestId("x_request_id") + .build() + ) + .build() + + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofUploadPostTransformSuccess(uploadPostTransformSuccess) + + assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()) + .contains(uploadPostTransformSuccess) + assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty + } + + @Test + fun ofUploadPostTransformSuccessRoundtrip() { + val jsonMapper = jsonMapper() + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofUploadPostTransformSuccess( + UploadPostTransformSuccessEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformSuccessEvent.Data.builder() + .fileId("fileId") + .name("name") + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformSuccessEvent.Request.builder() + .transformation( + UploadPostTransformSuccessEvent.Request.Transformation.builder() + .type( + UploadPostTransformSuccessEvent.Request.Transformation.Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformSuccessEvent.Request.Transformation + .Protocol + .HLS + ) + .value("value") + .build() + ) + .xRequestId("x_request_id") + .build() + ) + .build() + ) + + val roundtrippedUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnwrapWebhookEvent).isEqualTo(unwrapWebhookEvent) + } + + @Test + fun ofUploadPostTransformError() { + val uploadPostTransformError = + UploadPostTransformErrorEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformErrorEvent.Data.builder() + .fileId("fileId") + .name("name") + .path("path") + .transformation( + UploadPostTransformErrorEvent.Data.Transformation.builder() + .error( + UploadPostTransformErrorEvent.Data.Transformation.Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformErrorEvent.Request.builder() + .transformation( + UploadPostTransformErrorEvent.Request.Transformation.builder() + .type( + UploadPostTransformErrorEvent.Request.Transformation.Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformErrorEvent.Request.Transformation.Protocol + .HLS + ) + .value("value") + .build() + ) + .xRequestId("x_request_id") + .build() + ) + .build() + + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofUploadPostTransformError(uploadPostTransformError) + + assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformError()).contains(uploadPostTransformError) + } + + @Test + fun ofUploadPostTransformErrorRoundtrip() { + val jsonMapper = jsonMapper() + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofUploadPostTransformError( + UploadPostTransformErrorEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformErrorEvent.Data.builder() + .fileId("fileId") + .name("name") + .path("path") + .transformation( + UploadPostTransformErrorEvent.Data.Transformation.builder() + .error( + UploadPostTransformErrorEvent.Data.Transformation.Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformErrorEvent.Request.builder() + .transformation( + UploadPostTransformErrorEvent.Request.Transformation.builder() + .type( + UploadPostTransformErrorEvent.Request.Transformation.Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformErrorEvent.Request.Transformation + .Protocol + .HLS + ) + .value("value") + .build() + ) + .xRequestId("x_request_id") + .build() + ) + .build() + ) + + val roundtrippedUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnwrapWebhookEvent).isEqualTo(unwrapWebhookEvent) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val unwrapWebhookEvent = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { unwrapWebhookEvent.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEventTest.kt new file mode 100644 index 00000000..e7a4925a --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEventTest.kt @@ -0,0 +1,152 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UploadPostTransformErrorEventTest { + + @Test + fun create() { + val uploadPostTransformErrorEvent = + UploadPostTransformErrorEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformErrorEvent.Data.builder() + .fileId("fileId") + .name("name") + .path("path") + .transformation( + UploadPostTransformErrorEvent.Data.Transformation.builder() + .error( + UploadPostTransformErrorEvent.Data.Transformation.Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformErrorEvent.Request.builder() + .transformation( + UploadPostTransformErrorEvent.Request.Transformation.builder() + .type( + UploadPostTransformErrorEvent.Request.Transformation.Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformErrorEvent.Request.Transformation.Protocol + .HLS + ) + .value("value") + .build() + ) + .xRequestId("x_request_id") + .build() + ) + .build() + + assertThat(uploadPostTransformErrorEvent.id()).isEqualTo("id") + assertThat(uploadPostTransformErrorEvent.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(uploadPostTransformErrorEvent.data()) + .isEqualTo( + UploadPostTransformErrorEvent.Data.builder() + .fileId("fileId") + .name("name") + .path("path") + .transformation( + UploadPostTransformErrorEvent.Data.Transformation.builder() + .error( + UploadPostTransformErrorEvent.Data.Transformation.Error.builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .url("https://example.com") + .build() + ) + assertThat(uploadPostTransformErrorEvent.request()) + .isEqualTo( + UploadPostTransformErrorEvent.Request.builder() + .transformation( + UploadPostTransformErrorEvent.Request.Transformation.builder() + .type( + UploadPostTransformErrorEvent.Request.Transformation.Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformErrorEvent.Request.Transformation.Protocol.HLS + ) + .value("value") + .build() + ) + .xRequestId("x_request_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val uploadPostTransformErrorEvent = + UploadPostTransformErrorEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformErrorEvent.Data.builder() + .fileId("fileId") + .name("name") + .path("path") + .transformation( + UploadPostTransformErrorEvent.Data.Transformation.builder() + .error( + UploadPostTransformErrorEvent.Data.Transformation.Error + .builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformErrorEvent.Request.builder() + .transformation( + UploadPostTransformErrorEvent.Request.Transformation.builder() + .type( + UploadPostTransformErrorEvent.Request.Transformation.Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformErrorEvent.Request.Transformation.Protocol + .HLS + ) + .value("value") + .build() + ) + .xRequestId("x_request_id") + .build() + ) + .build() + + val roundtrippedUploadPostTransformErrorEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(uploadPostTransformErrorEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUploadPostTransformErrorEvent) + .isEqualTo(uploadPostTransformErrorEvent) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEventTest.kt new file mode 100644 index 00000000..eaa86ef2 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEventTest.kt @@ -0,0 +1,120 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UploadPostTransformSuccessEventTest { + + @Test + fun create() { + val uploadPostTransformSuccessEvent = + UploadPostTransformSuccessEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformSuccessEvent.Data.builder() + .fileId("fileId") + .name("name") + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformSuccessEvent.Request.builder() + .transformation( + UploadPostTransformSuccessEvent.Request.Transformation.builder() + .type( + UploadPostTransformSuccessEvent.Request.Transformation.Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformSuccessEvent.Request.Transformation.Protocol + .HLS + ) + .value("value") + .build() + ) + .xRequestId("x_request_id") + .build() + ) + .build() + + assertThat(uploadPostTransformSuccessEvent.id()).isEqualTo("id") + assertThat(uploadPostTransformSuccessEvent.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(uploadPostTransformSuccessEvent.data()) + .isEqualTo( + UploadPostTransformSuccessEvent.Data.builder() + .fileId("fileId") + .name("name") + .url("https://example.com") + .build() + ) + assertThat(uploadPostTransformSuccessEvent.request()) + .isEqualTo( + UploadPostTransformSuccessEvent.Request.builder() + .transformation( + UploadPostTransformSuccessEvent.Request.Transformation.builder() + .type( + UploadPostTransformSuccessEvent.Request.Transformation.Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformSuccessEvent.Request.Transformation.Protocol.HLS + ) + .value("value") + .build() + ) + .xRequestId("x_request_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val uploadPostTransformSuccessEvent = + UploadPostTransformSuccessEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPostTransformSuccessEvent.Data.builder() + .fileId("fileId") + .name("name") + .url("https://example.com") + .build() + ) + .request( + UploadPostTransformSuccessEvent.Request.builder() + .transformation( + UploadPostTransformSuccessEvent.Request.Transformation.builder() + .type( + UploadPostTransformSuccessEvent.Request.Transformation.Type + .TRANSFORMATION + ) + .protocol( + UploadPostTransformSuccessEvent.Request.Transformation.Protocol + .HLS + ) + .value("value") + .build() + ) + .xRequestId("x_request_id") + .build() + ) + .build() + + val roundtrippedUploadPostTransformSuccessEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(uploadPostTransformSuccessEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUploadPostTransformSuccessEvent) + .isEqualTo(uploadPostTransformSuccessEvent) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEventTest.kt new file mode 100644 index 00000000..e97ad849 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEventTest.kt @@ -0,0 +1,108 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UploadPreTransformErrorEventTest { + + @Test + fun create() { + val uploadPreTransformErrorEvent = + UploadPreTransformErrorEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformErrorEvent.Data.builder() + .name("name") + .path("path") + .transformation( + UploadPreTransformErrorEvent.Data.Transformation.builder() + .error( + UploadPreTransformErrorEvent.Data.Transformation.Error.builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .build() + ) + .request( + UploadPreTransformErrorEvent.Request.builder() + .transformation("transformation") + .xRequestId("x_request_id") + .build() + ) + .build() + + assertThat(uploadPreTransformErrorEvent.id()).isEqualTo("id") + assertThat(uploadPreTransformErrorEvent.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(uploadPreTransformErrorEvent.data()) + .isEqualTo( + UploadPreTransformErrorEvent.Data.builder() + .name("name") + .path("path") + .transformation( + UploadPreTransformErrorEvent.Data.Transformation.builder() + .error( + UploadPreTransformErrorEvent.Data.Transformation.Error.builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .build() + ) + assertThat(uploadPreTransformErrorEvent.request()) + .isEqualTo( + UploadPreTransformErrorEvent.Request.builder() + .transformation("transformation") + .xRequestId("x_request_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val uploadPreTransformErrorEvent = + UploadPreTransformErrorEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformErrorEvent.Data.builder() + .name("name") + .path("path") + .transformation( + UploadPreTransformErrorEvent.Data.Transformation.builder() + .error( + UploadPreTransformErrorEvent.Data.Transformation.Error.builder() + .reason("encoding_failed") + .build() + ) + .build() + ) + .build() + ) + .request( + UploadPreTransformErrorEvent.Request.builder() + .transformation("transformation") + .xRequestId("x_request_id") + .build() + ) + .build() + + val roundtrippedUploadPreTransformErrorEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(uploadPreTransformErrorEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUploadPreTransformErrorEvent).isEqualTo(uploadPreTransformErrorEvent) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt new file mode 100644 index 00000000..7068d5a9 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt @@ -0,0 +1,536 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import com.imagekit.api.models.files.Metadata +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UploadPreTransformSuccessEventTest { + + @Test + fun create() { + val uploadPreTransformSuccessEvent = + UploadPreTransformSuccessEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformSuccessEvent.Data.builder() + .addAiTag( + UploadPreTransformSuccessEvent.Data.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata( + UploadPreTransformSuccessEvent.Data.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + UploadPreTransformSuccessEvent.Data.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.builder() + .aiAutoDescription( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .AiAutoDescription + .SUCCESS + ) + .awsAutoTagging( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .AwsAutoTagging + .SUCCESS + ) + .googleAutoTagging( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .GoogleAutoTagging + .SUCCESS + ) + .removeBg( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.RemoveBg + .SUCCESS + ) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .metadata( + Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + Metadata.Exif.builder() + .exif( + Metadata.Exif.InnerExif.builder() + .apertureValue(0.0) + .colorSpace(0L) + .createDate("CreateDate") + .customRendered(0L) + .dateTimeOriginal("DateTimeOriginal") + .exifImageHeight(0L) + .exifImageWidth(0L) + .exifVersion("ExifVersion") + .exposureCompensation(0.0) + .exposureMode(0L) + .exposureProgram(0L) + .exposureTime(0.0) + .flash(0L) + .flashpixVersion("FlashpixVersion") + .fNumber(0.0) + .focalLength(0L) + .focalPlaneResolutionUnit(0L) + .focalPlaneXResolution(0.0) + .focalPlaneYResolution(0.0) + .interopOffset(0L) + .iso(0L) + .meteringMode(0L) + .sceneCaptureType(0L) + .shutterSpeedValue(0.0) + .subSecTime("SubSecTime") + .whiteBalance(0L) + .build() + ) + .gps( + Metadata.Exif.Gps.builder().addGpsVersionId(0L).build() + ) + .image( + Metadata.Exif.Image.builder() + .exifOffset(0L) + .gpsInfo(0L) + .make("Make") + .model("Model") + .modifyDate("ModifyDate") + .orientation(0L) + .resolutionUnit(0L) + .software("Software") + .xResolution(0L) + .yCbCrPositioning(0L) + .yResolution(0L) + .build() + ) + .interoperability( + Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + Metadata.Exif.Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + ) + .build() + ) + .format("format") + .hasColorProfile(true) + .hasTransparency(true) + .height(0L) + .pHash("pHash") + .quality(0L) + .size(0L) + .videoCodec("videoCodec") + .width(0L) + .build() + ) + .name("name") + .size(0.0) + .addTag("string") + .thumbnailUrl("thumbnailUrl") + .url("url") + .versionInfo( + UploadPreTransformSuccessEvent.Data.VersionInfo.builder() + .id("id") + .name("name") + .build() + ) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .request( + UploadPreTransformSuccessEvent.Request.builder() + .transformation("transformation") + .xRequestId("x_request_id") + .build() + ) + .build() + + assertThat(uploadPreTransformSuccessEvent.id()).isEqualTo("id") + assertThat(uploadPreTransformSuccessEvent.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(uploadPreTransformSuccessEvent.data()) + .isEqualTo( + UploadPreTransformSuccessEvent.Data.builder() + .addAiTag( + UploadPreTransformSuccessEvent.Data.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata( + UploadPreTransformSuccessEvent.Data.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + UploadPreTransformSuccessEvent.Data.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.builder() + .aiAutoDescription( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .AiAutoDescription + .SUCCESS + ) + .awsAutoTagging( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.AwsAutoTagging + .SUCCESS + ) + .googleAutoTagging( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .GoogleAutoTagging + .SUCCESS + ) + .removeBg( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.RemoveBg.SUCCESS + ) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .metadata( + Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + Metadata.Exif.builder() + .exif( + Metadata.Exif.InnerExif.builder() + .apertureValue(0.0) + .colorSpace(0L) + .createDate("CreateDate") + .customRendered(0L) + .dateTimeOriginal("DateTimeOriginal") + .exifImageHeight(0L) + .exifImageWidth(0L) + .exifVersion("ExifVersion") + .exposureCompensation(0.0) + .exposureMode(0L) + .exposureProgram(0L) + .exposureTime(0.0) + .flash(0L) + .flashpixVersion("FlashpixVersion") + .fNumber(0.0) + .focalLength(0L) + .focalPlaneResolutionUnit(0L) + .focalPlaneXResolution(0.0) + .focalPlaneYResolution(0.0) + .interopOffset(0L) + .iso(0L) + .meteringMode(0L) + .sceneCaptureType(0L) + .shutterSpeedValue(0.0) + .subSecTime("SubSecTime") + .whiteBalance(0L) + .build() + ) + .gps(Metadata.Exif.Gps.builder().addGpsVersionId(0L).build()) + .image( + Metadata.Exif.Image.builder() + .exifOffset(0L) + .gpsInfo(0L) + .make("Make") + .model("Model") + .modifyDate("ModifyDate") + .orientation(0L) + .resolutionUnit(0L) + .software("Software") + .xResolution(0L) + .yCbCrPositioning(0L) + .yResolution(0L) + .build() + ) + .interoperability( + Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + Metadata.Exif.Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + ) + .build() + ) + .format("format") + .hasColorProfile(true) + .hasTransparency(true) + .height(0L) + .pHash("pHash") + .quality(0L) + .size(0L) + .videoCodec("videoCodec") + .width(0L) + .build() + ) + .name("name") + .size(0.0) + .addTag("string") + .thumbnailUrl("thumbnailUrl") + .url("url") + .versionInfo( + UploadPreTransformSuccessEvent.Data.VersionInfo.builder() + .id("id") + .name("name") + .build() + ) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + assertThat(uploadPreTransformSuccessEvent.request()) + .isEqualTo( + UploadPreTransformSuccessEvent.Request.builder() + .transformation("transformation") + .xRequestId("x_request_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val uploadPreTransformSuccessEvent = + UploadPreTransformSuccessEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + UploadPreTransformSuccessEvent.Data.builder() + .addAiTag( + UploadPreTransformSuccessEvent.Data.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .customCoordinates("customCoordinates") + .customMetadata( + UploadPreTransformSuccessEvent.Data.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + UploadPreTransformSuccessEvent.Data.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .extensionStatus( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.builder() + .aiAutoDescription( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .AiAutoDescription + .SUCCESS + ) + .awsAutoTagging( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .AwsAutoTagging + .SUCCESS + ) + .googleAutoTagging( + UploadPreTransformSuccessEvent.Data.ExtensionStatus + .GoogleAutoTagging + .SUCCESS + ) + .removeBg( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.RemoveBg + .SUCCESS + ) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .metadata( + Metadata.builder() + .audioCodec("audioCodec") + .bitRate(0L) + .density(0L) + .duration(0L) + .exif( + Metadata.Exif.builder() + .exif( + Metadata.Exif.InnerExif.builder() + .apertureValue(0.0) + .colorSpace(0L) + .createDate("CreateDate") + .customRendered(0L) + .dateTimeOriginal("DateTimeOriginal") + .exifImageHeight(0L) + .exifImageWidth(0L) + .exifVersion("ExifVersion") + .exposureCompensation(0.0) + .exposureMode(0L) + .exposureProgram(0L) + .exposureTime(0.0) + .flash(0L) + .flashpixVersion("FlashpixVersion") + .fNumber(0.0) + .focalLength(0L) + .focalPlaneResolutionUnit(0L) + .focalPlaneXResolution(0.0) + .focalPlaneYResolution(0.0) + .interopOffset(0L) + .iso(0L) + .meteringMode(0L) + .sceneCaptureType(0L) + .shutterSpeedValue(0.0) + .subSecTime("SubSecTime") + .whiteBalance(0L) + .build() + ) + .gps( + Metadata.Exif.Gps.builder().addGpsVersionId(0L).build() + ) + .image( + Metadata.Exif.Image.builder() + .exifOffset(0L) + .gpsInfo(0L) + .make("Make") + .model("Model") + .modifyDate("ModifyDate") + .orientation(0L) + .resolutionUnit(0L) + .software("Software") + .xResolution(0L) + .yCbCrPositioning(0L) + .yResolution(0L) + .build() + ) + .interoperability( + Metadata.Exif.Interoperability.builder() + .interopIndex("InteropIndex") + .interopVersion("InteropVersion") + .build() + ) + .makernote( + Metadata.Exif.Makernote.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .thumbnail( + Metadata.Exif.Thumbnail.builder() + .compression(0L) + .resolutionUnit(0L) + .thumbnailLength(0L) + .thumbnailOffset(0L) + .xResolution(0L) + .yResolution(0L) + .build() + ) + .build() + ) + .format("format") + .hasColorProfile(true) + .hasTransparency(true) + .height(0L) + .pHash("pHash") + .quality(0L) + .size(0L) + .videoCodec("videoCodec") + .width(0L) + .build() + ) + .name("name") + .size(0.0) + .addTag("string") + .thumbnailUrl("thumbnailUrl") + .url("url") + .versionInfo( + UploadPreTransformSuccessEvent.Data.VersionInfo.builder() + .id("id") + .name("name") + .build() + ) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .request( + UploadPreTransformSuccessEvent.Request.builder() + .transformation("transformation") + .xRequestId("x_request_id") + .build() + ) + .build() + + val roundtrippedUploadPreTransformSuccessEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(uploadPreTransformSuccessEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUploadPreTransformSuccessEvent) + .isEqualTo(uploadPreTransformSuccessEvent) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt new file mode 100644 index 00000000..e3c95329 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt @@ -0,0 +1,210 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VideoTransformationAcceptedEventTest { + + @Test + fun create() { + val videoTransformationAcceptedEvent = + VideoTransformationAcceptedEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationAcceptedEvent.Data.builder() + .asset( + VideoTransformationAcceptedEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationAcceptedEvent.Data.Transformation.builder() + .type( + VideoTransformationAcceptedEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationAcceptedEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationAcceptedEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .build() + + assertThat(videoTransformationAcceptedEvent.id()).isEqualTo("id") + assertThat(videoTransformationAcceptedEvent.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(videoTransformationAcceptedEvent.data()) + .isEqualTo( + VideoTransformationAcceptedEvent.Data.builder() + .asset( + VideoTransformationAcceptedEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationAcceptedEvent.Data.Transformation.builder() + .type( + VideoTransformationAcceptedEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationAcceptedEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationAcceptedEvent.Data.Transformation.Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationAcceptedEvent.Data.Transformation.Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationAcceptedEvent.Data.Transformation.Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationAcceptedEvent.Data.Transformation.Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + assertThat(videoTransformationAcceptedEvent.request()) + .isEqualTo( + VideoTransformationAcceptedEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val videoTransformationAcceptedEvent = + VideoTransformationAcceptedEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationAcceptedEvent.Data.builder() + .asset( + VideoTransformationAcceptedEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationAcceptedEvent.Data.Transformation.builder() + .type( + VideoTransformationAcceptedEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationAcceptedEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationAcceptedEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationAcceptedEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .build() + + val roundtrippedVideoTransformationAcceptedEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(videoTransformationAcceptedEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVideoTransformationAcceptedEvent) + .isEqualTo(videoTransformationAcceptedEvent) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt new file mode 100644 index 00000000..4d2b3f63 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt @@ -0,0 +1,238 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VideoTransformationErrorEventTest { + + @Test + fun create() { + val videoTransformationErrorEvent = + VideoTransformationErrorEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationErrorEvent.Data.builder() + .asset( + VideoTransformationErrorEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationErrorEvent.Data.Transformation.builder() + .type( + VideoTransformationErrorEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .error( + VideoTransformationErrorEvent.Data.Transformation.Error + .builder() + .reason( + VideoTransformationErrorEvent.Data.Transformation.Error + .Reason + .ENCODING_FAILED + ) + .build() + ) + .options( + VideoTransformationErrorEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationErrorEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationErrorEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationErrorEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationErrorEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationErrorEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .build() + + assertThat(videoTransformationErrorEvent.id()).isEqualTo("id") + assertThat(videoTransformationErrorEvent.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(videoTransformationErrorEvent.data()) + .isEqualTo( + VideoTransformationErrorEvent.Data.builder() + .asset( + VideoTransformationErrorEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationErrorEvent.Data.Transformation.builder() + .type( + VideoTransformationErrorEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .error( + VideoTransformationErrorEvent.Data.Transformation.Error.builder() + .reason( + VideoTransformationErrorEvent.Data.Transformation.Error + .Reason + .ENCODING_FAILED + ) + .build() + ) + .options( + VideoTransformationErrorEvent.Data.Transformation.Options.builder() + .audioCodec( + VideoTransformationErrorEvent.Data.Transformation.Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationErrorEvent.Data.Transformation.Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationErrorEvent.Data.Transformation.Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationErrorEvent.Data.Transformation.Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + assertThat(videoTransformationErrorEvent.request()) + .isEqualTo( + VideoTransformationErrorEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val videoTransformationErrorEvent = + VideoTransformationErrorEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationErrorEvent.Data.builder() + .asset( + VideoTransformationErrorEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationErrorEvent.Data.Transformation.builder() + .type( + VideoTransformationErrorEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .error( + VideoTransformationErrorEvent.Data.Transformation.Error + .builder() + .reason( + VideoTransformationErrorEvent.Data.Transformation.Error + .Reason + .ENCODING_FAILED + ) + .build() + ) + .options( + VideoTransformationErrorEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationErrorEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationErrorEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationErrorEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationErrorEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationErrorEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .build() + + val roundtrippedVideoTransformationErrorEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(videoTransformationErrorEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVideoTransformationErrorEvent) + .isEqualTo(videoTransformationErrorEvent) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt new file mode 100644 index 00000000..2c9c0127 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt @@ -0,0 +1,275 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VideoTransformationReadyEventTest { + + @Test + fun create() { + val videoTransformationReadyEvent = + VideoTransformationReadyEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationReadyEvent.Data.builder() + .asset( + VideoTransformationReadyEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationReadyEvent.Data.Transformation.builder() + .type( + VideoTransformationReadyEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationReadyEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationReadyEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationReadyEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationReadyEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationReadyEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .output( + VideoTransformationReadyEvent.Data.Transformation.Output + .builder() + .url("https://example.com") + .videoMetadata( + VideoTransformationReadyEvent.Data.Transformation.Output + .VideoMetadata + .builder() + .bitrate(0L) + .duration(0.0) + .height(0L) + .width(0L) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationReadyEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .timings( + VideoTransformationReadyEvent.Timings.builder() + .downloadDuration(0L) + .encodingDuration(0L) + .build() + ) + .build() + + assertThat(videoTransformationReadyEvent.id()).isEqualTo("id") + assertThat(videoTransformationReadyEvent.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(videoTransformationReadyEvent.data()) + .isEqualTo( + VideoTransformationReadyEvent.Data.builder() + .asset( + VideoTransformationReadyEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationReadyEvent.Data.Transformation.builder() + .type( + VideoTransformationReadyEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationReadyEvent.Data.Transformation.Options.builder() + .audioCodec( + VideoTransformationReadyEvent.Data.Transformation.Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationReadyEvent.Data.Transformation.Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationReadyEvent.Data.Transformation.Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationReadyEvent.Data.Transformation.Options + .VideoCodec + .H264 + ) + .build() + ) + .output( + VideoTransformationReadyEvent.Data.Transformation.Output.builder() + .url("https://example.com") + .videoMetadata( + VideoTransformationReadyEvent.Data.Transformation.Output + .VideoMetadata + .builder() + .bitrate(0L) + .duration(0.0) + .height(0L) + .width(0L) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + assertThat(videoTransformationReadyEvent.request()) + .isEqualTo( + VideoTransformationReadyEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + assertThat(videoTransformationReadyEvent.timings()) + .contains( + VideoTransformationReadyEvent.Timings.builder() + .downloadDuration(0L) + .encodingDuration(0L) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val videoTransformationReadyEvent = + VideoTransformationReadyEvent.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + VideoTransformationReadyEvent.Data.builder() + .asset( + VideoTransformationReadyEvent.Data.Asset.builder() + .url("https://example.com") + .build() + ) + .transformation( + VideoTransformationReadyEvent.Data.Transformation.builder() + .type( + VideoTransformationReadyEvent.Data.Transformation.Type + .VIDEO_TRANSFORMATION + ) + .options( + VideoTransformationReadyEvent.Data.Transformation.Options + .builder() + .audioCodec( + VideoTransformationReadyEvent.Data.Transformation + .Options + .AudioCodec + .AAC + ) + .autoRotate(true) + .format( + VideoTransformationReadyEvent.Data.Transformation + .Options + .Format + .MP4 + ) + .quality(0L) + .streamProtocol( + VideoTransformationReadyEvent.Data.Transformation + .Options + .StreamProtocol + .HLS + ) + .addVariant("string") + .videoCodec( + VideoTransformationReadyEvent.Data.Transformation + .Options + .VideoCodec + .H264 + ) + .build() + ) + .output( + VideoTransformationReadyEvent.Data.Transformation.Output + .builder() + .url("https://example.com") + .videoMetadata( + VideoTransformationReadyEvent.Data.Transformation.Output + .VideoMetadata + .builder() + .bitrate(0L) + .duration(0.0) + .height(0L) + .width(0L) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .request( + VideoTransformationReadyEvent.Request.builder() + .url("https://example.com") + .xRequestId("x_request_id") + .userAgent("user_agent") + .build() + ) + .timings( + VideoTransformationReadyEvent.Timings.builder() + .downloadDuration(0L) + .encodingDuration(0L) + .build() + ) + .build() + + val roundtrippedVideoTransformationReadyEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(videoTransformationReadyEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVideoTransformationReadyEvent) + .isEqualTo(videoTransformationReadyEvent) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt new file mode 100644 index 00000000..33349dd2 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt @@ -0,0 +1,1762 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services + +import com.github.tomakehurst.wiremock.client.WireMock.anyUrl +import com.github.tomakehurst.wiremock.client.WireMock.post +import com.github.tomakehurst.wiremock.client.WireMock.status +import com.github.tomakehurst.wiremock.client.WireMock.stubFor +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest +import com.imagekit.api.client.ImageKitClient +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.jsonMapper +import com.imagekit.api.errors.BadRequestException +import com.imagekit.api.errors.ImageKitException +import com.imagekit.api.errors.InternalServerException +import com.imagekit.api.errors.NotFoundException +import com.imagekit.api.errors.PermissionDeniedException +import com.imagekit.api.errors.RateLimitException +import com.imagekit.api.errors.UnauthorizedException +import com.imagekit.api.errors.UnexpectedStatusCodeException +import com.imagekit.api.errors.UnprocessableEntityException +import com.imagekit.api.models.files.FileUploadParams +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.entry +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.api.parallel.ResourceLock + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class ErrorHandlingTest { + + companion object { + + private val ERROR_JSON: JsonValue = JsonValue.from(mapOf("errorProperty" to "42")) + + private val ERROR_JSON_BYTES: ByteArray = jsonMapper().writeValueAsBytes(ERROR_JSON) + + private const val HEADER_NAME: String = "Error-Header" + + private const val HEADER_VALUE: String = "42" + + private const val NOT_JSON: String = "Not JSON" + } + + private lateinit var client: ImageKitClient + + @BeforeEach + fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { + client = + ImageKitOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + } + + @Test + fun filesUpload400() { + val fileService = client.files() + stubFor( + post(anyUrl()) + .willReturn( + status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(400) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun filesUpload400WithRawResponse() { + val fileService = client.files().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(400) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun filesUpload401() { + val fileService = client.files() + stubFor( + post(anyUrl()) + .willReturn( + status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(401) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun filesUpload401WithRawResponse() { + val fileService = client.files().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(401) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun filesUpload403() { + val fileService = client.files() + stubFor( + post(anyUrl()) + .willReturn( + status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(403) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun filesUpload403WithRawResponse() { + val fileService = client.files().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(403) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun filesUpload404() { + val fileService = client.files() + stubFor( + post(anyUrl()) + .willReturn( + status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(404) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun filesUpload404WithRawResponse() { + val fileService = client.files().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(404) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun filesUpload422() { + val fileService = client.files() + stubFor( + post(anyUrl()) + .willReturn( + status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(422) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun filesUpload422WithRawResponse() { + val fileService = client.files().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(422) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun filesUpload429() { + val fileService = client.files() + stubFor( + post(anyUrl()) + .willReturn( + status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(429) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun filesUpload429WithRawResponse() { + val fileService = client.files().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(429) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun filesUpload500() { + val fileService = client.files() + stubFor( + post(anyUrl()) + .willReturn( + status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(500) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun filesUpload500WithRawResponse() { + val fileService = client.files().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(500) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun filesUpload999() { + val fileService = client.files() + stubFor( + post(anyUrl()) + .willReturn( + status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(999) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun filesUpload999WithRawResponse() { + val fileService = client.files().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(999) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun filesUploadInvalidJsonBody() { + val fileService = client.files() + stubFor( + post(anyUrl()) + .willReturn(status(200).withHeader(HEADER_NAME, HEADER_VALUE).withBody(NOT_JSON)) + ) + + val e = + assertThrows { + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + ) + } + + assertThat(e).hasMessage("Error reading response") + } + + private fun Headers.toMap(): Map> = + mutableMapOf>().also { map -> + names().forEach { map[it] = values(it) } + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt new file mode 100644 index 00000000..f26281ec --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services + +import com.github.tomakehurst.wiremock.client.WireMock.anyUrl +import com.github.tomakehurst.wiremock.client.WireMock.equalTo +import com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath +import com.github.tomakehurst.wiremock.client.WireMock.ok +import com.github.tomakehurst.wiremock.client.WireMock.post +import com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor +import com.github.tomakehurst.wiremock.client.WireMock.stubFor +import com.github.tomakehurst.wiremock.client.WireMock.verify +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest +import com.imagekit.api.client.ImageKitClient +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.core.JsonValue +import com.imagekit.api.models.files.FileUploadParams +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class ServiceParamsTest { + + private lateinit var client: ImageKitClient + + @BeforeEach + fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { + client = + ImageKitOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + } + + @Disabled("Prism tests are disabled") + @Test + fun upload() { + val fileService = client.files() + stubFor(post(anyUrl()).willReturn(ok("{}"))) + + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .putAdditionalHeader("Secret-Header", "42") + .putAdditionalQueryParam("secret_query_param", "42") + .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) + .build() + ) + + verify( + postRequestedFor(anyUrl()) + .withHeader("Secret-Header", equalTo("42")) + .withQueryParam("secret_query_param", equalTo("42")) + .withRequestBody(matchingJsonPath("$.secretProperty", equalTo("42"))) + ) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt new file mode 100644 index 00000000..322f6ced --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import com.imagekit.api.models.assets.AssetListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AssetServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val assetServiceAsync = client.assets() + + val assetsFuture = + assetServiceAsync.list( + AssetListParams.builder() + .fileType(AssetListParams.FileType.ALL) + .limit(1L) + .path("path") + .searchQuery("searchQuery") + .skip(0L) + .sort(AssetListParams.Sort.ASC_NAME) + .type(AssetListParams.Type.FILE) + .build() + ) + + val assets = assetsFuture.get() + assets.forEach { it.validate() } + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt new file mode 100644 index 00000000..bb8af989 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CustomMetadataFieldServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val customMetadataFieldServiceAsync = client.customMetadataFields() + + val customMetadataFieldFuture = + customMetadataFieldServiceAsync.create( + CustomMetadataFieldCreateParams.builder() + .label("price") + .name("price") + .schema( + CustomMetadataFieldCreateParams.Schema.builder() + .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue(3000.0) + .minLength(0.0) + .minValue(1000.0) + .selectOptions( + listOf( + CustomMetadataFieldCreateParams.Schema.SelectOption.ofString( + "small" + ), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofString( + "medium" + ), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofString( + "large" + ), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofNumber( + 30.0 + ), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofNumber( + 40.0 + ), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + .build() + ) + + val customMetadataField = customMetadataFieldFuture.get() + customMetadataField.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val customMetadataFieldServiceAsync = client.customMetadataFields() + + val customMetadataFieldFuture = + customMetadataFieldServiceAsync.update( + CustomMetadataFieldUpdateParams.builder() + .id("id") + .label("price") + .schema( + CustomMetadataFieldUpdateParams.Schema.builder() + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue(3000.0) + .minLength(0.0) + .minValue(1000.0) + .selectOptions( + listOf( + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofString( + "small" + ), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofString( + "medium" + ), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofString( + "large" + ), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofNumber( + 30.0 + ), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofNumber( + 40.0 + ), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + .build() + ) + + val customMetadataField = customMetadataFieldFuture.get() + customMetadataField.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val customMetadataFieldServiceAsync = client.customMetadataFields() + + val customMetadataFieldsFuture = + customMetadataFieldServiceAsync.list( + CustomMetadataFieldListParams.builder().includeDeleted(true).build() + ) + + val customMetadataFields = customMetadataFieldsFuture.get() + customMetadataFields.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val customMetadataFieldServiceAsync = client.customMetadataFields() + + val customMetadataFieldFuture = customMetadataFieldServiceAsync.delete("id") + + val customMetadataField = customMetadataFieldFuture.get() + customMetadataField.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt new file mode 100644 index 00000000..6e8d541b --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -0,0 +1,313 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import com.imagekit.api.core.JsonValue +import com.imagekit.api.models.files.FileCopyParams +import com.imagekit.api.models.files.FileMoveParams +import com.imagekit.api.models.files.FileRenameParams +import com.imagekit.api.models.files.FileUpdateParams +import com.imagekit.api.models.files.FileUploadParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class FileServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileServiceAsync = client.files() + + val fileFuture = + fileServiceAsync.update( + FileUpdateParams.builder() + .fileId("fileId") + .update( + FileUpdateParams.Update.UpdateFileDetails.builder() + .customCoordinates("10,10,100,100") + .customMetadata( + FileUpdateParams.Update.UpdateFileDetails.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("description") + .extensions( + listOf( + FileUpdateParams.Update.UpdateFileDetails.Extension.ofRemoveBg( + FileUpdateParams.Update.UpdateFileDetails.Extension.RemoveBg + .builder() + .options( + FileUpdateParams.Update.UpdateFileDetails.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUpdateParams.Update.UpdateFileDetails.Extension + .ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + FileUpdateParams.Update.UpdateFileDetails + .Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUpdateParams.Update.UpdateFileDetails.Extension + .ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + FileUpdateParams.Update.UpdateFileDetails + .Extension + .AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) + .build() + ), + FileUpdateParams.Update.UpdateFileDetails.Extension + .ofAiAutoDescription(), + ) + ) + .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) + .addTag("tag1") + .addTag("tag2") + .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") + .build() + ) + .build() + ) + + val file = fileFuture.get() + file.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileServiceAsync = client.files() + + val future = fileServiceAsync.delete("fileId") + + val response = future.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun copy() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileServiceAsync = client.files() + + val responseFuture = + fileServiceAsync.copy( + FileCopyParams.builder() + .destinationPath("/folder/to/copy/into/") + .sourceFilePath("/path/to/file.jpg") + .includeFileVersions(false) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileServiceAsync = client.files() + + val fileFuture = fileServiceAsync.get("fileId") + + val file = fileFuture.get() + file.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun move() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileServiceAsync = client.files() + + val responseFuture = + fileServiceAsync.move( + FileMoveParams.builder() + .destinationPath("/folder/to/move/into/") + .sourceFilePath("/path/to/file.jpg") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun rename() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileServiceAsync = client.files() + + val responseFuture = + fileServiceAsync.rename( + FileRenameParams.builder() + .filePath("/path/to/file.jpg") + .newFileName("newFileName.jpg") + .purgeCache(true) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun upload() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileServiceAsync = client.files() + + val responseFuture = + fileServiceAsync.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt new file mode 100644 index 00000000..175c051b --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt @@ -0,0 +1,132 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import com.imagekit.api.models.folders.FolderCopyParams +import com.imagekit.api.models.folders.FolderCreateParams +import com.imagekit.api.models.folders.FolderDeleteParams +import com.imagekit.api.models.folders.FolderMoveParams +import com.imagekit.api.models.folders.FolderRenameParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class FolderServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val folderServiceAsync = client.folders() + + val folderFuture = + folderServiceAsync.create( + FolderCreateParams.builder() + .folderName("summer") + .parentFolderPath("/product/images/") + .build() + ) + + val folder = folderFuture.get() + folder.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val folderServiceAsync = client.folders() + + val folderFuture = + folderServiceAsync.delete( + FolderDeleteParams.builder().folderPath("/folder/to/delete/").build() + ) + + val folder = folderFuture.get() + folder.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun copy() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val folderServiceAsync = client.folders() + + val responseFuture = + folderServiceAsync.copy( + FolderCopyParams.builder() + .destinationPath("/path/of/destination/folder") + .sourceFolderPath("/path/of/source/folder") + .includeVersions(true) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun move() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val folderServiceAsync = client.folders() + + val responseFuture = + folderServiceAsync.move( + FolderMoveParams.builder() + .destinationPath("/path/of/destination/folder") + .sourceFolderPath("/path/of/source/folder") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun rename() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val folderServiceAsync = client.folders() + + val responseFuture = + folderServiceAsync.rename( + FolderRenameParams.builder() + .folderPath("/path/of/folder") + .newFolderName("new-folder-name") + .purgeCache(true) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt new file mode 100644 index 00000000..55c67968 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt @@ -0,0 +1,131 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.accounts + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import com.imagekit.api.models.accounts.origins.OriginCreateParams +import com.imagekit.api.models.accounts.origins.OriginRequest +import com.imagekit.api.models.accounts.origins.OriginUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class OriginServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val originServiceAsync = client.accounts().origins() + + val originResponseFuture = + originServiceAsync.create( + OriginCreateParams.builder() + .origin( + OriginRequest.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) + .build() + ) + + val originResponse = originResponseFuture.get() + originResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val originServiceAsync = client.accounts().origins() + + val originResponseFuture = + originServiceAsync.update( + OriginUpdateParams.builder() + .id("id") + .origin( + OriginRequest.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) + .build() + ) + + val originResponse = originResponseFuture.get() + originResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val originServiceAsync = client.accounts().origins() + + val originResponsesFuture = originServiceAsync.list() + + val originResponses = originResponsesFuture.get() + originResponses.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val originServiceAsync = client.accounts().origins() + + val future = originServiceAsync.delete("id") + + val response = future.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val originServiceAsync = client.accounts().origins() + + val originResponseFuture = originServiceAsync.get("id") + + val originResponse = originResponseFuture.get() + originResponse.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt new file mode 100644 index 00000000..e95e7e55 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.accounts + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class UrlEndpointServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val urlEndpointServiceAsync = client.accounts().urlEndpoints() + + val urlEndpointResponseFuture = + urlEndpointServiceAsync.create( + UrlEndpointCreateParams.builder() + .urlEndpointRequest( + UrlEndpointRequest.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + ) + .build() + ) + + val urlEndpointResponse = urlEndpointResponseFuture.get() + urlEndpointResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val urlEndpointServiceAsync = client.accounts().urlEndpoints() + + val urlEndpointResponseFuture = + urlEndpointServiceAsync.update( + UrlEndpointUpdateParams.builder() + .id("id") + .urlEndpointRequest( + UrlEndpointRequest.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + ) + .build() + ) + + val urlEndpointResponse = urlEndpointResponseFuture.get() + urlEndpointResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val urlEndpointServiceAsync = client.accounts().urlEndpoints() + + val urlEndpointResponsesFuture = urlEndpointServiceAsync.list() + + val urlEndpointResponses = urlEndpointResponsesFuture.get() + urlEndpointResponses.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val urlEndpointServiceAsync = client.accounts().urlEndpoints() + + val future = urlEndpointServiceAsync.delete("id") + + val response = future.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val urlEndpointServiceAsync = client.accounts().urlEndpoints() + + val urlEndpointResponseFuture = urlEndpointServiceAsync.get("id") + + val urlEndpointResponse = urlEndpointResponseFuture.get() + urlEndpointResponse.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt new file mode 100644 index 00000000..08dd5a9e --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.accounts + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import com.imagekit.api.models.accounts.usage.UsageGetParams +import java.time.LocalDate +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class UsageServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val usageServiceAsync = client.accounts().usage() + + val usageFuture = + usageServiceAsync.get( + UsageGetParams.builder() + .endDate(LocalDate.parse("2019-12-27")) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + val usage = usageFuture.get() + usage.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt new file mode 100644 index 00000000..d98f98fc --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.beta.v2 + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import com.imagekit.api.core.JsonValue +import com.imagekit.api.models.beta.v2.files.FileUploadParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class FileServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun upload() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileServiceAsync = client.beta().v2().files() + + val responseFuture = + fileServiceAsync.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt new file mode 100644 index 00000000..547c8cab --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.cache + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import com.imagekit.api.models.cache.invalidation.InvalidationCreateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class InvalidationServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val invalidationServiceAsync = client.cache().invalidation() + + val invalidationFuture = + invalidationServiceAsync.create( + InvalidationCreateParams.builder() + .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg") + .build() + ) + + val invalidation = invalidationFuture.get() + invalidation.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val invalidationServiceAsync = client.cache().invalidation() + + val invalidationFuture = invalidationServiceAsync.get("requestId") + + val invalidation = invalidationFuture.get() + invalidation.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt new file mode 100644 index 00000000..fd95a1e5 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt @@ -0,0 +1,112 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.files + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import com.imagekit.api.models.files.bulk.BulkAddTagsParams +import com.imagekit.api.models.files.bulk.BulkDeleteParams +import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams +import com.imagekit.api.models.files.bulk.BulkRemoveTagsParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BulkServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val bulkServiceAsync = client.files().bulk() + + val bulkFuture = + bulkServiceAsync.delete( + BulkDeleteParams.builder() + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .build() + ) + + val bulk = bulkFuture.get() + bulk.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun addTags() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val bulkServiceAsync = client.files().bulk() + + val responseFuture = + bulkServiceAsync.addTags( + BulkAddTagsParams.builder() + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .tags(listOf("t-shirt", "round-neck", "sale2019")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun removeAiTags() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val bulkServiceAsync = client.files().bulk() + + val responseFuture = + bulkServiceAsync.removeAiTags( + BulkRemoveAiTagsParams.builder() + .aiTags(listOf("t-shirt", "round-neck", "sale2019")) + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun removeTags() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val bulkServiceAsync = client.files().bulk() + + val responseFuture = + bulkServiceAsync.removeTags( + BulkRemoveTagsParams.builder() + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .tags(listOf("t-shirt", "round-neck", "sale2019")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt new file mode 100644 index 00000000..827832b6 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.files + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class MetadataServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val metadataServiceAsync = client.files().metadata() + + val metadataFuture = metadataServiceAsync.get("fileId") + + val metadata = metadataFuture.get() + metadata.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun getFromUrl() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val metadataServiceAsync = client.files().metadata() + + val metadataFuture = + metadataServiceAsync.getFromUrl( + MetadataGetFromUrlParams.builder().url("https://example.com").build() + ) + + val metadata = metadataFuture.get() + metadata.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt new file mode 100644 index 00000000..afbefeb0 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt @@ -0,0 +1,93 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.files + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import com.imagekit.api.models.files.versions.VersionDeleteParams +import com.imagekit.api.models.files.versions.VersionGetParams +import com.imagekit.api.models.files.versions.VersionRestoreParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class VersionServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val versionServiceAsync = client.files().versions() + + val filesFuture = versionServiceAsync.list("fileId") + + val files = filesFuture.get() + files.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val versionServiceAsync = client.files().versions() + + val versionFuture = + versionServiceAsync.delete( + VersionDeleteParams.builder().fileId("fileId").versionId("versionId").build() + ) + + val version = versionFuture.get() + version.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val versionServiceAsync = client.files().versions() + + val fileFuture = + versionServiceAsync.get( + VersionGetParams.builder().fileId("fileId").versionId("versionId").build() + ) + + val file = fileFuture.get() + file.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun restore() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val versionServiceAsync = client.files().versions() + + val fileFuture = + versionServiceAsync.restore( + VersionRestoreParams.builder().fileId("fileId").versionId("versionId").build() + ) + + val file = fileFuture.get() + file.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt new file mode 100644 index 00000000..db5b2d61 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async.folders + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class JobServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val jobServiceAsync = client.folders().job() + + val jobFuture = jobServiceAsync.get("jobId") + + val job = jobFuture.get() + job.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt new file mode 100644 index 00000000..50fc335a --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.models.assets.AssetListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AssetServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val assetService = client.assets() + + val assets = + assetService.list( + AssetListParams.builder() + .fileType(AssetListParams.FileType.ALL) + .limit(1L) + .path("path") + .searchQuery("searchQuery") + .skip(0L) + .sort(AssetListParams.Sort.ASC_NAME) + .type(AssetListParams.Type.FILE) + .build() + ) + + assets.forEach { it.validate() } + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt new file mode 100644 index 00000000..be0a158b --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt @@ -0,0 +1,156 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CustomMetadataFieldServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val customMetadataFieldService = client.customMetadataFields() + + val customMetadataField = + customMetadataFieldService.create( + CustomMetadataFieldCreateParams.builder() + .label("price") + .name("price") + .schema( + CustomMetadataFieldCreateParams.Schema.builder() + .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue(3000.0) + .minLength(0.0) + .minValue(1000.0) + .selectOptions( + listOf( + CustomMetadataFieldCreateParams.Schema.SelectOption.ofString( + "small" + ), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofString( + "medium" + ), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofString( + "large" + ), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofNumber( + 30.0 + ), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofNumber( + 40.0 + ), + CustomMetadataFieldCreateParams.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + .build() + ) + + customMetadataField.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val customMetadataFieldService = client.customMetadataFields() + + val customMetadataField = + customMetadataFieldService.update( + CustomMetadataFieldUpdateParams.builder() + .id("id") + .label("price") + .schema( + CustomMetadataFieldUpdateParams.Schema.builder() + .defaultValue("string") + .isValueRequired(true) + .maxLength(0.0) + .maxValue(3000.0) + .minLength(0.0) + .minValue(1000.0) + .selectOptions( + listOf( + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofString( + "small" + ), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofString( + "medium" + ), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofString( + "large" + ), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofNumber( + 30.0 + ), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofNumber( + 40.0 + ), + CustomMetadataFieldUpdateParams.Schema.SelectOption.ofBool(true), + ) + ) + .build() + ) + .build() + ) + + customMetadataField.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val customMetadataFieldService = client.customMetadataFields() + + val customMetadataFields = + customMetadataFieldService.list( + CustomMetadataFieldListParams.builder().includeDeleted(true).build() + ) + + customMetadataFields.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val customMetadataFieldService = client.customMetadataFields() + + val customMetadataField = customMetadataFieldService.delete("id") + + customMetadataField.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt new file mode 100644 index 00000000..2e932b81 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -0,0 +1,305 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.core.JsonValue +import com.imagekit.api.models.files.FileCopyParams +import com.imagekit.api.models.files.FileMoveParams +import com.imagekit.api.models.files.FileRenameParams +import com.imagekit.api.models.files.FileUpdateParams +import com.imagekit.api.models.files.FileUploadParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class FileServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileService = client.files() + + val file = + fileService.update( + FileUpdateParams.builder() + .fileId("fileId") + .update( + FileUpdateParams.Update.UpdateFileDetails.builder() + .customCoordinates("10,10,100,100") + .customMetadata( + FileUpdateParams.Update.UpdateFileDetails.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("description") + .extensions( + listOf( + FileUpdateParams.Update.UpdateFileDetails.Extension.ofRemoveBg( + FileUpdateParams.Update.UpdateFileDetails.Extension.RemoveBg + .builder() + .options( + FileUpdateParams.Update.UpdateFileDetails.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUpdateParams.Update.UpdateFileDetails.Extension + .ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + FileUpdateParams.Update.UpdateFileDetails + .Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUpdateParams.Update.UpdateFileDetails.Extension + .ofAutoTagging( + FileUpdateParams.Update.UpdateFileDetails.Extension + .AutoTaggingExtension + .builder() + .maxTags(10L) + .minConfidence(80L) + .name( + FileUpdateParams.Update.UpdateFileDetails + .Extension + .AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) + .build() + ), + FileUpdateParams.Update.UpdateFileDetails.Extension + .ofAiAutoDescription(), + ) + ) + .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) + .addTag("tag1") + .addTag("tag2") + .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") + .build() + ) + .build() + ) + + file.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileService = client.files() + + fileService.delete("fileId") + } + + @Disabled("Prism tests are disabled") + @Test + fun copy() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileService = client.files() + + val response = + fileService.copy( + FileCopyParams.builder() + .destinationPath("/folder/to/copy/into/") + .sourceFilePath("/path/to/file.jpg") + .includeFileVersions(false) + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileService = client.files() + + val file = fileService.get("fileId") + + file.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun move() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileService = client.files() + + val response = + fileService.move( + FileMoveParams.builder() + .destinationPath("/folder/to/move/into/") + .sourceFilePath("/path/to/file.jpg") + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun rename() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileService = client.files() + + val response = + fileService.rename( + FileRenameParams.builder() + .filePath("/path/to/file.jpg") + .newFileName("newFileName.jpg") + .purgeCache(true) + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun upload() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileService = client.files() + + val response = + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + ) + + response.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt new file mode 100644 index 00000000..13026e90 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt @@ -0,0 +1,127 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.models.folders.FolderCopyParams +import com.imagekit.api.models.folders.FolderCreateParams +import com.imagekit.api.models.folders.FolderDeleteParams +import com.imagekit.api.models.folders.FolderMoveParams +import com.imagekit.api.models.folders.FolderRenameParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class FolderServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val folderService = client.folders() + + val folder = + folderService.create( + FolderCreateParams.builder() + .folderName("summer") + .parentFolderPath("/product/images/") + .build() + ) + + folder.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val folderService = client.folders() + + val folder = + folderService.delete( + FolderDeleteParams.builder().folderPath("/folder/to/delete/").build() + ) + + folder.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun copy() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val folderService = client.folders() + + val response = + folderService.copy( + FolderCopyParams.builder() + .destinationPath("/path/of/destination/folder") + .sourceFolderPath("/path/of/source/folder") + .includeVersions(true) + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun move() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val folderService = client.folders() + + val response = + folderService.move( + FolderMoveParams.builder() + .destinationPath("/path/of/destination/folder") + .sourceFolderPath("/path/of/source/folder") + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun rename() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val folderService = client.folders() + + val response = + folderService.rename( + FolderRenameParams.builder() + .folderPath("/path/of/folder") + .newFolderName("new-folder-name") + .purgeCache(true) + .build() + ) + + response.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt new file mode 100644 index 00000000..324a0687 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt @@ -0,0 +1,125 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.accounts + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.models.accounts.origins.OriginCreateParams +import com.imagekit.api.models.accounts.origins.OriginRequest +import com.imagekit.api.models.accounts.origins.OriginUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class OriginServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val originService = client.accounts().origins() + + val originResponse = + originService.create( + OriginCreateParams.builder() + .origin( + OriginRequest.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) + .build() + ) + + originResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val originService = client.accounts().origins() + + val originResponse = + originService.update( + OriginUpdateParams.builder() + .id("id") + .origin( + OriginRequest.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) + .build() + ) + + originResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val originService = client.accounts().origins() + + val originResponses = originService.list() + + originResponses.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val originService = client.accounts().origins() + + originService.delete("id") + } + + @Disabled("Prism tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val originService = client.accounts().origins() + + val originResponse = originService.get("id") + + originResponse.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt new file mode 100644 index 00000000..cdd0f580 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt @@ -0,0 +1,127 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.accounts + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class UrlEndpointServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val urlEndpointService = client.accounts().urlEndpoints() + + val urlEndpointResponse = + urlEndpointService.create( + UrlEndpointCreateParams.builder() + .urlEndpointRequest( + UrlEndpointRequest.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + ) + .build() + ) + + urlEndpointResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val urlEndpointService = client.accounts().urlEndpoints() + + val urlEndpointResponse = + urlEndpointService.update( + UrlEndpointUpdateParams.builder() + .id("id") + .urlEndpointRequest( + UrlEndpointRequest.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) + .build() + ) + .build() + ) + .build() + ) + + urlEndpointResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val urlEndpointService = client.accounts().urlEndpoints() + + val urlEndpointResponses = urlEndpointService.list() + + urlEndpointResponses.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val urlEndpointService = client.accounts().urlEndpoints() + + urlEndpointService.delete("id") + } + + @Disabled("Prism tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val urlEndpointService = client.accounts().urlEndpoints() + + val urlEndpointResponse = urlEndpointService.get("id") + + urlEndpointResponse.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt new file mode 100644 index 00000000..b579bdf8 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.accounts + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.models.accounts.usage.UsageGetParams +import java.time.LocalDate +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class UsageServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val usageService = client.accounts().usage() + + val usage = + usageService.get( + UsageGetParams.builder() + .endDate(LocalDate.parse("2019-12-27")) + .startDate(LocalDate.parse("2019-12-27")) + .build() + ) + + usage.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt new file mode 100644 index 00000000..07b702f8 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.beta.v2 + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.core.JsonValue +import com.imagekit.api.models.beta.v2.files.FileUploadParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class FileServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun upload() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val fileService = client.beta().v2().files() + + val response = + fileService.upload( + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() + ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") + .build() + ) + + response.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt new file mode 100644 index 00000000..819af016 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.cache + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.models.cache.invalidation.InvalidationCreateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class InvalidationServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val invalidationService = client.cache().invalidation() + + val invalidation = + invalidationService.create( + InvalidationCreateParams.builder() + .url("https://ik.imagekit.io/your_imagekit_id/default-image.jpg") + .build() + ) + + invalidation.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val invalidationService = client.cache().invalidation() + + val invalidation = invalidationService.get("requestId") + + invalidation.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt new file mode 100644 index 00000000..55230523 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt @@ -0,0 +1,108 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.files + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.models.files.bulk.BulkAddTagsParams +import com.imagekit.api.models.files.bulk.BulkDeleteParams +import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams +import com.imagekit.api.models.files.bulk.BulkRemoveTagsParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BulkServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val bulkService = client.files().bulk() + + val bulk = + bulkService.delete( + BulkDeleteParams.builder() + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .build() + ) + + bulk.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun addTags() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val bulkService = client.files().bulk() + + val response = + bulkService.addTags( + BulkAddTagsParams.builder() + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .tags(listOf("t-shirt", "round-neck", "sale2019")) + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun removeAiTags() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val bulkService = client.files().bulk() + + val response = + bulkService.removeAiTags( + BulkRemoveAiTagsParams.builder() + .aiTags(listOf("t-shirt", "round-neck", "sale2019")) + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun removeTags() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val bulkService = client.files().bulk() + + val response = + bulkService.removeTags( + BulkRemoveTagsParams.builder() + .addFileId("598821f949c0a938d57563bd") + .addFileId("598821f949c0a938d57563be") + .tags(listOf("t-shirt", "round-neck", "sale2019")) + .build() + ) + + response.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt new file mode 100644 index 00000000..fcdef81c --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.files + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class MetadataServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val metadataService = client.files().metadata() + + val metadata = metadataService.get("fileId") + + metadata.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun getFromUrl() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val metadataService = client.files().metadata() + + val metadata = + metadataService.getFromUrl( + MetadataGetFromUrlParams.builder().url("https://example.com").build() + ) + + metadata.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt new file mode 100644 index 00000000..a8d311ca --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.files + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.models.files.versions.VersionDeleteParams +import com.imagekit.api.models.files.versions.VersionGetParams +import com.imagekit.api.models.files.versions.VersionRestoreParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class VersionServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val versionService = client.files().versions() + + val files = versionService.list("fileId") + + files.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val versionService = client.files().versions() + + val version = + versionService.delete( + VersionDeleteParams.builder().fileId("fileId").versionId("versionId").build() + ) + + version.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val versionService = client.files().versions() + + val file = + versionService.get( + VersionGetParams.builder().fileId("fileId").versionId("versionId").build() + ) + + file.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun restore() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val versionService = client.files().versions() + + val file = + versionService.restore( + VersionRestoreParams.builder().fileId("fileId").versionId("versionId").build() + ) + + file.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt new file mode 100644 index 00000000..63455dd0 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking.folders + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class JobServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateApiKey("My Private API Key") + .password("My Password") + .build() + val jobService = client.folders().job() + + val job = jobService.get("jobId") + + job.validate() + } +} diff --git a/image-kit-java-example/build.gradle.kts b/image-kit-java-example/build.gradle.kts new file mode 100644 index 00000000..f9f4b81b --- /dev/null +++ b/image-kit-java-example/build.gradle.kts @@ -0,0 +1,28 @@ +plugins { + id("image-kit.java") + application +} + +repositories { + mavenCentral() +} + +dependencies { + implementation(project(":image-kit-java")) +} + +tasks.withType().configureEach { + // Allow using more modern APIs, like `List.of` and `Map.of`, in examples. + options.release.set(9) +} + +application { + // Use `./gradlew :image-kit-java-example:run` to run `Main` + // Use `./gradlew :image-kit-java-example:run -Pexample=Something` to run `SomethingExample` + mainClass = "com.imagekit.api.example.${ + if (project.hasProperty("example")) + "${project.property("example")}Example" + else + "Main" + }" +} diff --git a/image-kit-java-lib/.keep b/image-kit-java-lib/.keep new file mode 100644 index 00000000..5e2c99fd --- /dev/null +++ b/image-kit-java-lib/.keep @@ -0,0 +1,4 @@ +File generated from our OpenAPI spec by Stainless. + +This directory can be used to store custom files to expand the SDK. +It is ignored by Stainless code generation and its content (other than this keep file) won't be touched. \ No newline at end of file diff --git a/image-kit-java-proguard-test/build.gradle.kts b/image-kit-java-proguard-test/build.gradle.kts new file mode 100644 index 00000000..c541ddc4 --- /dev/null +++ b/image-kit-java-proguard-test/build.gradle.kts @@ -0,0 +1,101 @@ +plugins { + id("image-kit.kotlin") + id("com.gradleup.shadow") version "8.3.8" +} + +buildscript { + repositories { + google() + } + + dependencies { + classpath("com.guardsquare:proguard-gradle:7.4.2") + classpath("com.android.tools:r8:8.3.37") + } +} + +dependencies { + testImplementation(project(":image-kit-java")) + testImplementation(kotlin("test")) + testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") + testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4") +} + +tasks.shadowJar { + from(sourceSets.test.get().output) + configurations = listOf(project.configurations.testRuntimeClasspath.get()) +} + +val proguardJarPath = "${layout.buildDirectory.get()}/libs/${project.name}-${project.version}-proguard.jar" +val proguardJar by tasks.registering(proguard.gradle.ProGuardTask::class) { + group = "verification" + dependsOn(tasks.shadowJar) + notCompatibleWithConfigurationCache("ProGuard") + + injars(tasks.shadowJar) + outjars(proguardJarPath) + printmapping("${layout.buildDirectory.get()}/proguard-mapping.txt") + + val javaHome = System.getProperty("java.home") + if (System.getProperty("java.version").startsWith("1.")) { + // Before Java 9, the runtime classes were packaged in a single jar file. + libraryjars("$javaHome/lib/rt.jar") + } else { + // As of Java 9, the runtime classes are packaged in modular jmod files. + libraryjars( + // Filters must be specified first, as a map. + mapOf("jarfilter" to "!**.jar", "filter" to "!module-info.class"), + "$javaHome/jmods/java.base.jmod" + ) + } + + configuration("./test.pro") + configuration("../image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro") +} + +val testProGuard by tasks.registering(JavaExec::class) { + group = "verification" + dependsOn(proguardJar) + notCompatibleWithConfigurationCache("ProGuard") + + mainClass.set("com.imagekit.api.proguard.ProGuardCompatibilityTest") + classpath = files(proguardJarPath) +} + +val r8JarPath = "${layout.buildDirectory.get()}/libs/${project.name}-${project.version}-r8.jar" +val r8Jar by tasks.registering(JavaExec::class) { + group = "verification" + dependsOn(tasks.shadowJar) + notCompatibleWithConfigurationCache("R8") + + mainClass.set("com.android.tools.r8.R8") + classpath = buildscript.configurations["classpath"] + + args = listOf( + "--release", + "--classfile", + "--output", r8JarPath, + "--lib", System.getProperty("java.home"), + "--pg-conf", "./test.pro", + "--pg-conf", "../image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro", + "--pg-map-output", "${layout.buildDirectory.get()}/r8-mapping.txt", + tasks.shadowJar.get().archiveFile.get().asFile.absolutePath, + ) +} + +val testR8 by tasks.registering(JavaExec::class) { + group = "verification" + dependsOn(r8Jar) + notCompatibleWithConfigurationCache("R8") + + mainClass.set("com.imagekit.api.proguard.ProGuardCompatibilityTest") + classpath = files(r8JarPath) +} + +tasks.test { + dependsOn(testProGuard) + dependsOn(testR8) + // We defer to the tests run via the ProGuard JAR. + enabled = false +} diff --git a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt new file mode 100644 index 00000000..6b3c1c94 --- /dev/null +++ b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt @@ -0,0 +1,168 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.proguard + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import com.imagekit.api.models.Overlay +import com.imagekit.api.models.OverlayPosition +import com.imagekit.api.models.OverlayTiming +import com.imagekit.api.models.StreamingResolution +import com.imagekit.api.models.TextOverlay +import com.imagekit.api.models.TextOverlayTransformation +import com.imagekit.api.models.files.File +import java.time.OffsetDateTime +import kotlin.reflect.full.memberFunctions +import kotlin.reflect.jvm.javaMethod +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ProGuardCompatibilityTest { + + companion object { + + @JvmStatic + fun main(args: Array) { + // To debug that we're using the right JAR. + val jarPath = this::class.java.getProtectionDomain().codeSource.location + println("JAR being used: $jarPath") + + // We have to manually run the test methods instead of using the JUnit runner because it + // seems impossible to get working with R8. + val test = ProGuardCompatibilityTest() + test::class + .memberFunctions + .asSequence() + .filter { function -> + function.javaMethod?.isAnnotationPresent(Test::class.java) == true + } + .forEach { it.call(test) } + } + } + + @Test + fun proguardRules() { + val rulesFile = + javaClass.classLoader.getResourceAsStream("META-INF/proguard/image-kit-java-core.pro") + + assertThat(rulesFile).isNotNull() + } + + @Test + fun client() { + val client = + ImageKitOkHttpClient.builder() + .privateApiKey("My Private API Key") + .password("My Password") + .build() + + assertThat(client).isNotNull() + assertThat(client.customMetadataFields()).isNotNull() + assertThat(client.files()).isNotNull() + assertThat(client.assets()).isNotNull() + assertThat(client.cache()).isNotNull() + assertThat(client.folders()).isNotNull() + assertThat(client.accounts()).isNotNull() + assertThat(client.beta()).isNotNull() + assertThat(client.webhooks()).isNotNull() + } + + @Test + fun fileRoundtrip() { + val jsonMapper = jsonMapper() + val file = + File.builder() + .addAiTag( + File.AiTag.builder().confidence(0.0).name("name").source("source").build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .width(0.0) + .build() + + val roundtrippedFile = + jsonMapper.readValue(jsonMapper.writeValueAsString(file), jacksonTypeRef()) + + assertThat(roundtrippedFile).isEqualTo(file) + } + + @Test + fun overlayRoundtrip() { + val jsonMapper = jsonMapper() + val overlay = + Overlay.ofText( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + ) + + val roundtrippedOverlay = + jsonMapper.readValue(jsonMapper.writeValueAsString(overlay), jacksonTypeRef()) + + assertThat(roundtrippedOverlay).isEqualTo(overlay) + } + + @Test + fun streamingResolutionRoundtrip() { + val jsonMapper = jsonMapper() + val streamingResolution = StreamingResolution._240 + + val roundtrippedStreamingResolution = + jsonMapper.readValue( + jsonMapper.writeValueAsString(streamingResolution), + jacksonTypeRef(), + ) + + assertThat(roundtrippedStreamingResolution).isEqualTo(streamingResolution) + } +} diff --git a/image-kit-java-proguard-test/test.pro b/image-kit-java-proguard-test/test.pro new file mode 100644 index 00000000..64d7928e --- /dev/null +++ b/image-kit-java-proguard-test/test.pro @@ -0,0 +1,9 @@ +# Specify the entrypoint where ProGuard starts to determine what's reachable. +-keep class com.imagekit.api.proguard.** { *; } + +# For the testing framework. +-keep class org.junit.** { *; } + +# Many warnings don't apply for our testing purposes. +-dontnote +-dontwarn \ No newline at end of file diff --git a/image-kit-java/build.gradle.kts b/image-kit-java/build.gradle.kts new file mode 100644 index 00000000..7eaf9e42 --- /dev/null +++ b/image-kit-java/build.gradle.kts @@ -0,0 +1,29 @@ +plugins { + id("image-kit.kotlin") + id("image-kit.publish") +} + +dependencies { + api(project(":image-kit-java-client-okhttp")) +} + +// Redefine `dokkaJavadoc` to: +// - Depend on the root project's task for merging the docs of all the projects +// - Forward that task's output to this task's output +tasks.named("dokkaJavadoc").configure { + actions.clear() + + val dokkaJavadocCollector = rootProject.tasks["dokkaJavadocCollector"] + dependsOn(dokkaJavadocCollector) + + val outputDirectory = project.layout.buildDirectory.dir("dokka/javadoc") + doLast { + copy { + from(dokkaJavadocCollector.outputs.files) + into(outputDirectory) + duplicatesStrategy = DuplicatesStrategy.INCLUDE + } + } + + outputs.dir(outputDirectory) +} diff --git a/imagekit-sdk/build.gradle b/imagekit-sdk/build.gradle deleted file mode 100644 index ff248c8f..00000000 --- a/imagekit-sdk/build.gradle +++ /dev/null @@ -1,28 +0,0 @@ -plugins { - id 'java' - id 'java-library' -} - -group 'io.imagekit.sdk' -version '2.0.1' - -sourceCompatibility = 1.8 - -repositories { - mavenCentral() -} - -test { - useJUnitPlatform() -} - -dependencies { - compile 'commons-codec:commons-codec:1.13' - implementation 'com.google.code.gson:gson:2.7' - implementation 'com.squareup.okhttp3:okhttp:3.10.0' - compile group: 'com.squareup.okio', name: 'okio', version: '1.14.0' - testCompile group: 'junit', name: 'junit', version: '4.12' - testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.8.2") - testCompile "org.mockito:mockito-all:2.+" - testImplementation 'com.squareup.okhttp3:mockwebserver:3.10.0' -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/ImageKit.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/ImageKit.java deleted file mode 100644 index 2cd8fa7a..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/ImageKit.java +++ /dev/null @@ -1,437 +0,0 @@ -package io.imagekit.sdk; - -import io.imagekit.sdk.config.Configuration; -import io.imagekit.sdk.exceptions.BadRequestException; -import io.imagekit.sdk.exceptions.ConflictException; -import io.imagekit.sdk.exceptions.ForbiddenException; -import io.imagekit.sdk.exceptions.InternalServerException; -import io.imagekit.sdk.exceptions.NotFoundException; -import io.imagekit.sdk.exceptions.PartialSuccessException; -import io.imagekit.sdk.exceptions.TooManyRequestsException; -import io.imagekit.sdk.exceptions.UnauthorizedException; -import io.imagekit.sdk.exceptions.UnknownException; -import io.imagekit.sdk.models.*; -import io.imagekit.sdk.models.results.*; -import io.imagekit.sdk.tasks.Calculation; -import io.imagekit.sdk.tasks.RestClient; -import io.imagekit.sdk.tasks.UrlGen; - -import java.util.List; -import java.util.Map; - -public final class ImageKit { - private static ImageKit imageKit; - private Configuration configuration; - private RestClient restClient; - - private ImageKit() { - configuration = new Configuration(); - } - - /** - * getInstance() method will return single instance all over the application - * - * @return object ImageKit - */ - public static synchronized ImageKit getInstance() { - if (imageKit == null) { - imageKit = new ImageKit(); - imageKit.restClient = new RestClient(imageKit); - } - return imageKit; - } - - /** - * setRestClient(RestClient restClient) it takes object of RestClient class - * - * @param restClient to set restClient - */ - void setRestClient(RestClient restClient) { - this.restClient = restClient; - } - - /** - * setConfig(Configuration config) - * - * @param config will save new configuration - */ - public void setConfig(Configuration config) { - this.configuration = config; - } - - /** - * getConfig() - * - * @return it will return current configuration - */ - public Configuration getConfig() { - return configuration; - } - - /** - * - * @param options is a HashMap of Objects it can contains following keys - - * ["path","src","urlEndpoint","transformation", - * "transformationPosition","queryParameters", - * "signed","expireSeconds"] where transformation is an List of - * HashMap, signed is boolean and expireSeconds is integer. - * @return String new generated url - */ - - public String getUrl(Map options) { - return UrlGen.getUrl(options); - } - - /** - * - * @param fileCreateRequest is a object which contains file and other parameters - * @return object of Result class - */ - public Result upload(FileCreateRequest fileCreateRequest) throws InternalServerException, BadRequestException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - return restClient.upload(fileCreateRequest); - } - - /** - * - * @param fileUpdateRequest is a object which contains parameters and fileId - * @return object of Result class - */ - public Result updateFileDetail(FileUpdateRequest fileUpdateRequest) - throws ForbiddenException, TooManyRequestsException, InternalServerException, UnauthorizedException, - BadRequestException, UnknownException { - return restClient.updateFileDetail(fileUpdateRequest); - } - - /** - * - * @param getFileListRequest is an map it may contain keys [ "path", "fileType", "tags", - * "includeFolder", "name", "limit", "skip"] - * @return ResultList class that contains list of BaseFile - */ - public ResultList getFileList(GetFileListRequest getFileListRequest) throws ForbiddenException, TooManyRequestsException, - InternalServerException, UnauthorizedException, BadRequestException, UnknownException, IllegalAccessException, InstantiationException { - return restClient.getFileList(getFileListRequest); - } - - /** - * - * @param fileId is a unique file id - * @return Result class - */ - public Result getFileDetail(String fileId) throws ForbiddenException, TooManyRequestsException, - InternalServerException, UnauthorizedException, BadRequestException, UnknownException { - return restClient.getFileDetail(fileId); - } - - /** - * - * @param fileId is a unique file id - * @return ResultMetaData class - */ - public ResultMetaData getFileMetadata(String fileId) throws ForbiddenException, TooManyRequestsException, - InternalServerException, UnauthorizedException, BadRequestException, UnknownException { - return restClient.getFileMetaData(fileId); - } - - /** - * - * @param url is a remote image url - * @return ResultMetaData class - */ - public ResultMetaData getRemoteFileMetadata(String url) throws ForbiddenException, TooManyRequestsException, - InternalServerException, UnauthorizedException, BadRequestException, UnknownException { - return restClient.getRemoteFileMetaData(url); - } - - /** - * - * @param fileId is a unique file id - * @return Result class - */ - public Result deleteFile(String fileId) throws ForbiddenException, TooManyRequestsException, - InternalServerException, UnauthorizedException, BadRequestException, UnknownException { - return restClient.deleteFile(fileId); - } - - /** - * - * @param fileIds is a list of unique file id - * @return Result class - */ - public ResultFileDelete bulkDeleteFiles(List fileIds) - throws ForbiddenException, TooManyRequestsException, InternalServerException, PartialSuccessException, - UnauthorizedException, NotFoundException, BadRequestException, UnknownException { - return restClient.bulkDeleteFiles(fileIds); - } - - /** - * - * @param url is image url - * @return ResultCache class - */ - public ResultCache purgeCache(String url) throws ForbiddenException, TooManyRequestsException, - InternalServerException, UnauthorizedException, BadRequestException, UnknownException { - return restClient.purgeCache(url); - } - - /** - * - * @param requestId is cache request id - * @return ResultCacheStatus class - */ - public ResultCacheStatus getPurgeCacheStatus(String requestId) throws ForbiddenException, TooManyRequestsException, - InternalServerException, UnauthorizedException, BadRequestException, UnknownException { - return restClient.getPurgeCacheStatus(requestId); - } - - /** - * - * @return a map that contains token, expire and signature - */ - public Map getAuthenticationParameters() { - return Calculation.getAuthenticatedParams(null, 0, configuration.getPrivateKey()); - } - - /** - * - * @param token take as a argument - * @return a map that contains token, expire and signature - */ - public Map getAuthenticationParameters(String token) { - return Calculation.getAuthenticatedParams(token, 0, configuration.getPrivateKey()); - } - - /** - * - * @param token take as first argument - * @param expire is a Timestamp in milliseconds take as second argument - * @return a map that contains token, expire and signature - */ - public Map getAuthenticationParameters(String token, long expire) { - return Calculation.getAuthenticatedParams(token, expire, configuration.getPrivateKey()); - } - - /** - * firstHex and secondHex must have equal length - * - * @param firstHex take Hex as a String argument - * @param secondHex take Hex as a String argument - * @return it's distance - */ - public int pHashDistance(String firstHex, String secondHex) { - return Calculation.getHammingDistance(firstHex, secondHex); - } - - /** - * - * @param tagsRequest is a object which contains fileIds and tags as a - * parameters - * @return ArrayList of String - */ - public ResultTags addTags(TagsRequest tagsRequest) - throws NotFoundException, PartialSuccessException, BadRequestException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - return restClient.manageTags(tagsRequest, "addTags"); - } - - /** - * - * @param aiTagsRequest is a object which contains fileIds and tags as a - * parameters - * @return ArrayList of String - */ - public ResultTags removeAITags(AITagsRequest aiTagsRequest) - throws PartialSuccessException, NotFoundException, BadRequestException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - return restClient.removeAITags(aiTagsRequest); - } - - /** - * - * @param tagsRequest is a object which contains fileIds and tags as a - * parameters - * @return ArrayList of String - */ - public ResultTags removeTags(TagsRequest tagsRequest) - throws NotFoundException, PartialSuccessException, BadRequestException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - return restClient.manageTags(tagsRequest, "removeTags"); - } - - /** - * - * @return a CustomMetaDataResultList that contains CustomMetaDataField's name, - * label, schema - */ - public ResultCustomMetaDataFieldList getCustomMetaDataFields(boolean includeDeleted) throws UnknownException { - return restClient.getCustomMetaDataFields(includeDeleted); - } - - /** - * - * @param customMetaDataFieldCreateRequest that contains CustomMetaDataField's - * name, label, schema with type, - * minLength, maxLength - * @return ResultCustomMetaData with ResultCustomMetaDataField - */ - public ResultCustomMetaDataField createCustomMetaDataFields( - CustomMetaDataFieldCreateRequest customMetaDataFieldCreateRequest) - throws BadRequestException, UnknownException { - return restClient.createCustomMetaDataFields(customMetaDataFieldCreateRequest); - } - - /** - * - * @param id is a id of customMetaDataFields - * @return Result class - */ - public ResultNoContent deleteCustomMetaDataField(String id) throws NotFoundException, UnknownException { - return restClient.deleteCustomMetaDataField(id); - } - - /** - * - * @param customMetaDataFieldUpdateRequest that contains CustomMetaDataField's - * id, schema with type, minLength, - * maxLength - * @return Result class - */ - public ResultCustomMetaDataField updateCustomMetaDataFields( - CustomMetaDataFieldUpdateRequest customMetaDataFieldUpdateRequest) - throws BadRequestException, NotFoundException, UnknownException { - return restClient.updateCustomMetaDataFields(customMetaDataFieldUpdateRequest); - } - - /** - * - * @param deleteFileVersionRequest class - * @return Result class - */ - public ResultNoContent deleteFileVersion(DeleteFileVersionRequest deleteFileVersionRequest) - throws BadRequestException, NotFoundException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - return restClient.deleteFileVersion(deleteFileVersionRequest); - } - - /** - * - * @param copyFileRequest class - * @return Result class - */ - public ResultNoContent copyFile(CopyFileRequest copyFileRequest) - throws NotFoundException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - return restClient.copyFile(copyFileRequest); - } - - /** - * - * @param moveFileRequest class - * @return Result class - */ - public ResultNoContent moveFile(MoveFileRequest moveFileRequest) - throws NotFoundException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - return restClient.moveFile(moveFileRequest); - } - - /** - * - * @param renameFileRequest class - * @return Result class - */ - public ResultRenameFile renameFile(RenameFileRequest renameFileRequest) throws ConflictException, - PartialSuccessException, NotFoundException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - return restClient.renameFile(renameFileRequest); - } - - /** - * - * @param fileId & versionId - * @return a Result class - */ - public Result restoreFileVersion(String fileId, String versionId) - throws NotFoundException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - return restClient.restoreFileVersion(fileId, versionId); - } - - /** - * - * @param createFolderRequest which contains folderPath that is full path to the - * folder you want to delete - * @return Result class - */ - public ResultEmptyBlock createFolder(CreateFolderRequest createFolderRequest) throws UnknownException { - return restClient.createFolder(createFolderRequest); - } - - /** - * - * @param deleteFolderRequest which contains folderPath that is full path to the - * folder you want to delete - * @return Result class - */ - public ResultNoContent deleteFolder(DeleteFolderRequest deleteFolderRequest) - throws NotFoundException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - return restClient.deleteFolder(deleteFolderRequest); - } - - /** - * - * @param copyFolderRequest that contains sourceFolderPath, destinationPath, - * includeFileVersions - * @return Result class - */ - public ResultOfFolderActions copyFolder(CopyFolderRequest copyFolderRequest) - throws NotFoundException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - return restClient.copyFolder(copyFolderRequest); - } - - /** - * - * @param moveFolderRequest that contains sourceFolderPath, destinationPath - * @return Result class - */ - public ResultOfFolderActions moveFolder(MoveFolderRequest moveFolderRequest) - throws NotFoundException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - return restClient.moveFolder(moveFolderRequest); - } - - /** - * - * @param jobId - * @return a Result class - */ - public ResultBulkJobStatus getBulkJobStatus(String jobId) throws ForbiddenException, TooManyRequestsException, - InternalServerException, UnauthorizedException, BadRequestException, UnknownException { - return restClient.getBulkJobStatus(jobId); - } - - /** - * - * @param fileId - * @return a Result class - */ - public ResultFileVersions getFileVersions(String fileId) - throws NotFoundException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - return restClient.getFileVersions(fileId); - } - - /** - * - * @param fileId & versionId - * @return a Result class - */ - public ResultFileVersionDetails getFileVersionDetails(String fileId, String versionId) - throws NotFoundException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - return restClient.getFileVersionDetails(fileId, versionId); - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/config/Configuration.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/config/Configuration.java deleted file mode 100644 index 4ff6c7c9..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/config/Configuration.java +++ /dev/null @@ -1,63 +0,0 @@ -package io.imagekit.sdk.config; - -/** - * Configuration class contains sdk configuration - */ -public class Configuration { - private String publicKey; - private String privateKey; - private String urlEndpoint; - - public Configuration() { - - } - - public Configuration(String publicKey, String privateKey, String urlEndpoint) { - this.publicKey = publicKey; - this.privateKey = privateKey; - this.urlEndpoint = urlEndpoint; - } - - public String getPublicKey() { - return publicKey; - } - - public void setPublicKey(String publicKey) { - this.publicKey = publicKey; - } - - public String getPrivateKey() { - return privateKey; - } - - public void setPrivateKey(String privateKey) { - this.privateKey = privateKey; - } - - public String getUrlEndpoint() { - return urlEndpoint; - } - - public void setUrlEndpoint(String urlEndpoint) { - this.urlEndpoint = urlEndpoint; - } - - @Override - public String toString() { - return "Configuration{" + "publicKey='" + publicKey + '\'' + ", privateKey='" + privateKey + '\'' - + ", urlEndpoint='" + urlEndpoint + '\'' + '}'; - } - - public boolean validate() { - if (urlEndpoint == null) { - throw new RuntimeException("UrlEndpoint not found in config.properties"); - } - if (privateKey == null) { - throw new RuntimeException("PrivateKey not found in config.properties"); - } - if (publicKey == null) { - throw new RuntimeException("PublicKey not found in config.properties"); - } - return true; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/constants/Transformer.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/constants/Transformer.java deleted file mode 100644 index 6e1ebc5e..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/constants/Transformer.java +++ /dev/null @@ -1,86 +0,0 @@ -package io.imagekit.sdk.constants; - -import java.util.HashMap; -import java.util.Map; - -public class Transformer { - - private Map trans = new HashMap<>(); - private static Transformer transformer; - - public static synchronized Transformer getInstance() { - if (null != transformer) { - return transformer; - } - transformer = new Transformer(); - - transformer.trans.put("height", "h"); - transformer.trans.put("width", "w"); - transformer.trans.put("aspectRatio", "ar"); - transformer.trans.put("quality", "q"); - transformer.trans.put("crop", "c"); - transformer.trans.put("cropMode", "cm"); - transformer.trans.put("x", "x"); - transformer.trans.put("y", "y"); - transformer.trans.put("focus", "fo"); - transformer.trans.put("format", "f"); - transformer.trans.put("radius", "r"); - transformer.trans.put("background", "bg"); - transformer.trans.put("border", "b"); - transformer.trans.put("rotation", "rt"); - transformer.trans.put("blur", "bl"); - transformer.trans.put("named", "n"); - transformer.trans.put("overlayX", "ox"); - transformer.trans.put("overlayY", "oy"); - transformer.trans.put("overlayFocus", "ofo"); - transformer.trans.put("overlayHeight", "oh"); - transformer.trans.put("overlayWidth", "ow"); - transformer.trans.put("overlayImage", "oi"); - transformer.trans.put("overlayImageTrim", "oit"); - transformer.trans.put("overlayImageAspectRatio", "oiar"); - transformer.trans.put("overlayImageBackground", "oibg"); - transformer.trans.put("overlayImageBorder", "oib"); - transformer.trans.put("overlayImageDPR", "oidpr"); - transformer.trans.put("overlayImageQuality", "oiq"); - transformer.trans.put("overlayImageCropping", "oic"); - transformer.trans.put("overlayImageFocus", "oifo"); - transformer.trans.put("overlayText", "ot"); - transformer.trans.put("overlayTextFontSize", "ots"); - transformer.trans.put("overlayTextFontFamily", "otf"); - transformer.trans.put("overlayTextColor", "otc"); - transformer.trans.put("overlayTextTransparency", "oa"); - transformer.trans.put("overlayAlpha", "oa"); - transformer.trans.put("overlayTextTypography", "ott"); - transformer.trans.put("overlayBackground", "obg"); - transformer.trans.put("overlayTextEncoded", "ote"); - transformer.trans.put("overlayTextWidth", "otw"); - transformer.trans.put("overlayTextBackground", "otbg"); - transformer.trans.put("overlayTextPadding", "otp"); - transformer.trans.put("overlayTextInnerAlignment", "otia"); - transformer.trans.put("overlayRadius", "or"); - transformer.trans.put("progressive", "pr"); - transformer.trans.put("lossless", "lo"); - transformer.trans.put("trim", "t"); - transformer.trans.put("metadata", "md"); - transformer.trans.put("colorProfile", "cp"); - transformer.trans.put("defaultImage", "di"); - transformer.trans.put("dpr", "dpr"); - transformer.trans.put("effectSharpen", "e-sharpen"); - transformer.trans.put("effectUSM", "e-usm"); - transformer.trans.put("effectContrast", "e-contrast"); - transformer.trans.put("effectGray", "e-grayscale"); - transformer.trans.put("original", "orig"); - transformer.trans.put("raw", "raw"); - - return transformer; - } - - private Transformer() { - - } - - public String transform(String key) { - return this.trans.get(key) != null ? this.trans.get(key) : key; - } - -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/constants/Version.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/constants/Version.java deleted file mode 100644 index 1a6cbcce..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/constants/Version.java +++ /dev/null @@ -1,5 +0,0 @@ -package io.imagekit.sdk.constants; - -public class Version { - public static final String VERSION_CODE="java-2.0.1"; -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/BadRequestException.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/BadRequestException.java deleted file mode 100644 index ccaa72db..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/BadRequestException.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.imagekit.sdk.exceptions; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class BadRequestException extends Exception { - - private String message; - private String help; - private ResponseMetaData responseMetaData; - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - public BadRequestException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, - String message1, String help, ResponseMetaData responseMetaData) { - super(message, cause, enableSuppression, writableStackTrace); - this.message = message1; - this.help = help; - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "BadRequestException{" + "message='" + message + '\'' + ", help='" + help + '\'' + ", responseMetaData=" - + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/ConflictException.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/ConflictException.java deleted file mode 100644 index 2734bab5..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/ConflictException.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.imagekit.sdk.exceptions; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class ConflictException extends Exception { - - private String message; - private String help; - private ResponseMetaData responseMetaData; - - public ConflictException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, - String message1, String help, ResponseMetaData responseMetaData) { - super(message, cause, enableSuppression, writableStackTrace); - this.message = message1; - this.help = help; - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "ConflictException{" + "message='" + message + '\'' + ", help='" + help + '\'' + ", responseMetaData=" - + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/ForbiddenException.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/ForbiddenException.java deleted file mode 100644 index eb73cf69..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/ForbiddenException.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.imagekit.sdk.exceptions; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class ForbiddenException extends Exception { - - private String message; - private String help; - private ResponseMetaData responseMetaData; - - public ForbiddenException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, - String message1, String help, ResponseMetaData responseMetaData) { - super(message, cause, enableSuppression, writableStackTrace); - this.message = message1; - this.help = help; - this.responseMetaData = responseMetaData; - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "ForbiddenException{" + "message='" + message + '\'' + ", help='" + help + '\'' + ", responseMetaData=" - + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/InternalServerException.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/InternalServerException.java deleted file mode 100644 index 938c4640..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/InternalServerException.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.imagekit.sdk.exceptions; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class InternalServerException extends Exception { - - private String message; - private String help; - private ResponseMetaData responseMetaData; - - public InternalServerException(String message, Throwable cause, boolean enableSuppression, - boolean writableStackTrace, String message1, String help, ResponseMetaData responseMetaData) { - super(message, cause, enableSuppression, writableStackTrace); - this.message = message1; - this.help = help; - this.responseMetaData = responseMetaData; - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "InternalServerException{" + "message='" + message + '\'' + ", help='" + help + '\'' - + ", responseMetaData=" + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/NotFoundException.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/NotFoundException.java deleted file mode 100644 index a3b446c3..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/NotFoundException.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.imagekit.sdk.exceptions; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class NotFoundException extends Exception { - - private String message; - private String help; - private ResponseMetaData responseMetaData; - - public NotFoundException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, - String message1, String help, ResponseMetaData responseMetaData) { - super(message, cause, enableSuppression, writableStackTrace); - this.message = message1; - this.help = help; - this.responseMetaData = responseMetaData; - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "NotFoundException{" + "message='" + message + '\'' + ", help='" + help + '\'' + ", responseMetaData=" - + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/PartialSuccessException.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/PartialSuccessException.java deleted file mode 100644 index 22e318cf..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/PartialSuccessException.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.imagekit.sdk.exceptions; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class PartialSuccessException extends Exception { - - private String message; - private String help; - private ResponseMetaData responseMetaData; - - public PartialSuccessException(String message, Throwable cause, boolean enableSuppression, - boolean writableStackTrace, String message1, String help, ResponseMetaData responseMetaData) { - super(message, cause, enableSuppression, writableStackTrace); - this.message = message1; - this.help = help; - this.responseMetaData = responseMetaData; - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "PartialSuccessException{" + "message='" + message + '\'' + ", help='" + help + '\'' - + ", responseMetaData=" + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/TooManyRequestsException.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/TooManyRequestsException.java deleted file mode 100644 index fcdf8370..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/TooManyRequestsException.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.imagekit.sdk.exceptions; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class TooManyRequestsException extends Exception { - - private String message; - private String help; - private ResponseMetaData responseMetaData; - - public TooManyRequestsException(String message, Throwable cause, boolean enableSuppression, - boolean writableStackTrace, String message1, String help, ResponseMetaData responseMetaData) { - super(message, cause, enableSuppression, writableStackTrace); - this.message = message1; - this.help = help; - this.responseMetaData = responseMetaData; - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "TooManyRequestsException{" + "message='" + message + '\'' + ", help='" + help + '\'' - + ", responseMetaData=" + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/UnauthorizedException.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/UnauthorizedException.java deleted file mode 100644 index e785dab6..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/UnauthorizedException.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.imagekit.sdk.exceptions; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class UnauthorizedException extends Exception { - - private String message; - private String help; - private ResponseMetaData responseMetaData; - - public UnauthorizedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, - String message1, String help, ResponseMetaData responseMetaData) { - super(message, cause, enableSuppression, writableStackTrace); - this.message = message1; - this.help = help; - this.responseMetaData = responseMetaData; - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "UnauthorizedException{" + "message='" + message + '\'' + ", help='" + help + '\'' - + ", responseMetaData=" + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/UnknownException.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/UnknownException.java deleted file mode 100644 index 0a9a1f1c..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/exceptions/UnknownException.java +++ /dev/null @@ -1,36 +0,0 @@ -package io.imagekit.sdk.exceptions; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class UnknownException extends Exception { - - private String message; - private String help; - private ResponseMetaData responseMetaData; - - public UnknownException(String message, Throwable cause) { - super(message, cause); - } - - public UnknownException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, - String message1, String help, ResponseMetaData responseMetaData) { - super(message, cause, enableSuppression, writableStackTrace); - this.message = message1; - this.help = help; - this.responseMetaData = responseMetaData; - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "UnknownException{" + "message='" + message + '\'' + ", help='" + help + '\'' + ", responseMetaData=" - + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/AITagsRequest.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/AITagsRequest.java deleted file mode 100644 index fb2c714c..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/AITagsRequest.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.imagekit.sdk.models; - -import java.util.List; - -public class AITagsRequest { - public List fileIds; - public List AITags; - - public List getFileIds() { - return fileIds; - } - - public void setFileIds(List fileIds) { - this.fileIds = fileIds; - } - - public List getAITags() { - return AITags; - } - - public void setAITags(List AITags) { - this.AITags = AITags; - } - - @Override - public String toString() { - return "AITagsRequest{" + "fileIds=" + fileIds + ", AITags=" + AITags + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/BaseFile.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/BaseFile.java deleted file mode 100644 index 3161e5f8..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/BaseFile.java +++ /dev/null @@ -1,253 +0,0 @@ -package io.imagekit.sdk.models; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; - -import java.util.Date; -import java.util.List; - -public class BaseFile { - protected String fileId; - protected String name; - protected String url; - protected String thumbnail; - protected int height; - protected int width; - protected long size; - protected String filePath; - protected List tags; - protected boolean isPrivateFile; - protected String customCoordinates; - protected String fileType; - protected JsonArray aiTags; - protected JsonElement versionInfo; - protected JsonElement customMetadata; - - protected JsonElement embeddedMetadata; - protected JsonElement extensionStatus; - protected String type; - protected String mime; - protected Boolean hasAlpha; - protected Date createdAt; - protected Date updatedAt; - - public BaseFile() { - } - - public BaseFile(String fileId, String name, String url, String thumbnail, int height, int width, long size, - String filePath, List tags, boolean isPrivateFile, String customCoordinates, String fileType, - JsonArray aiTags, JsonElement versionInfo, JsonElement customMetadata, JsonElement embeddedMetadata, - JsonElement extensionStatus, String type, String mime, Boolean hasAlpha, Date createdAt, Date updatedAt) { - this.fileId = fileId; - this.name = name; - this.url = url; - this.thumbnail = thumbnail; - this.height = height; - this.width = width; - this.size = size; - this.filePath = filePath; - this.tags = tags; - this.isPrivateFile = isPrivateFile; - this.customCoordinates = customCoordinates; - this.fileType = fileType; - this.aiTags = aiTags; - this.versionInfo = versionInfo; - this.customMetadata = customMetadata; - this.embeddedMetadata = embeddedMetadata; - this.extensionStatus = extensionStatus; - this.type = type; - this.mime = mime; - this.hasAlpha = hasAlpha; - this.createdAt = createdAt; - this.updatedAt = updatedAt; - } - - public String getFileId() { - return fileId; - } - - public void setFileId(String fileId) { - this.fileId = fileId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getThumbnail() { - return thumbnail; - } - - public void setThumbnail(String thumbnail) { - this.thumbnail = thumbnail; - } - - public int getHeight() { - return height; - } - - public void setHeight(int height) { - this.height = height; - } - - public int getWidth() { - return width; - } - - public void setWidth(int width) { - this.width = width; - } - - public long getSize() { - return size; - } - - public void setSize(long size) { - this.size = size; - } - - public String getFilePath() { - return filePath; - } - - public void setFilePath(String filePath) { - this.filePath = filePath; - } - - public List getTags() { - return tags; - } - - public void setTags(List tags) { - this.tags = tags; - } - - public boolean isPrivateFile() { - return isPrivateFile; - } - - public void setPrivateFile(boolean privateFile) { - isPrivateFile = privateFile; - } - - public String getCustomCoordinates() { - return customCoordinates; - } - - public void setCustomCoordinates(String customCoordinates) { - this.customCoordinates = customCoordinates; - } - - public String getFileType() { - return fileType; - } - - public void setFileType(String fileType) { - this.fileType = fileType; - } - - public JsonArray getAiTags() { - return aiTags; - } - - public void setAiTags(JsonArray aiTags) { - this.aiTags = aiTags; - } - - public JsonElement getVersionInfo() { - return versionInfo; - } - - public void setVersionInfo(JsonElement versionInfo) { - this.versionInfo = versionInfo; - } - - public JsonElement getCustomMetadata() { - return customMetadata; - } - - public void setCustomMetadata(JsonElement customMetadata) { - this.customMetadata = customMetadata; - } - - public JsonElement getEmbeddedMetadata() { - return embeddedMetadata; - } - - public void setEmbeddedMetadata(JsonElement embeddedMetadata) { - this.embeddedMetadata = embeddedMetadata; - } - - public JsonElement getExtensionStatus() { - return extensionStatus; - } - - public void setExtensionStatus(JsonElement extensionStatus) { - this.extensionStatus = extensionStatus; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getMime() { - return mime; - } - - public void setMime(String mime) { - this.mime = mime; - } - - public Boolean getHasAlpha() { - return hasAlpha; - } - - public void setHasAlpha(Boolean hasAlpha) { - this.hasAlpha = hasAlpha; - } - - public Date getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } - - public Date getUpdatedAt() { - return updatedAt; - } - - public void setUpdatedAt(Date updatedAt) { - this.updatedAt = updatedAt; - } - - @Override - public String toString() { - return "BaseFile{" + "fileId='" + fileId + '\'' + ", name='" + name + '\'' + ", url='" + url + '\'' - + ", thumbnail='" + thumbnail + '\'' + ", height=" + height + ", width=" + width + ", size=" + size - + ", filePath='" + filePath + '\'' + ", tags='" + tags + '\'' + ", isPrivateFile=" + isPrivateFile - + ", customCoordinates='" + customCoordinates + '\'' + ", fileType='" + fileType + '\'' + ", aiTags=" - + aiTags + ", versionInfo=" + versionInfo + ", customMetadata=" + customMetadata + ", embeddedMetadata=" - + embeddedMetadata + ", extensionStatus=" + extensionStatus + ", type='" + type + '\'' + ", mime='" - + mime + '\'' + ", hasAlpha=" + hasAlpha + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt - + '}'; - } - -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/CopyFileRequest.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/CopyFileRequest.java deleted file mode 100644 index b915ce1d..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/CopyFileRequest.java +++ /dev/null @@ -1,37 +0,0 @@ -package io.imagekit.sdk.models; - -public class CopyFileRequest { - public String sourceFilePath; - public String destinationPath; - public Boolean includeFileVersions; - - public String getSourceFilePath() { - return sourceFilePath; - } - - public void setSourceFilePath(String sourceFilePath) { - this.sourceFilePath = sourceFilePath; - } - - public String getDestinationPath() { - return destinationPath; - } - - public void setDestinationPath(String destinationPath) { - this.destinationPath = destinationPath; - } - - public Boolean getIncludeFileVersions() { - return includeFileVersions; - } - - public void setIncludeFileVersions(Boolean includeFileVersions) { - this.includeFileVersions = includeFileVersions; - } - - @Override - public String toString() { - return "CopyFileRequest{" + "sourceFilePath=" + sourceFilePath + ", destinationPath=" + destinationPath - + ", includeFileVersions=" + includeFileVersions + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/CopyFolderRequest.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/CopyFolderRequest.java deleted file mode 100644 index 0938fd50..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/CopyFolderRequest.java +++ /dev/null @@ -1,37 +0,0 @@ -package io.imagekit.sdk.models; - -public class CopyFolderRequest { - public String sourceFolderPath; - public String destinationPath; - public Boolean includeFileVersions; - - public String getSourceFolderPath() { - return sourceFolderPath; - } - - public void setSourceFolderPath(String sourceFolderPath) { - this.sourceFolderPath = sourceFolderPath; - } - - public String getDestinationPath() { - return destinationPath; - } - - public void setDestinationPath(String destinationPath) { - this.destinationPath = destinationPath; - } - - public Boolean getIncludeFileVersions() { - return includeFileVersions; - } - - public void setIncludeFileVersions(Boolean includeFileVersions) { - this.includeFileVersions = includeFileVersions; - } - - @Override - public String toString() { - return "CopyFolderRequest{" + "sourceFolderPath=" + sourceFolderPath + ", destinationPath=" + destinationPath - + ", includeFileVersions=" + includeFileVersions + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/CreateFolderRequest.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/CreateFolderRequest.java deleted file mode 100644 index 077d8d2c..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/CreateFolderRequest.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.imagekit.sdk.models; - -public class CreateFolderRequest { - public String folderName; - public String parentFolderPath; - - public String getFolderName() { - return folderName; - } - - public void setFolderName(String folderName) { - this.folderName = folderName; - } - - public String getParentFolderPath() { - return parentFolderPath; - } - - public void setParentFolderPath(String parentFolderPath) { - this.parentFolderPath = parentFolderPath; - } - - @Override - public String toString() { - return "DeleteFolderRequest{" + "folderName=" + folderName + "parentFolderPath=" + parentFolderPath + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/CustomMetaDataFieldCreateRequest.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/CustomMetaDataFieldCreateRequest.java deleted file mode 100644 index fc6d3a0b..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/CustomMetaDataFieldCreateRequest.java +++ /dev/null @@ -1,41 +0,0 @@ -package io.imagekit.sdk.models; - -public class CustomMetaDataFieldCreateRequest { - private String name; - private String label; - private CustomMetaDataFieldSchemaObject schema = new CustomMetaDataFieldSchemaObject(); - - public CustomMetaDataFieldCreateRequest() { - - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public CustomMetaDataFieldSchemaObject getSchema() { - return schema; - } - - public void setSchema(CustomMetaDataFieldSchemaObject schema) { - this.schema = schema; - } - - @Override - public String toString() { - return "CustomMetaDataFieldRequest{" + "name=" + '"' + name + '"' + ", label=" + '"' + label + '"' + ", schema=" - + schema + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/CustomMetaDataFieldSchemaObject.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/CustomMetaDataFieldSchemaObject.java deleted file mode 100644 index dc5b98f5..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/CustomMetaDataFieldSchemaObject.java +++ /dev/null @@ -1,94 +0,0 @@ -package io.imagekit.sdk.models; - -public class CustomMetaDataFieldSchemaObject { - private CustomMetaDataTypeEnum type; - private Object selectOptions; - private Object defaultValue; - private Boolean isValueRequired; - private Object minValue; - private Object maxValue; - private Integer minLength; - private Integer maxLength; - - public CustomMetaDataFieldSchemaObject() { - - } - - public CustomMetaDataTypeEnum getType() { - return type; - } - - public void setType(CustomMetaDataTypeEnum type) { - this.type = type; - } - - public Object getSelectOptions() { - return selectOptions; - } - - public void setSelectOptions(Object selectOptions) { - this.selectOptions = selectOptions; - } - - public Object getDefaultValue() { - return defaultValue; - } - - public void setDefaultValue(Object defaultValue) { - this.defaultValue = defaultValue; - } - - public Boolean getValueRequired() { - return isValueRequired; - } - - public void setValueRequired(Boolean valueRequired) { - isValueRequired = valueRequired; - } - - public Object getMinValue() { - return minValue; - } - - public void setMinValue(Object minValue) { - this.minValue = minValue; - } - - public Object getMaxValue() { - return maxValue; - } - - public void setMaxValue(Object maxValue) { - this.maxValue = maxValue; - } - - public Integer getMinLength() { - return minLength; - } - - public void setMinLength(Integer minLength) { - this.minLength = minLength; - } - - public Integer getMaxLength() { - return maxLength; - } - - public void setMaxLength(Integer maxLength) { - this.maxLength = maxLength; - } - - @Override - public String toString() { - return "CustomMetaDataFieldSchemaObject{" + - "type=" + type + - ", selectOptions=" + selectOptions + - ", defaultValue=" + defaultValue + - ", isValueRequired=" + isValueRequired + - ", minValue=" + minValue + - ", maxValue=" + maxValue + - ", minLength=" + minLength + - ", maxLength=" + maxLength + - '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/CustomMetaDataFieldUpdateRequest.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/CustomMetaDataFieldUpdateRequest.java deleted file mode 100644 index 6945a8e8..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/CustomMetaDataFieldUpdateRequest.java +++ /dev/null @@ -1,41 +0,0 @@ -package io.imagekit.sdk.models; - -public class CustomMetaDataFieldUpdateRequest { - private String id; - private String label; - private CustomMetaDataFieldSchemaObject schema = new CustomMetaDataFieldSchemaObject(); - - public CustomMetaDataFieldUpdateRequest() { - - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public CustomMetaDataFieldSchemaObject getSchema() { - return schema; - } - - public void setSchema(CustomMetaDataFieldSchemaObject schema) { - this.schema = schema; - } - - @Override - public String toString() { - return "CustomMetaDataFieldRequest{" + "id=" + '"' + id + '"' + ", label=" + '"' + label + '"' + ", schema=" - + schema + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/CustomMetaDataTypeEnum.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/CustomMetaDataTypeEnum.java deleted file mode 100644 index 97c0e247..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/CustomMetaDataTypeEnum.java +++ /dev/null @@ -1,5 +0,0 @@ -package io.imagekit.sdk.models; -public enum CustomMetaDataTypeEnum { - Text, Textarea, Number, Date, Boolean, SingleSelect, MultiSelect; - -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/DeleteFileVersionRequest.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/DeleteFileVersionRequest.java deleted file mode 100644 index 8b5b3e32..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/DeleteFileVersionRequest.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.imagekit.sdk.models; - -public class DeleteFileVersionRequest { - public String fileId; - public String versionId; - - public String getFileId() { - return fileId; - } - - public void setFileId(String fileId) { - this.fileId = fileId; - } - - public String getVersionId() { - return versionId; - } - - public void setVersionId(String versionId) { - this.versionId = versionId; - } - - @Override - public String toString() { - return "DeleteFileVersionRequest{" + "fileId='" + fileId + '\'' + ", versionId='" + versionId + '\'' + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/DeleteFolderRequest.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/DeleteFolderRequest.java deleted file mode 100644 index 2447fdf3..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/DeleteFolderRequest.java +++ /dev/null @@ -1,18 +0,0 @@ -package io.imagekit.sdk.models; - -public class DeleteFolderRequest { - public String folderPath; - - public String getFolderPath() { - return folderPath; - } - - public void setFolderPath(String folderPath) { - this.folderPath = folderPath; - } - - @Override - public String toString() { - return "DeleteFolderRequest{" + "folderPath=" + folderPath + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/FileCreateRequest.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/FileCreateRequest.java deleted file mode 100644 index 4b39425d..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/FileCreateRequest.java +++ /dev/null @@ -1,172 +0,0 @@ -package io.imagekit.sdk.models; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; - -import io.imagekit.sdk.utils.Utils; -import okhttp3.MediaType; -import okhttp3.MultipartBody; -import okhttp3.RequestBody; - -import java.net.URL; -import java.util.List; - -public class FileCreateRequest { - public URL url; - public String base64; - public byte[] bytes; - public String fileName; - public boolean useUniqueFileName; - public List tags; - public String folder; - public boolean isPrivateFile; - public String customCoordinates; - public List responseFields; - public JsonArray extensions; - public String webhookUrl; - public Boolean overwriteFile; - public Boolean overwriteAITags; - public Boolean overwriteTags; - public Boolean overwriteCustomMetadata; - public JsonObject customMetadata; - - public FileCreateRequest(URL url, String fileName) { - this.url = url; - this.fileName = fileName; - this.useUniqueFileName = true; - } - - public FileCreateRequest(String base64, String fileName) { - this.base64 = base64; - this.fileName = fileName; - this.useUniqueFileName = true; - } - - public FileCreateRequest(byte[] bytes, String fileName) { - this.bytes = bytes; - this.fileName = fileName; - this.useUniqueFileName = true; - } - - public String getFileName() { - return fileName; - } - - public void setFileName(String fileName) { - this.fileName = fileName; - } - - public boolean isUseUniqueFileName() { - return useUniqueFileName; - } - - public void setUseUniqueFileName(boolean useUniqueFileName) { - this.useUniqueFileName = useUniqueFileName; - } - - public List getTags() { - return tags; - } - - public void setTags(List tags) { - this.tags = tags; - } - - public String getFolder() { - return folder; - } - - public void setFolder(String folder) { - this.folder = folder; - } - - public boolean isPrivateFile() { - return isPrivateFile; - } - - public void setPrivateFile(boolean privateFile) { - isPrivateFile = privateFile; - } - - public String getCustomCoordinates() { - return customCoordinates; - } - - public void setCustomCoordinates(String customCoordinates) { - this.customCoordinates = customCoordinates; - } - - public List getResponseFields() { - return responseFields; - } - - public void setResponseFields(List responseFields) { - this.responseFields = responseFields; - } - - public JsonArray getExtensions() { - return extensions; - } - - public void setExtensions(JsonArray extensions) { - this.extensions = extensions; - } - - public String getWebhookUrl() { - return webhookUrl; - } - - public void setWebhookUrl(String webhookUrl) { - this.webhookUrl = webhookUrl; - } - - public Boolean isOverwriteFile() { - return overwriteFile; - } - - public void setOverwriteFile(Boolean overwriteFile) { - this.overwriteFile = overwriteFile; - } - - public Boolean isOverwriteAITags() { - return overwriteAITags; - } - - public void setOverwriteAITags(Boolean overwriteAITags) { - this.overwriteAITags = overwriteAITags; - } - - public Boolean isOverwriteTags() { - return overwriteTags; - } - - public void setOverwriteTags(Boolean overwriteTags) { - this.overwriteTags = overwriteTags; - } - - public Boolean isOverwriteCustomMetadata() { - return overwriteCustomMetadata; - } - - public void setOverwriteCustomMetadata(Boolean overwriteCustomMetadata) { - this.overwriteCustomMetadata = overwriteCustomMetadata; - } - - public JsonObject getCustomMetadata() { - return customMetadata; - } - - public void setCustomMetadata(JsonObject customMetadata) { - this.customMetadata = customMetadata; - } - - @Override - public String toString() { - return "FileCreateRequest{" + "fileName='" + fileName + '\'' + ", useUniqueFileName=" + useUniqueFileName - + ", tags=" + tags + ", folder='" + folder + '\'' + ", isPrivateFile=" + isPrivateFile - + ", customCoordinates=" + customCoordinates + ", responseFields=" + responseFields + ", extensions=" - + extensions + ", webhookUrl='" + webhookUrl + '\'' + ", overwriteFile=" + overwriteFile - + ", overwriteAITags=" + overwriteAITags + ", overwriteTags=" + overwriteTags - + ", overwriteCustomMetadata=" + overwriteCustomMetadata + ", customMetadata=" + customMetadata + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/FileUpdateRequest.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/FileUpdateRequest.java deleted file mode 100644 index a263657a..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/FileUpdateRequest.java +++ /dev/null @@ -1,93 +0,0 @@ -package io.imagekit.sdk.models; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; - -import java.util.List; - -public class FileUpdateRequest { - private String fileId; - public List removeAITags; - - public String webhookUrl; - - public JsonArray extensions; - - private List tags; - private String customCoordinates; - - public JsonObject customMetadata; - - public FileUpdateRequest(String fileId) { - this.fileId = fileId; - } - - public String getFileId() { - return fileId; - } - - public void setFileId(String fileId) { - this.fileId = fileId; - } - - public List getRemoveAITags() { - return removeAITags; - } - - public void setRemoveAITags(List removeAITags) { - this.removeAITags = removeAITags; - } - - public String getWebhookUrl() { - return webhookUrl; - } - - public void setWebhookUrl(String webhookUrl) { - this.webhookUrl = webhookUrl; - } - - public JsonArray getExtensions() { - return extensions; - } - - public void setExtensions(JsonArray extensions) { - this.extensions = extensions; - } - - public List getTags() { - return tags; - } - - public void setTags(List tags) { - this.tags = tags; - } - - public String getCustomCoordinates() { - return customCoordinates; - } - - public void setCustomCoordinates(String customCoordinates) { - this.customCoordinates = customCoordinates; - } - - public JsonObject getCustomMetadata() { - return customMetadata; - } - - public void setCustomMetadata(JsonObject customMetadata) { - this.customMetadata = customMetadata; - } - - @Override - public String toString() { - return "FileUpdateRequest{" + - "fileId='" + fileId + '\'' + - ", removeAITags=" + removeAITags + - ", webhookUrl='" + webhookUrl + '\'' + - ", extensions=" + extensions + - ", tags=" + tags + - ", customCoordinates='" + customCoordinates + '\'' + - ", customMetadata=" + customMetadata + - '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/GetFileListRequest.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/GetFileListRequest.java deleted file mode 100644 index 0727060f..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/GetFileListRequest.java +++ /dev/null @@ -1,92 +0,0 @@ -package io.imagekit.sdk.models; - -import java.util.Arrays; - -public class GetFileListRequest { - public String type; - public String sort; - public String path; - public String searchQuery; - public String fileType; - public String limit; - public String skip; - public String[] tags; - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getSort() { - return sort; - } - - public void setSort(String sort) { - this.sort = sort; - } - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - public String getSearchQuery() { - return searchQuery; - } - - public void setSearchQuery(String searchQuery) { - this.searchQuery = searchQuery; - } - - public String getFileType() { - return fileType; - } - - public void setFileType(String fileType) { - this.fileType = fileType; - } - - public String getLimit() { - return limit; - } - - public void setLimit(String limit) { - this.limit = limit; - } - - public String getSkip() { - return skip; - } - - public void setSkip(String skip) { - this.skip = skip; - } - - public String[] getTags() { - return tags; - } - - public void setTags(String[] tags) { - this.tags = tags; - } - - @Override - public String toString() { - return "GetFileListRequest{" + - "type='" + type + '\'' + - ", sort='" + sort + '\'' + - ", path='" + path + '\'' + - ", searchQuery='" + searchQuery + '\'' + - ", fileType='" + fileType + '\'' + - ", limit='" + limit + '\'' + - ", skip='" + skip + '\'' + - ", tags=" + Arrays.toString(tags) + - '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/MetaData.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/MetaData.java deleted file mode 100644 index dd2603a7..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/MetaData.java +++ /dev/null @@ -1,731 +0,0 @@ -package io.imagekit.sdk.models; - -import com.google.gson.JsonObject; - -import java.util.List; - -public class MetaData { - private float height; - private float width; - private float size; - private String format; - private boolean hasColorProfile; - private float quality; - private float density; - private boolean hasTransparency; - private String pHash; - EXIFObject exif; - - - // Getter Methods - - public float getHeight() { - return height; - } - - public float getWidth() { - return width; - } - - public float getSize() { - return size; - } - - public String getFormat() { - return format; - } - - public boolean getHasColorProfile() { - return hasColorProfile; - } - - public float getQuality() { - return quality; - } - - public float getDensity() { - return density; - } - - public boolean getHasTransparency() { - return hasTransparency; - } - - public String getPHash() { - return pHash; - } - - public EXIFObject getExif() { - return exif; - } - - // Setter Methods - - public void setHeight(float height) { - this.height = height; - } - - public void setWidth(float width) { - this.width = width; - } - - public void setSize(float size) { - this.size = size; - } - - public void setFormat(String format) { - this.format = format; - } - - public void setHasColorProfile(boolean hasColorProfile) { - this.hasColorProfile = hasColorProfile; - } - - public void setQuality(float quality) { - this.quality = quality; - } - - public void setDensity(float density) { - this.density = density; - } - - public void setHasTransparency(boolean hasTransparency) { - this.hasTransparency = hasTransparency; - } - - public void setPHash(String pHash) { - this.pHash = pHash; - } - - public void setExif(EXIFObject exifObject) { - this.exif = exifObject; - } - - @Override - public String toString() { - return "MetaData{" + - "height=" + height + - ", width=" + width + - ", size=" + size + - ", format='" + format + '\'' + - ", hasColorProfile=" + hasColorProfile + - ", quality=" + quality + - ", density=" + density + - ", hasTransparency=" + hasTransparency + - ", pHash='" + pHash + '\'' + - ", EXIF=" + exif + - '}'; - } - - public class EXIFObject { - private ImageObject image; - private Thumbnail thumbnail; - private Exif exif; - private GPS gps; - private Interoperability interoperability; - private JsonObject makernote; - - public EXIFObject() { - } - - public ImageObject getImage() { - return image; - } - - public void setImage(ImageObject image) { - this.image = image; - } - - public Thumbnail getThumbnail() { - return thumbnail; - } - - public void setThumbnail(Thumbnail thumbnail) { - this.thumbnail = thumbnail; - } - - public Exif getExif() { - return exif; - } - - public void setExif(Exif exif) { - this.exif = exif; - } - - public GPS getGps() { - return gps; - } - - public void setGps(GPS gps) { - this.gps = gps; - } - - public Interoperability getInteroperability() { - return interoperability; - } - - public void setInteroperability(Interoperability interoperability) { - this.interoperability = interoperability; - } - - public JsonObject getMakernote() { - return makernote; - } - - public void setMakernote(JsonObject makernote) { - this.makernote = makernote; - } - - @Override - public String toString() { - return "EXIFObject{" + - "image=" + image + - ", thumbnail=" + thumbnail + - ", exif=" + exif + - ", gps=" + gps + - ", interoperability=" + interoperability + - ", makernote=" + makernote + - '}'; - } - } - - public class ImageObject{ - private String Make; - private String Model; - private int Orientation; - private int XResolution; - private int YResolution; - private int ResolutionUnit; - private String Software; - private String ModifyDate; - private int YCbCrPositioning; - private int ExifOffset; - private int GPSInfo; - - public ImageObject() { - } - - public String getMake() { - return Make; - } - - public void setMake(String make) { - Make = make; - } - - public String getModel() { - return Model; - } - - public void setModel(String model) { - Model = model; - } - - public int getOrientation() { - return Orientation; - } - - public void setOrientation(int orientation) { - Orientation = orientation; - } - - public int getXResolution() { - return XResolution; - } - - public void setXResolution(int XResolution) { - this.XResolution = XResolution; - } - - public int getYResolution() { - return YResolution; - } - - public void setYResolution(int YResolution) { - this.YResolution = YResolution; - } - - public int getResolutionUnit() { - return ResolutionUnit; - } - - public void setResolutionUnit(int resolutionUnit) { - ResolutionUnit = resolutionUnit; - } - - public String getSoftware() { - return Software; - } - - public void setSoftware(String software) { - Software = software; - } - - public String getModifyDate() { - return ModifyDate; - } - - public void setModifyDate(String modifyDate) { - ModifyDate = modifyDate; - } - - public int getYCbCrPositioning() { - return YCbCrPositioning; - } - - public void setYCbCrPositioning(int YCbCrPositioning) { - this.YCbCrPositioning = YCbCrPositioning; - } - - public int getExifOffset() { - return ExifOffset; - } - - public void setExifOffset(int exifOffset) { - ExifOffset = exifOffset; - } - - public int getGPSInfo() { - return GPSInfo; - } - - public void setGPSInfo(int GPSInfo) { - this.GPSInfo = GPSInfo; - } - - @Override - public String toString() { - return "ImageObject{" + - "Make='" + Make + '\'' + - ", Model='" + Model + '\'' + - ", Orientation=" + Orientation + - ", XResolution=" + XResolution + - ", YResolution=" + YResolution + - ", ResolutionUnit=" + ResolutionUnit + - ", Software='" + Software + '\'' + - ", ModifyDate='" + ModifyDate + '\'' + - ", YCbCrPositioning=" + YCbCrPositioning + - ", ExifOffset=" + ExifOffset + - ", GPSInfo=" + GPSInfo + - '}'; - } - } - - public class Thumbnail{ - private int Compression; - private int XResolution; - private int YResolution; - private int ResolutionUnit; - private int ThumbnailOffset; - private int ThumbnailLength; - - public Thumbnail() { - } - - public int getCompression() { - return Compression; - } - - public void setCompression(int compression) { - Compression = compression; - } - - public int getXResolution() { - return XResolution; - } - - public void setXResolution(int XResolution) { - this.XResolution = XResolution; - } - - public int getYResolution() { - return YResolution; - } - - public void setYResolution(int YResolution) { - this.YResolution = YResolution; - } - - public int getResolutionUnit() { - return ResolutionUnit; - } - - public void setResolutionUnit(int resolutionUnit) { - ResolutionUnit = resolutionUnit; - } - - public int getThumbnailOffset() { - return ThumbnailOffset; - } - - public void setThumbnailOffset(int thumbnailOffset) { - ThumbnailOffset = thumbnailOffset; - } - - public int getThumbnailLength() { - return ThumbnailLength; - } - - public void setThumbnailLength(int thumbnailLength) { - ThumbnailLength = thumbnailLength; - } - - @Override - public String toString() { - return "Thumbnail{" + - "Compression=" + Compression + - ", XResolution=" + XResolution + - ", YResolution=" + YResolution + - ", ResolutionUnit=" + ResolutionUnit + - ", ThumbnailOffset=" + ThumbnailOffset + - ", ThumbnailLength=" + ThumbnailLength + - '}'; - } - } - - public class Exif{ - private double ExposureTime; - private double FNumber; - private int ExposureProgram; - private int ISO; - private String ExifVersion; - private String DateTimeOriginal; - private String CreateDate; - private double ShutterSpeedValue; - private double ApertureValue; - private int ExposureCompensation; - private int MeteringMode; - private int Flash; - private int FocalLength; - private String SubSecTime; - private String SubSecTimeOriginal; - private String SubSecTimeDigitized; - private String FlashpixVersion; - private int ColorSpace; - private int ExifImageWidth; - private int ExifImageHeight; - private int InteropOffset; - private double FocalPlaneXResolution; - private double FocalPlaneYResolution; - private int FocalPlaneResolutionUnit; - private int CustomRendered; - private int ExposureMode; - private int WhiteBalance; - private int SceneCaptureType; - - public Exif() { - } - - public double getExposureTime() { - return ExposureTime; - } - - public void setExposureTime(double exposureTime) { - ExposureTime = exposureTime; - } - - public double getFNumber() { - return FNumber; - } - - public void setFNumber(double FNumber) { - this.FNumber = FNumber; - } - - public int getExposureProgram() { - return ExposureProgram; - } - - public void setExposureProgram(int exposureProgram) { - ExposureProgram = exposureProgram; - } - - public int getISO() { - return ISO; - } - - public void setISO(int ISO) { - this.ISO = ISO; - } - - public String getExifVersion() { - return ExifVersion; - } - - public void setExifVersion(String exifVersion) { - ExifVersion = exifVersion; - } - - public String getDateTimeOriginal() { - return DateTimeOriginal; - } - - public void setDateTimeOriginal(String dateTimeOriginal) { - DateTimeOriginal = dateTimeOriginal; - } - - public String getCreateDate() { - return CreateDate; - } - - public void setCreateDate(String createDate) { - CreateDate = createDate; - } - - public double getShutterSpeedValue() { - return ShutterSpeedValue; - } - - public void setShutterSpeedValue(double shutterSpeedValue) { - ShutterSpeedValue = shutterSpeedValue; - } - - public double getApertureValue() { - return ApertureValue; - } - - public void setApertureValue(double apertureValue) { - ApertureValue = apertureValue; - } - - public int getExposureCompensation() { - return ExposureCompensation; - } - - public void setExposureCompensation(int exposureCompensation) { - ExposureCompensation = exposureCompensation; - } - - public int getMeteringMode() { - return MeteringMode; - } - - public void setMeteringMode(int meteringMode) { - MeteringMode = meteringMode; - } - - public int getFlash() { - return Flash; - } - - public void setFlash(int flash) { - Flash = flash; - } - - public int getFocalLength() { - return FocalLength; - } - - public void setFocalLength(int focalLength) { - FocalLength = focalLength; - } - - public String getSubSecTime() { - return SubSecTime; - } - - public void setSubSecTime(String subSecTime) { - SubSecTime = subSecTime; - } - - public String getSubSecTimeOriginal() { - return SubSecTimeOriginal; - } - - public void setSubSecTimeOriginal(String subSecTimeOriginal) { - SubSecTimeOriginal = subSecTimeOriginal; - } - - public String getSubSecTimeDigitized() { - return SubSecTimeDigitized; - } - - public void setSubSecTimeDigitized(String subSecTimeDigitized) { - SubSecTimeDigitized = subSecTimeDigitized; - } - - public String getFlashpixVersion() { - return FlashpixVersion; - } - - public void setFlashpixVersion(String flashpixVersion) { - FlashpixVersion = flashpixVersion; - } - - public int getColorSpace() { - return ColorSpace; - } - - public void setColorSpace(int colorSpace) { - ColorSpace = colorSpace; - } - - public int getExifImageWidth() { - return ExifImageWidth; - } - - public void setExifImageWidth(int exifImageWidth) { - ExifImageWidth = exifImageWidth; - } - - public int getExifImageHeight() { - return ExifImageHeight; - } - - public void setExifImageHeight(int exifImageHeight) { - ExifImageHeight = exifImageHeight; - } - - public int getInteropOffset() { - return InteropOffset; - } - - public void setInteropOffset(int interopOffset) { - InteropOffset = interopOffset; - } - - public double getFocalPlaneXResolution() { - return FocalPlaneXResolution; - } - - public void setFocalPlaneXResolution(double focalPlaneXResolution) { - FocalPlaneXResolution = focalPlaneXResolution; - } - - public double getFocalPlaneYResolution() { - return FocalPlaneYResolution; - } - - public void setFocalPlaneYResolution(double focalPlaneYResolution) { - FocalPlaneYResolution = focalPlaneYResolution; - } - - public int getFocalPlaneResolutionUnit() { - return FocalPlaneResolutionUnit; - } - - public void setFocalPlaneResolutionUnit(int focalPlaneResolutionUnit) { - FocalPlaneResolutionUnit = focalPlaneResolutionUnit; - } - - public int getCustomRendered() { - return CustomRendered; - } - - public void setCustomRendered(int customRendered) { - CustomRendered = customRendered; - } - - public int getExposureMode() { - return ExposureMode; - } - - public void setExposureMode(int exposureMode) { - ExposureMode = exposureMode; - } - - public int getWhiteBalance() { - return WhiteBalance; - } - - public void setWhiteBalance(int whiteBalance) { - WhiteBalance = whiteBalance; - } - - public int getSceneCaptureType() { - return SceneCaptureType; - } - - public void setSceneCaptureType(int sceneCaptureType) { - SceneCaptureType = sceneCaptureType; - } - - @Override - public String toString() { - return "Exif{" + - "ExposureTime=" + ExposureTime + - ", FNumber=" + FNumber + - ", ExposureProgram=" + ExposureProgram + - ", ISO=" + ISO + - ", ExifVersion='" + ExifVersion + '\'' + - ", DateTimeOriginal='" + DateTimeOriginal + '\'' + - ", CreateDate='" + CreateDate + '\'' + - ", ShutterSpeedValue=" + ShutterSpeedValue + - ", ApertureValue=" + ApertureValue + - ", ExposureCompensation=" + ExposureCompensation + - ", MeteringMode=" + MeteringMode + - ", Flash=" + Flash + - ", FocalLength=" + FocalLength + - ", SubSecTime='" + SubSecTime + '\'' + - ", SubSecTimeOriginal='" + SubSecTimeOriginal + '\'' + - ", SubSecTimeDigitized='" + SubSecTimeDigitized + '\'' + - ", FlashpixVersion='" + FlashpixVersion + '\'' + - ", ColorSpace=" + ColorSpace + - ", ExifImageWidth=" + ExifImageWidth + - ", ExifImageHeight=" + ExifImageHeight + - ", InteropOffset=" + InteropOffset + - ", FocalPlaneXResolution=" + FocalPlaneXResolution + - ", FocalPlaneYResolution=" + FocalPlaneYResolution + - ", FocalPlaneResolutionUnit=" + FocalPlaneResolutionUnit + - ", CustomRendered=" + CustomRendered + - ", ExposureMode=" + ExposureMode + - ", WhiteBalance=" + WhiteBalance + - ", SceneCaptureType=" + SceneCaptureType + - '}'; - } - } - - public class GPS{ - private List GPSVersionID; - - public GPS() { - } - - public List getGPSVersionID() { - return GPSVersionID; - } - - public void setGPSVersionID(List GPSVersionID) { - this.GPSVersionID = GPSVersionID; - } - - @Override - public String toString() { - return "GPS{" + - "GPSVersionID=" + GPSVersionID + - '}'; - } - } - - public class Interoperability{ - private String InteropIndex; - private String InteropVersion; - - public Interoperability() { - } - - public String getInteropIndex() { - return InteropIndex; - } - - public void setInteropIndex(String interopIndex) { - InteropIndex = interopIndex; - } - - public String getInteropVersion() { - return InteropVersion; - } - - public void setInteropVersion(String interopVersion) { - InteropVersion = interopVersion; - } - - @Override - public String toString() { - return "Interoperability{" + - "InteropIndex='" + InteropIndex + '\'' + - ", InteropVersion='" + InteropVersion + '\'' + - '}'; - } - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/MoveFileRequest.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/MoveFileRequest.java deleted file mode 100644 index 2d015a57..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/MoveFileRequest.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.imagekit.sdk.models; - -public class MoveFileRequest { - public String sourceFilePath; - public String destinationPath; - - public String getSourceFilePath() { - return sourceFilePath; - } - - public void setSourceFilePath(String sourceFilePath) { - this.sourceFilePath = sourceFilePath; - } - - public String getDestinationPath() { - return destinationPath; - } - - public void setDestinationPath(String destinationPath) { - this.destinationPath = destinationPath; - } - - @Override - public String toString() { - return "MoveFileRequest{" + "sourceFilePath=" + sourceFilePath + ", destinationPath=" + destinationPath + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/MoveFolderRequest.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/MoveFolderRequest.java deleted file mode 100644 index 900a97ff..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/MoveFolderRequest.java +++ /dev/null @@ -1,28 +0,0 @@ -package io.imagekit.sdk.models; - -public class MoveFolderRequest { - public String sourceFolderPath; - public String destinationPath; - - public String getSourceFolderPath() { - return sourceFolderPath; - } - - public void setSourceFolderPath(String sourceFolderPath) { - this.sourceFolderPath = sourceFolderPath; - } - - public String getDestinationPath() { - return destinationPath; - } - - public void setDestinationPath(String destinationPath) { - this.destinationPath = destinationPath; - } - - @Override - public String toString() { - return "MoveFolderRequest{" + "sourceFolderPath=" + sourceFolderPath + ", destinationPath=" + destinationPath - + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/RenameFileRequest.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/RenameFileRequest.java deleted file mode 100644 index 85d5fc97..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/RenameFileRequest.java +++ /dev/null @@ -1,37 +0,0 @@ -package io.imagekit.sdk.models; - -public class RenameFileRequest { - public String filePath; - public String newFileName; - public Boolean purgeCache; - - public String getFilePath() { - return filePath; - } - - public void setFilePath(String filePath) { - this.filePath = filePath; - } - - public String getNewFileName() { - return newFileName; - } - - public void setNewFileName(String newFileName) { - this.newFileName = newFileName; - } - - public Boolean getPurgeCache() { - return purgeCache; - } - - public void setPurgeCache(Boolean purgeCache) { - this.purgeCache = purgeCache; - } - - @Override - public String toString() { - return "RenameFileRequest{" + "filePath=" + filePath + ", newFileName=" + newFileName + ", purgeCache=" - + purgeCache + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/ResponseMetaData.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/ResponseMetaData.java deleted file mode 100644 index 57f1859e..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/ResponseMetaData.java +++ /dev/null @@ -1,63 +0,0 @@ -package io.imagekit.sdk.models; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class ResponseMetaData { - - private String raw; - private int httpStatusCode; - private Map headers; - - public String getRaw() { - return raw; - } - - public void setRaw(String raw) { - this.raw = raw; - } - - public int getHttpStatusCode() { - return httpStatusCode; - } - - public void setHttpStatusCode(int httpStatusCode) { - this.httpStatusCode = httpStatusCode; - } - - public Map getHeaders() { - return headers; - } - - public void setHeaders(Map headers) { - this.headers = headers; - } - - public Map getMap() { - if (null != raw) { - return new Gson().fromJson(raw, new TypeToken>() { - }.getType()); - } - return new HashMap<>(); - } - - public List getList() { - if (null != raw) { - return new Gson().fromJson(raw, new TypeToken() { - }.getType()); - } - return new ArrayList<>(); - } - - @Override - public String toString() { - return "ResponseMetaData{" + "raw='" + raw + '\'' + ", httpStatusCode=" + httpStatusCode + ", headers=" - + headers + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/TagsRequest.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/TagsRequest.java deleted file mode 100644 index 7653c8ad..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/TagsRequest.java +++ /dev/null @@ -1,35 +0,0 @@ -package io.imagekit.sdk.models; - -import java.util.List; -import java.util.stream.Collectors; - -public class TagsRequest { - public List fileIds; - public List tags; - - public TagsRequest(List fileIds, List tags) { - this.fileIds = fileIds; - this.tags = tags; - } - - public List getTags() { - return tags; - } - - public void setTags(List tags) { - this.tags = tags; - } - - public List getFileIds() { - return fileIds; - } - - public void setFileIds(List fileIds) { - this.fileIds = fileIds; - } - - @Override - public String toString() { - return "TagsRequest{" + "fileIds=" + fileIds + ", tags=" + tags + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/Result.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/Result.java deleted file mode 100644 index 4c51941c..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/Result.java +++ /dev/null @@ -1,193 +0,0 @@ -package io.imagekit.sdk.models.results; - -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.reflect.TypeToken; - -import io.imagekit.sdk.models.BaseFile; -import io.imagekit.sdk.models.ResponseMetaData; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class Result extends BaseFile { - private String help; - @Deprecated - private String raw; - private ResponseMetaData responseMetaData = new ResponseMetaData(); - - public Result() { - } - - public Result(String fileId, String name, String url, String thumbnail, int height, int width, long size, - String filePath, List tags, boolean isPrivateFile, String customCoordinates, String fileType, - JsonArray aiTags, JsonObject versionInfo, JsonObject customMetadata, JsonObject embeddedMetadata, - JsonObject extensionStatus, String type, String mime, Boolean hasAlpha, Date createdAt, Date updatedAt) { - this.fileId = fileId; - this.name = name; - this.url = url; - this.thumbnail = thumbnail; - this.height = height; - this.width = width; - this.size = size; - this.filePath = filePath; - this.tags = tags; - this.isPrivateFile = isPrivateFile; - this.customCoordinates = customCoordinates; - this.fileType = fileType; - this.aiTags = aiTags; - this.versionInfo = versionInfo; - this.customMetadata = customMetadata; - this.embeddedMetadata = embeddedMetadata; - this.extensionStatus = extensionStatus; - this.type = type; - this.mime = mime; - this.hasAlpha = hasAlpha; - this.createdAt = createdAt; - this.updatedAt = updatedAt; - } - - public String getHelp() { - return help; - } - - public String getRaw() { - return raw; - } - - public void setRaw(String raw) { - this.raw = raw; - } - - @Deprecated - public Map getMap() { - if (null != raw) { - return new Gson().fromJson(raw, new TypeToken>() { - }.getType()); - } - return new HashMap<>(); - } - - public void setHelp(String help) { - this.help = help; - } - - public String getFileId() { - return fileId; - } - - public void setFileId(String fileId) { - this.fileId = fileId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getThumbnail() { - return thumbnail; - } - - public void setThumbnail(String thumbnail) { - this.thumbnail = thumbnail; - } - - public int getHeight() { - return height; - } - - public void setHeight(int height) { - this.height = height; - } - - public int getWidth() { - return width; - } - - public void setWidth(int width) { - this.width = width; - } - - public long getSize() { - return size; - } - - public void setSize(long size) { - this.size = size; - } - - public String getFilePath() { - return filePath; - } - - public void setFilePath(String filePath) { - this.filePath = filePath; - } - - public List getTags() { - return tags; - } - - public void setTags(List tags) { - this.tags = tags; - } - - public boolean isPrivateFile() { - return isPrivateFile; - } - - public void setPrivateFile(boolean privateFile) { - isPrivateFile = privateFile; - } - - public String getCustomCoordinates() { - return customCoordinates; - } - - public void setCustomCoordinates(String customCoordinates) { - this.customCoordinates = customCoordinates; - } - - public String getFileType() { - return fileType; - } - - public void setFileType(String fileType) { - this.fileType = fileType; - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "Result{" + "fileId='" + fileId + '\'' + ", name='" + name + '\'' + ", url='" + url + '\'' - + ", thumbnail='" + thumbnail + '\'' + ", height=" + height + ", width=" + width + ", size=" + size - + ", filePath='" + filePath + '\'' + ", tags=" + tags + ", isPrivateFile=" + isPrivateFile - + ", customCoordinates='" + customCoordinates + '\'' + ", fileType='" + fileType + '\'' + ", aiTags=" - + aiTags + ", versionInfo=" + versionInfo + ", customMetadata=" + customMetadata + ", embeddedMetadata=" - + embeddedMetadata + ", extensionStatus=" + extensionStatus + ", type='" + type + '\'' + ", mime='" - + mime + '\'' + ", hasAlpha=" + hasAlpha + ", createdAt=" + createdAt + ", updatedAt=" + updatedAt - + ", help='" + help + '\'' + ", raw='" + raw + '\'' + ", responseMetaData=" + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultBulkJobStatus.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultBulkJobStatus.java deleted file mode 100644 index 644755d2..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultBulkJobStatus.java +++ /dev/null @@ -1,48 +0,0 @@ -package io.imagekit.sdk.models.results; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class ResultBulkJobStatus { - private String jobId; - private String type; - private String status; - private ResponseMetaData responseMetaData = new ResponseMetaData(); - - public String getJobId() { - return jobId; - } - - public void setJobId(String jobId) { - this.jobId = jobId; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "ResultBulkJobStatus{" + "jobId='" + jobId + '\'' + ", type='" + type + '\'' + ", status='" + status - + '\'' + ", responseMetaData=" + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultCache.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultCache.java deleted file mode 100644 index 742ec191..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultCache.java +++ /dev/null @@ -1,67 +0,0 @@ -package io.imagekit.sdk.models.results; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import java.util.HashMap; -import java.util.Map; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class ResultCache { - private String help; - private String requestId; - @Deprecated - private String raw; - private ResponseMetaData responseMetaData = new ResponseMetaData(); - - public ResultCache() { - } - - public String getHelp() { - return help; - } - - public void setHelp(String help) { - this.help = help; - } - - public String getRaw() { - return raw; - } - - public void setRaw(String raw) { - this.raw = raw; - } - - @Deprecated - public Map getMap() { - if (null != raw) { - return new Gson().fromJson(raw, new TypeToken>() { - }.getType()); - } - return new HashMap<>(); - } - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "ResultCache{" + "help='" + help + '\'' + ", requestId='" + requestId + '\'' + ", raw='" + raw + '\'' - + ", responseMetaData=" + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultCacheStatus.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultCacheStatus.java deleted file mode 100644 index a61cba34..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultCacheStatus.java +++ /dev/null @@ -1,67 +0,0 @@ -package io.imagekit.sdk.models.results; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import java.util.HashMap; -import java.util.Map; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class ResultCacheStatus { - private String help; - private String status; - @Deprecated - private String raw; - private ResponseMetaData responseMetaData = new ResponseMetaData(); - - public ResultCacheStatus() { - } - - public String getHelp() { - return help; - } - - public String getRaw() { - return raw; - } - - public void setRaw(String raw) { - this.raw = raw; - } - - @Deprecated - public Map getMap() { - if (null != raw) { - return new Gson().fromJson(raw, new TypeToken>() { - }.getType()); - } - return new HashMap<>(); - } - - public void setHelp(String help) { - this.help = help; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "ResultCacheStatus{" + "help='" + help + '\'' + ", status='" + status + '\'' + ", raw='" + raw + '\'' - + ", responseMetaData=" + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultCustomMetaDataField.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultCustomMetaDataField.java deleted file mode 100644 index 2dc6836a..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultCustomMetaDataField.java +++ /dev/null @@ -1,62 +0,0 @@ -package io.imagekit.sdk.models.results; - -import io.imagekit.sdk.models.CustomMetaDataFieldSchemaObject; -import io.imagekit.sdk.models.ResponseMetaData; - -public class ResultCustomMetaDataField { - private String id; - private String name; - private String label; - private CustomMetaDataFieldSchemaObject schema = new CustomMetaDataFieldSchemaObject(); - private ResponseMetaData responseMetaData = new ResponseMetaData(); - - public ResultCustomMetaDataField() { - - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public CustomMetaDataFieldSchemaObject getSchema() { - return schema; - } - - public void setSchema(CustomMetaDataFieldSchemaObject schema) { - this.schema = schema; - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "ResultCustomMetaDataField{" + "id='" + id + '\'' + ", name='" + name + '\'' + ", label='" + label + '\'' - + ", schema=" + schema + ", responseMetaData=" + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultCustomMetaDataFieldList.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultCustomMetaDataFieldList.java deleted file mode 100644 index 1528c21b..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultCustomMetaDataFieldList.java +++ /dev/null @@ -1,33 +0,0 @@ -package io.imagekit.sdk.models.results; - -import java.util.List; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class ResultCustomMetaDataFieldList { - - private List resultCustomMetaDataFieldList; - private ResponseMetaData responseMetaData = new ResponseMetaData(); - - public List getResultCustomMetaDataFieldList() { - return resultCustomMetaDataFieldList; - } - - public void setResultCustomMetaDataFieldList(List resultCustomMetaDataFieldList) { - this.resultCustomMetaDataFieldList = resultCustomMetaDataFieldList; - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "ResultCustomMetaDataFieldList{" + "resultCustomMetaDataFieldList=" + resultCustomMetaDataFieldList - + ", responseMetaData=" + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultEmptyBlock.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultEmptyBlock.java deleted file mode 100644 index ce1cf4a8..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultEmptyBlock.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.imagekit.sdk.models.results; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class ResultEmptyBlock { - private ResponseMetaData responseMetaData = new ResponseMetaData(); - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "ResultEmptyBlock{" + "responseMetaData=" + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultException.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultException.java deleted file mode 100644 index 0e66630b..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultException.java +++ /dev/null @@ -1,42 +0,0 @@ -package io.imagekit.sdk.models.results; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class ResultException { - private String message; - private String help; - private ResponseMetaData responseMetaData = new ResponseMetaData(); - - public ResultException() { - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public String getHelp() { - return help; - } - - public void setHelp(String help) { - this.help = help; - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "ResultException{" + "message='" + message + '\'' + ", help='" + help + '\'' + ", responseMetaData=" - + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultFileDelete.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultFileDelete.java deleted file mode 100644 index cb50ff4b..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultFileDelete.java +++ /dev/null @@ -1,81 +0,0 @@ -package io.imagekit.sdk.models.results; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class ResultFileDelete { - private String help; - @Deprecated - private String raw; - private List successfullyDeletedFileIds; - private List missingFileIds; - private ResponseMetaData responseMetaData = new ResponseMetaData(); - - public ResultFileDelete() { - successfullyDeletedFileIds = new ArrayList<>(); - missingFileIds = new ArrayList<>(); - } - - public String getHelp() { - return help; - } - - public void setHelp(String help) { - this.help = help; - } - - public String getRaw() { - return raw; - } - - public void setRaw(String raw) { - this.raw = raw; - } - - @Deprecated - public Map getMap() { - if (null != raw) { - return new Gson().fromJson(raw, new TypeToken>() { - }.getType()); - } - return new HashMap<>(); - } - - public List getSuccessfullyDeletedFileIds() { - return successfullyDeletedFileIds; - } - - public void setSuccessfullyDeletedFileIds(List successfullyDeletedFileIds) { - this.successfullyDeletedFileIds = successfullyDeletedFileIds; - } - - public List getMissingFileIds() { - return missingFileIds; - } - - public void setMissingFileIds(List missingFileIds) { - this.missingFileIds = missingFileIds; - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "ResultFileDelete{" + "help='" + help + '\'' + ", raw='" + raw + '\'' + ", successfullyDeletedFileIds=" - + successfullyDeletedFileIds + ", missingFileIds=" + missingFileIds + ", responseMetaData=" - + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultFileVersionDetails.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultFileVersionDetails.java deleted file mode 100644 index f9f83c25..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultFileVersionDetails.java +++ /dev/null @@ -1,221 +0,0 @@ -package io.imagekit.sdk.models.results; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import java.util.List; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class ResultFileVersionDetails { - - protected String type; - protected String name; - protected String createdAt; - protected String updatedAt; - protected String fileId; - protected List tags; - protected JsonArray aiTags; - protected JsonObject versionInfo; - protected JsonObject embeddedMetadata; - protected String customCoordinates; - protected JsonObject customMetadata; - protected boolean isPrivateFile; - protected String url; - protected String thumbnail; - protected String fileType; - protected String filePath; - protected int height; - protected int width; - protected long size; - protected Boolean hasAlpha; - protected String mime; - private ResponseMetaData responseMetaData = new ResponseMetaData(); - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(String createdAt) { - this.createdAt = createdAt; - } - - public String getUpdatedAt() { - return updatedAt; - } - - public void setUpdatedAt(String updatedAt) { - this.updatedAt = updatedAt; - } - - public String getFileId() { - return fileId; - } - - public void setFileId(String fileId) { - this.fileId = fileId; - } - - public List getTags() { - return tags; - } - - public void setTags(List tags) { - this.tags = tags; - } - - public JsonArray getAiTags() { - return aiTags; - } - - public void setAiTags(JsonArray aiTags) { - this.aiTags = aiTags; - } - - public JsonObject getVersionInfo() { - return versionInfo; - } - - public void setVersionInfo(JsonObject versionInfo) { - this.versionInfo = versionInfo; - } - - public JsonObject getEmbeddedMetadata() { - return embeddedMetadata; - } - - public void setEmbeddedMetadata(JsonObject embeddedMetadata) { - this.embeddedMetadata = embeddedMetadata; - } - - public String getCustomCoordinates() { - return customCoordinates; - } - - public void setCustomCoordinates(String customCoordinates) { - this.customCoordinates = customCoordinates; - } - - public JsonObject getCustomMetadata() { - return customMetadata; - } - - public void setCustomMetadata(JsonObject customMetadata) { - this.customMetadata = customMetadata; - } - - public boolean isPrivateFile() { - return isPrivateFile; - } - - public void setPrivateFile(boolean privateFile) { - isPrivateFile = privateFile; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getThumbnail() { - return thumbnail; - } - - public void setThumbnail(String thumbnail) { - this.thumbnail = thumbnail; - } - - public String getFileType() { - return fileType; - } - - public void setFileType(String fileType) { - this.fileType = fileType; - } - - public String getFilePath() { - return filePath; - } - - public void setFilePath(String filePath) { - this.filePath = filePath; - } - - public int getHeight() { - return height; - } - - public void setHeight(int height) { - this.height = height; - } - - public int getWidth() { - return width; - } - - public void setWidth(int width) { - this.width = width; - } - - public long getSize() { - return size; - } - - public void setSize(long size) { - this.size = size; - } - - public Boolean getHasAlpha() { - return hasAlpha; - } - - public void setHasAlpha(Boolean hasAlpha) { - this.hasAlpha = hasAlpha; - } - - public String getMime() { - return mime; - } - - public void setMime(String mime) { - this.mime = mime; - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "ResultFileVersion{" + "type='" + type + '\'' + ", name='" + name + '\'' + ", createdAt='" + createdAt - + '\'' + ", updatedAt='" + updatedAt + '\'' + ", fileId='" + fileId + '\'' + ", tags=" + tags - + ", aiTags=" + aiTags + ", versionInfo=" + versionInfo + ", embeddedMetadata=" + embeddedMetadata - + ", customCoordinates='" + customCoordinates + '\'' + ", customMetadata=" + customMetadata - + ", isPrivateFile=" + isPrivateFile + ", url='" + url + '\'' + ", thumbnail='" + thumbnail + '\'' - + ", fileType='" + fileType + '\'' + ", filePath='" + filePath + '\'' + ", height=" + height - + ", width=" + width + ", size=" + size + ", hasAlpha=" + hasAlpha + ", mime='" + mime + '\'' - + ", responseMetaData=" + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultFileVersions.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultFileVersions.java deleted file mode 100644 index 3e2a2327..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultFileVersions.java +++ /dev/null @@ -1,33 +0,0 @@ -package io.imagekit.sdk.models.results; - -import java.util.ArrayList; -import java.util.List; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class ResultFileVersions { - List resultFileVersionDetailsList = new ArrayList<>(); - private ResponseMetaData responseMetaData = new ResponseMetaData(); - - public List getResultFileVersionDetailsList() { - return resultFileVersionDetailsList; - } - - public void setResultFileVersionDetailsList(List resultFileVersionDetailsList) { - this.resultFileVersionDetailsList = resultFileVersionDetailsList; - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "ResultFileVersions{" + "resultFileVersionDetailsList=" + resultFileVersionDetailsList - + ", responseMetaData=" + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultList.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultList.java deleted file mode 100644 index 7c51f5b5..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultList.java +++ /dev/null @@ -1,73 +0,0 @@ -package io.imagekit.sdk.models.results; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import io.imagekit.sdk.models.BaseFile; -import io.imagekit.sdk.models.ResponseMetaData; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class ResultList { - private String help; - @Deprecated - private String raw; - private List results; - private ResponseMetaData responseMetaData = new ResponseMetaData(); - - public ResultList() { - } - - public ResultList(List results) { - this.results = results; - } - - public String getHelp() { - return help; - } - - public void setHelp(String help) { - this.help = help; - } - - public String getRaw() { - return raw; - } - - public void setRaw(String raw) { - this.raw = raw; - } - - @Deprecated - public List> getMap() { - if (null != raw) { - return new Gson().fromJson(raw, new TypeToken>>() { - }.getType()); - } - return new ArrayList>(); - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - public List getResults() { - return results; - } - - public void setResults(List results) { - this.results = results; - } - - @Override - public String toString() { - return "ResultList{" + "help='" + help + '\'' + ", raw='" + raw + '\'' + ", results=" + results - + ", responseMetaData=" + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultMetaData.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultMetaData.java deleted file mode 100644 index be2e6ed0..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultMetaData.java +++ /dev/null @@ -1,68 +0,0 @@ -package io.imagekit.sdk.models.results; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import java.util.HashMap; -import java.util.Map; - -import io.imagekit.sdk.models.MetaData; -import io.imagekit.sdk.models.ResponseMetaData; - -public class ResultMetaData { - private String help; - @Deprecated - private String raw; - private MetaData results; - private ResponseMetaData responseMetaData = new ResponseMetaData(); - - public ResultMetaData() { - } - - public String getHelp() { - return help; - } - - public void setHelp(String help) { - this.help = help; - } - - public String getRaw() { - return raw; - } - - public void setRaw(String raw) { - this.raw = raw; - } - - @Deprecated - public Map getMap() { - if (null != raw) { - return new Gson().fromJson(raw, new TypeToken>() { - }.getType()); - } - return new HashMap<>(); - } - - public MetaData getResults() { - return results; - } - - public void setResults(MetaData results) { - this.results = results; - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "ResultMetaData{" + "help='" + help + '\'' + ", raw='" + raw + '\'' + ", results=" + results - + ", responseMetaData=" + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultNoContent.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultNoContent.java deleted file mode 100644 index 439cb615..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultNoContent.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.imagekit.sdk.models.results; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class ResultNoContent { - private ResponseMetaData responseMetaData = new ResponseMetaData(); - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "ResultNoContent{" + "responseMetaData=" + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultOfFolderActions.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultOfFolderActions.java deleted file mode 100644 index 905f43b4..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultOfFolderActions.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.imagekit.sdk.models.results; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class ResultOfFolderActions { - private String jobId; - private ResponseMetaData responseMetaData = new ResponseMetaData(); - - public String getJobId() { - return jobId; - } - - public void setJobId(String jobId) { - this.jobId = jobId; - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "ResultOfFolderActions{" + "jobId='" + jobId + '\'' + ", responseMetaData=" + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultRenameFile.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultRenameFile.java deleted file mode 100644 index fdc0686d..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultRenameFile.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.imagekit.sdk.models.results; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class ResultRenameFile { - private String purgeRequestId; - private ResponseMetaData responseMetaData = new ResponseMetaData(); - - public String getPurgeRequestId() { - return purgeRequestId; - } - - public void setPurgeRequestId(String purgeRequestId) { - this.purgeRequestId = purgeRequestId; - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "ResultRenameFile{" + "purgeRequestId='" + purgeRequestId + '\'' + ", responseMetaData=" - + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultTags.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultTags.java deleted file mode 100644 index 88499dfa..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/models/results/ResultTags.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.imagekit.sdk.models.results; - -import java.util.List; - -import io.imagekit.sdk.models.ResponseMetaData; - -public class ResultTags { - private List successfullyUpdatedFileIds; - private ResponseMetaData responseMetaData = new ResponseMetaData(); - - public List getSuccessfullyUpdatedFileIds() { - return successfullyUpdatedFileIds; - } - - public void setSuccessfullyUpdatedFileIds(List successfullyUpdatedFileIds) { - this.successfullyUpdatedFileIds = successfullyUpdatedFileIds; - } - - public ResponseMetaData getResponseMetaData() { - return responseMetaData; - } - - public void setResponseMetaData(ResponseMetaData responseMetaData) { - this.responseMetaData = responseMetaData; - } - - @Override - public String toString() { - return "ResultTags{" + "successfullyUpdatedFileIds=" + successfullyUpdatedFileIds + ", responseMetaData=" - + responseMetaData + '}'; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/tasks/Calculation.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/tasks/Calculation.java deleted file mode 100644 index 417af9b8..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/tasks/Calculation.java +++ /dev/null @@ -1,49 +0,0 @@ -package io.imagekit.sdk.tasks; - -import org.apache.commons.codec.digest.HmacUtils; -import java.math.BigInteger; -import java.util.*; -import java.util.regex.Pattern; - -public class Calculation { - private static final int DEFAULT_TIME_DIFF = 60 * 30; - - public static Map getAuthenticatedParams(String token, long expire, String privateKey){ - if (token==null){ - token= UUID.randomUUID().toString(); - } - if (expire==0){ - expire= Calendar.getInstance().getTimeInMillis()+DEFAULT_TIME_DIFF; - } - if (privateKey==null) throw new RuntimeException("Private key can't be null."); - - String signature = HmacUtils.hmacSha1Hex(privateKey, token + expire); - - Map auth=new HashMap<>(); - auth.put("token",token); - auth.put("expire", String.valueOf(expire)); - auth.put("signature",signature); - return auth; - } - - public static int getHammingDistance(String firstHex, String secondHex){ - if (!(isValidHex(firstHex) && isValidHex(secondHex))){ - throw new RuntimeException("Both argument should be hexadecimal."); - } - if (firstHex.length()!=secondHex.length()) throw new RuntimeException("Both argument are not equal in length."); - - BigInteger xor = new BigInteger(firstHex, 16).xor(new BigInteger(secondHex, 16)); - - int count=0; - for(int i = 0; i < xor.toString(2).length(); i++) { - if (xor.toString(2).charAt(i)=='1'){ - count+=1; - } - } - return count; - } - - static boolean isValidHex(String hex){ - return Pattern.matches("^[0-9a-fA-F]+$",hex); - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/tasks/MultipartBuilder.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/tasks/MultipartBuilder.java deleted file mode 100644 index 98914b3c..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/tasks/MultipartBuilder.java +++ /dev/null @@ -1,99 +0,0 @@ -package io.imagekit.sdk.tasks; - -import com.google.gson.Gson; -import com.google.gson.JsonParser; - -import io.imagekit.sdk.models.FileCreateRequest; -import io.imagekit.sdk.models.FileUpdateRequest; -import io.imagekit.sdk.utils.Utils; -import okhttp3.MediaType; -import okhttp3.MultipartBody; -import okhttp3.RequestBody; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -public class MultipartBuilder { - private static final String RANDOM_BOUNDARY = "randomBoundary-------------------"; - - public MultipartBody build(FileCreateRequest fileCreateRequest) { - MultipartBody.Builder builder = new MultipartBody.Builder(RANDOM_BOUNDARY).setType(MultipartBody.FORM); - - if (null != fileCreateRequest.url) { - builder.addFormDataPart("file", fileCreateRequest.url.toString()); - } else if (null != fileCreateRequest.base64) { - builder.addFormDataPart("file", fileCreateRequest.base64); - } else if (null != fileCreateRequest.bytes) { - builder.addFormDataPart("file", Utils.bytesToBase64(fileCreateRequest.bytes)); - } else { - throw new RuntimeException("Error: File not provided."); - } - if (null != fileCreateRequest.fileName) { - builder.addFormDataPart("fileName", fileCreateRequest.fileName); - } else { - throw new RuntimeException("Error: Filename not provided"); - } - if (fileCreateRequest.useUniqueFileName) { - builder.addFormDataPart("useUniqueFileName", "true"); - } else { - builder.addFormDataPart("useUniqueFileName", "false"); - } - if (null != fileCreateRequest.tags) { - builder.addFormDataPart("tags", Utils.listToString(fileCreateRequest.tags)); - } - if (null != fileCreateRequest.folder) { - builder.addFormDataPart("folder", fileCreateRequest.folder); - } - if (fileCreateRequest.isPrivateFile) { - builder.addFormDataPart("isPrivateFile", "true"); - } - if (null != fileCreateRequest.customCoordinates) { - builder.addFormDataPart("customCoordinates", fileCreateRequest.customCoordinates); - } - if (null != fileCreateRequest.responseFields) { - builder.addFormDataPart("responseFields", Utils.listToString(fileCreateRequest.responseFields)); - } - if (fileCreateRequest.overwriteFile != null && fileCreateRequest.overwriteFile) { - builder.addFormDataPart("overwriteFile", "true"); - } - if (fileCreateRequest.overwriteAITags != null && fileCreateRequest.overwriteAITags) { - builder.addFormDataPart("overwriteAITags", "true"); - } - if (fileCreateRequest.overwriteTags != null && fileCreateRequest.overwriteTags) { - builder.addFormDataPart("overwriteTags", "true"); - } - if (fileCreateRequest.overwriteCustomMetadata != null && fileCreateRequest.overwriteCustomMetadata) { - builder.addFormDataPart("overwriteCustomMetadata", "true"); - } - if (null != fileCreateRequest.extensions) { - builder.addFormDataPart("extensions", fileCreateRequest.extensions.toString()); - } - if (null != fileCreateRequest.webhookUrl) { - builder.addFormDataPart("webhookUrl", fileCreateRequest.webhookUrl); - } - if (null != fileCreateRequest.customMetadata) { - builder.addFormDataPart("customMetadata", fileCreateRequest.customMetadata.toString()); - } - return builder.build(); - } - - public RequestBody build(FileUpdateRequest fileUpdateRequest) { - if (fileUpdateRequest.getFileId() == null) { - throw new RuntimeException("Error: File Id not provided."); - } - if (fileUpdateRequest.getFileId().trim().length() < 1) { - throw new RuntimeException("Error: File Id not provided."); - } - return RequestBody.create(MediaType.parse("application/json; charset=utf-8"), - new Gson().toJson(fileUpdateRequest)); - } - - public RequestBody build(String json) { - if (json == null) { - throw new RuntimeException("Error: You can't send null body."); - } else { - return RequestBody.create(MediaType.parse("application/json; charset=utf-8"), json); - } - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/tasks/QueryMaker.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/tasks/QueryMaker.java deleted file mode 100644 index 26d343cc..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/tasks/QueryMaker.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.imagekit.sdk.tasks; - -public class QueryMaker { - private String query; - - public void put(String q){ - if (null!=query){ - query+="&"; - } - else { - query=""; - } - query+=q; - } - - public String get(){ - return query; - } - -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/tasks/RestClient.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/tasks/RestClient.java deleted file mode 100644 index 5e6fbf32..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/tasks/RestClient.java +++ /dev/null @@ -1,964 +0,0 @@ -package io.imagekit.sdk.tasks; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; -import com.google.gson.reflect.TypeToken; - -import io.imagekit.sdk.ImageKit; -import io.imagekit.sdk.exceptions.BadRequestException; -import io.imagekit.sdk.exceptions.ConflictException; -import io.imagekit.sdk.exceptions.ForbiddenException; -import io.imagekit.sdk.exceptions.InternalServerException; -import io.imagekit.sdk.exceptions.NotFoundException; -import io.imagekit.sdk.exceptions.PartialSuccessException; -import io.imagekit.sdk.exceptions.TooManyRequestsException; -import io.imagekit.sdk.exceptions.UnauthorizedException; -import io.imagekit.sdk.exceptions.UnknownException; -import io.imagekit.sdk.models.AITagsRequest; -import io.imagekit.sdk.models.BaseFile; -import io.imagekit.sdk.models.CopyFileRequest; -import io.imagekit.sdk.models.CopyFolderRequest; -import io.imagekit.sdk.models.CreateFolderRequest; -import io.imagekit.sdk.models.CustomMetaDataFieldCreateRequest; -import io.imagekit.sdk.models.CustomMetaDataFieldUpdateRequest; -import io.imagekit.sdk.models.DeleteFileVersionRequest; -import io.imagekit.sdk.models.DeleteFolderRequest; -import io.imagekit.sdk.models.FileCreateRequest; -import io.imagekit.sdk.models.GetFileListRequest; -import io.imagekit.sdk.models.MoveFileRequest; -import io.imagekit.sdk.models.MoveFolderRequest; -import io.imagekit.sdk.models.MetaData; -import io.imagekit.sdk.models.FileUpdateRequest; -import io.imagekit.sdk.models.RenameFileRequest; -import io.imagekit.sdk.models.TagsRequest; -import io.imagekit.sdk.models.results.*; -import io.imagekit.sdk.utils.Utils; -import okhttp3.*; - -import java.io.IOException; -import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -public class RestClient { - - public static String API_BASE_URL = "https://api.imagekit.io/"; - public static String UPLOAD_BASE_URL = "https://upload.imagekit.io/"; - - private ImageKit imageKit; - Request request; - OkHttpClient client; - MultipartBuilder multipartBuilder; - - public RestClient(ImageKit imageKit) { - this.imageKit = imageKit; - this.client = new OkHttpClient(); - this.multipartBuilder = new MultipartBuilder(); - } - - public Result upload(FileCreateRequest fileCreateRequest) throws InternalServerException, BadRequestException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - Result result = null; - Map headers = Utils.getHeaders(imageKit); - - MultipartBody body = multipartBuilder.build(fileCreateRequest); - - request = new Request.Builder().url(UPLOAD_BASE_URL.concat("api/v1/files/upload")).post(body) - .headers(Headers.of(headers)).build(); - - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 200) { - respBody = response.body().string(); - result = new Gson().fromJson(respBody, Result.class); - result.setRaw(respBody); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, result.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return result; - } - - public Result updateFileDetail(FileUpdateRequest fileUpdateRequest) - throws ForbiddenException, TooManyRequestsException, InternalServerException, UnauthorizedException, - BadRequestException, UnknownException { - Result result = null; - Map headers = Utils.getHeaders(imageKit); - String url = String.format(Locale.US, API_BASE_URL.concat("v1/files/%s/details"), - fileUpdateRequest.getFileId()); - request = new Request.Builder().url(url).patch(multipartBuilder.build(fileUpdateRequest)) - .headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 200) { - respBody = response.body().string(); - result = new Gson().fromJson(respBody, Result.class); - result.setRaw(respBody); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, result.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return result; - } - - public ResultList getFileList(GetFileListRequest getFileListRequest) throws ForbiddenException, TooManyRequestsException, - InternalServerException, UnauthorizedException, BadRequestException, UnknownException, InstantiationException, IllegalAccessException { - ResultList resultList = new ResultList(); - Map headers = Utils.getHeaders(imageKit); - - QueryMaker queryMaker = new QueryMaker(); - Map options = new HashMap<>(); - if (getFileListRequest.getType() != null) { - options.put("type", getFileListRequest.getType()); - } - if (getFileListRequest.getSort() != null) { - options.put("sort", getFileListRequest.getSort()); - } - if (getFileListRequest.getPath() != null) { - options.put("path", getFileListRequest.getPath()); - } - if (getFileListRequest.getSearchQuery() != null) { - options.put("searchQuery", getFileListRequest.getSearchQuery()); - } - if (getFileListRequest.getFileType() != null) { - options.put("fileType", getFileListRequest.getFileType()); - } - if (getFileListRequest.getLimit() != null) { - options.put("limit", getFileListRequest.getLimit()); - } - if (getFileListRequest.getSkip() != null) { - options.put("skip", getFileListRequest.getSkip()); - } - if (getFileListRequest.getTags() != null) { - options.put("tags", String.join(",", getFileListRequest.getTags())); - } - for (Map.Entry entry : options.entrySet()) { - queryMaker.put(String.format("%s=%s", entry.getKey(), entry.getValue())); - } - - String url = String.format(Locale.US, API_BASE_URL.concat("v1/files?%s"), queryMaker.get()); - - request = new Request.Builder().url(url).get().headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 200) { - respBody = response.body().string(); - List files = new Gson().fromJson(respBody, - new TypeToken>() { - }.getType()); - resultList.setResults(files); - resultList.setRaw(respBody); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, resultList.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return resultList; - } - - public Result getFileDetail(String fileId) throws ForbiddenException, TooManyRequestsException, - InternalServerException, UnauthorizedException, BadRequestException, UnknownException { - Result result = new Result(); - Map headers = Utils.getHeaders(imageKit); - - String url = String.format(Locale.US, API_BASE_URL.concat("v1/files/%s/details"), fileId); - - request = new Request.Builder().url(url).get().headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 200) { - respBody = response.body().string(); - result = new Gson().fromJson(respBody, Result.class); - result.setRaw(respBody); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, result.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return result; - } - - public ResultMetaData getFileMetaData(String fileId) throws ForbiddenException, TooManyRequestsException, - InternalServerException, UnauthorizedException, BadRequestException, UnknownException { - ResultMetaData result = new ResultMetaData(); - Map headers = Utils.getHeaders(imageKit); - - String url = String.format(Locale.US, API_BASE_URL.concat("v1/files/%s/metadata"), fileId); - - request = new Request.Builder().url(url).get().headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 200) { - respBody = response.body().string(); - MetaData metaData = new Gson().fromJson(respBody, MetaData.class); - result.setResults(metaData); - result.setRaw(respBody); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, result.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return result; - } - - public ResultMetaData getRemoteFileMetaData(String url) throws ForbiddenException, TooManyRequestsException, - InternalServerException, UnauthorizedException, BadRequestException, UnknownException { - ResultMetaData result = new ResultMetaData(); - Map headers = Utils.getHeaders(imageKit); - - String apiURL = API_BASE_URL.concat("v1/metadata?url=") + url; - - request = new Request.Builder().url(apiURL).get().headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 200) { - respBody = response.body().string(); - MetaData metaData = new Gson().fromJson(respBody, MetaData.class); - result.setResults(metaData); - result.setRaw(respBody); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, result.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return result; - } - - public Result deleteFile(String fileId) throws ForbiddenException, TooManyRequestsException, - InternalServerException, UnauthorizedException, BadRequestException, UnknownException { - Result result = new Result(); - Map headers = Utils.getHeaders(imageKit); - - String url = String.format(Locale.US, API_BASE_URL.concat("v1/files/%s"), fileId); - - request = new Request.Builder().url(url).delete().headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 204) { - respBody = response.body().string(); - result.setFileId(fileId); - result.setRaw(respBody); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, result.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return result; - } - - public ResultFileDelete bulkDeleteFiles(List fileIds) - throws ForbiddenException, TooManyRequestsException, InternalServerException, PartialSuccessException, - UnauthorizedException, NotFoundException, BadRequestException, UnknownException { - ResultFileDelete result = new ResultFileDelete(); - Map headers = Utils.getHeaders(imageKit); - - String url = API_BASE_URL.concat("v1/files/batch/deleteByFileIds"); - - request = new Request.Builder().url(url) - .post(multipartBuilder.build(String.format("{\"fileIds\":%s}", new Gson().toJson(fileIds)))) - .headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 200) { - respBody = response.body().string(); - result = new Gson().fromJson(respBody, ResultFileDelete.class); - result.setRaw(respBody); - } else if (response.code() == 207 || response.code() == 404) { - Utils.throwOtherException(response); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, result.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return result; - } - - public ResultCache purgeCache(String url) throws ForbiddenException, TooManyRequestsException, - InternalServerException, UnauthorizedException, BadRequestException, UnknownException { - ResultCache result = new ResultCache(); - Map headers = Utils.getHeaders(imageKit); - - request = new Request.Builder().url(API_BASE_URL.concat("v1/files/purge")) - .post(multipartBuilder.build(String.format("{\"url\":\"%s\"}", url))).headers(Headers.of(headers)) - .build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 200 || response.code() == 201) { - respBody = response.body().string(); - result = new Gson().fromJson(respBody, ResultCache.class); - result.setRaw(respBody); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, result.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return result; - } - - public ResultCacheStatus getPurgeCacheStatus(String requestId) throws ForbiddenException, TooManyRequestsException, - InternalServerException, UnauthorizedException, BadRequestException, UnknownException { - ResultCacheStatus result = new ResultCacheStatus(); - Map headers = Utils.getHeaders(imageKit); - - String url = String.format(Locale.US, API_BASE_URL.concat("v1/files/purge/%s"), requestId); - - request = new Request.Builder().url(url).get().headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 200) { - respBody = response.body().string(); - result = new Gson().fromJson(respBody, ResultCacheStatus.class); - result.setRaw(respBody); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, result.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return result; - } - - public ResultTags manageTags(TagsRequest tagsRequest, String action) - throws NotFoundException, PartialSuccessException, BadRequestException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - ResultTags resultTags = new ResultTags(); - Map headers = Utils.getHeaders(imageKit); - - RequestBody requestBody = RequestBody.create(okhttp3.MediaType.parse("application/json"), - new Gson().toJson(tagsRequest)); - request = new Request.Builder() - .url(action.equals("removeTags") ? API_BASE_URL.concat("v1/files/removeTags") - : API_BASE_URL.concat("v1/files/addTags")) - .post(requestBody).headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 200) { - respBody = response.body().string(); - resultTags = new Gson().fromJson(respBody, ResultTags.class); - } else if (response.code() == 207 || response.code() == 404) { - Utils.throwOtherException(response); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, resultTags.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return resultTags; - } - - public ResultTags removeAITags(AITagsRequest aiTagsRequest) - throws PartialSuccessException, NotFoundException, BadRequestException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - ResultTags resultTags = new ResultTags(); - Map headers = Utils.getHeaders(imageKit); - - RequestBody requestBody = RequestBody.create(okhttp3.MediaType.parse("application/json"), - new Gson().toJson(aiTagsRequest)); - request = new Request.Builder().url(API_BASE_URL.concat("v1/files/removeAITags")).post(requestBody) - .headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 200) { - respBody = response.body().string(); - resultTags = new Gson().fromJson(respBody, ResultTags.class); - } else if (response.code() == 207 || response.code() == 404) { - Utils.throwOtherException(response); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, resultTags.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return resultTags; - } - - public ResultCustomMetaDataFieldList getCustomMetaDataFields(boolean includeDeleted) throws UnknownException { - ResultCustomMetaDataFieldList resultCustomMetaDataFieldList = new ResultCustomMetaDataFieldList(); - - Map headers = Utils.getHeaders(imageKit); - - request = new Request.Builder() - .url(API_BASE_URL.concat("v1/customMetadataFields?includeDeleted=" + includeDeleted)).get() - .headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 200) { - respBody = response.body().string(); - List resultCustomMetaDataFields = new Gson().fromJson(respBody, - new TypeToken>() { - }.getType()); - resultCustomMetaDataFieldList.setResultCustomMetaDataFieldList(resultCustomMetaDataFields); - } - Utils.populateResponseMetadata(respBody, resultCustomMetaDataFieldList.getResponseMetaData(), - response.code(), response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return resultCustomMetaDataFieldList; - } - - public ResultCustomMetaDataField createCustomMetaDataFields( - CustomMetaDataFieldCreateRequest customMetaDataFieldCreateRequest) - throws BadRequestException, UnknownException { - if (customMetaDataFieldCreateRequest.getName() == null) { - throw new RuntimeException("Error: Name not provided."); - } - if (customMetaDataFieldCreateRequest.getLabel() == null) { - throw new RuntimeException("Error: Label not provided."); - } - ResultCustomMetaDataField resultCustomMetaDataField = new ResultCustomMetaDataField(); - Map headers = Utils.getHeaders(imageKit); - - RequestBody requestBody = RequestBody.create(okhttp3.MediaType.parse("application/json"), - new Gson().toJson(customMetaDataFieldCreateRequest)); - request = new Request.Builder().url(API_BASE_URL.concat("v1/customMetadataFields")).post(requestBody) - .headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 201) { - respBody = response.body().string(); - JsonElement responseBody = new JsonParser().parse(respBody); - resultCustomMetaDataField = new Gson().fromJson(responseBody, ResultCustomMetaDataField.class); - } else { - if (response.code() == 400) { - ResultException result = Utils.populateResult(response); - throw new BadRequestException(result.getMessage(), null, false, false, result.getMessage(), - result.getHelp(), result.getResponseMetaData()); - } - } - Utils.populateResponseMetadata(respBody, resultCustomMetaDataField.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return resultCustomMetaDataField; - } - - public ResultNoContent deleteCustomMetaDataField(String id) throws NotFoundException, UnknownException { - ResultNoContent resultNoContent = new ResultNoContent(); - Map headers = Utils.getHeaders(imageKit); - - String url = String.format(Locale.US, API_BASE_URL.concat("v1/customMetadataFields/%s"), id); - - request = new Request.Builder().url(url).delete().headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 204) { - String respString = response.body().string(); - respBody = respString == null ? "" : respString; - } else { - if (response.code() == 404) { - ResultException result = Utils.populateResult(response); - throw new NotFoundException(result.getMessage(), null, false, false, result.getMessage(), - result.getHelp(), result.getResponseMetaData()); - } - } - Utils.populateResponseMetadata(respBody, resultNoContent.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return resultNoContent; - } - - public ResultCustomMetaDataField updateCustomMetaDataFields( - CustomMetaDataFieldUpdateRequest customMetaDataFieldUpdateRequest) - throws BadRequestException, NotFoundException, UnknownException { - ResultCustomMetaDataField resultCustomMetaDataField = new ResultCustomMetaDataField(); - - Map headers = Utils.getHeaders(imageKit); - - RequestBody requestBody = RequestBody.create(okhttp3.MediaType.parse("application/json"), - new Gson().toJson(customMetaDataFieldUpdateRequest)); - String url = String.format(Locale.US, API_BASE_URL.concat("v1/customMetadataFields/%s"), - customMetaDataFieldUpdateRequest.getId()); - request = new Request.Builder().url(url).patch(requestBody).headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 200) { - respBody = response.body().string(); - JsonElement responseBody = new JsonParser().parse(respBody); - resultCustomMetaDataField = new Gson().fromJson(responseBody, ResultCustomMetaDataField.class); - } else { - if (response.code() == 400 || response.code() == 404) { - ResultException result = Utils.populateResult(response); - if (response.code() == 400) { - throw new BadRequestException(result.getMessage(), null, false, false, result.getMessage(), - result.getHelp(), result.getResponseMetaData()); - } else { - throw new NotFoundException(result.getMessage(), null, false, false, result.getMessage(), - result.getHelp(), result.getResponseMetaData()); - } - } - } - Utils.populateResponseMetadata(respBody, resultCustomMetaDataField.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return resultCustomMetaDataField; - } - - public ResultNoContent deleteFileVersion(DeleteFileVersionRequest deleteFileVersionRequest) - throws BadRequestException, NotFoundException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - ResultNoContent resultNoContent = new ResultNoContent(); - - Map headers = Utils.getHeaders(imageKit); - - String url = String.format(Locale.US, API_BASE_URL.concat("v1/files/%s/versions/%s"), - deleteFileVersionRequest.getFileId(), deleteFileVersionRequest.getVersionId()); - request = new Request.Builder().url(url).delete().headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 204) { - String respString = response.body().string(); - respBody = respString == null ? "" : respString; - } else if (response.code() == 400 || response.code() == 404) { - ResultException result = Utils.populateResult(response); - if (response.code() == 400) { - throw new BadRequestException(result.getMessage(), null, false, false, result.getMessage(), - result.getHelp(), result.getResponseMetaData()); - } else { - throw new NotFoundException(result.getMessage(), null, false, false, result.getMessage(), - result.getHelp(), result.getResponseMetaData()); - } - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, resultNoContent.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return resultNoContent; - } - - public ResultNoContent copyFile(CopyFileRequest copyFileRequest) - throws NotFoundException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - ResultNoContent resultNoContent = new ResultNoContent(); - Map headers = Utils.getHeaders(imageKit); - - RequestBody requestBody = RequestBody.create(okhttp3.MediaType.parse("application/json"), - new Gson().toJson(copyFileRequest)); - request = new Request.Builder().url(API_BASE_URL.concat("v1/files/copy")).post(requestBody) - .headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 204) { - String respString = response.body().string(); - respBody = respString == null ? "" : respString; - } else if (response.code() == 404) { - ResultException result = Utils.populateResult(response); - throw new NotFoundException(result.getMessage(), null, false, false, result.getMessage(), - result.getHelp(), result.getResponseMetaData()); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, resultNoContent.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return resultNoContent; - } - - public ResultNoContent moveFile(MoveFileRequest moveFileRequest) - throws NotFoundException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - ResultNoContent resultNoContent = new ResultNoContent(); - Map headers = Utils.getHeaders(imageKit); - - RequestBody requestBody = RequestBody.create(okhttp3.MediaType.parse("application/json"), - new Gson().toJson(moveFileRequest)); - request = new Request.Builder().url(API_BASE_URL.concat("v1/files/move")).post(requestBody) - .headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 204) { - String respString = response.body().string(); - respBody = respString == null ? "" : respString; - } else if (response.code() == 404) { - ResultException result = Utils.populateResult(response); - throw new NotFoundException(result.getMessage(), null, false, false, result.getMessage(), - result.getHelp(), result.getResponseMetaData()); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, resultNoContent.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return resultNoContent; - } - - public ResultRenameFile renameFile(RenameFileRequest renameFileRequest) throws PartialSuccessException, - ConflictException, NotFoundException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - ResultRenameFile resultRenameFile = new ResultRenameFile(); - Map headers = Utils.getHeaders(imageKit); - - RequestBody requestBody = RequestBody.create(okhttp3.MediaType.parse("application/json"), - new Gson().toJson(renameFileRequest)); - request = new Request.Builder().url(API_BASE_URL.concat("v1/files/rename")).put(requestBody) - .headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 200) { - String respString = response.body().string(); - respBody = respString == null || respString.equals("") ? "{}" : respString; - resultRenameFile = new Gson().fromJson(respBody, ResultRenameFile.class); - } else if (response.code() == 207 || response.code() == 404) { - Utils.throwOtherException(response); - } else if (response.code() == 409) { - ResultException result = Utils.populateResult(response); - throw new ConflictException(result.getMessage(), null, false, false, result.getMessage(), - result.getHelp(), result.getResponseMetaData()); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, resultRenameFile.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return resultRenameFile; - } - - public Result restoreFileVersion(String fileId, String versionId) - throws NotFoundException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - Result resultFileVersionDetails = new Result(); - Map headers = Utils.getHeaders(imageKit); - - String url = String.format(Locale.US, API_BASE_URL.concat("v1/files/%s/versions/%s/restore"), fileId, - versionId); - RequestBody requestBody = RequestBody.create(okhttp3.MediaType.parse("application/json"), ""); - request = new Request.Builder().url(url).put(requestBody).headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 200) { - System.out.println("20000000000000"); - respBody = response.body().string(); - resultFileVersionDetails = new Gson().fromJson(respBody, Result.class); - } else if (response.code() == 404) { - System.out.println("400000000000004"); - ResultException result = Utils.populateResult(response); - throw new NotFoundException(result.getMessage(), null, false, false, result.getMessage(), - result.getHelp(), result.getResponseMetaData()); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, resultFileVersionDetails.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return resultFileVersionDetails; - } - - public ResultEmptyBlock createFolder(CreateFolderRequest createFolderRequest) throws UnknownException { - ResultEmptyBlock resultEmptyBlock = new ResultEmptyBlock(); - Map headers = Utils.getHeaders(imageKit); - - RequestBody requestBody = RequestBody.create(okhttp3.MediaType.parse("application/json"), - new Gson().toJson(createFolderRequest)); - request = new Request.Builder().url(API_BASE_URL.concat("v1/folder/")).post(requestBody) - .headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 201) { - String respString = response.body().string(); - respBody = respString == null || respString.equals("") ? "{}" : respString; - } - Utils.populateResponseMetadata(respBody, resultEmptyBlock.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return resultEmptyBlock; - } - - public ResultNoContent deleteFolder(DeleteFolderRequest deleteFolderRequest) - throws NotFoundException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - ResultNoContent resultNoContent = new ResultNoContent(); - Map headers = Utils.getHeaders(imageKit); - - RequestBody requestBody = RequestBody.create(okhttp3.MediaType.parse("application/json"), - new Gson().toJson(deleteFolderRequest)); - request = new Request.Builder().url(API_BASE_URL.concat("v1/folder/")).delete(requestBody) - .headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 204) { - String respString = response.body().string(); - respBody = respString == null ? "" : respString; - } else if (response.code() == 404) { - ResultException result = Utils.populateResult(response); - throw new NotFoundException(result.getMessage(), null, false, false, result.getMessage(), - result.getHelp(), result.getResponseMetaData()); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, resultNoContent.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return resultNoContent; - } - - public ResultOfFolderActions copyFolder(CopyFolderRequest copyFolderRequest) - throws NotFoundException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - ResultOfFolderActions resultOfFolderActions = new ResultOfFolderActions(); - Map headers = Utils.getHeaders(imageKit); - - RequestBody requestBody = RequestBody.create(okhttp3.MediaType.parse("application/json"), - new Gson().toJson(copyFolderRequest)); - - request = new Request.Builder().url(API_BASE_URL.concat("v1/bulkJobs/moveFolder")).post(requestBody) - .headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 200) { - respBody = response.body().string(); - resultOfFolderActions = new Gson().fromJson(respBody, ResultOfFolderActions.class); - } else if (response.code() == 404) { - ResultException result = Utils.populateResult(response); - throw new NotFoundException(result.getMessage(), null, false, false, result.getMessage(), - result.getHelp(), result.getResponseMetaData()); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, resultOfFolderActions.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return resultOfFolderActions; - } - - public ResultOfFolderActions moveFolder(MoveFolderRequest moveFolderRequest) - throws NotFoundException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - ResultOfFolderActions resultOfFolderActions = new ResultOfFolderActions(); - Map headers = Utils.getHeaders(imageKit); - - RequestBody requestBody = RequestBody.create(okhttp3.MediaType.parse("application/json"), - new Gson().toJson(moveFolderRequest)); - - request = new Request.Builder().url(API_BASE_URL.concat("v1/bulkJobs/moveFolder")).post(requestBody) - .headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 200) { - respBody = response.body().string(); - resultOfFolderActions = new Gson().fromJson(respBody, ResultOfFolderActions.class); - } else if (response.code() == 404) { - ResultException result = Utils.populateResult(response); - throw new NotFoundException(result.getMessage(), null, false, false, result.getMessage(), - result.getHelp(), result.getResponseMetaData()); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, resultOfFolderActions.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return resultOfFolderActions; - } - - public ResultBulkJobStatus getBulkJobStatus(String jobId) throws ForbiddenException, TooManyRequestsException, - InternalServerException, UnauthorizedException, BadRequestException, UnknownException { - ResultBulkJobStatus resultBulkJobStatus = new ResultBulkJobStatus(); - - Map headers = Utils.getHeaders(imageKit); - - String url = String.format(Locale.US, API_BASE_URL.concat("v1/bulkJobs/%s"), jobId); - - request = new Request.Builder().url(url).get().headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 200) { - respBody = response.body().string(); - resultBulkJobStatus = new Gson().fromJson(respBody, ResultBulkJobStatus.class); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, resultBulkJobStatus.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return resultBulkJobStatus; - } - - public ResultFileVersions getFileVersions(String fileId) - throws NotFoundException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - ResultFileVersions resultFileVersions = new ResultFileVersions(); - Map headers = Utils.getHeaders(imageKit); - - String url = String.format(Locale.US, API_BASE_URL.concat("v1/files/%s/versions"), fileId); - - request = new Request.Builder().url(url).get().headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 200) { - respBody = response.body().string(); - List resultFileVersionDetailsList = new Gson().fromJson(respBody, - new TypeToken>() { - }.getType()); - resultFileVersions.setResultFileVersionDetailsList(resultFileVersionDetailsList); - } else if (response.code() == 404) { - ResultException result = Utils.populateResult(response); - throw new NotFoundException(result.getMessage(), null, false, false, result.getMessage(), - result.getHelp(), result.getResponseMetaData()); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, resultFileVersions.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return resultFileVersions; - } - - public ResultFileVersionDetails getFileVersionDetails(String fileId, String versionId) - throws NotFoundException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - if (fileId == null) { - throw new RuntimeException("Error: FileId not provided."); - } - if (versionId == null) { - throw new RuntimeException("Error: versionId not provided."); - } - ResultFileVersionDetails resultFileVersionDetails = new ResultFileVersionDetails(); - Map headers = Utils.getHeaders(imageKit); - - String url = String.format(Locale.US, API_BASE_URL.concat("v1/files/%s/versions/%s"), fileId, versionId); - - request = new Request.Builder().url(url).get().headers(Headers.of(headers)).build(); - - try { - Response response = client.newCall(request).execute(); - String respBody = ""; - if (response.code() == 200) { - respBody = response.body().string(); - resultFileVersionDetails = new Gson().fromJson(respBody, ResultFileVersionDetails.class); - } else if (response.code() == 404) { - ResultException result = Utils.populateResult(response); - throw new NotFoundException(result.getMessage(), null, false, false, result.getMessage(), - result.getHelp(), result.getResponseMetaData()); - } else { - Utils.generalApiThrowException(response); - } - Utils.populateResponseMetadata(respBody, resultFileVersionDetails.getResponseMetaData(), response.code(), - response.headers().toMultimap()); - } catch (IOException e) { - throw new UnknownException(e.getMessage(), e.getCause()); - } - return resultFileVersionDetails; - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/tasks/UrlGen.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/tasks/UrlGen.java deleted file mode 100644 index 771e0783..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/tasks/UrlGen.java +++ /dev/null @@ -1,212 +0,0 @@ -package io.imagekit.sdk.tasks; - -import io.imagekit.sdk.ImageKit; -import io.imagekit.sdk.config.Configuration; -import io.imagekit.sdk.constants.Transformer; -import io.imagekit.sdk.constants.Version; -import org.apache.commons.codec.digest.HmacUtils; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.*; - -public class UrlGen { - - private static final long DEFAULT_TIMESTAMP = 9999999999L; - - public static String getUrl(Map options) { - String path = (String) options.get("path"); - String urlEndpoint = (String) options.get("urlEndpoint"); - String src = (String) options.get("src"); - Map queryParams = (Map) options.get("queryParameters"); - List> transformation = (List>) options.get("transformation"); - String transformationPosition = (String) options.get("transformationPosition"); - boolean signed = false; - if (null != options.get("signed")) { - signed = (boolean) options.get("signed"); - } - long expire = 0; - if (null != options.get("expireSeconds")) { - expire = (long) (int) options.get("expireSeconds"); - } - return UrlGen.generateUrl(path, urlEndpoint, src, queryParams, transformation, transformationPosition, signed, - expire); - } - - private static String generateUrl(String path, String urlEndpoint, String src, Map queryParameters, - List> transformation, String transformationPosition, boolean signed, - long expireSeconds) { - Configuration config = ImageKit.getInstance().getConfig(); - if (urlEndpoint == null) { - urlEndpoint = config.getUrlEndpoint(); - } - if (urlEndpoint.charAt(urlEndpoint.length() - 1) != '/') { - urlEndpoint += "/"; - } - String newUrl = null; - if (null != src) { - newUrl = buildFullUrl(src, queryParameters, transformation, transformationPosition, signed, expireSeconds, - config.getPrivateKey(), urlEndpoint); - } else { - if ("query".equalsIgnoreCase(transformationPosition)) { - newUrl = buildFullUrl(urlEndpoint + (path.charAt(0) == '/' ? path.substring(1, path.length()) : path), - queryParameters, transformation, transformationPosition, signed, expireSeconds, - config.getPrivateKey(), urlEndpoint); - } else { - newUrl = buildPathUrl(path.charAt(0) == '/' ? path : "/" + path, urlEndpoint, queryParameters, - transformation, transformationPosition, signed, expireSeconds, config.getPrivateKey()); - } - } - return newUrl; - } - - private static String buildPathUrl(String path, String urlEndpoint, Map queryParameters, - List> transformation, String transformationPosition, boolean signed, long expireSeconds, - String privateKey) { - - StringBuilder tr = new StringBuilder(""); - if (transformation != null && transformation.size() > 0) { - tr.append("tr"); - for (Map map : transformation) { - Set> entries = map.entrySet(); - tr.append(":"); - int i = 0; - for (Map.Entry entry : entries) { - String key = entry.getKey(); - String value = entry.getValue(); - String element = Transformer.getInstance().transform(key) - + (value.equalsIgnoreCase("-") ? "" : "-" + value); - tr.append(element.contains("oi") || element.contains("di") - ? element.replaceFirst("/", "").replaceAll("/", "@@") - : element); - if (i < entries.size() - 1) { - tr.append(","); - } - i++; - } - } - } - - QueryMaker queryMaker = new QueryMaker(); - if (null != queryParameters) { - for (Map.Entry entry : queryParameters.entrySet()) { - queryMaker.put(String.format(Locale.US, "%s=%s", entry.getKey(), entry.getValue())); - } - } - - URI baseUrl = URI.create(urlEndpoint); - URI newUri = null; - try { - String newPath = baseUrl.getPath(); - if (tr.toString().equalsIgnoreCase("")) { - newPath += path.substring(1, path.length()); - } else { - newPath += tr + path; - } - - URI tmpUri = new URI(baseUrl.getScheme(), baseUrl.getUserInfo(), baseUrl.getHost(), baseUrl.getPort(), - newPath, queryMaker.get(), null); - - if (signed) { - sign(urlEndpoint, expireSeconds, privateKey, queryMaker, tmpUri); - } - - newUri = new URI(baseUrl.getScheme(), baseUrl.getUserInfo(), baseUrl.getHost(), baseUrl.getPort(), newPath, - queryMaker.get(), null); - - } catch (URISyntaxException e) { - e.printStackTrace(); - } - return newUri.toString(); - } - - private static String buildFullUrl(String src, Map queryParameters, - List> transformation, String transformationPosition, boolean signed, long expireSeconds, - String privateKey, String urlEndpoint) { - StringBuilder tr = new StringBuilder(""); - if (transformation != null && transformation.size() > 0) { - tr.append("tr="); - for (Map map : transformation) { - Set> entries = map.entrySet(); - if (!tr.toString().equalsIgnoreCase("tr=")) - tr.append(":"); - int i = 0; - for (Map.Entry entry : entries) { - String key = entry.getKey(); - String value = entry.getValue(); - String element = Transformer.getInstance().transform(key) - + (value.equalsIgnoreCase("-") ? "" : "-" + value); - tr.append(element); - if (i < entries.size() - 1) { - tr.append(","); - } - i++; - } - } - } - - QueryMaker queryMaker = new QueryMaker(); - - // check existing query params - if (null != src) { - String[] parts = src.split("\\?"); - if (parts.length > 1) { - String[] queries = parts[1].split("&"); - for (String query : queries) { - queryMaker.put(query); - } - } - } - - if (null != queryParameters) { - for (Map.Entry entry : queryParameters.entrySet()) { - queryMaker.put(String.format(Locale.US, "%s=%s", entry.getKey(), entry.getValue())); - } - } - if (!tr.toString().equalsIgnoreCase("")) { - queryMaker.put(tr.toString()); - } - - URI baseUrl = URI.create(src); - URI newUri = null; - try { - String newPath = baseUrl.getPath(); - URI tmpUri = new URI(baseUrl.getScheme(), baseUrl.getUserInfo(), baseUrl.getHost(), baseUrl.getPort(), - newPath, queryMaker.get(), null); - - if (signed) { - sign(urlEndpoint, expireSeconds, privateKey, queryMaker, tmpUri); - } - - newUri = new URI(baseUrl.getScheme(), baseUrl.getUserInfo(), baseUrl.getHost(), baseUrl.getPort(), newPath, - queryMaker.get(), null); - } catch (URISyntaxException e) { - e.printStackTrace(); - } - return newUri.toString(); - } - - private static void sign(String urlEndpoint, long expireSeconds, String privateKey, QueryMaker queryMaker, - URI tmpUri) { - long expiryTimestamp = DEFAULT_TIMESTAMP; - if (expireSeconds > 0) { - expiryTimestamp = ((Calendar.getInstance().getTimeInMillis() / 1000) + expireSeconds); - } - String signature = signUrl(privateKey, tmpUri.toString(), urlEndpoint, expiryTimestamp); - if (expiryTimestamp > 0 && expiryTimestamp != DEFAULT_TIMESTAMP) { - queryMaker.put("ik-t=" + expiryTimestamp); - } - queryMaker.put("ik-s=" + signature); - } - - public static String signUrl(String privateKey, String url, String urlEndpoint, long expiryTimestamp) { - if (expiryTimestamp < 1) { - expiryTimestamp = DEFAULT_TIMESTAMP; - } - if (urlEndpoint.charAt(urlEndpoint.length() - 1) != '/') { - urlEndpoint += "/"; - } - String replaceUrl = url.replace(urlEndpoint, "") + expiryTimestamp; - return HmacUtils.hmacSha1Hex(privateKey, replaceUrl); - } -} diff --git a/imagekit-sdk/src/main/java/io/imagekit/sdk/utils/Utils.java b/imagekit-sdk/src/main/java/io/imagekit/sdk/utils/Utils.java deleted file mode 100644 index 19fa01cd..00000000 --- a/imagekit-sdk/src/main/java/io/imagekit/sdk/utils/Utils.java +++ /dev/null @@ -1,185 +0,0 @@ -package io.imagekit.sdk.utils; - -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; - -import io.imagekit.sdk.ImageKit; -import io.imagekit.sdk.config.Configuration; -import io.imagekit.sdk.exceptions.BadRequestException; -import io.imagekit.sdk.exceptions.ConflictException; -import io.imagekit.sdk.exceptions.ForbiddenException; -import io.imagekit.sdk.exceptions.InternalServerException; -import io.imagekit.sdk.exceptions.NotFoundException; -import io.imagekit.sdk.exceptions.PartialSuccessException; -import io.imagekit.sdk.exceptions.TooManyRequestsException; -import io.imagekit.sdk.exceptions.UnauthorizedException; -import io.imagekit.sdk.exceptions.UnknownException; -import io.imagekit.sdk.models.ResponseMetaData; -import io.imagekit.sdk.models.results.ResultCache; -import io.imagekit.sdk.models.results.ResultException; -import okhttp3.Credentials; -import okhttp3.Response; - -import java.io.*; -import java.util.ArrayList; -import java.util.Base64; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; -import java.util.Set; -import java.util.stream.Collectors; - -public class Utils { - - public static String listToString(List list) { - StringBuilder builder = new StringBuilder(); - for (int i = 0; i < list.size(); i++) { - if (null != list.get(i)) { - builder.append(list.get(i)); - if (i < list.size() - 1) { - builder.append(","); - } - } - } - return builder.toString(); - } - - public static String fileToBase64(File file) { - String base64File = ""; - try (FileInputStream imageInFile = new FileInputStream(file)) { - // Reading a file from file system - byte fileData[] = new byte[(int) file.length()]; - imageInFile.read(fileData); - base64File = Base64.getEncoder().encodeToString(fileData); - } catch (FileNotFoundException e) { - System.out.println("File not found" + e); - } catch (IOException ioe) { - System.out.println("Exception while reading the file " + ioe); - } - return base64File; - } - - public static byte[] fileToBytes(File file) { - byte[] bytes = null; - try (FileInputStream imageInFile = new FileInputStream(file)) { - // Reading a file from file system - bytes = new byte[(int) file.length()]; - imageInFile.read(bytes); - } catch (FileNotFoundException e) { - System.out.println("File not found" + e); - } catch (IOException ioe) { - System.out.println("Exception while reading the file " + ioe); - } - return bytes; - } - - public static String bytesToBase64(byte[] fileData) { - String base64File = ""; - base64File = Base64.getEncoder().encodeToString(fileData); - return base64File; - } - - /** - * - * @param cls is a Class name from which this method will invoke - * @return it will return object of Configuration class - * @throws IOException if config.properties file doesn't exists - */ - public static Configuration getSystemConfig(Class cls) throws IOException { - Properties properties = new Properties(); - String configFile = "config.properties"; - InputStream is = cls.getClassLoader().getResourceAsStream(configFile); - if (null != is) { - properties.load(is); - } else { - throw new FileNotFoundException("Property file '" + configFile + "' not found in classpath"); - } - Configuration config = new Configuration(); - config.setUrlEndpoint(properties.getProperty("UrlEndpoint")); - config.setPublicKey(properties.getProperty("PublicKey")); - config.setPrivateKey(properties.getProperty("PrivateKey")); - config.validate(); - return config; - } - - public static Map mapListOfStringToString(Map> listMap) { - Map stringMap = new HashMap<>(); - Set>> listMapEntries = listMap.entrySet(); - for (Entry> entry : listMapEntries) { - stringMap.put(entry.getKey(), entry.getValue().stream().collect(Collectors.joining(","))); - - } - return stringMap; - } - - public static void populateResponseMetadata(String respBody, ResponseMetaData responseMetadata, int responseCode, - Map> responseHeaders) throws IOException { - responseMetadata.setRaw(respBody); - if (responseHeaders != null) { - Map mappedHeader = Utils.mapListOfStringToString(responseHeaders); - responseMetadata.setHeaders(mappedHeader); - } - responseMetadata.setHttpStatusCode(responseCode); - } - - public static Map getHeaders(ImageKit imageKit) { - String credential = Credentials.basic(imageKit.getConfig().getPrivateKey(), ""); - Map headers = new HashMap<>(); - headers.put("Accept-Encoding", "application/json"); - headers.put("Content-Type", "application/json"); - headers.put("Authorization", credential); - return headers; - } - - public static void generalApiThrowException(Response response) - throws IOException, BadRequestException, InternalServerException, UnknownException, UnauthorizedException, - ForbiddenException, TooManyRequestsException { - ResultException result = populateResult(response); - if (response.code() == 400) { - throw new BadRequestException(result.getMessage(), null, false, false, result.getMessage(), - result.getHelp(), result.getResponseMetaData()); - } else if (response.code() == 401) { - throw new UnauthorizedException(result.getMessage(), null, false, false, result.getMessage(), - result.getHelp(), result.getResponseMetaData()); - } else if (response.code() == 403) { - throw new ForbiddenException(result.getMessage(), null, false, false, result.getMessage(), result.getHelp(), - result.getResponseMetaData()); - } else if (response.code() == 429) { - throw new TooManyRequestsException(result.getMessage(), null, false, false, result.getMessage(), - result.getHelp(), result.getResponseMetaData()); - } else if (response.code() == 500 || response.code() == 502 || response.code() == 503 - || response.code() == 504) { - throw new InternalServerException(result.getMessage(), null, false, false, result.getMessage(), - result.getHelp(), result.getResponseMetaData()); - } else { - throw new UnknownException(result.getMessage(), null, false, false, result.getMessage(), result.getHelp(), - result.getResponseMetaData()); - } - } - - public static void throwOtherException(Response response) - throws IOException, PartialSuccessException, NotFoundException, UnknownException { - ResultException result = populateResult(response); - if (response.code() == 207) { - throw new PartialSuccessException(result.getMessage(), null, false, false, result.getMessage(), - result.getHelp(), result.getResponseMetaData()); - } else if (response.code() == 404) { - throw new NotFoundException(result.getMessage(), null, false, false, result.getMessage(), result.getHelp(), - result.getResponseMetaData()); - } else { - throw new UnknownException(result.getMessage(), null, false, false, result.getMessage(), result.getHelp(), - result.getResponseMetaData()); - } - } - - public static ResultException populateResult(Response response) throws IOException { - String resp = response.body().string(); - ResultException result = new Gson().fromJson(resp, ResultException.class); - populateResponseMetadata(resp, result.getResponseMetaData(), response.code(), response.headers().toMultimap()); - return result; - } - -} diff --git a/imagekit-sdk/src/test/java/io/imagekit/sdk/FileOperationTest.java b/imagekit-sdk/src/test/java/io/imagekit/sdk/FileOperationTest.java deleted file mode 100644 index 95284133..00000000 --- a/imagekit-sdk/src/test/java/io/imagekit/sdk/FileOperationTest.java +++ /dev/null @@ -1,255 +0,0 @@ -package io.imagekit.sdk; - -import io.imagekit.sdk.exceptions.BadRequestException; -import io.imagekit.sdk.exceptions.ConflictException; -import io.imagekit.sdk.exceptions.ForbiddenException; -import io.imagekit.sdk.exceptions.InternalServerException; -import io.imagekit.sdk.exceptions.NotFoundException; -import io.imagekit.sdk.exceptions.PartialSuccessException; -import io.imagekit.sdk.exceptions.TooManyRequestsException; -import io.imagekit.sdk.exceptions.UnauthorizedException; -import io.imagekit.sdk.exceptions.UnknownException; -import io.imagekit.sdk.models.CopyFileRequest; -import io.imagekit.sdk.models.MoveFileRequest; -import io.imagekit.sdk.models.RenameFileRequest; -import io.imagekit.sdk.tasks.RestClient; -import io.imagekit.sdk.utils.Utils; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; - -import static org.junit.Assert.assertEquals; - -public class FileOperationTest { - private ImageKit SUT; - - @Before - public void setUp() throws Exception { - SUT = ImageKit.getInstance(); - SUT.setConfig(Utils.getSystemConfig(ImageKitTest.class)); - } - - @Test(expected = NotFoundException.class) - public void copyFile_404_Expected() - throws InterruptedException, IOException, NotFoundException, BadRequestException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - - CopyFileRequest copyFileRequest = new CopyFileRequest(); - copyFileRequest.setSourceFilePath("/sample_image.jpg"); - copyFileRequest.setDestinationPath("/Gallery/"); - copyFileRequest.setIncludeFileVersions(true); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404) - .setBody("{\n" + " \"message\": \"No file found with filePath /sample_image.jpg\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\",\n" - + " \"reason\": \"SOURCE_FILE_MISSING\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.copyFile(copyFileRequest); - server.takeRequest(); - } - - @Test - public void copyFile_successExpected() - throws InterruptedException, IOException, NotFoundException, BadRequestException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - - CopyFileRequest copyFileRequest = new CopyFileRequest(); - copyFileRequest.setSourceFilePath("/car_false.jpeg"); - copyFileRequest.setDestinationPath("/Gallery/"); - copyFileRequest.setIncludeFileVersions(true); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(204).setBody("")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.copyFile(copyFileRequest); - RecordedRequest request = server.takeRequest(); - - String copyFileRequestJson = "{\"sourceFilePath\":\"/car_false.jpeg\",\"destinationPath\":\"/Gallery/\",\"includeFileVersions\":true}"; - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals(copyFileRequestJson, utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("POST /v1/files/copy HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/files/copy"), request.getRequestUrl().toString()); - } - - @Test(expected = NotFoundException.class) - public void moveFile_404_Expected() - throws InterruptedException, IOException, NotFoundException, BadRequestException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - - MoveFileRequest moveFileRequest = new MoveFileRequest(); - moveFileRequest.setSourceFilePath("/demo1/sample_image_th.jpg"); - moveFileRequest.setDestinationPath("/"); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404) - .setBody("{\n" + " \"message\": \"No file found with filePath /demo1/sample_image_th.jpg\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\",\n" - + " \"reason\": \"SOURCE_FILE_MISSING\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.moveFile(moveFileRequest); - server.takeRequest(); - } - - @Test - public void moveFile_successExpected() - throws InterruptedException, IOException, NotFoundException, BadRequestException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - - MoveFileRequest moveFileRequest = new MoveFileRequest(); - moveFileRequest.setSourceFilePath("/new_la.jpg"); - moveFileRequest.setDestinationPath("test"); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(204).setBody("")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.moveFile(moveFileRequest); - RecordedRequest request = server.takeRequest(); - - String moveFileRequestJson = "{\"sourceFilePath\":\"/new_la.jpg\",\"destinationPath\":\"test\"}"; - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals(moveFileRequestJson, utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("POST /v1/files/move HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/files/move"), request.getRequestUrl().toString()); - } - - @Test(expected = NotFoundException.class) - public void renameFile_404_Expected() throws InterruptedException, IOException, ConflictException, - PartialSuccessException, NotFoundException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - - RenameFileRequest renameFileRequest = new RenameFileRequest(); - renameFileRequest.setFilePath("/sample_image_th.jpg"); - renameFileRequest.setNewFileName("new_car.jpg"); - renameFileRequest.setPurgeCache(true); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404) - .setBody("{\n" - + " \"message\": \"No file found in media library with filePath /sample_image_th.jpg\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\",\n" - + " \"reason\": \"FILE_MISSING\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.renameFile(renameFileRequest); - server.takeRequest(); - } - - @Test(expected = ConflictException.class) - public void renameFile_409_Expected() throws InterruptedException, IOException, ConflictException, - PartialSuccessException, NotFoundException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - - RenameFileRequest renameFileRequest = new RenameFileRequest(); - renameFileRequest.setFilePath("/new1.jpg"); - renameFileRequest.setNewFileName("new_car.jpg"); - renameFileRequest.setPurgeCache(false); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(409) - .setBody("{\n" - + " \"message\": \"File with name new_car.jpg already exists at the same location.\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\",\n" - + " \"reason\": \"FILE_ALREADY_EXISTS\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.renameFile(renameFileRequest); - server.takeRequest(); - } - - @Test - public void renameFile_successExpected() throws InterruptedException, IOException, ConflictException, - PartialSuccessException, NotFoundException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - - RenameFileRequest renameFileRequest = new RenameFileRequest(); - renameFileRequest.setFilePath("/car_false.jpeg"); - renameFileRequest.setNewFileName("new_car.jpeg"); - renameFileRequest.setPurgeCache(false); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("{}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.renameFile(renameFileRequest); - RecordedRequest request = server.takeRequest(); - - String renameFileRequestJson = "{\"filePath\":\"/car_false.jpeg\",\"newFileName\":\"new_car.jpeg\",\"purgeCache\":false}"; - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals(renameFileRequestJson, utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("PUT /v1/files/rename HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/files/rename"), request.getRequestUrl().toString()); - } - - @Test - public void renameFile_successExpected_with_purge_cache() throws InterruptedException, IOException, - ConflictException, PartialSuccessException, NotFoundException, BadRequestException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - - RenameFileRequest renameFileRequest = new RenameFileRequest(); - renameFileRequest.setFilePath("/car_false.jpeg"); - renameFileRequest.setNewFileName("new_car.jpeg"); - renameFileRequest.setPurgeCache(true); - - MockWebServer server = new MockWebServer(); - server.enqueue( - new MockResponse().setBody("{\n" + " \"purgeRequestId\": \"62b973a00f0ad4164f307dad\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.renameFile(renameFileRequest); - RecordedRequest request = server.takeRequest(); - - String renameFileRequestJson = "{\"filePath\":\"/car_false.jpeg\",\"newFileName\":\"new_car.jpeg\",\"purgeCache\":true}"; - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals(renameFileRequestJson, utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("PUT /v1/files/rename HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/files/rename"), request.getRequestUrl().toString()); - } - - @Test(expected = InternalServerException.class) - public void getBulkJobStatus_500_Expected() - throws InterruptedException, IOException, ForbiddenException, TooManyRequestsException, - InternalServerException, UnauthorizedException, BadRequestException, UnknownException { - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(500) - .setBody("{\n" - + " \"message\": \"We have experienced an internal error while processing your request.\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.getBulkJobStatus("jobId"); - server.takeRequest(); - } - - @Test - public void getBulkJobStatus_successExpected() - throws InterruptedException, IOException, ForbiddenException, TooManyRequestsException, - InternalServerException, UnauthorizedException, BadRequestException, UnknownException { - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("{\n" + " \"jobId\": \"629f44ac7eb0fe8173622d4b\",\n" - + " \"type\": \"MOVE_FOLDER\",\n" + " \"status\": \"Completed\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.getBulkJobStatus("629f44ac7eb0fe8173622d4b"); - RecordedRequest request = server.takeRequest(); - - assertEquals("application/json", request.getHeader("Content-Type")); - assertEquals("GET /v1/bulkJobs/629f44ac7eb0fe8173622d4b HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/bulkJobs/629f44ac7eb0fe8173622d4b"), - request.getRequestUrl().toString()); - } -} diff --git a/imagekit-sdk/src/test/java/io/imagekit/sdk/FolderOperationTest.java b/imagekit-sdk/src/test/java/io/imagekit/sdk/FolderOperationTest.java deleted file mode 100644 index 899fb0f6..00000000 --- a/imagekit-sdk/src/test/java/io/imagekit/sdk/FolderOperationTest.java +++ /dev/null @@ -1,227 +0,0 @@ -package io.imagekit.sdk; - -import io.imagekit.sdk.exceptions.BadRequestException; -import io.imagekit.sdk.exceptions.ForbiddenException; -import io.imagekit.sdk.exceptions.InternalServerException; -import io.imagekit.sdk.exceptions.NotFoundException; -import io.imagekit.sdk.exceptions.TooManyRequestsException; -import io.imagekit.sdk.exceptions.UnauthorizedException; -import io.imagekit.sdk.exceptions.UnknownException; -import io.imagekit.sdk.models.CopyFolderRequest; -import io.imagekit.sdk.models.CreateFolderRequest; -import io.imagekit.sdk.models.DeleteFolderRequest; -import io.imagekit.sdk.models.MoveFolderRequest; -import io.imagekit.sdk.tasks.RestClient; -import io.imagekit.sdk.utils.Utils; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; - -import static org.junit.Assert.assertEquals; - -public class FolderOperationTest { - private ImageKit SUT; - - @Before - public void setUp() throws Exception { - SUT = ImageKit.getInstance(); - SUT.setConfig(Utils.getSystemConfig(ImageKitTest.class)); - } - - @Test - public void createFolder_400_Expected() throws InterruptedException, IOException, UnknownException { - - CreateFolderRequest createFolderRequest = new CreateFolderRequest(); - createFolderRequest.setFolderName("/testFolder"); - createFolderRequest.setParentFolderPath("/"); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(400)); - server.enqueue( - new MockResponse().setBody("{\n" + " \"message\": \"folderName parameter cannot have a slash.\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.createFolder(createFolderRequest); - server.takeRequest(); - } - - @Test - public void createFolder_successExpected() throws InterruptedException, IOException, UnknownException { - - CreateFolderRequest createFolderRequest = new CreateFolderRequest(); - createFolderRequest.setFolderName("testFolder"); - createFolderRequest.setParentFolderPath("/"); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("{}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.createFolder(createFolderRequest); - RecordedRequest request = server.takeRequest(); - - String createFolderRequestJson = "{\"folderName\":\"testFolder\",\"parentFolderPath\":\"/\"}"; - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals(createFolderRequestJson, utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("POST /v1/folder/ HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/folder/"), request.getRequestUrl().toString()); - } - - @Test(expected = NotFoundException.class) - public void deleteFolder_404_Expected() - throws InterruptedException, IOException, NotFoundException, BadRequestException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - - DeleteFolderRequest deleteFolderRequest = new DeleteFolderRequest(); - deleteFolderRequest.setFolderPath("/testFolder"); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404) - .setBody("{\n" + " \"message\": \"No folder found with folderPath testFolder/\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\",\n" - + " \"reason\": \"FOLDER_NOT_FOUND\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.deleteFolder(deleteFolderRequest); - server.takeRequest(); - } - - @Test - public void deleteFolder_successExpected() - throws InterruptedException, IOException, NotFoundException, BadRequestException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - - DeleteFolderRequest deleteFolderRequest = new DeleteFolderRequest(); - deleteFolderRequest.setFolderPath("testFolder"); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(204).setBody("")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.deleteFolder(deleteFolderRequest); - RecordedRequest request = server.takeRequest(); - - String deleteFolderRequestJson = "{\"folderPath\":\"testFolder\"}"; - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals(deleteFolderRequestJson, utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("DELETE /v1/folder/ HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/folder/"), request.getRequestUrl().toString()); - } - - @Test(expected = BadRequestException.class) - public void copyFolder_400_Expected() - throws InterruptedException, IOException, NotFoundException, BadRequestException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - - CopyFolderRequest copyFolderRequest = new CopyFolderRequest(); - copyFolderRequest.setSourceFolderPath("/"); - copyFolderRequest.setDestinationPath("/test"); - copyFolderRequest.setIncludeFileVersions(false); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(400) - .setBody("{\n" + " \"message\": \"sourceFolderPath cannot be root\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\",\n" - + " \"reason\": \"SOURCE_IS_ROOT\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.copyFolder(copyFolderRequest); - server.takeRequest(); - } - - @Test(expected = NotFoundException.class) - public void copyFolder_404_Expected() - throws InterruptedException, IOException, NotFoundException, BadRequestException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - - CopyFolderRequest copyFolderRequest = new CopyFolderRequest(); - copyFolderRequest.setSourceFolderPath("/testFolder"); - copyFolderRequest.setDestinationPath("/test"); - copyFolderRequest.setIncludeFileVersions(true); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404) - .setBody("{\n" + " \"message\": \"No files & folder found at sourceFolderPath /testFolder\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\",\n" - + " \"reason\": \"NO_FILES_FOLDER\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.copyFolder(copyFolderRequest); - server.takeRequest(); - } - - @Test - public void copyFolder_successExpected() - throws InterruptedException, IOException, NotFoundException, BadRequestException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - - CopyFolderRequest copyFolderRequest = new CopyFolderRequest(); - copyFolderRequest.setSourceFolderPath("/testFolder"); - copyFolderRequest.setDestinationPath("/Gallery"); - copyFolderRequest.setIncludeFileVersions(true); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("{\n" + " \"jobId\": \"629f43017eb0feff5c61f83c\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.copyFolder(copyFolderRequest); - RecordedRequest request = server.takeRequest(); - - String copyFolderRequestJson = "{\"sourceFolderPath\":\"/testFolder\",\"destinationPath\":\"/Gallery\",\"includeFileVersions\":true}"; - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals(copyFolderRequestJson, utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("POST /v1/bulkJobs/moveFolder HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/bulkJobs/moveFolder"), request.getRequestUrl().toString()); - } - - @Test(expected = NotFoundException.class) - public void moveFolder_404_Expected() - throws InterruptedException, IOException, NotFoundException, BadRequestException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - - MoveFolderRequest moveFolderRequest = new MoveFolderRequest(); - moveFolderRequest.setSourceFolderPath("/testFolder/"); - moveFolderRequest.setDestinationPath("/Gallery"); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404) - .setBody("{\n" + " \"message\": \"No files & folder found at sourceFolderPath /testFolder\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\",\n" - + " \"reason\": \"NO_FILES_FOLDER\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.moveFolder(moveFolderRequest); - server.takeRequest(); - } - - @Test - public void moveFolder_successExpected() - throws InterruptedException, IOException, NotFoundException, BadRequestException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - - MoveFolderRequest moveFolderRequest = new MoveFolderRequest(); - moveFolderRequest.setSourceFolderPath("/testFolder"); - moveFolderRequest.setDestinationPath("/Gallery"); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("{\n" + " \"jobId\": \"629f44ac7eb0fe8173622d4b\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.moveFolder(moveFolderRequest); - RecordedRequest request = server.takeRequest(); - - String moveFolderRequestJson = "{\"sourceFolderPath\":\"/testFolder\",\"destinationPath\":\"/Gallery\"}"; - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals(moveFolderRequestJson, utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("POST /v1/bulkJobs/moveFolder HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/bulkJobs/moveFolder"), request.getRequestUrl().toString()); - } -} diff --git a/imagekit-sdk/src/test/java/io/imagekit/sdk/GetUrlTest.java b/imagekit-sdk/src/test/java/io/imagekit/sdk/GetUrlTest.java deleted file mode 100644 index 8a79b129..00000000 --- a/imagekit-sdk/src/test/java/io/imagekit/sdk/GetUrlTest.java +++ /dev/null @@ -1,491 +0,0 @@ -package io.imagekit.sdk; - -import io.imagekit.sdk.utils.Utils; -import org.hamcrest.MatcherAssert; -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Pattern; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -public class GetUrlTest { - private static final Pattern IMAGEKIT_SIGNED_URL_PATTERN = Pattern.compile("(https://.*)\\?ik-t=(.*)&ik-s=(.*)"); - private ImageKit SUT; - - @Before - public void setUp() throws Exception { - SUT = ImageKit.getInstance(); - SUT.setConfig(Utils.getSystemConfig(ImageKitTest.class)); - } - - private void assertSignedUrl(String expectedBaseUrl, String actualUrl) { - java.util.regex.Matcher matcher = IMAGEKIT_SIGNED_URL_PATTERN.matcher(actualUrl); - assertTrue(actualUrl + " does not look like a signed url", matcher.matches()); - assertEquals(expectedBaseUrl, matcher.group(1)); - assertFalse(matcher.group(2).trim().isEmpty()); - assertFalse(matcher.group(3).trim().isEmpty()); - } - - @Test - public void getUrl_with_height_width_options() { - List> transformation = new ArrayList<>(); - Map scale = new HashMap<>(); - scale.put("height", "600"); - scale.put("width", "400"); - transformation.add(scale); - - Map options = new HashMap<>(); - options.put("path", "/default-image.jpg"); - options.put("transformation", transformation); - String url = SUT.getUrl(options); - - assertThat(SUT.getConfig().getUrlEndpoint() + "/tr:w-400,h-600/default-image.jpg", is(url)); - } - - @Test - public void getUrl_with_height_width_options_url_version_check() { - List> transformation = new ArrayList<>(); - Map scale = new HashMap<>(); - scale.put("height", "600"); - scale.put("width", "400"); - transformation.add(scale); - Map options = new HashMap<>(); - options.put("path", "/default-image.jpg"); - options.put("transformation", transformation); - String url = SUT.getUrl(options); - assertThat(SUT.getConfig().getUrlEndpoint() + "/tr:w-400,h-600/default-image.jpg", is(url)); - } - - @Test - public void getUrl_with_new_transformation_params_options() throws IOException { - SUT = ImageKit.getInstance(); - SUT.setConfig(Utils.getSystemConfig(ImageKitTest.class)); - List> transformation = new ArrayList<>(); - Map scale = new HashMap<>(); - scale.put("height", "600"); - scale.put("width", "400"); - transformation.add(scale); - Map newParams = new HashMap<>(); - newParams.put("myparam", "40"); - transformation.add(newParams); - - Map options = new HashMap<>(); - options.put("path", "/default-image.jpg"); - options.put("transformation", transformation); - String url = SUT.getUrl(options); - assertThat(SUT.getConfig().getUrlEndpoint() + "/tr:w-400,h-600:myparam-40/default-image.jpg", is(url)); - } - - @Test - public void getUrl_with_slash_in_path() { - List> transformation = new ArrayList<>(); - Map scale = new HashMap<>(); - scale.put("height", "600"); - scale.put("width", "400"); - transformation.add(scale); - - Map options = new HashMap<>(); - options.put("path", "/default-image.jpg"); - options.put("transformation", transformation); - String url = SUT.getUrl(options); - assertThat(SUT.getConfig().getUrlEndpoint() + "/tr:w-400,h-600/default-image.jpg", is(url)); - } - - @Test - public void getUrl_without_slash_in_path() { - List> transformation = new ArrayList<>(); - Map scale = new HashMap<>(); - scale.put("height", "600"); - scale.put("width", "400"); - transformation.add(scale); - Map options = new HashMap<>(); - options.put("path", "default-image.jpg"); - options.put("transformation", transformation); - String url = SUT.getUrl(options); - assertThat(SUT.getConfig().getUrlEndpoint() + "/tr:w-400,h-600/default-image.jpg", is(url)); - } - - @Test - public void getUrl_with_overriding_urlEndpoint() { - List> transformation = new ArrayList<>(); - Map scale = new HashMap<>(); - scale.put("height", "600"); - scale.put("width", "400"); - transformation.add(scale); - - Map options = new HashMap<>(); - options.put("path", "/default-image.jpg"); - options.put("urlEndpoint", "https://ik.imagekit.io/your_imagekit_id/different-url-endpoint-prefix"); - options.put("transformation", transformation); - - String url = SUT.getUrl(options); - assertThat( - "https://ik.imagekit.io/your_imagekit_id/different-url-endpoint-prefix/tr:w-400,h-600/default-image.jpg", - is(url)); - } - - @Test - public void getUrl_with_transformation_parameters() { - List> transformation = new ArrayList>(); - Map scale = new HashMap<>(); - scale.put("height", "600"); - scale.put("width", "400"); - scale.put("aspectRatio", "4-3"); - scale.put("quality", "40"); - scale.put("crop", "force"); - scale.put("cropMode", "extract"); - scale.put("focus", "left"); - scale.put("format", "png"); - scale.put("radius", "20"); - scale.put("background", "A94D34"); - scale.put("border", "5-A94D34"); - scale.put("rotation", "90"); - scale.put("blur", "10"); - scale.put("named", "any_name"); - scale.put("overlayImage", "/folder/file.jpg"); - scale.put("overlayX", "20"); - scale.put("overlayY", "10"); - scale.put("overlayFocus", "top"); - scale.put("overlayHeight", "20"); - scale.put("overlayWidth", "20"); - scale.put("overlayText", "Image Text"); - scale.put("overlayTextFontSize", "18"); - scale.put("overlayTextFontFamily", "Open Sans"); - scale.put("overlayTextColor", "00FFFF"); - scale.put("overlayAlpha", ""); - scale.put("overlayTextTypography", "b"); - scale.put("overlayBackground", "00AAFF55"); - scale.put("overlayImageTrim", String.valueOf(false)); - scale.put("progressive", String.valueOf(true)); - scale.put("lossless", String.valueOf(true)); - scale.put("trim", "5"); - scale.put("metadata", String.valueOf(true)); - scale.put("colorProfile", String.valueOf(true)); - scale.put("defaultImage", "/folder/file.jpg"); - scale.put("dpr", "3"); - scale.put("effectSharpen", "-"); - scale.put("effectUSM", ""); - scale.put("effectContrast", "1"); - scale.put("effectGray", ""); - scale.put("original", String.valueOf(true)); - scale.put("raw", "w-200,h-200"); - scale.put("overlayImage", "oi"); - scale.put("overlayImageTrim", "oit"); - scale.put("overlayImageAspectRatio", "oiar"); - scale.put("overlayImageBackground", "oibg"); - scale.put("overlayImageBorder", "oib"); - scale.put("overlayImageDPR", "oidpr"); - scale.put("overlayImageQuality", "oiq"); - scale.put("overlayImageCropping", "oic"); - scale.put("overlayImageFocus", "oifo"); - - transformation.add(scale); - - Map options = new HashMap<>(); - options.put("path", "/default-image.jpg"); - options.put("urlEndpoint", "https://ik.imagekit.io/your_imagekit_id/"); - options.put("transformation", transformation); - - String url = SUT.getUrl(options); - assertThat( - "https://ik.imagekit.io/your_imagekit_id/tr:cm-extract,ofo-top,n-any_name,md-true,ow-20,e-contrast-1,oiar-oiar,fo-left,bl-10,ar-4-3,oit-oit,e-usm-,oidpr-oidpr,oa-,obg-00AAFF55,ots-18,t-5,oh-20,oic-oic,cp-true,r-20,ox-20,ot-Image%20Text,oy-10,otc-00FFFF,di-folder@@file.jpg,h-600,b-5-A94D34,orig-true,rt-90,dpr-3,f-png,raw-w-200,h-200,lo-true,e-grayscale-,oibg-oibg,q-40,ott-b,oib-oib,oiq-oiq,bg-A94D34,w-400,pr-true,e-sharpen,oi-oi,oifo-oifo,c-force,otf-Open%20Sans/default-image.jpg", - is(url)); - } - - @Test - public void getUrl_with_overriding_urlEndpoint_double_slash_tests() { - List> transformation = new ArrayList>(); - Map scale = new HashMap<>(); - scale.put("height", "600"); - scale.put("width", "400"); - transformation.add(scale); - - Map options = new HashMap<>(); - options.put("path", "/default-image.jpg"); - options.put("urlEndpoint", "https://ik.imagekit.io/your_imagekit_id/"); - options.put("transformation", transformation); - - String url = SUT.getUrl(options); - assertThat("https://ik.imagekit.io/your_imagekit_id/tr:w-400,h-600/default-image.jpg", is(url)); - } - - @Test - public void getUrl_with_options_as_query() { - Map queryParams = new HashMap<>(); - queryParams.put("v", "123"); - - List> transformation = new ArrayList<>(); - Map scale = new HashMap<>(); - scale.put("height", "600"); - scale.put("width", "400"); - transformation.add(scale); - - Map options = new HashMap<>(); - options.put("path", "/default-image.jpg"); - options.put("queryParameters", queryParams); - options.put("transformation", transformation); - options.put("transformationPosition", "query"); - - String url = SUT.getUrl(options); - MatcherAssert.assertThat(SUT.getConfig().getUrlEndpoint() + "/default-image.jpg?v=123&tr=w-400,h-600", is(url)); - } - - @Test() - public void getUrl_with_options_as_path() { - Map queryParams = new HashMap<>(); - queryParams.put("v", "123"); - - List> transformation = new ArrayList<>(); - Map scale = new HashMap<>(); - scale.put("height", "600"); - scale.put("width", "400"); - transformation.add(scale); - - Map options = new HashMap<>(); - options.put("path", "/default-image.jpg"); - options.put("queryParameters", queryParams); - options.put("transformation", transformation); - - String url = SUT.getUrl(options); - assertThat(SUT.getConfig().getUrlEndpoint() + "/tr:w-400,h-600/default-image.jpg?v=123", is(url)); - } - - @Test - public void getUrl_with_chained_transformation_options_as_query() { - Map queryParams = new HashMap<>(); - queryParams.put("v", "123"); - - List> transformation = new ArrayList<>(); - Map scale = new HashMap<>(); - scale.put("height", "600"); - scale.put("width", "400"); - transformation.add(scale); - Map rotate = new HashMap<>(); - rotate.put("rotation", "90"); - transformation.add(rotate); - - Map options = new HashMap<>(); - options.put("path", "/default-image.jpg"); - options.put("queryParameters", queryParams); - options.put("transformation", transformation); - options.put("transformationPosition", "query"); - - String url = SUT.getUrl(options); - assertThat(SUT.getConfig().getUrlEndpoint() + "/default-image.jpg?v=123&tr=w-400,h-600:rt-90", is(url)); - } - - @Test - public void getUrl_with_chained_transformation_options_as_path() { - Map queryParams = new HashMap<>(); - queryParams.put("v", "123"); - - List> transformation = new ArrayList<>(); - Map scale = new HashMap<>(); - scale.put("height", "600"); - scale.put("width", "400"); - transformation.add(scale); - Map rotate = new HashMap<>(); - rotate.put("rotation", "90"); - transformation.add(rotate); - - Map options = new HashMap<>(); - options.put("path", "/default-image.jpg"); - options.put("queryParameters", queryParams); - options.put("transformation", transformation); - - String url = SUT.getUrl(options); - assertThat(SUT.getConfig().getUrlEndpoint() + "/tr:w-400,h-600:rt-90/default-image.jpg?v=123", is(url)); - } - - @Test - public void getUrl_with_multiple_query_params_addition_check() { - Map queryParams = new HashMap<>(); - queryParams.put("v", "123"); - queryParams.put("z", "234"); - - List> transformation = new ArrayList<>(); - Map scale = new HashMap<>(); - scale.put("height", "600"); - scale.put("width", "400"); - transformation.add(scale); - - Map options = new HashMap<>(); - options.put("src", "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?q=abc"); - options.put("queryParameters", queryParams); - options.put("transformation", transformation); - - String url = SUT.getUrl(options); - assertThat( - "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?q=abc&v=123&z=234&tr=w-400,h-600", - is(url)); - } - - @Test - public void getUrl_with_double_and_check() { - Map queryParams = new HashMap<>(); - queryParams.put("v", "123"); - queryParams.put("z", "234"); - - List> transformation = new ArrayList<>(); - Map scale = new HashMap<>(); - scale.put("height", "600"); - scale.put("width", "400"); - transformation.add(scale); - - Map options = new HashMap<>(); - options.put("src", "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?q=abc&&"); - options.put("queryParameters", queryParams); - options.put("transformation", transformation); - - String url = SUT.getUrl(options); - assertThat( - "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?q=abc&v=123&z=234&tr=w-400,h-600", - is(url)); - } - - @Test - public void getUrl_with_double_question_mark_check() { - Map queryParams = new HashMap<>(); - queryParams.put("v", "123"); - queryParams.put("z", "234"); - - List> transformation = new ArrayList<>(); - Map scale = new HashMap<>(); - scale.put("height", "600"); - scale.put("width", "400"); - transformation.add(scale); - - Map options = new HashMap<>(); - options.put("src", "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg??"); - options.put("queryParameters", queryParams); - options.put("transformation", transformation); - - String url = SUT.getUrl(options); - assertThat("https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?v=123&z=234&tr=w-400,h-600", - is(url)); - } - - @Test - public void getUrl_with_src() { - List> transformation = new ArrayList<>(); - Map scale = new HashMap<>(); - scale.put("height", "600"); - scale.put("width", "400"); - transformation.add(scale); - - Map options = new HashMap<>(); - options.put("src", "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg"); - options.put("transformation", transformation); - - String url = SUT.getUrl(options); - assertThat("https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?tr=w-400,h-600", is(url)); - } - - @Test - public void getUrl_src_with_query_params() { - Map queryParams = new HashMap<>(); - queryParams.put("v", "123"); - queryParams.put("z", "234"); - - List> transformation = new ArrayList<>(); - Map scale = new HashMap<>(); - scale.put("height", "600"); - scale.put("width", "400"); - transformation.add(scale); - - Map options = new HashMap<>(); - options.put("src", "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?srcParam=srcParamValue"); - options.put("queryParameters", queryParams); - options.put("transformation", transformation); - - String url = SUT.getUrl(options); - assertThat( - "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?srcParam=srcParamValue&v=123&z=234&tr=w-400,h-600", - is(url)); - } - - @Test - public void getUrl_src_with_query_params_but_transformationPosition_is_path() { - Map queryParam = new HashMap<>(); - queryParam.put("v", "123"); - queryParam.put("z", "234"); - - List> transformation = new ArrayList>(); - Map scale = new HashMap<>(); - scale.put("height", "600"); - scale.put("width", "400"); - transformation.add(scale); - - Map options = new HashMap<>(); - options.put("src", "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg"); - options.put("queryParameters", queryParam); - options.put("transformation", transformation); - options.put("transformationPosition", "path"); - - String url = SUT.getUrl(options); - assertThat("https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?v=123&z=234&tr=w-400,h-600", - is(url)); - } - - @Test - public void getUrl_with_signature() { - List> transformation = new ArrayList>(); - Map scale = new HashMap<>(); - scale.put("width", "100"); - transformation.add(scale); - - Map options = new HashMap<>(); - options.put("path", "/test-signed-url.png"); - options.put("transformation", transformation); - options.put("signed", true); - options.put("expireSeconds", 1000); - - String url = SUT.getUrl(options); - - assertSignedUrl("https://ik.imagekit.io/imagekit_id/tr:w-100/test-signed-url.png", url); - } - - @Test - public void getUrl_with_signature_src_noTransform() { - Map options = new HashMap<>(); - options.put("src", "https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg"); - options.put("signed", true); - options.put("expireSeconds", 1000); - - String url = SUT.getUrl(options); - - assertSignedUrl("https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg", url); - } - - @Test - public void getUrl_with_time_expire() { - List> transformation = new ArrayList>(); - Map scale = new HashMap<>(); - scale.put("height", "600"); - scale.put("width", "400"); - transformation.add(scale); - Map rotate = new HashMap<>(); - rotate.put("rotation", "90"); - transformation.add(rotate); - - Map options = new HashMap<>(); - options.put("path", "/default-image.jpg"); - options.put("transformation", transformation); - options.put("expireSeconds", 100); - options.put("signed", true); - - String url = SUT.getUrl(options); - assertTrue(url.contains("ik-t")); - } -} diff --git a/imagekit-sdk/src/test/java/io/imagekit/sdk/ImageKitTest.java b/imagekit-sdk/src/test/java/io/imagekit/sdk/ImageKitTest.java deleted file mode 100644 index ba2123ef..00000000 --- a/imagekit-sdk/src/test/java/io/imagekit/sdk/ImageKitTest.java +++ /dev/null @@ -1,82 +0,0 @@ -package io.imagekit.sdk; - -import io.imagekit.sdk.config.Configuration; -import io.imagekit.sdk.utils.Utils; -import org.junit.Before; -import org.junit.Test; - -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -public class ImageKitTest { - private ImageKit SUT; - - @Before - public void setUp() throws Exception { - SUT = ImageKit.getInstance(); - SUT.setConfig(Utils.getSystemConfig(ImageKitTest.class)); - } - - @Test - public void imageKit_configurationTest() { - Configuration config = new Configuration(); - config.setPrivateKey("private_Key"); - config.setPublicKey("public_key"); - config.setUrlEndpoint("url_end_point"); - ImageKit.getInstance().setConfig(config); - assertEquals(config.toString(), ImageKit.getInstance().getConfig().toString()); - } - - @Test - public void withoutToken_getAuthenticationParameters_successExpected() { - Map auth = SUT.getAuthenticationParameters(); - assertNotNull(auth); - } - - @Test(expected = RuntimeException.class) - public void withoutPrivateKey_getAuthenticationParameters_successExpected() { - SUT.getConfig().setPrivateKey(null); - Map auth = SUT.getAuthenticationParameters(); - assertNotNull(auth); - } - - @Test - public void withTokenAndExpire_getAuthenticationParameters_successExpected() { - Map auth = SUT.getAuthenticationParameters("your_token", 1582269249); - assertNotNull(auth); - assertEquals("your_token", auth.get("token")); - assertEquals("1582269249", auth.get("expire")); - assertEquals("e71bcd6031016b060d349d212e23e85c791decdd", auth.get("signature")); - } - - @Test - public void sameImage_getHammingDistance_expectedSuccessWith() { - int hammingDistance = SUT.pHashDistance("f06830ca9f1e3e90", "f06830ca9f1e3e90"); - assertEquals(0, hammingDistance); - } - - @Test - public void similarImage_getHammingDistance_expectedSuccessWith() { - int hammingDistance = SUT.pHashDistance("33699c96619cc69e", "968e978414fe04ea"); - assertEquals(30, hammingDistance); - } - - @Test - public void dissimilarImage_getHammingDistance_expectedSuccessWith() { - int hammingDistance = SUT.pHashDistance("a4a65595ac94518b", "7838873e791f8400"); - assertEquals(37, hammingDistance); - } - - @Test(expected = RuntimeException.class) - public void invalidHash_getHammingDistance_throwException() { - int hammingDistance = SUT.pHashDistance("a4a65595ac94518Z", "7838873e791f8400"); - } - - @Test(expected = RuntimeException.class) - public void differentLength_getHammingDistance_throwException() { - int hammingDistance = SUT.pHashDistance("a4a65595ac94518b3", "7838873e791f8400"); - } - -} \ No newline at end of file diff --git a/imagekit-sdk/src/test/java/io/imagekit/sdk/PurgeCacheTest.java b/imagekit-sdk/src/test/java/io/imagekit/sdk/PurgeCacheTest.java deleted file mode 100644 index cbb68f95..00000000 --- a/imagekit-sdk/src/test/java/io/imagekit/sdk/PurgeCacheTest.java +++ /dev/null @@ -1,98 +0,0 @@ -package io.imagekit.sdk; - -import io.imagekit.sdk.exceptions.BadRequestException; -import io.imagekit.sdk.exceptions.ForbiddenException; -import io.imagekit.sdk.exceptions.InternalServerException; -import io.imagekit.sdk.exceptions.TooManyRequestsException; -import io.imagekit.sdk.exceptions.UnauthorizedException; -import io.imagekit.sdk.exceptions.UnknownException; -import io.imagekit.sdk.tasks.RestClient; -import io.imagekit.sdk.utils.Utils; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; - -import static org.junit.Assert.assertEquals; - -public class PurgeCacheTest { - - private ImageKit SUT; - - @Before - public void setUp() throws Exception { - SUT = ImageKit.getInstance(); - SUT.setConfig(Utils.getSystemConfig(ImageKitTest.class)); - } - - @Test(expected = BadRequestException.class) - public void imageKit_purgeCache_404Expected() - throws ForbiddenException, TooManyRequestsException, InternalServerException, UnauthorizedException, - BadRequestException, UnknownException, InterruptedException, IOException { - MockWebServer server = new MockWebServer(); - String responseJson = "{\n" + " \"message\": \"Invalid url\"\n" + "}"; - server.enqueue(new MockResponse().setResponseCode(400).setBody(responseJson)); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.purgeCache("url"); - - server.takeRequest(); - } - - @Test - public void imageKit_purgeCache_successExpected() - throws IOException, ForbiddenException, TooManyRequestsException, InternalServerException, - UnauthorizedException, BadRequestException, UnknownException, InterruptedException { - MockWebServer server = new MockWebServer(); - String responseJson = "{\n" + " \"requestId\": \"62b01f15214dfbdf3692dd0a\"\n" + "}"; - server.enqueue(new MockResponse().setBody(responseJson)); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.purgeCache("https://ik.imagekit.io/zv3rkhsym/sample-image11_g1Qv0wpqP.jpg"); - - RecordedRequest request = server.takeRequest(); - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals("{\"url\":\"https://ik.imagekit.io/zv3rkhsym/sample-image11_g1Qv0wpqP.jpg\"}", utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("POST /v1/files/purge HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/files/purge"), request.getRequestUrl().toString()); - } - - @Test(expected = BadRequestException.class) - public void imageKit_getPurgeCacheStatus_400Expected() - throws ForbiddenException, TooManyRequestsException, InternalServerException, UnauthorizedException, - BadRequestException, UnknownException, InterruptedException, IOException { - MockWebServer server = new MockWebServer(); - String responseJson = "{\n" + " \"message\": \"No request found for this requestId.\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\"\n" + "}"; - server.enqueue(new MockResponse().setResponseCode(400).setBody(responseJson)); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.getPurgeCacheStatus("62b01f15214dfbdf3692dd0b"); - - server.takeRequest(); - } - - @Test - public void imageKit_getPurgeCacheStatus_successExpected() - throws ForbiddenException, TooManyRequestsException, InternalServerException, UnauthorizedException, - BadRequestException, UnknownException, InterruptedException, IOException { - MockWebServer server = new MockWebServer(); - String responseJson = "{\n" + " \"status\": \"Completed\"\n" + "}"; - server.enqueue(new MockResponse().setBody(responseJson)); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.getPurgeCacheStatus("62b01f15214dfbdf3692dd0a"); - - RecordedRequest request = server.takeRequest(); - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals("", utf8RequestBody); - assertEquals("application/json", request.getHeader("Content-Type")); - assertEquals("GET /v1/files/purge/62b01f15214dfbdf3692dd0a HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/files/purge/62b01f15214dfbdf3692dd0a"), - request.getRequestUrl().toString()); - } -} diff --git a/imagekit-sdk/src/test/java/io/imagekit/sdk/UploadTest.java b/imagekit-sdk/src/test/java/io/imagekit/sdk/UploadTest.java deleted file mode 100644 index ad075804..00000000 --- a/imagekit-sdk/src/test/java/io/imagekit/sdk/UploadTest.java +++ /dev/null @@ -1,251 +0,0 @@ -package io.imagekit.sdk; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import io.imagekit.sdk.exceptions.BadRequestException; -import io.imagekit.sdk.exceptions.ForbiddenException; -import io.imagekit.sdk.exceptions.InternalServerException; -import io.imagekit.sdk.exceptions.TooManyRequestsException; -import io.imagekit.sdk.exceptions.UnauthorizedException; -import io.imagekit.sdk.exceptions.UnknownException; -import io.imagekit.sdk.models.FileCreateRequest; -import io.imagekit.sdk.tasks.RestClient; -import io.imagekit.sdk.utils.Utils; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URL; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertEquals; - -public class UploadTest { - private ImageKit SUT; - - @Before - public void setUp() throws Exception { - SUT = ImageKit.getInstance(); - SUT.setConfig(Utils.getSystemConfig(ImageKitTest.class)); - } - - @Test(expected = UnknownHostException.class) - public void imageKit_upload_expect_UnknownHostException() throws IOException { - String imageUrl = "https://homepagesabc.cae.wisc.edu/~ece533/images/12.png"; - URL url = new URL(imageUrl); - HttpURLConnection urlConnect = (HttpURLConnection) url.openConnection(); - urlConnect.getContent(); - } - - @Test(expected = RuntimeException.class) - public void imageKit_upload_expected_RuntimeException_for_file() - throws IOException, InterruptedException, InternalServerException, BadRequestException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - FileCreateRequest fileCreateRequest = new FileCreateRequest((String) null, "sample-cat-image.png"); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("java.lang.RuntimeException: Error: File not provided.")); - server.start(); - RestClient.UPLOAD_BASE_URL = server.url("/").toString(); - SUT.upload(fileCreateRequest); - RecordedRequest request = server.takeRequest(); - } - - @Test - public void imageKit_upload_returnSuccess() throws IOException, InterruptedException, InternalServerException, - BadRequestException, UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - String imageUrl = "https://homepages.cae.wisc.edu/~ece533/images/cat.png"; - URL url = new URL(imageUrl); - FileCreateRequest fileCreateRequest = new FileCreateRequest(url, "sample-cat-image.png"); - List tags = new ArrayList<>(); - tags.add("Software"); - tags.add("Developer"); - tags.add("Engineer"); - fileCreateRequest.setTags(tags); - fileCreateRequest.setFolder("demo1"); - String customCoordinates = "10,10,20,20"; - fileCreateRequest.setCustomCoordinates(customCoordinates); - - List responseFields = new ArrayList<>(); - responseFields.add("thumbnail"); - responseFields.add("tags"); - responseFields.add("customCoordinates"); - - fileCreateRequest.setResponseFields(responseFields); - JsonObject optionsInnerObject = new JsonObject(); - optionsInnerObject.addProperty("add_shadow", true); - JsonObject innerObject1 = new JsonObject(); - innerObject1.addProperty("name", "remove-bg"); - innerObject1.add("options", optionsInnerObject); - JsonObject innerObject2 = new JsonObject(); - innerObject2.addProperty("name", "google-auto-tagging"); - innerObject2.addProperty("minConfidence", 10); - innerObject2.addProperty("maxTags", 5); - JsonArray jsonArray = new JsonArray(); - jsonArray.add(innerObject1); - jsonArray.add(innerObject2); - fileCreateRequest.setExtensions(jsonArray); - fileCreateRequest.setWebhookUrl("https://webhook.site/c78d617f-33bc-40d9-9e61-608999721e2e"); - fileCreateRequest.setOverwriteFile(true); - fileCreateRequest.setUseUniqueFileName(false); - fileCreateRequest.setPrivateFile(false); - fileCreateRequest.setOverwriteAITags(false); - fileCreateRequest.setOverwriteTags(false); - fileCreateRequest.setOverwriteCustomMetadata(true); - JsonObject jsonObjectCustomMetadata = new JsonObject(); - jsonObjectCustomMetadata.addProperty("test1", 10); - fileCreateRequest.setCustomMetadata(jsonObjectCustomMetadata); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("{\r\n" + " \"fileId\": \"62a465d245a84a0ef3852968\",\r\n" - + " \"name\": \"sample-cat-image_GG0_X8GOn.jpg\",\r\n" + " \"size\": 23023,\r\n" - + " \"versionInfo\": {\r\n" + " \"id\": \"62a465d245a84a0ef3852968\",\r\n" - + " \"name\": \"Version 1\"\r\n" + " },\r\n" - + " \"filePath\": \"/demo1/sample-cat-image_GG0_X8GOn.jpg\",\r\n" - + " \"url\": \"https://ik.imagekit.io/zv3rkhsym/demo1/sample-cat-image_GG0_X8GOn.jpg\",\r\n" - + " \"fileType\": \"image\",\r\n" + " \"height\": 354,\r\n" + " \"width\": 236,\r\n" - + " \"thumbnailUrl\": \"https://ik.imagekit.io/zv3rkhsym/tr:n-ik_ml_thumbnail/demo1/sample-cat-image_GG0_X8GOn.jpg\",\r\n" - + " \"AITags\": [\r\n" + " {\r\n" + " \"name\": \"Clothing\",\r\n" - + " \"confidence\": 98.77,\r\n" + " \"source\": \"google-auto-tagging\"\r\n" - + " },\r\n" + " {\r\n" + " \"name\": \"Plant\",\r\n" - + " \"confidence\": 96.51,\r\n" + " \"source\": \"google-auto-tagging\"\r\n" - + " },\r\n" + " {\r\n" + " \"name\": \"Smile\",\r\n" - + " \"confidence\": 95.31,\r\n" + " \"source\": \"google-auto-tagging\"\r\n" - + " },\r\n" + " {\r\n" + " \"name\": \"Shoe\",\r\n" - + " \"confidence\": 95.2,\r\n" + " \"source\": \"google-auto-tagging\"\r\n" - + " },\r\n" + " {\r\n" + " \"name\": \"Street light\",\r\n" - + " \"confidence\": 91.05,\r\n" + " \"source\": \"google-auto-tagging\"\r\n" - + " }\r\n" + " ],\r\n" + " \"extensionStatus\": {\r\n" + " \"remove-bg\": \"pending\",\r\n" - + " \"google-auto-tagging\": \"success\"\r\n" + " }\r\n" + "}")); - server.start(); - RestClient.UPLOAD_BASE_URL = server.url("/").toString(); - SUT.upload(fileCreateRequest); - RecordedRequest request = server.takeRequest(); - String json = "--randomBoundary-------------------\r\n" + - "Content-Disposition: form-data; name=\"file\"\r\n" + - "Content-Length: 53\r\n" + - "\r\n" + - "https://homepages.cae.wisc.edu/~ece533/images/cat.png\r\n" + - "--randomBoundary-------------------\r\n" + - "Content-Disposition: form-data; name=\"fileName\"\r\n" + - "Content-Length: 20\r\n" + - "\r\n" + - "sample-cat-image.png\r\n" + - "--randomBoundary-------------------\r\n" + - "Content-Disposition: form-data; name=\"useUniqueFileName\"\r\n" + - "Content-Length: 5\r\n" + - "\r\n" + - "false\r\n" + - "--randomBoundary-------------------\r\n" + - "Content-Disposition: form-data; name=\"tags\"\r\n" + - "Content-Length: 27\r\n" + - "\r\n" + - "Software,Developer,Engineer\r\n" + - "--randomBoundary-------------------\r\n" + - "Content-Disposition: form-data; name=\"folder\"\r\n" + - "Content-Length: 5\r\n" + - "\r\n" + - "demo1\r\n" + - "--randomBoundary-------------------\r\n" + - "Content-Disposition: form-data; name=\"customCoordinates\"\r\n" + - "Content-Length: 11\r\n" + - "\r\n" + - "10,10,20,20\r\n" + - "--randomBoundary-------------------\r\n" + - "Content-Disposition: form-data; name=\"responseFields\"\r\n" + - "Content-Length: 32\r\n" + - "\r\n" + - "thumbnail,tags,customCoordinates\r\n" + - "--randomBoundary-------------------\r\n" + - "Content-Disposition: form-data; name=\"overwriteFile\"\r\n" + - "Content-Length: 4\r\n" + - "\r\n" + - "true\r\n" + - "--randomBoundary-------------------\r\n" + - "Content-Disposition: form-data; name=\"overwriteCustomMetadata\"\r\n" + - "Content-Length: 4\r\n" + - "\r\n" + - "true\r\n" + - "--randomBoundary-------------------\r\n" + - "Content-Disposition: form-data; name=\"extensions\"\r\n" + - "Content-Length: 114\r\n" + - "\r\n" + - "[{\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true}},{\"name\":\"google-auto-tagging\",\"minConfidence\":10,\"maxTags\":5}]\r\n" + - "--randomBoundary-------------------\r\n" + - "Content-Disposition: form-data; name=\"webhookUrl\"\r\n" + - "Content-Length: 57\r\n" + - "\r\n" + - "https://webhook.site/c78d617f-33bc-40d9-9e61-608999721e2e\r\n" + - "--randomBoundary-------------------\r\n" + - "Content-Disposition: form-data; name=\"customMetadata\"\r\n" + - "Content-Length: 12\r\n" + - "\r\n" + - "{\"test1\":10}\r\n" + - "--randomBoundary---------------------"; - assertEquals(json, request.getBody().readUtf8().trim()); - assertEquals("POST /api/v1/files/upload HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.UPLOAD_BASE_URL.concat("api/v1/files/upload"), request.getRequestUrl().toString()); - } - - @Test(expected = BadRequestException.class) - public void imageKit_upload_400_expected() throws IOException, InterruptedException, InternalServerException, - BadRequestException, UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - String imageUrl = "https://homepages.cae.wisc.edu/~ece533/images/cat.png"; - URL url = new URL(imageUrl); - FileCreateRequest fileCreateRequest = new FileCreateRequest(url, "sample-cat-image.png"); - List tags = new ArrayList<>(); - tags.add("Software"); - tags.add("Developer"); - tags.add("Engineer"); - fileCreateRequest.setTags(tags); - fileCreateRequest.setFolder("demo1"); - String customCoordinates = "10,10,20,20"; - fileCreateRequest.setCustomCoordinates(customCoordinates); - - List responseFields = new ArrayList<>(); - responseFields.add("thumbnail"); - responseFields.add("tags"); - responseFields.add("customCoordinates"); - - fileCreateRequest.setResponseFields(responseFields); - JsonObject optionsInnerObject = new JsonObject(); - optionsInnerObject.addProperty("add_shadow", true); - JsonObject innerObject1 = new JsonObject(); - innerObject1.addProperty("name", "remove-bg"); - innerObject1.add("options", optionsInnerObject); - JsonObject innerObject2 = new JsonObject(); - innerObject2.addProperty("name", "google-auto-tagging"); - innerObject2.addProperty("minConfidence", 10); - innerObject2.addProperty("maxTags", 5); - JsonArray jsonArray = new JsonArray(); - jsonArray.add(innerObject1); - jsonArray.add(innerObject2); - fileCreateRequest.setExtensions(jsonArray); - fileCreateRequest.setWebhookUrl("https://webhook.site/c78d617f-33bc-40d9-9e61-608999721e2e"); - fileCreateRequest.setUseUniqueFileName(false); - fileCreateRequest.setPrivateFile(false); - fileCreateRequest.setOverwriteFile(false); - fileCreateRequest.setOverwriteAITags(false); - fileCreateRequest.setOverwriteTags(false); - fileCreateRequest.setOverwriteCustomMetadata(true); - JsonObject jsonObjectCustomMetadata = new JsonObject(); - jsonObjectCustomMetadata.addProperty("test1", 10); - fileCreateRequest.setCustomMetadata(jsonObjectCustomMetadata); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(400).setBody("{\r\n" - + " \"message\": \"A file with the same name already exists at the exact location. We could not overwrite it because both overwriteFile and useUniqueFileName are set to false.\"\r\n" - + "}")); - server.start(); - RestClient.UPLOAD_BASE_URL = server.url("/").toString(); - SUT.upload(fileCreateRequest); - server.takeRequest(); - } - -} \ No newline at end of file diff --git a/imagekit-sdk/src/test/java/io/imagekit/sdk/config/ConfigurationTest.java b/imagekit-sdk/src/test/java/io/imagekit/sdk/config/ConfigurationTest.java deleted file mode 100644 index cd94018c..00000000 --- a/imagekit-sdk/src/test/java/io/imagekit/sdk/config/ConfigurationTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package io.imagekit.sdk.config; - -import org.junit.Test; -import java.io.IOException; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; - -public class ConfigurationTest { - - Configuration SUT; - - @Test - public void configFileExit_validate_successExpected() throws IOException { - SUT=new Configuration(); - SUT.setPrivateKey("privateKey"); - SUT.setPublicKey("publicKey"); - SUT.setUrlEndpoint("endPoint"); - - boolean result=SUT.validate(); - assertTrue(result); - } - - @Test(expected = RuntimeException.class) - public void configNotExit_validate_errorExpected() throws IOException { - SUT=new Configuration(); - SUT.setPrivateKey("privateKey"); - SUT.setUrlEndpoint("endPoint"); - - boolean result=SUT.validate(); - assertTrue(result); - } - - @Test - public void config_getter_setter_successExpected() throws IOException { - String privateKey="privateKey"; - String publicKey="publicKey"; - String endPoint="endPoint"; - SUT=new Configuration(publicKey,privateKey,endPoint); - assertThat(privateKey,is(SUT.getPrivateKey())); - assertThat(publicKey,is(SUT.getPublicKey())); - assertThat(endPoint,is(SUT.getUrlEndpoint())); - } -} \ No newline at end of file diff --git a/imagekit-sdk/src/test/java/io/imagekit/sdk/manage/CustomMetaDataFieldTest.java b/imagekit-sdk/src/test/java/io/imagekit/sdk/manage/CustomMetaDataFieldTest.java deleted file mode 100644 index d62919c9..00000000 --- a/imagekit-sdk/src/test/java/io/imagekit/sdk/manage/CustomMetaDataFieldTest.java +++ /dev/null @@ -1,477 +0,0 @@ -package io.imagekit.sdk.manage; - -import io.imagekit.sdk.ImageKit; -import io.imagekit.sdk.ImageKitTest; -import io.imagekit.sdk.exceptions.BadRequestException; -import io.imagekit.sdk.exceptions.NotFoundException; -import io.imagekit.sdk.exceptions.UnknownException; -import io.imagekit.sdk.models.CustomMetaDataFieldCreateRequest; -import io.imagekit.sdk.models.CustomMetaDataFieldSchemaObject; -import io.imagekit.sdk.models.CustomMetaDataFieldUpdateRequest; -import io.imagekit.sdk.models.CustomMetaDataTypeEnum; -import io.imagekit.sdk.models.results.ResultCustomMetaDataField; -import io.imagekit.sdk.tasks.RestClient; -import io.imagekit.sdk.utils.Utils; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertEquals; - -public class CustomMetaDataFieldTest { - - private ImageKit SUT; - - @Before - public void setUp() throws Exception { - SUT = ImageKit.getInstance(); - SUT.setConfig(Utils.getSystemConfig(ImageKitTest.class)); - } - - @Test - public void get_custom_metadata_fields_expectedSuccessWith() - throws IOException, InterruptedException, UnknownException { - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("[\n" + " {\n" + " \"id\": \"6291f00890ba008cc27f64d1\",\n" - + " \"name\": \"price\",\n" + " \"label\": \"Amount\",\n" + " \"schema\": {\n" - + " \"minValue\": 10,\n" + " \"maxValue\": 200,\n" - + " \"type\": \"Number\"\n" + " }\n" + " },\n" + " {\n" - + " \"id\": \"6296f91191fa57ccc36b15cf\",\n" + " \"name\": \"Amount2\",\n" - + " \"label\": \"Amouunt\",\n" + " \"schema\": {\n" - + " \"type\": \"Number\",\n" + " \"minValue\": 10,\n" - + " \"maxValue\": 1000\n" + " }\n" + " }\n" + "]")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.getCustomMetaDataFields(false); - RecordedRequest request = server.takeRequest(); - assertEquals("application/json", request.getHeader("Content-Type")); - assertEquals("GET /v1/customMetadataFields?includeDeleted=false HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/customMetadataFields?includeDeleted=false"), - request.getRequestUrl().toString()); - } - - @Test(expected = BadRequestException.class) - public void createCustomMetaDataFields_expected_400() - throws InterruptedException, IOException, BadRequestException, UnknownException { - - MockWebServer server = new MockWebServer(); - String responseJson = "{\n" + " \"message\": \"Invalid schema object\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\",\n" + " \"errors\": {\n" - + " \"minValue\": \"not allowed for this type\",\n" - + " \"maxValue\": \"not allowed for this type\"\n" + " }\n" + "}"; - server.enqueue(new MockResponse().setResponseCode(400).setBody(responseJson)); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - - CustomMetaDataFieldSchemaObject mockCustomMetaDataFieldSchemaObject = new CustomMetaDataFieldSchemaObject(); - mockCustomMetaDataFieldSchemaObject.setType(CustomMetaDataTypeEnum.Text); - mockCustomMetaDataFieldSchemaObject.setMinValue(10); - mockCustomMetaDataFieldSchemaObject.setMaxValue(100); - - CustomMetaDataFieldCreateRequest customMetaDataFieldCreateRequest = new CustomMetaDataFieldCreateRequest(); - customMetaDataFieldCreateRequest.setName("mockName"); - customMetaDataFieldCreateRequest.setLabel("mockLabel"); - customMetaDataFieldCreateRequest.setSchema(mockCustomMetaDataFieldSchemaObject); - - ResultCustomMetaDataField resultCustomMetaDataField = SUT - .createCustomMetaDataFields(customMetaDataFieldCreateRequest); - RecordedRequest request = server.takeRequest(); - String customMetaDataFieldCreateRequestJson = "{\"name\":\"mockName\",\"label\":\"mockLabel\",\"schema\":{\"type\":\"Number\",\"minValue\":10,\"maxValue\":100}}"; - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals(400, resultCustomMetaDataField.getResponseMetaData().getHttpStatusCode()); - assertEquals(customMetaDataFieldCreateRequestJson, utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("POST /v1/customMetadataFields HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/customMetadataFields"), request.getRequestUrl().toString()); - } - - @Test - public void createCustomMetaDataFields_successExpected() - throws InterruptedException, IOException, BadRequestException, UnknownException { - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("{\n" + " \"id\": \"629f2e2f7eb0fe2eb25f9988\",\n" - + " \"name\": \"test1\",\n" + " \"label\": \"test1\",\n" + " \"schema\": {\n" - + " \"type\": \"Number\",\n" + " \"isValueRequired\": false,\n" - + " \"minValue\": 10,\n" + " \"maxValue\": 1000\n" + " }\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - - CustomMetaDataFieldSchemaObject mockCustomMetaDataFieldSchemaObject = new CustomMetaDataFieldSchemaObject(); - mockCustomMetaDataFieldSchemaObject.setType(CustomMetaDataTypeEnum.Number); - mockCustomMetaDataFieldSchemaObject.setMinValue(10); - mockCustomMetaDataFieldSchemaObject.setMaxValue(100); - - CustomMetaDataFieldCreateRequest customMetaDataFieldCreateRequest = new CustomMetaDataFieldCreateRequest(); - customMetaDataFieldCreateRequest.setName("mockName"); - customMetaDataFieldCreateRequest.setLabel("mockLabel"); - customMetaDataFieldCreateRequest.setSchema(mockCustomMetaDataFieldSchemaObject); - - SUT.createCustomMetaDataFields(customMetaDataFieldCreateRequest); - RecordedRequest request = server.takeRequest(); - - String customMetaDataFieldCreateRequestJson = "{\"name\":\"mockName\",\"label\":\"mockLabel\",\"schema\":{\"type\":\"Number\",\"minValue\":10,\"maxValue\":100}}"; - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals(customMetaDataFieldCreateRequestJson, utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("POST /v1/customMetadataFields HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/customMetadataFields"), request.getRequestUrl().toString()); - } - - @Test - public void createCustomMetaDataFields_successExpected_type_Textarea() - throws InterruptedException, IOException, BadRequestException, UnknownException { - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("{\n" + - " \"name\": \"mockName\",\n" + - " \"label\": \"mockLabel\",\n" + - " \"schema\": {\n" + - " \"isValueRequired\": true,\n" + - " \"defaultValue\": \"default value of test\",\n" + - " \"type\": \"Textarea\",\n" + - " \"minLength\": 10,\n" + - " \"maxLength\": 1000\n" + - " }\n" + - "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - - CustomMetaDataFieldSchemaObject mockCustomMetaDataFieldSchemaObject = new CustomMetaDataFieldSchemaObject(); - mockCustomMetaDataFieldSchemaObject.setValueRequired(true); - mockCustomMetaDataFieldSchemaObject.setDefaultValue("default value of test"); - mockCustomMetaDataFieldSchemaObject.setType(CustomMetaDataTypeEnum.Textarea); - mockCustomMetaDataFieldSchemaObject.setMinLength(10); - mockCustomMetaDataFieldSchemaObject.setMaxLength(100); - - CustomMetaDataFieldCreateRequest customMetaDataFieldCreateRequest = new CustomMetaDataFieldCreateRequest(); - customMetaDataFieldCreateRequest.setName("mockName"); - customMetaDataFieldCreateRequest.setLabel("mockLabel"); - customMetaDataFieldCreateRequest.setSchema(mockCustomMetaDataFieldSchemaObject); - - SUT.createCustomMetaDataFields(customMetaDataFieldCreateRequest); - RecordedRequest request = server.takeRequest(); - - String customMetaDataFieldCreateRequestJson = "{\"name\":\"mockName\",\"label\":\"mockLabel\",\"schema\":{\"type\":\"Textarea\",\"defaultValue\":\"default value of test\",\"isValueRequired\":true,\"minLength\":10,\"maxLength\":100}}"; - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals(customMetaDataFieldCreateRequestJson, utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("POST /v1/customMetadataFields HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/customMetadataFields"), request.getRequestUrl().toString()); - } - - @Test - public void createCustomMetaDataFields_successExpected_type_Date() - throws InterruptedException, IOException, BadRequestException, UnknownException { - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("{\n" + - " \"id\": \"62c2d18da6f0abb293b3941a\",\n" + - " \"name\": \"name\",\n" + - " \"label\": \"label\",\n" + - " \"schema\": {\n" + - " \"type\": \"Date\",\n" + - " \"minValue\": \"2022-11-30T10:11:10+00:00\",\n" + - " \"maxValue\": \"2022-12-30T10:11:10+00:00\"\n" + - " }\n" + - "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - - CustomMetaDataFieldSchemaObject customMetaDataFieldSchemaObject = new CustomMetaDataFieldSchemaObject(); - customMetaDataFieldSchemaObject.setType(CustomMetaDataTypeEnum.Date); - customMetaDataFieldSchemaObject.setMinValue("2022-11-30T10:11:10+00:00"); - customMetaDataFieldSchemaObject.setMaxValue("2022-12-30T10:11:10+00:00"); - - CustomMetaDataFieldCreateRequest customMetaDataFieldCreateRequest = new CustomMetaDataFieldCreateRequest(); - customMetaDataFieldCreateRequest.setName("Name"); - customMetaDataFieldCreateRequest.setLabel("Label"); - customMetaDataFieldCreateRequest.setSchema(customMetaDataFieldSchemaObject); - - SUT.createCustomMetaDataFields(customMetaDataFieldCreateRequest); - RecordedRequest request = server.takeRequest(); - - String customMetaDataFieldCreateRequestJson = "{\"name\":\"Name\",\"label\":\"Label\",\"schema\":{\"type\":\"Date\",\"minValue\":\"2022-11-30T10:11:10+00:00\",\"maxValue\":\"2022-12-30T10:11:10+00:00\"}}"; - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals(customMetaDataFieldCreateRequestJson, utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("POST /v1/customMetadataFields HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/customMetadataFields"), request.getRequestUrl().toString()); - } - - @Test - public void createCustomMetaDataFields_successExpected_type_Boolean() - throws InterruptedException, IOException, BadRequestException, UnknownException { - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("{\n" + - " \"id\": \"62c2e4268eed64d4a80c585a\",\n" + - " \"name\": \"Name\",\n" + - " \"label\": \"Label\",\n" + - " \"schema\": {\n" + - " \"type\": \"Boolean\",\n" + - " \"isValueRequired\": true,\n" + - " \"defaultValue\": true\n" + - " }\n" + - "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - - CustomMetaDataFieldSchemaObject customMetaDataFieldSchemaObject = new CustomMetaDataFieldSchemaObject(); - customMetaDataFieldSchemaObject.setType(CustomMetaDataTypeEnum.Boolean); - customMetaDataFieldSchemaObject.setValueRequired(true); - customMetaDataFieldSchemaObject.setDefaultValue(true); - - CustomMetaDataFieldCreateRequest customMetaDataFieldCreateRequest = new CustomMetaDataFieldCreateRequest(); - customMetaDataFieldCreateRequest.setName("Name"); - customMetaDataFieldCreateRequest.setLabel("Label"); - customMetaDataFieldCreateRequest.setSchema(customMetaDataFieldSchemaObject); - - SUT.createCustomMetaDataFields(customMetaDataFieldCreateRequest); - RecordedRequest request = server.takeRequest(); - - String customMetaDataFieldCreateRequestJson = "{\"name\":\"Name\",\"label\":\"Label\",\"schema\":{\"type\":\"Boolean\",\"defaultValue\":true,\"isValueRequired\":true}}"; - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals(customMetaDataFieldCreateRequestJson, utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("POST /v1/customMetadataFields HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/customMetadataFields"), request.getRequestUrl().toString()); - } - - @Test - public void createCustomMetaDataFields_successExpected_type_SingleSelect() - throws InterruptedException, IOException, BadRequestException, UnknownException { - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("{\n" + - " \"id\": \"62c2cfe2a6f0ab95fcb3640f\",\n" + - " \"name\": \"Name\",\n" + - " \"label\": \"Label\",\n" + - " \"schema\": {\n" + - " \"type\": \"SingleSelect\",\n" + - " \"selectOptions\": [\n" + - " \"small\",\n" + - " \"medium\",\n" + - " \"large\",\n" + - " 30,\n" + - " 40,\n" + - " true\n" + - " ]\n" + - " }\n" + - "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - - List objectList = new ArrayList<>(); - objectList.add("small"); - objectList.add("medium"); - objectList.add("large"); - objectList.add(30); - objectList.add(40); - objectList.add(true); - CustomMetaDataFieldSchemaObject customMetaDataFieldSchemaObject = new CustomMetaDataFieldSchemaObject(); - customMetaDataFieldSchemaObject.setType(CustomMetaDataTypeEnum.SingleSelect); - customMetaDataFieldSchemaObject.setSelectOptions(objectList); - - CustomMetaDataFieldCreateRequest customMetaDataFieldCreateRequest = new CustomMetaDataFieldCreateRequest(); - customMetaDataFieldCreateRequest.setName("Name"); - customMetaDataFieldCreateRequest.setLabel("Label"); - customMetaDataFieldCreateRequest.setSchema(customMetaDataFieldSchemaObject); - - SUT.createCustomMetaDataFields(customMetaDataFieldCreateRequest); - RecordedRequest request = server.takeRequest(); - - String customMetaDataFieldCreateRequestJson = "{\"name\":\"Name\",\"label\":\"Label\",\"schema\":{\"type\":\"SingleSelect\",\"selectOptions\":[\"small\",\"medium\",\"large\",30,40,true]}}"; - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals(customMetaDataFieldCreateRequestJson, utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("POST /v1/customMetadataFields HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/customMetadataFields"), request.getRequestUrl().toString()); - } - - @Test - public void createCustomMetaDataFields_successExpected_type_MultiSelect() - throws InterruptedException, IOException, BadRequestException, UnknownException { - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("{\n" + - " \"id\": \"62c2d3c5a6f0ab2330b3b0b2\",\n" + - " \"name\": \"Name\",\n" + - " \"label\": \"Label\",\n" + - " \"schema\": {\n" + - " \"isValueRequired\": true,\n" + - " \"defaultValue\": [\n" + - " \"small\",\n" + - " 30,\n" + - " true\n" + - " ],\n" + - " \"type\": \"MultiSelect\",\n" + - " \"selectOptions\": [\n" + - " \"small\",\n" + - " \"medium\",\n" + - " \"large\",\n" + - " 30,\n" + - " 40,\n" + - " true\n" + - " ]\n" + - " }\n" + - "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - - List objectList = new ArrayList<>(); - objectList.add("small"); - objectList.add("medium"); - objectList.add("large"); - objectList.add(30); - objectList.add(40); - objectList.add(true); - - List defaultValueObject = new ArrayList<>(); - defaultValueObject.add("small"); - defaultValueObject.add(30); - defaultValueObject.add(true); - CustomMetaDataFieldSchemaObject customMetaDataFieldSchemaObject = new CustomMetaDataFieldSchemaObject(); - customMetaDataFieldSchemaObject.setType(CustomMetaDataTypeEnum.MultiSelect); - customMetaDataFieldSchemaObject.setValueRequired(true); - customMetaDataFieldSchemaObject.setDefaultValue(defaultValueObject); - customMetaDataFieldSchemaObject.setSelectOptions(objectList); - - CustomMetaDataFieldCreateRequest customMetaDataFieldCreateRequest = new CustomMetaDataFieldCreateRequest(); - customMetaDataFieldCreateRequest.setName("Name"); - customMetaDataFieldCreateRequest.setLabel("Label"); - customMetaDataFieldCreateRequest.setSchema(customMetaDataFieldSchemaObject); - - SUT.createCustomMetaDataFields(customMetaDataFieldCreateRequest); - RecordedRequest request = server.takeRequest(); - - String customMetaDataFieldCreateRequestJson = "{\"name\":\"Name\",\"label\":\"Label\",\"schema\":{\"type\":\"MultiSelect\",\"selectOptions\":[\"small\",\"medium\",\"large\",30,40,true],\"defaultValue\":[\"small\",30,true],\"isValueRequired\":true}}"; - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals(customMetaDataFieldCreateRequestJson, utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("POST /v1/customMetadataFields HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/customMetadataFields"), request.getRequestUrl().toString()); - } - - @Test(expected = NotFoundException.class) - public void deleteCustomMetaDataField_404_Expected() - throws IOException, InterruptedException, NotFoundException, UnknownException { - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404) - .setBody("{\n" + " \"message\": \"No such custom metadata field exists\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - - SUT.deleteCustomMetaDataField("6296fd7091fa5768106b808E"); - server.takeRequest(); - } - - @Test - public void deleteCustomMetaDataField_successExpected() - throws IOException, InterruptedException, NotFoundException, UnknownException { - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - - SUT.deleteCustomMetaDataField("629f2e2f7eb0fe2eb25f9988"); - RecordedRequest request = server.takeRequest(); - - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals("", utf8RequestBody); - assertEquals("application/json", request.getHeader("Content-Type")); - assertEquals("DELETE /v1/customMetadataFields/629f2e2f7eb0fe2eb25f9988 HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/customMetadataFields/629f2e2f7eb0fe2eb25f9988"), - request.getRequestUrl().toString()); - } - - @Test(expected = NotFoundException.class) - public void updateCustomMetaDataFields_404_Expected() - throws InterruptedException, IOException, BadRequestException, NotFoundException, UnknownException { - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404) - .setBody("{\n" + " \"message\": \"No such custom metadata field exists\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - - CustomMetaDataFieldSchemaObject mockCustomMetaDataFieldSchemaObject = new CustomMetaDataFieldSchemaObject(); - mockCustomMetaDataFieldSchemaObject.setMinLength(10); - - CustomMetaDataFieldUpdateRequest customMetaDataFieldUpdateRequest = new CustomMetaDataFieldUpdateRequest(); - customMetaDataFieldUpdateRequest.setId("6296fd7091fa5768106b808E"); - customMetaDataFieldUpdateRequest.setLabel("mockEditLabel"); - customMetaDataFieldUpdateRequest.setSchema(mockCustomMetaDataFieldSchemaObject); - - SUT.updateCustomMetaDataFields(customMetaDataFieldUpdateRequest); - server.takeRequest(); - } - - @Test(expected = BadRequestException.class) - public void updateCustomMetaDataFields_400_Expected() - throws InterruptedException, IOException, BadRequestException, NotFoundException, UnknownException { - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(400) - .setBody("{\n" + " \"message\": \"Invalid schema object\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\",\n" - + " \"errors\": {\n" + " \"minLength\": \"not allowed for this type\"\n" + " }\n" - + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - - CustomMetaDataFieldSchemaObject mockCustomMetaDataFieldSchemaObject = new CustomMetaDataFieldSchemaObject(); - mockCustomMetaDataFieldSchemaObject.setMinLength(10); - - CustomMetaDataFieldUpdateRequest customMetaDataFieldUpdateRequest = new CustomMetaDataFieldUpdateRequest(); - customMetaDataFieldUpdateRequest.setId("628f189d4e4ea318b69efa9d"); - customMetaDataFieldUpdateRequest.setLabel("mockEditLabel"); - customMetaDataFieldUpdateRequest.setSchema(mockCustomMetaDataFieldSchemaObject); - - SUT.updateCustomMetaDataFields(customMetaDataFieldUpdateRequest); - server.takeRequest(); - } - - @Test - public void updateCustomMetaDataFields_successExpected() - throws InterruptedException, IOException, BadRequestException, NotFoundException, UnknownException { - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse() - .setBody("{\n" + " \"id\": \"6296fd7091fa5768106b808d\",\n" + " \"name\": \"Amount3\",\n" - + " \"label\": \"testPrices\",\n" + " \"schema\": {\n" + " \"minValue\": 0,\n" - + " \"maxValue\": 10,\n" + " \"type\": \"Number\"\n" + " }\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - - CustomMetaDataFieldSchemaObject mockCustomMetaDataFieldSchemaObject = new CustomMetaDataFieldSchemaObject(); - mockCustomMetaDataFieldSchemaObject.setType(CustomMetaDataTypeEnum.Number); - mockCustomMetaDataFieldSchemaObject.setMinValue(10); - mockCustomMetaDataFieldSchemaObject.setMaxValue(100); - - CustomMetaDataFieldUpdateRequest customMetaDataFieldUpdateRequest = new CustomMetaDataFieldUpdateRequest(); - customMetaDataFieldUpdateRequest.setId("628f189d4e4ea318b69efa9d"); - customMetaDataFieldUpdateRequest.setLabel("mockEditLabel"); - customMetaDataFieldUpdateRequest.setSchema(mockCustomMetaDataFieldSchemaObject); - - SUT.updateCustomMetaDataFields(customMetaDataFieldUpdateRequest); - RecordedRequest request = server.takeRequest(); - - String customMetaDataFieldUpdateRequestJson = "{\"id\":\"628f189d4e4ea318b69efa9d\",\"label\":\"mockEditLabel\",\"schema\":{\"type\":\"Number\",\"minValue\":10,\"maxValue\":100}}"; - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals(customMetaDataFieldUpdateRequestJson, utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("PATCH /v1/customMetadataFields/628f189d4e4ea318b69efa9d HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/customMetadataFields/628f189d4e4ea318b69efa9d"), - request.getRequestUrl().toString()); - } -} diff --git a/imagekit-sdk/src/test/java/io/imagekit/sdk/manage/FileTest.java b/imagekit-sdk/src/test/java/io/imagekit/sdk/manage/FileTest.java deleted file mode 100644 index 9e2c7fbe..00000000 --- a/imagekit-sdk/src/test/java/io/imagekit/sdk/manage/FileTest.java +++ /dev/null @@ -1,589 +0,0 @@ -package io.imagekit.sdk.manage; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import io.imagekit.sdk.ImageKit; -import io.imagekit.sdk.ImageKitTest; -import io.imagekit.sdk.exceptions.BadRequestException; -import io.imagekit.sdk.exceptions.ForbiddenException; -import io.imagekit.sdk.exceptions.InternalServerException; -import io.imagekit.sdk.exceptions.NotFoundException; -import io.imagekit.sdk.exceptions.PartialSuccessException; -import io.imagekit.sdk.exceptions.TooManyRequestsException; -import io.imagekit.sdk.exceptions.UnauthorizedException; -import io.imagekit.sdk.exceptions.UnknownException; -import io.imagekit.sdk.models.FileUpdateRequest; -import io.imagekit.sdk.models.GetFileListRequest; -import io.imagekit.sdk.tasks.RestClient; -import io.imagekit.sdk.utils.Utils; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; - -public class FileTest { - - private ImageKit SUT; - - @Before - public void setUp() throws Exception { - SUT = ImageKit.getInstance(); - SUT.setConfig(Utils.getSystemConfig(ImageKitTest.class)); - } - - @Test(expected = UnknownException.class) - public void imageKit_updateDetails_expected_404() - throws IOException, InterruptedException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - - FileUpdateRequest fileUpdateRequest = new FileUpdateRequest("62a9c3ccd875ec6fd658c804"); - MockWebServer server = new MockWebServer(); - String responseJson = "{\n" + " \"message\": \"The requested file does not exist.\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\"\n" + "}"; - server.enqueue(new MockResponse().setResponseCode(404).setBody(responseJson)); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.updateFileDetail(fileUpdateRequest); - server.takeRequest(); - } - - @Test(expected = UnknownException.class) - public void imageKit_updateDetails_expected_400() - throws IOException, InterruptedException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - - FileUpdateRequest fileUpdateRequest = new FileUpdateRequest("62a9c3ccd875ec6fd658c804"); - MockWebServer server = new MockWebServer(); - String responseJson = "{\n" + " \"message\": \"The requested file does not exist.\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\"\n" + "}"; - server.enqueue(new MockResponse().setResponseCode(404).setBody(responseJson)); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.updateFileDetail(fileUpdateRequest); - server.takeRequest(); - } - - @Test - public void imageKit_updateDetails_returnTrue() - throws IOException, InterruptedException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("{\n" + - " \"type\": \"file\",\n" + - " \"name\": \"new_car.jpg\",\n" + - " \"createdAt\": \"2022-06-15T11:34:36.294Z\",\n" + - " \"updatedAt\": \"2022-07-04T10:15:50.067Z\",\n" + - " \"fileId\": \"62a9c3ccd875ec6fd658c854\",\n" + - " \"tags\": [\n" + - " \"Software\",\n" + - " \"Developer\",\n" + - " \"Engineer\"\n" + - " ],\n" + - " \"AITags\": [\n" + - " {\n" + - " \"name\": \"Clothing\",\n" + - " \"confidence\": 98.77,\n" + - " \"source\": \"google-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Smile\",\n" + - " \"confidence\": 95.31,\n" + - " \"source\": \"google-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Shoe\",\n" + - " \"confidence\": 95.2,\n" + - " \"source\": \"google-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Street light\",\n" + - " \"confidence\": 91.05,\n" + - " \"source\": \"google-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Person\",\n" + - " \"confidence\": 96.5,\n" + - " \"source\": \"aws-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Female\",\n" + - " \"confidence\": 91.27,\n" + - " \"source\": \"aws-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Flyer\",\n" + - " \"confidence\": 90.62,\n" + - " \"source\": \"aws-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Poster\",\n" + - " \"confidence\": 90.62,\n" + - " \"source\": \"aws-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Advertisement\",\n" + - " \"confidence\": 90.62,\n" + - " \"source\": \"aws-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Plant\",\n" + - " \"confidence\": 96.51,\n" + - " \"source\": \"google-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Street fashion\",\n" + - " \"confidence\": 89.1,\n" + - " \"source\": \"google-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Fashion\",\n" + - " \"confidence\": 88.46,\n" + - " \"source\": \"google-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Tree\",\n" + - " \"confidence\": 87.62,\n" + - " \"source\": \"google-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Yellow\",\n" + - " \"confidence\": 85.76,\n" + - " \"source\": \"google-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Happy\",\n" + - " \"confidence\": 84.01,\n" + - " \"source\": \"google-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Grass\",\n" + - " \"confidence\": 82.89,\n" + - " \"source\": \"google-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Leisure\",\n" + - " \"confidence\": 81.19,\n" + - " \"source\": \"google-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Morning\",\n" + - " \"confidence\": 79.09,\n" + - " \"source\": \"google-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Summer\",\n" + - " \"confidence\": 78.87,\n" + - " \"source\": \"google-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"People\",\n" + - " \"confidence\": 77.9,\n" + - " \"source\": \"google-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Electric blue\",\n" + - " \"confidence\": 75.57,\n" + - " \"source\": \"google-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Beauty\",\n" + - " \"confidence\": 75.22,\n" + - " \"source\": \"google-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Denim\",\n" + - " \"confidence\": 74.91,\n" + - " \"source\": \"google-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Recreation\",\n" + - " \"confidence\": 74.33,\n" + - " \"source\": \"google-auto-tagging\"\n" + - " },\n" + - " {\n" + - " \"name\": \"Publication\",\n" + - " \"confidence\": 74.24,\n" + - " \"source\": \"google-auto-tagging\"\n" + - " }\n" + - " ],\n" + - " \"versionInfo\": {\n" + - " \"id\": \"62b97749f63122840530fda9\",\n" + - " \"name\": \"Version 4\"\n" + - " },\n" + - " \"embeddedMetadata\": {\n" + - " \"DateCreated\": \"2022-07-04T10:15:50.066Z\",\n" + - " \"DateTimeCreated\": \"2022-07-04T10:15:50.066Z\"\n" + - " },\n" + - " \"customCoordinates\": null,\n" + - " \"customMetadata\": {\n" + - " \"test100\": 10,\n" + - " \"test10\": 11\n" + - " },\n" + - " \"isPrivateFile\": false,\n" + - " \"url\": \"https://ik.imagekit.io/zv3rkhsym/new_car.jpg\",\n" + - " \"thumbnail\": \"https://ik.imagekit.io/zv3rkhsym/tr:n-ik_ml_thumbnail/new_car.jpg\",\n" + - " \"fileType\": \"image\",\n" + - " \"filePath\": \"/new_car.jpg\",\n" + - " \"height\": 354,\n" + - " \"width\": 236,\n" + - " \"size\": 7390,\n" + - " \"hasAlpha\": false,\n" + - " \"mime\": \"image/jpeg\"\n" + - "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - List tags = new ArrayList<>(); - tags.add("Software"); - tags.add("Developer"); - tags.add("Engineer"); - - List aiTags = new ArrayList<>(); - aiTags.add("Plant"); - FileUpdateRequest fileUpdateRequest = new FileUpdateRequest("62a9c3ccd875ec6fd658c854"); - fileUpdateRequest.setRemoveAITags(aiTags); - fileUpdateRequest.setWebhookUrl("https://webhook.site/c78d617f-33bc-40d9-9e61-608999721e2e"); - - JsonObject optionsInnerObject = new JsonObject(); - optionsInnerObject.addProperty("add_shadow", true); - optionsInnerObject.addProperty("bg_color", "yellow"); - JsonObject innerObject1 = new JsonObject(); - innerObject1.addProperty("name", "remove-bg"); - innerObject1.add("options", optionsInnerObject); - JsonObject innerObject2 = new JsonObject(); - innerObject2.addProperty("name", "google-auto-tagging"); - innerObject2.addProperty("minConfidence", 15); - innerObject2.addProperty("maxTags", 20); - JsonArray jsonArray = new JsonArray(); - jsonArray.add(innerObject1); - jsonArray.add(innerObject2); - - fileUpdateRequest.setExtensions(jsonArray); - fileUpdateRequest.setTags(tags); - fileUpdateRequest.setCustomCoordinates("10,10,40,40"); - JsonObject jsonObjectCustomMetadata = new JsonObject(); - jsonObjectCustomMetadata.addProperty("test10", 11); - fileUpdateRequest.setCustomMetadata(jsonObjectCustomMetadata); - - SUT.updateFileDetail(fileUpdateRequest); - RecordedRequest request = server.takeRequest(); - - String requestJson = "{\"fileId\":\"62a9c3ccd875ec6fd658c854\",\"removeAITags\":[\"Plant\"],\"webhookUrl\":\"https://webhook.site/c78d617f-33bc-40d9-9e61-608999721e2e\",\"extensions\":[{\"name\":\"remove-bg\",\"options\":{\"add_shadow\":true,\"bg_color\":\"yellow\"}},{\"name\":\"google-auto-tagging\",\"minConfidence\":15,\"maxTags\":20}],\"tags\":[\"Software\",\"Developer\",\"Engineer\"],\"customCoordinates\":\"10,10,40,40\",\"customMetadata\":{\"test10\":11}}"; - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals(requestJson, utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("PATCH /v1/files/62a9c3ccd875ec6fd658c854/details HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/files/62a9c3ccd875ec6fd658c854/details"), - request.getRequestUrl().toString()); - } - - @Test - public void imageKit_getFileList_returnList() - throws InterruptedException, IOException, ForbiddenException, TooManyRequestsException, InternalServerException, UnauthorizedException, BadRequestException, UnknownException, IllegalAccessException, InstantiationException { - - MockWebServer server = new MockWebServer(); - String responseJson = "[\n" + " {\n" + " \"type\": \"file\",\n" - + " \"name\": \"default-image.jpg\",\n" - + " \"createdAt\": \"2022-06-11T07:26:19.294Z\",\n" - + " \"updatedAt\": \"2022-06-11T07:26:19.600Z\",\n" - + " \"fileId\": \"62a4439bce686814dfcce65c\",\n" + " \"tags\": null,\n" - + " \"AITags\": null,\n" + " \"versionInfo\": {\n" - + " \"id\": \"62a4439bce686814dfcce65c\",\n" + " \"name\": \"Version 1\"\n" - + " },\n" + " \"embeddedMetadata\": {\n" - + " \"DateCreated\": \"2022-06-11T07:26:19.599Z\",\n" - + " \"DateTimeCreated\": \"2022-06-11T07:26:19.600Z\"\n" + " },\n" - + " \"customCoordinates\": null,\n" + " \"customMetadata\": {},\n" - + " \"isPrivateFile\": false,\n" - + " \"url\": \"https://ik.imagekit.io/zv3rkhsym/default-image.jpg\",\n" - + " \"thumbnail\": \"https://ik.imagekit.io/zv3rkhsym/tr:n-ik_ml_thumbnail/default-image.jpg\",\n" - + " \"fileType\": \"image\",\n" + " \"filePath\": \"/default-image.jpg\",\n" - + " \"height\": 1000,\n" + " \"width\": 1000,\n" + " \"size\": 147022,\n" - + " \"hasAlpha\": false,\n" + " \"mime\": \"image/jpeg\"\n" + " }\n" + "]"; - server.enqueue(new MockResponse().setBody(responseJson)); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - String[] tags = new String[3]; - tags[0] = "Software"; - tags[1] = "Developer"; - tags[2] = "Engineer"; - GetFileListRequest getFileListRequest = new GetFileListRequest(); - getFileListRequest.setType("file"); - getFileListRequest.setSort("ASC_CREATED"); - getFileListRequest.setPath("/"); - getFileListRequest.setSearchQuery("createdAt >= '2d' OR size < '2mb' OR format='png'"); - getFileListRequest.setFileType("all"); - getFileListRequest.setLimit("1"); - getFileListRequest.setSkip("0"); - getFileListRequest.setTags(tags); - SUT.getFileList(getFileListRequest); - - RecordedRequest request = server.takeRequest(); - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals("", utf8RequestBody); - assertEquals("application/json", request.getHeader("Content-Type")); - assertEquals( - "GET /v1/files?path=/&searchQuery=createdAt%20%3E=%20%272d%27%20OR%20size%20%3C%20%272mb%27%20OR%20format=%27png%27&limit=1&skip=0&sort=ASC_CREATED&type=file&fileType=all&tags=Software,Developer,Engineer HTTP/1.1", - request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat( - "v1/files?path=/&searchQuery=createdAt%20%3E=%20%272d%27%20OR%20size%20%3C%20%272mb%27%20OR%20format=%27png%27&limit=1&skip=0&sort=ASC_CREATED&type=file&fileType=all&tags=Software,Developer,Engineer"), - request.getRequestUrl().toString()); - - } - - @Test(expected = BadRequestException.class) - public void imageKit_getFileList_400_expected() - throws InterruptedException, ForbiddenException, TooManyRequestsException, InternalServerException, - UnauthorizedException, BadRequestException, UnknownException, IOException, IllegalAccessException, InstantiationException { - - MockWebServer server = new MockWebServer(); - String responseJson = "{\n" - + " \"message\": \"Invalid search query - createdAt field must have a valid date value. Make sure the value is enclosed within quotes. Please refer to the documentation for syntax specification.\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\"\n" + "}"; - server.enqueue(new MockResponse().setResponseCode(400).setBody(responseJson)); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - String[] tags = new String[3]; - tags[0] = "Software"; - tags[1] = "Developer"; - tags[2] = "Engineer"; - GetFileListRequest getFileListRequest = new GetFileListRequest(); - getFileListRequest.setType("file"); - getFileListRequest.setSort("ASC_CREATED"); - getFileListRequest.setPath("/"); - getFileListRequest.setSearchQuery("createdAt >= '2d' OR size < '2mb' OR format='png'"); - getFileListRequest.setFileType("all"); - getFileListRequest.setLimit("1"); - getFileListRequest.setSkip("0"); - getFileListRequest.setTags(tags); - SUT.getFileList(getFileListRequest); - - server.takeRequest(); - } - - @Test(expected = BadRequestException.class) - public void imageKit_getFileDetail__expected_400() - throws IOException, InterruptedException, BadRequestException, InternalServerException, UnknownException, - ForbiddenException, TooManyRequestsException, UnauthorizedException { - - MockWebServer server = new MockWebServer(); - String responseJson = "{\n" + " \"message\": \"Your request contains invalid fileId parameter.\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\"\n" + "}"; - server.enqueue(new MockResponse().setResponseCode(400).setBody(responseJson)); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.getFileDetail("fileId"); - - server.takeRequest(); - } - - @Test - public void imageKit_getFileDetail_successExpected() - throws IOException, ForbiddenException, TooManyRequestsException, InternalServerException, - UnauthorizedException, BadRequestException, UnknownException, InterruptedException { - MockWebServer server = new MockWebServer(); - String responseJson = "{\n" + " \"type\": \"file\",\n" + " \"name\": \"sample-image11_g1Qv0wpqP.jpg\",\n" - + " \"createdAt\": \"2022-06-20T05:00:41.830Z\",\n" - + " \"updatedAt\": \"2022-06-20T05:00:43.263Z\",\n" - + " \"fileId\": \"62affef97db937b028f3b47a\",\n" + " \"tags\": [\n" + " \"Software\",\n" - + " \"Developer\",\n" + " \"Engineer\"\n" + " ],\n" + " \"AITags\": null,\n" - + " \"versionInfo\": {\n" + " \"id\": \"62affef97db937b028f3b47a\",\n" - + " \"name\": \"Version 1\"\n" + " },\n" + " \"embeddedMetadata\": {},\n" - + " \"customCoordinates\": null,\n" + " \"customMetadata\": {},\n" - + " \"isPrivateFile\": false,\n" - + " \"url\": \"https://ik.imagekit.io/zv3rkhsym/sample-image11_g1Qv0wpqP.jpg\",\n" - + " \"thumbnail\": \"https://ik.imagekit.io/demo/img/static-file-1.png\",\n" - + " \"fileType\": \"non-image\",\n" + " \"filePath\": \"/sample-image11_g1Qv0wpqP.jpg\",\n" - + " \"size\": 169170\n" + "}"; - server.enqueue(new MockResponse().setBody(responseJson)); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.getFileDetail("62affef97db937b028f3b47a"); - - RecordedRequest request = server.takeRequest(); - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals("", utf8RequestBody); - assertEquals("application/json", request.getHeader("Content-Type")); - assertEquals("GET /v1/files/62affef97db937b028f3b47a/details HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/files/62affef97db937b028f3b47a/details"), - request.getRequestUrl().toString()); - } - - @Test - public void imageKit_getFileMetaData_successExpected() - throws IOException, ForbiddenException, TooManyRequestsException, InternalServerException, - UnauthorizedException, BadRequestException, UnknownException, InterruptedException { - MockWebServer server = new MockWebServer(); - String responseJson = "{\n" + " \"height\": 300,\n" + " \"width\": 300,\n" + " \"size\": 51085,\n" - + " \"format\": \"jpg\",\n" + " \"hasColorProfile\": false,\n" + " \"quality\": 0,\n" - + " \"density\": 300,\n" + " \"hasTransparency\": false,\n" + " \"exif\": {\n" - + " \"image\": {\n" + " \"Orientation\": 1,\n" + " \"XResolution\": 300,\n" - + " \"YResolution\": 300,\n" + " \"ResolutionUnit\": 2,\n" - + " \"Software\": \"Adobe Photoshop CS5 (12.0x20100115 [20100115.m.998 2010/01/15:02:00:00 cutoff; m branch]) Windows\",\n" - + " \"ModifyDate\": \"2017:09:11 22:15:46\",\n" + " \"ExifOffset\": 236\n" - + " },\n" + " \"thumbnail\": {\n" + " \"Compression\": 6,\n" - + " \"XResolution\": 72,\n" + " \"YResolution\": 72,\n" - + " \"ResolutionUnit\": 2,\n" + " \"ThumbnailOffset\": 374,\n" - + " \"ThumbnailLength\": 4083\n" + " },\n" + " \"exif\": {\n" - + " \"ColorSpace\": 65535,\n" + " \"ExifImageWidth\": 300,\n" - + " \"ExifImageHeight\": 300\n" + " },\n" + " \"gps\": {},\n" - + " \"interoperability\": {},\n" + " \"makernote\": {}\n" + " },\n" - + " \"pHash\": \"2df5da2dd63c6926\"\n" + "}"; - server.enqueue(new MockResponse().setBody(responseJson)); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.getFileMetadata("62b43109d23153217b8b8a36"); - - RecordedRequest request = server.takeRequest(); - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals("", utf8RequestBody); - assertEquals("application/json", request.getHeader("Content-Type")); - assertEquals("GET /v1/files/62b43109d23153217b8b8a36/metadata HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/files/62b43109d23153217b8b8a36/metadata"), - request.getRequestUrl().toString()); - - } - - @Test(expected = BadRequestException.class) - public void imageKit_getFileMetaData_400_Expected() - throws IOException, ForbiddenException, TooManyRequestsException, InternalServerException, - UnauthorizedException, BadRequestException, UnknownException, InterruptedException { - MockWebServer server = new MockWebServer(); - String responseJson = "{\n" + " \"message\": \"Your request contains invalid fileId parameter.\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\",\n" - + " \"type\": \"INVALID_PARAM_ERROR\"\n" + "}"; - server.enqueue(new MockResponse().setResponseCode(400).setBody(responseJson)); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.getFileMetadata("fileId"); - server.takeRequest(); - } - - @Test - public void imageKit_getRemoteFileMetaData_successExpected() - throws IOException, ForbiddenException, TooManyRequestsException, InternalServerException, - UnauthorizedException, BadRequestException, UnknownException, InterruptedException { - MockWebServer server = new MockWebServer(); - String responseJson = "{\n" + " \"height\": 1000,\n" + " \"width\": 1000,\n" + " \"size\": 147022,\n" - + " \"format\": \"jpg\",\n" + " \"hasColorProfile\": false,\n" + " \"quality\": 0,\n" - + " \"density\": 72,\n" + " \"hasTransparency\": false,\n" + " \"exif\": {},\n" - + " \"pHash\": \"e0d52b612ad538f6\"\n" + "}"; - server.enqueue(new MockResponse().setBody(responseJson)); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.getRemoteFileMetadata("https://ik.imagekit.io/zv3rkhsym/default-image.jpg"); - - RecordedRequest request = server.takeRequest(); - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals("", utf8RequestBody); - assertEquals("application/json", request.getHeader("Content-Type")); - assertEquals("GET /v1/metadata?url=https://ik.imagekit.io/zv3rkhsym/default-image.jpg HTTP/1.1", - request.getRequestLine()); - assertEquals( - RestClient.API_BASE_URL.concat("v1/metadata?url=https://ik.imagekit.io/zv3rkhsym/default-image.jpg"), - request.getRequestUrl().toString()); - - } - - @Test(expected = BadRequestException.class) - public void imageKit_getRemoteFileMetaData_400_Expected() - throws ForbiddenException, TooManyRequestsException, InternalServerException, UnauthorizedException, - BadRequestException, UnknownException, InterruptedException, IOException { - MockWebServer server = new MockWebServer(); - String responseJson = "{\n" - + " \"message\": \"remote_url should be accessible using your ImageKit.io account.\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\"\n" + "}"; - server.enqueue(new MockResponse().setResponseCode(400).setBody(responseJson)); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.getRemoteFileMetadata("remote_url"); - - server.takeRequest(); - } - - @Test(expected = BadRequestException.class) - public void imageKit_deleteFile_400_Expected() - throws ForbiddenException, TooManyRequestsException, InternalServerException, UnauthorizedException, - BadRequestException, UnknownException, InterruptedException, IOException { - MockWebServer server = new MockWebServer(); - String responseJson = "{\n" + " \"message\": \"Your request contains invalid fileId parameter.\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\"\n" + "}"; - server.enqueue(new MockResponse().setResponseCode(400).setBody(responseJson)); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.deleteFile("629f3de17eb0fe4053615450"); - - server.takeRequest(); - } - - @Test - public void imageKit_deleteFile_successExpected() - throws IOException, ForbiddenException, TooManyRequestsException, InternalServerException, - UnauthorizedException, BadRequestException, UnknownException, InterruptedException { - MockWebServer server = new MockWebServer(); - String responseJson = ""; - server.enqueue(new MockResponse().setResponseCode(204).setBody(responseJson)); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.deleteFile("62affef97db937b028f3b47a"); - - RecordedRequest request = server.takeRequest(); - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals("", utf8RequestBody); - assertEquals("application/json", request.getHeader("Content-Type")); - assertEquals("DELETE /v1/files/62affef97db937b028f3b47a HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/files/62affef97db937b028f3b47a"), - request.getRequestUrl().toString()); - } - - @Test(expected = NotFoundException.class) - public void imageKit_bulkDeleteFiles_404Expected() throws ForbiddenException, TooManyRequestsException, - InternalServerException, PartialSuccessException, UnauthorizedException, NotFoundException, - BadRequestException, UnknownException, IOException, InterruptedException { - List fileIds = new ArrayList<>(); - fileIds.add("file_id_1"); - fileIds.add("file_id_2"); - fileIds.add("file_id_3"); - MockWebServer server = new MockWebServer(); - String responseJson = "{\n" + " \"message\": \"The requested file(s) does not exist.\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\",\n" - + " \"missingFileIds\": [\n" + " \"62ad9ece7db937e35ef18dda\"\n" + " ]\n" + "}"; - server.enqueue(new MockResponse().setResponseCode(404).setBody(responseJson)); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.bulkDeleteFiles(fileIds); - - server.takeRequest(); - } - - @Test - public void imageKit_bulkDeleteFiles_successExpected() throws ForbiddenException, TooManyRequestsException, - InternalServerException, PartialSuccessException, UnauthorizedException, NotFoundException, - BadRequestException, UnknownException, IOException, InterruptedException { - List fileIds = new ArrayList<>(); - fileIds.add("62ad9ece7db937e35ef18dda"); - MockWebServer server = new MockWebServer(); - String responseJson = "{\n" + " \"successfullyDeletedFileIds\": [\n" - + " \"62ad9ece7db937e35ef18dda\"\n" + " ]\n" + "}"; - server.enqueue(new MockResponse().setBody(responseJson)); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.bulkDeleteFiles(fileIds); - - RecordedRequest request = server.takeRequest(); - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals("{\"fileIds\":[\"62ad9ece7db937e35ef18dda\"]}", utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("POST /v1/files/batch/deleteByFileIds HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/files/batch/deleteByFileIds"), - request.getRequestUrl().toString()); - } -} diff --git a/imagekit-sdk/src/test/java/io/imagekit/sdk/manage/FileVersionTest.java b/imagekit-sdk/src/test/java/io/imagekit/sdk/manage/FileVersionTest.java deleted file mode 100644 index 8189f580..00000000 --- a/imagekit-sdk/src/test/java/io/imagekit/sdk/manage/FileVersionTest.java +++ /dev/null @@ -1,267 +0,0 @@ -package io.imagekit.sdk.manage; - -import io.imagekit.sdk.ImageKit; -import io.imagekit.sdk.ImageKitTest; -import io.imagekit.sdk.exceptions.BadRequestException; -import io.imagekit.sdk.exceptions.ForbiddenException; -import io.imagekit.sdk.exceptions.InternalServerException; -import io.imagekit.sdk.exceptions.NotFoundException; -import io.imagekit.sdk.exceptions.TooManyRequestsException; -import io.imagekit.sdk.exceptions.UnauthorizedException; -import io.imagekit.sdk.exceptions.UnknownException; -import io.imagekit.sdk.models.DeleteFileVersionRequest; -import io.imagekit.sdk.tasks.RestClient; -import io.imagekit.sdk.utils.Utils; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; - -import static org.junit.Assert.assertEquals; - -public class FileVersionTest { - - private ImageKit SUT; - - @Before - public void setUp() throws Exception { - SUT = ImageKit.getInstance(); - SUT.setConfig(Utils.getSystemConfig(ImageKitTest.class)); - } - - @Test(expected = NotFoundException.class) - public void getFileVersions_404_Expected() - throws InterruptedException, IOException, NotFoundException, BadRequestException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404) - .setBody("{\n" + " \"message\": \"The requested asset does not exist.\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.getFileVersions("id"); - server.takeRequest(); - } - - @Test - public void getFileVersions_successExpected() - throws InterruptedException, IOException, NotFoundException, BadRequestException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("[\n" + " {\n" + " \"type\": \"file\",\n" - + " \"name\": \"w2_image.png\",\n" + " \"createdAt\": \"2022-06-07T12:00:33.825Z\",\n" - + " \"updatedAt\": \"2022-06-07T12:00:33.828Z\",\n" - + " \"fileId\": \"629f3de17eb0fe4053615450\",\n" + " \"tags\": [\n" - + " \"tag10\"\n" + " ],\n" + " \"AITags\": [\n" + " {\n" - + " \"name\": \"Colorfulness\",\n" + " \"confidence\": 96.19,\n" - + " \"source\": \"google-auto-tagging\"\n" + " },\n" + " {\n" - + " \"name\": \"Purple\",\n" + " \"confidence\": 86.05,\n" - + " \"source\": \"google-auto-tagging\"\n" + " },\n" + " {\n" - + " \"name\": \"Violet\",\n" + " \"confidence\": 81.08,\n" - + " \"source\": \"google-auto-tagging\"\n" + " },\n" + " {\n" - + " \"name\": \"Rectangle\",\n" + " \"confidence\": 80.99,\n" - + " \"source\": \"google-auto-tagging\"\n" + " }\n" + " ],\n" - + " \"versionInfo\": {\n" + " \"id\": \"629f3de17eb0fe4053615450\",\n" - + " \"name\": \"Version 1\"\n" + " },\n" + " \"embeddedMetadata\": {\n" - + " \"DateCreated\": \"2022-05-26T06:05:18.087Z\",\n" + " \"ImageWidth\": 1006,\n" - + " \"ImageHeight\": 467,\n" - + " \"DateTimeCreated\": \"2022-05-26T06:05:18.088Z\"\n" + " },\n" - + " \"customCoordinates\": null,\n" + " \"customMetadata\": {},\n" - + " \"isPrivateFile\": false,\n" - + " \"url\": \"https://ik.imagekit.io/xyxt2lnil/w2_image.png\",\n" - + " \"thumbnail\": \"https://ik.imagekit.io/xyxt2lnil/tr:n-ik_ml_thumbnail/w2_image.png\",\n" - + " \"fileType\": \"image\",\n" + " \"filePath\": \"/w2_image.png\",\n" - + " \"height\": 467,\n" + " \"width\": 1006,\n" + " \"size\": 47579,\n" - + " \"hasAlpha\": true,\n" + " \"mime\": \"image/png\"\n" + " }\n" + "]")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.getFileVersions("629f3de17eb0fe4053615450"); - RecordedRequest request = server.takeRequest(); - - assertEquals("application/json", request.getHeader("Content-Type")); - assertEquals("GET /v1/files/629f3de17eb0fe4053615450/versions HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/files/629f3de17eb0fe4053615450/versions"), - request.getRequestUrl().toString()); - } - - @Test(expected = NotFoundException.class) - public void getFileVersionDetails_404_Expected() - throws InterruptedException, IOException, NotFoundException, BadRequestException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404) - .setBody("{\n" + " \"message\": \"The requested asset does not exist.\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.getFileVersionDetails("629f3de17eb0fe4053615450", "629f3de17eb0fe4053615450"); - server.takeRequest(); - } - - @Test - public void getFileVersionDetails_successExpected() - throws InterruptedException, IOException, NotFoundException, BadRequestException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("{\n" + " \"type\": \"file\",\n" - + " \"name\": \"w2_image.png\",\n" + " \"createdAt\": \"2022-06-07T12:00:33.825Z\",\n" - + " \"updatedAt\": \"2022-06-07T12:00:33.828Z\",\n" - + " \"fileId\": \"629f3de17eb0fe4053615450\",\n" + " \"tags\": [\n" + " \"tag10\"\n" - + " ],\n" + " \"AITags\": [\n" + " {\n" + " \"name\": \"Colorfulness\",\n" - + " \"confidence\": 96.19,\n" + " \"source\": \"google-auto-tagging\"\n" - + " },\n" + " {\n" + " \"name\": \"Purple\",\n" - + " \"confidence\": 86.05,\n" + " \"source\": \"google-auto-tagging\"\n" - + " },\n" + " {\n" + " \"name\": \"Violet\",\n" - + " \"confidence\": 81.08,\n" + " \"source\": \"google-auto-tagging\"\n" - + " },\n" + " {\n" + " \"name\": \"Rectangle\",\n" - + " \"confidence\": 80.99,\n" + " \"source\": \"google-auto-tagging\"\n" - + " }\n" + " ],\n" + " \"versionInfo\": {\n" - + " \"id\": \"629f3de17eb0fe4053615450\",\n" + " \"name\": \"Version 1\"\n" + " },\n" - + " \"embeddedMetadata\": {\n" + " \"DateCreated\": \"2022-05-26T06:05:18.087Z\",\n" - + " \"ImageWidth\": 1006,\n" + " \"ImageHeight\": 467,\n" - + " \"DateTimeCreated\": \"2022-05-26T06:05:18.088Z\"\n" + " },\n" - + " \"customCoordinates\": null,\n" + " \"customMetadata\": {},\n" - + " \"isPrivateFile\": false,\n" - + " \"url\": \"https://ik.imagekit.io/xyxt2lnil/w2_image.png\",\n" - + " \"thumbnail\": \"https://ik.imagekit.io/xyxt2lnil/tr:n-ik_ml_thumbnail/w2_image.png\",\n" - + " \"fileType\": \"image\",\n" + " \"filePath\": \"/w2_image.png\",\n" + " \"height\": 467,\n" - + " \"width\": 1006,\n" + " \"size\": 47579,\n" + " \"hasAlpha\": true,\n" - + " \"mime\": \"image/png\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.getFileVersionDetails("629f3de17eb0fe4053615450", "629f3de17eb0fe4053615450"); - RecordedRequest request = server.takeRequest(); - - assertEquals("application/json", request.getHeader("Content-Type")); - assertEquals("GET /v1/files/629f3de17eb0fe4053615450/versions/629f3de17eb0fe4053615450 HTTP/1.1", - request.getRequestLine()); - assertEquals( - RestClient.API_BASE_URL.concat("v1/files/629f3de17eb0fe4053615450/versions/629f3de17eb0fe4053615450"), - request.getRequestUrl().toString()); - } - - @Test(expected = BadRequestException.class) - public void deleteFileVersion_400_SuccessWith() - throws IOException, InterruptedException, BadRequestException, NotFoundException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - - DeleteFileVersionRequest deleteFileVersionRequest = new DeleteFileVersionRequest(); - deleteFileVersionRequest.setFileId("629d90768482ba272ed17628"); - deleteFileVersionRequest.setVersionId("id"); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(400) - .setBody("{\n" + " \"message\": \"Your request contains invalid versionId parameter.\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.deleteFileVersion(deleteFileVersionRequest); - server.takeRequest(); - } - - @Test(expected = NotFoundException.class) - public void deleteFileVersion_404_SuccessWith() - throws IOException, InterruptedException, BadRequestException, NotFoundException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - - DeleteFileVersionRequest deleteFileVersionRequest = new DeleteFileVersionRequest(); - deleteFileVersionRequest.setFileId("629d90768482ba272ed17628"); - deleteFileVersionRequest.setVersionId("62a9c403d89eedb81721102b"); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404) - .setBody("{\n" + " \"message\": \"The requested file version does not exist.\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.deleteFileVersion(deleteFileVersionRequest); - server.takeRequest(); - } - - @Test - public void deleteFileVersion_expectedSuccessWith() - throws IOException, InterruptedException, BadRequestException, NotFoundException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - - DeleteFileVersionRequest deleteFileVersionRequest = new DeleteFileVersionRequest(); - deleteFileVersionRequest.setFileId("629d90768482ba272ed17628"); - deleteFileVersionRequest.setVersionId("629d91878482bae8bed177f2"); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(204).setBody("")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.deleteFileVersion(deleteFileVersionRequest); - RecordedRequest request = server.takeRequest(); - - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals("", utf8RequestBody); - assertEquals("application/json", request.getHeader("Content-Type")); - assertEquals("DELETE /v1/files/629d90768482ba272ed17628/versions/629d91878482bae8bed177f2 HTTP/1.1", - request.getRequestLine()); - assertEquals( - RestClient.API_BASE_URL.concat("v1/files/629d90768482ba272ed17628/versions/629d91878482bae8bed177f2"), - request.getRequestUrl().toString()); - } - - @Test - public void restoreFileVersion_expectedSuccessWith() - throws IOException, InterruptedException, BadRequestException, NotFoundException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("{\n" + " \"type\": \"file\",\n" - + " \"name\": \"new_car.jpg\",\n" + " \"createdAt\": \"2022-06-15T11:34:36.294Z\",\n" - + " \"updatedAt\": \"2022-06-27T12:11:11.254Z\",\n" - + " \"fileId\": \"62a9c3ccd875ec6fd658c854\",\n" + " \"tags\": [\n" + " \"tagg\",\n" - + " \"tagg1\"\n" + " ],\n" + " \"AITags\": null,\n" + " \"versionInfo\": {\n" - + " \"id\": \"62b97749f63122840530fda9\",\n" + " \"name\": \"Version 1\"\n" + " },\n" - + " \"embeddedMetadata\": {\n" + " \"XResolution\": 250,\n" - + " \"YResolution\": 250,\n" + " \"DateCreated\": \"2022-06-15T11:34:36.702Z\",\n" - + " \"DateTimeCreated\": \"2022-06-15T11:34:36.702Z\"\n" + " },\n" - + " \"customCoordinates\": \"10,10,20,20\",\n" + " \"customMetadata\": {\n" - + " \"test100\": 10\n" + " },\n" + " \"isPrivateFile\": false,\n" - + " \"url\": \"https://ik.imagekit.io/zv3rkhsym/new_car.jpg\",\n" - + " \"thumbnail\": \"https://ik.imagekit.io/zv3rkhsym/tr:n-ik_ml_thumbnail/new_car.jpg\",\n" - + " \"fileType\": \"image\",\n" + " \"filePath\": \"/new_car.jpg\",\n" + " \"height\": 354,\n" - + " \"width\": 236,\n" + " \"size\": 23023,\n" + " \"hasAlpha\": false,\n" - + " \"mime\": \"image/jpeg\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.restoreFileVersion("62a9c3ccd875ec6fd658c854", "62b97749f63122840530fda9"); - RecordedRequest request = server.takeRequest(); - - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals("", utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("PUT /v1/files/62a9c3ccd875ec6fd658c854/versions/62b97749f63122840530fda9/restore HTTP/1.1", - request.getRequestLine()); - assertEquals( - RestClient.API_BASE_URL - .concat("v1/files/62a9c3ccd875ec6fd658c854/versions/62b97749f63122840530fda9/restore"), - request.getRequestUrl().toString()); - } - - @Test(expected = NotFoundException.class) - public void restoreFileVersion_expected_404() - throws IOException, InterruptedException, BadRequestException, NotFoundException, InternalServerException, - UnknownException, ForbiddenException, TooManyRequestsException, UnauthorizedException { - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404) - .setBody("{\n" + " \"message\": \"The requested file version does not exist.\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\"\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.restoreFileVersion("62a9c3ccd875ec6fd658c854", "62b97749f63122840530fda9"); - RecordedRequest request = server.takeRequest(); - request.getBody().readUtf8(); - } -} diff --git a/imagekit-sdk/src/test/java/io/imagekit/sdk/manage/TagsTest.java b/imagekit-sdk/src/test/java/io/imagekit/sdk/manage/TagsTest.java deleted file mode 100644 index 3aaeb172..00000000 --- a/imagekit-sdk/src/test/java/io/imagekit/sdk/manage/TagsTest.java +++ /dev/null @@ -1,194 +0,0 @@ -package io.imagekit.sdk.manage; - -import io.imagekit.sdk.ImageKit; -import io.imagekit.sdk.ImageKitTest; -import io.imagekit.sdk.exceptions.BadRequestException; -import io.imagekit.sdk.exceptions.ForbiddenException; -import io.imagekit.sdk.exceptions.InternalServerException; -import io.imagekit.sdk.exceptions.NotFoundException; -import io.imagekit.sdk.exceptions.PartialSuccessException; -import io.imagekit.sdk.exceptions.TooManyRequestsException; -import io.imagekit.sdk.exceptions.UnauthorizedException; -import io.imagekit.sdk.exceptions.UnknownException; -import io.imagekit.sdk.models.AITagsRequest; -import io.imagekit.sdk.models.TagsRequest; -import io.imagekit.sdk.tasks.RestClient; -import io.imagekit.sdk.utils.Utils; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertEquals; - -public class TagsTest { - - private ImageKit SUT; - - @Before - public void setUp() throws Exception { - SUT = ImageKit.getInstance(); - SUT.setConfig(Utils.getSystemConfig(ImageKitTest.class)); - } - - @Test(expected = NotFoundException.class) - public void add_tags_expected_404() throws IOException, InterruptedException, NotFoundException, - PartialSuccessException, BadRequestException, InternalServerException, UnknownException, ForbiddenException, - TooManyRequestsException, UnauthorizedException { - - List fileIds = new ArrayList<>(); - fileIds.add("629f3de17eb0fe4053615450"); - List tags = new ArrayList<>(); - tags.add("tag1"); - tags.add("tag2"); - - TagsRequest tagsRequest = new TagsRequest(fileIds, tags); - - MockWebServer server = new MockWebServer(); - String tagsResponseJson = "{\n" + " \"message\": \"The requested file(s) does not exist.\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\",\n" - + " \"missingFileIds\": [\n" + " \"629f3de17eb0fe4053615450\"\n" + " ]\n" + "}"; - server.enqueue(new MockResponse().setResponseCode(404).setBody(tagsResponseJson)); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.addTags(tagsRequest); - - server.takeRequest(); - } - - @Test - public void add_tags_expectedSuccessWith() throws IOException, InterruptedException, NotFoundException, - PartialSuccessException, BadRequestException, InternalServerException, UnknownException, ForbiddenException, - TooManyRequestsException, UnauthorizedException { - - List fileIds = new ArrayList<>(); - fileIds.add("62958deef33aa80bdadf7533"); - List tags = new ArrayList<>(); - tags.add("tag1"); - tags.add("tag2"); - - TagsRequest tagsRequest = new TagsRequest(fileIds, tags); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("{\"successfullyUpdatedFileIds\": [\"62958deef33aa80bdadf7533\"]}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.addTags(tagsRequest); - RecordedRequest request = server.takeRequest(); - - String tagsRequestJson = "{\"fileIds\":[\"62958deef33aa80bdadf7533\"],\"tags\":[\"tag1\",\"tag2\"]}"; - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals(tagsRequestJson, utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("POST /v1/files/addTags HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/files/addTags"), request.getRequestUrl().toString()); - } - - @Test(expected = NotFoundException.class) - public void remove_tags_expected_404_bad_request() throws InterruptedException, NotFoundException, - PartialSuccessException, BadRequestException, InternalServerException, UnknownException, ForbiddenException, - TooManyRequestsException, UnauthorizedException { - - List fileIds = new ArrayList<>(); - fileIds.add("629f3de17eb0fe4053615450"); - List tags = new ArrayList<>(); - tags.add("tag1"); - - TagsRequest tagsRequest = new TagsRequest(fileIds, tags); - - MockWebServer server = new MockWebServer(); - String tagsResponseJson = "{\n" + " \"message\": \"The requested file(s) does not exist.\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\",\n" - + " \"missingFileIds\": [\n" + " \"629f3de17eb0fe4053615450\"\n" + " ]\n" + "}"; - server.enqueue(new MockResponse().setResponseCode(404).setBody(tagsResponseJson)); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.removeTags(tagsRequest); - server.takeRequest(); - } - - @Test - public void remove_tags_expectedSuccessWith() throws IOException, InterruptedException, NotFoundException, - PartialSuccessException, BadRequestException, InternalServerException, UnknownException, ForbiddenException, - TooManyRequestsException, UnauthorizedException { - - List fileIds = new ArrayList<>(); - fileIds.add("62958deef33aa80bdadf7533"); - List tags = new ArrayList<>(); - tags.add("tag1"); - - TagsRequest tagsRequest = new TagsRequest(fileIds, tags); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("{\"successfullyUpdatedFileIds\": [\"62958deef33aa80bdadf7533\"]}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.removeTags(tagsRequest); - RecordedRequest request = server.takeRequest(); - - String tagsRequestJson = "{\"fileIds\":[\"62958deef33aa80bdadf7533\"],\"tags\":[\"tag1\"]}"; - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals(tagsRequestJson, utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("POST /v1/files/removeTags HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/files/removeTags"), request.getRequestUrl().toString()); - } - - @Test(expected = NotFoundException.class) - public void removeAITags_404_Expected() throws InterruptedException, IOException, PartialSuccessException, - NotFoundException, BadRequestException, InternalServerException, UnknownException, ForbiddenException, - TooManyRequestsException, UnauthorizedException { - - List fileIds = new ArrayList<>(); - fileIds.add("629f3de17eb0fe4053615450"); - List aiTags = new ArrayList<>(); - aiTags.add("Font"); - - AITagsRequest aiTagsRequest = new AITagsRequest(); - aiTagsRequest.setFileIds(fileIds); - aiTagsRequest.setAITags(aiTags); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404) - .setBody("{\n" + " \"message\": \"The requested file(s) does not exist.\",\n" - + " \"help\": \"For support kindly contact us at support@imagekit.io .\",\n" - + " \"missingFileIds\": [\n" + " \"629f3de17eb0fe4053615450\"\n" + " ]\n" + "}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.removeAITags(aiTagsRequest); - server.takeRequest(); - } - - @Test - public void removeAITags_successExpected() throws InterruptedException, IOException, PartialSuccessException, - NotFoundException, BadRequestException, InternalServerException, UnknownException, ForbiddenException, - TooManyRequestsException, UnauthorizedException { - - List fileIds = new ArrayList<>(); - fileIds.add("62958deef33aa80bdadf7533"); - List aiTags = new ArrayList<>(); - aiTags.add("Font"); - - AITagsRequest aiTagsRequest = new AITagsRequest(); - aiTagsRequest.setFileIds(fileIds); - aiTagsRequest.setAITags(aiTags); - - MockWebServer server = new MockWebServer(); - server.enqueue(new MockResponse().setBody("{\"successfullyUpdatedFileIds\": [\"62958deef33aa80bdadf7533\"]}")); - server.start(); - RestClient.API_BASE_URL = server.url("/").toString(); - SUT.removeAITags(aiTagsRequest); - RecordedRequest request = server.takeRequest(); - - String aiTagsRequestJson = "{\"fileIds\":[\"62958deef33aa80bdadf7533\"],\"AITags\":[\"Font\"]}"; - String utf8RequestBody = request.getBody().readUtf8(); - assertEquals(aiTagsRequestJson, utf8RequestBody); - assertEquals("application/json; charset=utf-8", request.getHeader("Content-Type")); - assertEquals("POST /v1/files/removeAITags HTTP/1.1", request.getRequestLine()); - assertEquals(RestClient.API_BASE_URL.concat("v1/files/removeAITags"), request.getRequestUrl().toString()); - } -} diff --git a/imagekit-sdk/src/test/java/io/imagekit/sdk/tasks/CalculationTest.java b/imagekit-sdk/src/test/java/io/imagekit/sdk/tasks/CalculationTest.java deleted file mode 100644 index f6e8e5e4..00000000 --- a/imagekit-sdk/src/test/java/io/imagekit/sdk/tasks/CalculationTest.java +++ /dev/null @@ -1,104 +0,0 @@ -package io.imagekit.sdk.tasks; - - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import java.util.Calendar; -import java.util.Map; -import java.util.UUID; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; - -public class CalculationTest { - Calculation SUT; - - @Before - public void setUp() throws Exception { - SUT=new Calculation(); - } - - @Test(expected = RuntimeException.class) - public void nullPrivateKey_getAuthenticatedParams_throwException() { - Calculation.getAuthenticatedParams(UUID.randomUUID().toString(), Calendar.getInstance().getTimeInMillis(),null); - } - - @Test - public void privateKeyProvided_getAuthenticatedParams_with_static_input_ExpectedData() { - String token="your_token"; - String privateKey="private_key_test"; - long expire=1582269249; - Map authenticatedParams = Calculation.getAuthenticatedParams(token, expire, privateKey); - assertEquals(token,authenticatedParams.get("token")); - assertEquals(String.valueOf(expire),authenticatedParams.get("expire")); - assertEquals("e71bcd6031016b060d349d212e23e85c791decdd",authenticatedParams.get("signature")); - } - - @Test - public void privateKeyProvided_getAuthenticatedParams_ExpectedData() { - String token=UUID.randomUUID().toString(); - String privateKey="my_private_key"; - long expire=Calendar.getInstance().getTimeInMillis(); - Map authenticatedParams = Calculation.getAuthenticatedParams(token, expire, privateKey); - assertThat(authenticatedParams.get("token"),is(token)); - assertEquals(String.valueOf(expire),authenticatedParams.get("expire")); - assertNotNull(authenticatedParams.get("signature")); - } - - @Test - public void expireNotProvided_getAuthenticatedParams_ExpectedData() { - String token=UUID.randomUUID().toString(); - String privateKey="my_private_key"; - Map authenticatedParams = Calculation.getAuthenticatedParams(token,0, privateKey); - assertThat(authenticatedParams.get("token"),is(token)); - assertNotNull(authenticatedParams.get("expire")); - assertNotNull(authenticatedParams.get("signature")); - } - - @Test - public void sameImage_getHammingDistance_expectedSuccessWith() { - int hammingDistance = Calculation.getHammingDistance("f06830ca9f1e3e90", "f06830ca9f1e3e90"); - assertEquals(0,hammingDistance); - } - - @Test - public void similarImage_getHammingDistance_expectedSuccessWith() { - int hammingDistance = Calculation.getHammingDistance("2d5ad3936d2e015b", "2d6ed293db36a4fb"); - assertEquals(17,hammingDistance); - } - - @Test - public void dissimilarImage_getHammingDistance_expectedSuccessWith() { - int hammingDistance = Calculation.getHammingDistance("a4a65595ac94518b", "7838873e791f8400"); - assertEquals(37,hammingDistance); - } - - @Test(expected = RuntimeException.class) - public void invalidHash_getHammingDistance_throwException() { - int hammingDistance = Calculation.getHammingDistance("a4a65595ac94518Z", "7838873e791f8400"); - } - - @Test(expected = RuntimeException.class) - public void differentLength_getHammingDistance_throwException() { - int hammingDistance = Calculation.getHammingDistance("a4a65595ac94518b3", "7838873e791f8400"); - } - - @Test - public void correctHex_isValidHex_trueExpected() { - boolean result=Calculation.isValidHex("a4a65595ac94518b"); - assertTrue(result); - } - - @Test - public void incorrectHex_isValidHex_falseExpected() { - boolean result=Calculation.isValidHex("a4a65595ac94518T"); - assertFalse(result); - } - - @After - public void tearDown() throws Exception { - SUT=null; - } -} \ No newline at end of file diff --git a/imagekit-sdk/src/test/java/io/imagekit/sdk/tasks/MultipartBuilderTest.java b/imagekit-sdk/src/test/java/io/imagekit/sdk/tasks/MultipartBuilderTest.java deleted file mode 100644 index 9b1a705c..00000000 --- a/imagekit-sdk/src/test/java/io/imagekit/sdk/tasks/MultipartBuilderTest.java +++ /dev/null @@ -1,239 +0,0 @@ -package io.imagekit.sdk.tasks; - -import com.google.gson.Gson; -import io.imagekit.sdk.models.FileCreateRequest; -import io.imagekit.sdk.models.FileUpdateRequest; -import okhttp3.*; -import okhttp3.mockwebserver.Dispatcher; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import static org.junit.Assert.assertEquals; - - -public class MultipartBuilderTest { - MockWebServer server; - Map headers; - OkHttpClient okHttpClient; - MultipartBuilder SUT; - - @Before - public void setUp() throws Exception { - SUT=new MultipartBuilder(); - - String credential = Credentials.basic("private_key_test",""); - headers=new HashMap<>(); - headers.put("Accept-Encoding","application/json"); - headers.put("Content-Type","application/json"); - headers.put("Authorization",credential); - - server = new MockWebServer(); - MockResponse response=new MockResponse() - .setResponseCode(200) - .setBody("{isSuccessful=true, message='Your request contains invalid file.', help='For support kindly contact us at support@imagekit.io .', fileId='null', name='null', url='null', thumbnail='null', height=0, width=0, size=0, filePath='null', tags='null', isPrivateFile=false, customCoordinates='null', fileType='null'}"); - - server.setDispatcher(new Dispatcher() { - @Override - public MockResponse dispatch(RecordedRequest request) throws InterruptedException { - return response; - } - }); - server.start(); - - okHttpClient= new OkHttpClient.Builder() - .connectTimeout(2, TimeUnit.SECONDS) - .readTimeout(2, TimeUnit.SECONDS) - .writeTimeout(2, TimeUnit.SECONDS) - .build(); - - } - - @After - public void tearDown() throws Exception { - server.shutdown(); - } - - @Test - public void build_test_with_FileCreateRequest() throws Exception{ - - FileCreateRequest fileCreateRequest=new FileCreateRequest("f06830ca9f1e3e90","demo.jpg"); - fileCreateRequest.setPrivateFile(true); - - MultipartBody body = SUT.build(fileCreateRequest); - - HttpUrl baseUrl = server.url("/api/v1/files/upload"); - Request request=new Request.Builder() - .url(baseUrl) - .post(body) - .headers(Headers.of(headers)) - .build(); - - Response response = okHttpClient.newCall(request).execute(); - - String boundary=body.boundary(); - - String expectedMultipartData="--"+boundary+"\r\n" + - "Content-Disposition: form-data; name=\"file\"\r\n" + - "Content-Length: 16\r\n\r\n" + - "f06830ca9f1e3e90\r\n" + - "--"+boundary+"\r\n" + - "Content-Disposition: form-data; name=\"fileName\"\r\n" + - "Content-Length: 8\r\n\r\n" + - "demo.jpg\r\n" + - "--"+boundary+"\r\n" + - "Content-Disposition: form-data; name=\"useUniqueFileName\"\r\n" + - "Content-Length: 4\r\n\r\n" + - "true\r\n" + - "--"+boundary+"\r\n" + - "Content-Disposition: form-data; name=\"isPrivateFile\"\r\n" + - "Content-Length: 4\r\n\r\n" + - "true\r\n" + - "--"+boundary+"--\r\n"; - - // It's capture multipart request - RecordedRequest recordedRequest=server.takeRequest(); - - String data=recordedRequest.getBody().readUtf8(); - - assertEquals(expectedMultipartData, data); - } - - @Test - public void build_test_with_FileCreateRequest_more_params() throws Exception{ - - FileCreateRequest fileCreateRequest=new FileCreateRequest("f06830ca9f1e3e90","demo.jpg"); - fileCreateRequest.setPrivateFile(true); - fileCreateRequest.setFolder("/sample-folder"); - List tags=new ArrayList<>(); - tags.add("Software"); - tags.add("Developer"); - tags.add("Engineer"); - fileCreateRequest.setTags(tags); - fileCreateRequest.setCustomCoordinates("10,10,100,100"); - List responseFields=new ArrayList<>(); - responseFields.add("metadata"); - fileCreateRequest.setResponseFields(responseFields); - - MultipartBody body = SUT.build(fileCreateRequest); - - HttpUrl baseUrl = server.url("/api/v1/files/upload"); - Request request=new Request.Builder() - .url(baseUrl) - .post(body) - .headers(Headers.of(headers)) - .build(); - - Response response = okHttpClient.newCall(request).execute(); - - String boundary=body.boundary(); - - String expectedMultipartData="--"+boundary+"\r\n" + - "Content-Disposition: form-data; name=\"file\"\r\n" + - "Content-Length: 16\r\n\r\n" + - "f06830ca9f1e3e90\r\n" + - "--"+boundary+"\r\n" + - "Content-Disposition: form-data; name=\"fileName\"\r\n" + - "Content-Length: 8\r\n\r\n" + - "demo.jpg\r\n" + - "--"+boundary+"\r\n" + - "Content-Disposition: form-data; name=\"useUniqueFileName\"\r\n" + - "Content-Length: 4\r\n\r\n" + - "true\r\n" + - "--"+boundary+"\r\n" + - "Content-Disposition: form-data; name=\"tags\"\r\n" + - "Content-Length: 27\r\n\r\n" + - "Software,Developer,Engineer\r\n" + - "--"+boundary+"\r\n" + - "Content-Disposition: form-data; name=\"folder\"\r\n" + - "Content-Length: 14\r\n\r\n" + - "/sample-folder\r\n" + - "--"+boundary+"\r\n" + - "Content-Disposition: form-data; name=\"isPrivateFile\"\r\n" + - "Content-Length: 4\r\n\r\n" + - "true\r\n" + - "--"+boundary+"\r\n" + - "Content-Disposition: form-data; name=\"customCoordinates\"\r\n" + - "Content-Length: 13\r\n\r\n" + - "10,10,100,100\r\n" + - "--"+boundary+"\r\n" + - "Content-Disposition: form-data; name=\"responseFields\"\r\n" + - "Content-Length: 8\r\n\r\n" + - "metadata\r\n" + - "--"+boundary+"--\r\n"; - - - // It's capture multipart request - RecordedRequest recordedRequest=server.takeRequest(); - - String data=recordedRequest.getBody().readUtf8(); - - assertEquals(expectedMultipartData, data); - } - - @Test - public void build_test_with_FileUpdateRequest() throws Exception{ - - FileUpdateRequest fileUpdateRequest=new FileUpdateRequest("598821f949c0a938d57563bd"); - List tags=new ArrayList<>(); - tags.add("t-shirt"); - tags.add("round-neck"); - tags.add("sale2020"); - fileUpdateRequest.setTags(tags); - - RequestBody body=SUT.build(fileUpdateRequest); - - HttpUrl baseUrl = server.url(String.format("/v1/files/%s/details",fileUpdateRequest.getFileId())); - Request request=new Request.Builder() - .url(baseUrl) - .post(body) - .headers(Headers.of(headers)) - .build(); - - Response response = okHttpClient.newCall(request).execute(); - - - String expectedRequestObject="{\"fileId\":\"598821f949c0a938d57563bd\",\"tags\":[\"t-shirt\",\"round-neck\",\"sale2020\"]}"; - - // It's capture multipart request - RecordedRequest recordedRequest=server.takeRequest(); - - String data=recordedRequest.getBody().readUtf8(); - - assertEquals(expectedRequestObject, data); - } - - @Test - public void build_test_with_From_Json_String() throws Exception{ - - String json="{\"fileIds\":[\"598821f949c0a938d57534bd\",\"338821f949c0a938d57563bz\",\"987821f949c0a938d57563rt\"]}"; - - RequestBody body=SUT.build(json); - - HttpUrl baseUrl = server.url("/v1/files/batch/deleteByFileIds"); - Request request=new Request.Builder() - .url(baseUrl) - .post(body) - .headers(Headers.of(headers)) - .build(); - - Response response = okHttpClient.newCall(request).execute(); - - - String expectedRequestObject="{\"fileIds\":[\"598821f949c0a938d57534bd\",\"338821f949c0a938d57563bz\",\"987821f949c0a938d57563rt\"]}"; - - // It's capture multipart request - RecordedRequest recordedRequest=server.takeRequest(); - - String data=recordedRequest.getBody().readUtf8(); - - assertEquals(expectedRequestObject, data); - } -} \ No newline at end of file diff --git a/imagekit-sdk/src/test/java/io/imagekit/sdk/tasks/QueryMakerTest.java b/imagekit-sdk/src/test/java/io/imagekit/sdk/tasks/QueryMakerTest.java deleted file mode 100644 index 6eb08160..00000000 --- a/imagekit-sdk/src/test/java/io/imagekit/sdk/tasks/QueryMakerTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.imagekit.sdk.tasks; - -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class QueryMakerTest { - - QueryMaker SUT; - - @Before - public void setUp() throws Exception { - SUT=new QueryMaker(); - } - - @Test - public void prepareQueary_returnQueryString() { - SUT.put("public=allow"); - SUT.put("user=guest"); - String param = SUT.get(); - assertEquals("public=allow&user=guest",param); - } - - @Test - public void withoutEntry_prepareQueary() { - String param = SUT.get(); - assertNull(param); - } -} \ No newline at end of file diff --git a/imagekit-sdk/src/test/java/io/imagekit/sdk/tasks/UrlGenTest.java b/imagekit-sdk/src/test/java/io/imagekit/sdk/tasks/UrlGenTest.java deleted file mode 100644 index 1b379a81..00000000 --- a/imagekit-sdk/src/test/java/io/imagekit/sdk/tasks/UrlGenTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.imagekit.sdk.tasks; - -import org.junit.Test; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; - -public class UrlGenTest { - @Test - public void signUrl_tests() { - String url="https://test-domain.com/test-endpoint/tr:w-100/test-signed-url.png"; - String signature = UrlGen.signUrl("private_key_test", url, "https://test-domain.com/test-endpoint/", 100); - assertThat("5e5037a31a7121cbe2964e220b4338cc6e1ba66d",is(signature)); - - } - - @Test - public void signUrl_tests_expire_zero() { - String url="https://test-domain.com/test-endpoint/tr:w-100/test-signed-url.png"; - String signature = UrlGen.signUrl("private_key_test", url, "https://test-domain.com/test-endpoint/", 0); - assertThat("41b3075c40bc84147eb71b8b49ae7fbf349d0f00",is(signature)); - - } - - @Test - public void signUrl_tests_without_slash_expire_zero() { - String url="https://test-domain.com/test-endpoint/tr:w-100/test-signed-url.png"; - String signature = UrlGen.signUrl("private_key_test", url, "https://test-domain.com/test-endpoint", 0); - assertThat("41b3075c40bc84147eb71b8b49ae7fbf349d0f00",is(signature)); - - } -} \ No newline at end of file diff --git a/imagekit-sdk/src/test/java/io/imagekit/sdk/utils/UtilsTest.java b/imagekit-sdk/src/test/java/io/imagekit/sdk/utils/UtilsTest.java deleted file mode 100644 index e68b2067..00000000 --- a/imagekit-sdk/src/test/java/io/imagekit/sdk/utils/UtilsTest.java +++ /dev/null @@ -1,90 +0,0 @@ -package io.imagekit.sdk.utils; - -import io.imagekit.sdk.config.Configuration; -import org.junit.Test; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; - -public class UtilsTest { - - @Test - public void empty_listToString_returnTrue() { - List list=new ArrayList<>(); - String data=Utils.listToString(list); - assertNotNull(data); - } - - @Test - public void withElements_listToString_returnTrue() { - List list=new ArrayList<>(); - list.add("Element 1"); - list.add("Element 2"); - list.add("Element 3"); - String data=Utils.listToString(list); - assertThat("Element 1,Element 2,Element 3",is(data)); - } - - @Test - public void withNullElements_listToString_returnTrue() { - List list=new ArrayList<>(); - list.add("Element 1"); - list.add(null); - list.add("Element 2"); - String data=Utils.listToString(list); - assertEquals("Element 1,Element 2",data); - } - - @Test - public void withNullElements_listToString_returnFalse() { - List list=new ArrayList<>(); - list.add("Element 1"); - list.add(null); - list.add("Element 2"); - String data=Utils.listToString(list); - assertNotEquals("Element 1,null,Element 2",data); - } - - @Test - public void validFile_fileToBase64_expectedTrue() { - URL imageURL = UtilsTest.class.getClassLoader().getResource("sample1.jpg"); - File file=new File(imageURL.getPath()); - String base64 = Utils.fileToBase64(file); - assertNotNull(base64); - } - - @Test(expected = Exception.class) - public void noFile_fileToBase64_expectedTrue() { - File file=mock(File.class); - String base64 = Utils.fileToBase64(file); - assertNull(base64); - } - - @Test - public void validFile_fileToBytes_expectedTrue() { - URL imageURL = UtilsTest.class.getClassLoader().getResource("sample1.jpg"); - File file=new File(imageURL.getPath()); - byte[] bytes = Utils.fileToBytes(file); - assertNotNull(bytes); - } - - @Test(expected = Exception.class) - public void noFile_fileToBytes_expectedTrue() { - File file=mock(File.class); - byte[] bytes = Utils.fileToBytes(file); - assertNull(bytes); - } - - @Test - public void test_getSystemConfig_expectedSuccess() throws IOException { - Configuration config=Utils.getSystemConfig(UtilsTest.class); - assertNotNull(config); - } -} \ No newline at end of file diff --git a/imagekit-sdk/src/test/resources/config.properties b/imagekit-sdk/src/test/resources/config.properties deleted file mode 100644 index a7cbc4ae..00000000 --- a/imagekit-sdk/src/test/resources/config.properties +++ /dev/null @@ -1,6 +0,0 @@ -# Copy this sample file add rename it to "config.properties" -# Put essential values of keys [UrlEndpoint, PrivateKey, PublicKey] - -UrlEndpoint=https://ik.imagekit.io/imagekit_id -PrivateKey=private_key_test -PublicKey=public_key_test \ No newline at end of file diff --git a/imagekit-sdk/src/test/resources/sample1.jpg b/imagekit-sdk/src/test/resources/sample1.jpg deleted file mode 100644 index 3a52a95dfd4f26a12b8f23ee91ff2fa7425f6859..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 51085 zcmeFZbwHHc_cuCpgTT-!-7qk8NOulhA`AlzFyv4o2uhB0Nhs0{0@9!&9int2jewE{ zA}Dvje|0O%M1ML#|mqE~q!IzJT+2VnnE z_aj=079iNy2>@_k`<*H|dOE;Z4P88up1v-gUaTs{;;cL%Q6Z5)Q4x@c2nZz3YW+JW zgbJ%uen?LzCs|emtAmfd2h_!umzC8V?&0Ve;0r*@ zOUj5y%YZy>GFD?LpJj~yAVhH46{guCx1ORX`u>R;P?%(}^ z;q;e3Fg*V54@`_db@*fcshjN6ANn-WDcZAutMp>_Vh=!kEo4lY|#N7&p*X;$U0_ zw857F3xI)%jf0DaPe4e7o<#p-VgN9)elxEDFt9POFtIUl@Nn^Qu!zObOmZyj>l7dy zB_n%EHt%pzTwrp3oiaNI737tJ7})3DmV3-l@$mW={T586{19(_3F9HO!p@q92wv_s_gP zAqQY$qOHZgvI!3tNBqi!>mUkjv<2R5lsKZ{$-qksUO~nV#W);ReeR{G7*j!g!AG39 zmj>W*iFb{ojVPpXR5O)8!q)yY;eX!(?!Qd9m%cB;mFLzo2*x4b3dT?t@9k&<1X)$IM>6*LwFs#_f~P|RgI<2g zd84G{J5XAc$FI)Gp=yPy*c2y{>7$OuQQk$=sZA=;qP5j7r0lO)n{Fjk5fNpz>4~h{`|F{MWzz56v5xg8 z_D+B%9BHE#QIa(3xZ55_{=2xRO6~}uZ^_CUmEa8aS8;`aMr6O`n z4b<#TL7|bb!X8pB?y(_xT}P+NK!`^bZu}jSk0;XopMt5Z)+sPqLHc?Dfu*FZT-OcU z<0&(V(|2j_cfobw`tbsyhI*hbEteGRGy-EXR-VTCnEB>w+_^iVs&$V!N*{NENeC#6 z+p6mc9&_-_uqvH$3{xaMn~({ZvgvOSp>wXl9}T=?dJ{X>Xgl;3BVNGaC#5v@ry(AT z9J0NZZA~Oa0TdV7w^n1tBpXXrS!@<7zv6m5Wu}(uRwRBzKs|0p{}tC#hmCU5_0y$=o3@& zgLBUd#GjAxA{^@9D{(j9V|RsDwa0_i;u;YrBzX9whZ^#ui<2uo+7y_#n z0p%oqhlbbXc9=$;Vr{xyNEq6SK||?pu_dtK_+o0VZ(F2jS<4?P41-hd7-q{!nbp4Q zn-j`pW<+;-X=e)JNz!s}d;)N!;1U#?+4`|^dyp9G6=`$EW9-2(ttR)-_XI)*D~66Z z7Zdr`Ht%)$#b@>>&rRq^+ynL>=PYhhn9dNYP4?|@bC&eA-(n0%iQpCFU?S4O+enO@ zT#8pJdWK|T0-Y3uJm8r0cO2n!cQx~=PK9N$3x<0)oTEt z1IE+f>hm8j-;_Onv-TiQ8sZkEZ1nC!yduOa88()e=-gfOtugAwJ4)ro;_ z`?7BE&7MHkEkDM%;1T_PlB(E>aV=`H4FvN{^QRA%@q?016RBQ_;}Xmmf?@u+V&BW7 zp!Q464>FP&A>(p#$}tbge^8%5DkqDqruEY4IP?z;Z1*O1f}fvJ$%Q_7Nzs2>BXn&` zyc_NtU81t^^7~Wg=WbG239AwtaTpTj>sy?(F$pIZfV@T-1oil^Ui|0o#aa7US*0Jm z@yiDO%O3@~@NcoFKgpWp@5KqjTc((1qM!RN)Y^UWQuJl1!wsEby3DGe8^u*0+ci%T z->?k&0K#|hoFLq+KFNwnyK83e@uarL=9t23{I^H_mGb0tvR;iAw13uEs9D7UMqf-h zzqj>}%IoniE>|jbrwGz0Pw?X4e=5(GYE+eSXX=r)p4kKGgaH=k)@7O#y{5Jkn#X{#!apK1(vuccJil4|t38#IcQ{Or?Ow zR`RS%`CKr6>r_S-JeK~n*gZK`)-~b#hq{ECzGzUlVKB3#pynnZuWIV(Ha7f<%^8(Q7^mwbQKfVgfLhgJzQFW2dFHX$(<5%xt z>!yDAc`+m2(>(<2MmhW7g1>F1RL#Jd^gwayZfgyRc+B@;|90QIpXNg|&Z|%?PLB26 zzV|KEm#U(uK`&n{e^b?!Y>AKFmKq*oBE8l5+*GFZ@7F}Jm>P!33*FYe*qL??-vpA%ud_tx``&WLN> z?7dPT$7JnWVZr&#rmvz_HOfMhDGA#v1w~Z@xp7}8tAE5`-7chjinP=1`Bp-bV4SIC zRlg;pu~>2e2rZU%OEOqYmod%IvzTw+ zf38lQ!kXIds}u72C*;2O;bH&weJjnWE}J!Or1a1C+;K=XQ(RtOMlaTTFu{&CmIKM{ z;P44e`bu5Skwq|8TV>o*!}mhSwn+7Qo1*=Me;9WLtKG%ScU zzB|-WI8@OTKcQMj=I<FdI{!VD0|sw)l^5l)4|eA z!n2Oc zk5O5I8)Q_}B4A!CO?o%^QGwBMo;m9puUi`aLv=sI3Ui7A(`Nf8PDpRXC=GJW?8^k^ z`3W37B=-EA@I*bY(y#sig{v!n7D!@Fgd`tgDVcB~-2{@3VAx37vfrzm&}a9l60fUz z(Mgi%a&P;5`2)g=ZrY@;lilD;Jhicf#n(B76(#Q2$2U-_ABXWD->EbhH`BrQ)xl2E z%zH~u6>J|+OQON2kjzn+ow2(uDnNKNh6+bV|QklO?qn7u`nZ@}5l@a(HteZKLdu_|U0OG^%nLCsma(sw2wGTJnFUyCMjzmkSk zxl}K!#-vj>G`1UHg(ZGC0H{|;h;}Loh6QT!nYM6*#hI7E>5-cXAKnZ`G+`zlS9A3sG*>yK2AKA|Kex+VZBi zW!Pq^xXn9XKEHcD@+ReeRmQcO#8Q+6b2(T{79L+^Arosiq|J+~3f1u!9Z$s8d5yVS zcs$5%j(8`W`#-aNg9TUM=a(&Zd?{iVEiTI!ItE3O_-ah}W?LOhh$9mzzP1s#1)Y{H zZ|{FSr(h*l^Ow%l9OCXueDL^-Z!u~|aKO3LuSU4BE!49<|Km@MR=8ahzqbGd!C0AJ zL*wRp@@M77IFGumS~m5F+-=h!oGo?L6!GMjAMakwUF^{c{RMi635futl(qD*FQF0u zfQ%8t3V_AHslkYbR4`Y1e(^Z3c-KDVoObQy6ea|K7gypg(zCDX$z1V*(eX9(a|tW} z07PCsa1W$`AJWSYi7sBLR&n<+hI#lQF8P=F%M_xata6!Zc_3lGd6)T18d~N`R?kb> z-NDn-{ZjKUy)Ykrdj!lx&B6ptx+GuOA&brcFz%tFzwDs+n;iyTNVunm?;m`CiWk!3 zQtf3ebXyKSe-(UB{BP*+;r=NqO=gMXADroq4{0B|h{XgZDeH=|pJ&@|`5cf-u z{~46s9a;Z7I>grI7uPB0lQLc1;Lze*nuisYxvi+|ZYx|P@SNZR`|0}#J zU*KQr{ypO{713)J{rurK=F8l##djr3e_6zGMn}K;b6Esjj?C5Q&;c9(_Gl2*4d4v$ z0eAxZ03HBGfFM8=APEoyNCQCVM*_f#rmzB3(0ngI&}H>2CI5{6M*CCyKP3Jp@F)GR zMGNrobH7}cmzXZDgQuT|qwjxNGf*T5&AZxFOwhQkyQjxxr>=r7%nAATvNF;W@vD5* zNdUyz4cIoP9j~y#7JL_4I)| z!#)03EyQZZm)Z@kXlNZI_GqM71Lgtqu}8uj(FA}=kk{{hkMNi9CFPQ%g>Ys?C;w0P zAIs0j{cjs7y2VT9|C6HU>-_i47HyQhJJQ77`5#iGP#C%%ED)*Xt7)RA`+M`i|4sgf zFoBDw&ut}lxbtsMk^Snt=5I3E4m?MglfB>7W=7x-^FjVM;%2|e{}d;3a8~hj_w@Oj zbIE_{SJwEGfvy73_w=~*H38Do3;k2&3;X-TA#_Jir2n82J9r||6Y4+cMCc)Q`LE(v zYmVo#ApkM@!Mt&JmH+i?MShjX__bGI1FuS#6B^^H)}=h)8rfwT{p9_6FjjsoR5XxJ ziw5TZ1@8X^?*9eu{{`;<1@8X^?*9eu{{`;<1@8X^?*9eu{{`;<1@8X^?*9eu|Gx;_ z|3VI~qtO5Wz!d$U(E~JK4^TqGbe?GN4hCQa7y?|-c_jMry~?3MNdV>lMB)<8GY0&E zHm}f!U+5qn0Pj~D7po+9U64pG8DU`$Um^R;Lz6;KPlRxwy_YaZNJJPQcO%ft9_j`| zvO2)f=$Aa(LHkQKR=A@)o4L52h@O`U%muD_+XrTRTi*nF+YKu1$aX`4RW48_5aES@ zA?;ZM5$+zoGJ*1JSITA3`Af1e8|#$_(oLT2>PRB1g`Od+il+~ZRa{6!5Go=e!YTn0 z0*Qgez@h?w9nBOG1WCz=NXUT2SpNuY=+=B3on#=Y>VLF_F3Gd~(W!ud0HFXeAx|G? zVUV=6w6KV%u&AgYT0+n_$OCB~DCptK{#%18%opkdzxtBEdZ`hOlKUa$+0d5$>H@;+ zPqqK8uYL69_z0Hbsqwq62!F_9qlNHruyOvz`7QB3NiQz%WMK$k2w-8LFERaf zCyNVxC#wK$CN3uWUeTWc4<8o?n*fUteK!q#Ckud!g>L^(CYptXhl!6t03al~hCVEW ziG#kQg^P=WgMo$XiGj|O!`-4SC1fKG#n1J zDqzlggmgZ}T+kF%@dA^2dS8jIac(t9^|j;ssfEuRO?kQ}c%{}qX=s|k_@rgDw9PFn zt(=g45s}XR0WML|Y3W794UIj$lT#a;pTA^0EGcbj?(3hP*?Rx=1nwFbbUP*%m6?@Y zR$kH4+BPsaG&?uHy|er6^gB5KeTfY1MqDgxEL=Q13^>|kasc*q910Mw(xH((-sMd) z^fj_q_@ZOLRrVugDhL6!n8Uaa$GxtUR23TE`vvt-PO$OXGjT3e^ldUzZo-HLS~_|j zUOov)DQOvX4NWa=vrB7XPR=fHSEQeR0NR|$sA#lBY3Ugc(N+}}6_=EvO>1mwMqAh2 z)7#gNHgRHdYI+83=laIx)_b(E$Dclb`Fesj`JdOmN_Pb$nkl)5l!uTwN+)>TsoPrO z5s4i*3gh;vm*-92WNq z7%Ge68~l9k>WE1mf0ruk9>~}=?UZ3iU?^C!Ff>~`#ZiCu#kz!c6We>uG;L2$K$hNK zL;~tb>bkZVu0?l;DJ^ZtLba@#V@Uo}OGi}K%A!w%B;cnS*TAOqMPG?RcPxii_Of3shnMTFBguH7;?>209K7Kn+ztzFZl<7_2@&S;r zN$XDI_Po2d;aFe_TwQZZu5P zmr8BzVe&nsqgIcH2$*}D$=Ekt@+7Dld~k<9$xMsNG?w41O1@({+t7yAj6QSMqN_J& zS;F`5{XMv{Efup0TN{;N(|n!G&PcdH^kA18gBrL%gj4oOPim+;m!8~%d&yMvWm87# z)133b+pBz^lpgWhR(J|v}6$^>RlOa9~lm9G@LVbvHwJC6PRr= zd@r|F`;NMmrGznfmGp3kbOB=|LQm=@_$b@~Glw?QjBBt^Z**6B8)cEomVO!yQk)nR zVnpDZd{Xs4bCu2U9TIm+(nKlU1$o{$eUc&f;oxO-@Xe)DE2DSx7o$%_Z2L zkPhj(Ch~X;-?+}mUW>k)LsIJGQ4l36Vox_&?OjQ`7mvizdm$n3o_1f@UC3t(WR{sG zES^2ZF2oiQ(p~$K{9TcnP`wX{d7LOMP`y|!F=J-N5X>IAqDBi9yBS%MTUHLqOX5&E zTO6+i#xLR!7_C^`Gwue1-*ON)3lw~9ZjK)i*SJ=OZLH3&XUXWQOIp|ZGSlS8q6hCo z)QY|49rg4L%WOl*JnV{c!OUD%`W1326TBW~96*R|40Z{%r&hVOA#~ufwL?Zo zb2wx~BD7xN&cP%;k)v4%tiq0ib3Ie#C~M5vnm_u%*6<+AZHn}b(()|<(}%U|s`PiN zOkACaM3#LU7Atbs7lwMJ7BUgVjK{38`kVBWp%(xRd4qflb0Yz-p71pa6%m1r52cKX zxR0me6}!Oyc0i!caY6Qe|7c zP>jFr%fbZC7ugm}Vg}D9vPRNFI~fwA+TeWy#UmZJ;d)WG(vFRz93@ASJA{RksmN07lSggXk;(azm8Xi0Gq<^8>DST^@CZ*fHy_&olWh&9KsNQtQ=9IJb zaE{+R2ea)IgHwA>wk%v5s0RB~aQeL6E@ZE%Yw7u;=?;g-lbLgN7h~+FfsN|dwF_>s z#>KCl%*+O*AoglP7d7)k%3W4OO=G$cQ$$2evLAX4*^)nixj&!O(7rJ#tm@vufI-{X zJY>mS)~gqRMpS!YRwZ#wreA_k#`dEsvG?B}9B-zF9Qbw;9r*@D>=n@X)Dn*dOzyXt zz2AWr6veJ~?+8uEJ#kf6kl5>aYm-j@$?O%7X5|wxq)3An)Gjhlnn7JBmuDNaNsFR7 z{%U*dE#qx*XJFXFk~Z)hF~WNbrA^7jv;Vn}RSC7`HU7K;&ff6penrZ>g>}rL4=A77 z(v``J!#)406fzpKtmFyVDgK?j>djMlLv`;#>9d%eHkq=opSX3e;g~%!6h&IzrRssN zrM^aGr~n=2lS5f*_w$XMyxo?{V)M9a;;FSPX2q6+=s)xVRuxAh9_fMUoVuN@ViF(b zJ=^)%ERhUO_5?EWz9jG8%%HYD>u;rAuWpWKZ)xX%>X~qI@p~ap8o%ZW;-XA8#w+;R z8WNq3uQM-~rib73{(`+%^||Lw$lJiiL5a`KgkLbPT=XXgFwAt|fbu1%2 zSJ4K9(~JSxYX4cCZcdV`tXgZwu#HfKvW)b}sBApUTwZ zVdf7umXrRQihU2Szp`Ymi_oHdvPgeTKKG5MJ~+Qwb;7YeXe>fYTa*FUV@7TflDEQ@ zt*g&XbX`b2|J8nwMPC}Y1zegJFVU*7(_$?`pL<>lZY1g}nVO7=(HzMFEXs+mYjd0O z!~J@FIrRi!W_!g=sXrLMKGTNWgZDtw)5$T%&y=henH1y@!EhgAU`#Isyx5$ALW%WB z_@-8&jvqcMT7Rtb#MdEgF8h0~%XnES(DTu3mm;GG{f>tVWcp3Fasp+puNgta1%NN{ znqR4bkBFyN{0jc&8_WhP146CL-3sU1v2^nVPQpAgCz9)qTG?VS_^3>|R?~-BX>{z8`)M5kSYGIS# zj)EEidN?*6MjVF)AL2%p)E*E9Ch@EPv`dpyyfM}zqX^#iHwG8{)U2ybktG9TA*W~P zm)HBpXVaNBIB=OXkUlX?)kK(qTd(P*jjv|2DytZBvf}(!dn$z@`ZDiF&%yx ztsB>GXj18A=KB`cK;^;)hrAwZIr=WG^T4Yvl7GmzpsQ#M)pz?#gacU2fJ70#8COP> zk2&wn=k5?8DceKn6zde&Ln_ZPuGYBAC)pI;bih&?rQ4;ZVcFOpA`iCp&X%qnw0<48 zG#Sa=+;e0c%7@pHGTV3mky+y_CBzU;V$YE^0>#x5xL1U1B({z9M50}}R}$kPRFW3R zP%ht1ejen|uBIK2upu|zb|O_w-NW!WM`)pL_6`^oVnMa9IdTwl|#IWr!6Jd z-sWY`O?}z1Hly%P!n>HqhS1JFNQiKrMho7pd3c)CinT``e7|4znKs1{N_{xVyMtOX zyA7pnWoExIsVhJI5)nA3OMf%EFWWoY<-H4BC!7r@F{Fmzd582)ws&K)m^yPM$BLAh z6-5eXSw;pgoDb5|QGLL$u(S1H`hbpg)PxQHkUl0(b?L4qW)fifyd3PZkl8Em@k)5} z;0Ni*(#zoVVoJMHCxi6&pVCd!0taktoR*a#GGOPz0LEJA59^B& zVoHVZ@G(mxXh&TU3yJwm;4GmXS@_}_g~VpklC@s*(dIpeip_oCdzFM??GlEci7hY3 zhE5!uQY%5>R8iVn*#@Baw_)4~97fQmyM2X?noEuD1T&tDB$S#X$WKkfR9xQ~zWIFD zlI5GQDIXZMT6sYIvN_?zFRyOGc9?dOArWULecbhxQ%e-N^@(*0-s&(X_ISp=p1t_E zo!3c~pNB;gua5`+BQa`7=$rMBM>GC#sQy4Hu*xNimaMM0ug$xbD@|g%O>!wq(7%81Q%9FNsgq(pFDv4XKPGug%^*u|0Jx41!o&mfkzxw6# z7^ev=fZBGT`}ye_pm?v9E2kty7fM-NV$o^kcar&`RIcd@p{Qf8!ZfV8@Luk7D6TYm zeRjtzDrMUuyeEunhr%gOMO*pV0a$_7@#F7~qXnAHMCQCIva@tnYhPCzM*rlOX#L)b z%x!D2$oDKio#2_-7!-NUTp}~ywqshpZgimb%zE($^(GbA=^?}rK#SrvnT-8J20kIS z^gHCfX$a}O4wT)vof@}x&EAw!te-wnh(^*7F!55z%{45G0ls`=(;`KNK2n7|Jsad( zjy=m9OxP~`p@{p~WMO0R^vQ;-+lhCDd0F40+r=bcefaY=hbex13e_6_{f}5g365WU z(>($?_KKE`L{NOVD9w-cNi`@G&fBTJM`|<;$LUQ4o3DNBQkTGbbIO@D5OiRgQ=Si*-<$FVKG-jHZi^(HQ{;jFOrr93$K#G#{aKGl2HItRVnn!RfHTjQrcc*cJ# za!rop7M_Rz%|4TSj!=@T*Dh(OjN>226~G-KV=h`+!Ctp?;J|DPM!Yp8_oI5FTx4;- z{rTyx*}|uIjTAGUdkc|O1`@nmHdUC^OZ(N6yE9vn{P1_UMSVqfdNUk+pKiN!O|9ta zITH>Lu)V`PcQ2&}sf1IG7AD$h)u7}^M zVItjfF;U0wzL`!E9itYsX~negcjTTw``DsLN7DXbZ%svg#jyGzwT>Id1XY9@!)r^DEk8&hUM*voZ_-hLX8sZ1grbBd~_sTB$8A!*~Q@# z+)W_LwEyj#ULQ3_%atQ zi*&JJB!G7PW+#c%_#(#_2uBI8Wd=Vv)Mew0t%vAa!01_Ed0iycV*7-$YMrsUVm#ff zN7;aICDvNtu_{U+=oTX%)g7n%!%Ag%=FflZkDQCC_pQh%5L#Jh21HHbMm0+;A#5FrC z1dgj_PdlxQf%VI$c1s>t2;ZUDM;}rAeYEjlIcAZo{qFWEE+{?2_Nw6AMvzF>2SOwzI<~ciRNJ89bot{nzk; zkh6v}J;DfcY8qzwQ~P*s?^VneJuDhww*}K%vhaRowg<~z^j+obHqUHQ3!bzmN`Q)p zEKn(FBTJu+mJ=artyqLfxsas1uirjRDYn*7R4mK~JqOPrO%TNvRBjYP8j`pj%;c7m zHm;tbUnRF1=-bRlf|@X!rhokC_=<*LYTfD$8J3rrPAhC8dnRY$*=}H{9g%NmuOO@o zRBF;aHy8hWeSf)c@kO$Rt^zJ_UGH9YDJosa%DAEKt9Lp(J;)`iRHowr*lUmz9PKAf z!r7sA>KFs`T7bfo-NkX_+SB&ch-ts&N;Zstj^`~RksZ`Aeu8hqEgTe&4D+K-dnbODaUJl1HoO_ z7J$;^Tj9Jj{JeqY5WQ;{6eKkYTI1Z}{ybw3XRyZl?2B|9QZ;_8&-SHa7@Yf&17sMy z{E~rf##(pCYLk#{eqt8U}xxPgp4F}qv0H0j?Px6t3QDDonk z;}HiOmvf-BpEadt>b}*%a&ILD1n15lS?N)}@Xj|EnkGy=-gqLWT=Ly*y&v*S^(4Vw zS&bAE#FtLle=B!Q{>227EW^>HB-pUnUMEnLwy;rukPxsA$lze2 zrGr&xSQI=`Qsk`>P!U@r0;E|>II|M^JKiR*cB& zxVrQf7XY?+cAobh*@=~?Y+9(PAHb`GrYnV)bn--Ty$y$2hEL%0Pixoq>a&gxdrcc3 zKH3OrD57l}k6$Zorv{;0(fm&9+rmTK9R9MDdrfuU_eSnh?J4I4MTdlq25hF47wgV& zlPa>S%qF)x<@j>8_-vavxEznY^#PW_?f$skzH|wI)WjaPXsZ!@Fp4Nlc44mXA=q`|9(!T)<`jWUPWN(;Sv;Qa|ro|WH5Dd99QtKZVfS5WF!^@7r?PPr*Npkgm+AAtd;B?k$ZW^_yyW3BoP)XQqa!rjESos~fp|Dw zH+u18ayQ%JXrLhHVJD@wjZAv&_eA8pTxZz(OjQ$AwDU2fxp7VTWH|pasbyY7ZqhAzaB) zW%(7lH#T?H6J1N&?bpO-60v(ZtOm02k7kx3hfy4us*xQUK=%Uc=+~ph55n4C*$R73 zFM5l(L~VAGu)j;Tp=qoRU1~YB1gfr;z%wEJjIVN*mh+9!Q`Zoz`zg;}KPo~t+};84 z#TU++EqrsRTTgSckzvx>&93QDP}9}})R3umEFbwOgJojVVh}sM>*jY@F5tBz5p?m4 zj0umnps@`{%v7<$QRbRjr@}jFwVE35lITP=J^`(nhbUc}G6?&u<LRfFd#szW`}czoMOGQ`}%1fCh49< zzN$vWm6;RcxY?!x9!<5+TP+Gz8C`8sVrFiQy~6zY&Mdwzh&k+SBXDkyC;)f|*_4V8QsfskN#eZ#b9n0q#0YAH?8- zY{P3Roe$D=O3PQ}%B`~k<|e+54f77!Sg?zFRCq5^&bXCb{^MGS$wAlOh2AHJqi6^GLxUnO0qE?7msd7O0T$*Jil z|I>%#GheM2MkYSZ*jnRIH7ny>siu<%uF<_h2IS8>w}**!R4 z;Ugc5NQEN!)JlurIk-i&6`aXGKlREguudODxg=zc#I~5paxv_&G%zgWC>GVUI7Faq zl%Epns7DZC2Ja$PPrMbiw6gjA)VXp+WU@bck|&P%2afkCwe2eXObFuV>q42;fZ;wr zZ}zekLT{mIT~}l<<c6o1dX-9*fCZ#O6eg zJ!R{jG36vCGVyky7>&>Xd#3HU*(d|)$^-w+WTmrGP>GdAHqy3oah446ZPyq*QO7L# zk2ej{p4HEpge}~W+BH%mqwARtw6_*+KOhl8ct{PgrohD>gh%>;*|bc}>q9F2zqiyi zbQUx(Wv_gG9Wf{W?nGjJ!XPWrF5d>q7xjn#xp&)Mxs))#14-C3T9t^+EMZ)|#w#2Bnyc6JK4lr=jaq+mTyi|^eeH}qtzuEuwr7?s z{X5^K*Y%4g+F*8B_uoQvY7vo|t<90GJEili5XtYA+^_GZALQmK)?oa6BI(~cCGk3PU_(<*MvCgb8sI6URvDMwghk}cW~T>QRE ztx@5k?9@ehGzSjvEUtEP@DkFU3wf^hTViJm1gXaHxb}F>{!}V)xi6Yn58j(Sf=onG zF17&rBJS#)auF{)f_87ko6&~%@Ugu-%XUSacrQ3Y<0;F#seD=j^lKZ2OI*gTgH)Y0 zn`)LSgg+iN)3v-Nyh#8QYFrB2%<@wwF;58W7I`G8urAV5QP(tI6z?vPfj9TrYmx9l zO^*PI*jLX~^7vG)6z5fkb}$RpNV00P&@~ba)3gyoKRx5+x=G4V3jmL}|B0UdFwjs3 zh3|~z#>=x5#@@_g5}#%=k@v_&r6#|`N-OgDR9(BjOrZDI4>Q`Ddf3NC6tC+RKYLT{O35UK_P9(I5)-^_=I#cV{P6UTD27vE_#NRrt{;c1X8U;EH4Tx{Ww9F{W z+9lxjKs5x~BejdnpnqPLu0)Z#|g?DSP)jboTQFsGMptD1{(khR$ASH4? zJn@v17)vs&BGvR_?zz9P9tthYdm4Mo*+C7)~ z$<&zQ5P4OIx~3aeCDw9$S}%)4y=GtfH!4-1-shRXMc%2f#-}4jsT?>^gKz3&<_YWk zk>h6*f?FBNA(Kk$cb}%q@&=on#;<>u-Z475(wG4V;X*4d*ma7 zuj@urc6cyJ;QScaVZIQdQBrVf88QD%B1Y-p`*IvGS;x?iE90}^Mi0lMg}@)Qb@kzU zTjLxP0|taXJ>Ee)ywL2Jq^*6*?iWp)L#p-$oEG+aEF%>!>`oJhn}+um&So0VytBF< zq2EBppYpk64#gC0ONuS4yv~lPag?iqTWaaPF;ezt=|FCkwXF^m>r+LHnDVJ#i{HR$ z_Bd}-9aCwh;PDs^47rK>M8rX~FQYYy!6t;!DiOcHd6Avo$YBmu5J;s+&_Yy(O?r+L zrsuh{OR4g<)aERD!~MO%19Nr>7Gp{yGtGicqkixHS&M8wzky29{vVpKAps%HZEs!> zPO|*K&O?`5YEydOcAAvXn|{H1;5(h$xI;CsCmwqf>wp|+N0jEj)Pu7b;-9C5sGyv} zX#xNhPARid(&Co!T1_twSu_NwRB31!9O?!ki4>39h2+=2EF^4av$eHho7{Fy)q!w+ zT#1sn0FY4?7pmHx;==cvMH+2%bPJucJ+C+Zcqd)LTl!So+(?yN;qCm9oL`%eaf%yl z5pL;g!T=(o#JPUn;u=sf6BE4-*eJbLQc~faYf|}=_I>@vOn2p6H9ib1LLv>Tf8`1&&`}@=jZZ^3l zMk57>sN3B;8>J5hlB+%(@CQ8qwvguQo(f^><%3iEl}<55x5?o%7NEZ~-{*4C+$llW zFaXQ4>$%fRRSjj_8d4Y1z1u)8nc0DFPg8WwEIx#j7w~oKM_4u-ZBpX{q0T1|9l}26 zAi4Oe0EQ>GnBR%1e|Ir{<-bOSOxvW(^|yc?_q*lzS~)$^iOsD5n=WC#e)~{g!YI@# z1!N=u%8}OJ{Cbowh(`);ZV7JZ=Q$j`o?tjJp~~BpA%bXpG5z=yW*=!I1mVRxpFN)$ z`gp_B8G-nLK4RgJi(VBItPLV$QgtC1+_pif;;$vA`XZ{xNIp5C07^k0feS6%&5Z6^ z=(k^&Wk=?0$Xj}GU2_=Z^>E3=BG1}_lj<1NM5meiU9tx_R6uuus2z%ceMJ9c5(%r% z8o8DXaZ4j~bMd1Dmu$k!Od5hxb^ocU^a{9c+(bK(t0%rAhe^=Gwy3MDacT!FzdG3f z8RJfOCRTJ~J{Qph8X@;Zc<(cInjNsY;J08d)-I?vE0SySiol@(>_+eUAFeCqr%5viE5`zH$6Do8j39<^l~pI z0T-2-b0mMQ!GFoZCILa*id{EIGpxI1tAsoMX+iC}-?6UogmK$k;feM&v;JIdhtyQe zzzGBbruE6_5iYdcLsm1lg@dl>Ca)S_A%*1fvZRb13c?k;jHE3>C?(TI+sXpSfSkq1 zaTp_Swt6l0&U!Cf;JCu!B%*V6HvFvfEC@1N%3xV$O0=~L3~m#aOM=ov=GST!YqDkb zzI{>y`nhkQ9>FlhAwu|*-p|xEO+h00&e^DP@}1VLfqT%pfs1v1(D~D~(2d^>UDYvFgtl*3JCD53XUZBOlr#GuU?aug6ThiI^PA zw%6|QFrRa?p6hbjV>~GOm_O0ljysSqYm&)iYA#(#6I;oV!r4BF2geL%=)TDyl{u$W z(!&8^*sMH%nS1>9A>snyY>oaO@_ARm)${ExCfTK2dl7FU+?<*d$6jaE*xHo!;avtHehr3YP3{^01+5Y?GVn)(^+W zd-d-wF)ZCuNRWvbEFkLd0H+jYV6bzb{3MnR*AlkJXzt)R^=yU1J5^eW=hx>xu654E zH<38`S8T7s#gfeKie>ThCbX*70;J%&c|8 zo!S73AZVS$f+zXM&4LH%9!|yPtA0peH8|~H^Rek$A>PUiV8jTX`1SWyfX5Ffmz$Zj zz4~Gvwc?mkw6S_>tQ%#~E-r6x78!S<`gX5b4*ITp1S%CWz;dZ#@)yOQzZm)U z*jkVAS$z&yMBy{Ly)(HWlL`|0`c+iAeuk-X@Y2K8zVz`q1p1@@!tBz0r6N&!I|k^^9Hg!Gd&1og;^x z$9PWw^BYbcu+Pv|ng!U<#DFe|sPs9sdT(_Ehyp30#3yOhTn4_qPWzmE3Qq1d3$J3r zV5KPiuu1JzI*W5FiI*YF1UxQM=Ad1cEa~ETm()lVGQF-Z>taliK z)axv=k*QVNWE?^~iU>C}UJtClGdoARroRXNW|v#YNr6MW%pHA~|EJO>QP9f+wTv^_ z{|$dYfWO-I?axg&saj^g|J5cH^ums-Y+8o*(lO!8n<6Wf&b&#Aal<2$N~n8_STe1N z*8c#PHkw6nK%u_`#k{x@6FDAP)lZ2US$MDI(m5A9Y(CG&*~KlKXpZef;Yy4uhJEfB?9`hb zZDYlNnW8&_VudOhs-S9iOOc@ahP-$RD|JK)$&6IXJBc06-4FwBXC7~D2d`D(q~q=+ z6*gw>Z}H-=aiH_6t}`spWiPlUoKdVCD6#cU6sgKjPf3bX%T~9ijGK#ld9n>6VZfDR zL#;+)!_thbGXl~Lk%aK)n-pT@+5&3^RY>b+c}>0B?I*w7c;TeB%Sw$ZGZ3eb1FTuB zM$*8Z;P`T_f>la01t+*8jTQQaVIgg{ApNfVGSd|tIRaIt15(qMF%RN!+_n z$C`>zg-EOtE!O7xn;Y}Oj4f5-ip3xvTD7mPr(X_NPBe7RBA`fj5%kz`mF=bMsD_?gYLe#(y;!1ZJh z7EiKoVeI<(MJEb2VG~OFd}5)fL}FrA+X~;qjGeS>%aCY2uBaxpj-?vP6?wWcLZnp6 zNh6#DV06&z=E#a)YOHDP4J;#LcW%eOC@B4v0Zv#QT18y0%mPMz&<7bRnlMa6(T1kY z*p)^BE*J*bDpW@-$O&SDP(7S%pc-+92qX+9nQ3FHF_|Kh%Vv?_8dvnz06V+e;)+IGnt35)n1O_B3iyK>+HY=4crg5cq3<5Mx2;2cvZsz>o8Z5dd zDPILN#leUXVjF9A9}#aJDHB9*s)Vcy1(y(HXImCxBuy>wBVIa;O%^@?z*35{r?{)g zUWPWDumj3KNgQ-Gbx}3m0Mx1+sfpol7tc}23Vz{{2n3A|r;nktG)n5mnVMSCVInA3 zV(nrq!0X~TsF*ZN{KYFUh-{`QF34_FpKsU4;)))cY{lt3w~#3J7=op|IPz$U`T&Yd z6*5dz1GH&yIH_APpyQ@ZJ9!FWbzl|LZc;uRvt$!Q*DAo)7*=ED`C|4uYi=vkMarc` zH=XWpU7@eK{jbddR8quJlL^J7!)5aj*@-v$IdCb4?ut$oD==nhtEtU9HPS#g0r2J9 zO?v9>ML5u7A~nvJxxMxF@lpwz4=S-dpbet>>NxraG>OGXifxd#=G}3+7A}b_wxQ;~NVutSq64xYtD`d-lGZ^(<{f7^MY13h`34L6*-lnIm4;178kQU~!}CP$L`<4!R3DGCnp#XuQJX1OMLJWH4M^Q<8;dRPuDsH)qm-Nhp>GApRvK@WeM{K| z#tIPAR~QjXkfH@msH$Y6iWngP$an7tOMM(+V;WM* ztAf*1RMYNLy;+L|BT_j^UWFbsn*Lud?;~m3=K0$#;d@(~rO+b3|JNn>b{Hz3Y+#mC zwlYU@d6S8*Q$C{psyhnPN&K15L+ z%$z7e%hl9zOd)m`8eIE67US(i(POKF6=S}g@;weMM%eXLBGriP92D{ZK|S{y@pJ^q zq$p)hs{tm2zQ6SI3ZEob)h#p-;&@^VN(o>1{^=m$L>msK`IbmF zjfrD(YmQndA#)LhPnHPjY8)x|7hQB0J^=FQG(hk(O%+t8rJYD-u-uGw9@}wL(GA$t zO+}}{nE-T9K?R#|@Emm}aH0oT(~V%Qq(dSqjirX$k8dAo5kc#W4RWNy?1YdQsXBP^ zOyNk?PiB#pINAQ!hMqj$6p8bURQgOH)Uz~~D1!GN!{Ej;&xY%s&0~me%B#*M9*QE03W z2p|*Ic6=&57A-?99cCppQqxgk?D1kXm5d@t3?zcgUch$aWyF9_Nk_IEdD zCQjYYZw@Ejy#4FDwWVhWp$BPQpIGGCLvCB7>emV+$^F!S8)HtgZYN8V*mmIIY9wr^ zb-pyV!WZ00z6h3J;{K96H z133mCeC|E~-<0oYp=z2{;M2^~i50ggYkR%^ADn;slm+CMazgzsqs~5CYwMsNt{ezASD6cZT z3&5Hv7)~9JMv_$j056rH(UxUa+s{y0-BDSU>Z>FRF#9(x;ci_5ikwk1OByUc{Tv52 zb6`HcD>PMbh^|$%encdo+9L%CKOSsjMArfZA}SEcG;MKZBp<5WRR$<0bf8sIX`}rv zg7M#Qw~6EQfoh6&s+KL#kk>uUxn$xgGS&&DCK*v2G}5tf#jY$n^59d#;UH69CW}(h zn;&iX<7tX2y>n8jH#H3MDX`c<(_3l9ExQy{RVI`5RLrmCN}~O)c(E#)POMc?C89q1 z5&~G1<*VJ%q@_hOt1v~j-xKWRpi>G=(?vx!>_F6a9N4cVFe$mB8>~gWzemTFB58YZ z0;9?f)d+i=^T0;heXwSmY7yA#FW?Qi;}m4n$fVs&Opd^dpXlbO*|i9$!bLy_YYlFF zobjcNEDR};ew zIQH$@fJqyZ?%kLX$WME0Tw?J`2g2sc=?7uk%+6)I?Y0%;wGg4}f%FksdVNn7GSW#w zi(=RwElw39#B$S^DPmFYC}`>S>Mf}{dwIOMk)&x-l1CKm^`njBxbGCCtqm!&!D3Wr zpq`$rXvxrel+IZ@4XnfS-WoCb=+UFfS-O%ST0&VthNU6^5WrkAfvDGqDc*P31UfYy z2d1O@&c-tP$Aaw%ZM6~JH#<7gPtJpU)z!>ftF;l~Q!8PaKMLC}BZSk9hZCXnB=nxD7i3$3Ymn-D1-@_upRqh6ucXjnongZ&DGHdyGDaF4 zJ_y+qub99vP&Lr$Vd1X{uhN}86h6rxUbvYm+tKGnpV045T8k!Q9Y(8_C4AdaH9iXx zs;k9K3G&=-0`_8~?%=0!ve4T_aG{hRwZ-90}F|IsgW_>2^l^2Up{Xq>N>Z>i=_Hfxh^9YY#cO+i~75XGlb zDdqQkz%;*y6q+i!NQz{opqjR|Q4s!;%G*7sUNVG9qGz^Hu3{l4=BgN*?u~us zA72!;wvdENz*U-3<-9#${#{3h#T6_Ol@#R`#Q?EZ;(}>!<@LxLD5hsFk2W1!iQ{-g zfZ^)RQ}Tdnw>Kl|<-wqh)tpTSlt>kn$iJgsv%9~uj;P`&KXNJ_G+{(&wDy8H`WHkO zSPDR4lrvRUN_YFAi2!)7YqtxngX=y{C>gqG=`dutH>1Na%dk zu@>Fh{B<;38`KFqYm!FsIE-uIe{UW}+A4Vf3XoWNs)T#T^5e9bYMr#@4H~dBF}JFfql@j-Vv65LNy3uVB*?o%Z7ZP{@5kwa`BoIr@g1*q z@a@f2N@UYBKs%jAwg=udTQktjDz09i!k9%f0d^4*tZ@%p!6D( zdpF-lvP{*N(tl=13mqxr?5fVdX2hy;)5R5QQPssX)OD15N-T90#D^`u*1Hc4Pa<{@ zvdI9!pJ5wMt!HKHjUw|}lQ;qoN>0d*s$;LtwEL)VY{^k3C73EEikk_+urLu7nXDzK zb8mLu9sV3Gdg&m9Eb3PPC|zk~2`gnV-qKV~9ZCFYnrwA2YTQR9)#a+FaXP7HsiDmD z3|vSAtS#kt+Jsu_4eiF#;!vW|N!5-tuk!10DSSAR+D0ioVs`#CqM^g6aVmNorG+e+ zhdbsWB@P(T-DUZS6pMyyY*ZSs_6|PVNLUS^6*#S(G?wc5cI8(tklPL7Pf$Mj;a0)Z zY!UJA^2gQ#i`x_#~x*I!EBMQRZ?*Az&d zu|qBuULM6x;0C`F--;Dfw|Egs>RGpuZ*`bih^i&vc0ojku}U0}ZrOa4^P`875c;El4Iy#t6OpcjIhPE6byOLt9R1tb{OR z(`d2n#jWk4=l;9p(zjrLdnALL|5#2}>2BkzoBqvEwTEpALU{FEV@aw4RB&e5g`$JK0hb)tg5xTim za|tTRa0|Are)i+^(Z;^6xn=?4JKPX_Ir5xFcgu+ z15HLDA>I4KTb??DOaqN|B{&Q307=sPy(sSSq^(S5DIHr-4z}m3O9p1588*qds49D3 zo}&wOiKaY4LRkO-R2^;f^2w`%G|N#U0NU<1u(z|7id@zNQ!Q@cxPg0XZ)oL{Mh#6P z>s$~OP@CT8>*Z;4CJa+7@i7iYn|->DHl)nO8a7B!9a}#NfM@d6Ma`7lFz@Z}%lKyl zM(uz=G(`PS;21qFddM~OSWI|anT{&&=M}VUVT!h*ofyWFAkeS_c7o>IjyJB&wA?iS z2?l!4U1g_XS<~+2w@od=u+dJCaVbgKM;PIW!i)Y;%Xm!r_bVF6#UIXMaEPhuuV49)C1h~)#ChNnj<0}lZg*YM%dgki=b`i)wo>-Nx0lQGty# zWNGLl!(uXGC_L4)il<9yrMTLogWlWh=dD1rtcfaSR#?Mk*Ie82~+vygBM1anuCkMcY5r)6_XM?hIRun|yoQiV?Dc z8JmDB!Z4)HNya~xVn_-T1c%FV4wu)8Hi{#(xYFUF3pQqmWWnli`fs&2xcj?pI_bxo zYB8;5SHLn-IMHjbkz=WKP;GmF4;6|4+^Q+_4pozB9_VWV2YYeFBnm_osN+Hw6NSeW z6u6$zAuM5Fkj zxbd~PpeBlf@W!K}rPwjr-T3NL733^UMy#0;8qIcI*5!aTVC3UT$*(IhBWPoxI-Xli zJ*=ojMigrMH($9Yp3_RLP-hxr#pwiYgb)zwd8E?L=mUi%riDS=4b=Vj=aMN>Hq%vf zPi;qqi+1OR28>$-h@@^QJskvd)K*TE(9=fsm2%2J2@HPox%dt?>xo3_J2CX5I~H7V zKqVxTfQ)fF1y*NJJxym!SE>0eGMsINWO__m2qB`Wjf3JTBQylmc4~+tqcHUI&;sY*KhFJVBs)r{0_L{#C{BJj0J>s{HMZW%4R;$HaC=PL(!g^Ma@h z#?5bdo)Tr7po@1>;@m4EWX9f_l((z4tGvaBE!kl#wC)BmBy@FAgv>Yw5t;D0ux!DH z$Bf~1C0a~AwFAak4b`pfQ>Z);URk#4bgW3A9!;4)X6Sj96u1OP=%h|h=`T;RHZXDA zt(IfLv6&!jDojQ;k(|@Bi3;7=_>L4>WY(-X-XSopo}Cmh&bQ+<%$W?_I#$>q#|Z*B zP?hDhvmiiCm?nbf=>DD&@ZZxO{DB+ZkT5zB#R_a-M zvAxfIc-fNZB)AQ2lH>0`G(uKcFXwtIZYxd?(Z3||I`U` zXG*bbd1I-D7a_)xSTe6}$H$Fh6in)-tk=>F40yI%s>Es#IK$)-B6tS2m*K6b!jO_lC!&P! zRW#H!9V?bfh{w#sQy<7Vwf8VL1L4P338a~d{{Ux=RlNjND=A`xI-4ekzqgHnA}A>N zqtoe^J41m~*Wh@85kZSGF_e*YaiAjnbv<>gx%g2}3ObnVzd3^9f6G_Tkix(f)Dg=X zU2>^G0*U0fjwMdg(@wiKoveIy<>(IjlyIa*Fw#hedkgrTFJgH5c2O4b z8@HXr+fFG?0*cVst{C+saMg%h4TA6AUMmWstHg+)!lopWvP}WkO*rys9eSV)RJv-F zqa?Ijzr;nqD{)akB8o%h3N-2cX{dq+q=gE>A>82WbMVZEC`}^*0q@?qf1BS?bpAy{C=o$rh1sIBiw7-w|}FXq{@(Knp$VYxSM|-!F48r-Va^P>gP)?<66U4<3x^G-qo^Gpna;`<7p`edzqvN$zGD_(E zl&mQBapF8Yc^}(v(~qmb*aNKo6_^(vO19Qa>bkj7l|RA&9&$*L@t|+3KB4oDWW!f2 z{{SJSz_9wjf1TCPPHF=~B}y^bD_N0P3lMFm66YJoaJ2V&LPWtMkCh7d1F`(F!t7jk zrPU+s3K5JLkT#LFMB*p{IGr{%j9~IXT}=R_#PIm=sbG;F30Y=ayU3)fs*Nvy9tVTP z$2Caskspmp_beNGM*&GuC|;}}fd>FM)xly@d-A>12OEiq-AOu<4~RY=4o>SB;f&Wf zZPEf`WKvF7-MZ&+KJAAYG;waYBD;cMi|-o+?eY44j%WzkMh$?Sl`K^v%B)`MH6(m_ zM-3b>1adUWJ*^WODF){mf?N3FaAemjkor{-OW?lPN}c|)jAy(z%W6V4N92Q(_Lgbb_1DnXarXuE{WAZ zKdF4%LHxr7q@~g6H+`FKv9JS9HF&;?ES)6LYo)7di8sCFSv&3caT-@9DI2b1M+cz2 zY)+TcRpGTTw3L{Ip2{z^yZ!tzY1pE_&1nXdJy+{3S5thd0Ol+%je{aKft%aMLy~Bw z`SPUDXNS^5<(7MSmka{<0m_pGh@Mp~GM>szev(9ezGICq@zb{+28#obu~wg!Vu^5C z6;Ze}L(DoG-EMDwSeg@{f{`02sC5>6K0L)zv}!i{;mQHDkbWG!0&mtk!xRix&eAbK z?(1#6$noNY5kXt$sZmXhnhIEgS(z=Wn|N_@5(uPfxCu7=AgM1y_z{gS7*9d3e;xvOc$l{7dP%)(@qysh_CPjAPTQ~GITrchl>oGCX| zNYt{tE|=I%oF4pIk*P8$lHm(!WhaG1g`;-`PSzUO^6jE2H|9YRPI9zw3Y{*d&u%+g zz=6|E6@FXx?wyafPHaz#F zoRzf2ix*p-*Y@$S(WCzW<_IQ`IP}o@GwopJLvAPufk~ZtI;Mk`5=Q9iHyF=|?hkN5 z(2s{4NUb(iGLb~5tsa+foW+X1b?Fuz23^h-a{1Yp0T1%@7?g5*uIfU!lPZlxfd}Eh zPI0;ot$p)870x4p9X&>}kF$Q?E-f1TmS&>muuLIQDnT0u_rUe+s^-Tsqu{y1IxKPD z2&T*Ugp_%Y4h~;r>P<7d+-ejtC_5ej9kVUE0l*}|2iaL)Yn~?N$Go@kt;7O@vjd2Z zv&7MY&K{PtGy@HjAz^e8(_-}Erx00c3{>>e%VsVY%VV+7t5|9na8Y-F;kfVC*}Z6w!V5`_CN{XDw1)tXkrSfd_e`F62B z?T>rgl?IJdiHP=;bWj&j@Y}^f=F^QJxK`R4Kaf(KILPsZc!>9h+9Z2;x&;*62o;E7(R`^fHr6Lw z_dI+g0W?i;h>GQ!*93N3Oq;6^Nu~2l6-QKK~+0P zB$3nAI;jZNF{1>RZ*W*2j|wibJ6B%sRGB{G<~Y=Yl6IAx*x9btr-*Eb7zs!`5=f8^ z!%BQXY&IYTEEPfx00O`ZcyQ1};X#&;IPIi`dfMx2kVc==#|0R)MAKtdQ!KI5HA;NU zs%jFLk>)xnw&hdc4;xVc(ZdLFO=^fAI!x8$HMk}>fw9AWZv(G$ht}6dOG`;Rg3+^& z6l)MqfwvOeK2Wd-@R|{2b`0EGx}vysIE3&};~(F3P*>_-s&!dMC_|QV+@c)aoSmpC zWexgDIxn+5Mf?wNza9qnvouw+9nwF#Iqn@bEOsxt4d$7T<}MTdO>g2q-z)f2^F35c zDKd^3f>J#VMKp4RiQbnoN&_T})2``Rn)+-ks=h2oBjJ~!l){9LpIyI&Wg2&d`4@(L0ceMWHQ{w(L{9$ssV4LaEk84p*V=g z)`yvXZQePcc&1FGVb%%aXJ?fU{(y4T80yw*#$IwU3>9lB-U8=Hr;B>A9ycxDhZ~D* z6?nBy$^~}sniS;7ObA&{KDBQ2(5*#dkVu6^z0+$8THKY)Rwy>GJg~-v2s0*f>E=?$ zGk!_PE!6yHFG6u2>V-7M31@(Rm69ua&SL-)gSfvCX16Y~$yyVrjua=|yuRA<^$grO z-6a126iglzOFG-@*EIDHDgOXf@Qk1`t|5)Y-_7grS><|)dR?1cBSvEC$5m$i)4(O( z^Q~=^gy|<~8)|vUyDVbb7UUI!(!V~4Pj?eXCo67TSFK;r}8-DH`K=hzC9bYQ{ z*8u2XVKZ#pcayr^h&pp8+9tT^bm%l9;aE)YsA;vjf{Z*Z#S~KE!j!mXAoR1wkQ=mQ zhc>@{INk<|ZeJ9+s?BqXe=Nnhn#J_Cgz;KbW{R#J# zqMUH)c1Vsztai69*rJ6wjMDZB#DK>vQkOOaDIVTGvWspWrDY{q^2~!$Y|G2oxgE(-f?rH51GdSv}=TTEOeakYLjn89t;* zIM5{x8erJNLo0*iNw5>}ZZ0^A1G=8+(k6wP{A^OvOrk~drc1k$EN(d3t+gmp_cN8U z+L8dG;f&QKRaC`A)UnwA08b6tL{wRtJ{GB{k>e>(POuYiD4RI(<&CgWnnaAvO$Y{) zwRQ5=%H`xXZpu%9(~D4mk%bW6UKcjj6@zwwT$>AD+c@cjAxkIvDJS7bdhB~FNN*lz!%MZmjce&k18--U z#)Z>+0)(Er5!>W<;2+qpqI9bdbs{TpiVQ;>!ZSV_G&qheg2goqOGi3LC8wKKO|g@x zI**9sjy8q37Lo}VKs0Y-m_Eg;md*l(+)yNtL@05`*+^X1)hxe*ViI5vM?Fn+6H=}w zprma~vPth2^9a#LbN6tT{{T8eYta~pp07F`?$+X6TreIB0VFF=5TZ7FXprXY)%|_z zE^No;k!t8Lhm!`t;si8)LS203wqzbAGC$E{7V^*-$<5*$C;HP#9(puz@KX}~s;jZSCCjDUT zP>Kik;?my88;n903HVjaWy-2lr&gQ%tcQNnN)#BccQqRA{;SPhJBxM08NKlki-()9j$RZz$#XupADR-ntAv zhCMXK{A-dg}GL#MF=LW+Qv~zYny2&(Y67=)#=-8voD* za{D2~Da}KEk9O-G$JxxGXxAC86gXo-%g+ix#ase3P&lDmXt~!kryAv#=-RE_&|H?> z#C#7GA`K8a;553dz-lE4GDJ(-%&I&14nCBbqSwtT@P40T@?mmfNrt;qLZ()7q-`E2 zH$Y7kd`}n^*p)>~g1&2(3{MPOPBjx|SE0p|O%+wO zE(!^q<6&)^i5B9vkY>E-vK-ob~X~8~5aG@+D?7TT)?P6#Tnpl=s6p9o@Rzurvi^ug+ z1hs_I=2@j_+S5oJE3mGDwSzisQ zbFw%ql!Z6;KV!wMUpB8gEx+A+rUZegbsvbLx$1+deO~D%U!cuBKg+mQHH3-V495;O zB$7&ZfATV~mdXro*!*}yy&0|Tnl-W#r0g@ab&jf*I~CkqgFn1ot?SM<;7+9J*r@x5 zn5xXi{YCXpsWi!m=FItt(9q8mh}ml+Dq)n+$_0RDV=J2-4!n$C-g~Q%RO^Hf=%)c$ zr<8Uxk>wDZTSO^xJZ>FoJvcxfR21N*Tw0W1kkm~kC5p{z%)^UUPbk@PZFw5Q;%&rM zgt(0YLW$Z>&W1U&E!#QY5CRY|LJ&RxW9^|DKAGieA1q=x#vO@bN-Pc^i_g4x3lApU z{yY$)B4rANDJ5UyAHskaJL!J-{hLclI@=%NQ#{!Z9m8vWZ!h9ibS{nNL0Lsw?`H71 z+y~{xRh2r0l{TUeoh)y8?OtSyhSIK(QUv?Hbe7F{-ha#(y&PH37@Aq5gkbN80EpEn zgqXyQ9g6@@upf^L@7}z1z#djRJpAZMySYYHX2CXXqyyrPiQ5xRIZis*vH5V!I*I45 za#FUJZrzO^?^@^FJ@0-cu|k8oQYBny-#mGr$@h*b5fTaGJUr=BoZ`(iu$X3*q^E^_ z+Dc2TYFpd>FQ)u|GEKrpnZm2PKaz4>N^$8sX;G9AVOe@8RjFZ;)H1}I?m@l4 zBVPQIoov87D;I57Ck>Q2s{DTpGfcRyj&G#TeGP|?|GDe7eq1U4IY9X;M|Dl*L0l)7sU z8aB-mk9kGSye>IprcDr+MGQ0*VWW-%8L?Xv$AU4ZRdNhe3W`UHqvjyGvCx6+;=m$< z7vskwp<)$tgz}BWfo}db;-sev4qn`>2&8Pmnf>8*z5Va(;>4iE1y=4RrU**x0j>zY z6x)c~NS;|9RPRKPDiHdyxd*o#N@)UJ1R7<;yg+jrn zmkXb9P4T|6sP=NJ0End)ODw8tUOSE@L=wYHrZ$*pe09>?ZKkxGX!7R!yhf3*(In~~ zLZ1!HaN@M+4i}9{vN+=wG1Oae2Hx8q6W=sYy+Gh!hr0F<~l%pzIZEi)wVipKEb#skW2T^)Gp87WyF(xN0c;*XBJ5MZ3zEe#N zL)*@Pi+jM4xqLYg=6NgjK}5jIR|Bov5j*Cm5A1 z!Q&=1rlc@LJ%aXMzTBd-bR?a4MJj7`o=^n@4>>z}jV0EP2+RwMW{h^JusjC^iR)@7 zNed7Fvah^N*^Yn?ByF@ismCxtql0mAVjH(1;@RMoe7%R&yq6kzmYF}8(j zx*S?sdTLXSQrF?tc8BMvZxY;}vKX5y4#f_mhR-Er0jLmqIos7lc5gMUOD!lZJP!|< z9dsddvo%-xcg_^m%>`9PLCzCX;rX8ls0h+iPVKR3k;uC*w0LmCD9n|XJ*dfPL`?LY zC^^2{w9fNblmd}(&?N_?4XLYzqN;*KrfOLg;gMEoC10}2>u^WFj!UpMj(RH#+H|FQ zNP-Lz#%Nf}c$lP;l1SR}M8Sp5pB^^4K0=Cx4V4)6E;R&E#dp<1ESd#j+>3FNDM}4U zom9z9wo5ANSa@5&@t`7?p4_weO}gN+j0y`)m}CT5yy3fhS(&7yy@%iD|Q z1r<4PB51>9eyyAz9>MErBJ(NWkZ%vzsWv~ynhKLik$wV!qeqy!@q&LUnQ)e49VUx?fgRth8j@mo5S(%?@Dk5f;?(Sr`uxnn&j4J^`3t$!JO?aIu72U1dupO<< zC3LCg!N!?e36ScjLup{5{{UAk4mD=2O2s#SAgO7DZwXH__YN#h-^5sSh2_5aFj|%ez6(TA|+_aW1!+>GO%8OQe!Cwxg#xUx- zc;2fBkkd@jIB2)3i!yEOHQ-f}tzC7HcX|!DQg#|Gw0Ub1$L_UNE?%~!aOx>y8$vRu zaj<)J;qwhBn4lxqZL~=nB26K)UO~gNE(cSBX1WORxaAEAixE&+bkUXdA(ZywC+$%3 zN>(O?nO17`lfCu2$_jDAXQ-kh)*nc?&R5Bl{aEP)M-{2TorZ498%UN)BsOazU(6|f z{p@%U&UZ;oG2h$br0pG5H*PO(4BlUyyEP#N&#_!5ub^~L7n5qJF~L-1#N^9(WN{g@ z0zxlQWE+J#Ak?#--X1(H%N%XOPOSipdisY&NZZM7?VgxNdgQ`7KgK;mvs7h#ClaBT z6Kp;3${(6IZ6zgCo2w-#rJdLw+KYQN=H9YtXw(x4+1JRe+h(^dJKgtzYttlw;TYkM zPZ2?GdBZVGU-@=H!FL)M7~+_yKz7SfwV73j(1_JepB@nAC2kPHHgTcuNS4}CuO9n= zf#t;dpM?pX8_Uq*9XiZ3(JNH{04$r##UMj+Ae91%06n&yPY-eyLzZq1AnfX(R{Q3P zV>xGrv4;#nm?x}I^IOvT4F3SroFl08RQ~`io3c@Sxt&&xcQr&5#=@k5_Lv|nM~ECZ zb16;Ds$WhEZ0T3yK+8?=URRwtV6&;G#w;m^_(akn*tT79260+^NOJ)SZ|iw zqptFRk>F$4u~Hf%5mG^9 zw_yi|Ra_oX!s@d2S;`nKOs!K{gyGb*6>`dMOp(L`T%V7AP1d%`X_TOuAP=7|@r3 zVbvIf5>DpigV_H79yCQd6;r-X^q((((pvkpy}MfcYe1S)CrnrW(>_$$P6(-3yGaajQ#^=dc0TX2+){+VrjSxL(#`PMnnUDAyI?J_c=FRl*J|-iC+aDu z-}-2bdrpelUzcq&LC4j$Y9mn?M8AQQ5iE9qC>I)a|)KHH1&Q&Gl)m$E53 zDc(W}P4?2)EKS~Nm@Lm8kZ^5&^ix>{7HOc>*h206PZ=4ooH=ECV=tEZY*tD=%g zHW>Gw%)5K*?czr)7v4zOLY%XE?R%7=!a)KLL8T@Ygi&Se0-p|vyveo~sghB+Ni?J1 zy7-R^aL(P5+GC9cGc3VZZ>i0jBhzG6dv!C>&-0F;*YzK!S&kg5jaKZbsLS|_d+_g> zkL(*S?jPP3)7!vqWx2%M_txqOCxO{Dk(-y>{{V58ro%C0x`g4Z9~P6t&#q{mXN-}Z z@)uJuOqtXdp^N#gJLVIK;Oy@lu?PBQw>fN6p-PMhE^>GGg(!9j!Dmqsb(!*3;b}U&o1DwF->} z7D)r92O1MGeyLbmB>^EyBZ0sGJ~SotM-jm?Zhgwr)s>EyI8;7Q#%Si-W6}?;SZ7RnOH0%IXFE-Y z)tZb8GrTp>V6|g^%gGw-WCZ=F%91;BN6WIIZ0d+Im2l|cSjD`%{y@LFsptP)hfZnun=HtlPk{0C-xp88+c zZhQ(jjwwAOs;6Dn?WVxx>2EPcr_dlMe;Q9uLBk!qDIu1<8ogazCOy>b#`PJdj;HyL z&R{3r+>&pME4Z?+v~4>0^HzI;NlM>bs2(2LzIXKsQWV95AT&fu{JJ=vx%8vfYK&f1 z_T3;*wd#Pn*@rYKg*m5Df#l@vIESIi?zgT(F#rOd38PM;#5%r}3zd7C>McE5f% z!j{G}U;orUxSn99{;JPK9J{Kjz1niU)b{3JCuMNSZ|O`LD;bX>*3m&OI)6zMHt7lW zo>3{rgZE^Kq{S2kfZA+t+;eGf#ArVIp4t}jl+86|B^0+08v%3Jj@)?CF8)XcjfM}F zXeEKARRNH0CB3|`qYmXJXfn<;ROYq{N_#UXEm5#u*X_j&B4{s~xDEqtA*Q2csWG=< z*_XY(JXR5n11{c*6*4AK7}h64PcQi$!Q?7*+NSp7t{o|_SX&pKNE;~IVmVnO!zYPi z5mUt&@~MK4uvfV}D{Axhky1tG?yK_Z;TVc4_>NAmdYQy(1vq9X#PLdgW=0o%_NELCvIHPb*p7ZQQ=bY92f!` z6t%x}`#Gd4YWJ*6M#^pZ61p^7HjUhQBu8BrEWxfjmN8+eUmjEfOP89Kk(=|lQ z4*)O1 z>!-1)4|nVmsVc7OYS#|Tv^8%Y*y+95m3&3*#PKP@jREN+7Tm?aZsjT?WhpVN?F}V{ z8xfVHJKuG{98TSuPuyrq{_-h5+~_{XGvw8j@>8@*jVQI(Uk==Pt5k!97Ts?GolFr( zoI5GwxrS4Sr7@0-hO2tRcDEZ-sRwNxSy?S& zXfe&0Im4P{VYg?#pnEUJP`Rru1qvYWpv1-IOu|0xVW99MU#RiJ5-H{$==AfVP3teA zd4o6M7$;J4Y*JO`T!^x^A%RmMcCVpiH`)NXWgUR<;0t|ncb{!9v?WO4(m2*keLePp zX_ma@jnUG>i+x0Ol%@m}dC{_mUdM%Xd(&BcCZoo5c zBUMiXd5L`LL$yvJ06t6 z35~RVo!cRzwJu;x3O&6)pn)*DLlTBA1djH;w$yXiDuq*7ZMsTiai;7-l*x-!1ahd3 zYzXbIHnc)!n?WW|MG2TCd*P8r!s)mT{uf*EAu~n{E{9E&Kh*yK=6^7|_V4odd;7kR zZ^w=Cr8=ws)i=3I0;`fQI}>6;`>~CGZ!-C@g>ZFiuKJ0IQ&ZsYh9`M!x^m?+MEQg8 zBc_1*3TTuwXr)cY?;j3ZRR$ioffTC4DxQ+AmaaATpdj|RBK+7*6t3h0CWeT5gHn|8 zM@9@T<7+TFYB>5^HD~j%1{B*vS2b%*HB^R4Tiyrh| z5@?n80W><~I>>NrPJ()?2rOYT0dO}D8*;7*kw$rC&}qc2Tqwg<<7rz=(7{t2kve%> zmBy=U4kK#QO61VnFy19N$pC{QgIrFHcBl(usoZ;8hUg-q%*P0kKu&LkX08D};)iPy z!={cE80Y0BSXZ#hZmIF7#6cJ_Ks3={&_E3W*gY zao7vk^6Gm?F}9zywkmJ~vW{gYU8BSBnrLa!LPHo;VdJL)4?eXySrwJ#tut(x=%S0& z$1v2rJR;4nm^dlRQ{kwCc~qYK#TBTqS@AqY5MJzWx5I}zw9qxCO4kB~HNz7Q!`2c4 zEFdWj!j&HJ$)VM=L6$%?Tl4xRBZ)Lr=Wt7hW$aH4*$|oxW)B6diVSHmuO_=}!rQdh z;m4FsUey39DfDL0Sxh&l4kI5Hz_CS99HvTXesHUt7jC&%2siMKqVDfj+ns` zw2TR)ctHd;j?%+k+HfxEI))WD*gA!xP8?|kh$E$SRXRi{%E&zF=KBE{Xja$bi6n5_ zTYX7$5NC}maz0ewJlOqgcbuP>!qvvmQrf+ay71D<+Z{%OS^jbW4I|c${zQn;V3eUw z;-dQaTawIK*QVr&beR|JJdIX2a+(rdDM_x~Wsl#7M3RzTk{Z(PPcE zYl&9vN8RNyy^o3Q%8V!{nB9dK6v<0NBcVhDwwEAZURVkby5X6nmLHb!N{9rhOy)Jy zcvHt)+elOuiHdfE4W6D=jiDm;vfIRQ>9(uK;%v4DKNwjRz~PBh88FhtU-3Ml{*dCdSi4TRi~ zbmh$@OhnB#;y9Kg2}*gYS=9j%-`T}zY!uLH^E7lFB$`K5iDqKk3Gp`?@pESi2VXc; zW@R1~lm6-ewEhE#))~OBvfAvSv#4Rt`Ld)@~turK0X^CNig;H&7 z_ho+O;OqDCLJq1XEfxfmP_XK0YbJsqG?kVRzS2)Frourqvejx@lN@N$(e&R7iv^A+ zhy5qZ-y^8hF&FQ^>a!SJRNBVpq+0@Z?WArYouR=gro-ylnrb`681J|*Za?`QYSbwL zx20C?mXvm2D6r;iNBR9^^+wMu>~^j71BUD;NT3DX-+bhpW|5dpEL1p{l2s}-vmXP+ zN;-v7$oFfLQggvGVNA57_ufkP&~d9o!l?5!z1GmvMZsZ`Uzlk@c@Ti1yPbGqXf(?~ zO2)99zV(#}D$}+6EISW}H!;SInNNxUsQ97`J{jPV3blp9j}H8%+A~Gzc3_2zPHO7f$LwYEQP5JtWN%W-J0)D($Ab z1yzsEW(B5?XcvEv$BC>i)UZ-^(5rYd)V99yI0X-9RbtGI6-_2{;xtt|VrH4FVO3C!SX*A&ajT0GRUpxZRh~4{Fu4jFI_O8kaP@^Cr7T@w zQ3|mg!ixj-@XJSp4vGz~;4RXiHku#uwGCAr3`DC*P6wP>hKhKVU`-xcxTJ~UQR|%I z_24pFVH$Fw1Y<^)FwLh1n4{9u@)0TjCOV*W|wd0zee&f4*vSj|1& zVPF5(8>P*-rBntPS+=ME>Uo%{74yvf@d=8>O$@V@WlikIa|8W6tYbv(x=td6Y@3y( ztDXTWY=%bwk?kjr3@VMVN%N!YgY@$cp~0x45hE+0-bf$3FV7WYLeJ%(HYf(oS$3L> zGDS|Yg-zQEC?4H7p{O950A}szas?_I4x^z8s~*HEFZX;oaAj3j;jss01o)g$E+E z2)d&#gkQ%^c!}tW9N8)r0-dU@O$*B9qz$I$*NH#`(18zVMmW+F8?IXIkwPsLZQT9* zP|_lcZf}z41EQXC?Gh=ZsQVinNTiPtc-6w@MIU7iz)3qMXvkJ)YHCU-%g1?SK%@_% z*WhqvW~A3rd%7;!5bhxO>3%kunlcogtYcM6GKA1*!2EcvDI6)(uZ1OO^3)Yr zj1jf0=HOdHZfS17G^L9`rGPe?5sqJ^p@(`z0njTEt@u>8i8Md9%TUrJ(Q)c$%N#~H zR27lq^CXdezysd3$BltJIkfvk&|5bemaQX=5Il04uNtnzFySg zP7-KoVW?5rjBbaX#+0_05^IhV0en)BFf5AWa5~&}=9SP57$ivmQOv_I+B$q8CIw9~ ziMIyQ$8UZUsFJceC{&Q&bAj3Mpe9Kgn!Zx2buQaT@fXvJPAP*`XhtH2-kabOV+_)` z_ea}lZ{ynBM(Gq{)-)#n03)XUbNsf$X3KUK`gqjS@Fpw&&@iVa;?#6zs(NNI53*TL z-^|5HubmszI5FW*d0!4mq_c|t#Nq;)oi+P)HXFm73Md}&}NeZ4{Djk&%Zak?QYiMp@E=lu4+l?G`-7IH?0)J z4Qvrdw%~aEJi5dRzFKA79W-Mj%an~p05uY!#2b|)QrfQrfv~yhULo&&gX|->JcW?CrFZsdHpE6Wgogrn zWF>~GLHBrO9m0VJE-6(ho`fPszyqeb_P-cPri~nI>6(JHNn1(PvZ7ScRXFn|iIGY2?naMGbr7#~Ym za?T`aGHSLClW>rXNa0QShpoA0Q9U*qC&Z=gD$t<_5r(%iZ3G{I;a7Tuo|=%;mtMRl z1kX;|DEa3L*2^SaG_!dF+zS?%9Qm~ z5X~ap>NQe(3vn{t(qe>JeZHj3O%uG|>O-bj7gTZXm1Y?0@SI-(nINjFdSfj+E5x%2 z6hpc8?P0CBA9s4~TDUB(LWN4Uy^v=2nQM2fX;W(ifiQNF7{Ht;VXn^|GRxUm=DN(y zOD+*2d6;!pA2d_VRDX40iXzTS9V|wkHsZ^S;@vH4)Czt+Lv0jTZcb$V$K}w`*Tz8+ z(LQ%Z*m!*sO!hERK=JhBPHqJCvd?e+0G(I$)#VAF^7hN}Mn&3tcf8`}J=3Ugh5|Ixa<@02ija^*`y z3Iz($5CGFoW*`w<12V+)G$75ES8-A@Bn-o2mD%q0 zBaWIU354THtQQThN~kL$h?R|ju+*P#G~)29TC~3KC<+oEFxI$|lwLU-xVE-DVYWog z9bIRREEGmGoNOx7`Nf;e2h3(4YUJMhGE0(}pjz!fSs>#|x?h-YiIaqfV8e(qJZ3U1}68&oT0 zOoIw!Mrl)Hwz`iVd%edBd5dD4R3d5L2EZi6@hWOK{@jkLEIVG@ZTqm&N{t<4xjL_I zkkWXX9CIH_mkYpVs3P?+ppdveBVGmU^WOFNtbyKc$pwyBTt9FVLl;M~-X9KCqO0(}7*;zi_@%FaoFk!S`0r`8pm_L0bLP2X*x@bjOw|D3&*cJeq+Owebh) z;J0+cs%BJb5AEU0Bxa#3BnS{=+eL<=79^E6u(|Qzu{er=G)~HoONCTQ#-XmZzi!Qc zZ{5b0-~uSd&e3DVvX1vmGj3ADa-|GSh($q&(%EZirER6GHMRTSk^Xg++&b}rDdAa( z*@pLJHhE$~oCtIu5a|>F^&>gp*se8;rWa(SsCL`4?2CAhr-E#*(Zn>6vm{hKzFW&{ zd4BTP8c?-iNQ}QjM;;Xv;g`*lMm4IycD|P4_Y_H*D9am4S?ND2<&4r{i9=p}z@TrA zL2F*zsuroEHU^oSes%|%~6hE zQwH5cr*hG<`w&{-`%U;ynlj*$HdKkZS%s-ak^&s*;%G0RuBo7h<;=|#FL@?FyJWZ; z0vKN294TdBnBznHq-n+~CLx4ln8aqXN&xf_6H;BT@9hPE{J5ppf=)GiJ2kHqk7Wng zPFZYw&Himp(X|AGR`~##A%aHtWZU8a@5{2NA8o;D`;@Eim0j#848zSxBf z50zw>VO!!*vzE9@kl~aKutw3t)QIs6K3Y0?#Jl~(Rc`mwnT~`_ zeC=j=!U}Yx&|^cFQRa%Vkf8_73*P)tg+$OXOcFw<$z*KPM^9HrOH>RmAGnU%0&QW& zR^1A6%-slB28$ zB+cK};*=;la;4;Psc*AuacDFFxg?WLxN;>$MKo*;+T};l&8*JKWeSo3qeqaiS}7?5 zOBiMYV;c{5>ET`5gc_CiV#TE(k~UUc;gqQav>2TfOB{?$6Q~vh0rt6jH_pRIH@7B0 z(6k7~DK9n#B91nYhbKbI!vwp+fp-~Cc9A@3u1bF@Lm3(oqm3*%x+rjIFm;eKm8F(r<`TzSaN60FHkeHUuk#C= z#|w`tRB@)CEeWw(UjAo?9yp9EcIuK33Q(Y@hLrEIEVob%{5XaT(8k@?!)B8SG}VaV$g&wURZT(;=aoX|3Rdm5l}Uk9FiIw${8sVIRZMcJBjY6j)xQ~ z?XZO+g2uv@gBY0+A8f2y80}ggjd7knXSIui26;#PVUlSFF z7{ioDEKJ9_3IJj7U`G#(GIqiC{CeL>oVjK)5|LRuN~Zz+^84r#+$f0qJ&o&V@Yh91LDdRINa6M zbacLK4&@Mo?_3`1!*wkqX`oY9%TlEy3X6|)w-3c~{wtQVHW)D+9~*_}@f5zZs3gB&Z<-%RifnJ-SMGLlqfI+_0f zm{(!ggp*A2)H84M8dhTWziTk!7P6~UGu(vgM&7xhZO-}Tk6#PU^Nn>)vlgFF2LR-**0C1!?S(DdSCHGaW z#ce!iuB;ag>Mjpam*c5v_U%=Fl`2E;J;6TC60XGSCWfr<7N#`DBARhJI!xD3B{d76 zSyamjA7}DBQf}bIfB(}q_)Lxn{ zMnNIZGfk%Oub8*5Ac`fM*1T^Kh5AuWI;l${((q@Er``DKd5NW!4plMN17h|Xd zdq*Bh05nr~bX3#!PiX;H`z?6_gT2Jj!Vr04?GTufg@J;lw3Xih0IXyEoLzhA1RbPFhhJ8-~zz zdz)O2D@&6_=wxYwwwtS%q-HJt7VpOp-Zb(bAvFe(gi*H9yr!-7@wY`8ShzruwuS7I zl48cN$uWFE43Wxwx^*3ghmQ#FFGEVwDp1`m+EvZDb{RsNkFO++M}mo`sl z6&y^_MY@y}L8SgK4Co}3A(06Ln|+c#jwxwko>*8iHd0o$)im-;v?H*+&uujE7P3ES??Rd@X2u2+fh#Q!d*C8$p+1ZQ&_`)$JZQgu+S>frYgGfdq&IBM6yhg2t%SsZ$^*dvRR zryafv(n@Q4y6a)k6e(q$;KN=O^4Ubt5In{G>yF$>Xq5qt9OnfJT&97l*dmrjnk56t z9$w#QJYHvw6(G(ukf6)*;y9|a-4;eE6CS{?y{|mCAXDr&G$;Q6G+I9*g`%-UCJ6|* z+y}#nbWSFWgM|hKKjj?Q%a~@4o;d^zsujiVBsv|V*~+b<6GjXB0B z8@6~}{rR-S<4rHUj3$;#yUAVs_3hr)<;^Bs@u{o+LOWY_(Q9!^q9{E4&NY!O<|h8v z9r*Vw%_$_^!#|SxsJL(zwU>ol;7z7L_0sq zTlah4>gLlrOxLbEyd!TIr3Dt<$!qNW{oJayQtN1*svmNv@^6y;CeNALFY`A0KMU}J z^SqokRMERXl}-lqm4q>@vruKX)RU$=YIbHy}Q}N0o6tRJqC8v>K~BVFPrv! zcKdjW<5cj96lHzh8n*McjHX2S@9I1sE3@Rh)AF0X-^Tv{vw;lLyZpyoRzmJ~=0B5R z8g+WoBQW_t%}?`vzHPnj_O{=L7u$WF8VqJp`IFx5k98(n`EQipCx0sKv$gHv#a=39 zJ>D@u?k(l~n~kMiqF=ib-W-MD0#;Y7{p<6P-~syldQ|U%0Om)-tR{mN1-kZwu{{YHI=U=zm7qz(B=Sim+i5)d! eTK@o7KivLX$@p7l&IG^aBi5!*`L}S>75~}c_jvFC diff --git a/scripts/build b/scripts/build new file mode 100755 index 00000000..f4063482 --- /dev/null +++ b/scripts/build @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Building classes" +./gradlew build testClasses -x test diff --git a/scripts/format b/scripts/format new file mode 100755 index 00000000..65db1769 --- /dev/null +++ b/scripts/format @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +if command -v ktfmt &> /dev/null; then + echo "==> Running ktfmt" + ./scripts/kotlin-format +else + echo "==> Running gradlew formatKotlin" + ./gradlew formatKotlin +fi + +if command -v palantir-java-format &> /dev/null; then + echo "==> Running palantir-java-format" + ./scripts/java-format +else + echo "==> Running gradlew formatJava" + ./gradlew formatJava +fi diff --git a/scripts/java-format b/scripts/java-format new file mode 100755 index 00000000..ad5febce --- /dev/null +++ b/scripts/java-format @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +find . -name "*.java" -not -path "./buildSrc/build/*" -print0 | xargs -0 -r palantir-java-format --palantir --replace "$@" diff --git a/scripts/kotlin-format b/scripts/kotlin-format new file mode 100755 index 00000000..3b8be9ea --- /dev/null +++ b/scripts/kotlin-format @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +find . -name "*.kt" -not -path "./buildSrc/build/*" -print0 | xargs -0 -r ktfmt --kotlinlang-style "$@" diff --git a/scripts/lint b/scripts/lint new file mode 100755 index 00000000..dbc8f776 --- /dev/null +++ b/scripts/lint @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Running lints" + +if command -v ktfmt &> /dev/null; then + echo "==> Checking ktfmt" + ./scripts/kotlin-format --dry-run --set-exit-if-changed +else + echo "==> Running gradlew lintKotlin" + ./gradlew lintKotlin +fi + +if command -v palantir-java-format &> /dev/null; then + echo "==> Checking palantir-java-format" + ./scripts/java-format --dry-run --set-exit-if-changed +else + echo "==> Running gradlew lintJava" + ./gradlew lintJava +fi diff --git a/scripts/mock b/scripts/mock new file mode 100755 index 00000000..0b28f6ea --- /dev/null +++ b/scripts/mock @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +if [[ -n "$1" && "$1" != '--'* ]]; then + URL="$1" + shift +else + URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)" +fi + +# Check if the URL is empty +if [ -z "$URL" ]; then + echo "Error: No OpenAPI spec path/url provided or found in .stats.yml" + exit 1 +fi + +echo "==> Starting mock server with URL ${URL}" + +# Run prism mock on the given spec +if [ "$1" == "--daemon" ]; then + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & + + # Wait for server to come online + echo -n "Waiting for server" + while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + echo -n "." + sleep 0.1 + done + + if grep -q "✖ fatal" ".prism.log"; then + cat .prism.log + exit 1 + fi + + echo +else + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" +fi diff --git a/scripts/test b/scripts/test new file mode 100755 index 00000000..047bc1db --- /dev/null +++ b/scripts/test @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +NC='\033[0m' # No Color + +function prism_is_running() { + curl --silent "http://localhost:4010" >/dev/null 2>&1 +} + +kill_server_on_port() { + pids=$(lsof -t -i tcp:"$1" || echo "") + if [ "$pids" != "" ]; then + kill "$pids" + echo "Stopped $pids." + fi +} + +function is_overriding_api_base_url() { + [ -n "$TEST_API_BASE_URL" ] +} + +if ! is_overriding_api_base_url && ! prism_is_running ; then + # When we exit this script, make sure to kill the background mock server process + trap 'kill_server_on_port 4010' EXIT + + # Start the dev server + ./scripts/mock --daemon +fi + +if is_overriding_api_base_url ; then + echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" + echo +elif ! prism_is_running ; then + echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" + echo -e "running against your OpenAPI spec." + echo + echo -e "To run the server, pass in the path or url of your OpenAPI" + echo -e "spec to the prism command:" + echo + echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" + echo + + exit 1 +else + echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" + echo +fi + +echo "==> Running tests" +./gradlew test "$@" diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 07bd3b12..00000000 --- a/settings.gradle +++ /dev/null @@ -1,3 +0,0 @@ -rootProject.name = 'imagekit-java' -include 'imagekit-sdk' - diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..554a1a87 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,14 @@ +rootProject.name = "image-kit-java-root" + +val projectNames = rootDir.listFiles() + ?.asSequence() + .orEmpty() + .filter { file -> + file.isDirectory && + file.name.startsWith("image-kit-java") && + file.listFiles()?.asSequence().orEmpty().any { it.name == "build.gradle.kts" } + } + .map { it.name } + .toList() +println("projects: $projectNames") +projectNames.forEach { include(it) } From 00f705596f585c9020a4620a9675e733f28b8b1b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 1 Sep 2025 13:54:05 +0000 Subject: [PATCH 002/142] chore: update SDK settings --- .github/workflows/publish-sonatype.yml | 41 ++++++++++++ .github/workflows/release-doctor.yml | 24 +++++++ .release-please-manifest.json | 3 + .stats.yml | 2 +- README.md | 14 +++- bin/check-release-environment | 33 +++++++++ build.gradle.kts | 2 +- .../main/kotlin/image-kit.publish.gradle.kts | 6 +- .../kotlin/com/imagekit/api/core/Check.kt | 2 +- release-please-config.json | 67 +++++++++++++++++++ 10 files changed, 187 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/publish-sonatype.yml create mode 100644 .github/workflows/release-doctor.yml create mode 100644 .release-please-manifest.json create mode 100644 bin/check-release-environment create mode 100644 release-please-config.json diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml new file mode 100644 index 00000000..59853755 --- /dev/null +++ b/.github/workflows/publish-sonatype.yml @@ -0,0 +1,41 @@ +# This workflow is triggered when a GitHub release is created. +# It can also be run manually to re-publish to Sonatype in case it failed for some reason. +# You can run this workflow by navigating to https://www.github.com/imagekit-developer/imagekit-java/actions/workflows/publish-sonatype.yml +name: Publish Sonatype +on: + workflow_dispatch: + + release: + types: [published] + +jobs: + publish: + name: publish + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: | + 8 + 17 + cache: gradle + + - name: Set up Gradle + uses: gradle/gradle-build-action@v2 + + - name: Publish to Sonatype + run: |- + export -- GPG_SIGNING_KEY_ID + printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD" + GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')" + ./gradlew publish --no-configuration-cache + env: + SONATYPE_USERNAME: ${{ secrets.IMAGE_KIT_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.IMAGE_KIT_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} + GPG_SIGNING_KEY: ${{ secrets.IMAGE_KIT_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} + GPG_SIGNING_PASSWORD: ${{ secrets.IMAGE_KIT_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }} \ No newline at end of file diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml new file mode 100644 index 00000000..4b394d27 --- /dev/null +++ b/.github/workflows/release-doctor.yml @@ -0,0 +1,24 @@ +name: Release Doctor +on: + pull_request: + branches: + - master + workflow_dispatch: + +jobs: + release_doctor: + name: release doctor + runs-on: ubuntu-latest + if: github.repository == 'imagekit-developer/imagekit-java' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') + + steps: + - uses: actions/checkout@v4 + + - name: Check release environment + run: | + bash ./bin/check-release-environment + env: + SONATYPE_USERNAME: ${{ secrets.IMAGE_KIT_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.IMAGE_KIT_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} + GPG_SIGNING_KEY: ${{ secrets.IMAGE_KIT_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} + GPG_SIGNING_PASSWORD: ${{ secrets.IMAGE_KIT_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..1332969b --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.0.1" +} \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index ad85869b..5d25590d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-3d7da4b8ef2ed30aa32c4fb3e98e498e67402e91aaa5fd4c628fc080bfe82ea1.yml openapi_spec_hash: aaa50fcbccec6f2cf1165f34bc6ac886 -config_hash: cf9d50fe62973f4e91ef65c147aabcc1 +config_hash: 9f8a678d9d4d06daec522e8deb49e3ad diff --git a/README.md b/README.md index ee8fe401..4e268347 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,26 @@ # Image Kit Java API Library + + [![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-java)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-java/0.0.1) [![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1) + + The Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs) from applications written in Java. It is generated with [Stainless](https://www.stainless.com/). + + The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1). + + ## Installation + + ### Gradle ```kotlin @@ -27,6 +37,8 @@ implementation("com.imagekit.api:image-kit-java:0.0.1") ``` + + ## Requirements This library requires Java 8 or later. @@ -695,4 +707,4 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. -We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-java/issues) with questions, bugs, or suggestions. +We are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions. diff --git a/bin/check-release-environment b/bin/check-release-environment new file mode 100644 index 00000000..3a6a7b4a --- /dev/null +++ b/bin/check-release-environment @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +errors=() + +if [ -z "${SONATYPE_USERNAME}" ]; then + errors+=("The SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +if [ -z "${SONATYPE_PASSWORD}" ]; then + errors+=("The SONATYPE_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +if [ -z "${GPG_SIGNING_KEY}" ]; then + errors+=("The GPG_SIGNING_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +if [ -z "${GPG_SIGNING_PASSWORD}" ]; then + errors+=("The GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +lenErrors=${#errors[@]} + +if [[ lenErrors -gt 0 ]]; then + echo -e "Found the following errors in the release environment:\n" + + for error in "${errors[@]}"; do + echo -e "- $error\n" + done + + exit 1 +fi + +echo "The environment is ready to push releases!" diff --git a/build.gradle.kts b/build.gradle.kts index 7712ede0..ce9ad14f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ repositories { allprojects { group = "com.imagekit.api" - version = "0.0.1" + version = "0.0.1" // x-release-please-version } subprojects { diff --git a/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts b/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts index ca87253e..8d987816 100644 --- a/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts @@ -27,9 +27,9 @@ configure { } scm { - connection.set("scm:git:git://github.com/stainless-sdks/imagekit-java.git") - developerConnection.set("scm:git:git://github.com/stainless-sdks/imagekit-java.git") - url.set("https://github.com/stainless-sdks/imagekit-java") + connection.set("scm:git:git://github.com/imagekit-developer/imagekit-java.git") + developerConnection.set("scm:git:git://github.com/imagekit-developer/imagekit-java.git") + url.set("https://github.com/imagekit-developer/imagekit-java") } versionMapping { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Check.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Check.kt index 93bcc538..f587fcc9 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Check.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Check.kt @@ -77,7 +77,7 @@ This can happen if you are either: Double-check that you are depending on compatible Jackson versions. -See https://www.github.com/stainless-sdks/imagekit-java#jackson for more information. +See https://www.github.com/imagekit-developer/imagekit-java#jackson for more information. """ .trimIndent() } diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..8f987198 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,67 @@ +{ + "packages": { + ".": {} + }, + "$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json", + "include-v-in-tag": true, + "include-component-in-tag": false, + "versioning": "prerelease", + "prerelease": true, + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": false, + "pull-request-header": "Automated Release PR", + "pull-request-title-pattern": "release: ${version}", + "changelog-sections": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "perf", + "section": "Performance Improvements" + }, + { + "type": "revert", + "section": "Reverts" + }, + { + "type": "chore", + "section": "Chores" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "style", + "section": "Styles" + }, + { + "type": "refactor", + "section": "Refactors" + }, + { + "type": "test", + "section": "Tests", + "hidden": true + }, + { + "type": "build", + "section": "Build System" + }, + { + "type": "ci", + "section": "Continuous Integration", + "hidden": true + } + ], + "release-type": "simple", + "extra-files": [ + "README.md", + "build.gradle.kts" + ] +} \ No newline at end of file From 4ab06b01316b114e526159de348b9d52fdd57567 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Sep 2025 07:21:10 +0000 Subject: [PATCH 003/142] feat(api): add BaseWebhookEvent --- .stats.yml | 6 +- .../webhooks/UnsafeUnwrapWebhookEvent.kt | 133 ------------------ .../api/models/webhooks/UnwrapWebhookEvent.kt | 133 ------------------ .../webhooks/UploadPostTransformErrorEvent.kt | 4 - .../UploadPostTransformSuccessEvent.kt | 5 - .../webhooks/UploadPreTransformErrorEvent.kt | 4 - .../UploadPreTransformSuccessEvent.kt | 4 - .../VideoTransformationAcceptedEvent.kt | 5 - .../webhooks/VideoTransformationErrorEvent.kt | 5 - .../webhooks/VideoTransformationReadyEvent.kt | 5 - 10 files changed, 3 insertions(+), 301 deletions(-) diff --git a/.stats.yml b/.stats.yml index 5d25590d..08185446 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-3d7da4b8ef2ed30aa32c4fb3e98e498e67402e91aaa5fd4c628fc080bfe82ea1.yml -openapi_spec_hash: aaa50fcbccec6f2cf1165f34bc6ac886 -config_hash: 9f8a678d9d4d06daec522e8deb49e3ad +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml +openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a +config_hash: 4e73c7e12a531edcd1366dab7eccc360 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt index a989564a..b5d18a24 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt @@ -18,11 +18,6 @@ import com.imagekit.api.errors.ImageKitInvalidDataException import java.util.Objects import java.util.Optional -/** - * Triggered when a new video transformation request is accepted for processing. This event confirms - * that ImageKit has received and queued your transformation request. Use this for debugging and - * tracking transformation lifecycle. - */ @JsonDeserialize(using = UnsafeUnwrapWebhookEvent.Deserializer::class) @JsonSerialize(using = UnsafeUnwrapWebhookEvent.Serializer::class) class UnsafeUnwrapWebhookEvent @@ -37,56 +32,24 @@ private constructor( private val _json: JsonValue? = null, ) { - /** - * Triggered when a new video transformation request is accepted for processing. This event - * confirms that ImageKit has received and queued your transformation request. Use this for - * debugging and tracking transformation lifecycle. - */ fun videoTransformationAccepted(): Optional = Optional.ofNullable(videoTransformationAccepted) - /** - * Triggered when video encoding is finished and the transformed resource is ready to be served. - * This is the key event to listen for - update your database or CMS flags when you receive this - * so your application can start showing the transformed video to users. - */ fun videoTransformationReady(): Optional = Optional.ofNullable(videoTransformationReady) - /** - * Triggered when an error occurs during video encoding. Listen to this webhook to log error - * reasons and debug issues. Check your origin and URL endpoint settings if the reason is - * related to download failure. For other errors, contact ImageKit support. - */ fun videoTransformationError(): Optional = Optional.ofNullable(videoTransformationError) - /** - * Triggered when a pre-transformation completes successfully. The file has been processed with - * the requested transformation and is now available in the Media Library. - */ fun uploadPreTransformSuccess(): Optional = Optional.ofNullable(uploadPreTransformSuccess) - /** - * Triggered when a pre-transformation fails. The file upload may have been accepted, but the - * requested transformation could not be applied. - */ fun uploadPreTransformError(): Optional = Optional.ofNullable(uploadPreTransformError) - /** - * Triggered when a post-transformation completes successfully. The transformed version of the - * file is now ready and can be accessed via the provided URL. Note that each - * post-transformation generates a separate webhook event. - */ fun uploadPostTransformSuccess(): Optional = Optional.ofNullable(uploadPostTransformSuccess) - /** - * Triggered when a post-transformation fails. The original file remains available, but the - * requested transformation could not be generated. - */ fun uploadPostTransformError(): Optional = Optional.ofNullable(uploadPostTransformError) @@ -104,56 +67,24 @@ private constructor( fun isUploadPostTransformError(): Boolean = uploadPostTransformError != null - /** - * Triggered when a new video transformation request is accepted for processing. This event - * confirms that ImageKit has received and queued your transformation request. Use this for - * debugging and tracking transformation lifecycle. - */ fun asVideoTransformationAccepted(): VideoTransformationAcceptedEvent = videoTransformationAccepted.getOrThrow("videoTransformationAccepted") - /** - * Triggered when video encoding is finished and the transformed resource is ready to be served. - * This is the key event to listen for - update your database or CMS flags when you receive this - * so your application can start showing the transformed video to users. - */ fun asVideoTransformationReady(): VideoTransformationReadyEvent = videoTransformationReady.getOrThrow("videoTransformationReady") - /** - * Triggered when an error occurs during video encoding. Listen to this webhook to log error - * reasons and debug issues. Check your origin and URL endpoint settings if the reason is - * related to download failure. For other errors, contact ImageKit support. - */ fun asVideoTransformationError(): VideoTransformationErrorEvent = videoTransformationError.getOrThrow("videoTransformationError") - /** - * Triggered when a pre-transformation completes successfully. The file has been processed with - * the requested transformation and is now available in the Media Library. - */ fun asUploadPreTransformSuccess(): UploadPreTransformSuccessEvent = uploadPreTransformSuccess.getOrThrow("uploadPreTransformSuccess") - /** - * Triggered when a pre-transformation fails. The file upload may have been accepted, but the - * requested transformation could not be applied. - */ fun asUploadPreTransformError(): UploadPreTransformErrorEvent = uploadPreTransformError.getOrThrow("uploadPreTransformError") - /** - * Triggered when a post-transformation completes successfully. The transformed version of the - * file is now ready and can be accessed via the provided URL. Note that each - * post-transformation generates a separate webhook event. - */ fun asUploadPostTransformSuccess(): UploadPostTransformSuccessEvent = uploadPostTransformSuccess.getOrThrow("uploadPostTransformSuccess") - /** - * Triggered when a post-transformation fails. The original file remains available, but the - * requested transformation could not be generated. - */ fun asUploadPostTransformError(): UploadPostTransformErrorEvent = uploadPostTransformError.getOrThrow("uploadPostTransformError") @@ -330,64 +261,32 @@ private constructor( companion object { - /** - * Triggered when a new video transformation request is accepted for processing. This event - * confirms that ImageKit has received and queued your transformation request. Use this for - * debugging and tracking transformation lifecycle. - */ @JvmStatic fun ofVideoTransformationAccepted( videoTransformationAccepted: VideoTransformationAcceptedEvent ) = UnsafeUnwrapWebhookEvent(videoTransformationAccepted = videoTransformationAccepted) - /** - * Triggered when video encoding is finished and the transformed resource is ready to be - * served. This is the key event to listen for - update your database or CMS flags when you - * receive this so your application can start showing the transformed video to users. - */ @JvmStatic fun ofVideoTransformationReady(videoTransformationReady: VideoTransformationReadyEvent) = UnsafeUnwrapWebhookEvent(videoTransformationReady = videoTransformationReady) - /** - * Triggered when an error occurs during video encoding. Listen to this webhook to log error - * reasons and debug issues. Check your origin and URL endpoint settings if the reason is - * related to download failure. For other errors, contact ImageKit support. - */ @JvmStatic fun ofVideoTransformationError(videoTransformationError: VideoTransformationErrorEvent) = UnsafeUnwrapWebhookEvent(videoTransformationError = videoTransformationError) - /** - * Triggered when a pre-transformation completes successfully. The file has been processed - * with the requested transformation and is now available in the Media Library. - */ @JvmStatic fun ofUploadPreTransformSuccess(uploadPreTransformSuccess: UploadPreTransformSuccessEvent) = UnsafeUnwrapWebhookEvent(uploadPreTransformSuccess = uploadPreTransformSuccess) - /** - * Triggered when a pre-transformation fails. The file upload may have been accepted, but - * the requested transformation could not be applied. - */ @JvmStatic fun ofUploadPreTransformError(uploadPreTransformError: UploadPreTransformErrorEvent) = UnsafeUnwrapWebhookEvent(uploadPreTransformError = uploadPreTransformError) - /** - * Triggered when a post-transformation completes successfully. The transformed version of - * the file is now ready and can be accessed via the provided URL. Note that each - * post-transformation generates a separate webhook event. - */ @JvmStatic fun ofUploadPostTransformSuccess( uploadPostTransformSuccess: UploadPostTransformSuccessEvent ) = UnsafeUnwrapWebhookEvent(uploadPostTransformSuccess = uploadPostTransformSuccess) - /** - * Triggered when a post-transformation fails. The original file remains available, but the - * requested transformation could not be generated. - */ @JvmStatic fun ofUploadPostTransformError(uploadPostTransformError: UploadPostTransformErrorEvent) = UnsafeUnwrapWebhookEvent(uploadPostTransformError = uploadPostTransformError) @@ -399,60 +298,28 @@ private constructor( */ interface Visitor { - /** - * Triggered when a new video transformation request is accepted for processing. This event - * confirms that ImageKit has received and queued your transformation request. Use this for - * debugging and tracking transformation lifecycle. - */ fun visitVideoTransformationAccepted( videoTransformationAccepted: VideoTransformationAcceptedEvent ): T - /** - * Triggered when video encoding is finished and the transformed resource is ready to be - * served. This is the key event to listen for - update your database or CMS flags when you - * receive this so your application can start showing the transformed video to users. - */ fun visitVideoTransformationReady( videoTransformationReady: VideoTransformationReadyEvent ): T - /** - * Triggered when an error occurs during video encoding. Listen to this webhook to log error - * reasons and debug issues. Check your origin and URL endpoint settings if the reason is - * related to download failure. For other errors, contact ImageKit support. - */ fun visitVideoTransformationError( videoTransformationError: VideoTransformationErrorEvent ): T - /** - * Triggered when a pre-transformation completes successfully. The file has been processed - * with the requested transformation and is now available in the Media Library. - */ fun visitUploadPreTransformSuccess( uploadPreTransformSuccess: UploadPreTransformSuccessEvent ): T - /** - * Triggered when a pre-transformation fails. The file upload may have been accepted, but - * the requested transformation could not be applied. - */ fun visitUploadPreTransformError(uploadPreTransformError: UploadPreTransformErrorEvent): T - /** - * Triggered when a post-transformation completes successfully. The transformed version of - * the file is now ready and can be accessed via the provided URL. Note that each - * post-transformation generates a separate webhook event. - */ fun visitUploadPostTransformSuccess( uploadPostTransformSuccess: UploadPostTransformSuccessEvent ): T - /** - * Triggered when a post-transformation fails. The original file remains available, but the - * requested transformation could not be generated. - */ fun visitUploadPostTransformError( uploadPostTransformError: UploadPostTransformErrorEvent ): T diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt index 8e1eab97..bb1358bb 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt @@ -18,11 +18,6 @@ import com.imagekit.api.errors.ImageKitInvalidDataException import java.util.Objects import java.util.Optional -/** - * Triggered when a new video transformation request is accepted for processing. This event confirms - * that ImageKit has received and queued your transformation request. Use this for debugging and - * tracking transformation lifecycle. - */ @JsonDeserialize(using = UnwrapWebhookEvent.Deserializer::class) @JsonSerialize(using = UnwrapWebhookEvent.Serializer::class) class UnwrapWebhookEvent @@ -37,56 +32,24 @@ private constructor( private val _json: JsonValue? = null, ) { - /** - * Triggered when a new video transformation request is accepted for processing. This event - * confirms that ImageKit has received and queued your transformation request. Use this for - * debugging and tracking transformation lifecycle. - */ fun videoTransformationAccepted(): Optional = Optional.ofNullable(videoTransformationAccepted) - /** - * Triggered when video encoding is finished and the transformed resource is ready to be served. - * This is the key event to listen for - update your database or CMS flags when you receive this - * so your application can start showing the transformed video to users. - */ fun videoTransformationReady(): Optional = Optional.ofNullable(videoTransformationReady) - /** - * Triggered when an error occurs during video encoding. Listen to this webhook to log error - * reasons and debug issues. Check your origin and URL endpoint settings if the reason is - * related to download failure. For other errors, contact ImageKit support. - */ fun videoTransformationError(): Optional = Optional.ofNullable(videoTransformationError) - /** - * Triggered when a pre-transformation completes successfully. The file has been processed with - * the requested transformation and is now available in the Media Library. - */ fun uploadPreTransformSuccess(): Optional = Optional.ofNullable(uploadPreTransformSuccess) - /** - * Triggered when a pre-transformation fails. The file upload may have been accepted, but the - * requested transformation could not be applied. - */ fun uploadPreTransformError(): Optional = Optional.ofNullable(uploadPreTransformError) - /** - * Triggered when a post-transformation completes successfully. The transformed version of the - * file is now ready and can be accessed via the provided URL. Note that each - * post-transformation generates a separate webhook event. - */ fun uploadPostTransformSuccess(): Optional = Optional.ofNullable(uploadPostTransformSuccess) - /** - * Triggered when a post-transformation fails. The original file remains available, but the - * requested transformation could not be generated. - */ fun uploadPostTransformError(): Optional = Optional.ofNullable(uploadPostTransformError) @@ -104,56 +67,24 @@ private constructor( fun isUploadPostTransformError(): Boolean = uploadPostTransformError != null - /** - * Triggered when a new video transformation request is accepted for processing. This event - * confirms that ImageKit has received and queued your transformation request. Use this for - * debugging and tracking transformation lifecycle. - */ fun asVideoTransformationAccepted(): VideoTransformationAcceptedEvent = videoTransformationAccepted.getOrThrow("videoTransformationAccepted") - /** - * Triggered when video encoding is finished and the transformed resource is ready to be served. - * This is the key event to listen for - update your database or CMS flags when you receive this - * so your application can start showing the transformed video to users. - */ fun asVideoTransformationReady(): VideoTransformationReadyEvent = videoTransformationReady.getOrThrow("videoTransformationReady") - /** - * Triggered when an error occurs during video encoding. Listen to this webhook to log error - * reasons and debug issues. Check your origin and URL endpoint settings if the reason is - * related to download failure. For other errors, contact ImageKit support. - */ fun asVideoTransformationError(): VideoTransformationErrorEvent = videoTransformationError.getOrThrow("videoTransformationError") - /** - * Triggered when a pre-transformation completes successfully. The file has been processed with - * the requested transformation and is now available in the Media Library. - */ fun asUploadPreTransformSuccess(): UploadPreTransformSuccessEvent = uploadPreTransformSuccess.getOrThrow("uploadPreTransformSuccess") - /** - * Triggered when a pre-transformation fails. The file upload may have been accepted, but the - * requested transformation could not be applied. - */ fun asUploadPreTransformError(): UploadPreTransformErrorEvent = uploadPreTransformError.getOrThrow("uploadPreTransformError") - /** - * Triggered when a post-transformation completes successfully. The transformed version of the - * file is now ready and can be accessed via the provided URL. Note that each - * post-transformation generates a separate webhook event. - */ fun asUploadPostTransformSuccess(): UploadPostTransformSuccessEvent = uploadPostTransformSuccess.getOrThrow("uploadPostTransformSuccess") - /** - * Triggered when a post-transformation fails. The original file remains available, but the - * requested transformation could not be generated. - */ fun asUploadPostTransformError(): UploadPostTransformErrorEvent = uploadPostTransformError.getOrThrow("uploadPostTransformError") @@ -330,64 +261,32 @@ private constructor( companion object { - /** - * Triggered when a new video transformation request is accepted for processing. This event - * confirms that ImageKit has received and queued your transformation request. Use this for - * debugging and tracking transformation lifecycle. - */ @JvmStatic fun ofVideoTransformationAccepted( videoTransformationAccepted: VideoTransformationAcceptedEvent ) = UnwrapWebhookEvent(videoTransformationAccepted = videoTransformationAccepted) - /** - * Triggered when video encoding is finished and the transformed resource is ready to be - * served. This is the key event to listen for - update your database or CMS flags when you - * receive this so your application can start showing the transformed video to users. - */ @JvmStatic fun ofVideoTransformationReady(videoTransformationReady: VideoTransformationReadyEvent) = UnwrapWebhookEvent(videoTransformationReady = videoTransformationReady) - /** - * Triggered when an error occurs during video encoding. Listen to this webhook to log error - * reasons and debug issues. Check your origin and URL endpoint settings if the reason is - * related to download failure. For other errors, contact ImageKit support. - */ @JvmStatic fun ofVideoTransformationError(videoTransformationError: VideoTransformationErrorEvent) = UnwrapWebhookEvent(videoTransformationError = videoTransformationError) - /** - * Triggered when a pre-transformation completes successfully. The file has been processed - * with the requested transformation and is now available in the Media Library. - */ @JvmStatic fun ofUploadPreTransformSuccess(uploadPreTransformSuccess: UploadPreTransformSuccessEvent) = UnwrapWebhookEvent(uploadPreTransformSuccess = uploadPreTransformSuccess) - /** - * Triggered when a pre-transformation fails. The file upload may have been accepted, but - * the requested transformation could not be applied. - */ @JvmStatic fun ofUploadPreTransformError(uploadPreTransformError: UploadPreTransformErrorEvent) = UnwrapWebhookEvent(uploadPreTransformError = uploadPreTransformError) - /** - * Triggered when a post-transformation completes successfully. The transformed version of - * the file is now ready and can be accessed via the provided URL. Note that each - * post-transformation generates a separate webhook event. - */ @JvmStatic fun ofUploadPostTransformSuccess( uploadPostTransformSuccess: UploadPostTransformSuccessEvent ) = UnwrapWebhookEvent(uploadPostTransformSuccess = uploadPostTransformSuccess) - /** - * Triggered when a post-transformation fails. The original file remains available, but the - * requested transformation could not be generated. - */ @JvmStatic fun ofUploadPostTransformError(uploadPostTransformError: UploadPostTransformErrorEvent) = UnwrapWebhookEvent(uploadPostTransformError = uploadPostTransformError) @@ -399,60 +298,28 @@ private constructor( */ interface Visitor { - /** - * Triggered when a new video transformation request is accepted for processing. This event - * confirms that ImageKit has received and queued your transformation request. Use this for - * debugging and tracking transformation lifecycle. - */ fun visitVideoTransformationAccepted( videoTransformationAccepted: VideoTransformationAcceptedEvent ): T - /** - * Triggered when video encoding is finished and the transformed resource is ready to be - * served. This is the key event to listen for - update your database or CMS flags when you - * receive this so your application can start showing the transformed video to users. - */ fun visitVideoTransformationReady( videoTransformationReady: VideoTransformationReadyEvent ): T - /** - * Triggered when an error occurs during video encoding. Listen to this webhook to log error - * reasons and debug issues. Check your origin and URL endpoint settings if the reason is - * related to download failure. For other errors, contact ImageKit support. - */ fun visitVideoTransformationError( videoTransformationError: VideoTransformationErrorEvent ): T - /** - * Triggered when a pre-transformation completes successfully. The file has been processed - * with the requested transformation and is now available in the Media Library. - */ fun visitUploadPreTransformSuccess( uploadPreTransformSuccess: UploadPreTransformSuccessEvent ): T - /** - * Triggered when a pre-transformation fails. The file upload may have been accepted, but - * the requested transformation could not be applied. - */ fun visitUploadPreTransformError(uploadPreTransformError: UploadPreTransformErrorEvent): T - /** - * Triggered when a post-transformation completes successfully. The transformed version of - * the file is now ready and can be accessed via the provided URL. Note that each - * post-transformation generates a separate webhook event. - */ fun visitUploadPostTransformSuccess( uploadPostTransformSuccess: UploadPostTransformSuccessEvent ): T - /** - * Triggered when a post-transformation fails. The original file remains available, but the - * requested transformation could not be generated. - */ fun visitUploadPostTransformError( uploadPostTransformError: UploadPostTransformErrorEvent ): T diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt index f1798541..88780b1f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt @@ -19,10 +19,6 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** - * Triggered when a post-transformation fails. The original file remains available, but the - * requested transformation could not be generated. - */ class UploadPostTransformErrorEvent private constructor( private val id: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt index ca9d87d3..9bf3dcf9 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt @@ -19,11 +19,6 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** - * Triggered when a post-transformation completes successfully. The transformed version of the file - * is now ready and can be accessed via the provided URL. Note that each post-transformation - * generates a separate webhook event. - */ class UploadPostTransformSuccessEvent private constructor( private val id: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt index 40bc5647..01cc8342 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt @@ -17,10 +17,6 @@ import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull -/** - * Triggered when a pre-transformation fails. The file upload may have been accepted, but the - * requested transformation could not be applied. - */ class UploadPreTransformErrorEvent private constructor( private val id: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt index 98121db9..74a446b6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt @@ -22,10 +22,6 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** - * Triggered when a pre-transformation completes successfully. The file has been processed with the - * requested transformation and is now available in the Media Library. - */ class UploadPreTransformSuccessEvent private constructor( private val id: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt index f31e7f90..ac927318 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt @@ -21,11 +21,6 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** - * Triggered when a new video transformation request is accepted for processing. This event confirms - * that ImageKit has received and queued your transformation request. Use this for debugging and - * tracking transformation lifecycle. - */ class VideoTransformationAcceptedEvent private constructor( private val id: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt index ee6f310c..f1403683 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt @@ -21,11 +21,6 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** - * Triggered when an error occurs during video encoding. Listen to this webhook to log error reasons - * and debug issues. Check your origin and URL endpoint settings if the reason is related to - * download failure. For other errors, contact ImageKit support. - */ class VideoTransformationErrorEvent private constructor( private val id: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt index 82654cde..82762ed6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt @@ -21,11 +21,6 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** - * Triggered when video encoding is finished and the transformed resource is ready to be served. - * This is the key event to listen for - update your database or CMS flags when you receive this so - * your application can start showing the transformed video to users. - */ class VideoTransformationReadyEvent private constructor( private val id: JsonField, From cbbd424da5ebd388dd6e3d8af7e38b7633ed0604 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Sep 2025 07:23:29 +0000 Subject: [PATCH 004/142] feat(api): manual updates --- .stats.yml | 2 +- .../api/models/webhooks/BaseWebhookEvent.kt | 209 ++++++++++++++++++ .../webhooks/UnsafeUnwrapWebhookEvent.kt | 133 +++++++++++ .../api/models/webhooks/UnwrapWebhookEvent.kt | 133 +++++++++++ .../webhooks/UploadPostTransformErrorEvent.kt | 86 +++---- .../UploadPostTransformSuccessEvent.kt | 87 ++++---- .../webhooks/UploadPreTransformErrorEvent.kt | 86 +++---- .../UploadPreTransformSuccessEvent.kt | 86 +++---- .../VideoTransformationAcceptedEvent.kt | 87 ++++---- .../webhooks/VideoTransformationErrorEvent.kt | 87 ++++---- .../webhooks/VideoTransformationReadyEvent.kt | 87 ++++---- .../models/webhooks/BaseWebhookEventTest.kt | 33 +++ .../webhooks/UnsafeUnwrapWebhookEventTest.kt | 14 ++ .../models/webhooks/UnwrapWebhookEventTest.kt | 14 ++ .../UploadPostTransformErrorEventTest.kt | 3 + .../UploadPostTransformSuccessEventTest.kt | 4 + .../UploadPreTransformErrorEventTest.kt | 3 + .../UploadPreTransformSuccessEventTest.kt | 3 + .../VideoTransformationAcceptedEventTest.kt | 4 + .../VideoTransformationErrorEventTest.kt | 3 + .../VideoTransformationReadyEventTest.kt | 3 + 21 files changed, 886 insertions(+), 281 deletions(-) create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/BaseWebhookEvent.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/BaseWebhookEventTest.kt diff --git a/.stats.yml b/.stats.yml index 08185446..52f982ba 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a -config_hash: 4e73c7e12a531edcd1366dab7eccc360 +config_hash: 08e12746cdca1c59c897cf2e50893c3c diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/BaseWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/BaseWebhookEvent.kt new file mode 100644 index 00000000..5b0e7ede --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/BaseWebhookEvent.kt @@ -0,0 +1,209 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects + +class BaseWebhookEvent +private constructor( + private val id: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(id, type, mutableMapOf()) + + /** + * Unique identifier for the event. + * + * @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") + + /** + * The type of webhook event. + * + * @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 type(): String = type.getRequired("type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BaseWebhookEvent]. + * + * The following fields are required: + * ```java + * .id() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BaseWebhookEvent]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(baseWebhookEvent: BaseWebhookEvent) = apply { + id = baseWebhookEvent.id + type = baseWebhookEvent.type + additionalProperties = baseWebhookEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the event. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The type of webhook event. */ + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BaseWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BaseWebhookEvent = + BaseWebhookEvent( + checkRequired("id", id), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BaseWebhookEvent = apply { + if (validated) { + return@apply + } + + id() + type() + 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 (type.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BaseWebhookEvent && + id == other.id && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BaseWebhookEvent{id=$id, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt index b5d18a24..a989564a 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt @@ -18,6 +18,11 @@ import com.imagekit.api.errors.ImageKitInvalidDataException import java.util.Objects import java.util.Optional +/** + * Triggered when a new video transformation request is accepted for processing. This event confirms + * that ImageKit has received and queued your transformation request. Use this for debugging and + * tracking transformation lifecycle. + */ @JsonDeserialize(using = UnsafeUnwrapWebhookEvent.Deserializer::class) @JsonSerialize(using = UnsafeUnwrapWebhookEvent.Serializer::class) class UnsafeUnwrapWebhookEvent @@ -32,24 +37,56 @@ private constructor( private val _json: JsonValue? = null, ) { + /** + * Triggered when a new video transformation request is accepted for processing. This event + * confirms that ImageKit has received and queued your transformation request. Use this for + * debugging and tracking transformation lifecycle. + */ fun videoTransformationAccepted(): Optional = Optional.ofNullable(videoTransformationAccepted) + /** + * Triggered when video encoding is finished and the transformed resource is ready to be served. + * This is the key event to listen for - update your database or CMS flags when you receive this + * so your application can start showing the transformed video to users. + */ fun videoTransformationReady(): Optional = Optional.ofNullable(videoTransformationReady) + /** + * Triggered when an error occurs during video encoding. Listen to this webhook to log error + * reasons and debug issues. Check your origin and URL endpoint settings if the reason is + * related to download failure. For other errors, contact ImageKit support. + */ fun videoTransformationError(): Optional = Optional.ofNullable(videoTransformationError) + /** + * Triggered when a pre-transformation completes successfully. The file has been processed with + * the requested transformation and is now available in the Media Library. + */ fun uploadPreTransformSuccess(): Optional = Optional.ofNullable(uploadPreTransformSuccess) + /** + * Triggered when a pre-transformation fails. The file upload may have been accepted, but the + * requested transformation could not be applied. + */ fun uploadPreTransformError(): Optional = Optional.ofNullable(uploadPreTransformError) + /** + * Triggered when a post-transformation completes successfully. The transformed version of the + * file is now ready and can be accessed via the provided URL. Note that each + * post-transformation generates a separate webhook event. + */ fun uploadPostTransformSuccess(): Optional = Optional.ofNullable(uploadPostTransformSuccess) + /** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ fun uploadPostTransformError(): Optional = Optional.ofNullable(uploadPostTransformError) @@ -67,24 +104,56 @@ private constructor( fun isUploadPostTransformError(): Boolean = uploadPostTransformError != null + /** + * Triggered when a new video transformation request is accepted for processing. This event + * confirms that ImageKit has received and queued your transformation request. Use this for + * debugging and tracking transformation lifecycle. + */ fun asVideoTransformationAccepted(): VideoTransformationAcceptedEvent = videoTransformationAccepted.getOrThrow("videoTransformationAccepted") + /** + * Triggered when video encoding is finished and the transformed resource is ready to be served. + * This is the key event to listen for - update your database or CMS flags when you receive this + * so your application can start showing the transformed video to users. + */ fun asVideoTransformationReady(): VideoTransformationReadyEvent = videoTransformationReady.getOrThrow("videoTransformationReady") + /** + * Triggered when an error occurs during video encoding. Listen to this webhook to log error + * reasons and debug issues. Check your origin and URL endpoint settings if the reason is + * related to download failure. For other errors, contact ImageKit support. + */ fun asVideoTransformationError(): VideoTransformationErrorEvent = videoTransformationError.getOrThrow("videoTransformationError") + /** + * Triggered when a pre-transformation completes successfully. The file has been processed with + * the requested transformation and is now available in the Media Library. + */ fun asUploadPreTransformSuccess(): UploadPreTransformSuccessEvent = uploadPreTransformSuccess.getOrThrow("uploadPreTransformSuccess") + /** + * Triggered when a pre-transformation fails. The file upload may have been accepted, but the + * requested transformation could not be applied. + */ fun asUploadPreTransformError(): UploadPreTransformErrorEvent = uploadPreTransformError.getOrThrow("uploadPreTransformError") + /** + * Triggered when a post-transformation completes successfully. The transformed version of the + * file is now ready and can be accessed via the provided URL. Note that each + * post-transformation generates a separate webhook event. + */ fun asUploadPostTransformSuccess(): UploadPostTransformSuccessEvent = uploadPostTransformSuccess.getOrThrow("uploadPostTransformSuccess") + /** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ fun asUploadPostTransformError(): UploadPostTransformErrorEvent = uploadPostTransformError.getOrThrow("uploadPostTransformError") @@ -261,32 +330,64 @@ private constructor( companion object { + /** + * Triggered when a new video transformation request is accepted for processing. This event + * confirms that ImageKit has received and queued your transformation request. Use this for + * debugging and tracking transformation lifecycle. + */ @JvmStatic fun ofVideoTransformationAccepted( videoTransformationAccepted: VideoTransformationAcceptedEvent ) = UnsafeUnwrapWebhookEvent(videoTransformationAccepted = videoTransformationAccepted) + /** + * Triggered when video encoding is finished and the transformed resource is ready to be + * served. This is the key event to listen for - update your database or CMS flags when you + * receive this so your application can start showing the transformed video to users. + */ @JvmStatic fun ofVideoTransformationReady(videoTransformationReady: VideoTransformationReadyEvent) = UnsafeUnwrapWebhookEvent(videoTransformationReady = videoTransformationReady) + /** + * Triggered when an error occurs during video encoding. Listen to this webhook to log error + * reasons and debug issues. Check your origin and URL endpoint settings if the reason is + * related to download failure. For other errors, contact ImageKit support. + */ @JvmStatic fun ofVideoTransformationError(videoTransformationError: VideoTransformationErrorEvent) = UnsafeUnwrapWebhookEvent(videoTransformationError = videoTransformationError) + /** + * Triggered when a pre-transformation completes successfully. The file has been processed + * with the requested transformation and is now available in the Media Library. + */ @JvmStatic fun ofUploadPreTransformSuccess(uploadPreTransformSuccess: UploadPreTransformSuccessEvent) = UnsafeUnwrapWebhookEvent(uploadPreTransformSuccess = uploadPreTransformSuccess) + /** + * Triggered when a pre-transformation fails. The file upload may have been accepted, but + * the requested transformation could not be applied. + */ @JvmStatic fun ofUploadPreTransformError(uploadPreTransformError: UploadPreTransformErrorEvent) = UnsafeUnwrapWebhookEvent(uploadPreTransformError = uploadPreTransformError) + /** + * Triggered when a post-transformation completes successfully. The transformed version of + * the file is now ready and can be accessed via the provided URL. Note that each + * post-transformation generates a separate webhook event. + */ @JvmStatic fun ofUploadPostTransformSuccess( uploadPostTransformSuccess: UploadPostTransformSuccessEvent ) = UnsafeUnwrapWebhookEvent(uploadPostTransformSuccess = uploadPostTransformSuccess) + /** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ @JvmStatic fun ofUploadPostTransformError(uploadPostTransformError: UploadPostTransformErrorEvent) = UnsafeUnwrapWebhookEvent(uploadPostTransformError = uploadPostTransformError) @@ -298,28 +399,60 @@ private constructor( */ interface Visitor { + /** + * Triggered when a new video transformation request is accepted for processing. This event + * confirms that ImageKit has received and queued your transformation request. Use this for + * debugging and tracking transformation lifecycle. + */ fun visitVideoTransformationAccepted( videoTransformationAccepted: VideoTransformationAcceptedEvent ): T + /** + * Triggered when video encoding is finished and the transformed resource is ready to be + * served. This is the key event to listen for - update your database or CMS flags when you + * receive this so your application can start showing the transformed video to users. + */ fun visitVideoTransformationReady( videoTransformationReady: VideoTransformationReadyEvent ): T + /** + * Triggered when an error occurs during video encoding. Listen to this webhook to log error + * reasons and debug issues. Check your origin and URL endpoint settings if the reason is + * related to download failure. For other errors, contact ImageKit support. + */ fun visitVideoTransformationError( videoTransformationError: VideoTransformationErrorEvent ): T + /** + * Triggered when a pre-transformation completes successfully. The file has been processed + * with the requested transformation and is now available in the Media Library. + */ fun visitUploadPreTransformSuccess( uploadPreTransformSuccess: UploadPreTransformSuccessEvent ): T + /** + * Triggered when a pre-transformation fails. The file upload may have been accepted, but + * the requested transformation could not be applied. + */ fun visitUploadPreTransformError(uploadPreTransformError: UploadPreTransformErrorEvent): T + /** + * Triggered when a post-transformation completes successfully. The transformed version of + * the file is now ready and can be accessed via the provided URL. Note that each + * post-transformation generates a separate webhook event. + */ fun visitUploadPostTransformSuccess( uploadPostTransformSuccess: UploadPostTransformSuccessEvent ): T + /** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ fun visitUploadPostTransformError( uploadPostTransformError: UploadPostTransformErrorEvent ): T diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt index bb1358bb..8e1eab97 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt @@ -18,6 +18,11 @@ import com.imagekit.api.errors.ImageKitInvalidDataException import java.util.Objects import java.util.Optional +/** + * Triggered when a new video transformation request is accepted for processing. This event confirms + * that ImageKit has received and queued your transformation request. Use this for debugging and + * tracking transformation lifecycle. + */ @JsonDeserialize(using = UnwrapWebhookEvent.Deserializer::class) @JsonSerialize(using = UnwrapWebhookEvent.Serializer::class) class UnwrapWebhookEvent @@ -32,24 +37,56 @@ private constructor( private val _json: JsonValue? = null, ) { + /** + * Triggered when a new video transformation request is accepted for processing. This event + * confirms that ImageKit has received and queued your transformation request. Use this for + * debugging and tracking transformation lifecycle. + */ fun videoTransformationAccepted(): Optional = Optional.ofNullable(videoTransformationAccepted) + /** + * Triggered when video encoding is finished and the transformed resource is ready to be served. + * This is the key event to listen for - update your database or CMS flags when you receive this + * so your application can start showing the transformed video to users. + */ fun videoTransformationReady(): Optional = Optional.ofNullable(videoTransformationReady) + /** + * Triggered when an error occurs during video encoding. Listen to this webhook to log error + * reasons and debug issues. Check your origin and URL endpoint settings if the reason is + * related to download failure. For other errors, contact ImageKit support. + */ fun videoTransformationError(): Optional = Optional.ofNullable(videoTransformationError) + /** + * Triggered when a pre-transformation completes successfully. The file has been processed with + * the requested transformation and is now available in the Media Library. + */ fun uploadPreTransformSuccess(): Optional = Optional.ofNullable(uploadPreTransformSuccess) + /** + * Triggered when a pre-transformation fails. The file upload may have been accepted, but the + * requested transformation could not be applied. + */ fun uploadPreTransformError(): Optional = Optional.ofNullable(uploadPreTransformError) + /** + * Triggered when a post-transformation completes successfully. The transformed version of the + * file is now ready and can be accessed via the provided URL. Note that each + * post-transformation generates a separate webhook event. + */ fun uploadPostTransformSuccess(): Optional = Optional.ofNullable(uploadPostTransformSuccess) + /** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ fun uploadPostTransformError(): Optional = Optional.ofNullable(uploadPostTransformError) @@ -67,24 +104,56 @@ private constructor( fun isUploadPostTransformError(): Boolean = uploadPostTransformError != null + /** + * Triggered when a new video transformation request is accepted for processing. This event + * confirms that ImageKit has received and queued your transformation request. Use this for + * debugging and tracking transformation lifecycle. + */ fun asVideoTransformationAccepted(): VideoTransformationAcceptedEvent = videoTransformationAccepted.getOrThrow("videoTransformationAccepted") + /** + * Triggered when video encoding is finished and the transformed resource is ready to be served. + * This is the key event to listen for - update your database or CMS flags when you receive this + * so your application can start showing the transformed video to users. + */ fun asVideoTransformationReady(): VideoTransformationReadyEvent = videoTransformationReady.getOrThrow("videoTransformationReady") + /** + * Triggered when an error occurs during video encoding. Listen to this webhook to log error + * reasons and debug issues. Check your origin and URL endpoint settings if the reason is + * related to download failure. For other errors, contact ImageKit support. + */ fun asVideoTransformationError(): VideoTransformationErrorEvent = videoTransformationError.getOrThrow("videoTransformationError") + /** + * Triggered when a pre-transformation completes successfully. The file has been processed with + * the requested transformation and is now available in the Media Library. + */ fun asUploadPreTransformSuccess(): UploadPreTransformSuccessEvent = uploadPreTransformSuccess.getOrThrow("uploadPreTransformSuccess") + /** + * Triggered when a pre-transformation fails. The file upload may have been accepted, but the + * requested transformation could not be applied. + */ fun asUploadPreTransformError(): UploadPreTransformErrorEvent = uploadPreTransformError.getOrThrow("uploadPreTransformError") + /** + * Triggered when a post-transformation completes successfully. The transformed version of the + * file is now ready and can be accessed via the provided URL. Note that each + * post-transformation generates a separate webhook event. + */ fun asUploadPostTransformSuccess(): UploadPostTransformSuccessEvent = uploadPostTransformSuccess.getOrThrow("uploadPostTransformSuccess") + /** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ fun asUploadPostTransformError(): UploadPostTransformErrorEvent = uploadPostTransformError.getOrThrow("uploadPostTransformError") @@ -261,32 +330,64 @@ private constructor( companion object { + /** + * Triggered when a new video transformation request is accepted for processing. This event + * confirms that ImageKit has received and queued your transformation request. Use this for + * debugging and tracking transformation lifecycle. + */ @JvmStatic fun ofVideoTransformationAccepted( videoTransformationAccepted: VideoTransformationAcceptedEvent ) = UnwrapWebhookEvent(videoTransformationAccepted = videoTransformationAccepted) + /** + * Triggered when video encoding is finished and the transformed resource is ready to be + * served. This is the key event to listen for - update your database or CMS flags when you + * receive this so your application can start showing the transformed video to users. + */ @JvmStatic fun ofVideoTransformationReady(videoTransformationReady: VideoTransformationReadyEvent) = UnwrapWebhookEvent(videoTransformationReady = videoTransformationReady) + /** + * Triggered when an error occurs during video encoding. Listen to this webhook to log error + * reasons and debug issues. Check your origin and URL endpoint settings if the reason is + * related to download failure. For other errors, contact ImageKit support. + */ @JvmStatic fun ofVideoTransformationError(videoTransformationError: VideoTransformationErrorEvent) = UnwrapWebhookEvent(videoTransformationError = videoTransformationError) + /** + * Triggered when a pre-transformation completes successfully. The file has been processed + * with the requested transformation and is now available in the Media Library. + */ @JvmStatic fun ofUploadPreTransformSuccess(uploadPreTransformSuccess: UploadPreTransformSuccessEvent) = UnwrapWebhookEvent(uploadPreTransformSuccess = uploadPreTransformSuccess) + /** + * Triggered when a pre-transformation fails. The file upload may have been accepted, but + * the requested transformation could not be applied. + */ @JvmStatic fun ofUploadPreTransformError(uploadPreTransformError: UploadPreTransformErrorEvent) = UnwrapWebhookEvent(uploadPreTransformError = uploadPreTransformError) + /** + * Triggered when a post-transformation completes successfully. The transformed version of + * the file is now ready and can be accessed via the provided URL. Note that each + * post-transformation generates a separate webhook event. + */ @JvmStatic fun ofUploadPostTransformSuccess( uploadPostTransformSuccess: UploadPostTransformSuccessEvent ) = UnwrapWebhookEvent(uploadPostTransformSuccess = uploadPostTransformSuccess) + /** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ @JvmStatic fun ofUploadPostTransformError(uploadPostTransformError: UploadPostTransformErrorEvent) = UnwrapWebhookEvent(uploadPostTransformError = uploadPostTransformError) @@ -298,28 +399,60 @@ private constructor( */ interface Visitor { + /** + * Triggered when a new video transformation request is accepted for processing. This event + * confirms that ImageKit has received and queued your transformation request. Use this for + * debugging and tracking transformation lifecycle. + */ fun visitVideoTransformationAccepted( videoTransformationAccepted: VideoTransformationAcceptedEvent ): T + /** + * Triggered when video encoding is finished and the transformed resource is ready to be + * served. This is the key event to listen for - update your database or CMS flags when you + * receive this so your application can start showing the transformed video to users. + */ fun visitVideoTransformationReady( videoTransformationReady: VideoTransformationReadyEvent ): T + /** + * Triggered when an error occurs during video encoding. Listen to this webhook to log error + * reasons and debug issues. Check your origin and URL endpoint settings if the reason is + * related to download failure. For other errors, contact ImageKit support. + */ fun visitVideoTransformationError( videoTransformationError: VideoTransformationErrorEvent ): T + /** + * Triggered when a pre-transformation completes successfully. The file has been processed + * with the requested transformation and is now available in the Media Library. + */ fun visitUploadPreTransformSuccess( uploadPreTransformSuccess: UploadPreTransformSuccessEvent ): T + /** + * Triggered when a pre-transformation fails. The file upload may have been accepted, but + * the requested transformation could not be applied. + */ fun visitUploadPreTransformError(uploadPreTransformError: UploadPreTransformErrorEvent): T + /** + * Triggered when a post-transformation completes successfully. The transformed version of + * the file is now ready and can be accessed via the provided URL. Note that each + * post-transformation generates a separate webhook event. + */ fun visitUploadPostTransformSuccess( uploadPostTransformSuccess: UploadPostTransformSuccessEvent ): T + /** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ fun visitUploadPostTransformError( uploadPostTransformError: UploadPostTransformErrorEvent ): T diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt index 88780b1f..d5ec74e4 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt @@ -19,26 +19,33 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** + * Triggered when a post-transformation fails. The original file remains available, but the + * requested transformation could not be generated. + */ class UploadPostTransformErrorEvent private constructor( private val id: JsonField, + private val type: JsonField, private val createdAt: JsonField, private val data: JsonField, private val request: JsonField, - private val type: JsonValue, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), @JsonProperty("request") @ExcludeMissing request: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - ) : this(id, createdAt, data, request, type, mutableMapOf()) + ) : this(id, type, createdAt, data, request, mutableMapOf()) + + fun toBaseWebhookEvent(): BaseWebhookEvent = + BaseWebhookEvent.builder().id(id).type(type).build() /** * Unique identifier for the event. @@ -48,6 +55,14 @@ private constructor( */ fun id(): String = id.getRequired("id") + /** + * The type of webhook event. + * + * @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 type(): String = type.getRequired("type") + /** * Timestamp of when the event occurred in ISO8601 format. * @@ -69,22 +84,18 @@ private constructor( fun request(): Request = request.getRequired("request") /** - * Expected to always return the following: - * ```java - * JsonValue.from("upload.post-transform.error") - * ``` + * Returns the raw JSON value of [id]. * - * However, this method can be useful for debugging and logging (e.g. if the server responded - * with an unexpected value). + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [type]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** * Returns the raw JSON value of [createdAt]. @@ -130,6 +141,7 @@ private constructor( * The following fields are required: * ```java * .id() + * .type() * .createdAt() * .data() * .request() @@ -142,19 +154,19 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null + private var type: JsonField? = null private var createdAt: JsonField? = null private var data: JsonField? = null private var request: JsonField? = null - private var type: JsonValue = JsonValue.from("upload.post-transform.error") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(uploadPostTransformErrorEvent: UploadPostTransformErrorEvent) = apply { id = uploadPostTransformErrorEvent.id + type = uploadPostTransformErrorEvent.type createdAt = uploadPostTransformErrorEvent.createdAt data = uploadPostTransformErrorEvent.data request = uploadPostTransformErrorEvent.request - type = uploadPostTransformErrorEvent.type additionalProperties = uploadPostTransformErrorEvent.additionalProperties.toMutableMap() } @@ -169,6 +181,17 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** The type of webhook event. */ + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + /** Timestamp of when the event occurred in ISO8601 format. */ fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) @@ -201,20 +224,6 @@ private constructor( */ fun request(request: JsonField) = apply { this.request = request } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from("upload.post-transform.error") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonValue) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -242,6 +251,7 @@ private constructor( * The following fields are required: * ```java * .id() + * .type() * .createdAt() * .data() * .request() @@ -252,10 +262,10 @@ private constructor( fun build(): UploadPostTransformErrorEvent = UploadPostTransformErrorEvent( checkRequired("id", id), + checkRequired("type", type), checkRequired("createdAt", createdAt), checkRequired("data", data), checkRequired("request", request), - type, additionalProperties.toMutableMap(), ) } @@ -268,14 +278,10 @@ private constructor( } id() + type() createdAt() data().validate() request().validate() - _type().let { - if (it != JsonValue.from("upload.post-transform.error")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } validated = true } @@ -295,10 +301,10 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (data.asKnown().getOrNull()?.validity() ?: 0) + - (request.asKnown().getOrNull()?.validity() ?: 0) + - type.let { if (it == JsonValue.from("upload.post-transform.error")) 1 else 0 } + (request.asKnown().getOrNull()?.validity() ?: 0) class Data private constructor( @@ -1669,19 +1675,19 @@ private constructor( return other is UploadPostTransformErrorEvent && id == other.id && + type == other.type && createdAt == other.createdAt && data == other.data && request == other.request && - type == other.type && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, createdAt, data, request, type, additionalProperties) + Objects.hash(id, type, createdAt, data, request, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "UploadPostTransformErrorEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" + "UploadPostTransformErrorEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, request=$request, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt index 9bf3dcf9..78cc1df5 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt @@ -19,26 +19,34 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** + * Triggered when a post-transformation completes successfully. The transformed version of the file + * is now ready and can be accessed via the provided URL. Note that each post-transformation + * generates a separate webhook event. + */ class UploadPostTransformSuccessEvent private constructor( private val id: JsonField, + private val type: JsonField, private val createdAt: JsonField, private val data: JsonField, private val request: JsonField, - private val type: JsonValue, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), @JsonProperty("request") @ExcludeMissing request: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - ) : this(id, createdAt, data, request, type, mutableMapOf()) + ) : this(id, type, createdAt, data, request, mutableMapOf()) + + fun toBaseWebhookEvent(): BaseWebhookEvent = + BaseWebhookEvent.builder().id(id).type(type).build() /** * Unique identifier for the event. @@ -48,6 +56,14 @@ private constructor( */ fun id(): String = id.getRequired("id") + /** + * The type of webhook event. + * + * @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 type(): String = type.getRequired("type") + /** * Timestamp of when the event occurred in ISO8601 format. * @@ -69,22 +85,18 @@ private constructor( fun request(): Request = request.getRequired("request") /** - * Expected to always return the following: - * ```java - * JsonValue.from("upload.post-transform.success") - * ``` + * Returns the raw JSON value of [id]. * - * However, this method can be useful for debugging and logging (e.g. if the server responded - * with an unexpected value). + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [type]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** * Returns the raw JSON value of [createdAt]. @@ -130,6 +142,7 @@ private constructor( * The following fields are required: * ```java * .id() + * .type() * .createdAt() * .data() * .request() @@ -142,20 +155,20 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null + private var type: JsonField? = null private var createdAt: JsonField? = null private var data: JsonField? = null private var request: JsonField? = null - private var type: JsonValue = JsonValue.from("upload.post-transform.success") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(uploadPostTransformSuccessEvent: UploadPostTransformSuccessEvent) = apply { id = uploadPostTransformSuccessEvent.id + type = uploadPostTransformSuccessEvent.type createdAt = uploadPostTransformSuccessEvent.createdAt data = uploadPostTransformSuccessEvent.data request = uploadPostTransformSuccessEvent.request - type = uploadPostTransformSuccessEvent.type additionalProperties = uploadPostTransformSuccessEvent.additionalProperties.toMutableMap() } @@ -171,6 +184,17 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** The type of webhook event. */ + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + /** Timestamp of when the event occurred in ISO8601 format. */ fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) @@ -203,20 +227,6 @@ private constructor( */ fun request(request: JsonField) = apply { this.request = request } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from("upload.post-transform.success") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonValue) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -244,6 +254,7 @@ private constructor( * The following fields are required: * ```java * .id() + * .type() * .createdAt() * .data() * .request() @@ -254,10 +265,10 @@ private constructor( fun build(): UploadPostTransformSuccessEvent = UploadPostTransformSuccessEvent( checkRequired("id", id), + checkRequired("type", type), checkRequired("createdAt", createdAt), checkRequired("data", data), checkRequired("request", request), - type, additionalProperties.toMutableMap(), ) } @@ -270,14 +281,10 @@ private constructor( } id() + type() createdAt() data().validate() request().validate() - _type().let { - if (it != JsonValue.from("upload.post-transform.success")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } validated = true } @@ -297,10 +304,10 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (data.asKnown().getOrNull()?.validity() ?: 0) + - (request.asKnown().getOrNull()?.validity() ?: 0) + - type.let { if (it == JsonValue.from("upload.post-transform.success")) 1 else 0 } + (request.asKnown().getOrNull()?.validity() ?: 0) class Data private constructor( @@ -1267,19 +1274,19 @@ private constructor( return other is UploadPostTransformSuccessEvent && id == other.id && + type == other.type && createdAt == other.createdAt && data == other.data && request == other.request && - type == other.type && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, createdAt, data, request, type, additionalProperties) + Objects.hash(id, type, createdAt, data, request, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "UploadPostTransformSuccessEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" + "UploadPostTransformSuccessEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, request=$request, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt index 01cc8342..50655f34 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt @@ -17,26 +17,33 @@ import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull +/** + * Triggered when a pre-transformation fails. The file upload may have been accepted, but the + * requested transformation could not be applied. + */ class UploadPreTransformErrorEvent private constructor( private val id: JsonField, + private val type: JsonField, private val createdAt: JsonField, private val data: JsonField, private val request: JsonField, - private val type: JsonValue, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), @JsonProperty("request") @ExcludeMissing request: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - ) : this(id, createdAt, data, request, type, mutableMapOf()) + ) : this(id, type, createdAt, data, request, mutableMapOf()) + + fun toBaseWebhookEvent(): BaseWebhookEvent = + BaseWebhookEvent.builder().id(id).type(type).build() /** * Unique identifier for the event. @@ -46,6 +53,14 @@ private constructor( */ fun id(): String = id.getRequired("id") + /** + * The type of webhook event. + * + * @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 type(): String = type.getRequired("type") + /** * Timestamp of when the event occurred in ISO8601 format. * @@ -67,22 +82,18 @@ private constructor( fun request(): Request = request.getRequired("request") /** - * Expected to always return the following: - * ```java - * JsonValue.from("upload.pre-transform.error") - * ``` + * Returns the raw JSON value of [id]. * - * However, this method can be useful for debugging and logging (e.g. if the server responded - * with an unexpected value). + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [type]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** * Returns the raw JSON value of [createdAt]. @@ -127,6 +138,7 @@ private constructor( * The following fields are required: * ```java * .id() + * .type() * .createdAt() * .data() * .request() @@ -139,19 +151,19 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null + private var type: JsonField? = null private var createdAt: JsonField? = null private var data: JsonField? = null private var request: JsonField? = null - private var type: JsonValue = JsonValue.from("upload.pre-transform.error") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(uploadPreTransformErrorEvent: UploadPreTransformErrorEvent) = apply { id = uploadPreTransformErrorEvent.id + type = uploadPreTransformErrorEvent.type createdAt = uploadPreTransformErrorEvent.createdAt data = uploadPreTransformErrorEvent.data request = uploadPreTransformErrorEvent.request - type = uploadPreTransformErrorEvent.type additionalProperties = uploadPreTransformErrorEvent.additionalProperties.toMutableMap() } @@ -166,6 +178,17 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** The type of webhook event. */ + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + /** Timestamp of when the event occurred in ISO8601 format. */ fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) @@ -198,20 +221,6 @@ private constructor( */ fun request(request: JsonField) = apply { this.request = request } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from("upload.pre-transform.error") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonValue) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -239,6 +248,7 @@ private constructor( * The following fields are required: * ```java * .id() + * .type() * .createdAt() * .data() * .request() @@ -249,10 +259,10 @@ private constructor( fun build(): UploadPreTransformErrorEvent = UploadPreTransformErrorEvent( checkRequired("id", id), + checkRequired("type", type), checkRequired("createdAt", createdAt), checkRequired("data", data), checkRequired("request", request), - type, additionalProperties.toMutableMap(), ) } @@ -265,14 +275,10 @@ private constructor( } id() + type() createdAt() data().validate() request().validate() - _type().let { - if (it != JsonValue.from("upload.pre-transform.error")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } validated = true } @@ -292,10 +298,10 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (data.asKnown().getOrNull()?.validity() ?: 0) + - (request.asKnown().getOrNull()?.validity() ?: 0) + - type.let { if (it == JsonValue.from("upload.pre-transform.error")) 1 else 0 } + (request.asKnown().getOrNull()?.validity() ?: 0) class Data private constructor( @@ -1079,19 +1085,19 @@ private constructor( return other is UploadPreTransformErrorEvent && id == other.id && + type == other.type && createdAt == other.createdAt && data == other.data && request == other.request && - type == other.type && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, createdAt, data, request, type, additionalProperties) + Objects.hash(id, type, createdAt, data, request, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "UploadPreTransformErrorEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" + "UploadPreTransformErrorEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, request=$request, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt index 74a446b6..9c71f74b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt @@ -22,26 +22,33 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** + * Triggered when a pre-transformation completes successfully. The file has been processed with the + * requested transformation and is now available in the Media Library. + */ class UploadPreTransformSuccessEvent private constructor( private val id: JsonField, + private val type: JsonField, private val createdAt: JsonField, private val data: JsonField, private val request: JsonField, - private val type: JsonValue, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), @JsonProperty("request") @ExcludeMissing request: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - ) : this(id, createdAt, data, request, type, mutableMapOf()) + ) : this(id, type, createdAt, data, request, mutableMapOf()) + + fun toBaseWebhookEvent(): BaseWebhookEvent = + BaseWebhookEvent.builder().id(id).type(type).build() /** * Unique identifier for the event. @@ -51,6 +58,14 @@ private constructor( */ fun id(): String = id.getRequired("id") + /** + * The type of webhook event. + * + * @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 type(): String = type.getRequired("type") + /** * Timestamp of when the event occurred in ISO8601 format. * @@ -74,22 +89,18 @@ private constructor( fun request(): Request = request.getRequired("request") /** - * Expected to always return the following: - * ```java - * JsonValue.from("upload.pre-transform.success") - * ``` + * Returns the raw JSON value of [id]. * - * However, this method can be useful for debugging and logging (e.g. if the server responded - * with an unexpected value). + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [type]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** * Returns the raw JSON value of [createdAt]. @@ -135,6 +146,7 @@ private constructor( * The following fields are required: * ```java * .id() + * .type() * .createdAt() * .data() * .request() @@ -147,19 +159,19 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null + private var type: JsonField? = null private var createdAt: JsonField? = null private var data: JsonField? = null private var request: JsonField? = null - private var type: JsonValue = JsonValue.from("upload.pre-transform.success") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(uploadPreTransformSuccessEvent: UploadPreTransformSuccessEvent) = apply { id = uploadPreTransformSuccessEvent.id + type = uploadPreTransformSuccessEvent.type createdAt = uploadPreTransformSuccessEvent.createdAt data = uploadPreTransformSuccessEvent.data request = uploadPreTransformSuccessEvent.request - type = uploadPreTransformSuccessEvent.type additionalProperties = uploadPreTransformSuccessEvent.additionalProperties.toMutableMap() } @@ -175,6 +187,17 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** The type of webhook event. */ + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + /** Timestamp of when the event occurred in ISO8601 format. */ fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) @@ -208,20 +231,6 @@ private constructor( */ fun request(request: JsonField) = apply { this.request = request } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from("upload.pre-transform.success") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonValue) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -249,6 +258,7 @@ private constructor( * The following fields are required: * ```java * .id() + * .type() * .createdAt() * .data() * .request() @@ -259,10 +269,10 @@ private constructor( fun build(): UploadPreTransformSuccessEvent = UploadPreTransformSuccessEvent( checkRequired("id", id), + checkRequired("type", type), checkRequired("createdAt", createdAt), checkRequired("data", data), checkRequired("request", request), - type, additionalProperties.toMutableMap(), ) } @@ -275,14 +285,10 @@ private constructor( } id() + type() createdAt() data().validate() request().validate() - _type().let { - if (it != JsonValue.from("upload.pre-transform.success")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } validated = true } @@ -302,10 +308,10 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (data.asKnown().getOrNull()?.validity() ?: 0) + - (request.asKnown().getOrNull()?.validity() ?: 0) + - type.let { if (it == JsonValue.from("upload.pre-transform.success")) 1 else 0 } + (request.asKnown().getOrNull()?.validity() ?: 0) /** Object containing details of a successful upload. */ class Data @@ -3197,19 +3203,19 @@ private constructor( return other is UploadPreTransformSuccessEvent && id == other.id && + type == other.type && createdAt == other.createdAt && data == other.data && request == other.request && - type == other.type && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, createdAt, data, request, type, additionalProperties) + Objects.hash(id, type, createdAt, data, request, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "UploadPreTransformSuccessEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" + "UploadPreTransformSuccessEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, request=$request, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt index ac927318..61dbf8ac 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt @@ -21,26 +21,34 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** + * Triggered when a new video transformation request is accepted for processing. This event confirms + * that ImageKit has received and queued your transformation request. Use this for debugging and + * tracking transformation lifecycle. + */ class VideoTransformationAcceptedEvent private constructor( private val id: JsonField, + private val type: JsonField, private val createdAt: JsonField, private val data: JsonField, private val request: JsonField, - private val type: JsonValue, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), @JsonProperty("request") @ExcludeMissing request: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - ) : this(id, createdAt, data, request, type, mutableMapOf()) + ) : this(id, type, createdAt, data, request, mutableMapOf()) + + fun toBaseWebhookEvent(): BaseWebhookEvent = + BaseWebhookEvent.builder().id(id).type(type).build() /** * Unique identifier for the event. @@ -50,6 +58,14 @@ private constructor( */ fun id(): String = id.getRequired("id") + /** + * The type of webhook event. + * + * @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 type(): String = type.getRequired("type") + /** * Timestamp when the event was created in ISO8601 format. * @@ -73,22 +89,18 @@ private constructor( fun request(): Request = request.getRequired("request") /** - * Expected to always return the following: - * ```java - * JsonValue.from("video.transformation.accepted") - * ``` + * Returns the raw JSON value of [id]. * - * However, this method can be useful for debugging and logging (e.g. if the server responded - * with an unexpected value). + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [type]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** * Returns the raw JSON value of [createdAt]. @@ -134,6 +146,7 @@ private constructor( * The following fields are required: * ```java * .id() + * .type() * .createdAt() * .data() * .request() @@ -146,20 +159,20 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null + private var type: JsonField? = null private var createdAt: JsonField? = null private var data: JsonField? = null private var request: JsonField? = null - private var type: JsonValue = JsonValue.from("video.transformation.accepted") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(videoTransformationAcceptedEvent: VideoTransformationAcceptedEvent) = apply { id = videoTransformationAcceptedEvent.id + type = videoTransformationAcceptedEvent.type createdAt = videoTransformationAcceptedEvent.createdAt data = videoTransformationAcceptedEvent.data request = videoTransformationAcceptedEvent.request - type = videoTransformationAcceptedEvent.type additionalProperties = videoTransformationAcceptedEvent.additionalProperties.toMutableMap() } @@ -175,6 +188,17 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** The type of webhook event. */ + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + /** Timestamp when the event was created in ISO8601 format. */ fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) @@ -208,20 +232,6 @@ private constructor( */ fun request(request: JsonField) = apply { this.request = request } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from("video.transformation.accepted") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonValue) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -249,6 +259,7 @@ private constructor( * The following fields are required: * ```java * .id() + * .type() * .createdAt() * .data() * .request() @@ -259,10 +270,10 @@ private constructor( fun build(): VideoTransformationAcceptedEvent = VideoTransformationAcceptedEvent( checkRequired("id", id), + checkRequired("type", type), checkRequired("createdAt", createdAt), checkRequired("data", data), checkRequired("request", request), - type, additionalProperties.toMutableMap(), ) } @@ -275,14 +286,10 @@ private constructor( } id() + type() createdAt() data().validate() request().validate() - _type().let { - if (it != JsonValue.from("video.transformation.accepted")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } validated = true } @@ -302,10 +309,10 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (data.asKnown().getOrNull()?.validity() ?: 0) + - (request.asKnown().getOrNull()?.validity() ?: 0) + - type.let { if (it == JsonValue.from("video.transformation.accepted")) 1 else 0 } + (request.asKnown().getOrNull()?.validity() ?: 0) class Data private constructor( @@ -2280,19 +2287,19 @@ private constructor( return other is VideoTransformationAcceptedEvent && id == other.id && + type == other.type && createdAt == other.createdAt && data == other.data && request == other.request && - type == other.type && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, createdAt, data, request, type, additionalProperties) + Objects.hash(id, type, createdAt, data, request, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "VideoTransformationAcceptedEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" + "VideoTransformationAcceptedEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, request=$request, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt index f1403683..176f4000 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt @@ -21,26 +21,34 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** + * Triggered when an error occurs during video encoding. Listen to this webhook to log error reasons + * and debug issues. Check your origin and URL endpoint settings if the reason is related to + * download failure. For other errors, contact ImageKit support. + */ class VideoTransformationErrorEvent private constructor( private val id: JsonField, + private val type: JsonField, private val createdAt: JsonField, private val data: JsonField, private val request: JsonField, - private val type: JsonValue, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), @JsonProperty("request") @ExcludeMissing request: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - ) : this(id, createdAt, data, request, type, mutableMapOf()) + ) : this(id, type, createdAt, data, request, mutableMapOf()) + + fun toBaseWebhookEvent(): BaseWebhookEvent = + BaseWebhookEvent.builder().id(id).type(type).build() /** * Unique identifier for the event. @@ -50,6 +58,14 @@ private constructor( */ fun id(): String = id.getRequired("id") + /** + * The type of webhook event. + * + * @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 type(): String = type.getRequired("type") + /** * Timestamp when the event was created in ISO8601 format. * @@ -73,22 +89,18 @@ private constructor( fun request(): Request = request.getRequired("request") /** - * Expected to always return the following: - * ```java - * JsonValue.from("video.transformation.error") - * ``` + * Returns the raw JSON value of [id]. * - * However, this method can be useful for debugging and logging (e.g. if the server responded - * with an unexpected value). + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [type]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** * Returns the raw JSON value of [createdAt]. @@ -134,6 +146,7 @@ private constructor( * The following fields are required: * ```java * .id() + * .type() * .createdAt() * .data() * .request() @@ -146,19 +159,19 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null + private var type: JsonField? = null private var createdAt: JsonField? = null private var data: JsonField? = null private var request: JsonField? = null - private var type: JsonValue = JsonValue.from("video.transformation.error") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(videoTransformationErrorEvent: VideoTransformationErrorEvent) = apply { id = videoTransformationErrorEvent.id + type = videoTransformationErrorEvent.type createdAt = videoTransformationErrorEvent.createdAt data = videoTransformationErrorEvent.data request = videoTransformationErrorEvent.request - type = videoTransformationErrorEvent.type additionalProperties = videoTransformationErrorEvent.additionalProperties.toMutableMap() } @@ -173,6 +186,17 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** The type of webhook event. */ + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + /** Timestamp when the event was created in ISO8601 format. */ fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) @@ -206,20 +230,6 @@ private constructor( */ fun request(request: JsonField) = apply { this.request = request } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from("video.transformation.error") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonValue) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -247,6 +257,7 @@ private constructor( * The following fields are required: * ```java * .id() + * .type() * .createdAt() * .data() * .request() @@ -257,10 +268,10 @@ private constructor( fun build(): VideoTransformationErrorEvent = VideoTransformationErrorEvent( checkRequired("id", id), + checkRequired("type", type), checkRequired("createdAt", createdAt), checkRequired("data", data), checkRequired("request", request), - type, additionalProperties.toMutableMap(), ) } @@ -273,14 +284,10 @@ private constructor( } id() + type() createdAt() data().validate() request().validate() - _type().let { - if (it != JsonValue.from("video.transformation.error")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } validated = true } @@ -300,10 +307,10 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (data.asKnown().getOrNull()?.validity() ?: 0) + - (request.asKnown().getOrNull()?.validity() ?: 0) + - type.let { if (it == JsonValue.from("video.transformation.error")) 1 else 0 } + (request.asKnown().getOrNull()?.validity() ?: 0) class Data private constructor( @@ -2629,19 +2636,19 @@ private constructor( return other is VideoTransformationErrorEvent && id == other.id && + type == other.type && createdAt == other.createdAt && data == other.data && request == other.request && - type == other.type && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, createdAt, data, request, type, additionalProperties) + Objects.hash(id, type, createdAt, data, request, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "VideoTransformationErrorEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, additionalProperties=$additionalProperties}" + "VideoTransformationErrorEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, request=$request, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt index 82762ed6..005fceac 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt @@ -21,13 +21,18 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** + * Triggered when video encoding is finished and the transformed resource is ready to be served. + * This is the key event to listen for - update your database or CMS flags when you receive this so + * your application can start showing the transformed video to users. + */ class VideoTransformationReadyEvent private constructor( private val id: JsonField, + private val type: JsonField, private val createdAt: JsonField, private val data: JsonField, private val request: JsonField, - private val type: JsonValue, private val timings: JsonField, private val additionalProperties: MutableMap, ) { @@ -35,14 +40,17 @@ private constructor( @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), @JsonProperty("request") @ExcludeMissing request: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("timings") @ExcludeMissing timings: JsonField = JsonMissing.of(), - ) : this(id, createdAt, data, request, type, timings, mutableMapOf()) + ) : this(id, type, createdAt, data, request, timings, mutableMapOf()) + + fun toBaseWebhookEvent(): BaseWebhookEvent = + BaseWebhookEvent.builder().id(id).type(type).build() /** * Unique identifier for the event. @@ -52,6 +60,14 @@ private constructor( */ fun id(): String = id.getRequired("id") + /** + * The type of webhook event. + * + * @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 type(): String = type.getRequired("type") + /** * Timestamp when the event was created in ISO8601 format. * @@ -74,17 +90,6 @@ private constructor( */ fun request(): Request = request.getRequired("request") - /** - * Expected to always return the following: - * ```java - * JsonValue.from("video.transformation.ready") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server responded - * with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** * Performance metrics for the transformation process. * @@ -100,6 +105,13 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** * Returns the raw JSON value of [createdAt]. * @@ -151,6 +163,7 @@ private constructor( * The following fields are required: * ```java * .id() + * .type() * .createdAt() * .data() * .request() @@ -163,20 +176,20 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null + private var type: JsonField? = null private var createdAt: JsonField? = null private var data: JsonField? = null private var request: JsonField? = null - private var type: JsonValue = JsonValue.from("video.transformation.ready") private var timings: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(videoTransformationReadyEvent: VideoTransformationReadyEvent) = apply { id = videoTransformationReadyEvent.id + type = videoTransformationReadyEvent.type createdAt = videoTransformationReadyEvent.createdAt data = videoTransformationReadyEvent.data request = videoTransformationReadyEvent.request - type = videoTransformationReadyEvent.type timings = videoTransformationReadyEvent.timings additionalProperties = videoTransformationReadyEvent.additionalProperties.toMutableMap() } @@ -192,6 +205,17 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** The type of webhook event. */ + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + /** Timestamp when the event was created in ISO8601 format. */ fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) @@ -225,20 +249,6 @@ private constructor( */ fun request(request: JsonField) = apply { this.request = request } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from("video.transformation.ready") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonValue) = apply { this.type = type } - /** Performance metrics for the transformation process. */ fun timings(timings: Timings) = timings(JsonField.of(timings)) @@ -277,6 +287,7 @@ private constructor( * The following fields are required: * ```java * .id() + * .type() * .createdAt() * .data() * .request() @@ -287,10 +298,10 @@ private constructor( fun build(): VideoTransformationReadyEvent = VideoTransformationReadyEvent( checkRequired("id", id), + checkRequired("type", type), checkRequired("createdAt", createdAt), checkRequired("data", data), checkRequired("request", request), - type, timings, additionalProperties.toMutableMap(), ) @@ -304,14 +315,10 @@ private constructor( } id() + type() createdAt() data().validate() request().validate() - _type().let { - if (it != JsonValue.from("video.transformation.ready")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } timings().ifPresent { it.validate() } validated = true } @@ -332,10 +339,10 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (data.asKnown().getOrNull()?.validity() ?: 0) + (request.asKnown().getOrNull()?.validity() ?: 0) + - type.let { if (it == JsonValue.from("video.transformation.ready")) 1 else 0 } + (timings.asKnown().getOrNull()?.validity() ?: 0) class Data @@ -3056,20 +3063,20 @@ private constructor( return other is VideoTransformationReadyEvent && id == other.id && + type == other.type && createdAt == other.createdAt && data == other.data && request == other.request && - type == other.type && timings == other.timings && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, createdAt, data, request, type, timings, additionalProperties) + Objects.hash(id, type, createdAt, data, request, timings, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "VideoTransformationReadyEvent{id=$id, createdAt=$createdAt, data=$data, request=$request, type=$type, timings=$timings, additionalProperties=$additionalProperties}" + "VideoTransformationReadyEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, request=$request, timings=$timings, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/BaseWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/BaseWebhookEventTest.kt new file mode 100644 index 00000000..577eb730 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/BaseWebhookEventTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BaseWebhookEventTest { + + @Test + fun create() { + val baseWebhookEvent = BaseWebhookEvent.builder().id("id").type("type").build() + + assertThat(baseWebhookEvent.id()).isEqualTo("id") + assertThat(baseWebhookEvent.type()).isEqualTo("type") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val baseWebhookEvent = BaseWebhookEvent.builder().id("id").type("type").build() + + val roundtrippedBaseWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(baseWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBaseWebhookEvent).isEqualTo(baseWebhookEvent) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt index 010070a5..b319bfe9 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt @@ -21,6 +21,7 @@ internal class UnsafeUnwrapWebhookEventTest { val videoTransformationAccepted = VideoTransformationAcceptedEvent.builder() .id("id") + .type("video.transformation.accepted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( VideoTransformationAcceptedEvent.Data.builder() @@ -100,6 +101,7 @@ internal class UnsafeUnwrapWebhookEventTest { UnsafeUnwrapWebhookEvent.ofVideoTransformationAccepted( VideoTransformationAcceptedEvent.builder() .id("id") + .type("video.transformation.accepted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( VideoTransformationAcceptedEvent.Data.builder() @@ -174,6 +176,7 @@ internal class UnsafeUnwrapWebhookEventTest { val videoTransformationReady = VideoTransformationReadyEvent.builder() .id("id") + .type("video.transformation.ready") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( VideoTransformationReadyEvent.Data.builder() @@ -275,6 +278,7 @@ internal class UnsafeUnwrapWebhookEventTest { UnsafeUnwrapWebhookEvent.ofVideoTransformationReady( VideoTransformationReadyEvent.builder() .id("id") + .type("video.transformation.ready") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( VideoTransformationReadyEvent.Data.builder() @@ -372,6 +376,7 @@ internal class UnsafeUnwrapWebhookEventTest { val videoTransformationError = VideoTransformationErrorEvent.builder() .id("id") + .type("video.transformation.error") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( VideoTransformationErrorEvent.Data.builder() @@ -461,6 +466,7 @@ internal class UnsafeUnwrapWebhookEventTest { UnsafeUnwrapWebhookEvent.ofVideoTransformationError( VideoTransformationErrorEvent.builder() .id("id") + .type("video.transformation.error") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( VideoTransformationErrorEvent.Data.builder() @@ -546,6 +552,7 @@ internal class UnsafeUnwrapWebhookEventTest { val uploadPreTransformSuccess = UploadPreTransformSuccessEvent.builder() .id("id") + .type("upload.pre-transform.success") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPreTransformSuccessEvent.Data.builder() @@ -733,6 +740,7 @@ internal class UnsafeUnwrapWebhookEventTest { UnsafeUnwrapWebhookEvent.ofUploadPreTransformSuccess( UploadPreTransformSuccessEvent.builder() .id("id") + .type("upload.pre-transform.success") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPreTransformSuccessEvent.Data.builder() @@ -920,6 +928,7 @@ internal class UnsafeUnwrapWebhookEventTest { val uploadPreTransformError = UploadPreTransformErrorEvent.builder() .id("id") + .type("upload.pre-transform.error") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPreTransformErrorEvent.Data.builder() @@ -964,6 +973,7 @@ internal class UnsafeUnwrapWebhookEventTest { UnsafeUnwrapWebhookEvent.ofUploadPreTransformError( UploadPreTransformErrorEvent.builder() .id("id") + .type("upload.pre-transform.error") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPreTransformErrorEvent.Data.builder() @@ -1004,6 +1014,7 @@ internal class UnsafeUnwrapWebhookEventTest { val uploadPostTransformSuccess = UploadPostTransformSuccessEvent.builder() .id("id") + .type("upload.post-transform.success") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPostTransformSuccessEvent.Data.builder() @@ -1052,6 +1063,7 @@ internal class UnsafeUnwrapWebhookEventTest { UnsafeUnwrapWebhookEvent.ofUploadPostTransformSuccess( UploadPostTransformSuccessEvent.builder() .id("id") + .type("upload.post-transform.success") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPostTransformSuccessEvent.Data.builder() @@ -1096,6 +1108,7 @@ internal class UnsafeUnwrapWebhookEventTest { val uploadPostTransformError = UploadPostTransformErrorEvent.builder() .id("id") + .type("upload.post-transform.error") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPostTransformErrorEvent.Data.builder() @@ -1155,6 +1168,7 @@ internal class UnsafeUnwrapWebhookEventTest { UnsafeUnwrapWebhookEvent.ofUploadPostTransformError( UploadPostTransformErrorEvent.builder() .id("id") + .type("upload.post-transform.error") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPostTransformErrorEvent.Data.builder() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt index f35cbec4..3addab08 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt @@ -21,6 +21,7 @@ internal class UnwrapWebhookEventTest { val videoTransformationAccepted = VideoTransformationAcceptedEvent.builder() .id("id") + .type("video.transformation.accepted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( VideoTransformationAcceptedEvent.Data.builder() @@ -100,6 +101,7 @@ internal class UnwrapWebhookEventTest { UnwrapWebhookEvent.ofVideoTransformationAccepted( VideoTransformationAcceptedEvent.builder() .id("id") + .type("video.transformation.accepted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( VideoTransformationAcceptedEvent.Data.builder() @@ -174,6 +176,7 @@ internal class UnwrapWebhookEventTest { val videoTransformationReady = VideoTransformationReadyEvent.builder() .id("id") + .type("video.transformation.ready") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( VideoTransformationReadyEvent.Data.builder() @@ -274,6 +277,7 @@ internal class UnwrapWebhookEventTest { UnwrapWebhookEvent.ofVideoTransformationReady( VideoTransformationReadyEvent.builder() .id("id") + .type("video.transformation.ready") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( VideoTransformationReadyEvent.Data.builder() @@ -371,6 +375,7 @@ internal class UnwrapWebhookEventTest { val videoTransformationError = VideoTransformationErrorEvent.builder() .id("id") + .type("video.transformation.error") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( VideoTransformationErrorEvent.Data.builder() @@ -459,6 +464,7 @@ internal class UnwrapWebhookEventTest { UnwrapWebhookEvent.ofVideoTransformationError( VideoTransformationErrorEvent.builder() .id("id") + .type("video.transformation.error") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( VideoTransformationErrorEvent.Data.builder() @@ -544,6 +550,7 @@ internal class UnwrapWebhookEventTest { val uploadPreTransformSuccess = UploadPreTransformSuccessEvent.builder() .id("id") + .type("upload.pre-transform.success") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPreTransformSuccessEvent.Data.builder() @@ -731,6 +738,7 @@ internal class UnwrapWebhookEventTest { UnwrapWebhookEvent.ofUploadPreTransformSuccess( UploadPreTransformSuccessEvent.builder() .id("id") + .type("upload.pre-transform.success") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPreTransformSuccessEvent.Data.builder() @@ -918,6 +926,7 @@ internal class UnwrapWebhookEventTest { val uploadPreTransformError = UploadPreTransformErrorEvent.builder() .id("id") + .type("upload.pre-transform.error") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPreTransformErrorEvent.Data.builder() @@ -961,6 +970,7 @@ internal class UnwrapWebhookEventTest { UnwrapWebhookEvent.ofUploadPreTransformError( UploadPreTransformErrorEvent.builder() .id("id") + .type("upload.pre-transform.error") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPreTransformErrorEvent.Data.builder() @@ -1001,6 +1011,7 @@ internal class UnwrapWebhookEventTest { val uploadPostTransformSuccess = UploadPostTransformSuccessEvent.builder() .id("id") + .type("upload.post-transform.success") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPostTransformSuccessEvent.Data.builder() @@ -1049,6 +1060,7 @@ internal class UnwrapWebhookEventTest { UnwrapWebhookEvent.ofUploadPostTransformSuccess( UploadPostTransformSuccessEvent.builder() .id("id") + .type("upload.post-transform.success") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPostTransformSuccessEvent.Data.builder() @@ -1093,6 +1105,7 @@ internal class UnwrapWebhookEventTest { val uploadPostTransformError = UploadPostTransformErrorEvent.builder() .id("id") + .type("upload.post-transform.error") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPostTransformErrorEvent.Data.builder() @@ -1151,6 +1164,7 @@ internal class UnwrapWebhookEventTest { UnwrapWebhookEvent.ofUploadPostTransformError( UploadPostTransformErrorEvent.builder() .id("id") + .type("upload.post-transform.error") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPostTransformErrorEvent.Data.builder() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEventTest.kt index e7a4925a..ce99a9c9 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEventTest.kt @@ -15,6 +15,7 @@ internal class UploadPostTransformErrorEventTest { val uploadPostTransformErrorEvent = UploadPostTransformErrorEvent.builder() .id("id") + .type("upload.post-transform.error") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPostTransformErrorEvent.Data.builder() @@ -55,6 +56,7 @@ internal class UploadPostTransformErrorEventTest { .build() assertThat(uploadPostTransformErrorEvent.id()).isEqualTo("id") + assertThat(uploadPostTransformErrorEvent.type()).isEqualTo("upload.post-transform.error") assertThat(uploadPostTransformErrorEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(uploadPostTransformErrorEvent.data()) @@ -101,6 +103,7 @@ internal class UploadPostTransformErrorEventTest { val uploadPostTransformErrorEvent = UploadPostTransformErrorEvent.builder() .id("id") + .type("upload.post-transform.error") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPostTransformErrorEvent.Data.builder() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEventTest.kt index eaa86ef2..ded4c114 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEventTest.kt @@ -15,6 +15,7 @@ internal class UploadPostTransformSuccessEventTest { val uploadPostTransformSuccessEvent = UploadPostTransformSuccessEvent.builder() .id("id") + .type("upload.post-transform.success") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPostTransformSuccessEvent.Data.builder() @@ -44,6 +45,8 @@ internal class UploadPostTransformSuccessEventTest { .build() assertThat(uploadPostTransformSuccessEvent.id()).isEqualTo("id") + assertThat(uploadPostTransformSuccessEvent.type()) + .isEqualTo("upload.post-transform.success") assertThat(uploadPostTransformSuccessEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(uploadPostTransformSuccessEvent.data()) @@ -80,6 +83,7 @@ internal class UploadPostTransformSuccessEventTest { val uploadPostTransformSuccessEvent = UploadPostTransformSuccessEvent.builder() .id("id") + .type("upload.post-transform.success") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPostTransformSuccessEvent.Data.builder() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEventTest.kt index e97ad849..e02922a7 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEventTest.kt @@ -15,6 +15,7 @@ internal class UploadPreTransformErrorEventTest { val uploadPreTransformErrorEvent = UploadPreTransformErrorEvent.builder() .id("id") + .type("upload.pre-transform.error") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPreTransformErrorEvent.Data.builder() @@ -40,6 +41,7 @@ internal class UploadPreTransformErrorEventTest { .build() assertThat(uploadPreTransformErrorEvent.id()).isEqualTo("id") + assertThat(uploadPreTransformErrorEvent.type()).isEqualTo("upload.pre-transform.error") assertThat(uploadPreTransformErrorEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(uploadPreTransformErrorEvent.data()) @@ -73,6 +75,7 @@ internal class UploadPreTransformErrorEventTest { val uploadPreTransformErrorEvent = UploadPreTransformErrorEvent.builder() .id("id") + .type("upload.pre-transform.error") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPreTransformErrorEvent.Data.builder() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt index 7068d5a9..241d7acf 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt @@ -17,6 +17,7 @@ internal class UploadPreTransformSuccessEventTest { val uploadPreTransformSuccessEvent = UploadPreTransformSuccessEvent.builder() .id("id") + .type("upload.pre-transform.success") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPreTransformSuccessEvent.Data.builder() @@ -185,6 +186,7 @@ internal class UploadPreTransformSuccessEventTest { .build() assertThat(uploadPreTransformSuccessEvent.id()).isEqualTo("id") + assertThat(uploadPreTransformSuccessEvent.type()).isEqualTo("upload.pre-transform.success") assertThat(uploadPreTransformSuccessEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(uploadPreTransformSuccessEvent.data()) @@ -357,6 +359,7 @@ internal class UploadPreTransformSuccessEventTest { val uploadPreTransformSuccessEvent = UploadPreTransformSuccessEvent.builder() .id("id") + .type("upload.pre-transform.success") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( UploadPreTransformSuccessEvent.Data.builder() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt index e3c95329..3ae8d593 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt @@ -15,6 +15,7 @@ internal class VideoTransformationAcceptedEventTest { val videoTransformationAcceptedEvent = VideoTransformationAcceptedEvent.builder() .id("id") + .type("video.transformation.accepted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( VideoTransformationAcceptedEvent.Data.builder() @@ -75,6 +76,8 @@ internal class VideoTransformationAcceptedEventTest { .build() assertThat(videoTransformationAcceptedEvent.id()).isEqualTo("id") + assertThat(videoTransformationAcceptedEvent.type()) + .isEqualTo("video.transformation.accepted") assertThat(videoTransformationAcceptedEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(videoTransformationAcceptedEvent.data()) @@ -139,6 +142,7 @@ internal class VideoTransformationAcceptedEventTest { val videoTransformationAcceptedEvent = VideoTransformationAcceptedEvent.builder() .id("id") + .type("video.transformation.accepted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( VideoTransformationAcceptedEvent.Data.builder() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt index 4d2b3f63..f03c9e27 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt @@ -15,6 +15,7 @@ internal class VideoTransformationErrorEventTest { val videoTransformationErrorEvent = VideoTransformationErrorEvent.builder() .id("id") + .type("video.transformation.error") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( VideoTransformationErrorEvent.Data.builder() @@ -85,6 +86,7 @@ internal class VideoTransformationErrorEventTest { .build() assertThat(videoTransformationErrorEvent.id()).isEqualTo("id") + assertThat(videoTransformationErrorEvent.type()).isEqualTo("video.transformation.error") assertThat(videoTransformationErrorEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(videoTransformationErrorEvent.data()) @@ -157,6 +159,7 @@ internal class VideoTransformationErrorEventTest { val videoTransformationErrorEvent = VideoTransformationErrorEvent.builder() .id("id") + .type("video.transformation.error") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( VideoTransformationErrorEvent.Data.builder() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt index 2c9c0127..a65e2a16 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt @@ -15,6 +15,7 @@ internal class VideoTransformationReadyEventTest { val videoTransformationReadyEvent = VideoTransformationReadyEvent.builder() .id("id") + .type("video.transformation.ready") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( VideoTransformationReadyEvent.Data.builder() @@ -97,6 +98,7 @@ internal class VideoTransformationReadyEventTest { .build() assertThat(videoTransformationReadyEvent.id()).isEqualTo("id") + assertThat(videoTransformationReadyEvent.type()).isEqualTo("video.transformation.ready") assertThat(videoTransformationReadyEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(videoTransformationReadyEvent.data()) @@ -182,6 +184,7 @@ internal class VideoTransformationReadyEventTest { val videoTransformationReadyEvent = VideoTransformationReadyEvent.builder() .id("id") + .type("video.transformation.ready") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( VideoTransformationReadyEvent.Data.builder() From 436b4f80d20ed9273dd8a7c39076419dbdd780b0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Sep 2025 08:17:36 +0000 Subject: [PATCH 005/142] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 52f982ba..cfcbd7f7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a -config_hash: 08e12746cdca1c59c897cf2e50893c3c +config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c From b46241040326016adf4ad220178ccf3221323f90 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Sep 2025 08:20:17 +0000 Subject: [PATCH 006/142] feat(api): manual updates --- .stats.yml | 4 +- README.md | 39 ++++----- .../api/models/files/FileUploadParams.kt | 85 ++++--------------- .../api/models/files/FileUploadParamsTest.kt | 10 +-- .../api/services/ErrorHandlingTest.kt | 34 ++++---- .../api/services/ServiceParamsTest.kt | 2 +- .../services/async/FileServiceAsyncTest.kt | 2 +- .../api/services/blocking/FileServiceTest.kt | 2 +- 8 files changed, 59 insertions(+), 119 deletions(-) diff --git a/.stats.yml b/.stats.yml index cfcbd7f7..282d18eb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml -openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-eab9713fd85da68b41e881dfd9cd71f654e8620132da2023bab7dd01e5f7852e.yml +openapi_spec_hash: b5037b26fbe7360c6bfaf9947a65bb85 config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c diff --git a/README.md b/README.md index 4e268347..2766220b 100644 --- a/README.md +++ b/README.md @@ -50,14 +50,13 @@ import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; -import java.io.ByteArrayInputStream; // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .file("https://www.example.com/public-url.jpg") .fileName("file-name.jpg") .build(); FileUploadResponse response = client.files().upload(params); @@ -155,7 +154,6 @@ import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; -import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties @@ -163,7 +161,7 @@ import java.util.concurrent.CompletableFuture; ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .file("https://www.example.com/public-url.jpg") .fileName("file-name.jpg") .build(); CompletableFuture response = client.async().files().upload(params); @@ -176,7 +174,6 @@ import com.imagekit.api.client.ImageKitClientAsync; import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; -import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties @@ -184,7 +181,7 @@ import java.util.concurrent.CompletableFuture; ImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv(); FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .file("https://www.example.com/public-url.jpg") .fileName("file-name.jpg") .build(); CompletableFuture response = client.files().upload(params); @@ -199,50 +196,50 @@ The SDK defines methods that accept files. To upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html): ```java -import com.imagekit.api.models.files.FileUploadParams; -import com.imagekit.api.models.files.FileUploadResponse; +import com.imagekit.api.models.beta.v2.files.FileUploadParams; +import com.imagekit.api.models.beta.v2.files.FileUploadResponse; import java.nio.file.Paths; FileUploadParams params = FileUploadParams.builder() .fileName("fileName") .file(Paths.get("/path/to/file")) .build(); -FileUploadResponse response = client.files().upload(params); +FileUploadResponse response = client.beta().v2().files().upload(params); ``` Or an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html): ```java -import com.imagekit.api.models.files.FileUploadParams; -import com.imagekit.api.models.files.FileUploadResponse; +import com.imagekit.api.models.beta.v2.files.FileUploadParams; +import com.imagekit.api.models.beta.v2.files.FileUploadResponse; import java.net.URL; FileUploadParams params = FileUploadParams.builder() .fileName("fileName") .file(new URL("https://example.com//path/to/file").openStream()) .build(); -FileUploadResponse response = client.files().upload(params); +FileUploadResponse response = client.beta().v2().files().upload(params); ``` Or a `byte[]` array: ```java -import com.imagekit.api.models.files.FileUploadParams; -import com.imagekit.api.models.files.FileUploadResponse; +import com.imagekit.api.models.beta.v2.files.FileUploadParams; +import com.imagekit.api.models.beta.v2.files.FileUploadResponse; FileUploadParams params = FileUploadParams.builder() .fileName("fileName") .file("content".getBytes()) .build(); -FileUploadResponse response = client.files().upload(params); +FileUploadResponse response = client.beta().v2().files().upload(params); ``` Note that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt): ```java import com.imagekit.api.core.MultipartField; -import com.imagekit.api.models.files.FileUploadParams; -import com.imagekit.api.models.files.FileUploadResponse; +import com.imagekit.api.models.beta.v2.files.FileUploadParams; +import com.imagekit.api.models.beta.v2.files.FileUploadResponse; import java.io.InputStream; import java.net.URL; @@ -253,7 +250,7 @@ FileUploadParams params = FileUploadParams.builder() .filename("/path/to/file") .build()) .build(); -FileUploadResponse response = client.files().upload(params); +FileUploadResponse response = client.beta().v2().files().upload(params); ``` ## Raw responses @@ -267,10 +264,9 @@ import com.imagekit.api.core.http.Headers; import com.imagekit.api.core.http.HttpResponseFor; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; -import java.io.ByteArrayInputStream; FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .file("https://www.example.com/public-url.jpg") .fileName("file-name.jpg") .build(); HttpResponseFor response = client.files().withRawResponse().upload(params); @@ -614,10 +610,9 @@ To access a property's raw JSON value, which may be undocumented, call its `_` p ```java import com.imagekit.api.core.JsonField; -import java.io.InputStream; import java.util.Optional; -JsonField file = client.files().upload(params)._file(); +JsonField file = client.files().upload(params)._file(); if (file.isMissing()) { // The property is absent from the JSON response diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt index e50852f0..91c29f10 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -28,13 +28,9 @@ import com.imagekit.api.core.http.Headers import com.imagekit.api.core.http.QueryParams import com.imagekit.api.core.toImmutable import com.imagekit.api.errors.ImageKitInvalidDataException -import java.io.InputStream -import java.nio.file.Path import java.util.Collections import java.util.Objects import java.util.Optional -import kotlin.io.path.inputStream -import kotlin.io.path.name import kotlin.jvm.optionals.getOrNull /** @@ -78,7 +74,7 @@ private constructor( * @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 file(): InputStream = body.file() + fun file(): String = body.file() /** * The name with which the file has to be uploaded. The file name can contain: @@ -327,7 +323,7 @@ private constructor( * * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. */ - fun _file(): MultipartField = body._file() + fun _file(): MultipartField = body._file() /** * Returns the raw multipart value of [fileName]. @@ -556,38 +552,15 @@ private constructor( * When supplying a URL, the server must receive the response headers within 8 seconds; * otherwise the request fails with 400 Bad Request. */ - fun file(file: InputStream) = apply { body.file(file) } + fun file(file: String) = apply { body.file(file) } /** * Sets [Builder.file] to an arbitrary multipart value. * - * You should usually call [Builder.file] with a well-typed [InputStream] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun file(file: MultipartField) = apply { body.file(file) } - - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. - */ - fun file(file: ByteArray) = apply { body.file(file) } - - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. + * You should usually call [Builder.file] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ - fun file(path: Path) = apply { body.file(path) } + fun file(file: MultipartField) = apply { body.file(file) } /** * The name with which the file has to be uploaded. The file name can contain: @@ -1197,7 +1170,7 @@ private constructor( class Body private constructor( - private val file: MultipartField, + private val file: MultipartField, private val fileName: MultipartField, private val token: MultipartField, private val checks: MultipartField, @@ -1235,7 +1208,7 @@ private constructor( * @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 file(): InputStream = file.value.getRequired("file") + fun file(): String = file.value.getRequired("file") /** * The name with which the file has to be uploaded. The file name can contain: @@ -1492,7 +1465,7 @@ private constructor( * * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. */ - @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField = file + @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField = file /** * Returns the raw multipart value of [fileName]. @@ -1726,7 +1699,7 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { - private var file: MultipartField? = null + private var file: MultipartField? = null private var fileName: MultipartField? = null private var token: MultipartField = MultipartField.of(null) private var checks: MultipartField = MultipartField.of(null) @@ -1788,44 +1761,16 @@ private constructor( * When supplying a URL, the server must receive the response headers within 8 seconds; * otherwise the request fails with 400 Bad Request. */ - fun file(file: InputStream) = file(MultipartField.of(file)) + fun file(file: String) = file(MultipartField.of(file)) /** * Sets [Builder.file] to an arbitrary multipart value. * - * You should usually call [Builder.file] with a well-typed [InputStream] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun file(file: MultipartField) = apply { this.file = file } - - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. - */ - fun file(file: ByteArray) = file(file.inputStream()) - - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. + * You should usually call [Builder.file] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun file(path: Path) = - file( - MultipartField.builder() - .value(path.inputStream()) - .filename(path.name) - .build() - ) + fun file(file: MultipartField) = apply { this.file = file } /** * The name with which the file has to be uploaded. The file name can contain: diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt index 11752909..b6e73175 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt @@ -13,7 +13,7 @@ internal class FileUploadParamsTest { @Test fun create() { FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -95,7 +95,7 @@ internal class FileUploadParamsTest { fun body() { val params = FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -184,7 +184,7 @@ internal class FileUploadParamsTest { ) .isEqualTo( mapOf( - "file" to MultipartField.of("some content".byteInputStream()), + "file" to MultipartField.of("https://www.example.com/path/to-image.jpg"), "fileName" to MultipartField.of("fileName"), "token" to MultipartField.of("token"), "checks" to MultipartField.of("\"request.folder\" : \"marketing/\"\n"), @@ -278,7 +278,7 @@ internal class FileUploadParamsTest { fun bodyWithoutOptionalFields() { val params = FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .build() @@ -294,7 +294,7 @@ internal class FileUploadParamsTest { ) .isEqualTo( mapOf( - "file" to MultipartField.of("some content".byteInputStream()), + "file" to MultipartField.of("https://www.example.com/path/to-image.jpg"), "fileName" to MultipartField.of("fileName"), ) .mapValues { (_, field) -> diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt index 33349dd2..57f8f40b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt @@ -73,7 +73,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -173,7 +173,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -273,7 +273,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -373,7 +373,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -473,7 +473,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -573,7 +573,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -673,7 +673,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -773,7 +773,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -873,7 +873,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -973,7 +973,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1073,7 +1073,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1173,7 +1173,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1273,7 +1273,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1373,7 +1373,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1473,7 +1473,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1573,7 +1573,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1671,7 +1671,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt index f26281ec..3f9c955a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt @@ -45,7 +45,7 @@ internal class ServiceParamsTest { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index 6e8d541b..a7b3f852 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -227,7 +227,7 @@ internal class FileServiceAsyncTest { val responseFuture = fileServiceAsync.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index 2e932b81..c7c4cf58 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -220,7 +220,7 @@ internal class FileServiceTest { val response = fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("https://www.example.com/path/to-image.jpg") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") From 76c5b5e1fbc0ac3415d5e35febce642dd47cd0ab Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Sep 2025 08:23:13 +0000 Subject: [PATCH 007/142] feat(api): manual updates --- .stats.yml | 4 +-- .../api/models/files/FileUploadParamsTest.kt | 14 +++----- .../api/services/ErrorHandlingTest.kt | 34 +++++++++---------- .../api/services/ServiceParamsTest.kt | 2 +- .../services/async/FileServiceAsyncTest.kt | 2 +- .../api/services/blocking/FileServiceTest.kt | 2 +- 6 files changed, 27 insertions(+), 31 deletions(-) diff --git a/.stats.yml b/.stats.yml index 282d18eb..7698a81b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-eab9713fd85da68b41e881dfd9cd71f654e8620132da2023bab7dd01e5f7852e.yml -openapi_spec_hash: b5037b26fbe7360c6bfaf9947a65bb85 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-911102f2eaf3be4b34381f6ba089330bed099bb72eb93667ce2f6e72b5934c8c.yml +openapi_spec_hash: 637ad417a580137914441bd790b04cc2 config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt index b6e73175..b6077db8 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt @@ -13,7 +13,7 @@ internal class FileUploadParamsTest { @Test fun create() { FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -95,7 +95,7 @@ internal class FileUploadParamsTest { fun body() { val params = FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -184,7 +184,7 @@ internal class FileUploadParamsTest { ) .isEqualTo( mapOf( - "file" to MultipartField.of("https://www.example.com/path/to-image.jpg"), + "file" to MultipartField.of("file"), "fileName" to MultipartField.of("fileName"), "token" to MultipartField.of("token"), "checks" to MultipartField.of("\"request.folder\" : \"marketing/\"\n"), @@ -276,11 +276,7 @@ internal class FileUploadParamsTest { @Test fun bodyWithoutOptionalFields() { - val params = - FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") - .fileName("fileName") - .build() + val params = FileUploadParams.builder().file("file").fileName("fileName").build() val body = params._body() @@ -294,7 +290,7 @@ internal class FileUploadParamsTest { ) .isEqualTo( mapOf( - "file" to MultipartField.of("https://www.example.com/path/to-image.jpg"), + "file" to MultipartField.of("file"), "fileName" to MultipartField.of("fileName"), ) .mapValues { (_, field) -> diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt index 57f8f40b..06be3bde 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt @@ -73,7 +73,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -173,7 +173,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -273,7 +273,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -373,7 +373,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -473,7 +473,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -573,7 +573,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -673,7 +673,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -773,7 +773,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -873,7 +873,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -973,7 +973,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1073,7 +1073,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1173,7 +1173,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1273,7 +1273,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1373,7 +1373,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1473,7 +1473,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1573,7 +1573,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1671,7 +1671,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt index 3f9c955a..58199ef9 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt @@ -45,7 +45,7 @@ internal class ServiceParamsTest { fileService.upload( FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index a7b3f852..a1cd1aa5 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -227,7 +227,7 @@ internal class FileServiceAsyncTest { val responseFuture = fileServiceAsync.upload( FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index c7c4cf58..2c44511a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -220,7 +220,7 @@ internal class FileServiceTest { val response = fileService.upload( FileUploadParams.builder() - .file("https://www.example.com/path/to-image.jpg") + .file("file") .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") From 74027efe9095a5e650addddf064d6e3773413894 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Sep 2025 08:25:33 +0000 Subject: [PATCH 008/142] feat(api): manual updates --- .stats.yml | 4 +- README.md | 39 +++++---- .../api/models/files/FileUploadParams.kt | 85 +++++++++++++++---- .../api/models/files/FileUploadParamsTest.kt | 14 +-- .../api/services/ErrorHandlingTest.kt | 34 ++++---- .../api/services/ServiceParamsTest.kt | 2 +- .../services/async/FileServiceAsyncTest.kt | 2 +- .../api/services/blocking/FileServiceTest.kt | 2 +- 8 files changed, 123 insertions(+), 59 deletions(-) diff --git a/.stats.yml b/.stats.yml index 7698a81b..d42605f1 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-911102f2eaf3be4b34381f6ba089330bed099bb72eb93667ce2f6e72b5934c8c.yml -openapi_spec_hash: 637ad417a580137914441bd790b04cc2 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-0726d89b19f532c7fb92990d688a9bfb5aa4a9a871d64f49d4ba45bac6998e4a.yml +openapi_spec_hash: 9525bb02ab496b3459a1f93ac50968e3 config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c diff --git a/README.md b/README.md index 2766220b..4e268347 100644 --- a/README.md +++ b/README.md @@ -50,13 +50,14 @@ import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() - .file("https://www.example.com/public-url.jpg") + .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) .fileName("file-name.jpg") .build(); FileUploadResponse response = client.files().upload(params); @@ -154,6 +155,7 @@ import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties @@ -161,7 +163,7 @@ import java.util.concurrent.CompletableFuture; ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() - .file("https://www.example.com/public-url.jpg") + .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) .fileName("file-name.jpg") .build(); CompletableFuture response = client.async().files().upload(params); @@ -174,6 +176,7 @@ import com.imagekit.api.client.ImageKitClientAsync; import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties @@ -181,7 +184,7 @@ import java.util.concurrent.CompletableFuture; ImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv(); FileUploadParams params = FileUploadParams.builder() - .file("https://www.example.com/public-url.jpg") + .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) .fileName("file-name.jpg") .build(); CompletableFuture response = client.files().upload(params); @@ -196,50 +199,50 @@ The SDK defines methods that accept files. To upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html): ```java -import com.imagekit.api.models.beta.v2.files.FileUploadParams; -import com.imagekit.api.models.beta.v2.files.FileUploadResponse; +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; import java.nio.file.Paths; FileUploadParams params = FileUploadParams.builder() .fileName("fileName") .file(Paths.get("/path/to/file")) .build(); -FileUploadResponse response = client.beta().v2().files().upload(params); +FileUploadResponse response = client.files().upload(params); ``` Or an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html): ```java -import com.imagekit.api.models.beta.v2.files.FileUploadParams; -import com.imagekit.api.models.beta.v2.files.FileUploadResponse; +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; import java.net.URL; FileUploadParams params = FileUploadParams.builder() .fileName("fileName") .file(new URL("https://example.com//path/to/file").openStream()) .build(); -FileUploadResponse response = client.beta().v2().files().upload(params); +FileUploadResponse response = client.files().upload(params); ``` Or a `byte[]` array: ```java -import com.imagekit.api.models.beta.v2.files.FileUploadParams; -import com.imagekit.api.models.beta.v2.files.FileUploadResponse; +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; FileUploadParams params = FileUploadParams.builder() .fileName("fileName") .file("content".getBytes()) .build(); -FileUploadResponse response = client.beta().v2().files().upload(params); +FileUploadResponse response = client.files().upload(params); ``` Note that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt): ```java import com.imagekit.api.core.MultipartField; -import com.imagekit.api.models.beta.v2.files.FileUploadParams; -import com.imagekit.api.models.beta.v2.files.FileUploadResponse; +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; import java.io.InputStream; import java.net.URL; @@ -250,7 +253,7 @@ FileUploadParams params = FileUploadParams.builder() .filename("/path/to/file") .build()) .build(); -FileUploadResponse response = client.beta().v2().files().upload(params); +FileUploadResponse response = client.files().upload(params); ``` ## Raw responses @@ -264,9 +267,10 @@ import com.imagekit.api.core.http.Headers; import com.imagekit.api.core.http.HttpResponseFor; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; FileUploadParams params = FileUploadParams.builder() - .file("https://www.example.com/public-url.jpg") + .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) .fileName("file-name.jpg") .build(); HttpResponseFor response = client.files().withRawResponse().upload(params); @@ -610,9 +614,10 @@ To access a property's raw JSON value, which may be undocumented, call its `_` p ```java import com.imagekit.api.core.JsonField; +import java.io.InputStream; import java.util.Optional; -JsonField file = client.files().upload(params)._file(); +JsonField file = client.files().upload(params)._file(); if (file.isMissing()) { // The property is absent from the JSON response diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt index 91c29f10..e50852f0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -28,9 +28,13 @@ import com.imagekit.api.core.http.Headers import com.imagekit.api.core.http.QueryParams import com.imagekit.api.core.toImmutable import com.imagekit.api.errors.ImageKitInvalidDataException +import java.io.InputStream +import java.nio.file.Path import java.util.Collections import java.util.Objects import java.util.Optional +import kotlin.io.path.inputStream +import kotlin.io.path.name import kotlin.jvm.optionals.getOrNull /** @@ -74,7 +78,7 @@ private constructor( * @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 file(): String = body.file() + fun file(): InputStream = body.file() /** * The name with which the file has to be uploaded. The file name can contain: @@ -323,7 +327,7 @@ private constructor( * * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. */ - fun _file(): MultipartField = body._file() + fun _file(): MultipartField = body._file() /** * Returns the raw multipart value of [fileName]. @@ -552,15 +556,38 @@ private constructor( * When supplying a URL, the server must receive the response headers within 8 seconds; * otherwise the request fails with 400 Bad Request. */ - fun file(file: String) = apply { body.file(file) } + fun file(file: InputStream) = apply { body.file(file) } /** * Sets [Builder.file] to an arbitrary multipart value. * - * You should usually call [Builder.file] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.file] with a well-typed [InputStream] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun file(file: MultipartField) = apply { body.file(file) } + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(file: ByteArray) = apply { body.file(file) } + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. */ - fun file(file: MultipartField) = apply { body.file(file) } + fun file(path: Path) = apply { body.file(path) } /** * The name with which the file has to be uploaded. The file name can contain: @@ -1170,7 +1197,7 @@ private constructor( class Body private constructor( - private val file: MultipartField, + private val file: MultipartField, private val fileName: MultipartField, private val token: MultipartField, private val checks: MultipartField, @@ -1208,7 +1235,7 @@ private constructor( * @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 file(): String = file.value.getRequired("file") + fun file(): InputStream = file.value.getRequired("file") /** * The name with which the file has to be uploaded. The file name can contain: @@ -1465,7 +1492,7 @@ private constructor( * * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. */ - @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField = file + @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField = file /** * Returns the raw multipart value of [fileName]. @@ -1699,7 +1726,7 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { - private var file: MultipartField? = null + private var file: MultipartField? = null private var fileName: MultipartField? = null private var token: MultipartField = MultipartField.of(null) private var checks: MultipartField = MultipartField.of(null) @@ -1761,16 +1788,44 @@ private constructor( * When supplying a URL, the server must receive the response headers within 8 seconds; * otherwise the request fails with 400 Bad Request. */ - fun file(file: String) = file(MultipartField.of(file)) + fun file(file: InputStream) = file(MultipartField.of(file)) /** * Sets [Builder.file] to an arbitrary multipart value. * - * You should usually call [Builder.file] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.file] with a well-typed [InputStream] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun file(file: MultipartField) = apply { this.file = file } + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(file: ByteArray) = file(file.inputStream()) + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. */ - fun file(file: MultipartField) = apply { this.file = file } + fun file(path: Path) = + file( + MultipartField.builder() + .value(path.inputStream()) + .filename(path.name) + .build() + ) /** * The name with which the file has to be uploaded. The file name can contain: diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt index b6077db8..11752909 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt @@ -13,7 +13,7 @@ internal class FileUploadParamsTest { @Test fun create() { FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -95,7 +95,7 @@ internal class FileUploadParamsTest { fun body() { val params = FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -184,7 +184,7 @@ internal class FileUploadParamsTest { ) .isEqualTo( mapOf( - "file" to MultipartField.of("file"), + "file" to MultipartField.of("some content".byteInputStream()), "fileName" to MultipartField.of("fileName"), "token" to MultipartField.of("token"), "checks" to MultipartField.of("\"request.folder\" : \"marketing/\"\n"), @@ -276,7 +276,11 @@ internal class FileUploadParamsTest { @Test fun bodyWithoutOptionalFields() { - val params = FileUploadParams.builder().file("file").fileName("fileName").build() + val params = + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .build() val body = params._body() @@ -290,7 +294,7 @@ internal class FileUploadParamsTest { ) .isEqualTo( mapOf( - "file" to MultipartField.of("file"), + "file" to MultipartField.of("some content".byteInputStream()), "fileName" to MultipartField.of("fileName"), ) .mapValues { (_, field) -> diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt index 06be3bde..33349dd2 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt @@ -73,7 +73,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -173,7 +173,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -273,7 +273,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -373,7 +373,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -473,7 +473,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -573,7 +573,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -673,7 +673,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -773,7 +773,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -873,7 +873,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -973,7 +973,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1073,7 +1073,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1173,7 +1173,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1273,7 +1273,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1373,7 +1373,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1473,7 +1473,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1573,7 +1573,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1671,7 +1671,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt index 58199ef9..f26281ec 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt @@ -45,7 +45,7 @@ internal class ServiceParamsTest { fileService.upload( FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index a1cd1aa5..6e8d541b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -227,7 +227,7 @@ internal class FileServiceAsyncTest { val responseFuture = fileServiceAsync.upload( FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index 2c44511a..2e932b81 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -220,7 +220,7 @@ internal class FileServiceTest { val response = fileService.upload( FileUploadParams.builder() - .file("file") + .file("some content".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") From 8dd79339154ea4ac3c721633dbdd536563fa4d8c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Sep 2025 08:34:35 +0000 Subject: [PATCH 009/142] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index d42605f1..cfcbd7f7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-0726d89b19f532c7fb92990d688a9bfb5aa4a9a871d64f49d4ba45bac6998e4a.yml -openapi_spec_hash: 9525bb02ab496b3459a1f93ac50968e3 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml +openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c From d57885b731de1837a7edcd3f6eab303db855475a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Sep 2025 09:04:58 +0000 Subject: [PATCH 010/142] feat(api): manual updates --- .stats.yml | 4 +- README.md | 93 +- .../api/models/files/FileUploadParams.kt | 11478 ++++++++++------ .../api/services/async/FileServiceAsync.kt | 32 +- .../services/async/FileServiceAsyncImpl.kt | 6 +- .../api/services/blocking/FileService.kt | 28 +- .../api/services/blocking/FileServiceImpl.kt | 6 +- .../api/models/files/FileUploadParamsTest.kt | 530 +- .../api/services/ErrorHandlingTest.kt | 2788 ++-- .../api/services/ServiceParamsTest.kt | 156 +- .../services/async/FileServiceAsyncTest.kt | 161 +- .../api/services/blocking/FileServiceTest.kt | 161 +- 12 files changed, 9677 insertions(+), 5766 deletions(-) diff --git a/.stats.yml b/.stats.yml index cfcbd7f7..d458a07c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml -openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-e7bc47a9221d7da9c8c9653d3fd1d4cfdf2408588e32c4aa62bd02a50ec93c36.yml +openapi_spec_hash: 8d061396a2fff9d1add4d5baf03ab939 config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c diff --git a/README.md b/README.md index 4e268347..d7b4537c 100644 --- a/README.md +++ b/README.md @@ -50,17 +50,12 @@ import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; -import java.io.ByteArrayInputStream; // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); -FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) - .fileName("file-name.jpg") - .build(); -FileUploadResponse response = client.files().upload(params); +FileUploadResponse response = client.files().upload(); ``` ## Client configuration @@ -155,18 +150,13 @@ import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; -import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); -FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) - .fileName("file-name.jpg") - .build(); -CompletableFuture response = client.async().files().upload(params); +CompletableFuture response = client.async().files().upload(); ``` Or create an asynchronous client from the beginning: @@ -176,18 +166,13 @@ import com.imagekit.api.client.ImageKitClientAsync; import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; -import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv(); -FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) - .fileName("file-name.jpg") - .build(); -CompletableFuture response = client.files().upload(params); +CompletableFuture response = client.files().upload(); ``` The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. @@ -199,50 +184,50 @@ The SDK defines methods that accept files. To upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html): ```java -import com.imagekit.api.models.files.FileUploadParams; -import com.imagekit.api.models.files.FileUploadResponse; +import com.imagekit.api.models.beta.v2.files.FileUploadParams; +import com.imagekit.api.models.beta.v2.files.FileUploadResponse; import java.nio.file.Paths; FileUploadParams params = FileUploadParams.builder() .fileName("fileName") .file(Paths.get("/path/to/file")) .build(); -FileUploadResponse response = client.files().upload(params); +FileUploadResponse response = client.beta().v2().files().upload(params); ``` Or an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html): ```java -import com.imagekit.api.models.files.FileUploadParams; -import com.imagekit.api.models.files.FileUploadResponse; +import com.imagekit.api.models.beta.v2.files.FileUploadParams; +import com.imagekit.api.models.beta.v2.files.FileUploadResponse; import java.net.URL; FileUploadParams params = FileUploadParams.builder() .fileName("fileName") .file(new URL("https://example.com//path/to/file").openStream()) .build(); -FileUploadResponse response = client.files().upload(params); +FileUploadResponse response = client.beta().v2().files().upload(params); ``` Or a `byte[]` array: ```java -import com.imagekit.api.models.files.FileUploadParams; -import com.imagekit.api.models.files.FileUploadResponse; +import com.imagekit.api.models.beta.v2.files.FileUploadParams; +import com.imagekit.api.models.beta.v2.files.FileUploadResponse; FileUploadParams params = FileUploadParams.builder() .fileName("fileName") .file("content".getBytes()) .build(); -FileUploadResponse response = client.files().upload(params); +FileUploadResponse response = client.beta().v2().files().upload(params); ``` Note that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt): ```java import com.imagekit.api.core.MultipartField; -import com.imagekit.api.models.files.FileUploadParams; -import com.imagekit.api.models.files.FileUploadResponse; +import com.imagekit.api.models.beta.v2.files.FileUploadParams; +import com.imagekit.api.models.beta.v2.files.FileUploadResponse; import java.io.InputStream; import java.net.URL; @@ -253,7 +238,7 @@ FileUploadParams params = FileUploadParams.builder() .filename("/path/to/file") .build()) .build(); -FileUploadResponse response = client.files().upload(params); +FileUploadResponse response = client.beta().v2().files().upload(params); ``` ## Raw responses @@ -267,13 +252,8 @@ import com.imagekit.api.core.http.Headers; import com.imagekit.api.core.http.HttpResponseFor; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; -import java.io.ByteArrayInputStream; -FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) - .fileName("file-name.jpg") - .build(); -HttpResponseFor response = client.files().withRawResponse().upload(params); +HttpResponseFor response = client.files().withRawResponse().upload(); int statusCode = response.statusCode(); Headers headers = response.headers(); @@ -382,9 +362,7 @@ To set a custom timeout, configure the method call using the `timeout` method: ```java import com.imagekit.api.models.files.FileUploadResponse; -FileUploadResponse response = client.files().upload( - params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build() -); +FileUploadResponse response = client.files().upload(RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()); ``` Or configure the default for all method calls at the client level: @@ -502,10 +480,10 @@ To set undocumented parameters on _nested_ headers, query params, or body classe ```java import com.imagekit.api.core.JsonValue; -import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams; -FileUploadParams params = FileUploadParams.builder() - .transformation(FileUploadParams.Transformation.builder() +CustomMetadataFieldCreateParams params = CustomMetadataFieldCreateParams.builder() + .schema(CustomMetadataFieldCreateParams.Schema.builder() .putAdditionalProperty("secretProperty", JsonValue.from("42")) .build()) .build(); @@ -516,13 +494,9 @@ These properties can be accessed on the nested built object later using the `_ad To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter: ```java -import com.imagekit.api.core.JsonValue; import com.imagekit.api.models.files.FileUploadParams; -FileUploadParams params = FileUploadParams.builder() - .file(JsonValue.from(42)) - .fileName("file-name.jpg") - .build(); +FileUploadParams params = FileUploadParams.builder().build(); ``` The most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method: @@ -570,11 +544,15 @@ To forcibly omit a required parameter or property, pass [`JsonMissing`](image-ki ```java import com.imagekit.api.core.JsonMissing; +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams; import com.imagekit.api.models.files.FileUploadParams; -FileUploadParams params = FileUploadParams.builder() - .fileName("fileName") - .file(JsonMissing.of()) +FileUploadParams params = CustomMetadataFieldCreateParams.builder() + .name("price") + .schema(CustomMetadataFieldCreateParams.Schema.builder() + .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) + .build()) + .label(JsonMissing.of()) .build(); ``` @@ -614,22 +592,21 @@ To access a property's raw JSON value, which may be undocumented, call its `_` p ```java import com.imagekit.api.core.JsonField; -import java.io.InputStream; import java.util.Optional; -JsonField file = client.files().upload(params)._file(); +JsonField field = client.files().upload(params)._field(); -if (file.isMissing()) { +if (field.isMissing()) { // The property is absent from the JSON response -} else if (file.isNull()) { +} else if (field.isNull()) { // The property was set to literal null } else { // Check if value was provided as a string // Other methods include `asNumber()`, `asBoolean()`, etc. - Optional jsonString = file.asString(); + Optional jsonString = field.asString(); // Try to deserialize into a custom type - MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class); + MyClass myObject = field.asUnknown().orElseThrow().convert(MyClass.class); } ``` @@ -652,9 +629,7 @@ Or configure the method call to validate the response using the `responseValidat ```java import com.imagekit.api.models.files.FileUploadResponse; -FileUploadResponse response = client.files().upload( - params, RequestOptions.builder().responseValidation(true).build() -); +FileUploadResponse response = client.files().upload(RequestOptions.builder().responseValidation(true).build()); ``` Or configure the default for all method calls at the client level: diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt index e50852f0..6d4722f3 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -21,6 +21,7 @@ import com.imagekit.api.core.JsonField import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField import com.imagekit.api.core.Params +import com.imagekit.api.core.allMaxBy import com.imagekit.api.core.checkKnown import com.imagekit.api.core.checkRequired import com.imagekit.api.core.getOrThrow @@ -61,1771 +62,4438 @@ import kotlin.jvm.optionals.getOrNull */ class FileUploadParams private constructor( - private val body: Body, + private val body: MultipartField, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. - * - * @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 file(): InputStream = body.file() - - /** - * The name with which the file has to be uploaded. The file name can contain: - * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - * - Special Characters: `.`, `-` - * - * Any other character including space will be replaced by `_` - * - * @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 fileName(): String = body.fileName() - - /** - * A unique value that the ImageKit.io server will use to recognize and prevent subsequent - * retries for the same request. We suggest using V4 UUIDs, or another random string with enough - * entropy to avoid collisions. This field is only required for authentication when uploading a - * file from the client side. - * - * **Note**: Sending a value that has been used in the past will result in a validation error. - * Even if your previous request resulted in an error, you should always send a new value for - * this field. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun token(): Optional = body.token() - - /** - * Server-side checks to run on the asset. Read more about - * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). - * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun checks(): Optional = body.checks() + fun body(): Optional = body.value.getOptional("body") /** - * Define an important area in the image. This is only relevant for image type files. - * - To be passed as a string with the x and y coordinates of the top-left corner, and width and - * height of the area of interest in the format `x,y,width,height`. For example - - * `10,10,100,100` - * - Can be used with fo-customtransformation. - * - If this field is not specified and the file is overwritten, then customCoordinates will be - * removed. + * Returns the raw multipart value of [body]. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * Unlike [body], this method doesn't throw if the multipart field has an unexpected type. */ - fun customCoordinates(): Optional = body.customCoordinates() + @JsonProperty("body") @ExcludeMissing fun _body(): MultipartField = body - /** - * JSON key-value pairs to associate with the asset. Create the custom metadata fields before - * setting these values. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun customMetadata(): Optional = body.customMetadata() + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders - /** - * Optional text to describe the contents of the file. - * - * @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() + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams - /** - * The time until your signature is valid. It must be a - * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. It - * should be in seconds. This field is only required for authentication when uploading a file - * from the client side. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun expire(): Optional = body.expire() + fun toBuilder() = Builder().from(this) - /** - * Array of extensions to be applied to the image. Each extension can be configured with - * specific parameters based on the extension type. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun extensions(): Optional> = body.extensions() + companion object { - /** - * The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, - * a new folder(s) is created. - * - * The folder name can contain: - * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - * - Special Characters: `/` , `_` , `-` - * - * Using multiple `/` creates a nested folder. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun folder(): Optional = body.folder() + @JvmStatic fun none(): FileUploadParams = builder().build() - /** - * Whether to mark the file as private or not. - * - * If `true`, the file is marked as private and is accessible only using named transformation or - * signed URL. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun isPrivateFile(): Optional = body.isPrivateFile() + /** Returns a mutable builder for constructing an instance of [FileUploadParams]. */ + @JvmStatic fun builder() = Builder() + } - /** - * Whether to upload file as published or not. - * - * If `false`, the file is marked as unpublished, which restricts access to the file only via - * the media library. Files in draft or unpublished state can only be publicly accessed after - * being published. - * - * The option to upload in draft state is only available in custom enterprise pricing plans. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun isPublished(): Optional = body.isPublished() + /** A builder for [FileUploadParams]. */ + class Builder internal constructor() { - /** - * If set to `true` and a file already exists at the exact location, its AITags will be removed. - * Set `overwriteAITags` to `false` to preserve AITags. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun overwriteAiTags(): Optional = body.overwriteAiTags() + private var body: MultipartField = MultipartField.of(null) + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - /** - * If the request does not have `customMetadata`, and a file already exists at the exact - * location, existing customMetadata will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun overwriteCustomMetadata(): Optional = body.overwriteCustomMetadata() + @JvmSynthetic + internal fun from(fileUploadParams: FileUploadParams) = apply { + body = fileUploadParams.body + additionalHeaders = fileUploadParams.additionalHeaders.toBuilder() + additionalQueryParams = fileUploadParams.additionalQueryParams.toBuilder() + } - /** - * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact - * location, upload API will return an error immediately. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun overwriteFile(): Optional = body.overwriteFile() + fun body(body: Body) = + body( + MultipartField.builder() + .value(body) + .contentType("application/octet-stream") + .build() + ) - /** - * If the request does not have `tags`, and a file already exists at the exact location, - * existing tags will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun overwriteTags(): Optional = body.overwriteTags() + /** + * Sets [Builder.body] to an arbitrary multipart value. + * + * You should usually call [Builder.body] with a well-typed [Body] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun body(body: MultipartField) = apply { this.body = body } - /** - * Your ImageKit.io public key. This field is only required for authentication when uploading a - * file from the client side. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun publicKey(): Optional = body.publicKey() + /** Alias for calling [body] with `Body.ofFileUploadV1(fileUploadV1)`. */ + fun body(fileUploadV1: Body.FileUploadV1) = body(Body.ofFileUploadV1(fileUploadV1)) - /** - * Array of response field keys to include in the API response body. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun responseFields(): Optional> = body.responseFields() + /** Alias for calling [body] with `Body.ofFileUploadV1ByUrl(fileUploadV1ByUrl)`. */ + fun body(fileUploadV1ByUrl: Body.FileUploadV1ByUrl) = + body(Body.ofFileUploadV1ByUrl(fileUploadV1ByUrl)) - /** - * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. Learn - * how to create a signature on the page below. This should be in lowercase. - * - * Signature must be calculated on the server-side. This field is only required for - * authentication when uploading a file from the client side. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun signature(): Optional = body.signature() + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - /** - * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", - * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the `%` - * character is not allowed. If this field is not specified and the file is overwritten, the - * existing tags will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun tags(): Optional> = body.tags() + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing file - * size or applying basic optimizations upfront (e.g., resize, compress). - * - `post` — applied immediately after upload. Ideal for generating transformed versions (like - * video encodes or thumbnails) in advance, so they're ready for delivery without delay. - * - * You can mix and match any combination of post-processing types. - * - * @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() + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - /** - * Whether to use a unique filename for this file or not. - * - * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique - * filename. - * - * If `false`, then the image is uploaded with the provided filename parameter, and any existing - * file with the same name is replaced. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun useUniqueFileName(): Optional = body.useUniqueFileName() + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - /** - * The final status of extensions after they have completed execution will be delivered to this - * endpoint as a POST request. - * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - * about the webhook payload structure. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun webhookUrl(): Optional = body.webhookUrl() + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - /** - * Returns the raw multipart value of [file]. - * - * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _file(): MultipartField = body._file() + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - /** - * Returns the raw multipart value of [fileName]. - * - * Unlike [fileName], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _fileName(): MultipartField = body._fileName() + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - /** - * Returns the raw multipart value of [token]. - * - * Unlike [token], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _token(): MultipartField = body._token() + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - /** - * Returns the raw multipart value of [checks]. - * - * Unlike [checks], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _checks(): MultipartField = body._checks() + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - /** - * Returns the raw multipart value of [customCoordinates]. - * - * Unlike [customCoordinates], this method doesn't throw if the multipart field has an - * unexpected type. - */ - fun _customCoordinates(): MultipartField = body._customCoordinates() + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - /** - * Returns the raw multipart value of [customMetadata]. - * - * Unlike [customMetadata], this method doesn't throw if the multipart field has an unexpected - * type. - */ - fun _customMetadata(): MultipartField = body._customMetadata() + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - /** - * Returns the raw multipart value of [description]. - * - * Unlike [description], this method doesn't throw if the multipart field has an unexpected - * type. - */ - fun _description(): MultipartField = body._description() + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - /** - * Returns the raw multipart value of [expire]. - * - * Unlike [expire], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _expire(): MultipartField = body._expire() + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - /** - * Returns the raw multipart value of [extensions]. - * - * Unlike [extensions], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _extensions(): MultipartField> = body._extensions() + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - /** - * Returns the raw multipart value of [folder]. - * - * Unlike [folder], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _folder(): MultipartField = body._folder() + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - /** - * Returns the raw multipart value of [isPrivateFile]. - * - * Unlike [isPrivateFile], this method doesn't throw if the multipart field has an unexpected - * type. - */ - fun _isPrivateFile(): MultipartField = body._isPrivateFile() + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - /** - * Returns the raw multipart value of [isPublished]. - * - * Unlike [isPublished], this method doesn't throw if the multipart field has an unexpected - * type. - */ - fun _isPublished(): MultipartField = body._isPublished() + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } - /** - * Returns the raw multipart value of [overwriteAiTags]. - * - * Unlike [overwriteAiTags], this method doesn't throw if the multipart field has an unexpected - * type. - */ - fun _overwriteAiTags(): MultipartField = body._overwriteAiTags() + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } - /** - * Returns the raw multipart value of [overwriteCustomMetadata]. - * - * Unlike [overwriteCustomMetadata], this method doesn't throw if the multipart field has an - * unexpected type. - */ - fun _overwriteCustomMetadata(): MultipartField = body._overwriteCustomMetadata() + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - /** - * Returns the raw multipart value of [overwriteFile]. - * - * Unlike [overwriteFile], this method doesn't throw if the multipart field has an unexpected - * type. - */ - fun _overwriteFile(): MultipartField = body._overwriteFile() + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - /** - * Returns the raw multipart value of [overwriteTags]. - * - * Unlike [overwriteTags], this method doesn't throw if the multipart field has an unexpected - * type. - */ - fun _overwriteTags(): MultipartField = body._overwriteTags() + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } - /** - * Returns the raw multipart value of [publicKey]. - * - * Unlike [publicKey], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _publicKey(): MultipartField = body._publicKey() - - /** - * Returns the raw multipart value of [responseFields]. - * - * Unlike [responseFields], this method doesn't throw if the multipart field has an unexpected - * type. - */ - fun _responseFields(): MultipartField> = body._responseFields() - - /** - * Returns the raw multipart value of [signature]. - * - * Unlike [signature], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _signature(): MultipartField = body._signature() - - /** - * Returns the raw multipart value of [tags]. - * - * Unlike [tags], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _tags(): MultipartField> = body._tags() - - /** - * Returns the raw multipart value of [transformation]. - * - * Unlike [transformation], this method doesn't throw if the multipart field has an unexpected - * type. - */ - fun _transformation(): MultipartField = body._transformation() - - /** - * Returns the raw multipart value of [useUniqueFileName]. - * - * Unlike [useUniqueFileName], this method doesn't throw if the multipart field has an - * unexpected type. - */ - fun _useUniqueFileName(): MultipartField = body._useUniqueFileName() - - /** - * Returns the raw multipart value of [webhookUrl]. - * - * Unlike [webhookUrl], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _webhookUrl(): MultipartField = body._webhookUrl() - - 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 [FileUploadParams]. - * - * The following fields are required: - * ```java - * .file() - * .fileName() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FileUploadParams]. */ - class Builder internal constructor() { + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - @JvmSynthetic - internal fun from(fileUploadParams: FileUploadParams) = apply { - body = fileUploadParams.body.toBuilder() - additionalHeaders = fileUploadParams.additionalHeaders.toBuilder() - additionalQueryParams = fileUploadParams.additionalQueryParams.toBuilder() + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) } /** - * Sets the entire request body. + * Returns an immutable instance of [FileUploadParams]. * - * 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: - * - [file] - * - [fileName] - * - [token] - * - [checks] - * - [customCoordinates] - * - etc. + * Further updates to this [Builder] will not mutate the returned instance. */ - fun body(body: Body) = apply { this.body = body.toBuilder() } + fun build(): FileUploadParams = + FileUploadParams(body, additionalHeaders.build(), additionalQueryParams.build()) + } - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. - */ - fun file(file: InputStream) = apply { body.file(file) } + fun _body(): Map> = + (mapOf("body" to _body()) + + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) + .toImmutable() - /** - * Sets [Builder.file] to an arbitrary multipart value. - * - * You should usually call [Builder.file] with a well-typed [InputStream] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun file(file: MultipartField) = apply { body.file(file) } + override fun _headers(): Headers = additionalHeaders - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. - */ - fun file(file: ByteArray) = apply { body.file(file) } + override fun _queryParams(): QueryParams = additionalQueryParams - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. - */ - fun file(path: Path) = apply { body.file(path) } + @JsonDeserialize(using = Body.Deserializer::class) + @JsonSerialize(using = Body.Serializer::class) + class Body + private constructor( + private val fileUploadV1: FileUploadV1? = null, + private val fileUploadV1ByUrl: FileUploadV1ByUrl? = null, + private val _json: JsonValue? = null, + ) { - /** - * The name with which the file has to be uploaded. The file name can contain: - * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - * - Special Characters: `.`, `-` - * - * Any other character including space will be replaced by `_` - */ - fun fileName(fileName: String) = apply { body.fileName(fileName) } + fun fileUploadV1(): Optional = Optional.ofNullable(fileUploadV1) - /** - * Sets [Builder.fileName] to an arbitrary multipart value. - * - * You should usually call [Builder.fileName] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun fileName(fileName: MultipartField) = apply { body.fileName(fileName) } + fun fileUploadV1ByUrl(): Optional = + Optional.ofNullable(fileUploadV1ByUrl) - /** - * A unique value that the ImageKit.io server will use to recognize and prevent subsequent - * retries for the same request. We suggest using V4 UUIDs, or another random string with - * enough entropy to avoid collisions. This field is only required for authentication when - * uploading a file from the client side. - * - * **Note**: Sending a value that has been used in the past will result in a validation - * error. Even if your previous request resulted in an error, you should always send a new - * value for this field. - */ - fun token(token: String) = apply { body.token(token) } + fun isFileUploadV1(): Boolean = fileUploadV1 != null - /** - * Sets [Builder.token] to an arbitrary multipart value. - * - * You should usually call [Builder.token] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun token(token: MultipartField) = apply { body.token(token) } + fun isFileUploadV1ByUrl(): Boolean = fileUploadV1ByUrl != null - /** - * Server-side checks to run on the asset. Read more about - * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). - */ - fun checks(checks: String) = apply { body.checks(checks) } + fun asFileUploadV1(): FileUploadV1 = fileUploadV1.getOrThrow("fileUploadV1") - /** - * Sets [Builder.checks] to an arbitrary multipart value. - * - * You should usually call [Builder.checks] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun checks(checks: MultipartField) = apply { body.checks(checks) } + fun asFileUploadV1ByUrl(): FileUploadV1ByUrl = + fileUploadV1ByUrl.getOrThrow("fileUploadV1ByUrl") - /** - * Define an important area in the image. This is only relevant for image type files. - * - To be passed as a string with the x and y coordinates of the top-left corner, and width - * and height of the area of interest in the format `x,y,width,height`. For example - - * `10,10,100,100` - * - Can be used with fo-customtransformation. - * - If this field is not specified and the file is overwritten, then customCoordinates will - * be removed. - */ - fun customCoordinates(customCoordinates: String) = apply { - body.customCoordinates(customCoordinates) - } + fun _json(): Optional = Optional.ofNullable(_json) - /** - * Sets [Builder.customCoordinates] to an arbitrary multipart value. - * - * You should usually call [Builder.customCoordinates] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun customCoordinates(customCoordinates: MultipartField) = apply { - body.customCoordinates(customCoordinates) - } + fun accept(visitor: Visitor): T = + when { + fileUploadV1 != null -> visitor.visitFileUploadV1(fileUploadV1) + fileUploadV1ByUrl != null -> visitor.visitFileUploadV1ByUrl(fileUploadV1ByUrl) + else -> visitor.unknown(_json) + } - /** - * JSON key-value pairs to associate with the asset. Create the custom metadata fields - * before setting these values. - */ - fun customMetadata(customMetadata: CustomMetadata) = apply { - body.customMetadata(customMetadata) - } + private var validated: Boolean = false - /** - * Sets [Builder.customMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.customMetadata] with a well-typed [CustomMetadata] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun customMetadata(customMetadata: MultipartField) = apply { - body.customMetadata(customMetadata) - } + fun validate(): Body = apply { + if (validated) { + return@apply + } - /** Optional text to describe the contents of the file. */ - fun description(description: String) = apply { body.description(description) } + accept( + object : Visitor { + override fun visitFileUploadV1(fileUploadV1: FileUploadV1) { + fileUploadV1.validate() + } - /** - * Sets [Builder.description] to an arbitrary multipart 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: MultipartField) = apply { - body.description(description) + override fun visitFileUploadV1ByUrl(fileUploadV1ByUrl: FileUploadV1ByUrl) { + fileUploadV1ByUrl.validate() + } + } + ) + validated = true } - /** - * The time until your signature is valid. It must be a - * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. - * It should be in seconds. This field is only required for authentication when uploading a - * file from the client side. - */ - fun expire(expire: Long) = apply { body.expire(expire) } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } /** - * Sets [Builder.expire] to an arbitrary multipart value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.expire] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun expire(expire: MultipartField) = apply { body.expire(expire) } - - /** - * Array of extensions to be applied to the image. Each extension can be configured with - * specific parameters based on the extension type. + * Used for best match union deserialization. */ - fun extensions(extensions: List) = apply { body.extensions(extensions) } + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitFileUploadV1(fileUploadV1: FileUploadV1) = + fileUploadV1.validity() - /** - * Sets [Builder.extensions] to an arbitrary multipart value. - * - * You should usually call [Builder.extensions] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun extensions(extensions: MultipartField>) = apply { - body.extensions(extensions) - } + override fun visitFileUploadV1ByUrl(fileUploadV1ByUrl: FileUploadV1ByUrl) = + fileUploadV1ByUrl.validity() - /** - * Adds a single [Extension] to [extensions]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addExtension(extension: Extension) = apply { body.addExtension(extension) } + override fun unknown(json: JsonValue?) = 0 + } + ) - /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: Extension.RemoveBg) = apply { body.addExtension(removeBg) } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: Extension.AutoTaggingExtension) = apply { - body.addExtension(autoTagging) + return other is Body && + fileUploadV1 == other.fileUploadV1 && + fileUploadV1ByUrl == other.fileUploadV1ByUrl } - /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ - fun addExtensionAiAutoDescription() = apply { body.addExtensionAiAutoDescription() } + override fun hashCode(): Int = Objects.hash(fileUploadV1, fileUploadV1ByUrl) - /** - * The folder path in which the image has to be uploaded. If the folder(s) didn't exist - * before, a new folder(s) is created. - * - * The folder name can contain: - * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - * - Special Characters: `/` , `_` , `-` - * - * Using multiple `/` creates a nested folder. - */ - fun folder(folder: String) = apply { body.folder(folder) } + override fun toString(): String = + when { + fileUploadV1 != null -> "Body{fileUploadV1=$fileUploadV1}" + fileUploadV1ByUrl != null -> "Body{fileUploadV1ByUrl=$fileUploadV1ByUrl}" + _json != null -> "Body{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Body") + } - /** - * Sets [Builder.folder] to an arbitrary multipart value. - * - * You should usually call [Builder.folder] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun folder(folder: MultipartField) = apply { body.folder(folder) } + companion object { - /** - * Whether to mark the file as private or not. - * - * If `true`, the file is marked as private and is accessible only using named - * transformation or signed URL. - */ - fun isPrivateFile(isPrivateFile: Boolean) = apply { body.isPrivateFile(isPrivateFile) } + @JvmStatic + fun ofFileUploadV1(fileUploadV1: FileUploadV1) = Body(fileUploadV1 = fileUploadV1) - /** - * Sets [Builder.isPrivateFile] to an arbitrary multipart value. - * - * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun isPrivateFile(isPrivateFile: MultipartField) = apply { - body.isPrivateFile(isPrivateFile) + @JvmStatic + fun ofFileUploadV1ByUrl(fileUploadV1ByUrl: FileUploadV1ByUrl) = + Body(fileUploadV1ByUrl = fileUploadV1ByUrl) } - /** - * Whether to upload file as published or not. - * - * If `false`, the file is marked as unpublished, which restricts access to the file only - * via the media library. Files in draft or unpublished state can only be publicly accessed - * after being published. - * - * The option to upload in draft state is only available in custom enterprise pricing plans. - */ - fun isPublished(isPublished: Boolean) = apply { body.isPublished(isPublished) } - - /** - * Sets [Builder.isPublished] to an arbitrary multipart value. - * - * You should usually call [Builder.isPublished] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun isPublished(isPublished: MultipartField) = apply { - body.isPublished(isPublished) - } + /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ + interface Visitor { - /** - * If set to `true` and a file already exists at the exact location, its AITags will be - * removed. Set `overwriteAITags` to `false` to preserve AITags. - */ - fun overwriteAiTags(overwriteAiTags: Boolean) = apply { - body.overwriteAiTags(overwriteAiTags) - } + fun visitFileUploadV1(fileUploadV1: FileUploadV1): T - /** - * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteAiTags] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun overwriteAiTags(overwriteAiTags: MultipartField) = apply { - body.overwriteAiTags(overwriteAiTags) - } + fun visitFileUploadV1ByUrl(fileUploadV1ByUrl: FileUploadV1ByUrl): T - /** - * If the request does not have `customMetadata`, and a file already exists at the exact - * location, existing customMetadata will be removed. - */ - fun overwriteCustomMetadata(overwriteCustomMetadata: Boolean) = apply { - body.overwriteCustomMetadata(overwriteCustomMetadata) + /** + * Maps an unknown variant of [Body] to a value of type [T]. + * + * An instance of [Body] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Body: $json") + } } - /** - * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteCustomMetadata] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun overwriteCustomMetadata(overwriteCustomMetadata: MultipartField) = apply { - body.overwriteCustomMetadata(overwriteCustomMetadata) - } + internal class Deserializer : BaseDeserializer(Body::class) { - /** - * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the - * exact location, upload API will return an error immediately. - */ - fun overwriteFile(overwriteFile: Boolean) = apply { body.overwriteFile(overwriteFile) } + override fun ObjectCodec.deserialize(node: JsonNode): Body { + val json = JsonValue.fromJsonNode(node) - /** - * Sets [Builder.overwriteFile] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteFile] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun overwriteFile(overwriteFile: MultipartField) = apply { - body.overwriteFile(overwriteFile) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Body(fileUploadV1 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(fileUploadV1ByUrl = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Body(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } } - /** - * If the request does not have `tags`, and a file already exists at the exact location, - * existing tags will be removed. - */ - fun overwriteTags(overwriteTags: Boolean) = apply { body.overwriteTags(overwriteTags) } + internal class Serializer : BaseSerializer(Body::class) { - /** - * Sets [Builder.overwriteTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteTags] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun overwriteTags(overwriteTags: MultipartField) = apply { - body.overwriteTags(overwriteTags) + override fun serialize( + value: Body, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.fileUploadV1 != null -> generator.writeObject(value.fileUploadV1) + value.fileUploadV1ByUrl != null -> + generator.writeObject(value.fileUploadV1ByUrl) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Body") + } + } } - /** - * Your ImageKit.io public key. This field is only required for authentication when - * uploading a file from the client side. - */ - fun publicKey(publicKey: String) = apply { body.publicKey(publicKey) } - - /** - * Sets [Builder.publicKey] to an arbitrary multipart value. - * - * You should usually call [Builder.publicKey] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun publicKey(publicKey: MultipartField) = apply { body.publicKey(publicKey) } - - /** Array of response field keys to include in the API response body. */ - fun responseFields(responseFields: List) = apply { - body.responseFields(responseFields) - } + class FileUploadV1 + private constructor( + private val file: MultipartField, + private val fileName: MultipartField, + private val token: MultipartField, + private val checks: MultipartField, + private val customCoordinates: MultipartField, + private val customMetadata: MultipartField, + private val description: MultipartField, + private val expire: MultipartField, + private val extensions: MultipartField>, + private val folder: MultipartField, + private val isPrivateFile: MultipartField, + private val isPublished: MultipartField, + private val overwriteAiTags: MultipartField, + private val overwriteCustomMetadata: MultipartField, + private val overwriteFile: MultipartField, + private val overwriteTags: MultipartField, + private val publicKey: MultipartField, + private val responseFields: MultipartField>, + private val signature: MultipartField, + private val tags: MultipartField>, + private val transformation: MultipartField, + private val useUniqueFileName: MultipartField, + private val webhookUrl: MultipartField, + private val additionalProperties: MutableMap, + ) { - /** - * Sets [Builder.responseFields] to an arbitrary multipart value. - * - * You should usually call [Builder.responseFields] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun responseFields(responseFields: MultipartField>) = apply { - body.responseFields(responseFields) - } + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + * + * @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 file(): InputStream = file.value.getRequired("file") + + /** + * The name with which the file has to be uploaded. The file name can contain: + * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + * - Special Characters: `.`, `-` + * + * Any other character including space will be replaced by `_` + * + * @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 fileName(): String = fileName.value.getRequired("fileName") + + /** + * A unique value that the ImageKit.io server will use to recognize and prevent + * subsequent retries for the same request. We suggest using V4 UUIDs, or another random + * string with enough entropy to avoid collisions. This field is only required for + * authentication when uploading a file from the client side. + * + * **Note**: Sending a value that has been used in the past will result in a validation + * error. Even if your previous request resulted in an error, you should always send a + * new value for this field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun token(): Optional = token.value.getOptional("token") + + /** + * Server-side checks to run on the asset. Read more about + * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun checks(): Optional = checks.value.getOptional("checks") + + /** + * Define an important area in the image. This is only relevant for image type files. + * - To be passed as a string with the x and y coordinates of the top-left corner, and + * width and height of the area of interest in the format `x,y,width,height`. For + * example - `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates + * will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun customCoordinates(): Optional = + customCoordinates.value.getOptional("customCoordinates") + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields + * before setting these values. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun customMetadata(): Optional = + customMetadata.value.getOptional("customMetadata") + + /** + * Optional text to describe the contents of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional = description.value.getOptional("description") + + /** + * The time until your signature is valid. It must be a + * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the + * future. It should be in seconds. This field is only required for authentication when + * uploading a file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun expire(): Optional = expire.value.getOptional("expire") + + /** + * Array of extensions to be applied to the image. Each extension can be configured with + * specific parameters based on the extension type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun extensions(): Optional> = extensions.value.getOptional("extensions") + + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't exist + * before, a new folder(s) is created. + * + * The folder name can contain: + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun folder(): Optional = folder.value.getOptional("folder") + + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named + * transformation or signed URL. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun isPrivateFile(): Optional = + isPrivateFile.value.getOptional("isPrivateFile") + + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file + * only via the media library. Files in draft or unpublished state can only be publicly + * accessed after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing + * plans. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun isPublished(): Optional = isPublished.value.getOptional("isPublished") + + /** + * If set to `true` and a file already exists at the exact location, its AITags will be + * removed. Set `overwriteAITags` to `false` to preserve AITags. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun overwriteAiTags(): Optional = + overwriteAiTags.value.getOptional("overwriteAITags") + + /** + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun overwriteCustomMetadata(): Optional = + overwriteCustomMetadata.value.getOptional("overwriteCustomMetadata") + + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the + * exact location, upload API will return an error immediately. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun overwriteFile(): Optional = + overwriteFile.value.getOptional("overwriteFile") + + /** + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun overwriteTags(): Optional = + overwriteTags.value.getOptional("overwriteTags") + + /** + * Your ImageKit.io public key. This field is only required for authentication when + * uploading a file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun publicKey(): Optional = publicKey.value.getOptional("publicKey") + + /** + * Array of response field keys to include in the API response body. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun responseFields(): Optional> = + responseFields.value.getOptional("responseFields") + + /** + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. + * Learn how to create a signature on the page below. This should be in lowercase. + * + * Signature must be calculated on the server-side. This field is only required for + * authentication when uploading a file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun signature(): Optional = signature.value.getOptional("signature") + + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. + * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not + * exceed 500, and the `%` character is not allowed. If this field is not specified and + * the file is overwritten, the existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tags(): Optional> = tags.value.getOptional("tags") + + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for + * reducing file size or applying basic optimizations upfront (e.g., resize, + * compress). + * - `post` — applied immediately after upload. Ideal for generating transformed + * versions (like video encodes or thumbnails) in advance, so they're ready for + * delivery without delay. + * + * You can mix and match any combination of post-processing types. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun transformation(): Optional = + transformation.value.getOptional("transformation") + + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a + * unique filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any + * existing file with the same name is replaced. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun useUniqueFileName(): Optional = + useUniqueFileName.value.getOptional("useUniqueFileName") + + /** + * The final status of extensions after they have completed execution will be delivered + * to this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun webhookUrl(): Optional = webhookUrl.value.getOptional("webhookUrl") + + /** + * Returns the raw multipart value of [file]. + * + * Unlike [file], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField = file + + /** + * Returns the raw multipart value of [fileName]. + * + * Unlike [fileName], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("fileName") + @ExcludeMissing + fun _fileName(): MultipartField = fileName + + /** + * Returns the raw multipart value of [token]. + * + * Unlike [token], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): MultipartField = token + + /** + * Returns the raw multipart value of [checks]. + * + * Unlike [checks], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("checks") @ExcludeMissing fun _checks(): MultipartField = checks + + /** + * Returns the raw multipart value of [customCoordinates]. + * + * Unlike [customCoordinates], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("customCoordinates") + @ExcludeMissing + fun _customCoordinates(): MultipartField = customCoordinates + + /** + * Returns the raw multipart value of [customMetadata]. + * + * Unlike [customMetadata], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): MultipartField = customMetadata + + /** + * Returns the raw multipart value of [description]. + * + * Unlike [description], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): MultipartField = description + + /** + * Returns the raw multipart value of [expire]. + * + * Unlike [expire], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("expire") @ExcludeMissing fun _expire(): MultipartField = expire + + /** + * Returns the raw multipart value of [extensions]. + * + * Unlike [extensions], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("extensions") + @ExcludeMissing + fun _extensions(): MultipartField> = extensions + + /** + * Returns the raw multipart value of [folder]. + * + * Unlike [folder], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("folder") @ExcludeMissing fun _folder(): MultipartField = folder + + /** + * Returns the raw multipart value of [isPrivateFile]. + * + * Unlike [isPrivateFile], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("isPrivateFile") + @ExcludeMissing + fun _isPrivateFile(): MultipartField = isPrivateFile + + /** + * Returns the raw multipart value of [isPublished]. + * + * Unlike [isPublished], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("isPublished") + @ExcludeMissing + fun _isPublished(): MultipartField = isPublished + + /** + * Returns the raw multipart value of [overwriteAiTags]. + * + * Unlike [overwriteAiTags], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteAITags") + @ExcludeMissing + fun _overwriteAiTags(): MultipartField = overwriteAiTags + + /** + * Returns the raw multipart value of [overwriteCustomMetadata]. + * + * Unlike [overwriteCustomMetadata], this method doesn't throw if the multipart field + * has an unexpected type. + */ + @JsonProperty("overwriteCustomMetadata") + @ExcludeMissing + fun _overwriteCustomMetadata(): MultipartField = overwriteCustomMetadata + + /** + * Returns the raw multipart value of [overwriteFile]. + * + * Unlike [overwriteFile], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteFile") + @ExcludeMissing + fun _overwriteFile(): MultipartField = overwriteFile + + /** + * Returns the raw multipart value of [overwriteTags]. + * + * Unlike [overwriteTags], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteTags") + @ExcludeMissing + fun _overwriteTags(): MultipartField = overwriteTags + + /** + * Returns the raw multipart value of [publicKey]. + * + * Unlike [publicKey], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("publicKey") + @ExcludeMissing + fun _publicKey(): MultipartField = publicKey + + /** + * Returns the raw multipart value of [responseFields]. + * + * Unlike [responseFields], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("responseFields") + @ExcludeMissing + fun _responseFields(): MultipartField> = responseFields + + /** + * Returns the raw multipart value of [signature]. + * + * Unlike [signature], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("signature") + @ExcludeMissing + fun _signature(): MultipartField = signature + + /** + * Returns the raw multipart value of [tags]. + * + * Unlike [tags], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): MultipartField> = tags + + /** + * Returns the raw multipart value of [transformation]. + * + * Unlike [transformation], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("transformation") + @ExcludeMissing + fun _transformation(): MultipartField = transformation + + /** + * Returns the raw multipart value of [useUniqueFileName]. + * + * Unlike [useUniqueFileName], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("useUniqueFileName") + @ExcludeMissing + fun _useUniqueFileName(): MultipartField = useUniqueFileName + + /** + * Returns the raw multipart value of [webhookUrl]. + * + * Unlike [webhookUrl], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("webhookUrl") + @ExcludeMissing + fun _webhookUrl(): MultipartField = webhookUrl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FileUploadV1]. + * + * The following fields are required: + * ```java + * .file() + * .fileName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileUploadV1]. */ + class Builder internal constructor() { + + private var file: MultipartField? = null + private var fileName: MultipartField? = null + private var token: MultipartField = MultipartField.of(null) + private var checks: MultipartField = MultipartField.of(null) + private var customCoordinates: MultipartField = MultipartField.of(null) + private var customMetadata: MultipartField = MultipartField.of(null) + private var description: MultipartField = MultipartField.of(null) + private var expire: MultipartField = MultipartField.of(null) + private var extensions: MultipartField>? = null + private var folder: MultipartField = MultipartField.of(null) + private var isPrivateFile: MultipartField = MultipartField.of(null) + private var isPublished: MultipartField = MultipartField.of(null) + private var overwriteAiTags: MultipartField = MultipartField.of(null) + private var overwriteCustomMetadata: MultipartField = + MultipartField.of(null) + private var overwriteFile: MultipartField = MultipartField.of(null) + private var overwriteTags: MultipartField = MultipartField.of(null) + private var publicKey: MultipartField = MultipartField.of(null) + private var responseFields: MultipartField>? = null + private var signature: MultipartField = MultipartField.of(null) + private var tags: MultipartField>? = null + private var transformation: MultipartField = MultipartField.of(null) + private var useUniqueFileName: MultipartField = MultipartField.of(null) + private var webhookUrl: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fileUploadV1: FileUploadV1) = apply { + file = fileUploadV1.file + fileName = fileUploadV1.fileName + token = fileUploadV1.token + checks = fileUploadV1.checks + customCoordinates = fileUploadV1.customCoordinates + customMetadata = fileUploadV1.customMetadata + description = fileUploadV1.description + expire = fileUploadV1.expire + extensions = fileUploadV1.extensions.map { it.toMutableList() } + folder = fileUploadV1.folder + isPrivateFile = fileUploadV1.isPrivateFile + isPublished = fileUploadV1.isPublished + overwriteAiTags = fileUploadV1.overwriteAiTags + overwriteCustomMetadata = fileUploadV1.overwriteCustomMetadata + overwriteFile = fileUploadV1.overwriteFile + overwriteTags = fileUploadV1.overwriteTags + publicKey = fileUploadV1.publicKey + responseFields = fileUploadV1.responseFields.map { it.toMutableList() } + signature = fileUploadV1.signature + tags = fileUploadV1.tags.map { it.toMutableList() } + transformation = fileUploadV1.transformation + useUniqueFileName = fileUploadV1.useUniqueFileName + webhookUrl = fileUploadV1.webhookUrl + additionalProperties = fileUploadV1.additionalProperties.toMutableMap() + } + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can + * fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 + * seconds; otherwise the request fails with 400 Bad Request. + */ + fun file(file: InputStream) = file(MultipartField.of(file)) + + /** + * Sets [Builder.file] to an arbitrary multipart value. + * + * You should usually call [Builder.file] with a well-typed [InputStream] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun file(file: MultipartField) = apply { this.file = file } + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can + * fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 + * seconds; otherwise the request fails with 400 Bad Request. + */ + fun file(file: ByteArray) = file(file.inputStream()) + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can + * fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 + * seconds; otherwise the request fails with 400 Bad Request. + */ + fun file(path: Path) = + file( + MultipartField.builder() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + /** + * The name with which the file has to be uploaded. The file name can contain: + * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + * - Special Characters: `.`, `-` + * + * Any other character including space will be replaced by `_` + */ + fun fileName(fileName: String) = fileName(MultipartField.of(fileName)) + + /** + * Sets [Builder.fileName] to an arbitrary multipart value. + * + * You should usually call [Builder.fileName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun fileName(fileName: MultipartField) = apply { this.fileName = fileName } + + /** + * A unique value that the ImageKit.io server will use to recognize and prevent + * subsequent retries for the same request. We suggest using V4 UUIDs, or another + * random string with enough entropy to avoid collisions. This field is only + * required for authentication when uploading a file from the client side. + * + * **Note**: Sending a value that has been used in the past will result in a + * validation error. Even if your previous request resulted in an error, you should + * always send a new value for this field. + */ + fun token(token: String) = token(MultipartField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary multipart value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: MultipartField) = apply { this.token = token } + + /** + * Server-side checks to run on the asset. Read more about + * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + */ + fun checks(checks: String) = checks(MultipartField.of(checks)) + + /** + * Sets [Builder.checks] to an arbitrary multipart value. + * + * You should usually call [Builder.checks] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun checks(checks: MultipartField) = apply { this.checks = checks } + + /** + * Define an important area in the image. This is only relevant for image type + * files. + * - To be passed as a string with the x and y coordinates of the top-left corner, + * and width and height of the area of interest in the format `x,y,width,height`. + * For example - `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then + * customCoordinates will be removed. + */ + fun customCoordinates(customCoordinates: String) = + customCoordinates(MultipartField.of(customCoordinates)) + + /** + * Sets [Builder.customCoordinates] to an arbitrary multipart value. + * + * You should usually call [Builder.customCoordinates] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun customCoordinates(customCoordinates: MultipartField) = apply { + this.customCoordinates = customCoordinates + } + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata + * fields before setting these values. + */ + fun customMetadata(customMetadata: CustomMetadata) = + customMetadata(MultipartField.of(customMetadata)) + + /** + * Sets [Builder.customMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.customMetadata] with a well-typed + * [CustomMetadata] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun customMetadata(customMetadata: MultipartField) = apply { + this.customMetadata = customMetadata + } + + /** Optional text to describe the contents of the file. */ + fun description(description: String) = description(MultipartField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary multipart 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: MultipartField) = apply { + this.description = description + } + + /** + * The time until your signature is valid. It must be a + * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the + * future. It should be in seconds. This field is only required for authentication + * when uploading a file from the client side. + */ + fun expire(expire: Long) = expire(MultipartField.of(expire)) + + /** + * Sets [Builder.expire] to an arbitrary multipart value. + * + * You should usually call [Builder.expire] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expire(expire: MultipartField) = apply { this.expire = expire } + + /** + * Array of extensions to be applied to the image. Each extension can be configured + * with specific parameters based on the extension type. + */ + fun extensions(extensions: List) = + extensions(MultipartField.of(extensions)) + + /** + * Sets [Builder.extensions] to an arbitrary multipart value. + * + * You should usually call [Builder.extensions] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun extensions(extensions: MultipartField>) = apply { + this.extensions = extensions.map { it.toMutableList() } + } + + /** + * Adds a single [Extension] to [extensions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExtension(extension: Extension) = apply { + extensions = + (extensions ?: MultipartField.of(mutableListOf())).also { + checkKnown("extensions", it).add(extension) + } + } + + /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ + fun addExtension(removeBg: Extension.RemoveBg) = + addExtension(Extension.ofRemoveBg(removeBg)) + + /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = + addExtension(Extension.ofAutoTagging(autoTagging)) + + /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ + fun addExtensionAiAutoDescription() = addExtension(Extension.ofAiAutoDescription()) + + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't + * exist before, a new folder(s) is created. + * + * The folder name can contain: + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. + */ + fun folder(folder: String) = folder(MultipartField.of(folder)) + + /** + * Sets [Builder.folder] to an arbitrary multipart value. + * + * You should usually call [Builder.folder] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun folder(folder: MultipartField) = apply { this.folder = folder } + + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named + * transformation or signed URL. + */ + fun isPrivateFile(isPrivateFile: Boolean) = + isPrivateFile(MultipartField.of(isPrivateFile)) + + /** + * Sets [Builder.isPrivateFile] to an arbitrary multipart value. + * + * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun isPrivateFile(isPrivateFile: MultipartField) = apply { + this.isPrivateFile = isPrivateFile + } + + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file + * only via the media library. Files in draft or unpublished state can only be + * publicly accessed after being published. + * + * The option to upload in draft state is only available in custom enterprise + * pricing plans. + */ + fun isPublished(isPublished: Boolean) = isPublished(MultipartField.of(isPublished)) + + /** + * Sets [Builder.isPublished] to an arbitrary multipart value. + * + * You should usually call [Builder.isPublished] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun isPublished(isPublished: MultipartField) = apply { + this.isPublished = isPublished + } + + /** + * If set to `true` and a file already exists at the exact location, its AITags will + * be removed. Set `overwriteAITags` to `false` to preserve AITags. + */ + fun overwriteAiTags(overwriteAiTags: Boolean) = + overwriteAiTags(MultipartField.of(overwriteAiTags)) + + /** + * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteAiTags] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun overwriteAiTags(overwriteAiTags: MultipartField) = apply { + this.overwriteAiTags = overwriteAiTags + } + + /** + * If the request does not have `customMetadata`, and a file already exists at the + * exact location, existing customMetadata will be removed. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: Boolean) = + overwriteCustomMetadata(MultipartField.of(overwriteCustomMetadata)) + + /** + * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteCustomMetadata] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: MultipartField) = + apply { + this.overwriteCustomMetadata = overwriteCustomMetadata + } + + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at + * the exact location, upload API will return an error immediately. + */ + fun overwriteFile(overwriteFile: Boolean) = + overwriteFile(MultipartField.of(overwriteFile)) + + /** + * Sets [Builder.overwriteFile] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun overwriteFile(overwriteFile: MultipartField) = apply { + this.overwriteFile = overwriteFile + } + + /** + * If the request does not have `tags`, and a file already exists at the exact + * location, existing tags will be removed. + */ + fun overwriteTags(overwriteTags: Boolean) = + overwriteTags(MultipartField.of(overwriteTags)) + + /** + * Sets [Builder.overwriteTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteTags] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun overwriteTags(overwriteTags: MultipartField) = apply { + this.overwriteTags = overwriteTags + } + + /** + * Your ImageKit.io public key. This field is only required for authentication when + * uploading a file from the client side. + */ + fun publicKey(publicKey: String) = publicKey(MultipartField.of(publicKey)) + + /** + * Sets [Builder.publicKey] to an arbitrary multipart value. + * + * You should usually call [Builder.publicKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun publicKey(publicKey: MultipartField) = apply { + this.publicKey = publicKey + } + + /** Array of response field keys to include in the API response body. */ + fun responseFields(responseFields: List) = + responseFields(MultipartField.of(responseFields)) + + /** + * Sets [Builder.responseFields] to an arbitrary multipart value. + * + * You should usually call [Builder.responseFields] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun responseFields(responseFields: MultipartField>) = apply { + this.responseFields = responseFields.map { it.toMutableList() } + } + + /** + * Adds a single [ResponseField] to [responseFields]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResponseField(responseField: ResponseField) = apply { + responseFields = + (responseFields ?: MultipartField.of(mutableListOf())).also { + checkKnown("responseFields", it).add(responseField) + } + } + + /** + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a + * key. Learn how to create a signature on the page below. This should be in + * lowercase. + * + * Signature must be calculated on the server-side. This field is only required for + * authentication when uploading a file from the client side. + */ + fun signature(signature: String) = signature(MultipartField.of(signature)) + + /** + * Sets [Builder.signature] to an arbitrary multipart value. + * + * You should usually call [Builder.signature] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun signature(signature: MultipartField) = apply { + this.signature = signature + } + + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. + * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not + * exceed 500, and the `%` character is not allowed. If this field is not specified + * and the file is overwritten, the existing tags will be removed. + */ + fun tags(tags: List) = tags(MultipartField.of(tags)) + + /** + * Sets [Builder.tags] to an arbitrary multipart value. + * + * You should usually call [Builder.tags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tags(tags: MultipartField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = + (tags ?: MultipartField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } + + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for + * reducing file size or applying basic optimizations upfront (e.g., resize, + * compress). + * - `post` — applied immediately after upload. Ideal for generating transformed + * versions (like video encodes or thumbnails) in advance, so they're ready for + * delivery without delay. + * + * You can mix and match any combination of post-processing types. + */ + fun transformation(transformation: Transformation) = + transformation(MultipartField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary multipart value. + * + * You should usually call [Builder.transformation] with a well-typed + * [Transformation] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun transformation(transformation: MultipartField) = apply { + this.transformation = transformation + } + + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get + * a unique filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and + * any existing file with the same name is replaced. + */ + fun useUniqueFileName(useUniqueFileName: Boolean) = + useUniqueFileName(MultipartField.of(useUniqueFileName)) + + /** + * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. + * + * You should usually call [Builder.useUniqueFileName] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun useUniqueFileName(useUniqueFileName: MultipartField) = apply { + this.useUniqueFileName = useUniqueFileName + } + + /** + * The final status of extensions after they have completed execution will be + * delivered to this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + */ + fun webhookUrl(webhookUrl: String) = webhookUrl(MultipartField.of(webhookUrl)) + + /** + * Sets [Builder.webhookUrl] to an arbitrary multipart value. + * + * You should usually call [Builder.webhookUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun webhookUrl(webhookUrl: MultipartField) = apply { + this.webhookUrl = webhookUrl + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FileUploadV1]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .file() + * .fileName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FileUploadV1 = + FileUploadV1( + checkRequired("file", file), + checkRequired("fileName", fileName), + token, + checks, + customCoordinates, + customMetadata, + description, + expire, + (extensions ?: MultipartField.of(null)).map { it.toImmutable() }, + folder, + isPrivateFile, + isPublished, + overwriteAiTags, + overwriteCustomMetadata, + overwriteFile, + overwriteTags, + publicKey, + (responseFields ?: MultipartField.of(null)).map { it.toImmutable() }, + signature, + (tags ?: MultipartField.of(null)).map { it.toImmutable() }, + transformation, + useUniqueFileName, + webhookUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FileUploadV1 = apply { + if (validated) { + return@apply + } + + file() + fileName() + token() + checks() + customCoordinates() + customMetadata().ifPresent { it.validate() } + description() + expire() + extensions().ifPresent { it.forEach { it.validate() } } + folder() + isPrivateFile() + isPublished() + overwriteAiTags() + overwriteCustomMetadata() + overwriteFile() + overwriteTags() + publicKey() + responseFields().ifPresent { it.forEach { it.validate() } } + signature() + tags() + transformation().ifPresent { it.validate() } + useUniqueFileName() + webhookUrl() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields + * before setting these values. + */ + class CustomMetadata + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomMetadata]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customMetadata: CustomMetadata) = apply { + additionalProperties = customMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CustomMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomMetadata{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Extension.Deserializer::class) + @JsonSerialize(using = Extension.Serializer::class) + class Extension + private constructor( + private val removeBg: RemoveBg? = null, + private val autoTagging: AutoTaggingExtension? = null, + private val aiAutoDescription: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun removeBg(): Optional = Optional.ofNullable(removeBg) + + fun autoTagging(): Optional = Optional.ofNullable(autoTagging) + + fun aiAutoDescription(): Optional = + Optional.ofNullable(aiAutoDescription) + + fun isRemoveBg(): Boolean = removeBg != null + + fun isAutoTagging(): Boolean = autoTagging != null + + fun isAiAutoDescription(): Boolean = aiAutoDescription != null + + fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") + + fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") + + fun asAiAutoDescription(): JsonValue = + aiAutoDescription.getOrThrow("aiAutoDescription") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + removeBg != null -> visitor.visitRemoveBg(removeBg) + autoTagging != null -> visitor.visitAutoTagging(autoTagging) + aiAutoDescription != null -> + visitor.visitAiAutoDescription(aiAutoDescription) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Extension = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) { + removeBg.validate() + } + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { + autoTagging.validate() + } + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { + aiAutoDescription.let { + if ( + it != JsonValue.from(mapOf("name" to "ai-auto-description")) + ) { + throw ImageKitInvalidDataException( + "'aiAutoDescription' is invalid, received $it" + ) + } + } + } + } + ) + 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 = + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = + autoTagging.validity() + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = + aiAutoDescription.let { + if ( + it == JsonValue.from(mapOf("name" to "ai-auto-description")) + ) + 1 + else 0 + } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extension && + removeBg == other.removeBg && + autoTagging == other.autoTagging && + aiAutoDescription == other.aiAutoDescription + } + + override fun hashCode(): Int = + Objects.hash(removeBg, autoTagging, aiAutoDescription) + + override fun toString(): String = + when { + removeBg != null -> "Extension{removeBg=$removeBg}" + autoTagging != null -> "Extension{autoTagging=$autoTagging}" + aiAutoDescription != null -> + "Extension{aiAutoDescription=$aiAutoDescription}" + _json != null -> "Extension{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Extension") + } + + companion object { + + @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = Extension(removeBg = removeBg) + + @JvmStatic + fun ofAutoTagging(autoTagging: AutoTaggingExtension) = + Extension(autoTagging = autoTagging) + + @JvmStatic + fun ofAiAutoDescription() = + Extension( + aiAutoDescription = + JsonValue.from(mapOf("name" to "ai-auto-description")) + ) + } + + /** + * An interface that defines how to map each variant of [Extension] to a value of + * type [T]. + */ + interface Visitor { + + fun visitRemoveBg(removeBg: RemoveBg): T + + fun visitAutoTagging(autoTagging: AutoTaggingExtension): T + + fun visitAiAutoDescription(aiAutoDescription: JsonValue): T + + /** + * Maps an unknown variant of [Extension] to a value of type [T]. + * + * An instance of [Extension] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Extension: $json") + } + } + + internal class Deserializer : BaseDeserializer(Extension::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Extension { + val json = JsonValue.fromJsonNode(node) + val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() + + when (name) { + "remove-bg" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Extension(removeBg = it, _json = json) + } ?: Extension(_json = json) + } + "ai-auto-description" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Extension(aiAutoDescription = it, _json = json) } + ?.takeIf { it.isValid() } ?: Extension(_json = json) + } + } + + return tryDeserialize(node, jacksonTypeRef())?.let { + Extension(autoTagging = it, _json = json) + } ?: Extension(_json = json) + } + } + + internal class Serializer : BaseSerializer(Extension::class) { + + override fun serialize( + value: Extension, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.removeBg != null -> generator.writeObject(value.removeBg) + value.autoTagging != null -> generator.writeObject(value.autoTagging) + value.aiAutoDescription != null -> + generator.writeObject(value.aiAutoDescription) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Extension") + } + } + } + + class RemoveBg + private constructor( + private val name: JsonValue, + private val options: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Specifies the background removal extension. + * + * Expected to always return the following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun options(): Optional = options.value.getOptional("options") + + /** + * Returns the raw multipart value of [options]. + * + * Unlike [options], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("options") + @ExcludeMissing + fun _options(): MultipartField = options + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveBg]. */ + class Builder internal constructor() { + + private var name: JsonValue = JsonValue.from("remove-bg") + private var options: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(removeBg: RemoveBg) = apply { + name = removeBg.name + options = removeBg.options + additionalProperties = removeBg.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + fun options(options: Options) = options(MultipartField.of(options)) + + /** + * Sets [Builder.options] to an arbitrary multipart value. + * + * You should usually call [Builder.options] with a well-typed [Options] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun options(options: MultipartField) = apply { + this.options = options + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemoveBg]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemoveBg = + RemoveBg(name, options, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): RemoveBg = apply { + if (validated) { + return@apply + } + + _name().let { + if (it != JsonValue.from("remove-bg")) { + throw ImageKitInvalidDataException( + "'name' is invalid, received $it" + ) + } + } + options().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + class Options + private constructor( + private val addShadow: MultipartField, + private val bgColor: MultipartField, + private val bgImageUrl: MultipartField, + private val semitransparency: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Whether to add an artificial shadow to the result. Default is false. + * Note: Adding shadows is currently only supported for car photos. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun addShadow(): Optional = + addShadow.value.getOptional("add_shadow") + + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") + * or color name (e.g., "green"). If this parameter is set, `bg_image_url` + * must be empty. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun bgColor(): Optional = bgColor.value.getOptional("bg_color") + + /** + * Sets a background image from a URL. If this parameter is set, `bg_color` + * must be empty. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun bgImageUrl(): Optional = + bgImageUrl.value.getOptional("bg_image_url") + + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun semitransparency(): Optional = + semitransparency.value.getOptional("semitransparency") + + /** + * Returns the raw multipart value of [addShadow]. + * + * Unlike [addShadow], this method doesn't throw if the multipart field has + * an unexpected type. + */ + @JsonProperty("add_shadow") + @ExcludeMissing + fun _addShadow(): MultipartField = addShadow + + /** + * Returns the raw multipart value of [bgColor]. + * + * Unlike [bgColor], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("bg_color") + @ExcludeMissing + fun _bgColor(): MultipartField = bgColor + + /** + * Returns the raw multipart value of [bgImageUrl]. + * + * Unlike [bgImageUrl], this method doesn't throw if the multipart field has + * an unexpected type. + */ + @JsonProperty("bg_image_url") + @ExcludeMissing + fun _bgImageUrl(): MultipartField = bgImageUrl + + /** + * Returns the raw multipart value of [semitransparency]. + * + * Unlike [semitransparency], this method doesn't throw if the multipart + * field has an unexpected type. + */ + @JsonProperty("semitransparency") + @ExcludeMissing + fun _semitransparency(): MultipartField = semitransparency + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Options]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Options]. */ + class Builder internal constructor() { + + private var addShadow: MultipartField = MultipartField.of(null) + private var bgColor: MultipartField = MultipartField.of(null) + private var bgImageUrl: MultipartField = MultipartField.of(null) + private var semitransparency: MultipartField = + MultipartField.of(null) + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(options: Options) = apply { + addShadow = options.addShadow + bgColor = options.bgColor + bgImageUrl = options.bgImageUrl + semitransparency = options.semitransparency + additionalProperties = options.additionalProperties.toMutableMap() + } + + /** + * Whether to add an artificial shadow to the result. Default is false. + * Note: Adding shadows is currently only supported for car photos. + */ + fun addShadow(addShadow: Boolean) = + addShadow(MultipartField.of(addShadow)) + + /** + * Sets [Builder.addShadow] to an arbitrary multipart value. + * + * You should usually call [Builder.addShadow] with a well-typed + * [Boolean] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun addShadow(addShadow: MultipartField) = apply { + this.addShadow = addShadow + } + + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", + * "fff") or color name (e.g., "green"). If this parameter is set, + * `bg_image_url` must be empty. + */ + fun bgColor(bgColor: String) = bgColor(MultipartField.of(bgColor)) + + /** + * Sets [Builder.bgColor] to an arbitrary multipart value. + * + * You should usually call [Builder.bgColor] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun bgColor(bgColor: MultipartField) = apply { + this.bgColor = bgColor + } + + /** + * Sets a background image from a URL. If this parameter is set, + * `bg_color` must be empty. + */ + fun bgImageUrl(bgImageUrl: String) = + bgImageUrl(MultipartField.of(bgImageUrl)) + + /** + * Sets [Builder.bgImageUrl] to an arbitrary multipart value. + * + * You should usually call [Builder.bgImageUrl] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun bgImageUrl(bgImageUrl: MultipartField) = apply { + this.bgImageUrl = bgImageUrl + } + + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + */ + fun semitransparency(semitransparency: Boolean) = + semitransparency(MultipartField.of(semitransparency)) + + /** + * Sets [Builder.semitransparency] to an arbitrary multipart value. + * + * You should usually call [Builder.semitransparency] with a well-typed + * [Boolean] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun semitransparency(semitransparency: MultipartField) = + apply { + this.semitransparency = semitransparency + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Options]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): Options = + Options( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Options = apply { + if (validated) { + return@apply + } + + addShadow() + bgColor() + bgImageUrl() + semitransparency() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Options && + addShadow == other.addShadow && + bgColor == other.bgColor && + bgImageUrl == other.bgImageUrl && + semitransparency == other.semitransparency && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveBg && + name == other.name && + options == other.options && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(name, options, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" + } + + class AutoTaggingExtension + private constructor( + private val maxTags: MultipartField, + private val minConfidence: MultipartField, + private val name: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Maximum number of tags to attach to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maxTags(): Long = maxTags.value.getRequired("maxTags") + + /** + * Minimum confidence level for tags to be considered valid. + * + * @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 minConfidence(): Long = minConfidence.value.getRequired("minConfidence") + + /** + * Specifies the auto-tagging extension used. + * + * @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(): Name = name.value.getRequired("name") + + /** + * Returns the raw multipart value of [maxTags]. + * + * Unlike [maxTags], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("maxTags") + @ExcludeMissing + fun _maxTags(): MultipartField = maxTags + + /** + * Returns the raw multipart value of [minConfidence]. + * + * Unlike [minConfidence], this method doesn't throw if the multipart field has + * an unexpected type. + */ + @JsonProperty("minConfidence") + @ExcludeMissing + fun _minConfidence(): MultipartField = minConfidence + + /** + * Returns the raw multipart value of [name]. + * + * Unlike [name], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AutoTaggingExtension]. + * + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutoTaggingExtension]. */ + class Builder internal constructor() { + + private var maxTags: MultipartField? = null + private var minConfidence: MultipartField? = null + private var name: MultipartField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { + maxTags = autoTaggingExtension.maxTags + minConfidence = autoTaggingExtension.minConfidence + name = autoTaggingExtension.name + additionalProperties = + autoTaggingExtension.additionalProperties.toMutableMap() + } + + /** Maximum number of tags to attach to the asset. */ + fun maxTags(maxTags: Long) = maxTags(MultipartField.of(maxTags)) + + /** + * Sets [Builder.maxTags] to an arbitrary multipart value. + * + * You should usually call [Builder.maxTags] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun maxTags(maxTags: MultipartField) = apply { + this.maxTags = maxTags + } + + /** Minimum confidence level for tags to be considered valid. */ + fun minConfidence(minConfidence: Long) = + minConfidence(MultipartField.of(minConfidence)) + + /** + * Sets [Builder.minConfidence] to an arbitrary multipart value. + * + * You should usually call [Builder.minConfidence] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minConfidence(minConfidence: MultipartField) = apply { + this.minConfidence = minConfidence + } + + /** Specifies the auto-tagging extension used. */ + fun name(name: Name) = name(MultipartField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary multipart value. + * + * You should usually call [Builder.name] with a well-typed [Name] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun name(name: MultipartField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutoTaggingExtension]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutoTaggingExtension = + AutoTaggingExtension( + checkRequired("maxTags", maxTags), + checkRequired("minConfidence", minConfidence), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutoTaggingExtension = apply { + if (validated) { + return@apply + } + + maxTags() + minConfidence() + name().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Specifies the auto-tagging extension used. */ + class Name + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") + + @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + } + + /** + * An enum containing [Name]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Name] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + /** + * An enum member indicating that [Name] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING + else -> throw ImageKitInvalidDataException("Unknown Name: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Name = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Name && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutoTaggingExtension && + maxTags == other.maxTags && + minConfidence == other.minConfidence && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(maxTags, minConfidence, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" + } + } + + class ResponseField + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TAGS = of("tags") + + @JvmField val CUSTOM_COORDINATES = of("customCoordinates") + + @JvmField val IS_PRIVATE_FILE = of("isPrivateFile") + + @JvmField val EMBEDDED_METADATA = of("embeddedMetadata") + + @JvmField val IS_PUBLISHED = of("isPublished") + + @JvmField val CUSTOM_METADATA = of("customMetadata") + + @JvmField val METADATA = of("metadata") + + @JvmStatic fun of(value: String) = ResponseField(JsonField.of(value)) + } + + /** An enum containing [ResponseField]'s known values. */ + enum class Known { + TAGS, + CUSTOM_COORDINATES, + IS_PRIVATE_FILE, + EMBEDDED_METADATA, + IS_PUBLISHED, + CUSTOM_METADATA, + METADATA, + } + + /** + * An enum containing [ResponseField]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ResponseField] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TAGS, + CUSTOM_COORDINATES, + IS_PRIVATE_FILE, + EMBEDDED_METADATA, + IS_PUBLISHED, + CUSTOM_METADATA, + METADATA, + /** + * An enum member indicating that [ResponseField] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TAGS -> Value.TAGS + CUSTOM_COORDINATES -> Value.CUSTOM_COORDINATES + IS_PRIVATE_FILE -> Value.IS_PRIVATE_FILE + EMBEDDED_METADATA -> Value.EMBEDDED_METADATA + IS_PUBLISHED -> Value.IS_PUBLISHED + CUSTOM_METADATA -> Value.CUSTOM_METADATA + METADATA -> Value.METADATA + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + TAGS -> Known.TAGS + CUSTOM_COORDINATES -> Known.CUSTOM_COORDINATES + IS_PRIVATE_FILE -> Known.IS_PRIVATE_FILE + EMBEDDED_METADATA -> Known.EMBEDDED_METADATA + IS_PUBLISHED -> Known.IS_PUBLISHED + CUSTOM_METADATA -> Known.CUSTOM_METADATA + METADATA -> Known.METADATA + else -> throw ImageKitInvalidDataException("Unknown ResponseField: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ResponseField = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResponseField && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for + * reducing file size or applying basic optimizations upfront (e.g., resize, + * compress). + * - `post` — applied immediately after upload. Ideal for generating transformed + * versions (like video encodes or thumbnails) in advance, so they're ready for + * delivery without delay. + * + * You can mix and match any combination of post-processing types. + */ + class Transformation + private constructor( + private val post: MultipartField>, + private val pre: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * List of transformations to apply _after_ the file is uploaded. Each item must + * match one of the following types: `transformation`, `gif-to-video`, `thumbnail`, + * `abs`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun post(): Optional> = post.value.getOptional("post") + + /** + * Transformation string to apply before uploading the file to the Media Library. + * Useful for optimizing files at ingestion. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun pre(): Optional = pre.value.getOptional("pre") + + /** + * Returns the raw multipart value of [post]. + * + * Unlike [post], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("post") @ExcludeMissing fun _post(): MultipartField> = post + + /** + * Returns the raw multipart value of [pre]. + * + * Unlike [pre], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("pre") @ExcludeMissing fun _pre(): MultipartField = pre + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Transformation]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Transformation]. */ + class Builder internal constructor() { + + private var post: MultipartField>? = null + private var pre: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(transformation: Transformation) = apply { + post = transformation.post.map { it.toMutableList() } + pre = transformation.pre + additionalProperties = transformation.additionalProperties.toMutableMap() + } + + /** + * List of transformations to apply _after_ the file is uploaded. Each item must + * match one of the following types: `transformation`, `gif-to-video`, + * `thumbnail`, `abs`. + */ + fun post(post: List) = post(MultipartField.of(post)) + + /** + * Sets [Builder.post] to an arbitrary multipart value. + * + * You should usually call [Builder.post] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun post(post: MultipartField>) = apply { + this.post = post.map { it.toMutableList() } + } + + /** + * Adds a single [Post] to [Builder.post]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPost(post: Post) = apply { + this.post = + (this.post ?: MultipartField.of(mutableListOf())).also { + checkKnown("post", it).add(post) + } + } + + /** Alias for calling [addPost] with `Post.ofTransformation(transformation)`. */ + fun addPost(transformation: Post.InnerTransformation) = + addPost(Post.ofTransformation(transformation)) + + /** + * Alias for calling [addPost] with the following: + * ```java + * Post.InnerTransformation.builder() + * .value(value) + * .build() + * ``` + */ + fun addTransformationPost(value: String) = + addPost(Post.InnerTransformation.builder().value(value).build()) + + /** Alias for calling [addPost] with `Post.ofGifToVideo(gifToVideo)`. */ + fun addPost(gifToVideo: Post.GifToVideo) = + addPost(Post.ofGifToVideo(gifToVideo)) + + /** Alias for calling [addPost] with `Post.ofThumbnail(thumbnail)`. */ + fun addPost(thumbnail: Post.Thumbnail) = addPost(Post.ofThumbnail(thumbnail)) + + /** Alias for calling [addPost] with `Post.ofAbs(abs)`. */ + fun addPost(abs: Post.Abs) = addPost(Post.ofAbs(abs)) + + /** + * Transformation string to apply before uploading the file to the Media + * Library. Useful for optimizing files at ingestion. + */ + fun pre(pre: String) = pre(MultipartField.of(pre)) + + /** + * Sets [Builder.pre] to an arbitrary multipart value. + * + * You should usually call [Builder.pre] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun pre(pre: MultipartField) = apply { this.pre = pre } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Adds a single [ResponseField] to [responseFields]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addResponseField(responseField: ResponseField) = apply { - body.addResponseField(responseField) - } + /** + * Returns an immutable instance of [Transformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Transformation = + Transformation( + (post ?: MultipartField.of(null)).map { it.toImmutable() }, + pre, + additionalProperties.toMutableMap(), + ) + } - /** - * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. - * Learn how to create a signature on the page below. This should be in lowercase. - * - * Signature must be calculated on the server-side. This field is only required for - * authentication when uploading a file from the client side. - */ - fun signature(signature: String) = apply { body.signature(signature) } + private var validated: Boolean = false - /** - * Sets [Builder.signature] to an arbitrary multipart value. - * - * You should usually call [Builder.signature] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun signature(signature: MultipartField) = apply { body.signature(signature) } + fun validate(): Transformation = apply { + if (validated) { + return@apply + } - /** - * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", - * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the - * `%` character is not allowed. If this field is not specified and the file is overwritten, - * the existing tags will be removed. - */ - fun tags(tags: List) = apply { body.tags(tags) } + post().ifPresent { it.forEach { it.validate() } } + pre() + validated = true + } - /** - * Sets [Builder.tags] to an arbitrary multipart value. - * - * You should usually call [Builder.tags] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun tags(tags: MultipartField>) = apply { body.tags(tags) } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - /** - * Adds a single [String] to [tags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTag(tag: String) = apply { body.addTag(tag) } + @JsonDeserialize(using = Post.Deserializer::class) + @JsonSerialize(using = Post.Serializer::class) + class Post + private constructor( + private val transformation: InnerTransformation? = null, + private val gifToVideo: GifToVideo? = null, + private val thumbnail: Thumbnail? = null, + private val abs: Abs? = null, + private val _json: JsonValue? = null, + ) { - /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing - * file size or applying basic optimizations upfront (e.g., resize, compress). - * - `post` — applied immediately after upload. Ideal for generating transformed versions - * (like video encodes or thumbnails) in advance, so they're ready for delivery without - * delay. - * - * You can mix and match any combination of post-processing types. - */ - fun transformation(transformation: Transformation) = apply { - body.transformation(transformation) - } + fun transformation(): Optional = + Optional.ofNullable(transformation) - /** - * Sets [Builder.transformation] to an arbitrary multipart value. - * - * You should usually call [Builder.transformation] with a well-typed [Transformation] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun transformation(transformation: MultipartField) = apply { - body.transformation(transformation) - } + fun gifToVideo(): Optional = Optional.ofNullable(gifToVideo) - /** - * Whether to use a unique filename for this file or not. - * - * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique - * filename. - * - * If `false`, then the image is uploaded with the provided filename parameter, and any - * existing file with the same name is replaced. - */ - fun useUniqueFileName(useUniqueFileName: Boolean) = apply { - body.useUniqueFileName(useUniqueFileName) - } + fun thumbnail(): Optional = Optional.ofNullable(thumbnail) - /** - * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. - * - * You should usually call [Builder.useUniqueFileName] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun useUniqueFileName(useUniqueFileName: MultipartField) = apply { - body.useUniqueFileName(useUniqueFileName) - } + fun abs(): Optional = Optional.ofNullable(abs) - /** - * The final status of extensions after they have completed execution will be delivered to - * this endpoint as a POST request. - * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - * about the webhook payload structure. - */ - fun webhookUrl(webhookUrl: String) = apply { body.webhookUrl(webhookUrl) } + fun isTransformation(): Boolean = transformation != null - /** - * Sets [Builder.webhookUrl] to an arbitrary multipart value. - * - * You should usually call [Builder.webhookUrl] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun webhookUrl(webhookUrl: MultipartField) = apply { body.webhookUrl(webhookUrl) } + fun isGifToVideo(): Boolean = gifToVideo != null - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun isThumbnail(): Boolean = thumbnail != null - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun isAbs(): Boolean = abs != null - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } + fun asTransformation(): InnerTransformation = + transformation.getOrThrow("transformation") - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun asGifToVideo(): GifToVideo = gifToVideo.getOrThrow("gifToVideo") - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun asThumbnail(): Thumbnail = thumbnail.getOrThrow("thumbnail") - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun asAbs(): Abs = abs.getOrThrow("abs") - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun _json(): Optional = Optional.ofNullable(_json) - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun accept(visitor: Visitor): T = + when { + transformation != null -> visitor.visitTransformation(transformation) + gifToVideo != null -> visitor.visitGifToVideo(gifToVideo) + thumbnail != null -> visitor.visitThumbnail(thumbnail) + abs != null -> visitor.visitAbs(abs) + else -> visitor.unknown(_json) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + private var validated: Boolean = false - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun validate(): Post = apply { + if (validated) { + return@apply + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + accept( + object : Visitor { + override fun visitTransformation( + transformation: InnerTransformation + ) { + transformation.validate() + } + + override fun visitGifToVideo(gifToVideo: GifToVideo) { + gifToVideo.validate() + } + + override fun visitThumbnail(thumbnail: Thumbnail) { + thumbnail.validate() + } + + override fun visitAbs(abs: Abs) { + abs.validate() + } + } + ) + validated = true + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitTransformation( + transformation: InnerTransformation + ) = transformation.validity() - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + override fun visitGifToVideo(gifToVideo: GifToVideo) = + gifToVideo.validity() - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + override fun visitThumbnail(thumbnail: Thumbnail) = + thumbnail.validity() - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + override fun visitAbs(abs: Abs) = abs.validity() - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Post && + transformation == other.transformation && + gifToVideo == other.gifToVideo && + thumbnail == other.thumbnail && + abs == other.abs + } + + override fun hashCode(): Int = + Objects.hash(transformation, gifToVideo, thumbnail, abs) + + override fun toString(): String = + when { + transformation != null -> "Post{transformation=$transformation}" + gifToVideo != null -> "Post{gifToVideo=$gifToVideo}" + thumbnail != null -> "Post{thumbnail=$thumbnail}" + abs != null -> "Post{abs=$abs}" + _json != null -> "Post{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Post") + } + + companion object { + + @JvmStatic + fun ofTransformation(transformation: InnerTransformation) = + Post(transformation = transformation) + + @JvmStatic + fun ofGifToVideo(gifToVideo: GifToVideo) = Post(gifToVideo = gifToVideo) + + @JvmStatic + fun ofThumbnail(thumbnail: Thumbnail) = Post(thumbnail = thumbnail) + + @JvmStatic fun ofAbs(abs: Abs) = Post(abs = abs) + } + + /** + * An interface that defines how to map each variant of [Post] to a value of + * type [T]. + */ + interface Visitor { + + fun visitTransformation(transformation: InnerTransformation): T + + fun visitGifToVideo(gifToVideo: GifToVideo): T + + fun visitThumbnail(thumbnail: Thumbnail): T + + fun visitAbs(abs: Abs): T + + /** + * Maps an unknown variant of [Post] to a value of type [T]. + * + * An instance of [Post] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the API may respond + * with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Post: $json") + } + } + + internal class Deserializer : BaseDeserializer(Post::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Post { + val json = JsonValue.fromJsonNode(node) + val type = + json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "transformation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Post(transformation = it, _json = json) } + ?: Post(_json = json) + } + "gif-to-video" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(gifToVideo = it, _json = json) + } ?: Post(_json = json) + } + "thumbnail" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(thumbnail = it, _json = json) + } ?: Post(_json = json) + } + "abs" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(abs = it, _json = json) + } ?: Post(_json = json) + } + } + + return Post(_json = json) + } + } + + internal class Serializer : BaseSerializer(Post::class) { + + override fun serialize( + value: Post, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.transformation != null -> + generator.writeObject(value.transformation) + value.gifToVideo != null -> generator.writeObject(value.gifToVideo) + value.thumbnail != null -> generator.writeObject(value.thumbnail) + value.abs != null -> generator.writeObject(value.abs) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Post") + } + } + } + + class InnerTransformation + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Transformation type. + * + * Expected to always return the following: + * ```java + * JsonValue.from("transformation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit + * URL-based 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 value(): String = value.value.getRequired("value") + + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): MultipartField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InnerTransformation]. + * + * The following fields are required: + * ```java + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InnerTransformation]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("transformation") + private var value: MultipartField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(innerTransformation: InnerTransformation) = apply { + type = innerTransformation.type + value = innerTransformation.value + additionalProperties = + innerTransformation.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("transformation") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit + * URL-based transformations. + */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InnerTransformation]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InnerTransformation = + InnerTransformation( + type, + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InnerTransformation = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("transformation")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InnerTransformation && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InnerTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" + } + + class GifToVideo + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Converts an animated GIF into an MP4. + * + * Expected to always return the following: + * ```java + * JsonValue.from("gif-to-video") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Optional transformation string to apply to the output video. **Example**: + * `q-80` + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.value.getOptional("value") + + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): MultipartField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GifToVideo]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GifToVideo]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("gif-to-video") + private var value: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(gifToVideo: GifToVideo) = apply { + type = gifToVideo.type + value = gifToVideo.value + additionalProperties = + gifToVideo.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("gif-to-video") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Optional transformation string to apply to the output video. + * **Example**: `q-80` + */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GifToVideo]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): GifToVideo = + GifToVideo(type, value, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): GifToVideo = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("gif-to-video")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GifToVideo && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GifToVideo{type=$type, value=$value, additionalProperties=$additionalProperties}" + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + class Thumbnail + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + /** + * Generates a thumbnail image. + * + * Expected to always return the following: + * ```java + * JsonValue.from("thumbnail") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + /** + * Optional transformation string. **Example**: `w-150,h-150` + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.value.getOptional("value") - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): MultipartField = value - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun toBuilder() = Builder().from(this) - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + companion object { - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + /** + * Returns a mutable builder for constructing an instance of + * [Thumbnail]. + */ + @JvmStatic fun builder() = Builder() + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + /** A builder for [Thumbnail]. */ + class Builder internal constructor() { - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + private var type: JsonValue = JsonValue.from("thumbnail") + private var value: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = + mutableMapOf() - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + @JvmSynthetic + internal fun from(thumbnail: Thumbnail) = apply { + type = thumbnail.type + value = thumbnail.value + additionalProperties = thumbnail.additionalProperties.toMutableMap() + } - /** - * Returns an immutable instance of [FileUploadParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .file() - * .fileName() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): FileUploadParams = - FileUploadParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("thumbnail") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Optional transformation string. **Example**: `w-150,h-150` */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun _body(): Map> = - (mapOf( - "file" to _file(), - "fileName" to _fileName(), - "token" to _token(), - "checks" to _checks(), - "customCoordinates" to _customCoordinates(), - "customMetadata" to _customMetadata(), - "description" to _description(), - "expire" to _expire(), - "extensions" to _extensions(), - "folder" to _folder(), - "isPrivateFile" to _isPrivateFile(), - "isPublished" to _isPublished(), - "overwriteAITags" to _overwriteAiTags(), - "overwriteCustomMetadata" to _overwriteCustomMetadata(), - "overwriteFile" to _overwriteFile(), - "overwriteTags" to _overwriteTags(), - "publicKey" to _publicKey(), - "responseFields" to _responseFields(), - "signature" to _signature(), - "tags" to _tags(), - "transformation" to _transformation(), - "useUniqueFileName" to _useUniqueFileName(), - "webhookUrl" to _webhookUrl(), - ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) - .toImmutable() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun _headers(): Headers = additionalHeaders + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun _queryParams(): QueryParams = additionalQueryParams + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - class Body - private constructor( - private val file: MultipartField, - private val fileName: MultipartField, - private val token: MultipartField, - private val checks: MultipartField, - private val customCoordinates: MultipartField, - private val customMetadata: MultipartField, - private val description: MultipartField, - private val expire: MultipartField, - private val extensions: MultipartField>, - private val folder: MultipartField, - private val isPrivateFile: MultipartField, - private val isPublished: MultipartField, - private val overwriteAiTags: MultipartField, - private val overwriteCustomMetadata: MultipartField, - private val overwriteFile: MultipartField, - private val overwriteTags: MultipartField, - private val publicKey: MultipartField, - private val responseFields: MultipartField>, - private val signature: MultipartField, - private val tags: MultipartField>, - private val transformation: MultipartField, - private val useUniqueFileName: MultipartField, - private val webhookUrl: MultipartField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns an immutable instance of [Thumbnail]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): Thumbnail = + Thumbnail(type, value, additionalProperties.toMutableMap()) + } - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. - * - * @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 file(): InputStream = file.value.getRequired("file") + private var validated: Boolean = false - /** - * The name with which the file has to be uploaded. The file name can contain: - * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - * - Special Characters: `.`, `-` - * - * Any other character including space will be replaced by `_` - * - * @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 fileName(): String = fileName.value.getRequired("fileName") + fun validate(): Thumbnail = apply { + if (validated) { + return@apply + } - /** - * A unique value that the ImageKit.io server will use to recognize and prevent subsequent - * retries for the same request. We suggest using V4 UUIDs, or another random string with - * enough entropy to avoid collisions. This field is only required for authentication when - * uploading a file from the client side. - * - * **Note**: Sending a value that has been used in the past will result in a validation - * error. Even if your previous request resulted in an error, you should always send a new - * value for this field. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun token(): Optional = token.value.getOptional("token") + _type().let { + if (it != JsonValue.from("thumbnail")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + value() + validated = true + } - /** - * Server-side checks to run on the asset. Read more about - * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun checks(): Optional = checks.value.getOptional("checks") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - /** - * Define an important area in the image. This is only relevant for image type files. - * - To be passed as a string with the x and y coordinates of the top-left corner, and width - * and height of the area of interest in the format `x,y,width,height`. For example - - * `10,10,100,100` - * - Can be used with fo-customtransformation. - * - If this field is not specified and the file is overwritten, then customCoordinates will - * be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun customCoordinates(): Optional = - customCoordinates.value.getOptional("customCoordinates") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * JSON key-value pairs to associate with the asset. Create the custom metadata fields - * before setting these values. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun customMetadata(): Optional = - customMetadata.value.getOptional("customMetadata") + return other is Thumbnail && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } - /** - * Optional text to describe the contents of the file. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun description(): Optional = description.value.getOptional("description") + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } - /** - * The time until your signature is valid. It must be a - * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. - * It should be in seconds. This field is only required for authentication when uploading a - * file from the client side. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun expire(): Optional = expire.value.getOptional("expire") + override fun hashCode(): Int = hashCode - /** - * Array of extensions to be applied to the image. Each extension can be configured with - * specific parameters based on the extension type. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun extensions(): Optional> = extensions.value.getOptional("extensions") + override fun toString() = + "Thumbnail{type=$type, value=$value, additionalProperties=$additionalProperties}" + } - /** - * The folder path in which the image has to be uploaded. If the folder(s) didn't exist - * before, a new folder(s) is created. - * - * The folder name can contain: - * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - * - Special Characters: `/` , `_` , `-` - * - * Using multiple `/` creates a nested folder. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun folder(): Optional = folder.value.getOptional("folder") + class Abs + private constructor( + private val protocol: MultipartField, + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { - /** - * Whether to mark the file as private or not. - * - * If `true`, the file is marked as private and is accessible only using named - * transformation or signed URL. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun isPrivateFile(): Optional = isPrivateFile.value.getOptional("isPrivateFile") + /** + * Streaming protocol to use (`hls` or `dash`). + * + * @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 protocol(): Protocol = protocol.value.getRequired("protocol") - /** - * Whether to upload file as published or not. - * - * If `false`, the file is marked as unpublished, which restricts access to the file only - * via the media library. Files in draft or unpublished state can only be publicly accessed - * after being published. - * - * The option to upload in draft state is only available in custom enterprise pricing plans. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun isPublished(): Optional = isPublished.value.getOptional("isPublished") + /** + * Adaptive Bitrate Streaming (ABS) setup. + * + * Expected to always return the following: + * ```java + * JsonValue.from("abs") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * If set to `true` and a file already exists at the exact location, its AITags will be - * removed. Set `overwriteAITags` to `false` to preserve AITags. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun overwriteAiTags(): Optional = - overwriteAiTags.value.getOptional("overwriteAITags") + /** + * List of different representations you want to create separated by an + * underscore. + * + * @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 value(): String = value.value.getRequired("value") - /** - * If the request does not have `customMetadata`, and a file already exists at the exact - * location, existing customMetadata will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun overwriteCustomMetadata(): Optional = - overwriteCustomMetadata.value.getOptional("overwriteCustomMetadata") + /** + * Returns the raw multipart value of [protocol]. + * + * Unlike [protocol], this method doesn't throw if the multipart field has + * an unexpected type. + */ + @JsonProperty("protocol") + @ExcludeMissing + fun _protocol(): MultipartField = protocol - /** - * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the - * exact location, upload API will return an error immediately. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun overwriteFile(): Optional = overwriteFile.value.getOptional("overwriteFile") + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): MultipartField = value - /** - * If the request does not have `tags`, and a file already exists at the exact location, - * existing tags will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun overwriteTags(): Optional = overwriteTags.value.getOptional("overwriteTags") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Your ImageKit.io public key. This field is only required for authentication when - * uploading a file from the client side. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun publicKey(): Optional = publicKey.value.getOptional("publicKey") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Abs]. + * + * The following fields are required: + * ```java + * .protocol() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Array of response field keys to include in the API response body. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun responseFields(): Optional> = - responseFields.value.getOptional("responseFields") + /** A builder for [Abs]. */ + class Builder internal constructor() { + + private var protocol: MultipartField? = null + private var type: JsonValue = JsonValue.from("abs") + private var value: MultipartField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(abs: Abs) = apply { + protocol = abs.protocol + type = abs.type + value = abs.value + additionalProperties = abs.additionalProperties.toMutableMap() + } - /** - * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. - * Learn how to create a signature on the page below. This should be in lowercase. - * - * Signature must be calculated on the server-side. This field is only required for - * authentication when uploading a file from the client side. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun signature(): Optional = signature.value.getOptional("signature") + /** Streaming protocol to use (`hls` or `dash`). */ + fun protocol(protocol: Protocol) = protocol(MultipartField.of(protocol)) + + /** + * Sets [Builder.protocol] to an arbitrary multipart value. + * + * You should usually call [Builder.protocol] with a well-typed + * [Protocol] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun protocol(protocol: MultipartField) = apply { + this.protocol = protocol + } - /** - * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", - * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the - * `%` character is not allowed. If this field is not specified and the file is overwritten, - * the existing tags will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun tags(): Optional> = tags.value.getOptional("tags") + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("abs") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * List of different representations you want to create separated by an + * underscore. + */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing - * file size or applying basic optimizations upfront (e.g., resize, compress). - * - `post` — applied immediately after upload. Ideal for generating transformed versions - * (like video encodes or thumbnails) in advance, so they're ready for delivery without - * delay. - * - * You can mix and match any combination of post-processing types. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun transformation(): Optional = - transformation.value.getOptional("transformation") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Whether to use a unique filename for this file or not. - * - * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique - * filename. - * - * If `false`, then the image is uploaded with the provided filename parameter, and any - * existing file with the same name is replaced. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun useUniqueFileName(): Optional = - useUniqueFileName.value.getOptional("useUniqueFileName") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * The final status of extensions after they have completed execution will be delivered to - * this endpoint as a POST request. - * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - * about the webhook payload structure. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun webhookUrl(): Optional = webhookUrl.value.getOptional("webhookUrl") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw multipart value of [file]. - * - * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. - */ - @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField = file + /** + * Returns an immutable instance of [Abs]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .protocol() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Abs = + Abs( + checkRequired("protocol", protocol), + type, + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw multipart value of [fileName]. - * - * Unlike [fileName], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("fileName") @ExcludeMissing fun _fileName(): MultipartField = fileName + private var validated: Boolean = false - /** - * Returns the raw multipart value of [token]. - * - * Unlike [token], this method doesn't throw if the multipart field has an unexpected type. - */ - @JsonProperty("token") @ExcludeMissing fun _token(): MultipartField = token + fun validate(): Abs = apply { + if (validated) { + return@apply + } - /** - * Returns the raw multipart value of [checks]. - * - * Unlike [checks], this method doesn't throw if the multipart field has an unexpected type. - */ - @JsonProperty("checks") @ExcludeMissing fun _checks(): MultipartField = checks + protocol().validate() + _type().let { + if (it != JsonValue.from("abs")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + value() + validated = true + } - /** - * Returns the raw multipart value of [customCoordinates]. - * - * Unlike [customCoordinates], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("customCoordinates") - @ExcludeMissing - fun _customCoordinates(): MultipartField = customCoordinates + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - /** - * Returns the raw multipart value of [customMetadata]. - * - * Unlike [customMetadata], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("customMetadata") - @ExcludeMissing - fun _customMetadata(): MultipartField = customMetadata + /** Streaming protocol to use (`hls` or `dash`). */ + class Protocol + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Returns the raw multipart value of [description]. - * - * Unlike [description], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): MultipartField = description + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from + * data that doesn't match any known member, and you want to know that + * value. For example, if the SDK is on an older version than the API, + * then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Returns the raw multipart value of [expire]. - * - * Unlike [expire], this method doesn't throw if the multipart field has an unexpected type. - */ - @JsonProperty("expire") @ExcludeMissing fun _expire(): MultipartField = expire + companion object { - /** - * Returns the raw multipart value of [extensions]. - * - * Unlike [extensions], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("extensions") - @ExcludeMissing - fun _extensions(): MultipartField> = extensions + @JvmField val HLS = of("hls") - /** - * Returns the raw multipart value of [folder]. - * - * Unlike [folder], this method doesn't throw if the multipart field has an unexpected type. - */ - @JsonProperty("folder") @ExcludeMissing fun _folder(): MultipartField = folder + @JvmField val DASH = of("dash") - /** - * Returns the raw multipart value of [isPrivateFile]. - * - * Unlike [isPrivateFile], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("isPrivateFile") - @ExcludeMissing - fun _isPrivateFile(): MultipartField = isPrivateFile + @JvmStatic fun of(value: String) = Protocol(JsonField.of(value)) + } - /** - * Returns the raw multipart value of [isPublished]. - * - * Unlike [isPublished], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("isPublished") - @ExcludeMissing - fun _isPublished(): MultipartField = isPublished + /** An enum containing [Protocol]'s known values. */ + enum class Known { + HLS, + DASH, + } - /** - * Returns the raw multipart value of [overwriteAiTags]. - * - * Unlike [overwriteAiTags], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("overwriteAITags") - @ExcludeMissing - fun _overwriteAiTags(): MultipartField = overwriteAiTags + /** + * An enum containing [Protocol]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [Protocol] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HLS, + DASH, + /** + * An enum member indicating that [Protocol] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } - /** - * Returns the raw multipart value of [overwriteCustomMetadata]. - * - * Unlike [overwriteCustomMetadata], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("overwriteCustomMetadata") - @ExcludeMissing - fun _overwriteCustomMetadata(): MultipartField = overwriteCustomMetadata + /** + * Returns an enum member corresponding to this class instance's value, + * or [Value._UNKNOWN] if the class was instantiated with an unknown + * value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HLS -> Value.HLS + DASH -> Value.DASH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + HLS -> Known.HLS + DASH -> Known.DASH + else -> + throw ImageKitInvalidDataException( + "Unknown Protocol: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Protocol = apply { + if (validated) { + return@apply + } + + known() + validated = true + } - /** - * Returns the raw multipart value of [overwriteFile]. - * - * Unlike [overwriteFile], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("overwriteFile") - @ExcludeMissing - fun _overwriteFile(): MultipartField = overwriteFile + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Protocol && value == other.value + } - /** - * Returns the raw multipart value of [overwriteTags]. - * - * Unlike [overwriteTags], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("overwriteTags") - @ExcludeMissing - fun _overwriteTags(): MultipartField = overwriteTags + override fun hashCode() = value.hashCode() - /** - * Returns the raw multipart value of [publicKey]. - * - * Unlike [publicKey], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("publicKey") - @ExcludeMissing - fun _publicKey(): MultipartField = publicKey + override fun toString() = value.toString() + } - /** - * Returns the raw multipart value of [responseFields]. - * - * Unlike [responseFields], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("responseFields") - @ExcludeMissing - fun _responseFields(): MultipartField> = responseFields + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw multipart value of [signature]. - * - * Unlike [signature], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("signature") - @ExcludeMissing - fun _signature(): MultipartField = signature + return other is Abs && + protocol == other.protocol && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } - /** - * Returns the raw multipart value of [tags]. - * - * Unlike [tags], this method doesn't throw if the multipart field has an unexpected type. - */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): MultipartField> = tags + private val hashCode: Int by lazy { + Objects.hash(protocol, type, value, additionalProperties) + } - /** - * Returns the raw multipart value of [transformation]. - * - * Unlike [transformation], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("transformation") - @ExcludeMissing - fun _transformation(): MultipartField = transformation + override fun hashCode(): Int = hashCode - /** - * Returns the raw multipart value of [useUniqueFileName]. - * - * Unlike [useUniqueFileName], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("useUniqueFileName") - @ExcludeMissing - fun _useUniqueFileName(): MultipartField = useUniqueFileName + override fun toString() = + "Abs{protocol=$protocol, type=$type, value=$value, additionalProperties=$additionalProperties}" + } + } - /** - * Returns the raw multipart value of [webhookUrl]. - * - * Unlike [webhookUrl], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("webhookUrl") - @ExcludeMissing - fun _webhookUrl(): MultipartField = webhookUrl + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + return other is Transformation && + post == other.post && + pre == other.pre && + additionalProperties == other.additionalProperties + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + private val hashCode: Int by lazy { Objects.hash(post, pre, additionalProperties) } - fun toBuilder() = Builder().from(this) + override fun hashCode(): Int = hashCode - companion object { + override fun toString() = + "Transformation{post=$post, pre=$pre, additionalProperties=$additionalProperties}" + } - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .file() - * .fileName() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var file: MultipartField? = null - private var fileName: MultipartField? = null - private var token: MultipartField = MultipartField.of(null) - private var checks: MultipartField = MultipartField.of(null) - private var customCoordinates: MultipartField = MultipartField.of(null) - private var customMetadata: MultipartField = MultipartField.of(null) - private var description: MultipartField = MultipartField.of(null) - private var expire: MultipartField = MultipartField.of(null) - private var extensions: MultipartField>? = null - private var folder: MultipartField = MultipartField.of(null) - private var isPrivateFile: MultipartField = MultipartField.of(null) - private var isPublished: MultipartField = MultipartField.of(null) - private var overwriteAiTags: MultipartField = MultipartField.of(null) - private var overwriteCustomMetadata: MultipartField = MultipartField.of(null) - private var overwriteFile: MultipartField = MultipartField.of(null) - private var overwriteTags: MultipartField = MultipartField.of(null) - private var publicKey: MultipartField = MultipartField.of(null) - private var responseFields: MultipartField>? = null - private var signature: MultipartField = MultipartField.of(null) - private var tags: MultipartField>? = null - private var transformation: MultipartField = MultipartField.of(null) - private var useUniqueFileName: MultipartField = MultipartField.of(null) - private var webhookUrl: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - file = body.file - fileName = body.fileName - token = body.token - checks = body.checks - customCoordinates = body.customCoordinates - customMetadata = body.customMetadata - description = body.description - expire = body.expire - extensions = body.extensions.map { it.toMutableList() } - folder = body.folder - isPrivateFile = body.isPrivateFile - isPublished = body.isPublished - overwriteAiTags = body.overwriteAiTags - overwriteCustomMetadata = body.overwriteCustomMetadata - overwriteFile = body.overwriteFile - overwriteTags = body.overwriteTags - publicKey = body.publicKey - responseFields = body.responseFields.map { it.toMutableList() } - signature = body.signature - tags = body.tags.map { it.toMutableList() } - transformation = body.transformation - useUniqueFileName = body.useUniqueFileName - webhookUrl = body.webhookUrl - additionalProperties = body.additionalProperties.toMutableMap() + return other is FileUploadV1 && + file == other.file && + fileName == other.fileName && + token == other.token && + checks == other.checks && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + description == other.description && + expire == other.expire && + extensions == other.extensions && + folder == other.folder && + isPrivateFile == other.isPrivateFile && + isPublished == other.isPublished && + overwriteAiTags == other.overwriteAiTags && + overwriteCustomMetadata == other.overwriteCustomMetadata && + overwriteFile == other.overwriteFile && + overwriteTags == other.overwriteTags && + publicKey == other.publicKey && + responseFields == other.responseFields && + signature == other.signature && + tags == other.tags && + transformation == other.transformation && + useUniqueFileName == other.useUniqueFileName && + webhookUrl == other.webhookUrl && + additionalProperties == other.additionalProperties } - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. - */ - fun file(file: InputStream) = file(MultipartField.of(file)) + private val hashCode: Int by lazy { + Objects.hash( + file, + fileName, + token, + checks, + customCoordinates, + customMetadata, + description, + expire, + extensions, + folder, + isPrivateFile, + isPublished, + overwriteAiTags, + overwriteCustomMetadata, + overwriteFile, + overwriteTags, + publicKey, + responseFields, + signature, + tags, + transformation, + useUniqueFileName, + webhookUrl, + additionalProperties, + ) + } - /** - * Sets [Builder.file] to an arbitrary multipart value. - * - * You should usually call [Builder.file] with a well-typed [InputStream] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun file(file: MultipartField) = apply { this.file = file } + override fun hashCode(): Int = hashCode - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. - */ - fun file(file: ByteArray) = file(file.inputStream()) + override fun toString() = + "FileUploadV1{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, expire=$expire, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, publicKey=$publicKey, responseFields=$responseFields, signature=$signature, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + } + + class FileUploadV1ByUrl + private constructor( + private val file: MultipartField, + private val fileName: MultipartField, + private val token: MultipartField, + private val checks: MultipartField, + private val customCoordinates: MultipartField, + private val customMetadata: MultipartField, + private val description: MultipartField, + private val expire: MultipartField, + private val extensions: MultipartField>, + private val folder: MultipartField, + private val isPrivateFile: MultipartField, + private val isPublished: MultipartField, + private val overwriteAiTags: MultipartField, + private val overwriteCustomMetadata: MultipartField, + private val overwriteFile: MultipartField, + private val overwriteTags: MultipartField, + private val publicKey: MultipartField, + private val responseFields: MultipartField>, + private val signature: MultipartField, + private val tags: MultipartField>, + private val transformation: MultipartField, + private val useUniqueFileName: MultipartField, + private val webhookUrl: MultipartField, + private val additionalProperties: MutableMap, + ) { /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * A publicly reachable URL that ImageKit’s servers can fetch. The server must receive + * the response headers within 8 seconds; otherwise the request fails with 400 Bad + * Request. * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. + * @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 file(path: Path) = - file( - MultipartField.builder() - .value(path.inputStream()) - .filename(path.name) - .build() - ) + fun file(): String = file.value.getRequired("file") /** * The name with which the file has to be uploaded. The file name can contain: @@ -1833,17 +4501,12 @@ private constructor( * - Special Characters: `.`, `-` * * Any other character including space will be replaced by `_` - */ - fun fileName(fileName: String) = fileName(MultipartField.of(fileName)) - - /** - * Sets [Builder.fileName] to an arbitrary multipart value. * - * You should usually call [Builder.fileName] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun fileName(fileName: MultipartField) = apply { this.fileName = fileName } + fun fileName(): String = fileName.value.getRequired("fileName") /** * A unique value that the ImageKit.io server will use to recognize and prevent @@ -1854,32 +4517,20 @@ private constructor( * **Note**: Sending a value that has been used in the past will result in a validation * error. Even if your previous request resulted in an error, you should always send a * new value for this field. - */ - fun token(token: String) = token(MultipartField.of(token)) - - /** - * Sets [Builder.token] to an arbitrary multipart value. * - * You should usually call [Builder.token] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun token(token: MultipartField) = apply { this.token = token } + fun token(): Optional = token.value.getOptional("token") /** * Server-side checks to run on the asset. Read more about * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). - */ - fun checks(checks: String) = checks(MultipartField.of(checks)) - - /** - * Sets [Builder.checks] to an arbitrary multipart value. * - * You should usually call [Builder.checks] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun checks(checks: MultipartField) = apply { this.checks = checks } + fun checks(): Optional = checks.value.getOptional("checks") /** * Define an important area in the image. This is only relevant for image type files. @@ -1889,908 +4540,434 @@ private constructor( * - Can be used with fo-customtransformation. * - If this field is not specified and the file is overwritten, then customCoordinates * will be removed. - */ - fun customCoordinates(customCoordinates: String) = - customCoordinates(MultipartField.of(customCoordinates)) - - /** - * Sets [Builder.customCoordinates] to an arbitrary multipart value. * - * You should usually call [Builder.customCoordinates] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun customCoordinates(customCoordinates: MultipartField) = apply { - this.customCoordinates = customCoordinates - } + fun customCoordinates(): Optional = + customCoordinates.value.getOptional("customCoordinates") /** * JSON key-value pairs to associate with the asset. Create the custom metadata fields * before setting these values. - */ - fun customMetadata(customMetadata: CustomMetadata) = - customMetadata(MultipartField.of(customMetadata)) - - /** - * Sets [Builder.customMetadata] to an arbitrary multipart value. * - * You should usually call [Builder.customMetadata] with a well-typed [CustomMetadata] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun customMetadata(customMetadata: MultipartField) = apply { - this.customMetadata = customMetadata - } - - /** Optional text to describe the contents of the file. */ - fun description(description: String) = description(MultipartField.of(description)) + fun customMetadata(): Optional = + customMetadata.value.getOptional("customMetadata") /** - * Sets [Builder.description] to an arbitrary multipart value. + * Optional text to describe the contents of the file. * - * 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. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun description(description: MultipartField) = apply { - this.description = description - } + fun description(): Optional = description.value.getOptional("description") /** * The time until your signature is valid. It must be a * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the * future. It should be in seconds. This field is only required for authentication when * uploading a file from the client side. - */ - fun expire(expire: Long) = expire(MultipartField.of(expire)) - - /** - * Sets [Builder.expire] to an arbitrary multipart value. * - * You should usually call [Builder.expire] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun expire(expire: MultipartField) = apply { this.expire = expire } + fun expire(): Optional = expire.value.getOptional("expire") /** * Array of extensions to be applied to the image. Each extension can be configured with * specific parameters based on the extension type. - */ - fun extensions(extensions: List) = extensions(MultipartField.of(extensions)) - - /** - * Sets [Builder.extensions] to an arbitrary multipart value. - * - * You should usually call [Builder.extensions] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun extensions(extensions: MultipartField>) = apply { - this.extensions = extensions.map { it.toMutableList() } - } - - /** - * Adds a single [Extension] to [extensions]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun addExtension(extension: Extension) = apply { - extensions = - (extensions ?: MultipartField.of(mutableListOf())).also { - checkKnown("extensions", it).add(extension) - } - } - - /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: Extension.RemoveBg) = - addExtension(Extension.ofRemoveBg(removeBg)) - - /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: Extension.AutoTaggingExtension) = - addExtension(Extension.ofAutoTagging(autoTagging)) - - /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ - fun addExtensionAiAutoDescription() = addExtension(Extension.ofAiAutoDescription()) + fun extensions(): Optional> = extensions.value.getOptional("extensions") /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist * before, a new folder(s) is created. * - * The folder name can contain: - * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - * - Special Characters: `/` , `_` , `-` - * - * Using multiple `/` creates a nested folder. - */ - fun folder(folder: String) = folder(MultipartField.of(folder)) - - /** - * Sets [Builder.folder] to an arbitrary multipart value. - * - * You should usually call [Builder.folder] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun folder(folder: MultipartField) = apply { this.folder = folder } - - /** - * Whether to mark the file as private or not. - * - * If `true`, the file is marked as private and is accessible only using named - * transformation or signed URL. - */ - fun isPrivateFile(isPrivateFile: Boolean) = - isPrivateFile(MultipartField.of(isPrivateFile)) - - /** - * Sets [Builder.isPrivateFile] to an arbitrary multipart value. - * - * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun isPrivateFile(isPrivateFile: MultipartField) = apply { - this.isPrivateFile = isPrivateFile - } - - /** - * Whether to upload file as published or not. - * - * If `false`, the file is marked as unpublished, which restricts access to the file - * only via the media library. Files in draft or unpublished state can only be publicly - * accessed after being published. - * - * The option to upload in draft state is only available in custom enterprise pricing - * plans. - */ - fun isPublished(isPublished: Boolean) = isPublished(MultipartField.of(isPublished)) - - /** - * Sets [Builder.isPublished] to an arbitrary multipart value. - * - * You should usually call [Builder.isPublished] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun isPublished(isPublished: MultipartField) = apply { - this.isPublished = isPublished - } - - /** - * If set to `true` and a file already exists at the exact location, its AITags will be - * removed. Set `overwriteAITags` to `false` to preserve AITags. - */ - fun overwriteAiTags(overwriteAiTags: Boolean) = - overwriteAiTags(MultipartField.of(overwriteAiTags)) - - /** - * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteAiTags] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun overwriteAiTags(overwriteAiTags: MultipartField) = apply { - this.overwriteAiTags = overwriteAiTags - } - - /** - * If the request does not have `customMetadata`, and a file already exists at the exact - * location, existing customMetadata will be removed. - */ - fun overwriteCustomMetadata(overwriteCustomMetadata: Boolean) = - overwriteCustomMetadata(MultipartField.of(overwriteCustomMetadata)) - - /** - * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteCustomMetadata] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun overwriteCustomMetadata(overwriteCustomMetadata: MultipartField) = apply { - this.overwriteCustomMetadata = overwriteCustomMetadata - } - - /** - * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the - * exact location, upload API will return an error immediately. - */ - fun overwriteFile(overwriteFile: Boolean) = - overwriteFile(MultipartField.of(overwriteFile)) - - /** - * Sets [Builder.overwriteFile] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteFile] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun overwriteFile(overwriteFile: MultipartField) = apply { - this.overwriteFile = overwriteFile - } - - /** - * If the request does not have `tags`, and a file already exists at the exact location, - * existing tags will be removed. - */ - fun overwriteTags(overwriteTags: Boolean) = - overwriteTags(MultipartField.of(overwriteTags)) - - /** - * Sets [Builder.overwriteTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteTags] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun overwriteTags(overwriteTags: MultipartField) = apply { - this.overwriteTags = overwriteTags - } - - /** - * Your ImageKit.io public key. This field is only required for authentication when - * uploading a file from the client side. - */ - fun publicKey(publicKey: String) = publicKey(MultipartField.of(publicKey)) - - /** - * Sets [Builder.publicKey] to an arbitrary multipart value. - * - * You should usually call [Builder.publicKey] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun publicKey(publicKey: MultipartField) = apply { this.publicKey = publicKey } - - /** Array of response field keys to include in the API response body. */ - fun responseFields(responseFields: List) = - responseFields(MultipartField.of(responseFields)) - - /** - * Sets [Builder.responseFields] to an arbitrary multipart value. - * - * You should usually call [Builder.responseFields] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun responseFields(responseFields: MultipartField>) = apply { - this.responseFields = responseFields.map { it.toMutableList() } - } - - /** - * Adds a single [ResponseField] to [responseFields]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addResponseField(responseField: ResponseField) = apply { - responseFields = - (responseFields ?: MultipartField.of(mutableListOf())).also { - checkKnown("responseFields", it).add(responseField) - } - } - - /** - * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. - * Learn how to create a signature on the page below. This should be in lowercase. - * - * Signature must be calculated on the server-side. This field is only required for - * authentication when uploading a file from the client side. - */ - fun signature(signature: String) = signature(MultipartField.of(signature)) - - /** - * Sets [Builder.signature] to an arbitrary multipart value. - * - * You should usually call [Builder.signature] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun signature(signature: MultipartField) = apply { this.signature = signature } - - /** - * Set the tags while uploading the file. Provide an array of tag strings (e.g. - * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not - * exceed 500, and the `%` character is not allowed. If this field is not specified and - * the file is overwritten, the existing tags will be removed. - */ - fun tags(tags: List) = tags(MultipartField.of(tags)) - - /** - * Sets [Builder.tags] to an arbitrary multipart value. + * The folder name can contain: + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. * - * You should usually call [Builder.tags] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun tags(tags: MultipartField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun folder(): Optional = folder.value.getOptional("folder") /** - * Adds a single [String] to [tags]. + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named + * transformation or signed URL. * - * @throws IllegalStateException if the field was previously set to a non-list. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun addTag(tag: String) = apply { - tags = - (tags ?: MultipartField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } + fun isPrivateFile(): Optional = + isPrivateFile.value.getOptional("isPrivateFile") /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for - * reducing file size or applying basic optimizations upfront (e.g., resize, - * compress). - * - `post` — applied immediately after upload. Ideal for generating transformed - * versions (like video encodes or thumbnails) in advance, so they're ready for - * delivery without delay. + * Whether to upload file as published or not. * - * You can mix and match any combination of post-processing types. + * If `false`, the file is marked as unpublished, which restricts access to the file + * only via the media library. Files in draft or unpublished state can only be publicly + * accessed after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing + * plans. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun transformation(transformation: Transformation) = - transformation(MultipartField.of(transformation)) + fun isPublished(): Optional = isPublished.value.getOptional("isPublished") /** - * Sets [Builder.transformation] to an arbitrary multipart value. + * If set to `true` and a file already exists at the exact location, its AITags will be + * removed. Set `overwriteAITags` to `false` to preserve AITags. * - * You should usually call [Builder.transformation] with a well-typed [Transformation] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun transformation(transformation: MultipartField) = apply { - this.transformation = transformation - } + fun overwriteAiTags(): Optional = + overwriteAiTags.value.getOptional("overwriteAITags") /** - * Whether to use a unique filename for this file or not. - * - * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a - * unique filename. + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. * - * If `false`, then the image is uploaded with the provided filename parameter, and any - * existing file with the same name is replaced. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun useUniqueFileName(useUniqueFileName: Boolean) = - useUniqueFileName(MultipartField.of(useUniqueFileName)) + fun overwriteCustomMetadata(): Optional = + overwriteCustomMetadata.value.getOptional("overwriteCustomMetadata") /** - * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the + * exact location, upload API will return an error immediately. * - * You should usually call [Builder.useUniqueFileName] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun useUniqueFileName(useUniqueFileName: MultipartField) = apply { - this.useUniqueFileName = useUniqueFileName - } + fun overwriteFile(): Optional = + overwriteFile.value.getOptional("overwriteFile") /** - * The final status of extensions after they have completed execution will be delivered - * to this endpoint as a POST request. - * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - * about the webhook payload structure. + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun webhookUrl(webhookUrl: String) = webhookUrl(MultipartField.of(webhookUrl)) + fun overwriteTags(): Optional = + overwriteTags.value.getOptional("overwriteTags") /** - * Sets [Builder.webhookUrl] to an arbitrary multipart value. + * Your ImageKit.io public key. This field is only required for authentication when + * uploading a file from the client side. * - * You should usually call [Builder.webhookUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun webhookUrl(webhookUrl: MultipartField) = apply { - this.webhookUrl = webhookUrl - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun publicKey(): Optional = publicKey.value.getOptional("publicKey") /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .file() - * .fileName() - * ``` + * Array of response field keys to include in the API response body. * - * @throws IllegalStateException if any required field is unset. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun build(): Body = - Body( - checkRequired("file", file), - checkRequired("fileName", fileName), - token, - checks, - customCoordinates, - customMetadata, - description, - expire, - (extensions ?: MultipartField.of(null)).map { it.toImmutable() }, - folder, - isPrivateFile, - isPublished, - overwriteAiTags, - overwriteCustomMetadata, - overwriteFile, - overwriteTags, - publicKey, - (responseFields ?: MultipartField.of(null)).map { it.toImmutable() }, - signature, - (tags ?: MultipartField.of(null)).map { it.toImmutable() }, - transformation, - useUniqueFileName, - webhookUrl, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - file() - fileName() - token() - checks() - customCoordinates() - customMetadata().ifPresent { it.validate() } - description() - expire() - extensions().ifPresent { it.forEach { it.validate() } } - folder() - isPrivateFile() - isPublished() - overwriteAiTags() - overwriteCustomMetadata() - overwriteFile() - overwriteTags() - publicKey() - responseFields().ifPresent { it.forEach { it.validate() } } - signature() - tags() - transformation().ifPresent { it.validate() } - useUniqueFileName() - webhookUrl() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - file == other.file && - fileName == other.fileName && - token == other.token && - checks == other.checks && - customCoordinates == other.customCoordinates && - customMetadata == other.customMetadata && - description == other.description && - expire == other.expire && - extensions == other.extensions && - folder == other.folder && - isPrivateFile == other.isPrivateFile && - isPublished == other.isPublished && - overwriteAiTags == other.overwriteAiTags && - overwriteCustomMetadata == other.overwriteCustomMetadata && - overwriteFile == other.overwriteFile && - overwriteTags == other.overwriteTags && - publicKey == other.publicKey && - responseFields == other.responseFields && - signature == other.signature && - tags == other.tags && - transformation == other.transformation && - useUniqueFileName == other.useUniqueFileName && - webhookUrl == other.webhookUrl && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - file, - fileName, - token, - checks, - customCoordinates, - customMetadata, - description, - expire, - extensions, - folder, - isPrivateFile, - isPublished, - overwriteAiTags, - overwriteCustomMetadata, - overwriteFile, - overwriteTags, - publicKey, - responseFields, - signature, - tags, - transformation, - useUniqueFileName, - webhookUrl, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, expire=$expire, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, publicKey=$publicKey, responseFields=$responseFields, signature=$signature, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" - } - - /** - * JSON key-value pairs to associate with the asset. Create the custom metadata fields before - * setting these values. - */ - class CustomMetadata - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [CustomMetadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customMetadata: CustomMetadata) = apply { - additionalProperties = customMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun responseFields(): Optional> = + responseFields.value.getOptional("responseFields") /** - * Returns an immutable instance of [CustomMetadata]. + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. + * Learn how to create a signature on the page below. This should be in lowercase. * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): CustomMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CustomMetadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = Extension.Deserializer::class) - @JsonSerialize(using = Extension.Serializer::class) - class Extension - private constructor( - private val removeBg: RemoveBg? = null, - private val autoTagging: AutoTaggingExtension? = null, - private val aiAutoDescription: JsonValue? = null, - private val _json: JsonValue? = null, - ) { - - fun removeBg(): Optional = Optional.ofNullable(removeBg) - - fun autoTagging(): Optional = Optional.ofNullable(autoTagging) - - fun aiAutoDescription(): Optional = Optional.ofNullable(aiAutoDescription) - - fun isRemoveBg(): Boolean = removeBg != null - - fun isAutoTagging(): Boolean = autoTagging != null - - fun isAiAutoDescription(): Boolean = aiAutoDescription != null - - fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") - - fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") - - fun asAiAutoDescription(): JsonValue = aiAutoDescription.getOrThrow("aiAutoDescription") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - removeBg != null -> visitor.visitRemoveBg(removeBg) - autoTagging != null -> visitor.visitAutoTagging(autoTagging) - aiAutoDescription != null -> visitor.visitAiAutoDescription(aiAutoDescription) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Extension = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitRemoveBg(removeBg: RemoveBg) { - removeBg.validate() - } - - override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { - autoTagging.validate() - } - - override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { - aiAutoDescription.let { - if (it != JsonValue.from(mapOf("name" to "ai-auto-description"))) { - throw ImageKitInvalidDataException( - "'aiAutoDescription' is invalid, received $it" - ) - } - } - } - } - ) - 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 = - accept( - object : Visitor { - override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() - - override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = - autoTagging.validity() + * Signature must be calculated on the server-side. This field is only required for + * authentication when uploading a file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun signature(): Optional = signature.value.getOptional("signature") - override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = - aiAutoDescription.let { - if (it == JsonValue.from(mapOf("name" to "ai-auto-description"))) 1 - else 0 - } + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. + * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not + * exceed 500, and the `%` character is not allowed. If this field is not specified and + * the file is overwritten, the existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tags(): Optional> = tags.value.getOptional("tags") - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for + * reducing file size or applying basic optimizations upfront (e.g., resize, + * compress). + * - `post` — applied immediately after upload. Ideal for generating transformed + * versions (like video encodes or thumbnails) in advance, so they're ready for + * delivery without delay. + * + * You can mix and match any combination of post-processing types. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun transformation(): Optional = + transformation.value.getOptional("transformation") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a + * unique filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any + * existing file with the same name is replaced. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun useUniqueFileName(): Optional = + useUniqueFileName.value.getOptional("useUniqueFileName") - return other is Extension && - removeBg == other.removeBg && - autoTagging == other.autoTagging && - aiAutoDescription == other.aiAutoDescription - } + /** + * The final status of extensions after they have completed execution will be delivered + * to this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun webhookUrl(): Optional = webhookUrl.value.getOptional("webhookUrl") - override fun hashCode(): Int = Objects.hash(removeBg, autoTagging, aiAutoDescription) + /** + * Returns the raw multipart value of [file]. + * + * Unlike [file], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField = file - override fun toString(): String = - when { - removeBg != null -> "Extension{removeBg=$removeBg}" - autoTagging != null -> "Extension{autoTagging=$autoTagging}" - aiAutoDescription != null -> "Extension{aiAutoDescription=$aiAutoDescription}" - _json != null -> "Extension{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Extension") - } + /** + * Returns the raw multipart value of [fileName]. + * + * Unlike [fileName], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("fileName") + @ExcludeMissing + fun _fileName(): MultipartField = fileName - companion object { + /** + * Returns the raw multipart value of [token]. + * + * Unlike [token], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): MultipartField = token - @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = Extension(removeBg = removeBg) + /** + * Returns the raw multipart value of [checks]. + * + * Unlike [checks], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("checks") @ExcludeMissing fun _checks(): MultipartField = checks - @JvmStatic - fun ofAutoTagging(autoTagging: AutoTaggingExtension) = - Extension(autoTagging = autoTagging) + /** + * Returns the raw multipart value of [customCoordinates]. + * + * Unlike [customCoordinates], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("customCoordinates") + @ExcludeMissing + fun _customCoordinates(): MultipartField = customCoordinates - @JvmStatic - fun ofAiAutoDescription() = - Extension( - aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) - ) - } + /** + * Returns the raw multipart value of [customMetadata]. + * + * Unlike [customMetadata], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): MultipartField = customMetadata - /** - * An interface that defines how to map each variant of [Extension] to a value of type [T]. - */ - interface Visitor { + /** + * Returns the raw multipart value of [description]. + * + * Unlike [description], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): MultipartField = description - fun visitRemoveBg(removeBg: RemoveBg): T + /** + * Returns the raw multipart value of [expire]. + * + * Unlike [expire], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("expire") @ExcludeMissing fun _expire(): MultipartField = expire - fun visitAutoTagging(autoTagging: AutoTaggingExtension): T + /** + * Returns the raw multipart value of [extensions]. + * + * Unlike [extensions], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("extensions") + @ExcludeMissing + fun _extensions(): MultipartField> = extensions - fun visitAiAutoDescription(aiAutoDescription: JsonValue): T + /** + * Returns the raw multipart value of [folder]. + * + * Unlike [folder], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("folder") @ExcludeMissing fun _folder(): MultipartField = folder /** - * Maps an unknown variant of [Extension] to a value of type [T]. + * Returns the raw multipart value of [isPrivateFile]. * - * An instance of [Extension] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * Unlike [isPrivateFile], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("isPrivateFile") + @ExcludeMissing + fun _isPrivateFile(): MultipartField = isPrivateFile + + /** + * Returns the raw multipart value of [isPublished]. * - * @throws ImageKitInvalidDataException in the default implementation. + * Unlike [isPublished], this method doesn't throw if the multipart field has an + * unexpected type. */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Extension: $json") - } - } + @JsonProperty("isPublished") + @ExcludeMissing + fun _isPublished(): MultipartField = isPublished - internal class Deserializer : BaseDeserializer(Extension::class) { + /** + * Returns the raw multipart value of [overwriteAiTags]. + * + * Unlike [overwriteAiTags], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteAITags") + @ExcludeMissing + fun _overwriteAiTags(): MultipartField = overwriteAiTags - override fun ObjectCodec.deserialize(node: JsonNode): Extension { - val json = JsonValue.fromJsonNode(node) - val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() + /** + * Returns the raw multipart value of [overwriteCustomMetadata]. + * + * Unlike [overwriteCustomMetadata], this method doesn't throw if the multipart field + * has an unexpected type. + */ + @JsonProperty("overwriteCustomMetadata") + @ExcludeMissing + fun _overwriteCustomMetadata(): MultipartField = overwriteCustomMetadata - when (name) { - "remove-bg" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Extension(removeBg = it, _json = json) - } ?: Extension(_json = json) - } - "ai-auto-description" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Extension(aiAutoDescription = it, _json = json) } - ?.takeIf { it.isValid() } ?: Extension(_json = json) - } - } + /** + * Returns the raw multipart value of [overwriteFile]. + * + * Unlike [overwriteFile], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteFile") + @ExcludeMissing + fun _overwriteFile(): MultipartField = overwriteFile - return tryDeserialize(node, jacksonTypeRef())?.let { - Extension(autoTagging = it, _json = json) - } ?: Extension(_json = json) - } - } + /** + * Returns the raw multipart value of [overwriteTags]. + * + * Unlike [overwriteTags], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteTags") + @ExcludeMissing + fun _overwriteTags(): MultipartField = overwriteTags - internal class Serializer : BaseSerializer(Extension::class) { + /** + * Returns the raw multipart value of [publicKey]. + * + * Unlike [publicKey], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("publicKey") + @ExcludeMissing + fun _publicKey(): MultipartField = publicKey - override fun serialize( - value: Extension, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.removeBg != null -> generator.writeObject(value.removeBg) - value.autoTagging != null -> generator.writeObject(value.autoTagging) - value.aiAutoDescription != null -> - generator.writeObject(value.aiAutoDescription) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Extension") - } - } - } + /** + * Returns the raw multipart value of [responseFields]. + * + * Unlike [responseFields], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("responseFields") + @ExcludeMissing + fun _responseFields(): MultipartField> = responseFields - class RemoveBg - private constructor( - private val name: JsonValue, - private val options: MultipartField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw multipart value of [signature]. + * + * Unlike [signature], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("signature") + @ExcludeMissing + fun _signature(): MultipartField = signature /** - * Specifies the background removal extension. + * Returns the raw multipart value of [tags]. * - * Expected to always return the following: - * ```java - * JsonValue.from("remove-bg") - * ``` + * Unlike [tags], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): MultipartField> = tags + + /** + * Returns the raw multipart value of [transformation]. * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). + * Unlike [transformation], this method doesn't throw if the multipart field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + @JsonProperty("transformation") + @ExcludeMissing + fun _transformation(): MultipartField = transformation /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * Returns the raw multipart value of [useUniqueFileName]. + * + * Unlike [useUniqueFileName], this method doesn't throw if the multipart field has an + * unexpected type. */ - fun options(): Optional = options.value.getOptional("options") + @JsonProperty("useUniqueFileName") + @ExcludeMissing + fun _useUniqueFileName(): MultipartField = useUniqueFileName /** - * Returns the raw multipart value of [options]. + * Returns the raw multipart value of [webhookUrl]. * - * Unlike [options], this method doesn't throw if the multipart field has an unexpected - * type. + * Unlike [webhookUrl], this method doesn't throw if the multipart field has an + * unexpected type. */ - @JsonProperty("options") + @JsonProperty("webhookUrl") @ExcludeMissing - fun _options(): MultipartField = options + fun _webhookUrl(): MultipartField = webhookUrl @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -2806,543 +4983,558 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RemoveBg]. */ - class Builder internal constructor() { - - private var name: JsonValue = JsonValue.from("remove-bg") - private var options: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(removeBg: RemoveBg) = apply { - name = removeBg.name - options = removeBg.options - additionalProperties = removeBg.additionalProperties.toMutableMap() - } - /** - * Sets the field to an arbitrary JSON value. + * Returns a mutable builder for constructing an instance of [FileUploadV1ByUrl]. * - * It is usually unnecessary to call this method because the field defaults to the - * following: + * The following fields are required: * ```java - * JsonValue.from("remove-bg") + * .file() + * .fileName() * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonValue) = apply { this.name = name } - - fun options(options: Options) = options(MultipartField.of(options)) - - /** - * Sets [Builder.options] to an arbitrary multipart value. - * - * You should usually call [Builder.options] with a well-typed [Options] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun options(options: MultipartField) = apply { this.options = options } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [RemoveBg]. - * - * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): RemoveBg = RemoveBg(name, options, additionalProperties.toMutableMap()) + @JvmStatic fun builder() = Builder() } - private var validated: Boolean = false - - fun validate(): RemoveBg = apply { - if (validated) { - return@apply - } + /** A builder for [FileUploadV1ByUrl]. */ + class Builder internal constructor() { - _name().let { - if (it != JsonValue.from("remove-bg")) { - throw ImageKitInvalidDataException("'name' is invalid, received $it") - } - } - options().ifPresent { it.validate() } - validated = true - } + private var file: MultipartField? = null + private var fileName: MultipartField? = null + private var token: MultipartField = MultipartField.of(null) + private var checks: MultipartField = MultipartField.of(null) + private var customCoordinates: MultipartField = MultipartField.of(null) + private var customMetadata: MultipartField = MultipartField.of(null) + private var description: MultipartField = MultipartField.of(null) + private var expire: MultipartField = MultipartField.of(null) + private var extensions: MultipartField>? = null + private var folder: MultipartField = MultipartField.of(null) + private var isPrivateFile: MultipartField = MultipartField.of(null) + private var isPublished: MultipartField = MultipartField.of(null) + private var overwriteAiTags: MultipartField = MultipartField.of(null) + private var overwriteCustomMetadata: MultipartField = + MultipartField.of(null) + private var overwriteFile: MultipartField = MultipartField.of(null) + private var overwriteTags: MultipartField = MultipartField.of(null) + private var publicKey: MultipartField = MultipartField.of(null) + private var responseFields: MultipartField>? = null + private var signature: MultipartField = MultipartField.of(null) + private var tags: MultipartField>? = null + private var transformation: MultipartField = MultipartField.of(null) + private var useUniqueFileName: MultipartField = MultipartField.of(null) + private var webhookUrl: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false + @JvmSynthetic + internal fun from(fileUploadV1ByUrl: FileUploadV1ByUrl) = apply { + file = fileUploadV1ByUrl.file + fileName = fileUploadV1ByUrl.fileName + token = fileUploadV1ByUrl.token + checks = fileUploadV1ByUrl.checks + customCoordinates = fileUploadV1ByUrl.customCoordinates + customMetadata = fileUploadV1ByUrl.customMetadata + description = fileUploadV1ByUrl.description + expire = fileUploadV1ByUrl.expire + extensions = fileUploadV1ByUrl.extensions.map { it.toMutableList() } + folder = fileUploadV1ByUrl.folder + isPrivateFile = fileUploadV1ByUrl.isPrivateFile + isPublished = fileUploadV1ByUrl.isPublished + overwriteAiTags = fileUploadV1ByUrl.overwriteAiTags + overwriteCustomMetadata = fileUploadV1ByUrl.overwriteCustomMetadata + overwriteFile = fileUploadV1ByUrl.overwriteFile + overwriteTags = fileUploadV1ByUrl.overwriteTags + publicKey = fileUploadV1ByUrl.publicKey + responseFields = fileUploadV1ByUrl.responseFields.map { it.toMutableList() } + signature = fileUploadV1ByUrl.signature + tags = fileUploadV1ByUrl.tags.map { it.toMutableList() } + transformation = fileUploadV1ByUrl.transformation + useUniqueFileName = fileUploadV1ByUrl.useUniqueFileName + webhookUrl = fileUploadV1ByUrl.webhookUrl + additionalProperties = fileUploadV1ByUrl.additionalProperties.toMutableMap() } - class Options - private constructor( - private val addShadow: MultipartField, - private val bgColor: MultipartField, - private val bgImageUrl: MultipartField, - private val semitransparency: MultipartField, - private val additionalProperties: MutableMap, - ) { + /** + * A publicly reachable URL that ImageKit’s servers can fetch. The server must + * receive the response headers within 8 seconds; otherwise the request fails with + * 400 Bad Request. + */ + fun file(file: String) = file(MultipartField.of(file)) /** - * Whether to add an artificial shadow to the result. Default is false. Note: Adding - * shadows is currently only supported for car photos. + * Sets [Builder.file] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * You should usually call [Builder.file] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun addShadow(): Optional = addShadow.value.getOptional("add_shadow") + fun file(file: MultipartField) = apply { this.file = file } /** - * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or - * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be - * empty. + * The name with which the file has to be uploaded. The file name can contain: + * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + * - Special Characters: `.`, `-` * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * Any other character including space will be replaced by `_` */ - fun bgColor(): Optional = bgColor.value.getOptional("bg_color") + fun fileName(fileName: String) = fileName(MultipartField.of(fileName)) /** - * Sets a background image from a URL. If this parameter is set, `bg_color` must be - * empty. + * Sets [Builder.fileName] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * You should usually call [Builder.fileName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun bgImageUrl(): Optional = bgImageUrl.value.getOptional("bg_image_url") + fun fileName(fileName: MultipartField) = apply { this.fileName = fileName } /** - * Allows semi-transparent regions in the result. Default is true. Note: - * Semitransparency is currently only supported for car windows. + * A unique value that the ImageKit.io server will use to recognize and prevent + * subsequent retries for the same request. We suggest using V4 UUIDs, or another + * random string with enough entropy to avoid collisions. This field is only + * required for authentication when uploading a file from the client side. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * **Note**: Sending a value that has been used in the past will result in a + * validation error. Even if your previous request resulted in an error, you should + * always send a new value for this field. */ - fun semitransparency(): Optional = - semitransparency.value.getOptional("semitransparency") + fun token(token: String) = token(MultipartField.of(token)) /** - * Returns the raw multipart value of [addShadow]. + * Sets [Builder.token] to an arbitrary multipart value. * - * Unlike [addShadow], this method doesn't throw if the multipart field has an - * unexpected type. + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - @JsonProperty("add_shadow") - @ExcludeMissing - fun _addShadow(): MultipartField = addShadow + fun token(token: MultipartField) = apply { this.token = token } /** - * Returns the raw multipart value of [bgColor]. - * - * Unlike [bgColor], this method doesn't throw if the multipart field has an - * unexpected type. + * Server-side checks to run on the asset. Read more about + * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). */ - @JsonProperty("bg_color") - @ExcludeMissing - fun _bgColor(): MultipartField = bgColor + fun checks(checks: String) = checks(MultipartField.of(checks)) /** - * Returns the raw multipart value of [bgImageUrl]. + * Sets [Builder.checks] to an arbitrary multipart value. * - * Unlike [bgImageUrl], this method doesn't throw if the multipart field has an - * unexpected type. + * You should usually call [Builder.checks] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - @JsonProperty("bg_image_url") - @ExcludeMissing - fun _bgImageUrl(): MultipartField = bgImageUrl + fun checks(checks: MultipartField) = apply { this.checks = checks } /** - * Returns the raw multipart value of [semitransparency]. - * - * Unlike [semitransparency], this method doesn't throw if the multipart field has - * an unexpected type. + * Define an important area in the image. This is only relevant for image type + * files. + * - To be passed as a string with the x and y coordinates of the top-left corner, + * and width and height of the area of interest in the format `x,y,width,height`. + * For example - `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then + * customCoordinates will be removed. */ - @JsonProperty("semitransparency") - @ExcludeMissing - fun _semitransparency(): MultipartField = semitransparency + fun customCoordinates(customCoordinates: String) = + customCoordinates(MultipartField.of(customCoordinates)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + /** + * Sets [Builder.customCoordinates] to an arbitrary multipart value. + * + * You should usually call [Builder.customCoordinates] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun customCoordinates(customCoordinates: MultipartField) = apply { + this.customCoordinates = customCoordinates } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata + * fields before setting these values. + */ + fun customMetadata(customMetadata: CustomMetadata) = + customMetadata(MultipartField.of(customMetadata)) - /** Returns a mutable builder for constructing an instance of [Options]. */ - @JvmStatic fun builder() = Builder() + /** + * Sets [Builder.customMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.customMetadata] with a well-typed + * [CustomMetadata] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun customMetadata(customMetadata: MultipartField) = apply { + this.customMetadata = customMetadata } - /** A builder for [Options]. */ - class Builder internal constructor() { - - private var addShadow: MultipartField = MultipartField.of(null) - private var bgColor: MultipartField = MultipartField.of(null) - private var bgImageUrl: MultipartField = MultipartField.of(null) - private var semitransparency: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(options: Options) = apply { - addShadow = options.addShadow - bgColor = options.bgColor - bgImageUrl = options.bgImageUrl - semitransparency = options.semitransparency - additionalProperties = options.additionalProperties.toMutableMap() - } - - /** - * Whether to add an artificial shadow to the result. Default is false. Note: - * Adding shadows is currently only supported for car photos. - */ - fun addShadow(addShadow: Boolean) = addShadow(MultipartField.of(addShadow)) - - /** - * Sets [Builder.addShadow] to an arbitrary multipart value. - * - * You should usually call [Builder.addShadow] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun addShadow(addShadow: MultipartField) = apply { - this.addShadow = addShadow - } - - /** - * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or - * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be - * empty. - */ - fun bgColor(bgColor: String) = bgColor(MultipartField.of(bgColor)) - - /** - * Sets [Builder.bgColor] to an arbitrary multipart value. - * - * You should usually call [Builder.bgColor] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun bgColor(bgColor: MultipartField) = apply { this.bgColor = bgColor } + /** Optional text to describe the contents of the file. */ + fun description(description: String) = description(MultipartField.of(description)) - /** - * Sets a background image from a URL. If this parameter is set, `bg_color` must - * be empty. - */ - fun bgImageUrl(bgImageUrl: String) = bgImageUrl(MultipartField.of(bgImageUrl)) - - /** - * Sets [Builder.bgImageUrl] to an arbitrary multipart value. - * - * You should usually call [Builder.bgImageUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun bgImageUrl(bgImageUrl: MultipartField) = apply { - this.bgImageUrl = bgImageUrl - } + /** + * Sets [Builder.description] to an arbitrary multipart 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: MultipartField) = apply { + this.description = description + } - /** - * Allows semi-transparent regions in the result. Default is true. Note: - * Semitransparency is currently only supported for car windows. - */ - fun semitransparency(semitransparency: Boolean) = - semitransparency(MultipartField.of(semitransparency)) + /** + * The time until your signature is valid. It must be a + * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the + * future. It should be in seconds. This field is only required for authentication + * when uploading a file from the client side. + */ + fun expire(expire: Long) = expire(MultipartField.of(expire)) - /** - * Sets [Builder.semitransparency] to an arbitrary multipart value. - * - * You should usually call [Builder.semitransparency] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun semitransparency(semitransparency: MultipartField) = apply { - this.semitransparency = semitransparency - } + /** + * Sets [Builder.expire] to an arbitrary multipart value. + * + * You should usually call [Builder.expire] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expire(expire: MultipartField) = apply { this.expire = expire } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Array of extensions to be applied to the image. Each extension can be configured + * with specific parameters based on the extension type. + */ + fun extensions(extensions: List) = + extensions(MultipartField.of(extensions)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.extensions] to an arbitrary multipart value. + * + * You should usually call [Builder.extensions] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun extensions(extensions: MultipartField>) = apply { + this.extensions = extensions.map { it.toMutableList() } + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + /** + * Adds a single [Extension] to [extensions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExtension(extension: Extension) = apply { + extensions = + (extensions ?: MultipartField.of(mutableListOf())).also { + checkKnown("extensions", it).add(extension) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Options]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Options = - Options( - addShadow, - bgColor, - bgImageUrl, - semitransparency, - additionalProperties.toMutableMap(), - ) } - private var validated: Boolean = false + /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ + fun addExtension(removeBg: Extension.RemoveBg) = + addExtension(Extension.ofRemoveBg(removeBg)) - fun validate(): Options = apply { - if (validated) { - return@apply - } + /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = + addExtension(Extension.ofAutoTagging(autoTagging)) - addShadow() - bgColor() - bgImageUrl() - semitransparency() - validated = true - } + /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ + fun addExtensionAiAutoDescription() = addExtension(Extension.ofAiAutoDescription()) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't + * exist before, a new folder(s) is created. + * + * The folder name can contain: + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. + */ + fun folder(folder: String) = folder(MultipartField.of(folder)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.folder] to an arbitrary multipart value. + * + * You should usually call [Builder.folder] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun folder(folder: MultipartField) = apply { this.folder = folder } - return other is Options && - addShadow == other.addShadow && - bgColor == other.bgColor && - bgImageUrl == other.bgImageUrl && - semitransparency == other.semitransparency && - additionalProperties == other.additionalProperties - } + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named + * transformation or signed URL. + */ + fun isPrivateFile(isPrivateFile: Boolean) = + isPrivateFile(MultipartField.of(isPrivateFile)) - private val hashCode: Int by lazy { - Objects.hash( - addShadow, - bgColor, - bgImageUrl, - semitransparency, - additionalProperties, - ) + /** + * Sets [Builder.isPrivateFile] to an arbitrary multipart value. + * + * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun isPrivateFile(isPrivateFile: MultipartField) = apply { + this.isPrivateFile = isPrivateFile } - override fun hashCode(): Int = hashCode - - override fun toString() = - "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" - } + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file + * only via the media library. Files in draft or unpublished state can only be + * publicly accessed after being published. + * + * The option to upload in draft state is only available in custom enterprise + * pricing plans. + */ + fun isPublished(isPublished: Boolean) = isPublished(MultipartField.of(isPublished)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * Sets [Builder.isPublished] to an arbitrary multipart value. + * + * You should usually call [Builder.isPublished] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun isPublished(isPublished: MultipartField) = apply { + this.isPublished = isPublished } - return other is RemoveBg && - name == other.name && - options == other.options && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(name, options, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" - } - - class AutoTaggingExtension - private constructor( - private val maxTags: MultipartField, - private val minConfidence: MultipartField, - private val name: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Maximum number of tags to attach to the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun maxTags(): Long = maxTags.value.getRequired("maxTags") - - /** - * Minimum confidence level for tags to be considered valid. - * - * @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 minConfidence(): Long = minConfidence.value.getRequired("minConfidence") + /** + * If set to `true` and a file already exists at the exact location, its AITags will + * be removed. Set `overwriteAITags` to `false` to preserve AITags. + */ + fun overwriteAiTags(overwriteAiTags: Boolean) = + overwriteAiTags(MultipartField.of(overwriteAiTags)) - /** - * Specifies the auto-tagging extension used. - * - * @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(): Name = name.value.getRequired("name") + /** + * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteAiTags] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun overwriteAiTags(overwriteAiTags: MultipartField) = apply { + this.overwriteAiTags = overwriteAiTags + } - /** - * Returns the raw multipart value of [maxTags]. - * - * Unlike [maxTags], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("maxTags") @ExcludeMissing fun _maxTags(): MultipartField = maxTags + /** + * If the request does not have `customMetadata`, and a file already exists at the + * exact location, existing customMetadata will be removed. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: Boolean) = + overwriteCustomMetadata(MultipartField.of(overwriteCustomMetadata)) - /** - * Returns the raw multipart value of [minConfidence]. - * - * Unlike [minConfidence], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("minConfidence") - @ExcludeMissing - fun _minConfidence(): MultipartField = minConfidence + /** + * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteCustomMetadata] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: MultipartField) = + apply { + this.overwriteCustomMetadata = overwriteCustomMetadata + } - /** - * Returns the raw multipart value of [name]. - * - * Unlike [name], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at + * the exact location, upload API will return an error immediately. + */ + fun overwriteFile(overwriteFile: Boolean) = + overwriteFile(MultipartField.of(overwriteFile)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.overwriteFile] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun overwriteFile(overwriteFile: MultipartField) = apply { + this.overwriteFile = overwriteFile + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * If the request does not have `tags`, and a file already exists at the exact + * location, existing tags will be removed. + */ + fun overwriteTags(overwriteTags: Boolean) = + overwriteTags(MultipartField.of(overwriteTags)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.overwriteTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteTags] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun overwriteTags(overwriteTags: MultipartField) = apply { + this.overwriteTags = overwriteTags + } - companion object { + /** + * Your ImageKit.io public key. This field is only required for authentication when + * uploading a file from the client side. + */ + fun publicKey(publicKey: String) = publicKey(MultipartField.of(publicKey)) /** - * Returns a mutable builder for constructing an instance of [AutoTaggingExtension]. + * Sets [Builder.publicKey] to an arbitrary multipart value. * - * The following fields are required: - * ```java - * .maxTags() - * .minConfidence() - * .name() - * ``` + * You should usually call [Builder.publicKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - @JvmStatic fun builder() = Builder() - } + fun publicKey(publicKey: MultipartField) = apply { + this.publicKey = publicKey + } - /** A builder for [AutoTaggingExtension]. */ - class Builder internal constructor() { + /** Array of response field keys to include in the API response body. */ + fun responseFields(responseFields: List) = + responseFields(MultipartField.of(responseFields)) - private var maxTags: MultipartField? = null - private var minConfidence: MultipartField? = null - private var name: MultipartField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.responseFields] to an arbitrary multipart value. + * + * You should usually call [Builder.responseFields] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun responseFields(responseFields: MultipartField>) = apply { + this.responseFields = responseFields.map { it.toMutableList() } + } - @JvmSynthetic - internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { - maxTags = autoTaggingExtension.maxTags - minConfidence = autoTaggingExtension.minConfidence - name = autoTaggingExtension.name - additionalProperties = autoTaggingExtension.additionalProperties.toMutableMap() + /** + * Adds a single [ResponseField] to [responseFields]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResponseField(responseField: ResponseField) = apply { + responseFields = + (responseFields ?: MultipartField.of(mutableListOf())).also { + checkKnown("responseFields", it).add(responseField) + } } - /** Maximum number of tags to attach to the asset. */ - fun maxTags(maxTags: Long) = maxTags(MultipartField.of(maxTags)) + /** + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a + * key. Learn how to create a signature on the page below. This should be in + * lowercase. + * + * Signature must be calculated on the server-side. This field is only required for + * authentication when uploading a file from the client side. + */ + fun signature(signature: String) = signature(MultipartField.of(signature)) /** - * Sets [Builder.maxTags] to an arbitrary multipart value. + * Sets [Builder.signature] to an arbitrary multipart value. * - * You should usually call [Builder.maxTags] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.signature] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun maxTags(maxTags: MultipartField) = apply { this.maxTags = maxTags } + fun signature(signature: MultipartField) = apply { + this.signature = signature + } - /** Minimum confidence level for tags to be considered valid. */ - fun minConfidence(minConfidence: Long) = - minConfidence(MultipartField.of(minConfidence)) + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. + * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not + * exceed 500, and the `%` character is not allowed. If this field is not specified + * and the file is overwritten, the existing tags will be removed. + */ + fun tags(tags: List) = tags(MultipartField.of(tags)) /** - * Sets [Builder.minConfidence] to an arbitrary multipart value. + * Sets [Builder.tags] to an arbitrary multipart value. * - * You should usually call [Builder.minConfidence] with a well-typed [Long] value + * You should usually call [Builder.tags] with a well-typed `List` value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun minConfidence(minConfidence: MultipartField) = apply { - this.minConfidence = minConfidence + fun tags(tags: MultipartField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = + (tags ?: MultipartField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } } - /** Specifies the auto-tagging extension used. */ - fun name(name: Name) = name(MultipartField.of(name)) + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for + * reducing file size or applying basic optimizations upfront (e.g., resize, + * compress). + * - `post` — applied immediately after upload. Ideal for generating transformed + * versions (like video encodes or thumbnails) in advance, so they're ready for + * delivery without delay. + * + * You can mix and match any combination of post-processing types. + */ + fun transformation(transformation: Transformation) = + transformation(MultipartField.of(transformation)) /** - * Sets [Builder.name] to an arbitrary multipart value. + * Sets [Builder.transformation] to an arbitrary multipart value. * - * You should usually call [Builder.name] with a well-typed [Name] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.transformation] with a well-typed + * [Transformation] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun transformation(transformation: MultipartField) = apply { + this.transformation = transformation + } + + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get + * a unique filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and + * any existing file with the same name is replaced. + */ + fun useUniqueFileName(useUniqueFileName: Boolean) = + useUniqueFileName(MultipartField.of(useUniqueFileName)) + + /** + * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. + * + * You should usually call [Builder.useUniqueFileName] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun useUniqueFileName(useUniqueFileName: MultipartField) = apply { + this.useUniqueFileName = useUniqueFileName + } + + /** + * The final status of extensions after they have completed execution will be + * delivered to this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + */ + fun webhookUrl(webhookUrl: String) = webhookUrl(MultipartField.of(webhookUrl)) + + /** + * Sets [Builder.webhookUrl] to an arbitrary multipart value. + * + * You should usually call [Builder.webhookUrl] 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: MultipartField) = apply { this.name = name } + fun webhookUrl(webhookUrl: MultipartField) = apply { + this.webhookUrl = webhookUrl + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3367,38 +5559,77 @@ private constructor( } /** - * Returns an immutable instance of [AutoTaggingExtension]. + * Returns an immutable instance of [FileUploadV1ByUrl]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .maxTags() - * .minConfidence() - * .name() + * .file() + * .fileName() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AutoTaggingExtension = - AutoTaggingExtension( - checkRequired("maxTags", maxTags), - checkRequired("minConfidence", minConfidence), - checkRequired("name", name), + fun build(): FileUploadV1ByUrl = + FileUploadV1ByUrl( + checkRequired("file", file), + checkRequired("fileName", fileName), + token, + checks, + customCoordinates, + customMetadata, + description, + expire, + (extensions ?: MultipartField.of(null)).map { it.toImmutable() }, + folder, + isPrivateFile, + isPublished, + overwriteAiTags, + overwriteCustomMetadata, + overwriteFile, + overwriteTags, + publicKey, + (responseFields ?: MultipartField.of(null)).map { it.toImmutable() }, + signature, + (tags ?: MultipartField.of(null)).map { it.toImmutable() }, + transformation, + useUniqueFileName, + webhookUrl, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): AutoTaggingExtension = apply { + fun validate(): FileUploadV1ByUrl = apply { if (validated) { return@apply } - maxTags() - minConfidence() - name().validate() + file() + fileName() + token() + checks() + customCoordinates() + customMetadata().ifPresent { it.validate() } + description() + expire() + extensions().ifPresent { it.forEach { it.validate() } } + folder() + isPrivateFile() + isPublished() + overwriteAiTags() + overwriteCustomMetadata() + overwriteFile() + overwriteTags() + publicKey() + responseFields().ifPresent { it.forEach { it.validate() } } + signature() + tags() + transformation().ifPresent { it.validate() } + useUniqueFileName() + webhookUrl() validated = true } @@ -3410,105 +5641,176 @@ private constructor( false } - /** Specifies the auto-tagging extension used. */ - class Name @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields + * before setting these values. + */ + class CustomMetadata + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun toBuilder() = Builder().from(this) companion object { - @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") + /** + * Returns a mutable builder for constructing an instance of [CustomMetadata]. + */ + @JvmStatic fun builder() = Builder() + } - @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") + /** A builder for [CustomMetadata]. */ + class Builder internal constructor() { - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } + private var additionalProperties: MutableMap = mutableMapOf() - /** An enum containing [Name]'s known values. */ - enum class Known { - GOOGLE_AUTO_TAGGING, - AWS_AUTO_TAGGING, - } + @JvmSynthetic + internal fun from(customMetadata: CustomMetadata) = apply { + additionalProperties = customMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Name] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GOOGLE_AUTO_TAGGING, - AWS_AUTO_TAGGING, /** - * An enum member indicating that [Name] was instantiated with an unknown value. + * Returns an immutable instance of [CustomMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. */ - _UNKNOWN, + fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING - AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING - else -> Value._UNKNOWN + private var validated: Boolean = false + + fun validate(): CustomMetadata = apply { + if (validated) { + return@apply } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING - AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING - else -> throw ImageKitInvalidDataException("Unknown Name: $value") + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomMetadata{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Extension.Deserializer::class) + @JsonSerialize(using = Extension.Serializer::class) + class Extension + private constructor( + private val removeBg: RemoveBg? = null, + private val autoTagging: AutoTaggingExtension? = null, + private val aiAutoDescription: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun removeBg(): Optional = Optional.ofNullable(removeBg) + + fun autoTagging(): Optional = Optional.ofNullable(autoTagging) + + fun aiAutoDescription(): Optional = + Optional.ofNullable(aiAutoDescription) + + fun isRemoveBg(): Boolean = removeBg != null + + fun isAutoTagging(): Boolean = autoTagging != null + + fun isAiAutoDescription(): Boolean = aiAutoDescription != null + + fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") + + fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") + + fun asAiAutoDescription(): JsonValue = + aiAutoDescription.getOrThrow("aiAutoDescription") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + removeBg != null -> visitor.visitRemoveBg(removeBg) + autoTagging != null -> visitor.visitAutoTagging(autoTagging) + aiAutoDescription != null -> + visitor.visitAiAutoDescription(aiAutoDescription) + else -> visitor.unknown(_json) } private var validated: Boolean = false - fun validate(): Name = apply { + fun validate(): Extension = apply { if (validated) { return@apply } - known() + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) { + removeBg.validate() + } + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { + autoTagging.validate() + } + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { + aiAutoDescription.let { + if ( + it != JsonValue.from(mapOf("name" to "ai-auto-description")) + ) { + throw ImageKitInvalidDataException( + "'aiAutoDescription' is invalid, received $it" + ) + } + } + } + } + ) validated = true } @@ -3526,792 +5828,1109 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = + autoTagging.validity() + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = + aiAutoDescription.let { + if ( + it == JsonValue.from(mapOf("name" to "ai-auto-description")) + ) + 1 + else 0 + } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extension && + removeBg == other.removeBg && + autoTagging == other.autoTagging && + aiAutoDescription == other.aiAutoDescription + } + + override fun hashCode(): Int = + Objects.hash(removeBg, autoTagging, aiAutoDescription) + + override fun toString(): String = + when { + removeBg != null -> "Extension{removeBg=$removeBg}" + autoTagging != null -> "Extension{autoTagging=$autoTagging}" + aiAutoDescription != null -> + "Extension{aiAutoDescription=$aiAutoDescription}" + _json != null -> "Extension{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Extension") + } + + companion object { + + @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = Extension(removeBg = removeBg) + + @JvmStatic + fun ofAutoTagging(autoTagging: AutoTaggingExtension) = + Extension(autoTagging = autoTagging) + + @JvmStatic + fun ofAiAutoDescription() = + Extension( + aiAutoDescription = + JsonValue.from(mapOf("name" to "ai-auto-description")) + ) + } + + /** + * An interface that defines how to map each variant of [Extension] to a value of + * type [T]. + */ + interface Visitor { + + fun visitRemoveBg(removeBg: RemoveBg): T + + fun visitAutoTagging(autoTagging: AutoTaggingExtension): T + + fun visitAiAutoDescription(aiAutoDescription: JsonValue): T + + /** + * Maps an unknown variant of [Extension] to a value of type [T]. + * + * An instance of [Extension] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Extension: $json") + } + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + internal class Deserializer : BaseDeserializer(Extension::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Extension { + val json = JsonValue.fromJsonNode(node) + val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() + + when (name) { + "remove-bg" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Extension(removeBg = it, _json = json) + } ?: Extension(_json = json) + } + "ai-auto-description" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Extension(aiAutoDescription = it, _json = json) } + ?.takeIf { it.isValid() } ?: Extension(_json = json) + } + } + + return tryDeserialize(node, jacksonTypeRef())?.let { + Extension(autoTagging = it, _json = json) + } ?: Extension(_json = json) } + } - return other is Name && value == other.value + internal class Serializer : BaseSerializer(Extension::class) { + + override fun serialize( + value: Extension, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.removeBg != null -> generator.writeObject(value.removeBg) + value.autoTagging != null -> generator.writeObject(value.autoTagging) + value.aiAutoDescription != null -> + generator.writeObject(value.aiAutoDescription) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Extension") + } + } } - override fun hashCode() = value.hashCode() + class RemoveBg + private constructor( + private val name: JsonValue, + private val options: MultipartField, + private val additionalProperties: MutableMap, + ) { - override fun toString() = value.toString() - } + /** + * Specifies the background removal extension. + * + * Expected to always return the following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun options(): Optional = options.value.getOptional("options") - return other is AutoTaggingExtension && - maxTags == other.maxTags && - minConfidence == other.minConfidence && - name == other.name && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw multipart value of [options]. + * + * Unlike [options], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("options") + @ExcludeMissing + fun _options(): MultipartField = options - private val hashCode: Int by lazy { - Objects.hash(maxTags, minConfidence, name, additionalProperties) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun hashCode(): Int = hashCode + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun toString() = - "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" - } - } + fun toBuilder() = Builder().from(this) - class ResponseField @JsonCreator private constructor(private val value: JsonField) : - Enum { + companion object { - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ + @JvmStatic fun builder() = Builder() + } - companion object { + /** A builder for [RemoveBg]. */ + class Builder internal constructor() { - @JvmField val TAGS = of("tags") + private var name: JsonValue = JsonValue.from("remove-bg") + private var options: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = + mutableMapOf() - @JvmField val CUSTOM_COORDINATES = of("customCoordinates") + @JvmSynthetic + internal fun from(removeBg: RemoveBg) = apply { + name = removeBg.name + options = removeBg.options + additionalProperties = removeBg.additionalProperties.toMutableMap() + } - @JvmField val IS_PRIVATE_FILE = of("isPrivateFile") + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun name(name: JsonValue) = apply { this.name = name } - @JvmField val EMBEDDED_METADATA = of("embeddedMetadata") + fun options(options: Options) = options(MultipartField.of(options)) - @JvmField val IS_PUBLISHED = of("isPublished") + /** + * Sets [Builder.options] to an arbitrary multipart value. + * + * You should usually call [Builder.options] with a well-typed [Options] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun options(options: MultipartField) = apply { + this.options = options + } - @JvmField val CUSTOM_METADATA = of("customMetadata") + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JvmField val METADATA = of("metadata") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JvmStatic fun of(value: String) = ResponseField(JsonField.of(value)) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** An enum containing [ResponseField]'s known values. */ - enum class Known { - TAGS, - CUSTOM_COORDINATES, - IS_PRIVATE_FILE, - EMBEDDED_METADATA, - IS_PUBLISHED, - CUSTOM_METADATA, - METADATA, - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * An enum containing [ResponseField]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ResponseField] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TAGS, - CUSTOM_COORDINATES, - IS_PRIVATE_FILE, - EMBEDDED_METADATA, - IS_PUBLISHED, - CUSTOM_METADATA, - METADATA, - /** - * An enum member indicating that [ResponseField] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TAGS -> Value.TAGS - CUSTOM_COORDINATES -> Value.CUSTOM_COORDINATES - IS_PRIVATE_FILE -> Value.IS_PRIVATE_FILE - EMBEDDED_METADATA -> Value.EMBEDDED_METADATA - IS_PUBLISHED -> Value.IS_PUBLISHED - CUSTOM_METADATA -> Value.CUSTOM_METADATA - METADATA -> Value.METADATA - else -> Value._UNKNOWN - } + /** + * Returns an immutable instance of [RemoveBg]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemoveBg = + RemoveBg(name, options, additionalProperties.toMutableMap()) + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TAGS -> Known.TAGS - CUSTOM_COORDINATES -> Known.CUSTOM_COORDINATES - IS_PRIVATE_FILE -> Known.IS_PRIVATE_FILE - EMBEDDED_METADATA -> Known.EMBEDDED_METADATA - IS_PUBLISHED -> Known.IS_PUBLISHED - CUSTOM_METADATA -> Known.CUSTOM_METADATA - METADATA -> Known.METADATA - else -> throw ImageKitInvalidDataException("Unknown ResponseField: $value") - } + private var validated: Boolean = false - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") - } + fun validate(): RemoveBg = apply { + if (validated) { + return@apply + } - private var validated: Boolean = false + _name().let { + if (it != JsonValue.from("remove-bg")) { + throw ImageKitInvalidDataException( + "'name' is invalid, received $it" + ) + } + } + options().ifPresent { it.validate() } + validated = true + } - fun validate(): ResponseField = apply { - if (validated) { - return@apply - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - known() - validated = true - } + class Options + private constructor( + private val addShadow: MultipartField, + private val bgColor: MultipartField, + private val bgImageUrl: MultipartField, + private val semitransparency: MultipartField, + private val additionalProperties: MutableMap, + ) { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + /** + * Whether to add an artificial shadow to the result. Default is false. + * Note: Adding shadows is currently only supported for car photos. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun addShadow(): Optional = + addShadow.value.getOptional("add_shadow") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") + * or color name (e.g., "green"). If this parameter is set, `bg_image_url` + * must be empty. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun bgColor(): Optional = bgColor.value.getOptional("bg_color") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets a background image from a URL. If this parameter is set, `bg_color` + * must be empty. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun bgImageUrl(): Optional = + bgImageUrl.value.getOptional("bg_image_url") - return other is ResponseField && value == other.value - } + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun semitransparency(): Optional = + semitransparency.value.getOptional("semitransparency") - override fun hashCode() = value.hashCode() + /** + * Returns the raw multipart value of [addShadow]. + * + * Unlike [addShadow], this method doesn't throw if the multipart field has + * an unexpected type. + */ + @JsonProperty("add_shadow") + @ExcludeMissing + fun _addShadow(): MultipartField = addShadow - override fun toString() = value.toString() - } + /** + * Returns the raw multipart value of [bgColor]. + * + * Unlike [bgColor], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("bg_color") + @ExcludeMissing + fun _bgColor(): MultipartField = bgColor - /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing file - * size or applying basic optimizations upfront (e.g., resize, compress). - * - `post` — applied immediately after upload. Ideal for generating transformed versions (like - * video encodes or thumbnails) in advance, so they're ready for delivery without delay. - * - * You can mix and match any combination of post-processing types. - */ - class Transformation - private constructor( - private val post: MultipartField>, - private val pre: MultipartField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw multipart value of [bgImageUrl]. + * + * Unlike [bgImageUrl], this method doesn't throw if the multipart field has + * an unexpected type. + */ + @JsonProperty("bg_image_url") + @ExcludeMissing + fun _bgImageUrl(): MultipartField = bgImageUrl - /** - * List of transformations to apply _after_ the file is uploaded. Each item must match one - * of the following types: `transformation`, `gif-to-video`, `thumbnail`, `abs`. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun post(): Optional> = post.value.getOptional("post") + /** + * Returns the raw multipart value of [semitransparency]. + * + * Unlike [semitransparency], this method doesn't throw if the multipart + * field has an unexpected type. + */ + @JsonProperty("semitransparency") + @ExcludeMissing + fun _semitransparency(): MultipartField = semitransparency - /** - * Transformation string to apply before uploading the file to the Media Library. Useful for - * optimizing files at ingestion. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun pre(): Optional = pre.value.getOptional("pre") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw multipart value of [post]. - * - * Unlike [post], this method doesn't throw if the multipart field has an unexpected type. - */ - @JsonProperty("post") @ExcludeMissing fun _post(): MultipartField> = post + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw multipart value of [pre]. - * - * Unlike [pre], this method doesn't throw if the multipart field has an unexpected type. - */ - @JsonProperty("pre") @ExcludeMissing fun _pre(): MultipartField = pre + fun toBuilder() = Builder().from(this) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns a mutable builder for constructing an instance of [Options]. + */ + @JvmStatic fun builder() = Builder() + } - fun toBuilder() = Builder().from(this) + /** A builder for [Options]. */ + class Builder internal constructor() { + + private var addShadow: MultipartField = MultipartField.of(null) + private var bgColor: MultipartField = MultipartField.of(null) + private var bgImageUrl: MultipartField = MultipartField.of(null) + private var semitransparency: MultipartField = + MultipartField.of(null) + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(options: Options) = apply { + addShadow = options.addShadow + bgColor = options.bgColor + bgImageUrl = options.bgImageUrl + semitransparency = options.semitransparency + additionalProperties = options.additionalProperties.toMutableMap() + } - companion object { + /** + * Whether to add an artificial shadow to the result. Default is false. + * Note: Adding shadows is currently only supported for car photos. + */ + fun addShadow(addShadow: Boolean) = + addShadow(MultipartField.of(addShadow)) + + /** + * Sets [Builder.addShadow] to an arbitrary multipart value. + * + * You should usually call [Builder.addShadow] with a well-typed + * [Boolean] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun addShadow(addShadow: MultipartField) = apply { + this.addShadow = addShadow + } - /** Returns a mutable builder for constructing an instance of [Transformation]. */ - @JvmStatic fun builder() = Builder() - } + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", + * "fff") or color name (e.g., "green"). If this parameter is set, + * `bg_image_url` must be empty. + */ + fun bgColor(bgColor: String) = bgColor(MultipartField.of(bgColor)) + + /** + * Sets [Builder.bgColor] to an arbitrary multipart value. + * + * You should usually call [Builder.bgColor] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun bgColor(bgColor: MultipartField) = apply { + this.bgColor = bgColor + } - /** A builder for [Transformation]. */ - class Builder internal constructor() { + /** + * Sets a background image from a URL. If this parameter is set, + * `bg_color` must be empty. + */ + fun bgImageUrl(bgImageUrl: String) = + bgImageUrl(MultipartField.of(bgImageUrl)) + + /** + * Sets [Builder.bgImageUrl] to an arbitrary multipart value. + * + * You should usually call [Builder.bgImageUrl] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun bgImageUrl(bgImageUrl: MultipartField) = apply { + this.bgImageUrl = bgImageUrl + } - private var post: MultipartField>? = null - private var pre: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + */ + fun semitransparency(semitransparency: Boolean) = + semitransparency(MultipartField.of(semitransparency)) + + /** + * Sets [Builder.semitransparency] to an arbitrary multipart value. + * + * You should usually call [Builder.semitransparency] with a well-typed + * [Boolean] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun semitransparency(semitransparency: MultipartField) = + apply { + this.semitransparency = semitransparency + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JvmSynthetic - internal fun from(transformation: Transformation) = apply { - post = transformation.post.map { it.toMutableList() } - pre = transformation.pre - additionalProperties = transformation.additionalProperties.toMutableMap() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * List of transformations to apply _after_ the file is uploaded. Each item must match - * one of the following types: `transformation`, `gif-to-video`, `thumbnail`, `abs`. - */ - fun post(post: List) = post(MultipartField.of(post)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.post] to an arbitrary multipart value. - * - * You should usually call [Builder.post] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun post(post: MultipartField>) = apply { - this.post = post.map { it.toMutableList() } - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Adds a single [Post] to [Builder.post]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPost(post: Post) = apply { - this.post = - (this.post ?: MultipartField.of(mutableListOf())).also { - checkKnown("post", it).add(post) - } - } + /** + * Returns an immutable instance of [Options]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): Options = + Options( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties.toMutableMap(), + ) + } - /** Alias for calling [addPost] with `Post.ofTransformation(transformation)`. */ - fun addPost(transformation: Post.InnerTransformation) = - addPost(Post.ofTransformation(transformation)) + private var validated: Boolean = false - /** - * Alias for calling [addPost] with the following: - * ```java - * Post.InnerTransformation.builder() - * .value(value) - * .build() - * ``` - */ - fun addTransformationPost(value: String) = - addPost(Post.InnerTransformation.builder().value(value).build()) + fun validate(): Options = apply { + if (validated) { + return@apply + } - /** Alias for calling [addPost] with `Post.ofGifToVideo(gifToVideo)`. */ - fun addPost(gifToVideo: Post.GifToVideo) = addPost(Post.ofGifToVideo(gifToVideo)) + addShadow() + bgColor() + bgImageUrl() + semitransparency() + validated = true + } - /** Alias for calling [addPost] with `Post.ofThumbnail(thumbnail)`. */ - fun addPost(thumbnail: Post.Thumbnail) = addPost(Post.ofThumbnail(thumbnail)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - /** Alias for calling [addPost] with `Post.ofAbs(abs)`. */ - fun addPost(abs: Post.Abs) = addPost(Post.ofAbs(abs)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Transformation string to apply before uploading the file to the Media Library. Useful - * for optimizing files at ingestion. - */ - fun pre(pre: String) = pre(MultipartField.of(pre)) + return other is Options && + addShadow == other.addShadow && + bgColor == other.bgColor && + bgImageUrl == other.bgImageUrl && + semitransparency == other.semitransparency && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.pre] to an arbitrary multipart value. - * - * You should usually call [Builder.pre] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun pre(pre: MultipartField) = apply { this.pre = pre } + private val hashCode: Int by lazy { + Objects.hash( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties, + ) + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + override fun hashCode(): Int = hashCode - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun toString() = + "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + return other is RemoveBg && + name == other.name && + options == other.options && + additionalProperties == other.additionalProperties + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private val hashCode: Int by lazy { + Objects.hash(name, options, additionalProperties) + } - /** - * Returns an immutable instance of [Transformation]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Transformation = - Transformation( - (post ?: MultipartField.of(null)).map { it.toImmutable() }, - pre, - additionalProperties.toMutableMap(), - ) - } + override fun hashCode(): Int = hashCode - private var validated: Boolean = false + override fun toString() = + "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" + } - fun validate(): Transformation = apply { - if (validated) { - return@apply - } + class AutoTaggingExtension + private constructor( + private val maxTags: MultipartField, + private val minConfidence: MultipartField, + private val name: MultipartField, + private val additionalProperties: MutableMap, + ) { - post().ifPresent { it.forEach { it.validate() } } - pre() - validated = true - } + /** + * Maximum number of tags to attach to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maxTags(): Long = maxTags.value.getRequired("maxTags") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + /** + * Minimum confidence level for tags to be considered valid. + * + * @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 minConfidence(): Long = minConfidence.value.getRequired("minConfidence") - @JsonDeserialize(using = Post.Deserializer::class) - @JsonSerialize(using = Post.Serializer::class) - class Post - private constructor( - private val transformation: InnerTransformation? = null, - private val gifToVideo: GifToVideo? = null, - private val thumbnail: Thumbnail? = null, - private val abs: Abs? = null, - private val _json: JsonValue? = null, - ) { + /** + * Specifies the auto-tagging extension used. + * + * @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(): Name = name.value.getRequired("name") - fun transformation(): Optional = - Optional.ofNullable(transformation) + /** + * Returns the raw multipart value of [maxTags]. + * + * Unlike [maxTags], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("maxTags") + @ExcludeMissing + fun _maxTags(): MultipartField = maxTags - fun gifToVideo(): Optional = Optional.ofNullable(gifToVideo) + /** + * Returns the raw multipart value of [minConfidence]. + * + * Unlike [minConfidence], this method doesn't throw if the multipart field has + * an unexpected type. + */ + @JsonProperty("minConfidence") + @ExcludeMissing + fun _minConfidence(): MultipartField = minConfidence - fun thumbnail(): Optional = Optional.ofNullable(thumbnail) + /** + * Returns the raw multipart value of [name]. + * + * Unlike [name], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name - fun abs(): Optional = Optional.ofNullable(abs) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isTransformation(): Boolean = transformation != null + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isGifToVideo(): Boolean = gifToVideo != null + fun toBuilder() = Builder().from(this) - fun isThumbnail(): Boolean = thumbnail != null + companion object { - fun isAbs(): Boolean = abs != null + /** + * Returns a mutable builder for constructing an instance of + * [AutoTaggingExtension]. + * + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun asTransformation(): InnerTransformation = - transformation.getOrThrow("transformation") + /** A builder for [AutoTaggingExtension]. */ + class Builder internal constructor() { + + private var maxTags: MultipartField? = null + private var minConfidence: MultipartField? = null + private var name: MultipartField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { + maxTags = autoTaggingExtension.maxTags + minConfidence = autoTaggingExtension.minConfidence + name = autoTaggingExtension.name + additionalProperties = + autoTaggingExtension.additionalProperties.toMutableMap() + } - fun asGifToVideo(): GifToVideo = gifToVideo.getOrThrow("gifToVideo") + /** Maximum number of tags to attach to the asset. */ + fun maxTags(maxTags: Long) = maxTags(MultipartField.of(maxTags)) - fun asThumbnail(): Thumbnail = thumbnail.getOrThrow("thumbnail") + /** + * Sets [Builder.maxTags] to an arbitrary multipart value. + * + * You should usually call [Builder.maxTags] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun maxTags(maxTags: MultipartField) = apply { + this.maxTags = maxTags + } - fun asAbs(): Abs = abs.getOrThrow("abs") + /** Minimum confidence level for tags to be considered valid. */ + fun minConfidence(minConfidence: Long) = + minConfidence(MultipartField.of(minConfidence)) - fun _json(): Optional = Optional.ofNullable(_json) + /** + * Sets [Builder.minConfidence] to an arbitrary multipart value. + * + * You should usually call [Builder.minConfidence] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minConfidence(minConfidence: MultipartField) = apply { + this.minConfidence = minConfidence + } - fun accept(visitor: Visitor): T = - when { - transformation != null -> visitor.visitTransformation(transformation) - gifToVideo != null -> visitor.visitGifToVideo(gifToVideo) - thumbnail != null -> visitor.visitThumbnail(thumbnail) - abs != null -> visitor.visitAbs(abs) - else -> visitor.unknown(_json) - } + /** Specifies the auto-tagging extension used. */ + fun name(name: Name) = name(MultipartField.of(name)) - private var validated: Boolean = false + /** + * Sets [Builder.name] to an arbitrary multipart value. + * + * You should usually call [Builder.name] with a well-typed [Name] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun name(name: MultipartField) = apply { this.name = name } - fun validate(): Post = apply { - if (validated) { - return@apply - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - accept( - object : Visitor { - override fun visitTransformation(transformation: InnerTransformation) { - transformation.validate() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - override fun visitGifToVideo(gifToVideo: GifToVideo) { - gifToVideo.validate() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitThumbnail(thumbnail: Thumbnail) { - thumbnail.validate() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - override fun visitAbs(abs: Abs) { - abs.validate() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + + /** + * Returns an immutable instance of [AutoTaggingExtension]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutoTaggingExtension = + AutoTaggingExtension( + checkRequired("maxTags", maxTags), + checkRequired("minConfidence", minConfidence), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + private var validated: Boolean = false - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitTransformation(transformation: InnerTransformation) = - transformation.validity() + fun validate(): AutoTaggingExtension = apply { + if (validated) { + return@apply + } - override fun visitGifToVideo(gifToVideo: GifToVideo) = gifToVideo.validity() + maxTags() + minConfidence() + name().validate() + validated = true + } - override fun visitThumbnail(thumbnail: Thumbnail) = thumbnail.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - override fun visitAbs(abs: Abs) = abs.validity() + /** Specifies the auto-tagging extension used. */ + class Name + @JsonCreator + private constructor(private val value: JsonField) : Enum { - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + companion object { - return other is Post && - transformation == other.transformation && - gifToVideo == other.gifToVideo && - thumbnail == other.thumbnail && - abs == other.abs - } + @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") - override fun hashCode(): Int = Objects.hash(transformation, gifToVideo, thumbnail, abs) + @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") - override fun toString(): String = - when { - transformation != null -> "Post{transformation=$transformation}" - gifToVideo != null -> "Post{gifToVideo=$gifToVideo}" - thumbnail != null -> "Post{thumbnail=$thumbnail}" - abs != null -> "Post{abs=$abs}" - _json != null -> "Post{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Post") - } + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } - companion object { + /** An enum containing [Name]'s known values. */ + enum class Known { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + } + + /** + * An enum containing [Name]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Name] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + /** + * An enum member indicating that [Name] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - @JvmStatic - fun ofTransformation(transformation: InnerTransformation) = - Post(transformation = transformation) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING + else -> Value._UNKNOWN + } - @JvmStatic fun ofGifToVideo(gifToVideo: GifToVideo) = Post(gifToVideo = gifToVideo) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING + else -> throw ImageKitInvalidDataException("Unknown Name: $value") + } - @JvmStatic fun ofThumbnail(thumbnail: Thumbnail) = Post(thumbnail = thumbnail) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } - @JvmStatic fun ofAbs(abs: Abs) = Post(abs = abs) - } + private var validated: Boolean = false - /** - * An interface that defines how to map each variant of [Post] to a value of type [T]. - */ - interface Visitor { + fun validate(): Name = apply { + if (validated) { + return@apply + } - fun visitTransformation(transformation: InnerTransformation): T + known() + validated = true + } - fun visitGifToVideo(gifToVideo: GifToVideo): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - fun visitThumbnail(thumbnail: Thumbnail): T + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun visitAbs(abs: Abs): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Maps an unknown variant of [Post] to a value of type [T]. - * - * An instance of [Post] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Post: $json") - } - } + return other is Name && value == other.value + } - internal class Deserializer : BaseDeserializer(Post::class) { + override fun hashCode() = value.hashCode() - override fun ObjectCodec.deserialize(node: JsonNode): Post { - val json = JsonValue.fromJsonNode(node) - val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + override fun toString() = value.toString() + } - when (type) { - "transformation" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Post(transformation = it, _json = json) } - ?: Post(_json = json) - } - "gif-to-video" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(gifToVideo = it, _json = json) - } ?: Post(_json = json) - } - "thumbnail" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(thumbnail = it, _json = json) - } ?: Post(_json = json) - } - "abs" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(abs = it, _json = json) - } ?: Post(_json = json) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is AutoTaggingExtension && + maxTags == other.maxTags && + minConfidence == other.minConfidence && + name == other.name && + additionalProperties == other.additionalProperties } - return Post(_json = json) - } - } + private val hashCode: Int by lazy { + Objects.hash(maxTags, minConfidence, name, additionalProperties) + } - internal class Serializer : BaseSerializer(Post::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Post, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.transformation != null -> generator.writeObject(value.transformation) - value.gifToVideo != null -> generator.writeObject(value.gifToVideo) - value.thumbnail != null -> generator.writeObject(value.thumbnail) - value.abs != null -> generator.writeObject(value.abs) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Post") - } + override fun toString() = + "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" } } - class InnerTransformation - private constructor( - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Transformation type. - * - * Expected to always return the following: - * ```java - * JsonValue.from("transformation") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based - * 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 value(): String = value.value.getRequired("value") + class ResponseField + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * Returns the raw multipart value of [value]. + * Returns this class instance's raw value. * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmField val TAGS = of("tags") - fun toBuilder() = Builder().from(this) + @JvmField val CUSTOM_COORDINATES = of("customCoordinates") - companion object { + @JvmField val IS_PRIVATE_FILE = of("isPrivateFile") - /** - * Returns a mutable builder for constructing an instance of - * [InnerTransformation]. - * - * The following fields are required: - * ```java - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + @JvmField val EMBEDDED_METADATA = of("embeddedMetadata") - /** A builder for [InnerTransformation]. */ - class Builder internal constructor() { + @JvmField val IS_PUBLISHED = of("isPublished") - private var type: JsonValue = JsonValue.from("transformation") - private var value: MultipartField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val CUSTOM_METADATA = of("customMetadata") - @JvmSynthetic - internal fun from(innerTransformation: InnerTransformation) = apply { - type = innerTransformation.type - value = innerTransformation.value - additionalProperties = - innerTransformation.additionalProperties.toMutableMap() - } + @JvmField val METADATA = of("metadata") - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```java - * JsonValue.from("transformation") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } + @JvmStatic fun of(value: String) = ResponseField(JsonField.of(value)) + } - /** - * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based - * transformations. - */ - fun value(value: String) = value(MultipartField.of(value)) + /** An enum containing [ResponseField]'s known values. */ + enum class Known { + TAGS, + CUSTOM_COORDINATES, + IS_PRIVATE_FILE, + EMBEDDED_METADATA, + IS_PUBLISHED, + CUSTOM_METADATA, + METADATA, + } + /** + * An enum containing [ResponseField]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ResponseField] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TAGS, + CUSTOM_COORDINATES, + IS_PRIVATE_FILE, + EMBEDDED_METADATA, + IS_PUBLISHED, + CUSTOM_METADATA, + METADATA, /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * An enum member indicating that [ResponseField] was instantiated with an + * unknown value. */ - fun value(value: MultipartField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + _UNKNOWN, + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TAGS -> Value.TAGS + CUSTOM_COORDINATES -> Value.CUSTOM_COORDINATES + IS_PRIVATE_FILE -> Value.IS_PRIVATE_FILE + EMBEDDED_METADATA -> Value.EMBEDDED_METADATA + IS_PUBLISHED -> Value.IS_PUBLISHED + CUSTOM_METADATA -> Value.CUSTOM_METADATA + METADATA -> Value.METADATA + else -> Value._UNKNOWN } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + TAGS -> Known.TAGS + CUSTOM_COORDINATES -> Known.CUSTOM_COORDINATES + IS_PRIVATE_FILE -> Known.IS_PRIVATE_FILE + EMBEDDED_METADATA -> Known.EMBEDDED_METADATA + IS_PUBLISHED -> Known.IS_PUBLISHED + CUSTOM_METADATA -> Known.CUSTOM_METADATA + METADATA -> Known.METADATA + else -> throw ImageKitInvalidDataException("Unknown ResponseField: $value") } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") } - /** - * Returns an immutable instance of [InnerTransformation]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): InnerTransformation = - InnerTransformation( - type, - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - private var validated: Boolean = false - fun validate(): InnerTransformation = apply { + fun validate(): ResponseField = apply { if (validated) { return@apply } - _type().let { - if (it != JsonValue.from("transformation")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } - value() + known() validated = true } @@ -4323,62 +6942,79 @@ private constructor( false } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is InnerTransformation && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(type, value, additionalProperties) + return other is ResponseField && value == other.value } - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "InnerTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - class GifToVideo + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for + * reducing file size or applying basic optimizations upfront (e.g., resize, + * compress). + * - `post` — applied immediately after upload. Ideal for generating transformed + * versions (like video encodes or thumbnails) in advance, so they're ready for + * delivery without delay. + * + * You can mix and match any combination of post-processing types. + */ + class Transformation private constructor( - private val type: JsonValue, - private val value: MultipartField, + private val post: MultipartField>, + private val pre: MultipartField, private val additionalProperties: MutableMap, ) { /** - * Converts an animated GIF into an MP4. - * - * Expected to always return the following: - * ```java - * JsonValue.from("gif-to-video") - * ``` + * List of transformations to apply _after_ the file is uploaded. Each item must + * match one of the following types: `transformation`, `gif-to-video`, `thumbnail`, + * `abs`. * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + fun post(): Optional> = post.value.getOptional("post") /** - * Optional transformation string to apply to the output video. **Example**: `q-80` + * Transformation string to apply before uploading the file to the Media Library. + * Useful for optimizing files at ingestion. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun value(): Optional = value.value.getOptional("value") + fun pre(): Optional = pre.value.getOptional("pre") + + /** + * Returns the raw multipart value of [post]. + * + * Unlike [post], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("post") @ExcludeMissing fun _post(): MultipartField> = post /** - * Returns the raw multipart value of [value]. + * Returns the raw multipart value of [pre]. * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. + * Unlike [pre], this method doesn't throw if the multipart field has an unexpected + * type. */ - @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value + @JsonProperty("pre") @ExcludeMissing fun _pre(): MultipartField = pre @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -4394,52 +7030,95 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [GifToVideo]. */ + /** + * Returns a mutable builder for constructing an instance of [Transformation]. + */ @JvmStatic fun builder() = Builder() } - /** A builder for [GifToVideo]. */ + /** A builder for [Transformation]. */ class Builder internal constructor() { - private var type: JsonValue = JsonValue.from("gif-to-video") - private var value: MultipartField = MultipartField.of(null) + private var post: MultipartField>? = null + private var pre: MultipartField = MultipartField.of(null) private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(gifToVideo: GifToVideo) = apply { - type = gifToVideo.type - value = gifToVideo.value - additionalProperties = gifToVideo.additionalProperties.toMutableMap() + internal fun from(transformation: Transformation) = apply { + post = transformation.post.map { it.toMutableList() } + pre = transformation.pre + additionalProperties = transformation.additionalProperties.toMutableMap() } /** - * Sets the field to an arbitrary JSON value. + * List of transformations to apply _after_ the file is uploaded. Each item must + * match one of the following types: `transformation`, `gif-to-video`, + * `thumbnail`, `abs`. + */ + fun post(post: List) = post(MultipartField.of(post)) + + /** + * Sets [Builder.post] to an arbitrary multipart value. + * + * You should usually call [Builder.post] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun post(post: MultipartField>) = apply { + this.post = post.map { it.toMutableList() } + } + + /** + * Adds a single [Post] to [Builder.post]. * - * It is usually unnecessary to call this method because the field defaults to - * the following: + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPost(post: Post) = apply { + this.post = + (this.post ?: MultipartField.of(mutableListOf())).also { + checkKnown("post", it).add(post) + } + } + + /** Alias for calling [addPost] with `Post.ofTransformation(transformation)`. */ + fun addPost(transformation: Post.InnerTransformation) = + addPost(Post.ofTransformation(transformation)) + + /** + * Alias for calling [addPost] with the following: * ```java - * JsonValue.from("gif-to-video") + * Post.InnerTransformation.builder() + * .value(value) + * .build() * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. */ - fun type(type: JsonValue) = apply { this.type = type } + fun addTransformationPost(value: String) = + addPost(Post.InnerTransformation.builder().value(value).build()) + + /** Alias for calling [addPost] with `Post.ofGifToVideo(gifToVideo)`. */ + fun addPost(gifToVideo: Post.GifToVideo) = + addPost(Post.ofGifToVideo(gifToVideo)) + + /** Alias for calling [addPost] with `Post.ofThumbnail(thumbnail)`. */ + fun addPost(thumbnail: Post.Thumbnail) = addPost(Post.ofThumbnail(thumbnail)) + + /** Alias for calling [addPost] with `Post.ofAbs(abs)`. */ + fun addPost(abs: Post.Abs) = addPost(Post.ofAbs(abs)) /** - * Optional transformation string to apply to the output video. **Example**: - * `q-80` + * Transformation string to apply before uploading the file to the Media + * Library. Useful for optimizing files at ingestion. */ - fun value(value: String) = value(MultipartField.of(value)) + fun pre(pre: String) = pre(MultipartField.of(pre)) /** - * Sets [Builder.value] to an arbitrary multipart value. + * Sets [Builder.pre] to an arbitrary multipart value. * - * You should usually call [Builder.value] with a well-typed [String] value + * You should usually call [Builder.pre] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun value(value: MultipartField) = apply { this.value = value } + fun pre(pre: MultipartField) = apply { this.pre = pre } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4464,27 +7143,27 @@ private constructor( } /** - * Returns an immutable instance of [GifToVideo]. + * Returns an immutable instance of [Transformation]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): GifToVideo = - GifToVideo(type, value, additionalProperties.toMutableMap()) + fun build(): Transformation = + Transformation( + (post ?: MultipartField.of(null)).map { it.toImmutable() }, + pre, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): GifToVideo = apply { + fun validate(): Transformation = apply { if (validated) { return@apply } - _type().let { - if (it != JsonValue.from("gif-to-video")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } - value() + post().ifPresent { it.forEach { it.validate() } } + pre() validated = true } @@ -4496,542 +7175,1188 @@ private constructor( false } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonDeserialize(using = Post.Deserializer::class) + @JsonSerialize(using = Post.Serializer::class) + class Post + private constructor( + private val transformation: InnerTransformation? = null, + private val gifToVideo: GifToVideo? = null, + private val thumbnail: Thumbnail? = null, + private val abs: Abs? = null, + private val _json: JsonValue? = null, + ) { - return other is GifToVideo && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } + fun transformation(): Optional = + Optional.ofNullable(transformation) - private val hashCode: Int by lazy { - Objects.hash(type, value, additionalProperties) - } + fun gifToVideo(): Optional = Optional.ofNullable(gifToVideo) - override fun hashCode(): Int = hashCode + fun thumbnail(): Optional = Optional.ofNullable(thumbnail) - override fun toString() = - "GifToVideo{type=$type, value=$value, additionalProperties=$additionalProperties}" - } + fun abs(): Optional = Optional.ofNullable(abs) - class Thumbnail - private constructor( - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { + fun isTransformation(): Boolean = transformation != null - /** - * Generates a thumbnail image. - * - * Expected to always return the following: - * ```java - * JsonValue.from("thumbnail") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + fun isGifToVideo(): Boolean = gifToVideo != null - /** - * Optional transformation string. **Example**: `w-150,h-150` - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun value(): Optional = value.value.getOptional("value") + fun isThumbnail(): Boolean = thumbnail != null - /** - * Returns the raw multipart value of [value]. - * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value + fun isAbs(): Boolean = abs != null - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun asTransformation(): InnerTransformation = + transformation.getOrThrow("transformation") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun asGifToVideo(): GifToVideo = gifToVideo.getOrThrow("gifToVideo") - fun toBuilder() = Builder().from(this) + fun asThumbnail(): Thumbnail = thumbnail.getOrThrow("thumbnail") - companion object { + fun asAbs(): Abs = abs.getOrThrow("abs") - /** Returns a mutable builder for constructing an instance of [Thumbnail]. */ - @JvmStatic fun builder() = Builder() - } + fun _json(): Optional = Optional.ofNullable(_json) - /** A builder for [Thumbnail]. */ - class Builder internal constructor() { + fun accept(visitor: Visitor): T = + when { + transformation != null -> visitor.visitTransformation(transformation) + gifToVideo != null -> visitor.visitGifToVideo(gifToVideo) + thumbnail != null -> visitor.visitThumbnail(thumbnail) + abs != null -> visitor.visitAbs(abs) + else -> visitor.unknown(_json) + } - private var type: JsonValue = JsonValue.from("thumbnail") - private var value: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = mutableMapOf() + private var validated: Boolean = false - @JvmSynthetic - internal fun from(thumbnail: Thumbnail) = apply { - type = thumbnail.type - value = thumbnail.value - additionalProperties = thumbnail.additionalProperties.toMutableMap() + fun validate(): Post = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTransformation( + transformation: InnerTransformation + ) { + transformation.validate() + } + + override fun visitGifToVideo(gifToVideo: GifToVideo) { + gifToVideo.validate() + } + + override fun visitThumbnail(thumbnail: Thumbnail) { + thumbnail.validate() + } + + override fun visitAbs(abs: Abs) { + abs.validate() + } + } + ) + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```java - * JsonValue.from("thumbnail") - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Used for best match union deserialization. */ - fun type(type: JsonValue) = apply { this.type = type } + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitTransformation( + transformation: InnerTransformation + ) = transformation.validity() + + override fun visitGifToVideo(gifToVideo: GifToVideo) = + gifToVideo.validity() + + override fun visitThumbnail(thumbnail: Thumbnail) = + thumbnail.validity() + + override fun visitAbs(abs: Abs) = abs.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Post && + transformation == other.transformation && + gifToVideo == other.gifToVideo && + thumbnail == other.thumbnail && + abs == other.abs + } - /** Optional transformation string. **Example**: `w-150,h-150` */ - fun value(value: String) = value(MultipartField.of(value)) + override fun hashCode(): Int = + Objects.hash(transformation, gifToVideo, thumbnail, abs) + + override fun toString(): String = + when { + transformation != null -> "Post{transformation=$transformation}" + gifToVideo != null -> "Post{gifToVideo=$gifToVideo}" + thumbnail != null -> "Post{thumbnail=$thumbnail}" + abs != null -> "Post{abs=$abs}" + _json != null -> "Post{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Post") + } + + companion object { + + @JvmStatic + fun ofTransformation(transformation: InnerTransformation) = + Post(transformation = transformation) + + @JvmStatic + fun ofGifToVideo(gifToVideo: GifToVideo) = Post(gifToVideo = gifToVideo) + + @JvmStatic + fun ofThumbnail(thumbnail: Thumbnail) = Post(thumbnail = thumbnail) + + @JvmStatic fun ofAbs(abs: Abs) = Post(abs = abs) + } /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * An interface that defines how to map each variant of [Post] to a value of + * type [T]. */ - fun value(value: MultipartField) = apply { this.value = value } + interface Visitor { - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun visitTransformation(transformation: InnerTransformation): T - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + fun visitGifToVideo(gifToVideo: GifToVideo): T + + fun visitThumbnail(thumbnail: Thumbnail): T + + fun visitAbs(abs: Abs): T + + /** + * Maps an unknown variant of [Post] to a value of type [T]. + * + * An instance of [Post] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the API may respond + * with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Post: $json") + } } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + internal class Deserializer : BaseDeserializer(Post::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Post { + val json = JsonValue.fromJsonNode(node) + val type = + json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "transformation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Post(transformation = it, _json = json) } + ?: Post(_json = json) + } + "gif-to-video" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(gifToVideo = it, _json = json) + } ?: Post(_json = json) + } + "thumbnail" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(thumbnail = it, _json = json) + } ?: Post(_json = json) + } + "abs" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(abs = it, _json = json) + } ?: Post(_json = json) + } + } + + return Post(_json = json) } + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + internal class Serializer : BaseSerializer(Post::class) { + + override fun serialize( + value: Post, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.transformation != null -> + generator.writeObject(value.transformation) + value.gifToVideo != null -> generator.writeObject(value.gifToVideo) + value.thumbnail != null -> generator.writeObject(value.thumbnail) + value.abs != null -> generator.writeObject(value.abs) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Post") + } + } } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + class InnerTransformation + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Transformation type. + * + * Expected to always return the following: + * ```java + * JsonValue.from("transformation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit + * URL-based 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 value(): String = value.value.getRequired("value") + + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): MultipartField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InnerTransformation]. + * + * The following fields are required: + * ```java + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InnerTransformation]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("transformation") + private var value: MultipartField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(innerTransformation: InnerTransformation) = apply { + type = innerTransformation.type + value = innerTransformation.value + additionalProperties = + innerTransformation.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("transformation") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit + * URL-based transformations. + */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InnerTransformation]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InnerTransformation = + InnerTransformation( + type, + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InnerTransformation = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("transformation")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InnerTransformation && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InnerTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" } - /** - * Returns an immutable instance of [Thumbnail]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Thumbnail = - Thumbnail(type, value, additionalProperties.toMutableMap()) - } + class GifToVideo + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { - private var validated: Boolean = false + /** + * Converts an animated GIF into an MP4. + * + * Expected to always return the following: + * ```java + * JsonValue.from("gif-to-video") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - fun validate(): Thumbnail = apply { - if (validated) { - return@apply + /** + * Optional transformation string to apply to the output video. **Example**: + * `q-80` + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.value.getOptional("value") + + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): MultipartField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GifToVideo]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GifToVideo]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("gif-to-video") + private var value: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(gifToVideo: GifToVideo) = apply { + type = gifToVideo.type + value = gifToVideo.value + additionalProperties = + gifToVideo.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("gif-to-video") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Optional transformation string to apply to the output video. + * **Example**: `q-80` + */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GifToVideo]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): GifToVideo = + GifToVideo(type, value, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): GifToVideo = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("gif-to-video")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GifToVideo && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GifToVideo{type=$type, value=$value, additionalProperties=$additionalProperties}" } - _type().let { - if (it != JsonValue.from("thumbnail")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") + class Thumbnail + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Generates a thumbnail image. + * + * Expected to always return the following: + * ```java + * JsonValue.from("thumbnail") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Optional transformation string. **Example**: `w-150,h-150` + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.value.getOptional("value") + + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): MultipartField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - } - value() - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun toBuilder() = Builder().from(this) - return other is Thumbnail && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } + companion object { - private val hashCode: Int by lazy { - Objects.hash(type, value, additionalProperties) - } + /** + * Returns a mutable builder for constructing an instance of + * [Thumbnail]. + */ + @JvmStatic fun builder() = Builder() + } - override fun hashCode(): Int = hashCode + /** A builder for [Thumbnail]. */ + class Builder internal constructor() { - override fun toString() = - "Thumbnail{type=$type, value=$value, additionalProperties=$additionalProperties}" - } + private var type: JsonValue = JsonValue.from("thumbnail") + private var value: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = + mutableMapOf() - class Abs - private constructor( - private val protocol: MultipartField, - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { + @JvmSynthetic + internal fun from(thumbnail: Thumbnail) = apply { + type = thumbnail.type + value = thumbnail.value + additionalProperties = thumbnail.additionalProperties.toMutableMap() + } - /** - * Streaming protocol to use (`hls` or `dash`). - * - * @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 protocol(): Protocol = protocol.value.getRequired("protocol") + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("thumbnail") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Optional transformation string. **Example**: `w-150,h-150` */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Adaptive Bitrate Streaming (ABS) setup. - * - * Expected to always return the following: - * ```java - * JsonValue.from("abs") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * List of different representations you want to create separated by an underscore. - * - * @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 value(): String = value.value.getRequired("value") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns the raw multipart value of [protocol]. - * - * Unlike [protocol], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("protocol") - @ExcludeMissing - fun _protocol(): MultipartField = protocol + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw multipart value of [value]. - * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value + /** + * Returns an immutable instance of [Thumbnail]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): Thumbnail = + Thumbnail(type, value, additionalProperties.toMutableMap()) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + private var validated: Boolean = false - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun validate(): Thumbnail = apply { + if (validated) { + return@apply + } - fun toBuilder() = Builder().from(this) + _type().let { + if (it != JsonValue.from("thumbnail")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + value() + validated = true + } - companion object { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - /** - * Returns a mutable builder for constructing an instance of [Abs]. - * - * The following fields are required: - * ```java - * .protocol() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** A builder for [Abs]. */ - class Builder internal constructor() { + return other is Thumbnail && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } - private var protocol: MultipartField? = null - private var type: JsonValue = JsonValue.from("abs") - private var value: MultipartField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } - @JvmSynthetic - internal fun from(abs: Abs) = apply { - protocol = abs.protocol - type = abs.type - value = abs.value - additionalProperties = abs.additionalProperties.toMutableMap() + override fun hashCode(): Int = hashCode + + override fun toString() = + "Thumbnail{type=$type, value=$value, additionalProperties=$additionalProperties}" } - /** Streaming protocol to use (`hls` or `dash`). */ - fun protocol(protocol: Protocol) = protocol(MultipartField.of(protocol)) + class Abs + private constructor( + private val protocol: MultipartField, + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { - /** - * Sets [Builder.protocol] to an arbitrary multipart value. - * - * You should usually call [Builder.protocol] with a well-typed [Protocol] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun protocol(protocol: MultipartField) = apply { - this.protocol = protocol - } + /** + * Streaming protocol to use (`hls` or `dash`). + * + * @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 protocol(): Protocol = protocol.value.getRequired("protocol") - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```java - * JsonValue.from("abs") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } + /** + * Adaptive Bitrate Streaming (ABS) setup. + * + * Expected to always return the following: + * ```java + * JsonValue.from("abs") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * List of different representations you want to create separated by an - * underscore. - */ - fun value(value: String) = value(MultipartField.of(value)) + /** + * List of different representations you want to create separated by an + * underscore. + * + * @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 value(): String = value.value.getRequired("value") - /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun value(value: MultipartField) = apply { this.value = value } + /** + * Returns the raw multipart value of [protocol]. + * + * Unlike [protocol], this method doesn't throw if the multipart field has + * an unexpected type. + */ + @JsonProperty("protocol") + @ExcludeMissing + fun _protocol(): MultipartField = protocol - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): MultipartField = value - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Abs]. + * + * The following fields are required: + * ```java + * .protocol() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** A builder for [Abs]. */ + class Builder internal constructor() { + + private var protocol: MultipartField? = null + private var type: JsonValue = JsonValue.from("abs") + private var value: MultipartField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(abs: Abs) = apply { + protocol = abs.protocol + type = abs.type + value = abs.value + additionalProperties = abs.additionalProperties.toMutableMap() + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** Streaming protocol to use (`hls` or `dash`). */ + fun protocol(protocol: Protocol) = protocol(MultipartField.of(protocol)) + + /** + * Sets [Builder.protocol] to an arbitrary multipart value. + * + * You should usually call [Builder.protocol] with a well-typed + * [Protocol] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun protocol(protocol: MultipartField) = apply { + this.protocol = protocol + } - /** - * Returns an immutable instance of [Abs]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .protocol() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Abs = - Abs( - checkRequired("protocol", protocol), - type, - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("abs") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * List of different representations you want to create separated by an + * underscore. + */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - private var validated: Boolean = false + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun validate(): Abs = apply { - if (validated) { - return@apply - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - protocol().validate() - _type().let { - if (it != JsonValue.from("abs")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Abs]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .protocol() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Abs = + Abs( + checkRequired("protocol", protocol), + type, + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) } - } - value() - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + private var validated: Boolean = false - /** Streaming protocol to use (`hls` or `dash`). */ - class Protocol - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun validate(): Abs = apply { + if (validated) { + return@apply + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + protocol().validate() + _type().let { + if (it != JsonValue.from("abs")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + value() + validated = true + } - companion object { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - @JvmField val HLS = of("hls") + /** Streaming protocol to use (`hls` or `dash`). */ + class Protocol + @JsonCreator + private constructor(private val value: JsonField) : Enum { - @JvmField val DASH = of("dash") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from + * data that doesn't match any known member, and you want to know that + * value. For example, if the SDK is on an older version than the API, + * then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - @JvmStatic fun of(value: String) = Protocol(JsonField.of(value)) - } + companion object { - /** An enum containing [Protocol]'s known values. */ - enum class Known { - HLS, - DASH, - } + @JvmField val HLS = of("hls") - /** - * An enum containing [Protocol]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Protocol] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - HLS, - DASH, - /** - * An enum member indicating that [Protocol] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + @JvmField val DASH = of("dash") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - HLS -> Value.HLS - DASH -> Value.DASH - else -> Value._UNKNOWN - } + @JvmStatic fun of(value: String) = Protocol(JsonField.of(value)) + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - HLS -> Known.HLS - DASH -> Known.DASH - else -> throw ImageKitInvalidDataException("Unknown Protocol: $value") - } + /** An enum containing [Protocol]'s known values. */ + enum class Known { + HLS, + DASH, + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") - } + /** + * An enum containing [Protocol]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [Protocol] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HLS, + DASH, + /** + * An enum member indicating that [Protocol] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } - private var validated: Boolean = false + /** + * Returns an enum member corresponding to this class instance's value, + * or [Value._UNKNOWN] if the class was instantiated with an unknown + * value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HLS -> Value.HLS + DASH -> Value.DASH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + HLS -> Known.HLS + DASH -> Known.DASH + else -> + throw ImageKitInvalidDataException( + "Unknown Protocol: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Protocol = apply { + if (validated) { + return@apply + } + + known() + validated = true + } - fun validate(): Protocol = apply { - if (validated) { - return@apply - } + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Protocol && value == other.value + } - known() - validated = true - } + override fun hashCode() = value.hashCode() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false + override fun toString() = value.toString() } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + return other is Abs && + protocol == other.protocol && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties } - return other is Protocol && value == other.value - } + private val hashCode: Int by lazy { + Objects.hash(protocol, type, value, additionalProperties) + } - override fun hashCode() = value.hashCode() + override fun hashCode(): Int = hashCode - override fun toString() = value.toString() + override fun toString() = + "Abs{protocol=$protocol, type=$type, value=$value, additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { @@ -5039,41 +8364,86 @@ private constructor( return true } - return other is Abs && - protocol == other.protocol && - type == other.type && - value == other.value && + return other is Transformation && + post == other.post && + pre == other.pre && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(protocol, type, value, additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(post, pre, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Abs{protocol=$protocol, type=$type, value=$value, additionalProperties=$additionalProperties}" + "Transformation{post=$post, pre=$pre, additionalProperties=$additionalProperties}" } - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - return other is Transformation && - post == other.post && - pre == other.pre && - additionalProperties == other.additionalProperties - } + return other is FileUploadV1ByUrl && + file == other.file && + fileName == other.fileName && + token == other.token && + checks == other.checks && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + description == other.description && + expire == other.expire && + extensions == other.extensions && + folder == other.folder && + isPrivateFile == other.isPrivateFile && + isPublished == other.isPublished && + overwriteAiTags == other.overwriteAiTags && + overwriteCustomMetadata == other.overwriteCustomMetadata && + overwriteFile == other.overwriteFile && + overwriteTags == other.overwriteTags && + publicKey == other.publicKey && + responseFields == other.responseFields && + signature == other.signature && + tags == other.tags && + transformation == other.transformation && + useUniqueFileName == other.useUniqueFileName && + webhookUrl == other.webhookUrl && + additionalProperties == other.additionalProperties + } - private val hashCode: Int by lazy { Objects.hash(post, pre, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + file, + fileName, + token, + checks, + customCoordinates, + customMetadata, + description, + expire, + extensions, + folder, + isPrivateFile, + isPublished, + overwriteAiTags, + overwriteCustomMetadata, + overwriteFile, + overwriteTags, + publicKey, + responseFields, + signature, + tags, + transformation, + useUniqueFileName, + webhookUrl, + additionalProperties, + ) + } - override fun hashCode(): Int = hashCode + override fun hashCode(): Int = hashCode - override fun toString() = - "Transformation{post=$post, pre=$pre, additionalProperties=$additionalProperties}" + override fun toString() = + "FileUploadV1ByUrl{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, expire=$expire, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, publicKey=$publicKey, responseFields=$responseFields, signature=$signature, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt index f5db6fe3..addd9d29 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt @@ -220,15 +220,23 @@ interface FileServiceAsync { * file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. * - [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies. */ - fun upload(params: FileUploadParams): CompletableFuture = - upload(params, RequestOptions.none()) + fun upload(): CompletableFuture = upload(FileUploadParams.none()) /** @see upload */ fun upload( - params: FileUploadParams, + params: FileUploadParams = FileUploadParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see upload */ + fun upload( + params: FileUploadParams = FileUploadParams.none() + ): CompletableFuture = upload(params, RequestOptions.none()) + + /** @see upload */ + fun upload(requestOptions: RequestOptions): CompletableFuture = + upload(FileUploadParams.none(), requestOptions) + /** A view of [FileServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -406,15 +414,25 @@ interface FileServiceAsync { * Returns a raw HTTP response for `post /api/v1/files/upload`, but is otherwise the same as * [FileServiceAsync.upload]. */ + fun upload(): CompletableFuture> = + upload(FileUploadParams.none()) + + /** @see upload */ fun upload( - params: FileUploadParams + params: FileUploadParams = FileUploadParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see upload */ + fun upload( + params: FileUploadParams = FileUploadParams.none() ): CompletableFuture> = upload(params, RequestOptions.none()) /** @see upload */ fun upload( - params: FileUploadParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + requestOptions: RequestOptions + ): CompletableFuture> = + upload(FileUploadParams.none(), requestOptions) } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt index bafc4724..5743ebbd 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt @@ -346,7 +346,11 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien else "https://upload.imagekit.io" ) .addPathSegments("api", "v1", "files", "upload") - .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .apply { + params._body().ifPresent { + body(multipartFormData(clientOptions.jsonMapper, it)) + } + } .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt index 8f4e8f80..51e5acf6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt @@ -202,14 +202,22 @@ interface FileService { * file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. * - [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies. */ - fun upload(params: FileUploadParams): FileUploadResponse = upload(params, RequestOptions.none()) + fun upload(): FileUploadResponse = upload(FileUploadParams.none()) /** @see upload */ fun upload( - params: FileUploadParams, + params: FileUploadParams = FileUploadParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): FileUploadResponse + /** @see upload */ + fun upload(params: FileUploadParams = FileUploadParams.none()): FileUploadResponse = + upload(params, RequestOptions.none()) + + /** @see upload */ + fun upload(requestOptions: RequestOptions): FileUploadResponse = + upload(FileUploadParams.none(), requestOptions) + /** A view of [FileService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -396,14 +404,24 @@ interface FileService { * [FileService.upload]. */ @MustBeClosed - fun upload(params: FileUploadParams): HttpResponseFor = - upload(params, RequestOptions.none()) + fun upload(): HttpResponseFor = upload(FileUploadParams.none()) /** @see upload */ @MustBeClosed fun upload( - params: FileUploadParams, + params: FileUploadParams = FileUploadParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see upload */ + @MustBeClosed + fun upload( + params: FileUploadParams = FileUploadParams.none() + ): HttpResponseFor = upload(params, RequestOptions.none()) + + /** @see upload */ + @MustBeClosed + fun upload(requestOptions: RequestOptions): HttpResponseFor = + upload(FileUploadParams.none(), requestOptions) } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt index 6448f2b3..85fd05b1 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt @@ -315,7 +315,11 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti else "https://upload.imagekit.io" ) .addPathSegments("api", "v1", "files", "upload") - .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .apply { + params._body().ifPresent { + body(multipartFormData(clientOptions.jsonMapper, it)) + } + } .build() .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt index 11752909..7957b53f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt @@ -5,6 +5,7 @@ package com.imagekit.api.models.files import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField import java.io.InputStream +import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,81 +14,95 @@ internal class FileUploadParamsTest { @Test fun create() { FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg.builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension.AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post.Thumbnail + .builder() + .value("w-150,h-150") .build() ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") - .build() - ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() } @@ -95,84 +110,101 @@ internal class FileUploadParamsTest { fun body() { val params = FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg.builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post.Thumbnail + .builder() + .value("w-150,h-150") .build() ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .pre("w-300,h-300,q-80") .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) - .value("sr-240_360_480_720_1080") - .build() - ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() - val body = params._body() + val body = params._body().getOrNull() assertThat(body.filterValues { !it.value.isNull() }) .usingRecursiveComparison() @@ -184,89 +216,135 @@ internal class FileUploadParamsTest { ) .isEqualTo( mapOf( - "file" to MultipartField.of("some content".byteInputStream()), - "fileName" to MultipartField.of("fileName"), - "token" to MultipartField.of("token"), - "checks" to MultipartField.of("\"request.folder\" : \"marketing/\"\n"), - "customCoordinates" to MultipartField.of("customCoordinates"), - "customMetadata" to - MultipartField.of( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ), - "description" to MultipartField.of("Running shoes"), - "expire" to MultipartField.of(0L), - "extensions" to - MultipartField.of( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options + "body" to + MultipartField.builder() + .value( + FileUploadParams.Body.ofFileUploadV1( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .putAdditionalProperty( + "brand", + JsonValue.from("bar"), + ) + .putAdditionalProperty( + "color", + JsonValue.from("bar"), + ) .build() ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension + .ofRemoveBg( + FileUploadParams.Body.FileUploadV1 + .Extension + .RemoveBg + .builder() + .options( + FileUploadParams.Body + .FileUploadV1 + .Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAutoTagging( + FileUploadParams.Body.FileUploadV1 + .Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body + .FileUploadV1 + .Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ), - "folder" to MultipartField.of("folder"), - "isPrivateFile" to MultipartField.of(true), - "isPublished" to MultipartField.of(true), - "overwriteAITags" to MultipartField.of(true), - "overwriteCustomMetadata" to MultipartField.of(true), - "overwriteFile" to MultipartField.of(true), - "overwriteTags" to MultipartField.of(true), - "publicKey" to MultipartField.of("publicKey"), - "responseFields" to - MultipartField.of( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ), - "signature" to MultipartField.of("signature"), - "tags" to MultipartField.of(listOf("t-shirt", "round-neck", "men")), - "transformation" to - MultipartField.of( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") - .build() - ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol - .DASH + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField + .TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation + .builder() + .addPost( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .value("sr-240_360_480_720_1080") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .pre("w-300,h-300,q-80") - .build() - ), - "useUniqueFileName" to MultipartField.of(true), - "webhookUrl" to MultipartField.of("https://example.com"), + ) + .contentType("application/octet-stream") + .build() ) .mapValues { (_, field) -> field.map { (it as? ByteArray)?.inputStream() ?: it } @@ -276,30 +354,10 @@ internal class FileUploadParamsTest { @Test fun bodyWithoutOptionalFields() { - val params = - FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .build() + val params = FileUploadParams.builder().build() - val body = params._body() + val body = params._body().getOrNull() - assertThat(body.filterValues { !it.value.isNull() }) - .usingRecursiveComparison() - // TODO(AssertJ): Replace this and the `mapValues` below with: - // https://github.com/assertj/assertj/issues/3165 - .withEqualsForType( - { a, b -> a.readBytes() contentEquals b.readBytes() }, - InputStream::class.java, - ) - .isEqualTo( - mapOf( - "file" to MultipartField.of("some content".byteInputStream()), - "fileName" to MultipartField.of("fileName"), - ) - .mapValues { (_, field) -> - field.map { (it as? ByteArray)?.inputStream() ?: it } - } - ) + assertThat(body.filterValues { !it.value.isNull() }).isEmpty() } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt index 33349dd2..ff35db98 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt @@ -73,83 +73,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -173,83 +197,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() ) - .value("sr-240_360_480_720_1080") + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -273,83 +321,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -373,83 +445,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -473,83 +569,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -573,83 +693,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() ) - .value("sr-240_360_480_720_1080") + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -673,83 +817,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() ) - .value("sr-240_360_480_720_1080") + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -773,83 +941,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -873,83 +1065,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -973,83 +1189,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() ) - .value("sr-240_360_480_720_1080") + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -1073,83 +1313,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() ) - .value("sr-240_360_480_720_1080") + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -1173,83 +1437,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -1273,83 +1561,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() ) - .value("sr-240_360_480_720_1080") + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -1373,83 +1685,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -1473,83 +1809,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() ) - .value("sr-240_360_480_720_1080") + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -1573,83 +1933,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -1671,83 +2055,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt index f26281ec..6a14b916 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt @@ -4,7 +4,6 @@ package com.imagekit.api.services import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.equalTo -import com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath import com.github.tomakehurst.wiremock.client.WireMock.ok import com.github.tomakehurst.wiremock.client.WireMock.post import com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor @@ -45,84 +44,100 @@ internal class ServiceParamsTest { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg.builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post.Thumbnail + .builder() + .value("w-150,h-150") .build() ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") - .build() - ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .putAdditionalHeader("Secret-Header", "42") .putAdditionalQueryParam("secret_query_param", "42") - .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) .build() ) @@ -130,7 +145,6 @@ internal class ServiceParamsTest { postRequestedFor(anyUrl()) .withHeader("Secret-Header", equalTo("42")) .withQueryParam("secret_query_param", equalTo("42")) - .withRequestBody(matchingJsonPath("$.secretProperty", equalTo("42"))) ) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index 6e8d541b..3acc3a30 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -227,83 +227,104 @@ internal class FileServiceAsyncTest { val responseFuture = fileServiceAsync.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1.Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index 2e932b81..89de610f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -220,83 +220,104 @@ internal class FileServiceTest { val response = fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1.Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) From 83ce0707ff45a9daa97e12daa9ad050dcbab53f9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Sep 2025 09:12:33 +0000 Subject: [PATCH 011/142] feat(api): manual updates --- .stats.yml | 4 +- README.md | 93 +- .../api/models/files/FileUploadParams.kt | 11454 ++++++---------- .../api/services/async/FileServiceAsync.kt | 32 +- .../services/async/FileServiceAsyncImpl.kt | 6 +- .../api/services/blocking/FileService.kt | 28 +- .../api/services/blocking/FileServiceImpl.kt | 6 +- .../api/models/files/FileUploadParamsTest.kt | 530 +- .../api/services/ErrorHandlingTest.kt | 2788 ++-- .../api/services/ServiceParamsTest.kt | 156 +- .../services/async/FileServiceAsyncTest.kt | 161 +- .../api/services/blocking/FileServiceTest.kt | 161 +- 12 files changed, 5754 insertions(+), 9665 deletions(-) diff --git a/.stats.yml b/.stats.yml index d458a07c..cfcbd7f7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-e7bc47a9221d7da9c8c9653d3fd1d4cfdf2408588e32c4aa62bd02a50ec93c36.yml -openapi_spec_hash: 8d061396a2fff9d1add4d5baf03ab939 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml +openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c diff --git a/README.md b/README.md index d7b4537c..4e268347 100644 --- a/README.md +++ b/README.md @@ -50,12 +50,17 @@ import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); -FileUploadResponse response = client.files().upload(); +FileUploadParams params = FileUploadParams.builder() + .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") + .build(); +FileUploadResponse response = client.files().upload(params); ``` ## Client configuration @@ -150,13 +155,18 @@ import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); -CompletableFuture response = client.async().files().upload(); +FileUploadParams params = FileUploadParams.builder() + .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") + .build(); +CompletableFuture response = client.async().files().upload(params); ``` Or create an asynchronous client from the beginning: @@ -166,13 +176,18 @@ import com.imagekit.api.client.ImageKitClientAsync; import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv(); -CompletableFuture response = client.files().upload(); +FileUploadParams params = FileUploadParams.builder() + .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") + .build(); +CompletableFuture response = client.files().upload(params); ``` The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. @@ -184,50 +199,50 @@ The SDK defines methods that accept files. To upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html): ```java -import com.imagekit.api.models.beta.v2.files.FileUploadParams; -import com.imagekit.api.models.beta.v2.files.FileUploadResponse; +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; import java.nio.file.Paths; FileUploadParams params = FileUploadParams.builder() .fileName("fileName") .file(Paths.get("/path/to/file")) .build(); -FileUploadResponse response = client.beta().v2().files().upload(params); +FileUploadResponse response = client.files().upload(params); ``` Or an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html): ```java -import com.imagekit.api.models.beta.v2.files.FileUploadParams; -import com.imagekit.api.models.beta.v2.files.FileUploadResponse; +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; import java.net.URL; FileUploadParams params = FileUploadParams.builder() .fileName("fileName") .file(new URL("https://example.com//path/to/file").openStream()) .build(); -FileUploadResponse response = client.beta().v2().files().upload(params); +FileUploadResponse response = client.files().upload(params); ``` Or a `byte[]` array: ```java -import com.imagekit.api.models.beta.v2.files.FileUploadParams; -import com.imagekit.api.models.beta.v2.files.FileUploadResponse; +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; FileUploadParams params = FileUploadParams.builder() .fileName("fileName") .file("content".getBytes()) .build(); -FileUploadResponse response = client.beta().v2().files().upload(params); +FileUploadResponse response = client.files().upload(params); ``` Note that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt): ```java import com.imagekit.api.core.MultipartField; -import com.imagekit.api.models.beta.v2.files.FileUploadParams; -import com.imagekit.api.models.beta.v2.files.FileUploadResponse; +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; import java.io.InputStream; import java.net.URL; @@ -238,7 +253,7 @@ FileUploadParams params = FileUploadParams.builder() .filename("/path/to/file") .build()) .build(); -FileUploadResponse response = client.beta().v2().files().upload(params); +FileUploadResponse response = client.files().upload(params); ``` ## Raw responses @@ -252,8 +267,13 @@ import com.imagekit.api.core.http.Headers; import com.imagekit.api.core.http.HttpResponseFor; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; -HttpResponseFor response = client.files().withRawResponse().upload(); +FileUploadParams params = FileUploadParams.builder() + .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") + .build(); +HttpResponseFor response = client.files().withRawResponse().upload(params); int statusCode = response.statusCode(); Headers headers = response.headers(); @@ -362,7 +382,9 @@ To set a custom timeout, configure the method call using the `timeout` method: ```java import com.imagekit.api.models.files.FileUploadResponse; -FileUploadResponse response = client.files().upload(RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()); +FileUploadResponse response = client.files().upload( + params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build() +); ``` Or configure the default for all method calls at the client level: @@ -480,10 +502,10 @@ To set undocumented parameters on _nested_ headers, query params, or body classe ```java import com.imagekit.api.core.JsonValue; -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams; +import com.imagekit.api.models.files.FileUploadParams; -CustomMetadataFieldCreateParams params = CustomMetadataFieldCreateParams.builder() - .schema(CustomMetadataFieldCreateParams.Schema.builder() +FileUploadParams params = FileUploadParams.builder() + .transformation(FileUploadParams.Transformation.builder() .putAdditionalProperty("secretProperty", JsonValue.from("42")) .build()) .build(); @@ -494,9 +516,13 @@ These properties can be accessed on the nested built object later using the `_ad To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter: ```java +import com.imagekit.api.core.JsonValue; import com.imagekit.api.models.files.FileUploadParams; -FileUploadParams params = FileUploadParams.builder().build(); +FileUploadParams params = FileUploadParams.builder() + .file(JsonValue.from(42)) + .fileName("file-name.jpg") + .build(); ``` The most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method: @@ -544,15 +570,11 @@ To forcibly omit a required parameter or property, pass [`JsonMissing`](image-ki ```java import com.imagekit.api.core.JsonMissing; -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams; import com.imagekit.api.models.files.FileUploadParams; -FileUploadParams params = CustomMetadataFieldCreateParams.builder() - .name("price") - .schema(CustomMetadataFieldCreateParams.Schema.builder() - .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) - .build()) - .label(JsonMissing.of()) +FileUploadParams params = FileUploadParams.builder() + .fileName("fileName") + .file(JsonMissing.of()) .build(); ``` @@ -592,21 +614,22 @@ To access a property's raw JSON value, which may be undocumented, call its `_` p ```java import com.imagekit.api.core.JsonField; +import java.io.InputStream; import java.util.Optional; -JsonField field = client.files().upload(params)._field(); +JsonField file = client.files().upload(params)._file(); -if (field.isMissing()) { +if (file.isMissing()) { // The property is absent from the JSON response -} else if (field.isNull()) { +} else if (file.isNull()) { // The property was set to literal null } else { // Check if value was provided as a string // Other methods include `asNumber()`, `asBoolean()`, etc. - Optional jsonString = field.asString(); + Optional jsonString = file.asString(); // Try to deserialize into a custom type - MyClass myObject = field.asUnknown().orElseThrow().convert(MyClass.class); + MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class); } ``` @@ -629,7 +652,9 @@ Or configure the method call to validate the response using the `responseValidat ```java import com.imagekit.api.models.files.FileUploadResponse; -FileUploadResponse response = client.files().upload(RequestOptions.builder().responseValidation(true).build()); +FileUploadResponse response = client.files().upload( + params, RequestOptions.builder().responseValidation(true).build() +); ``` Or configure the default for all method calls at the client level: diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt index 6d4722f3..e50852f0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -21,7 +21,6 @@ import com.imagekit.api.core.JsonField import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField import com.imagekit.api.core.Params -import com.imagekit.api.core.allMaxBy import com.imagekit.api.core.checkKnown import com.imagekit.api.core.checkRequired import com.imagekit.api.core.getOrThrow @@ -62,4438 +61,1771 @@ import kotlin.jvm.optionals.getOrNull */ class FileUploadParams private constructor( - private val body: MultipartField, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + * + * @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 file(): InputStream = body.file() + + /** + * The name with which the file has to be uploaded. The file name can contain: + * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + * - Special Characters: `.`, `-` + * + * Any other character including space will be replaced by `_` + * + * @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 fileName(): String = body.fileName() + + /** + * A unique value that the ImageKit.io server will use to recognize and prevent subsequent + * retries for the same request. We suggest using V4 UUIDs, or another random string with enough + * entropy to avoid collisions. This field is only required for authentication when uploading a + * file from the client side. + * + * **Note**: Sending a value that has been used in the past will result in a validation error. + * Even if your previous request resulted in an error, you should always send a new value for + * this field. + * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun body(): Optional = body.value.getOptional("body") + fun token(): Optional = body.token() /** - * Returns the raw multipart value of [body]. + * Server-side checks to run on the asset. Read more about + * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). * - * Unlike [body], this method doesn't throw if the multipart field has an unexpected type. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("body") @ExcludeMissing fun _body(): MultipartField = body - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders + fun checks(): Optional = body.checks() - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * Define an important area in the image. This is only relevant for image type files. + * - To be passed as a string with the x and y coordinates of the top-left corner, and width and + * height of the area of interest in the format `x,y,width,height`. For example - + * `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates will be + * removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customCoordinates(): Optional = body.customCoordinates() - fun toBuilder() = Builder().from(this) + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields before + * setting these values. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customMetadata(): Optional = body.customMetadata() - companion object { + /** + * Optional text to describe the contents of the file. + * + * @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() - @JvmStatic fun none(): FileUploadParams = builder().build() + /** + * The time until your signature is valid. It must be a + * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. It + * should be in seconds. This field is only required for authentication when uploading a file + * from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expire(): Optional = body.expire() - /** Returns a mutable builder for constructing an instance of [FileUploadParams]. */ - @JvmStatic fun builder() = Builder() - } + /** + * Array of extensions to be applied to the image. Each extension can be configured with + * specific parameters based on the extension type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun extensions(): Optional> = body.extensions() - /** A builder for [FileUploadParams]. */ - class Builder internal constructor() { + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, + * a new folder(s) is created. + * + * The folder name can contain: + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun folder(): Optional = body.folder() - private var body: MultipartField = MultipartField.of(null) - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named transformation or + * signed URL. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isPrivateFile(): Optional = body.isPrivateFile() - @JvmSynthetic - internal fun from(fileUploadParams: FileUploadParams) = apply { - body = fileUploadParams.body - additionalHeaders = fileUploadParams.additionalHeaders.toBuilder() - additionalQueryParams = fileUploadParams.additionalQueryParams.toBuilder() - } + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file only via + * the media library. Files in draft or unpublished state can only be publicly accessed after + * being published. + * + * The option to upload in draft state is only available in custom enterprise pricing plans. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isPublished(): Optional = body.isPublished() - fun body(body: Body) = - body( - MultipartField.builder() - .value(body) - .contentType("application/octet-stream") - .build() - ) + /** + * If set to `true` and a file already exists at the exact location, its AITags will be removed. + * Set `overwriteAITags` to `false` to preserve AITags. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun overwriteAiTags(): Optional = body.overwriteAiTags() - /** - * Sets [Builder.body] to an arbitrary multipart value. - * - * You should usually call [Builder.body] with a well-typed [Body] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun body(body: MultipartField) = apply { this.body = body } + /** + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun overwriteCustomMetadata(): Optional = body.overwriteCustomMetadata() - /** Alias for calling [body] with `Body.ofFileUploadV1(fileUploadV1)`. */ - fun body(fileUploadV1: Body.FileUploadV1) = body(Body.ofFileUploadV1(fileUploadV1)) + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact + * location, upload API will return an error immediately. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun overwriteFile(): Optional = body.overwriteFile() - /** Alias for calling [body] with `Body.ofFileUploadV1ByUrl(fileUploadV1ByUrl)`. */ - fun body(fileUploadV1ByUrl: Body.FileUploadV1ByUrl) = - body(Body.ofFileUploadV1ByUrl(fileUploadV1ByUrl)) + /** + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun overwriteTags(): Optional = body.overwriteTags() - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + /** + * Your ImageKit.io public key. This field is only required for authentication when uploading a + * file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun publicKey(): Optional = body.publicKey() - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + /** + * Array of response field keys to include in the API response body. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun responseFields(): Optional> = body.responseFields() - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + /** + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. Learn + * how to create a signature on the page below. This should be in lowercase. + * + * Signature must be calculated on the server-side. This field is only required for + * authentication when uploading a file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun signature(): Optional = body.signature() - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", + * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the `%` + * character is not allowed. If this field is not specified and the file is overwritten, the + * existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tags(): Optional> = body.tags() - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing file + * size or applying basic optimizations upfront (e.g., resize, compress). + * - `post` — applied immediately after upload. Ideal for generating transformed versions (like + * video encodes or thumbnails) in advance, so they're ready for delivery without delay. + * + * You can mix and match any combination of post-processing types. + * + * @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() - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique + * filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any existing + * file with the same name is replaced. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun useUniqueFileName(): Optional = body.useUniqueFileName() - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + /** + * The final status of extensions after they have completed execution will be delivered to this + * endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookUrl(): Optional = body.webhookUrl() - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + /** + * Returns the raw multipart value of [file]. + * + * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _file(): MultipartField = body._file() - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + /** + * Returns the raw multipart value of [fileName]. + * + * Unlike [fileName], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _fileName(): MultipartField = body._fileName() - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + /** + * Returns the raw multipart value of [token]. + * + * Unlike [token], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _token(): MultipartField = body._token() - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + /** + * Returns the raw multipart value of [checks]. + * + * Unlike [checks], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _checks(): MultipartField = body._checks() - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + /** + * Returns the raw multipart value of [customCoordinates]. + * + * Unlike [customCoordinates], this method doesn't throw if the multipart field has an + * unexpected type. + */ + fun _customCoordinates(): MultipartField = body._customCoordinates() - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + /** + * Returns the raw multipart value of [customMetadata]. + * + * Unlike [customMetadata], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _customMetadata(): MultipartField = body._customMetadata() - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + /** + * Returns the raw multipart value of [description]. + * + * Unlike [description], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _description(): MultipartField = body._description() - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + /** + * Returns the raw multipart value of [expire]. + * + * Unlike [expire], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _expire(): MultipartField = body._expire() - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + /** + * Returns the raw multipart value of [extensions]. + * + * Unlike [extensions], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _extensions(): MultipartField> = body._extensions() - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + /** + * Returns the raw multipart value of [folder]. + * + * Unlike [folder], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _folder(): MultipartField = body._folder() - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + /** + * Returns the raw multipart value of [isPrivateFile]. + * + * Unlike [isPrivateFile], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _isPrivateFile(): MultipartField = body._isPrivateFile() - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + /** + * Returns the raw multipart value of [isPublished]. + * + * Unlike [isPublished], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _isPublished(): MultipartField = body._isPublished() - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + /** + * Returns the raw multipart value of [overwriteAiTags]. + * + * Unlike [overwriteAiTags], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _overwriteAiTags(): MultipartField = body._overwriteAiTags() - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + /** + * Returns the raw multipart value of [overwriteCustomMetadata]. + * + * Unlike [overwriteCustomMetadata], this method doesn't throw if the multipart field has an + * unexpected type. + */ + fun _overwriteCustomMetadata(): MultipartField = body._overwriteCustomMetadata() - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + /** + * Returns the raw multipart value of [overwriteFile]. + * + * Unlike [overwriteFile], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _overwriteFile(): MultipartField = body._overwriteFile() - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + /** + * Returns the raw multipart value of [overwriteTags]. + * + * Unlike [overwriteTags], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _overwriteTags(): MultipartField = body._overwriteTags() - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + /** + * Returns the raw multipart value of [publicKey]. + * + * Unlike [publicKey], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _publicKey(): MultipartField = body._publicKey() + + /** + * Returns the raw multipart value of [responseFields]. + * + * Unlike [responseFields], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _responseFields(): MultipartField> = body._responseFields() + + /** + * Returns the raw multipart value of [signature]. + * + * Unlike [signature], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _signature(): MultipartField = body._signature() + + /** + * Returns the raw multipart value of [tags]. + * + * Unlike [tags], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _tags(): MultipartField> = body._tags() + + /** + * Returns the raw multipart value of [transformation]. + * + * Unlike [transformation], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _transformation(): MultipartField = body._transformation() + + /** + * Returns the raw multipart value of [useUniqueFileName]. + * + * Unlike [useUniqueFileName], this method doesn't throw if the multipart field has an + * unexpected type. + */ + fun _useUniqueFileName(): MultipartField = body._useUniqueFileName() + + /** + * Returns the raw multipart value of [webhookUrl]. + * + * Unlike [webhookUrl], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _webhookUrl(): MultipartField = body._webhookUrl() + + 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 an immutable instance of [FileUploadParams]. + * Returns a mutable builder for constructing an instance of [FileUploadParams]. * - * Further updates to this [Builder] will not mutate the returned instance. + * The following fields are required: + * ```java + * .file() + * .fileName() + * ``` */ - fun build(): FileUploadParams = - FileUploadParams(body, additionalHeaders.build(), additionalQueryParams.build()) + @JvmStatic fun builder() = Builder() } - fun _body(): Map> = - (mapOf("body" to _body()) + - _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) - .toImmutable() + /** A builder for [FileUploadParams]. */ + class Builder internal constructor() { - override fun _headers(): Headers = additionalHeaders + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - override fun _queryParams(): QueryParams = additionalQueryParams + @JvmSynthetic + internal fun from(fileUploadParams: FileUploadParams) = apply { + body = fileUploadParams.body.toBuilder() + additionalHeaders = fileUploadParams.additionalHeaders.toBuilder() + additionalQueryParams = fileUploadParams.additionalQueryParams.toBuilder() + } - @JsonDeserialize(using = Body.Deserializer::class) - @JsonSerialize(using = Body.Serializer::class) - class Body - private constructor( - private val fileUploadV1: FileUploadV1? = null, - private val fileUploadV1ByUrl: FileUploadV1ByUrl? = null, - private val _json: JsonValue? = null, - ) { + /** + * 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: + * - [file] + * - [fileName] + * - [token] + * - [checks] + * - [customCoordinates] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } - fun fileUploadV1(): Optional = Optional.ofNullable(fileUploadV1) + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(file: InputStream) = apply { body.file(file) } - fun fileUploadV1ByUrl(): Optional = - Optional.ofNullable(fileUploadV1ByUrl) + /** + * Sets [Builder.file] to an arbitrary multipart value. + * + * You should usually call [Builder.file] with a well-typed [InputStream] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun file(file: MultipartField) = apply { body.file(file) } - fun isFileUploadV1(): Boolean = fileUploadV1 != null + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(file: ByteArray) = apply { body.file(file) } - fun isFileUploadV1ByUrl(): Boolean = fileUploadV1ByUrl != null + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(path: Path) = apply { body.file(path) } - fun asFileUploadV1(): FileUploadV1 = fileUploadV1.getOrThrow("fileUploadV1") + /** + * The name with which the file has to be uploaded. The file name can contain: + * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + * - Special Characters: `.`, `-` + * + * Any other character including space will be replaced by `_` + */ + fun fileName(fileName: String) = apply { body.fileName(fileName) } - fun asFileUploadV1ByUrl(): FileUploadV1ByUrl = - fileUploadV1ByUrl.getOrThrow("fileUploadV1ByUrl") + /** + * Sets [Builder.fileName] to an arbitrary multipart value. + * + * You should usually call [Builder.fileName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fileName(fileName: MultipartField) = apply { body.fileName(fileName) } - fun _json(): Optional = Optional.ofNullable(_json) + /** + * A unique value that the ImageKit.io server will use to recognize and prevent subsequent + * retries for the same request. We suggest using V4 UUIDs, or another random string with + * enough entropy to avoid collisions. This field is only required for authentication when + * uploading a file from the client side. + * + * **Note**: Sending a value that has been used in the past will result in a validation + * error. Even if your previous request resulted in an error, you should always send a new + * value for this field. + */ + fun token(token: String) = apply { body.token(token) } - fun accept(visitor: Visitor): T = - when { - fileUploadV1 != null -> visitor.visitFileUploadV1(fileUploadV1) - fileUploadV1ByUrl != null -> visitor.visitFileUploadV1ByUrl(fileUploadV1ByUrl) - else -> visitor.unknown(_json) - } + /** + * Sets [Builder.token] to an arbitrary multipart value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: MultipartField) = apply { body.token(token) } - private var validated: Boolean = false + /** + * Server-side checks to run on the asset. Read more about + * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + */ + fun checks(checks: String) = apply { body.checks(checks) } - fun validate(): Body = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.checks] to an arbitrary multipart value. + * + * You should usually call [Builder.checks] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun checks(checks: MultipartField) = apply { body.checks(checks) } - accept( - object : Visitor { - override fun visitFileUploadV1(fileUploadV1: FileUploadV1) { - fileUploadV1.validate() - } + /** + * Define an important area in the image. This is only relevant for image type files. + * - To be passed as a string with the x and y coordinates of the top-left corner, and width + * and height of the area of interest in the format `x,y,width,height`. For example - + * `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates will + * be removed. + */ + fun customCoordinates(customCoordinates: String) = apply { + body.customCoordinates(customCoordinates) + } - override fun visitFileUploadV1ByUrl(fileUploadV1ByUrl: FileUploadV1ByUrl) { - fileUploadV1ByUrl.validate() - } - } - ) - validated = true + /** + * Sets [Builder.customCoordinates] to an arbitrary multipart value. + * + * You should usually call [Builder.customCoordinates] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customCoordinates(customCoordinates: MultipartField) = apply { + body.customCoordinates(customCoordinates) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields + * before setting these values. + */ + fun customMetadata(customMetadata: CustomMetadata) = apply { + body.customMetadata(customMetadata) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.customMetadata] to an arbitrary multipart value. * - * Used for best match union deserialization. + * You should usually call [Builder.customMetadata] with a well-typed [CustomMetadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitFileUploadV1(fileUploadV1: FileUploadV1) = - fileUploadV1.validity() + fun customMetadata(customMetadata: MultipartField) = apply { + body.customMetadata(customMetadata) + } - override fun visitFileUploadV1ByUrl(fileUploadV1ByUrl: FileUploadV1ByUrl) = - fileUploadV1ByUrl.validity() + /** Optional text to describe the contents of the file. */ + fun description(description: String) = apply { body.description(description) } - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * Sets [Builder.description] to an arbitrary multipart 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: MultipartField) = apply { + body.description(description) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The time until your signature is valid. It must be a + * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. + * It should be in seconds. This field is only required for authentication when uploading a + * file from the client side. + */ + fun expire(expire: Long) = apply { body.expire(expire) } - return other is Body && - fileUploadV1 == other.fileUploadV1 && - fileUploadV1ByUrl == other.fileUploadV1ByUrl - } + /** + * Sets [Builder.expire] to an arbitrary multipart value. + * + * You should usually call [Builder.expire] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun expire(expire: MultipartField) = apply { body.expire(expire) } - override fun hashCode(): Int = Objects.hash(fileUploadV1, fileUploadV1ByUrl) + /** + * Array of extensions to be applied to the image. Each extension can be configured with + * specific parameters based on the extension type. + */ + fun extensions(extensions: List) = apply { body.extensions(extensions) } - override fun toString(): String = - when { - fileUploadV1 != null -> "Body{fileUploadV1=$fileUploadV1}" - fileUploadV1ByUrl != null -> "Body{fileUploadV1ByUrl=$fileUploadV1ByUrl}" - _json != null -> "Body{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Body") - } + /** + * Sets [Builder.extensions] to an arbitrary multipart value. + * + * You should usually call [Builder.extensions] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun extensions(extensions: MultipartField>) = apply { + body.extensions(extensions) + } - companion object { + /** + * Adds a single [Extension] to [extensions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExtension(extension: Extension) = apply { body.addExtension(extension) } - @JvmStatic - fun ofFileUploadV1(fileUploadV1: FileUploadV1) = Body(fileUploadV1 = fileUploadV1) + /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ + fun addExtension(removeBg: Extension.RemoveBg) = apply { body.addExtension(removeBg) } - @JvmStatic - fun ofFileUploadV1ByUrl(fileUploadV1ByUrl: FileUploadV1ByUrl) = - Body(fileUploadV1ByUrl = fileUploadV1ByUrl) + /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = apply { + body.addExtension(autoTagging) } - /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ - interface Visitor { + /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ + fun addExtensionAiAutoDescription() = apply { body.addExtensionAiAutoDescription() } - fun visitFileUploadV1(fileUploadV1: FileUploadV1): T + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't exist + * before, a new folder(s) is created. + * + * The folder name can contain: + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. + */ + fun folder(folder: String) = apply { body.folder(folder) } - fun visitFileUploadV1ByUrl(fileUploadV1ByUrl: FileUploadV1ByUrl): T + /** + * Sets [Builder.folder] to an arbitrary multipart value. + * + * You should usually call [Builder.folder] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun folder(folder: MultipartField) = apply { body.folder(folder) } - /** - * Maps an unknown variant of [Body] to a value of type [T]. - * - * An instance of [Body] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Body: $json") - } + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named + * transformation or signed URL. + */ + fun isPrivateFile(isPrivateFile: Boolean) = apply { body.isPrivateFile(isPrivateFile) } + + /** + * Sets [Builder.isPrivateFile] to an arbitrary multipart value. + * + * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPrivateFile(isPrivateFile: MultipartField) = apply { + body.isPrivateFile(isPrivateFile) } - internal class Deserializer : BaseDeserializer(Body::class) { + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file only + * via the media library. Files in draft or unpublished state can only be publicly accessed + * after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing plans. + */ + fun isPublished(isPublished: Boolean) = apply { body.isPublished(isPublished) } - override fun ObjectCodec.deserialize(node: JsonNode): Body { - val json = JsonValue.fromJsonNode(node) + /** + * Sets [Builder.isPublished] to an arbitrary multipart value. + * + * You should usually call [Builder.isPublished] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isPublished(isPublished: MultipartField) = apply { + body.isPublished(isPublished) + } - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Body(fileUploadV1 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(fileUploadV1ByUrl = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from boolean). - 0 -> Body(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely - // valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } + /** + * If set to `true` and a file already exists at the exact location, its AITags will be + * removed. Set `overwriteAITags` to `false` to preserve AITags. + */ + fun overwriteAiTags(overwriteAiTags: Boolean) = apply { + body.overwriteAiTags(overwriteAiTags) } - internal class Serializer : BaseSerializer(Body::class) { + /** + * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteAiTags] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteAiTags(overwriteAiTags: MultipartField) = apply { + body.overwriteAiTags(overwriteAiTags) + } - override fun serialize( - value: Body, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.fileUploadV1 != null -> generator.writeObject(value.fileUploadV1) - value.fileUploadV1ByUrl != null -> - generator.writeObject(value.fileUploadV1ByUrl) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Body") - } - } + /** + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: Boolean) = apply { + body.overwriteCustomMetadata(overwriteCustomMetadata) } - class FileUploadV1 - private constructor( - private val file: MultipartField, - private val fileName: MultipartField, - private val token: MultipartField, - private val checks: MultipartField, - private val customCoordinates: MultipartField, - private val customMetadata: MultipartField, - private val description: MultipartField, - private val expire: MultipartField, - private val extensions: MultipartField>, - private val folder: MultipartField, - private val isPrivateFile: MultipartField, - private val isPublished: MultipartField, - private val overwriteAiTags: MultipartField, - private val overwriteCustomMetadata: MultipartField, - private val overwriteFile: MultipartField, - private val overwriteTags: MultipartField, - private val publicKey: MultipartField, - private val responseFields: MultipartField>, - private val signature: MultipartField, - private val tags: MultipartField>, - private val transformation: MultipartField, - private val useUniqueFileName: MultipartField, - private val webhookUrl: MultipartField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteCustomMetadata] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: MultipartField) = apply { + body.overwriteCustomMetadata(overwriteCustomMetadata) + } - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. - * - * @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 file(): InputStream = file.value.getRequired("file") + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the + * exact location, upload API will return an error immediately. + */ + fun overwriteFile(overwriteFile: Boolean) = apply { body.overwriteFile(overwriteFile) } - /** - * The name with which the file has to be uploaded. The file name can contain: - * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - * - Special Characters: `.`, `-` - * - * Any other character including space will be replaced by `_` - * - * @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 fileName(): String = fileName.value.getRequired("fileName") - - /** - * A unique value that the ImageKit.io server will use to recognize and prevent - * subsequent retries for the same request. We suggest using V4 UUIDs, or another random - * string with enough entropy to avoid collisions. This field is only required for - * authentication when uploading a file from the client side. - * - * **Note**: Sending a value that has been used in the past will result in a validation - * error. Even if your previous request resulted in an error, you should always send a - * new value for this field. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun token(): Optional = token.value.getOptional("token") - - /** - * Server-side checks to run on the asset. Read more about - * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun checks(): Optional = checks.value.getOptional("checks") - - /** - * Define an important area in the image. This is only relevant for image type files. - * - To be passed as a string with the x and y coordinates of the top-left corner, and - * width and height of the area of interest in the format `x,y,width,height`. For - * example - `10,10,100,100` - * - Can be used with fo-customtransformation. - * - If this field is not specified and the file is overwritten, then customCoordinates - * will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun customCoordinates(): Optional = - customCoordinates.value.getOptional("customCoordinates") - - /** - * JSON key-value pairs to associate with the asset. Create the custom metadata fields - * before setting these values. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun customMetadata(): Optional = - customMetadata.value.getOptional("customMetadata") - - /** - * Optional text to describe the contents of the file. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun description(): Optional = description.value.getOptional("description") - - /** - * The time until your signature is valid. It must be a - * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the - * future. It should be in seconds. This field is only required for authentication when - * uploading a file from the client side. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun expire(): Optional = expire.value.getOptional("expire") - - /** - * Array of extensions to be applied to the image. Each extension can be configured with - * specific parameters based on the extension type. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun extensions(): Optional> = extensions.value.getOptional("extensions") - - /** - * The folder path in which the image has to be uploaded. If the folder(s) didn't exist - * before, a new folder(s) is created. - * - * The folder name can contain: - * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - * - Special Characters: `/` , `_` , `-` - * - * Using multiple `/` creates a nested folder. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun folder(): Optional = folder.value.getOptional("folder") - - /** - * Whether to mark the file as private or not. - * - * If `true`, the file is marked as private and is accessible only using named - * transformation or signed URL. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun isPrivateFile(): Optional = - isPrivateFile.value.getOptional("isPrivateFile") - - /** - * Whether to upload file as published or not. - * - * If `false`, the file is marked as unpublished, which restricts access to the file - * only via the media library. Files in draft or unpublished state can only be publicly - * accessed after being published. - * - * The option to upload in draft state is only available in custom enterprise pricing - * plans. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun isPublished(): Optional = isPublished.value.getOptional("isPublished") - - /** - * If set to `true` and a file already exists at the exact location, its AITags will be - * removed. Set `overwriteAITags` to `false` to preserve AITags. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun overwriteAiTags(): Optional = - overwriteAiTags.value.getOptional("overwriteAITags") - - /** - * If the request does not have `customMetadata`, and a file already exists at the exact - * location, existing customMetadata will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun overwriteCustomMetadata(): Optional = - overwriteCustomMetadata.value.getOptional("overwriteCustomMetadata") - - /** - * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the - * exact location, upload API will return an error immediately. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun overwriteFile(): Optional = - overwriteFile.value.getOptional("overwriteFile") - - /** - * If the request does not have `tags`, and a file already exists at the exact location, - * existing tags will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun overwriteTags(): Optional = - overwriteTags.value.getOptional("overwriteTags") - - /** - * Your ImageKit.io public key. This field is only required for authentication when - * uploading a file from the client side. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun publicKey(): Optional = publicKey.value.getOptional("publicKey") - - /** - * Array of response field keys to include in the API response body. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun responseFields(): Optional> = - responseFields.value.getOptional("responseFields") - - /** - * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. - * Learn how to create a signature on the page below. This should be in lowercase. - * - * Signature must be calculated on the server-side. This field is only required for - * authentication when uploading a file from the client side. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun signature(): Optional = signature.value.getOptional("signature") - - /** - * Set the tags while uploading the file. Provide an array of tag strings (e.g. - * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not - * exceed 500, and the `%` character is not allowed. If this field is not specified and - * the file is overwritten, the existing tags will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun tags(): Optional> = tags.value.getOptional("tags") - - /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for - * reducing file size or applying basic optimizations upfront (e.g., resize, - * compress). - * - `post` — applied immediately after upload. Ideal for generating transformed - * versions (like video encodes or thumbnails) in advance, so they're ready for - * delivery without delay. - * - * You can mix and match any combination of post-processing types. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun transformation(): Optional = - transformation.value.getOptional("transformation") - - /** - * Whether to use a unique filename for this file or not. - * - * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a - * unique filename. - * - * If `false`, then the image is uploaded with the provided filename parameter, and any - * existing file with the same name is replaced. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun useUniqueFileName(): Optional = - useUniqueFileName.value.getOptional("useUniqueFileName") - - /** - * The final status of extensions after they have completed execution will be delivered - * to this endpoint as a POST request. - * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - * about the webhook payload structure. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun webhookUrl(): Optional = webhookUrl.value.getOptional("webhookUrl") - - /** - * Returns the raw multipart value of [file]. - * - * Unlike [file], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField = file - - /** - * Returns the raw multipart value of [fileName]. - * - * Unlike [fileName], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("fileName") - @ExcludeMissing - fun _fileName(): MultipartField = fileName - - /** - * Returns the raw multipart value of [token]. - * - * Unlike [token], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("token") @ExcludeMissing fun _token(): MultipartField = token - - /** - * Returns the raw multipart value of [checks]. - * - * Unlike [checks], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("checks") @ExcludeMissing fun _checks(): MultipartField = checks - - /** - * Returns the raw multipart value of [customCoordinates]. - * - * Unlike [customCoordinates], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("customCoordinates") - @ExcludeMissing - fun _customCoordinates(): MultipartField = customCoordinates - - /** - * Returns the raw multipart value of [customMetadata]. - * - * Unlike [customMetadata], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("customMetadata") - @ExcludeMissing - fun _customMetadata(): MultipartField = customMetadata - - /** - * Returns the raw multipart value of [description]. - * - * Unlike [description], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): MultipartField = description - - /** - * Returns the raw multipart value of [expire]. - * - * Unlike [expire], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("expire") @ExcludeMissing fun _expire(): MultipartField = expire - - /** - * Returns the raw multipart value of [extensions]. - * - * Unlike [extensions], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("extensions") - @ExcludeMissing - fun _extensions(): MultipartField> = extensions - - /** - * Returns the raw multipart value of [folder]. - * - * Unlike [folder], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("folder") @ExcludeMissing fun _folder(): MultipartField = folder - - /** - * Returns the raw multipart value of [isPrivateFile]. - * - * Unlike [isPrivateFile], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("isPrivateFile") - @ExcludeMissing - fun _isPrivateFile(): MultipartField = isPrivateFile - - /** - * Returns the raw multipart value of [isPublished]. - * - * Unlike [isPublished], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("isPublished") - @ExcludeMissing - fun _isPublished(): MultipartField = isPublished - - /** - * Returns the raw multipart value of [overwriteAiTags]. - * - * Unlike [overwriteAiTags], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("overwriteAITags") - @ExcludeMissing - fun _overwriteAiTags(): MultipartField = overwriteAiTags - - /** - * Returns the raw multipart value of [overwriteCustomMetadata]. - * - * Unlike [overwriteCustomMetadata], this method doesn't throw if the multipart field - * has an unexpected type. - */ - @JsonProperty("overwriteCustomMetadata") - @ExcludeMissing - fun _overwriteCustomMetadata(): MultipartField = overwriteCustomMetadata - - /** - * Returns the raw multipart value of [overwriteFile]. - * - * Unlike [overwriteFile], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("overwriteFile") - @ExcludeMissing - fun _overwriteFile(): MultipartField = overwriteFile - - /** - * Returns the raw multipart value of [overwriteTags]. - * - * Unlike [overwriteTags], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("overwriteTags") - @ExcludeMissing - fun _overwriteTags(): MultipartField = overwriteTags - - /** - * Returns the raw multipart value of [publicKey]. - * - * Unlike [publicKey], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("publicKey") - @ExcludeMissing - fun _publicKey(): MultipartField = publicKey - - /** - * Returns the raw multipart value of [responseFields]. - * - * Unlike [responseFields], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("responseFields") - @ExcludeMissing - fun _responseFields(): MultipartField> = responseFields - - /** - * Returns the raw multipart value of [signature]. - * - * Unlike [signature], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("signature") - @ExcludeMissing - fun _signature(): MultipartField = signature - - /** - * Returns the raw multipart value of [tags]. - * - * Unlike [tags], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): MultipartField> = tags - - /** - * Returns the raw multipart value of [transformation]. - * - * Unlike [transformation], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("transformation") - @ExcludeMissing - fun _transformation(): MultipartField = transformation - - /** - * Returns the raw multipart value of [useUniqueFileName]. - * - * Unlike [useUniqueFileName], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("useUniqueFileName") - @ExcludeMissing - fun _useUniqueFileName(): MultipartField = useUniqueFileName - - /** - * Returns the raw multipart value of [webhookUrl]. - * - * Unlike [webhookUrl], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("webhookUrl") - @ExcludeMissing - fun _webhookUrl(): MultipartField = webhookUrl - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [FileUploadV1]. - * - * The following fields are required: - * ```java - * .file() - * .fileName() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FileUploadV1]. */ - class Builder internal constructor() { - - private var file: MultipartField? = null - private var fileName: MultipartField? = null - private var token: MultipartField = MultipartField.of(null) - private var checks: MultipartField = MultipartField.of(null) - private var customCoordinates: MultipartField = MultipartField.of(null) - private var customMetadata: MultipartField = MultipartField.of(null) - private var description: MultipartField = MultipartField.of(null) - private var expire: MultipartField = MultipartField.of(null) - private var extensions: MultipartField>? = null - private var folder: MultipartField = MultipartField.of(null) - private var isPrivateFile: MultipartField = MultipartField.of(null) - private var isPublished: MultipartField = MultipartField.of(null) - private var overwriteAiTags: MultipartField = MultipartField.of(null) - private var overwriteCustomMetadata: MultipartField = - MultipartField.of(null) - private var overwriteFile: MultipartField = MultipartField.of(null) - private var overwriteTags: MultipartField = MultipartField.of(null) - private var publicKey: MultipartField = MultipartField.of(null) - private var responseFields: MultipartField>? = null - private var signature: MultipartField = MultipartField.of(null) - private var tags: MultipartField>? = null - private var transformation: MultipartField = MultipartField.of(null) - private var useUniqueFileName: MultipartField = MultipartField.of(null) - private var webhookUrl: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fileUploadV1: FileUploadV1) = apply { - file = fileUploadV1.file - fileName = fileUploadV1.fileName - token = fileUploadV1.token - checks = fileUploadV1.checks - customCoordinates = fileUploadV1.customCoordinates - customMetadata = fileUploadV1.customMetadata - description = fileUploadV1.description - expire = fileUploadV1.expire - extensions = fileUploadV1.extensions.map { it.toMutableList() } - folder = fileUploadV1.folder - isPrivateFile = fileUploadV1.isPrivateFile - isPublished = fileUploadV1.isPublished - overwriteAiTags = fileUploadV1.overwriteAiTags - overwriteCustomMetadata = fileUploadV1.overwriteCustomMetadata - overwriteFile = fileUploadV1.overwriteFile - overwriteTags = fileUploadV1.overwriteTags - publicKey = fileUploadV1.publicKey - responseFields = fileUploadV1.responseFields.map { it.toMutableList() } - signature = fileUploadV1.signature - tags = fileUploadV1.tags.map { it.toMutableList() } - transformation = fileUploadV1.transformation - useUniqueFileName = fileUploadV1.useUniqueFileName - webhookUrl = fileUploadV1.webhookUrl - additionalProperties = fileUploadV1.additionalProperties.toMutableMap() - } - - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can - * fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 - * seconds; otherwise the request fails with 400 Bad Request. - */ - fun file(file: InputStream) = file(MultipartField.of(file)) - - /** - * Sets [Builder.file] to an arbitrary multipart value. - * - * You should usually call [Builder.file] with a well-typed [InputStream] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun file(file: MultipartField) = apply { this.file = file } - - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can - * fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 - * seconds; otherwise the request fails with 400 Bad Request. - */ - fun file(file: ByteArray) = file(file.inputStream()) - - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can - * fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 - * seconds; otherwise the request fails with 400 Bad Request. - */ - fun file(path: Path) = - file( - MultipartField.builder() - .value(path.inputStream()) - .filename(path.name) - .build() - ) - - /** - * The name with which the file has to be uploaded. The file name can contain: - * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - * - Special Characters: `.`, `-` - * - * Any other character including space will be replaced by `_` - */ - fun fileName(fileName: String) = fileName(MultipartField.of(fileName)) - - /** - * Sets [Builder.fileName] to an arbitrary multipart value. - * - * You should usually call [Builder.fileName] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun fileName(fileName: MultipartField) = apply { this.fileName = fileName } - - /** - * A unique value that the ImageKit.io server will use to recognize and prevent - * subsequent retries for the same request. We suggest using V4 UUIDs, or another - * random string with enough entropy to avoid collisions. This field is only - * required for authentication when uploading a file from the client side. - * - * **Note**: Sending a value that has been used in the past will result in a - * validation error. Even if your previous request resulted in an error, you should - * always send a new value for this field. - */ - fun token(token: String) = token(MultipartField.of(token)) - - /** - * Sets [Builder.token] to an arbitrary multipart value. - * - * You should usually call [Builder.token] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun token(token: MultipartField) = apply { this.token = token } - - /** - * Server-side checks to run on the asset. Read more about - * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). - */ - fun checks(checks: String) = checks(MultipartField.of(checks)) - - /** - * Sets [Builder.checks] to an arbitrary multipart value. - * - * You should usually call [Builder.checks] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun checks(checks: MultipartField) = apply { this.checks = checks } - - /** - * Define an important area in the image. This is only relevant for image type - * files. - * - To be passed as a string with the x and y coordinates of the top-left corner, - * and width and height of the area of interest in the format `x,y,width,height`. - * For example - `10,10,100,100` - * - Can be used with fo-customtransformation. - * - If this field is not specified and the file is overwritten, then - * customCoordinates will be removed. - */ - fun customCoordinates(customCoordinates: String) = - customCoordinates(MultipartField.of(customCoordinates)) - - /** - * Sets [Builder.customCoordinates] to an arbitrary multipart value. - * - * You should usually call [Builder.customCoordinates] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun customCoordinates(customCoordinates: MultipartField) = apply { - this.customCoordinates = customCoordinates - } - - /** - * JSON key-value pairs to associate with the asset. Create the custom metadata - * fields before setting these values. - */ - fun customMetadata(customMetadata: CustomMetadata) = - customMetadata(MultipartField.of(customMetadata)) - - /** - * Sets [Builder.customMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.customMetadata] with a well-typed - * [CustomMetadata] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun customMetadata(customMetadata: MultipartField) = apply { - this.customMetadata = customMetadata - } - - /** Optional text to describe the contents of the file. */ - fun description(description: String) = description(MultipartField.of(description)) - - /** - * Sets [Builder.description] to an arbitrary multipart 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: MultipartField) = apply { - this.description = description - } - - /** - * The time until your signature is valid. It must be a - * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the - * future. It should be in seconds. This field is only required for authentication - * when uploading a file from the client side. - */ - fun expire(expire: Long) = expire(MultipartField.of(expire)) - - /** - * Sets [Builder.expire] to an arbitrary multipart value. - * - * You should usually call [Builder.expire] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun expire(expire: MultipartField) = apply { this.expire = expire } - - /** - * Array of extensions to be applied to the image. Each extension can be configured - * with specific parameters based on the extension type. - */ - fun extensions(extensions: List) = - extensions(MultipartField.of(extensions)) - - /** - * Sets [Builder.extensions] to an arbitrary multipart value. - * - * You should usually call [Builder.extensions] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun extensions(extensions: MultipartField>) = apply { - this.extensions = extensions.map { it.toMutableList() } - } - - /** - * Adds a single [Extension] to [extensions]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addExtension(extension: Extension) = apply { - extensions = - (extensions ?: MultipartField.of(mutableListOf())).also { - checkKnown("extensions", it).add(extension) - } - } - - /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: Extension.RemoveBg) = - addExtension(Extension.ofRemoveBg(removeBg)) - - /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: Extension.AutoTaggingExtension) = - addExtension(Extension.ofAutoTagging(autoTagging)) - - /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ - fun addExtensionAiAutoDescription() = addExtension(Extension.ofAiAutoDescription()) - - /** - * The folder path in which the image has to be uploaded. If the folder(s) didn't - * exist before, a new folder(s) is created. - * - * The folder name can contain: - * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - * - Special Characters: `/` , `_` , `-` - * - * Using multiple `/` creates a nested folder. - */ - fun folder(folder: String) = folder(MultipartField.of(folder)) - - /** - * Sets [Builder.folder] to an arbitrary multipart value. - * - * You should usually call [Builder.folder] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun folder(folder: MultipartField) = apply { this.folder = folder } - - /** - * Whether to mark the file as private or not. - * - * If `true`, the file is marked as private and is accessible only using named - * transformation or signed URL. - */ - fun isPrivateFile(isPrivateFile: Boolean) = - isPrivateFile(MultipartField.of(isPrivateFile)) - - /** - * Sets [Builder.isPrivateFile] to an arbitrary multipart value. - * - * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun isPrivateFile(isPrivateFile: MultipartField) = apply { - this.isPrivateFile = isPrivateFile - } - - /** - * Whether to upload file as published or not. - * - * If `false`, the file is marked as unpublished, which restricts access to the file - * only via the media library. Files in draft or unpublished state can only be - * publicly accessed after being published. - * - * The option to upload in draft state is only available in custom enterprise - * pricing plans. - */ - fun isPublished(isPublished: Boolean) = isPublished(MultipartField.of(isPublished)) - - /** - * Sets [Builder.isPublished] to an arbitrary multipart value. - * - * You should usually call [Builder.isPublished] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun isPublished(isPublished: MultipartField) = apply { - this.isPublished = isPublished - } - - /** - * If set to `true` and a file already exists at the exact location, its AITags will - * be removed. Set `overwriteAITags` to `false` to preserve AITags. - */ - fun overwriteAiTags(overwriteAiTags: Boolean) = - overwriteAiTags(MultipartField.of(overwriteAiTags)) - - /** - * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteAiTags] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun overwriteAiTags(overwriteAiTags: MultipartField) = apply { - this.overwriteAiTags = overwriteAiTags - } - - /** - * If the request does not have `customMetadata`, and a file already exists at the - * exact location, existing customMetadata will be removed. - */ - fun overwriteCustomMetadata(overwriteCustomMetadata: Boolean) = - overwriteCustomMetadata(MultipartField.of(overwriteCustomMetadata)) - - /** - * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteCustomMetadata] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun overwriteCustomMetadata(overwriteCustomMetadata: MultipartField) = - apply { - this.overwriteCustomMetadata = overwriteCustomMetadata - } - - /** - * If `false` and `useUniqueFileName` is also `false`, and a file already exists at - * the exact location, upload API will return an error immediately. - */ - fun overwriteFile(overwriteFile: Boolean) = - overwriteFile(MultipartField.of(overwriteFile)) - - /** - * Sets [Builder.overwriteFile] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteFile] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun overwriteFile(overwriteFile: MultipartField) = apply { - this.overwriteFile = overwriteFile - } - - /** - * If the request does not have `tags`, and a file already exists at the exact - * location, existing tags will be removed. - */ - fun overwriteTags(overwriteTags: Boolean) = - overwriteTags(MultipartField.of(overwriteTags)) - - /** - * Sets [Builder.overwriteTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteTags] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun overwriteTags(overwriteTags: MultipartField) = apply { - this.overwriteTags = overwriteTags - } - - /** - * Your ImageKit.io public key. This field is only required for authentication when - * uploading a file from the client side. - */ - fun publicKey(publicKey: String) = publicKey(MultipartField.of(publicKey)) - - /** - * Sets [Builder.publicKey] to an arbitrary multipart value. - * - * You should usually call [Builder.publicKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun publicKey(publicKey: MultipartField) = apply { - this.publicKey = publicKey - } - - /** Array of response field keys to include in the API response body. */ - fun responseFields(responseFields: List) = - responseFields(MultipartField.of(responseFields)) - - /** - * Sets [Builder.responseFields] to an arbitrary multipart value. - * - * You should usually call [Builder.responseFields] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun responseFields(responseFields: MultipartField>) = apply { - this.responseFields = responseFields.map { it.toMutableList() } - } - - /** - * Adds a single [ResponseField] to [responseFields]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addResponseField(responseField: ResponseField) = apply { - responseFields = - (responseFields ?: MultipartField.of(mutableListOf())).also { - checkKnown("responseFields", it).add(responseField) - } - } - - /** - * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a - * key. Learn how to create a signature on the page below. This should be in - * lowercase. - * - * Signature must be calculated on the server-side. This field is only required for - * authentication when uploading a file from the client side. - */ - fun signature(signature: String) = signature(MultipartField.of(signature)) - - /** - * Sets [Builder.signature] to an arbitrary multipart value. - * - * You should usually call [Builder.signature] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun signature(signature: MultipartField) = apply { - this.signature = signature - } - - /** - * Set the tags while uploading the file. Provide an array of tag strings (e.g. - * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not - * exceed 500, and the `%` character is not allowed. If this field is not specified - * and the file is overwritten, the existing tags will be removed. - */ - fun tags(tags: List) = tags(MultipartField.of(tags)) - - /** - * Sets [Builder.tags] to an arbitrary multipart value. - * - * You should usually call [Builder.tags] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun tags(tags: MultipartField>) = apply { - this.tags = tags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [tags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTag(tag: String) = apply { - tags = - (tags ?: MultipartField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } - - /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for - * reducing file size or applying basic optimizations upfront (e.g., resize, - * compress). - * - `post` — applied immediately after upload. Ideal for generating transformed - * versions (like video encodes or thumbnails) in advance, so they're ready for - * delivery without delay. - * - * You can mix and match any combination of post-processing types. - */ - fun transformation(transformation: Transformation) = - transformation(MultipartField.of(transformation)) - - /** - * Sets [Builder.transformation] to an arbitrary multipart value. - * - * You should usually call [Builder.transformation] with a well-typed - * [Transformation] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun transformation(transformation: MultipartField) = apply { - this.transformation = transformation - } - - /** - * Whether to use a unique filename for this file or not. - * - * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get - * a unique filename. - * - * If `false`, then the image is uploaded with the provided filename parameter, and - * any existing file with the same name is replaced. - */ - fun useUniqueFileName(useUniqueFileName: Boolean) = - useUniqueFileName(MultipartField.of(useUniqueFileName)) - - /** - * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. - * - * You should usually call [Builder.useUniqueFileName] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun useUniqueFileName(useUniqueFileName: MultipartField) = apply { - this.useUniqueFileName = useUniqueFileName - } - - /** - * The final status of extensions after they have completed execution will be - * delivered to this endpoint as a POST request. - * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - * about the webhook payload structure. - */ - fun webhookUrl(webhookUrl: String) = webhookUrl(MultipartField.of(webhookUrl)) - - /** - * Sets [Builder.webhookUrl] to an arbitrary multipart value. - * - * You should usually call [Builder.webhookUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun webhookUrl(webhookUrl: MultipartField) = apply { - this.webhookUrl = webhookUrl - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [FileUploadV1]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .file() - * .fileName() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): FileUploadV1 = - FileUploadV1( - checkRequired("file", file), - checkRequired("fileName", fileName), - token, - checks, - customCoordinates, - customMetadata, - description, - expire, - (extensions ?: MultipartField.of(null)).map { it.toImmutable() }, - folder, - isPrivateFile, - isPublished, - overwriteAiTags, - overwriteCustomMetadata, - overwriteFile, - overwriteTags, - publicKey, - (responseFields ?: MultipartField.of(null)).map { it.toImmutable() }, - signature, - (tags ?: MultipartField.of(null)).map { it.toImmutable() }, - transformation, - useUniqueFileName, - webhookUrl, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): FileUploadV1 = apply { - if (validated) { - return@apply - } - - file() - fileName() - token() - checks() - customCoordinates() - customMetadata().ifPresent { it.validate() } - description() - expire() - extensions().ifPresent { it.forEach { it.validate() } } - folder() - isPrivateFile() - isPublished() - overwriteAiTags() - overwriteCustomMetadata() - overwriteFile() - overwriteTags() - publicKey() - responseFields().ifPresent { it.forEach { it.validate() } } - signature() - tags() - transformation().ifPresent { it.validate() } - useUniqueFileName() - webhookUrl() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * JSON key-value pairs to associate with the asset. Create the custom metadata fields - * before setting these values. - */ - class CustomMetadata - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [CustomMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customMetadata: CustomMetadata) = apply { - additionalProperties = customMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [CustomMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): CustomMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CustomMetadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CustomMetadata{additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = Extension.Deserializer::class) - @JsonSerialize(using = Extension.Serializer::class) - class Extension - private constructor( - private val removeBg: RemoveBg? = null, - private val autoTagging: AutoTaggingExtension? = null, - private val aiAutoDescription: JsonValue? = null, - private val _json: JsonValue? = null, - ) { - - fun removeBg(): Optional = Optional.ofNullable(removeBg) - - fun autoTagging(): Optional = Optional.ofNullable(autoTagging) - - fun aiAutoDescription(): Optional = - Optional.ofNullable(aiAutoDescription) - - fun isRemoveBg(): Boolean = removeBg != null - - fun isAutoTagging(): Boolean = autoTagging != null - - fun isAiAutoDescription(): Boolean = aiAutoDescription != null - - fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") - - fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") - - fun asAiAutoDescription(): JsonValue = - aiAutoDescription.getOrThrow("aiAutoDescription") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - removeBg != null -> visitor.visitRemoveBg(removeBg) - autoTagging != null -> visitor.visitAutoTagging(autoTagging) - aiAutoDescription != null -> - visitor.visitAiAutoDescription(aiAutoDescription) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Extension = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitRemoveBg(removeBg: RemoveBg) { - removeBg.validate() - } - - override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { - autoTagging.validate() - } - - override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { - aiAutoDescription.let { - if ( - it != JsonValue.from(mapOf("name" to "ai-auto-description")) - ) { - throw ImageKitInvalidDataException( - "'aiAutoDescription' is invalid, received $it" - ) - } - } - } - } - ) - 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 = - accept( - object : Visitor { - override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() - - override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = - autoTagging.validity() - - override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = - aiAutoDescription.let { - if ( - it == JsonValue.from(mapOf("name" to "ai-auto-description")) - ) - 1 - else 0 - } - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Extension && - removeBg == other.removeBg && - autoTagging == other.autoTagging && - aiAutoDescription == other.aiAutoDescription - } - - override fun hashCode(): Int = - Objects.hash(removeBg, autoTagging, aiAutoDescription) - - override fun toString(): String = - when { - removeBg != null -> "Extension{removeBg=$removeBg}" - autoTagging != null -> "Extension{autoTagging=$autoTagging}" - aiAutoDescription != null -> - "Extension{aiAutoDescription=$aiAutoDescription}" - _json != null -> "Extension{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Extension") - } - - companion object { - - @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = Extension(removeBg = removeBg) - - @JvmStatic - fun ofAutoTagging(autoTagging: AutoTaggingExtension) = - Extension(autoTagging = autoTagging) - - @JvmStatic - fun ofAiAutoDescription() = - Extension( - aiAutoDescription = - JsonValue.from(mapOf("name" to "ai-auto-description")) - ) - } - - /** - * An interface that defines how to map each variant of [Extension] to a value of - * type [T]. - */ - interface Visitor { - - fun visitRemoveBg(removeBg: RemoveBg): T - - fun visitAutoTagging(autoTagging: AutoTaggingExtension): T - - fun visitAiAutoDescription(aiAutoDescription: JsonValue): T - - /** - * Maps an unknown variant of [Extension] to a value of type [T]. - * - * An instance of [Extension] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Extension: $json") - } - } - - internal class Deserializer : BaseDeserializer(Extension::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Extension { - val json = JsonValue.fromJsonNode(node) - val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() - - when (name) { - "remove-bg" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Extension(removeBg = it, _json = json) - } ?: Extension(_json = json) - } - "ai-auto-description" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Extension(aiAutoDescription = it, _json = json) } - ?.takeIf { it.isValid() } ?: Extension(_json = json) - } - } - - return tryDeserialize(node, jacksonTypeRef())?.let { - Extension(autoTagging = it, _json = json) - } ?: Extension(_json = json) - } - } - - internal class Serializer : BaseSerializer(Extension::class) { - - override fun serialize( - value: Extension, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.removeBg != null -> generator.writeObject(value.removeBg) - value.autoTagging != null -> generator.writeObject(value.autoTagging) - value.aiAutoDescription != null -> - generator.writeObject(value.aiAutoDescription) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Extension") - } - } - } - - class RemoveBg - private constructor( - private val name: JsonValue, - private val options: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Specifies the background removal extension. - * - * Expected to always return the following: - * ```java - * JsonValue.from("remove-bg") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun options(): Optional = options.value.getOptional("options") - - /** - * Returns the raw multipart value of [options]. - * - * Unlike [options], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("options") - @ExcludeMissing - fun _options(): MultipartField = options - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RemoveBg]. */ - class Builder internal constructor() { - - private var name: JsonValue = JsonValue.from("remove-bg") - private var options: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(removeBg: RemoveBg) = apply { - name = removeBg.name - options = removeBg.options - additionalProperties = removeBg.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults - * to the following: - * ```java - * JsonValue.from("remove-bg") - * ``` - * - * This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun name(name: JsonValue) = apply { this.name = name } - - fun options(options: Options) = options(MultipartField.of(options)) - - /** - * Sets [Builder.options] to an arbitrary multipart value. - * - * You should usually call [Builder.options] with a well-typed [Options] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun options(options: MultipartField) = apply { - this.options = options - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [RemoveBg]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemoveBg = - RemoveBg(name, options, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): RemoveBg = apply { - if (validated) { - return@apply - } - - _name().let { - if (it != JsonValue.from("remove-bg")) { - throw ImageKitInvalidDataException( - "'name' is invalid, received $it" - ) - } - } - options().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - class Options - private constructor( - private val addShadow: MultipartField, - private val bgColor: MultipartField, - private val bgImageUrl: MultipartField, - private val semitransparency: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Whether to add an artificial shadow to the result. Default is false. - * Note: Adding shadows is currently only supported for car photos. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun addShadow(): Optional = - addShadow.value.getOptional("add_shadow") - - /** - * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") - * or color name (e.g., "green"). If this parameter is set, `bg_image_url` - * must be empty. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun bgColor(): Optional = bgColor.value.getOptional("bg_color") - - /** - * Sets a background image from a URL. If this parameter is set, `bg_color` - * must be empty. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun bgImageUrl(): Optional = - bgImageUrl.value.getOptional("bg_image_url") - - /** - * Allows semi-transparent regions in the result. Default is true. Note: - * Semitransparency is currently only supported for car windows. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun semitransparency(): Optional = - semitransparency.value.getOptional("semitransparency") - - /** - * Returns the raw multipart value of [addShadow]. - * - * Unlike [addShadow], this method doesn't throw if the multipart field has - * an unexpected type. - */ - @JsonProperty("add_shadow") - @ExcludeMissing - fun _addShadow(): MultipartField = addShadow - - /** - * Returns the raw multipart value of [bgColor]. - * - * Unlike [bgColor], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("bg_color") - @ExcludeMissing - fun _bgColor(): MultipartField = bgColor - - /** - * Returns the raw multipart value of [bgImageUrl]. - * - * Unlike [bgImageUrl], this method doesn't throw if the multipart field has - * an unexpected type. - */ - @JsonProperty("bg_image_url") - @ExcludeMissing - fun _bgImageUrl(): MultipartField = bgImageUrl - - /** - * Returns the raw multipart value of [semitransparency]. - * - * Unlike [semitransparency], this method doesn't throw if the multipart - * field has an unexpected type. - */ - @JsonProperty("semitransparency") - @ExcludeMissing - fun _semitransparency(): MultipartField = semitransparency - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Options]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Options]. */ - class Builder internal constructor() { - - private var addShadow: MultipartField = MultipartField.of(null) - private var bgColor: MultipartField = MultipartField.of(null) - private var bgImageUrl: MultipartField = MultipartField.of(null) - private var semitransparency: MultipartField = - MultipartField.of(null) - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(options: Options) = apply { - addShadow = options.addShadow - bgColor = options.bgColor - bgImageUrl = options.bgImageUrl - semitransparency = options.semitransparency - additionalProperties = options.additionalProperties.toMutableMap() - } - - /** - * Whether to add an artificial shadow to the result. Default is false. - * Note: Adding shadows is currently only supported for car photos. - */ - fun addShadow(addShadow: Boolean) = - addShadow(MultipartField.of(addShadow)) - - /** - * Sets [Builder.addShadow] to an arbitrary multipart value. - * - * You should usually call [Builder.addShadow] with a well-typed - * [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun addShadow(addShadow: MultipartField) = apply { - this.addShadow = addShadow - } - - /** - * Specifies a solid color background using hex code (e.g., "81d4fa", - * "fff") or color name (e.g., "green"). If this parameter is set, - * `bg_image_url` must be empty. - */ - fun bgColor(bgColor: String) = bgColor(MultipartField.of(bgColor)) - - /** - * Sets [Builder.bgColor] to an arbitrary multipart value. - * - * You should usually call [Builder.bgColor] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun bgColor(bgColor: MultipartField) = apply { - this.bgColor = bgColor - } - - /** - * Sets a background image from a URL. If this parameter is set, - * `bg_color` must be empty. - */ - fun bgImageUrl(bgImageUrl: String) = - bgImageUrl(MultipartField.of(bgImageUrl)) - - /** - * Sets [Builder.bgImageUrl] to an arbitrary multipart value. - * - * You should usually call [Builder.bgImageUrl] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun bgImageUrl(bgImageUrl: MultipartField) = apply { - this.bgImageUrl = bgImageUrl - } - - /** - * Allows semi-transparent regions in the result. Default is true. Note: - * Semitransparency is currently only supported for car windows. - */ - fun semitransparency(semitransparency: Boolean) = - semitransparency(MultipartField.of(semitransparency)) - - /** - * Sets [Builder.semitransparency] to an arbitrary multipart value. - * - * You should usually call [Builder.semitransparency] with a well-typed - * [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun semitransparency(semitransparency: MultipartField) = - apply { - this.semitransparency = semitransparency - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Options]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): Options = - Options( - addShadow, - bgColor, - bgImageUrl, - semitransparency, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Options = apply { - if (validated) { - return@apply - } - - addShadow() - bgColor() - bgImageUrl() - semitransparency() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - addShadow == other.addShadow && - bgColor == other.bgColor && - bgImageUrl == other.bgImageUrl && - semitransparency == other.semitransparency && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - addShadow, - bgColor, - bgImageUrl, - semitransparency, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemoveBg && - name == other.name && - options == other.options && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(name, options, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" - } - - class AutoTaggingExtension - private constructor( - private val maxTags: MultipartField, - private val minConfidence: MultipartField, - private val name: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Maximum number of tags to attach to the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun maxTags(): Long = maxTags.value.getRequired("maxTags") - - /** - * Minimum confidence level for tags to be considered valid. - * - * @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 minConfidence(): Long = minConfidence.value.getRequired("minConfidence") - - /** - * Specifies the auto-tagging extension used. - * - * @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(): Name = name.value.getRequired("name") - - /** - * Returns the raw multipart value of [maxTags]. - * - * Unlike [maxTags], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("maxTags") - @ExcludeMissing - fun _maxTags(): MultipartField = maxTags - - /** - * Returns the raw multipart value of [minConfidence]. - * - * Unlike [minConfidence], this method doesn't throw if the multipart field has - * an unexpected type. - */ - @JsonProperty("minConfidence") - @ExcludeMissing - fun _minConfidence(): MultipartField = minConfidence - - /** - * Returns the raw multipart value of [name]. - * - * Unlike [name], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AutoTaggingExtension]. - * - * The following fields are required: - * ```java - * .maxTags() - * .minConfidence() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutoTaggingExtension]. */ - class Builder internal constructor() { - - private var maxTags: MultipartField? = null - private var minConfidence: MultipartField? = null - private var name: MultipartField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { - maxTags = autoTaggingExtension.maxTags - minConfidence = autoTaggingExtension.minConfidence - name = autoTaggingExtension.name - additionalProperties = - autoTaggingExtension.additionalProperties.toMutableMap() - } - - /** Maximum number of tags to attach to the asset. */ - fun maxTags(maxTags: Long) = maxTags(MultipartField.of(maxTags)) - - /** - * Sets [Builder.maxTags] to an arbitrary multipart value. - * - * You should usually call [Builder.maxTags] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun maxTags(maxTags: MultipartField) = apply { - this.maxTags = maxTags - } - - /** Minimum confidence level for tags to be considered valid. */ - fun minConfidence(minConfidence: Long) = - minConfidence(MultipartField.of(minConfidence)) - - /** - * Sets [Builder.minConfidence] to an arbitrary multipart value. - * - * You should usually call [Builder.minConfidence] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun minConfidence(minConfidence: MultipartField) = apply { - this.minConfidence = minConfidence - } - - /** Specifies the auto-tagging extension used. */ - fun name(name: Name) = name(MultipartField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary multipart value. - * - * You should usually call [Builder.name] with a well-typed [Name] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun name(name: MultipartField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AutoTaggingExtension]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .maxTags() - * .minConfidence() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AutoTaggingExtension = - AutoTaggingExtension( - checkRequired("maxTags", maxTags), - checkRequired("minConfidence", minConfidence), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutoTaggingExtension = apply { - if (validated) { - return@apply - } - - maxTags() - minConfidence() - name().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** Specifies the auto-tagging extension used. */ - class Name - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") - - @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") - - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } - - /** An enum containing [Name]'s known values. */ - enum class Known { - GOOGLE_AUTO_TAGGING, - AWS_AUTO_TAGGING, - } - - /** - * An enum containing [Name]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Name] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GOOGLE_AUTO_TAGGING, - AWS_AUTO_TAGGING, - /** - * An enum member indicating that [Name] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING - AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value is a - * not a known member. - */ - fun known(): Known = - when (this) { - GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING - AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING - else -> throw ImageKitInvalidDataException("Unknown Name: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value does - * not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Name = apply { - if (validated) { - return@apply - } - - known() - 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 (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Name && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AutoTaggingExtension && - maxTags == other.maxTags && - minConfidence == other.minConfidence && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(maxTags, minConfidence, name, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" - } - } - - class ResponseField - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TAGS = of("tags") - - @JvmField val CUSTOM_COORDINATES = of("customCoordinates") - - @JvmField val IS_PRIVATE_FILE = of("isPrivateFile") - - @JvmField val EMBEDDED_METADATA = of("embeddedMetadata") - - @JvmField val IS_PUBLISHED = of("isPublished") - - @JvmField val CUSTOM_METADATA = of("customMetadata") - - @JvmField val METADATA = of("metadata") - - @JvmStatic fun of(value: String) = ResponseField(JsonField.of(value)) - } - - /** An enum containing [ResponseField]'s known values. */ - enum class Known { - TAGS, - CUSTOM_COORDINATES, - IS_PRIVATE_FILE, - EMBEDDED_METADATA, - IS_PUBLISHED, - CUSTOM_METADATA, - METADATA, - } - - /** - * An enum containing [ResponseField]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ResponseField] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TAGS, - CUSTOM_COORDINATES, - IS_PRIVATE_FILE, - EMBEDDED_METADATA, - IS_PUBLISHED, - CUSTOM_METADATA, - METADATA, - /** - * An enum member indicating that [ResponseField] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TAGS -> Value.TAGS - CUSTOM_COORDINATES -> Value.CUSTOM_COORDINATES - IS_PRIVATE_FILE -> Value.IS_PRIVATE_FILE - EMBEDDED_METADATA -> Value.EMBEDDED_METADATA - IS_PUBLISHED -> Value.IS_PUBLISHED - CUSTOM_METADATA -> Value.CUSTOM_METADATA - METADATA -> Value.METADATA - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TAGS -> Known.TAGS - CUSTOM_COORDINATES -> Known.CUSTOM_COORDINATES - IS_PRIVATE_FILE -> Known.IS_PRIVATE_FILE - EMBEDDED_METADATA -> Known.EMBEDDED_METADATA - IS_PUBLISHED -> Known.IS_PUBLISHED - CUSTOM_METADATA -> Known.CUSTOM_METADATA - METADATA -> Known.METADATA - else -> throw ImageKitInvalidDataException("Unknown ResponseField: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): ResponseField = apply { - if (validated) { - return@apply - } - - known() - 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 (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ResponseField && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for - * reducing file size or applying basic optimizations upfront (e.g., resize, - * compress). - * - `post` — applied immediately after upload. Ideal for generating transformed - * versions (like video encodes or thumbnails) in advance, so they're ready for - * delivery without delay. - * - * You can mix and match any combination of post-processing types. - */ - class Transformation - private constructor( - private val post: MultipartField>, - private val pre: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * List of transformations to apply _after_ the file is uploaded. Each item must - * match one of the following types: `transformation`, `gif-to-video`, `thumbnail`, - * `abs`. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun post(): Optional> = post.value.getOptional("post") - - /** - * Transformation string to apply before uploading the file to the Media Library. - * Useful for optimizing files at ingestion. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun pre(): Optional = pre.value.getOptional("pre") - - /** - * Returns the raw multipart value of [post]. - * - * Unlike [post], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("post") @ExcludeMissing fun _post(): MultipartField> = post - - /** - * Returns the raw multipart value of [pre]. - * - * Unlike [pre], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("pre") @ExcludeMissing fun _pre(): MultipartField = pre - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Transformation]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Transformation]. */ - class Builder internal constructor() { - - private var post: MultipartField>? = null - private var pre: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(transformation: Transformation) = apply { - post = transformation.post.map { it.toMutableList() } - pre = transformation.pre - additionalProperties = transformation.additionalProperties.toMutableMap() - } - - /** - * List of transformations to apply _after_ the file is uploaded. Each item must - * match one of the following types: `transformation`, `gif-to-video`, - * `thumbnail`, `abs`. - */ - fun post(post: List) = post(MultipartField.of(post)) - - /** - * Sets [Builder.post] to an arbitrary multipart value. - * - * You should usually call [Builder.post] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun post(post: MultipartField>) = apply { - this.post = post.map { it.toMutableList() } - } - - /** - * Adds a single [Post] to [Builder.post]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPost(post: Post) = apply { - this.post = - (this.post ?: MultipartField.of(mutableListOf())).also { - checkKnown("post", it).add(post) - } - } - - /** Alias for calling [addPost] with `Post.ofTransformation(transformation)`. */ - fun addPost(transformation: Post.InnerTransformation) = - addPost(Post.ofTransformation(transformation)) - - /** - * Alias for calling [addPost] with the following: - * ```java - * Post.InnerTransformation.builder() - * .value(value) - * .build() - * ``` - */ - fun addTransformationPost(value: String) = - addPost(Post.InnerTransformation.builder().value(value).build()) - - /** Alias for calling [addPost] with `Post.ofGifToVideo(gifToVideo)`. */ - fun addPost(gifToVideo: Post.GifToVideo) = - addPost(Post.ofGifToVideo(gifToVideo)) - - /** Alias for calling [addPost] with `Post.ofThumbnail(thumbnail)`. */ - fun addPost(thumbnail: Post.Thumbnail) = addPost(Post.ofThumbnail(thumbnail)) - - /** Alias for calling [addPost] with `Post.ofAbs(abs)`. */ - fun addPost(abs: Post.Abs) = addPost(Post.ofAbs(abs)) - - /** - * Transformation string to apply before uploading the file to the Media - * Library. Useful for optimizing files at ingestion. - */ - fun pre(pre: String) = pre(MultipartField.of(pre)) - - /** - * Sets [Builder.pre] to an arbitrary multipart value. - * - * You should usually call [Builder.pre] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun pre(pre: MultipartField) = apply { this.pre = pre } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Transformation]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Transformation = - Transformation( - (post ?: MultipartField.of(null)).map { it.toImmutable() }, - pre, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Transformation = apply { - if (validated) { - return@apply - } - - post().ifPresent { it.forEach { it.validate() } } - pre() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - @JsonDeserialize(using = Post.Deserializer::class) - @JsonSerialize(using = Post.Serializer::class) - class Post - private constructor( - private val transformation: InnerTransformation? = null, - private val gifToVideo: GifToVideo? = null, - private val thumbnail: Thumbnail? = null, - private val abs: Abs? = null, - private val _json: JsonValue? = null, - ) { - - fun transformation(): Optional = - Optional.ofNullable(transformation) - - fun gifToVideo(): Optional = Optional.ofNullable(gifToVideo) - - fun thumbnail(): Optional = Optional.ofNullable(thumbnail) - - fun abs(): Optional = Optional.ofNullable(abs) - - fun isTransformation(): Boolean = transformation != null - - fun isGifToVideo(): Boolean = gifToVideo != null - - fun isThumbnail(): Boolean = thumbnail != null - - fun isAbs(): Boolean = abs != null - - fun asTransformation(): InnerTransformation = - transformation.getOrThrow("transformation") - - fun asGifToVideo(): GifToVideo = gifToVideo.getOrThrow("gifToVideo") - - fun asThumbnail(): Thumbnail = thumbnail.getOrThrow("thumbnail") - - fun asAbs(): Abs = abs.getOrThrow("abs") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - transformation != null -> visitor.visitTransformation(transformation) - gifToVideo != null -> visitor.visitGifToVideo(gifToVideo) - thumbnail != null -> visitor.visitThumbnail(thumbnail) - abs != null -> visitor.visitAbs(abs) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Post = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitTransformation( - transformation: InnerTransformation - ) { - transformation.validate() - } - - override fun visitGifToVideo(gifToVideo: GifToVideo) { - gifToVideo.validate() - } - - override fun visitThumbnail(thumbnail: Thumbnail) { - thumbnail.validate() - } - - override fun visitAbs(abs: Abs) { - abs.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitTransformation( - transformation: InnerTransformation - ) = transformation.validity() - - override fun visitGifToVideo(gifToVideo: GifToVideo) = - gifToVideo.validity() - - override fun visitThumbnail(thumbnail: Thumbnail) = - thumbnail.validity() - - override fun visitAbs(abs: Abs) = abs.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Post && - transformation == other.transformation && - gifToVideo == other.gifToVideo && - thumbnail == other.thumbnail && - abs == other.abs - } - - override fun hashCode(): Int = - Objects.hash(transformation, gifToVideo, thumbnail, abs) - - override fun toString(): String = - when { - transformation != null -> "Post{transformation=$transformation}" - gifToVideo != null -> "Post{gifToVideo=$gifToVideo}" - thumbnail != null -> "Post{thumbnail=$thumbnail}" - abs != null -> "Post{abs=$abs}" - _json != null -> "Post{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Post") - } - - companion object { - - @JvmStatic - fun ofTransformation(transformation: InnerTransformation) = - Post(transformation = transformation) - - @JvmStatic - fun ofGifToVideo(gifToVideo: GifToVideo) = Post(gifToVideo = gifToVideo) - - @JvmStatic - fun ofThumbnail(thumbnail: Thumbnail) = Post(thumbnail = thumbnail) - - @JvmStatic fun ofAbs(abs: Abs) = Post(abs = abs) - } - - /** - * An interface that defines how to map each variant of [Post] to a value of - * type [T]. - */ - interface Visitor { - - fun visitTransformation(transformation: InnerTransformation): T - - fun visitGifToVideo(gifToVideo: GifToVideo): T - - fun visitThumbnail(thumbnail: Thumbnail): T - - fun visitAbs(abs: Abs): T - - /** - * Maps an unknown variant of [Post] to a value of type [T]. - * - * An instance of [Post] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, - * if the SDK is on an older version than the API, then the API may respond - * with new variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Post: $json") - } - } - - internal class Deserializer : BaseDeserializer(Post::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Post { - val json = JsonValue.fromJsonNode(node) - val type = - json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - - when (type) { - "transformation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Post(transformation = it, _json = json) } - ?: Post(_json = json) - } - "gif-to-video" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(gifToVideo = it, _json = json) - } ?: Post(_json = json) - } - "thumbnail" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(thumbnail = it, _json = json) - } ?: Post(_json = json) - } - "abs" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(abs = it, _json = json) - } ?: Post(_json = json) - } - } - - return Post(_json = json) - } - } - - internal class Serializer : BaseSerializer(Post::class) { - - override fun serialize( - value: Post, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.transformation != null -> - generator.writeObject(value.transformation) - value.gifToVideo != null -> generator.writeObject(value.gifToVideo) - value.thumbnail != null -> generator.writeObject(value.thumbnail) - value.abs != null -> generator.writeObject(value.abs) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Post") - } - } - } - - class InnerTransformation - private constructor( - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Transformation type. - * - * Expected to always return the following: - * ```java - * JsonValue.from("transformation") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit - * URL-based 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 value(): String = value.value.getRequired("value") - - /** - * Returns the raw multipart value of [value]. - * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): MultipartField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InnerTransformation]. - * - * The following fields are required: - * ```java - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerTransformation]. */ - class Builder internal constructor() { - - private var type: JsonValue = JsonValue.from("transformation") - private var value: MultipartField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerTransformation: InnerTransformation) = apply { - type = innerTransformation.type - value = innerTransformation.value - additionalProperties = - innerTransformation.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field - * defaults to the following: - * ```java - * JsonValue.from("transformation") - * ``` - * - * This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** - * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit - * URL-based transformations. - */ - fun value(value: String) = value(MultipartField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun value(value: MultipartField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InnerTransformation]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): InnerTransformation = - InnerTransformation( - type, - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false + /** + * Sets [Builder.overwriteFile] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteFile(overwriteFile: MultipartField) = apply { + body.overwriteFile(overwriteFile) + } - fun validate(): InnerTransformation = apply { - if (validated) { - return@apply - } + /** + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + */ + fun overwriteTags(overwriteTags: Boolean) = apply { body.overwriteTags(overwriteTags) } - _type().let { - if (it != JsonValue.from("transformation")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - value() - validated = true - } + /** + * Sets [Builder.overwriteTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteTags] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteTags(overwriteTags: MultipartField) = apply { + body.overwriteTags(overwriteTags) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + /** + * Your ImageKit.io public key. This field is only required for authentication when + * uploading a file from the client side. + */ + fun publicKey(publicKey: String) = apply { body.publicKey(publicKey) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.publicKey] to an arbitrary multipart value. + * + * You should usually call [Builder.publicKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun publicKey(publicKey: MultipartField) = apply { body.publicKey(publicKey) } - return other is InnerTransformation && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } + /** Array of response field keys to include in the API response body. */ + fun responseFields(responseFields: List) = apply { + body.responseFields(responseFields) + } - private val hashCode: Int by lazy { - Objects.hash(type, value, additionalProperties) - } + /** + * Sets [Builder.responseFields] to an arbitrary multipart value. + * + * You should usually call [Builder.responseFields] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun responseFields(responseFields: MultipartField>) = apply { + body.responseFields(responseFields) + } - override fun hashCode(): Int = hashCode + /** + * Adds a single [ResponseField] to [responseFields]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResponseField(responseField: ResponseField) = apply { + body.addResponseField(responseField) + } - override fun toString() = - "InnerTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" - } + /** + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. + * Learn how to create a signature on the page below. This should be in lowercase. + * + * Signature must be calculated on the server-side. This field is only required for + * authentication when uploading a file from the client side. + */ + fun signature(signature: String) = apply { body.signature(signature) } - class GifToVideo - private constructor( - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.signature] to an arbitrary multipart value. + * + * You should usually call [Builder.signature] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun signature(signature: MultipartField) = apply { body.signature(signature) } - /** - * Converts an animated GIF into an MP4. - * - * Expected to always return the following: - * ```java - * JsonValue.from("gif-to-video") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", + * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the + * `%` character is not allowed. If this field is not specified and the file is overwritten, + * the existing tags will be removed. + */ + fun tags(tags: List) = apply { body.tags(tags) } - /** - * Optional transformation string to apply to the output video. **Example**: - * `q-80` - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun value(): Optional = value.value.getOptional("value") + /** + * Sets [Builder.tags] to an arbitrary multipart value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: MultipartField>) = apply { body.tags(tags) } - /** - * Returns the raw multipart value of [value]. - * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): MultipartField = value + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { body.addTag(tag) } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing + * file size or applying basic optimizations upfront (e.g., resize, compress). + * - `post` — applied immediately after upload. Ideal for generating transformed versions + * (like video encodes or thumbnails) in advance, so they're ready for delivery without + * delay. + * + * You can mix and match any combination of post-processing types. + */ + fun transformation(transformation: Transformation) = apply { + body.transformation(transformation) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.transformation] to an arbitrary multipart value. + * + * You should usually call [Builder.transformation] with a well-typed [Transformation] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun transformation(transformation: MultipartField) = apply { + body.transformation(transformation) + } - fun toBuilder() = Builder().from(this) + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique + * filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any + * existing file with the same name is replaced. + */ + fun useUniqueFileName(useUniqueFileName: Boolean) = apply { + body.useUniqueFileName(useUniqueFileName) + } - companion object { + /** + * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. + * + * You should usually call [Builder.useUniqueFileName] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useUniqueFileName(useUniqueFileName: MultipartField) = apply { + body.useUniqueFileName(useUniqueFileName) + } - /** - * Returns a mutable builder for constructing an instance of - * [GifToVideo]. - */ - @JvmStatic fun builder() = Builder() - } + /** + * The final status of extensions after they have completed execution will be delivered to + * this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + */ + fun webhookUrl(webhookUrl: String) = apply { body.webhookUrl(webhookUrl) } - /** A builder for [GifToVideo]. */ - class Builder internal constructor() { + /** + * Sets [Builder.webhookUrl] to an arbitrary multipart value. + * + * You should usually call [Builder.webhookUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun webhookUrl(webhookUrl: MultipartField) = apply { body.webhookUrl(webhookUrl) } - private var type: JsonValue = JsonValue.from("gif-to-video") - private var value: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = - mutableMapOf() + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - @JvmSynthetic - internal fun from(gifToVideo: GifToVideo) = apply { - type = gifToVideo.type - value = gifToVideo.value - additionalProperties = - gifToVideo.additionalProperties.toMutableMap() - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field - * defaults to the following: - * ```java - * JsonValue.from("gif-to-video") - * ``` - * - * This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** - * Optional transformation string to apply to the output video. - * **Example**: `q-80` - */ - fun value(value: String) = value(MultipartField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun value(value: MultipartField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - /** - * Returns an immutable instance of [GifToVideo]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): GifToVideo = - GifToVideo(type, value, additionalProperties.toMutableMap()) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - private var validated: Boolean = false + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun validate(): GifToVideo = apply { - if (validated) { - return@apply - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - _type().let { - if (it != JsonValue.from("gif-to-video")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - value() - validated = true - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - return other is GifToVideo && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - private val hashCode: Int by lazy { - Objects.hash(type, value, additionalProperties) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - override fun hashCode(): Int = hashCode + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - override fun toString() = - "GifToVideo{type=$type, value=$value, additionalProperties=$additionalProperties}" - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - class Thumbnail - private constructor( - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - /** - * Generates a thumbnail image. - * - * Expected to always return the following: - * ```java - * JsonValue.from("thumbnail") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - /** - * Optional transformation string. **Example**: `w-150,h-150` - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun value(): Optional = value.value.getOptional("value") + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - /** - * Returns the raw multipart value of [value]. - * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): MultipartField = value + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } - fun toBuilder() = Builder().from(this) + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } - companion object { + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - /** - * Returns a mutable builder for constructing an instance of - * [Thumbnail]. - */ - @JvmStatic fun builder() = Builder() - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - /** A builder for [Thumbnail]. */ - class Builder internal constructor() { + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } - private var type: JsonValue = JsonValue.from("thumbnail") - private var value: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = - mutableMapOf() + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } - @JvmSynthetic - internal fun from(thumbnail: Thumbnail) = apply { - type = thumbnail.type - value = thumbnail.value - additionalProperties = thumbnail.additionalProperties.toMutableMap() - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field - * defaults to the following: - * ```java - * JsonValue.from("thumbnail") - * ``` - * - * This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** Optional transformation string. **Example**: `w-150,h-150` */ - fun value(value: String) = value(MultipartField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun value(value: MultipartField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Returns an immutable instance of [FileUploadParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .file() + * .fileName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FileUploadParams = + FileUploadParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun _body(): Map> = + (mapOf( + "file" to _file(), + "fileName" to _fileName(), + "token" to _token(), + "checks" to _checks(), + "customCoordinates" to _customCoordinates(), + "customMetadata" to _customMetadata(), + "description" to _description(), + "expire" to _expire(), + "extensions" to _extensions(), + "folder" to _folder(), + "isPrivateFile" to _isPrivateFile(), + "isPublished" to _isPublished(), + "overwriteAITags" to _overwriteAiTags(), + "overwriteCustomMetadata" to _overwriteCustomMetadata(), + "overwriteFile" to _overwriteFile(), + "overwriteTags" to _overwriteTags(), + "publicKey" to _publicKey(), + "responseFields" to _responseFields(), + "signature" to _signature(), + "tags" to _tags(), + "transformation" to _transformation(), + "useUniqueFileName" to _useUniqueFileName(), + "webhookUrl" to _webhookUrl(), + ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) + .toImmutable() - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + override fun _headers(): Headers = additionalHeaders - /** - * Returns an immutable instance of [Thumbnail]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): Thumbnail = - Thumbnail(type, value, additionalProperties.toMutableMap()) - } + override fun _queryParams(): QueryParams = additionalQueryParams - private var validated: Boolean = false + class Body + private constructor( + private val file: MultipartField, + private val fileName: MultipartField, + private val token: MultipartField, + private val checks: MultipartField, + private val customCoordinates: MultipartField, + private val customMetadata: MultipartField, + private val description: MultipartField, + private val expire: MultipartField, + private val extensions: MultipartField>, + private val folder: MultipartField, + private val isPrivateFile: MultipartField, + private val isPublished: MultipartField, + private val overwriteAiTags: MultipartField, + private val overwriteCustomMetadata: MultipartField, + private val overwriteFile: MultipartField, + private val overwriteTags: MultipartField, + private val publicKey: MultipartField, + private val responseFields: MultipartField>, + private val signature: MultipartField, + private val tags: MultipartField>, + private val transformation: MultipartField, + private val useUniqueFileName: MultipartField, + private val webhookUrl: MultipartField, + private val additionalProperties: MutableMap, + ) { - fun validate(): Thumbnail = apply { - if (validated) { - return@apply - } + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + * + * @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 file(): InputStream = file.value.getRequired("file") - _type().let { - if (it != JsonValue.from("thumbnail")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - value() - validated = true - } + /** + * The name with which the file has to be uploaded. The file name can contain: + * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + * - Special Characters: `.`, `-` + * + * Any other character including space will be replaced by `_` + * + * @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 fileName(): String = fileName.value.getRequired("fileName") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + /** + * A unique value that the ImageKit.io server will use to recognize and prevent subsequent + * retries for the same request. We suggest using V4 UUIDs, or another random string with + * enough entropy to avoid collisions. This field is only required for authentication when + * uploading a file from the client side. + * + * **Note**: Sending a value that has been used in the past will result in a validation + * error. Even if your previous request resulted in an error, you should always send a new + * value for this field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun token(): Optional = token.value.getOptional("token") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Server-side checks to run on the asset. Read more about + * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun checks(): Optional = checks.value.getOptional("checks") - return other is Thumbnail && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } + /** + * Define an important area in the image. This is only relevant for image type files. + * - To be passed as a string with the x and y coordinates of the top-left corner, and width + * and height of the area of interest in the format `x,y,width,height`. For example - + * `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates will + * be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customCoordinates(): Optional = + customCoordinates.value.getOptional("customCoordinates") - private val hashCode: Int by lazy { - Objects.hash(type, value, additionalProperties) - } + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields + * before setting these values. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customMetadata(): Optional = + customMetadata.value.getOptional("customMetadata") - override fun hashCode(): Int = hashCode + /** + * Optional text to describe the contents of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.value.getOptional("description") - override fun toString() = - "Thumbnail{type=$type, value=$value, additionalProperties=$additionalProperties}" - } + /** + * The time until your signature is valid. It must be a + * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. + * It should be in seconds. This field is only required for authentication when uploading a + * file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun expire(): Optional = expire.value.getOptional("expire") - class Abs - private constructor( - private val protocol: MultipartField, - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { + /** + * Array of extensions to be applied to the image. Each extension can be configured with + * specific parameters based on the extension type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun extensions(): Optional> = extensions.value.getOptional("extensions") - /** - * Streaming protocol to use (`hls` or `dash`). - * - * @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 protocol(): Protocol = protocol.value.getRequired("protocol") + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't exist + * before, a new folder(s) is created. + * + * The folder name can contain: + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun folder(): Optional = folder.value.getOptional("folder") - /** - * Adaptive Bitrate Streaming (ABS) setup. - * - * Expected to always return the following: - * ```java - * JsonValue.from("abs") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named + * transformation or signed URL. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isPrivateFile(): Optional = isPrivateFile.value.getOptional("isPrivateFile") - /** - * List of different representations you want to create separated by an - * underscore. - * - * @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 value(): String = value.value.getRequired("value") + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file only + * via the media library. Files in draft or unpublished state can only be publicly accessed + * after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing plans. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isPublished(): Optional = isPublished.value.getOptional("isPublished") - /** - * Returns the raw multipart value of [protocol]. - * - * Unlike [protocol], this method doesn't throw if the multipart field has - * an unexpected type. - */ - @JsonProperty("protocol") - @ExcludeMissing - fun _protocol(): MultipartField = protocol + /** + * If set to `true` and a file already exists at the exact location, its AITags will be + * removed. Set `overwriteAITags` to `false` to preserve AITags. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun overwriteAiTags(): Optional = + overwriteAiTags.value.getOptional("overwriteAITags") - /** - * Returns the raw multipart value of [value]. - * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): MultipartField = value + /** + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun overwriteCustomMetadata(): Optional = + overwriteCustomMetadata.value.getOptional("overwriteCustomMetadata") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the + * exact location, upload API will return an error immediately. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun overwriteFile(): Optional = overwriteFile.value.getOptional("overwriteFile") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Abs]. - * - * The following fields are required: - * ```java - * .protocol() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun overwriteTags(): Optional = overwriteTags.value.getOptional("overwriteTags") - /** A builder for [Abs]. */ - class Builder internal constructor() { - - private var protocol: MultipartField? = null - private var type: JsonValue = JsonValue.from("abs") - private var value: MultipartField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(abs: Abs) = apply { - protocol = abs.protocol - type = abs.type - value = abs.value - additionalProperties = abs.additionalProperties.toMutableMap() - } + /** + * Your ImageKit.io public key. This field is only required for authentication when + * uploading a file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun publicKey(): Optional = publicKey.value.getOptional("publicKey") - /** Streaming protocol to use (`hls` or `dash`). */ - fun protocol(protocol: Protocol) = protocol(MultipartField.of(protocol)) - - /** - * Sets [Builder.protocol] to an arbitrary multipart value. - * - * You should usually call [Builder.protocol] with a well-typed - * [Protocol] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun protocol(protocol: MultipartField) = apply { - this.protocol = protocol - } + /** + * Array of response field keys to include in the API response body. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun responseFields(): Optional> = + responseFields.value.getOptional("responseFields") - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field - * defaults to the following: - * ```java - * JsonValue.from("abs") - * ``` - * - * This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** - * List of different representations you want to create separated by an - * underscore. - */ - fun value(value: String) = value(MultipartField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun value(value: MultipartField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. + * Learn how to create a signature on the page below. This should be in lowercase. + * + * Signature must be calculated on the server-side. This field is only required for + * authentication when uploading a file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun signature(): Optional = signature.value.getOptional("signature") - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", + * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the + * `%` character is not allowed. If this field is not specified and the file is overwritten, + * the existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tags(): Optional> = tags.value.getOptional("tags") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing + * file size or applying basic optimizations upfront (e.g., resize, compress). + * - `post` — applied immediately after upload. Ideal for generating transformed versions + * (like video encodes or thumbnails) in advance, so they're ready for delivery without + * delay. + * + * You can mix and match any combination of post-processing types. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun transformation(): Optional = + transformation.value.getOptional("transformation") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique + * filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any + * existing file with the same name is replaced. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun useUniqueFileName(): Optional = + useUniqueFileName.value.getOptional("useUniqueFileName") - /** - * Returns an immutable instance of [Abs]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .protocol() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Abs = - Abs( - checkRequired("protocol", protocol), - type, - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } + /** + * The final status of extensions after they have completed execution will be delivered to + * this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookUrl(): Optional = webhookUrl.value.getOptional("webhookUrl") - private var validated: Boolean = false + /** + * Returns the raw multipart value of [file]. + * + * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField = file - fun validate(): Abs = apply { - if (validated) { - return@apply - } + /** + * Returns the raw multipart value of [fileName]. + * + * Unlike [fileName], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("fileName") @ExcludeMissing fun _fileName(): MultipartField = fileName - protocol().validate() - _type().let { - if (it != JsonValue.from("abs")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - value() - validated = true - } + /** + * Returns the raw multipart value of [token]. + * + * Unlike [token], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): MultipartField = token - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + /** + * Returns the raw multipart value of [checks]. + * + * Unlike [checks], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("checks") @ExcludeMissing fun _checks(): MultipartField = checks - /** Streaming protocol to use (`hls` or `dash`). */ - class Protocol - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * Returns the raw multipart value of [customCoordinates]. + * + * Unlike [customCoordinates], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("customCoordinates") + @ExcludeMissing + fun _customCoordinates(): MultipartField = customCoordinates - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from - * data that doesn't match any known member, and you want to know that - * value. For example, if the SDK is on an older version than the API, - * then the API may respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * Returns the raw multipart value of [customMetadata]. + * + * Unlike [customMetadata], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): MultipartField = customMetadata - companion object { + /** + * Returns the raw multipart value of [description]. + * + * Unlike [description], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): MultipartField = description - @JvmField val HLS = of("hls") + /** + * Returns the raw multipart value of [expire]. + * + * Unlike [expire], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("expire") @ExcludeMissing fun _expire(): MultipartField = expire - @JvmField val DASH = of("dash") + /** + * Returns the raw multipart value of [extensions]. + * + * Unlike [extensions], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("extensions") + @ExcludeMissing + fun _extensions(): MultipartField> = extensions - @JvmStatic fun of(value: String) = Protocol(JsonField.of(value)) - } + /** + * Returns the raw multipart value of [folder]. + * + * Unlike [folder], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("folder") @ExcludeMissing fun _folder(): MultipartField = folder - /** An enum containing [Protocol]'s known values. */ - enum class Known { - HLS, - DASH, - } + /** + * Returns the raw multipart value of [isPrivateFile]. + * + * Unlike [isPrivateFile], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("isPrivateFile") + @ExcludeMissing + fun _isPrivateFile(): MultipartField = isPrivateFile - /** - * An enum containing [Protocol]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [Protocol] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. - * For example, if the SDK is on an older version than the API, then - * the API may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - HLS, - DASH, - /** - * An enum member indicating that [Protocol] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } + /** + * Returns the raw multipart value of [isPublished]. + * + * Unlike [isPublished], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("isPublished") + @ExcludeMissing + fun _isPublished(): MultipartField = isPublished - /** - * Returns an enum member corresponding to this class instance's value, - * or [Value._UNKNOWN] if the class was instantiated with an unknown - * value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - HLS -> Value.HLS - DASH -> Value.DASH - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is - * always known and don't want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value - * is a not a known member. - */ - fun known(): Known = - when (this) { - HLS -> Known.HLS - DASH -> Known.DASH - else -> - throw ImageKitInvalidDataException( - "Unknown Protocol: $value" - ) - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is - * primarily for debugging and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value - * does not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Protocol = apply { - if (validated) { - return@apply - } - - known() - validated = true - } + /** + * Returns the raw multipart value of [overwriteAiTags]. + * + * Unlike [overwriteAiTags], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteAITags") + @ExcludeMissing + fun _overwriteAiTags(): MultipartField = overwriteAiTags - 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 (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Protocol && value == other.value - } + /** + * Returns the raw multipart value of [overwriteCustomMetadata]. + * + * Unlike [overwriteCustomMetadata], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteCustomMetadata") + @ExcludeMissing + fun _overwriteCustomMetadata(): MultipartField = overwriteCustomMetadata - override fun hashCode() = value.hashCode() + /** + * Returns the raw multipart value of [overwriteFile]. + * + * Unlike [overwriteFile], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteFile") + @ExcludeMissing + fun _overwriteFile(): MultipartField = overwriteFile - override fun toString() = value.toString() - } + /** + * Returns the raw multipart value of [overwriteTags]. + * + * Unlike [overwriteTags], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteTags") + @ExcludeMissing + fun _overwriteTags(): MultipartField = overwriteTags - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw multipart value of [publicKey]. + * + * Unlike [publicKey], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("publicKey") + @ExcludeMissing + fun _publicKey(): MultipartField = publicKey - return other is Abs && - protocol == other.protocol && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw multipart value of [responseFields]. + * + * Unlike [responseFields], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("responseFields") + @ExcludeMissing + fun _responseFields(): MultipartField> = responseFields - private val hashCode: Int by lazy { - Objects.hash(protocol, type, value, additionalProperties) - } + /** + * Returns the raw multipart value of [signature]. + * + * Unlike [signature], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("signature") + @ExcludeMissing + fun _signature(): MultipartField = signature - override fun hashCode(): Int = hashCode + /** + * Returns the raw multipart value of [tags]. + * + * Unlike [tags], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): MultipartField> = tags - override fun toString() = - "Abs{protocol=$protocol, type=$type, value=$value, additionalProperties=$additionalProperties}" - } - } + /** + * Returns the raw multipart value of [transformation]. + * + * Unlike [transformation], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("transformation") + @ExcludeMissing + fun _transformation(): MultipartField = transformation - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw multipart value of [useUniqueFileName]. + * + * Unlike [useUniqueFileName], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("useUniqueFileName") + @ExcludeMissing + fun _useUniqueFileName(): MultipartField = useUniqueFileName - return other is Transformation && - post == other.post && - pre == other.pre && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw multipart value of [webhookUrl]. + * + * Unlike [webhookUrl], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("webhookUrl") + @ExcludeMissing + fun _webhookUrl(): MultipartField = webhookUrl - private val hashCode: Int by lazy { Objects.hash(post, pre, additionalProperties) } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun hashCode(): Int = hashCode + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun toString() = - "Transformation{post=$post, pre=$pre, additionalProperties=$additionalProperties}" - } + fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + companion object { - return other is FileUploadV1 && - file == other.file && - fileName == other.fileName && - token == other.token && - checks == other.checks && - customCoordinates == other.customCoordinates && - customMetadata == other.customMetadata && - description == other.description && - expire == other.expire && - extensions == other.extensions && - folder == other.folder && - isPrivateFile == other.isPrivateFile && - isPublished == other.isPublished && - overwriteAiTags == other.overwriteAiTags && - overwriteCustomMetadata == other.overwriteCustomMetadata && - overwriteFile == other.overwriteFile && - overwriteTags == other.overwriteTags && - publicKey == other.publicKey && - responseFields == other.responseFields && - signature == other.signature && - tags == other.tags && - transformation == other.transformation && - useUniqueFileName == other.useUniqueFileName && - webhookUrl == other.webhookUrl && - additionalProperties == other.additionalProperties - } + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .file() + * .fileName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - private val hashCode: Int by lazy { - Objects.hash( - file, - fileName, - token, - checks, - customCoordinates, - customMetadata, - description, - expire, - extensions, - folder, - isPrivateFile, - isPublished, - overwriteAiTags, - overwriteCustomMetadata, - overwriteFile, - overwriteTags, - publicKey, - responseFields, - signature, - tags, - transformation, - useUniqueFileName, - webhookUrl, - additionalProperties, - ) + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var file: MultipartField? = null + private var fileName: MultipartField? = null + private var token: MultipartField = MultipartField.of(null) + private var checks: MultipartField = MultipartField.of(null) + private var customCoordinates: MultipartField = MultipartField.of(null) + private var customMetadata: MultipartField = MultipartField.of(null) + private var description: MultipartField = MultipartField.of(null) + private var expire: MultipartField = MultipartField.of(null) + private var extensions: MultipartField>? = null + private var folder: MultipartField = MultipartField.of(null) + private var isPrivateFile: MultipartField = MultipartField.of(null) + private var isPublished: MultipartField = MultipartField.of(null) + private var overwriteAiTags: MultipartField = MultipartField.of(null) + private var overwriteCustomMetadata: MultipartField = MultipartField.of(null) + private var overwriteFile: MultipartField = MultipartField.of(null) + private var overwriteTags: MultipartField = MultipartField.of(null) + private var publicKey: MultipartField = MultipartField.of(null) + private var responseFields: MultipartField>? = null + private var signature: MultipartField = MultipartField.of(null) + private var tags: MultipartField>? = null + private var transformation: MultipartField = MultipartField.of(null) + private var useUniqueFileName: MultipartField = MultipartField.of(null) + private var webhookUrl: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + file = body.file + fileName = body.fileName + token = body.token + checks = body.checks + customCoordinates = body.customCoordinates + customMetadata = body.customMetadata + description = body.description + expire = body.expire + extensions = body.extensions.map { it.toMutableList() } + folder = body.folder + isPrivateFile = body.isPrivateFile + isPublished = body.isPublished + overwriteAiTags = body.overwriteAiTags + overwriteCustomMetadata = body.overwriteCustomMetadata + overwriteFile = body.overwriteFile + overwriteTags = body.overwriteTags + publicKey = body.publicKey + responseFields = body.responseFields.map { it.toMutableList() } + signature = body.signature + tags = body.tags.map { it.toMutableList() } + transformation = body.transformation + useUniqueFileName = body.useUniqueFileName + webhookUrl = body.webhookUrl + additionalProperties = body.additionalProperties.toMutableMap() } - override fun hashCode(): Int = hashCode + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(file: InputStream) = file(MultipartField.of(file)) - override fun toString() = - "FileUploadV1{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, expire=$expire, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, publicKey=$publicKey, responseFields=$responseFields, signature=$signature, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.file] to an arbitrary multipart value. + * + * You should usually call [Builder.file] with a well-typed [InputStream] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun file(file: MultipartField) = apply { this.file = file } - class FileUploadV1ByUrl - private constructor( - private val file: MultipartField, - private val fileName: MultipartField, - private val token: MultipartField, - private val checks: MultipartField, - private val customCoordinates: MultipartField, - private val customMetadata: MultipartField, - private val description: MultipartField, - private val expire: MultipartField, - private val extensions: MultipartField>, - private val folder: MultipartField, - private val isPrivateFile: MultipartField, - private val isPublished: MultipartField, - private val overwriteAiTags: MultipartField, - private val overwriteCustomMetadata: MultipartField, - private val overwriteFile: MultipartField, - private val overwriteTags: MultipartField, - private val publicKey: MultipartField, - private val responseFields: MultipartField>, - private val signature: MultipartField, - private val tags: MultipartField>, - private val transformation: MultipartField, - private val useUniqueFileName: MultipartField, - private val webhookUrl: MultipartField, - private val additionalProperties: MutableMap, - ) { + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(file: ByteArray) = file(file.inputStream()) /** - * A publicly reachable URL that ImageKit’s servers can fetch. The server must receive - * the response headers within 8 seconds; otherwise the request fails with 400 Bad - * Request. + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. * - * @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). + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. */ - fun file(): String = file.value.getRequired("file") + fun file(path: Path) = + file( + MultipartField.builder() + .value(path.inputStream()) + .filename(path.name) + .build() + ) /** * The name with which the file has to be uploaded. The file name can contain: @@ -4501,12 +1833,17 @@ private constructor( * - Special Characters: `.`, `-` * * Any other character including space will be replaced by `_` + */ + fun fileName(fileName: String) = fileName(MultipartField.of(fileName)) + + /** + * Sets [Builder.fileName] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * You should usually call [Builder.fileName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun fileName(): String = fileName.value.getRequired("fileName") + fun fileName(fileName: MultipartField) = apply { this.fileName = fileName } /** * A unique value that the ImageKit.io server will use to recognize and prevent @@ -4517,20 +1854,32 @@ private constructor( * **Note**: Sending a value that has been used in the past will result in a validation * error. Even if your previous request resulted in an error, you should always send a * new value for this field. + */ + fun token(token: String) = token(MultipartField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun token(): Optional = token.value.getOptional("token") + fun token(token: MultipartField) = apply { this.token = token } /** * Server-side checks to run on the asset. Read more about * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + */ + fun checks(checks: String) = checks(MultipartField.of(checks)) + + /** + * Sets [Builder.checks] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.checks] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun checks(): Optional = checks.value.getOptional("checks") + fun checks(checks: MultipartField) = apply { this.checks = checks } /** * Define an important area in the image. This is only relevant for image type files. @@ -4540,50 +1889,109 @@ private constructor( * - Can be used with fo-customtransformation. * - If this field is not specified and the file is overwritten, then customCoordinates * will be removed. + */ + fun customCoordinates(customCoordinates: String) = + customCoordinates(MultipartField.of(customCoordinates)) + + /** + * Sets [Builder.customCoordinates] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.customCoordinates] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun customCoordinates(): Optional = - customCoordinates.value.getOptional("customCoordinates") + fun customCoordinates(customCoordinates: MultipartField) = apply { + this.customCoordinates = customCoordinates + } /** * JSON key-value pairs to associate with the asset. Create the custom metadata fields * before setting these values. + */ + fun customMetadata(customMetadata: CustomMetadata) = + customMetadata(MultipartField.of(customMetadata)) + + /** + * Sets [Builder.customMetadata] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.customMetadata] with a well-typed [CustomMetadata] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun customMetadata(): Optional = - customMetadata.value.getOptional("customMetadata") + fun customMetadata(customMetadata: MultipartField) = apply { + this.customMetadata = customMetadata + } + + /** Optional text to describe the contents of the file. */ + fun description(description: String) = description(MultipartField.of(description)) /** - * Optional text to describe the contents of the file. + * Sets [Builder.description] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected 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(): Optional = description.value.getOptional("description") + fun description(description: MultipartField) = apply { + this.description = description + } /** * The time until your signature is valid. It must be a * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the * future. It should be in seconds. This field is only required for authentication when * uploading a file from the client side. + */ + fun expire(expire: Long) = expire(MultipartField.of(expire)) + + /** + * Sets [Builder.expire] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.expire] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun expire(): Optional = expire.value.getOptional("expire") + fun expire(expire: MultipartField) = apply { this.expire = expire } /** * Array of extensions to be applied to the image. Each extension can be configured with * specific parameters based on the extension type. + */ + fun extensions(extensions: List) = extensions(MultipartField.of(extensions)) + + /** + * Sets [Builder.extensions] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.extensions] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun extensions(extensions: MultipartField>) = apply { + this.extensions = extensions.map { it.toMutableList() } + } + + /** + * Adds a single [Extension] to [extensions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun extensions(): Optional> = extensions.value.getOptional("extensions") + fun addExtension(extension: Extension) = apply { + extensions = + (extensions ?: MultipartField.of(mutableListOf())).also { + checkKnown("extensions", it).add(extension) + } + } + + /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ + fun addExtension(removeBg: Extension.RemoveBg) = + addExtension(Extension.ofRemoveBg(removeBg)) + + /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = + addExtension(Extension.ofAutoTagging(autoTagging)) + + /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ + fun addExtensionAiAutoDescription() = addExtension(Extension.ofAiAutoDescription()) /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist @@ -4594,380 +2002,795 @@ private constructor( * - Special Characters: `/` , `_` , `-` * * Using multiple `/` creates a nested folder. + */ + fun folder(folder: String) = folder(MultipartField.of(folder)) + + /** + * Sets [Builder.folder] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.folder] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun folder(folder: MultipartField) = apply { this.folder = folder } + + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named + * transformation or signed URL. + */ + fun isPrivateFile(isPrivateFile: Boolean) = + isPrivateFile(MultipartField.of(isPrivateFile)) + + /** + * Sets [Builder.isPrivateFile] to an arbitrary multipart value. + * + * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPrivateFile(isPrivateFile: MultipartField) = apply { + this.isPrivateFile = isPrivateFile + } + + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file + * only via the media library. Files in draft or unpublished state can only be publicly + * accessed after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing + * plans. + */ + fun isPublished(isPublished: Boolean) = isPublished(MultipartField.of(isPublished)) + + /** + * Sets [Builder.isPublished] to an arbitrary multipart value. + * + * You should usually call [Builder.isPublished] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPublished(isPublished: MultipartField) = apply { + this.isPublished = isPublished + } + + /** + * If set to `true` and a file already exists at the exact location, its AITags will be + * removed. Set `overwriteAITags` to `false` to preserve AITags. + */ + fun overwriteAiTags(overwriteAiTags: Boolean) = + overwriteAiTags(MultipartField.of(overwriteAiTags)) + + /** + * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteAiTags] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteAiTags(overwriteAiTags: MultipartField) = apply { + this.overwriteAiTags = overwriteAiTags + } + + /** + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: Boolean) = + overwriteCustomMetadata(MultipartField.of(overwriteCustomMetadata)) + + /** + * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteCustomMetadata] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: MultipartField) = apply { + this.overwriteCustomMetadata = overwriteCustomMetadata + } + + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the + * exact location, upload API will return an error immediately. + */ + fun overwriteFile(overwriteFile: Boolean) = + overwriteFile(MultipartField.of(overwriteFile)) + + /** + * Sets [Builder.overwriteFile] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteFile(overwriteFile: MultipartField) = apply { + this.overwriteFile = overwriteFile + } + + /** + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + */ + fun overwriteTags(overwriteTags: Boolean) = + overwriteTags(MultipartField.of(overwriteTags)) + + /** + * Sets [Builder.overwriteTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteTags] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteTags(overwriteTags: MultipartField) = apply { + this.overwriteTags = overwriteTags + } + + /** + * Your ImageKit.io public key. This field is only required for authentication when + * uploading a file from the client side. + */ + fun publicKey(publicKey: String) = publicKey(MultipartField.of(publicKey)) + + /** + * Sets [Builder.publicKey] to an arbitrary multipart value. + * + * You should usually call [Builder.publicKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun publicKey(publicKey: MultipartField) = apply { this.publicKey = publicKey } + + /** Array of response field keys to include in the API response body. */ + fun responseFields(responseFields: List) = + responseFields(MultipartField.of(responseFields)) + + /** + * Sets [Builder.responseFields] to an arbitrary multipart value. + * + * You should usually call [Builder.responseFields] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun responseFields(responseFields: MultipartField>) = apply { + this.responseFields = responseFields.map { it.toMutableList() } + } + + /** + * Adds a single [ResponseField] to [responseFields]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResponseField(responseField: ResponseField) = apply { + responseFields = + (responseFields ?: MultipartField.of(mutableListOf())).also { + checkKnown("responseFields", it).add(responseField) + } + } + + /** + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. + * Learn how to create a signature on the page below. This should be in lowercase. + * + * Signature must be calculated on the server-side. This field is only required for + * authentication when uploading a file from the client side. + */ + fun signature(signature: String) = signature(MultipartField.of(signature)) + + /** + * Sets [Builder.signature] to an arbitrary multipart value. + * + * You should usually call [Builder.signature] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun folder(): Optional = folder.value.getOptional("folder") + fun signature(signature: MultipartField) = apply { this.signature = signature } /** - * Whether to mark the file as private or not. - * - * If `true`, the file is marked as private and is accessible only using named - * transformation or signed URL. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * Set the tags while uploading the file. Provide an array of tag strings (e.g. + * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not + * exceed 500, and the `%` character is not allowed. If this field is not specified and + * the file is overwritten, the existing tags will be removed. */ - fun isPrivateFile(): Optional = - isPrivateFile.value.getOptional("isPrivateFile") + fun tags(tags: List) = tags(MultipartField.of(tags)) /** - * Whether to upload file as published or not. - * - * If `false`, the file is marked as unpublished, which restricts access to the file - * only via the media library. Files in draft or unpublished state can only be publicly - * accessed after being published. + * Sets [Builder.tags] to an arbitrary multipart value. * - * The option to upload in draft state is only available in custom enterprise pricing - * plans. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.tags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun isPublished(): Optional = isPublished.value.getOptional("isPublished") + fun tags(tags: MultipartField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** - * If set to `true` and a file already exists at the exact location, its AITags will be - * removed. Set `overwriteAITags` to `false` to preserve AITags. + * Adds a single [String] to [tags]. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun overwriteAiTags(): Optional = - overwriteAiTags.value.getOptional("overwriteAITags") + fun addTag(tag: String) = apply { + tags = + (tags ?: MultipartField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } /** - * If the request does not have `customMetadata`, and a file already exists at the exact - * location, existing customMetadata will be removed. + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for + * reducing file size or applying basic optimizations upfront (e.g., resize, + * compress). + * - `post` — applied immediately after upload. Ideal for generating transformed + * versions (like video encodes or thumbnails) in advance, so they're ready for + * delivery without delay. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You can mix and match any combination of post-processing types. */ - fun overwriteCustomMetadata(): Optional = - overwriteCustomMetadata.value.getOptional("overwriteCustomMetadata") + fun transformation(transformation: Transformation) = + transformation(MultipartField.of(transformation)) /** - * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the - * exact location, upload API will return an error immediately. + * Sets [Builder.transformation] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.transformation] with a well-typed [Transformation] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun overwriteFile(): Optional = - overwriteFile.value.getOptional("overwriteFile") + fun transformation(transformation: MultipartField) = apply { + this.transformation = transformation + } /** - * If the request does not have `tags`, and a file already exists at the exact location, - * existing tags will be removed. + * Whether to use a unique filename for this file or not. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a + * unique filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any + * existing file with the same name is replaced. */ - fun overwriteTags(): Optional = - overwriteTags.value.getOptional("overwriteTags") + fun useUniqueFileName(useUniqueFileName: Boolean) = + useUniqueFileName(MultipartField.of(useUniqueFileName)) /** - * Your ImageKit.io public key. This field is only required for authentication when - * uploading a file from the client side. + * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.useUniqueFileName] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useUniqueFileName(useUniqueFileName: MultipartField) = apply { + this.useUniqueFileName = useUniqueFileName + } + + /** + * The final status of extensions after they have completed execution will be delivered + * to this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. */ - fun publicKey(): Optional = publicKey.value.getOptional("publicKey") + fun webhookUrl(webhookUrl: String) = webhookUrl(MultipartField.of(webhookUrl)) /** - * Array of response field keys to include in the API response body. + * Sets [Builder.webhookUrl] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.webhookUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun responseFields(): Optional> = - responseFields.value.getOptional("responseFields") + fun webhookUrl(webhookUrl: MultipartField) = apply { + this.webhookUrl = webhookUrl + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. - * Learn how to create a signature on the page below. This should be in lowercase. + * Returns an immutable instance of [Body]. * - * Signature must be calculated on the server-side. This field is only required for - * authentication when uploading a file from the client side. + * Further updates to this [Builder] will not mutate the returned instance. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * The following fields are required: + * ```java + * .file() + * .fileName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("file", file), + checkRequired("fileName", fileName), + token, + checks, + customCoordinates, + customMetadata, + description, + expire, + (extensions ?: MultipartField.of(null)).map { it.toImmutable() }, + folder, + isPrivateFile, + isPublished, + overwriteAiTags, + overwriteCustomMetadata, + overwriteFile, + overwriteTags, + publicKey, + (responseFields ?: MultipartField.of(null)).map { it.toImmutable() }, + signature, + (tags ?: MultipartField.of(null)).map { it.toImmutable() }, + transformation, + useUniqueFileName, + webhookUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + file() + fileName() + token() + checks() + customCoordinates() + customMetadata().ifPresent { it.validate() } + description() + expire() + extensions().ifPresent { it.forEach { it.validate() } } + folder() + isPrivateFile() + isPublished() + overwriteAiTags() + overwriteCustomMetadata() + overwriteFile() + overwriteTags() + publicKey() + responseFields().ifPresent { it.forEach { it.validate() } } + signature() + tags() + transformation().ifPresent { it.validate() } + useUniqueFileName() + webhookUrl() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + file == other.file && + fileName == other.fileName && + token == other.token && + checks == other.checks && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + description == other.description && + expire == other.expire && + extensions == other.extensions && + folder == other.folder && + isPrivateFile == other.isPrivateFile && + isPublished == other.isPublished && + overwriteAiTags == other.overwriteAiTags && + overwriteCustomMetadata == other.overwriteCustomMetadata && + overwriteFile == other.overwriteFile && + overwriteTags == other.overwriteTags && + publicKey == other.publicKey && + responseFields == other.responseFields && + signature == other.signature && + tags == other.tags && + transformation == other.transformation && + useUniqueFileName == other.useUniqueFileName && + webhookUrl == other.webhookUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + file, + fileName, + token, + checks, + customCoordinates, + customMetadata, + description, + expire, + extensions, + folder, + isPrivateFile, + isPublished, + overwriteAiTags, + overwriteCustomMetadata, + overwriteFile, + overwriteTags, + publicKey, + responseFields, + signature, + tags, + transformation, + useUniqueFileName, + webhookUrl, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, expire=$expire, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, publicKey=$publicKey, responseFields=$responseFields, signature=$signature, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + } + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields before + * setting these values. + */ + class CustomMetadata + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CustomMetadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customMetadata: CustomMetadata) = apply { + additionalProperties = customMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. */ - fun signature(): Optional = signature.value.getOptional("signature") + fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CustomMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomMetadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Extension.Deserializer::class) + @JsonSerialize(using = Extension.Serializer::class) + class Extension + private constructor( + private val removeBg: RemoveBg? = null, + private val autoTagging: AutoTaggingExtension? = null, + private val aiAutoDescription: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun removeBg(): Optional = Optional.ofNullable(removeBg) + + fun autoTagging(): Optional = Optional.ofNullable(autoTagging) + + fun aiAutoDescription(): Optional = Optional.ofNullable(aiAutoDescription) + + fun isRemoveBg(): Boolean = removeBg != null + + fun isAutoTagging(): Boolean = autoTagging != null + + fun isAiAutoDescription(): Boolean = aiAutoDescription != null + + fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") + + fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") + + fun asAiAutoDescription(): JsonValue = aiAutoDescription.getOrThrow("aiAutoDescription") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + removeBg != null -> visitor.visitRemoveBg(removeBg) + autoTagging != null -> visitor.visitAutoTagging(autoTagging) + aiAutoDescription != null -> visitor.visitAiAutoDescription(aiAutoDescription) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Extension = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) { + removeBg.validate() + } + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { + autoTagging.validate() + } + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { + aiAutoDescription.let { + if (it != JsonValue.from(mapOf("name" to "ai-auto-description"))) { + throw ImageKitInvalidDataException( + "'aiAutoDescription' is invalid, received $it" + ) + } + } + } + } + ) + 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 = + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() - /** - * Set the tags while uploading the file. Provide an array of tag strings (e.g. - * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not - * exceed 500, and the `%` character is not allowed. If this field is not specified and - * the file is overwritten, the existing tags will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun tags(): Optional> = tags.value.getOptional("tags") + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = + autoTagging.validity() - /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for - * reducing file size or applying basic optimizations upfront (e.g., resize, - * compress). - * - `post` — applied immediately after upload. Ideal for generating transformed - * versions (like video encodes or thumbnails) in advance, so they're ready for - * delivery without delay. - * - * You can mix and match any combination of post-processing types. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun transformation(): Optional = - transformation.value.getOptional("transformation") + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = + aiAutoDescription.let { + if (it == JsonValue.from(mapOf("name" to "ai-auto-description"))) 1 + else 0 + } - /** - * Whether to use a unique filename for this file or not. - * - * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a - * unique filename. - * - * If `false`, then the image is uploaded with the provided filename parameter, and any - * existing file with the same name is replaced. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun useUniqueFileName(): Optional = - useUniqueFileName.value.getOptional("useUniqueFileName") + override fun unknown(json: JsonValue?) = 0 + } + ) - /** - * The final status of extensions after they have completed execution will be delivered - * to this endpoint as a POST request. - * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - * about the webhook payload structure. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun webhookUrl(): Optional = webhookUrl.value.getOptional("webhookUrl") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw multipart value of [file]. - * - * Unlike [file], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField = file + return other is Extension && + removeBg == other.removeBg && + autoTagging == other.autoTagging && + aiAutoDescription == other.aiAutoDescription + } - /** - * Returns the raw multipart value of [fileName]. - * - * Unlike [fileName], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("fileName") - @ExcludeMissing - fun _fileName(): MultipartField = fileName + override fun hashCode(): Int = Objects.hash(removeBg, autoTagging, aiAutoDescription) - /** - * Returns the raw multipart value of [token]. - * - * Unlike [token], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("token") @ExcludeMissing fun _token(): MultipartField = token + override fun toString(): String = + when { + removeBg != null -> "Extension{removeBg=$removeBg}" + autoTagging != null -> "Extension{autoTagging=$autoTagging}" + aiAutoDescription != null -> "Extension{aiAutoDescription=$aiAutoDescription}" + _json != null -> "Extension{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Extension") + } - /** - * Returns the raw multipart value of [checks]. - * - * Unlike [checks], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("checks") @ExcludeMissing fun _checks(): MultipartField = checks + companion object { - /** - * Returns the raw multipart value of [customCoordinates]. - * - * Unlike [customCoordinates], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("customCoordinates") - @ExcludeMissing - fun _customCoordinates(): MultipartField = customCoordinates + @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = Extension(removeBg = removeBg) - /** - * Returns the raw multipart value of [customMetadata]. - * - * Unlike [customMetadata], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("customMetadata") - @ExcludeMissing - fun _customMetadata(): MultipartField = customMetadata + @JvmStatic + fun ofAutoTagging(autoTagging: AutoTaggingExtension) = + Extension(autoTagging = autoTagging) - /** - * Returns the raw multipart value of [description]. - * - * Unlike [description], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): MultipartField = description + @JvmStatic + fun ofAiAutoDescription() = + Extension( + aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) + ) + } - /** - * Returns the raw multipart value of [expire]. - * - * Unlike [expire], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("expire") @ExcludeMissing fun _expire(): MultipartField = expire + /** + * An interface that defines how to map each variant of [Extension] to a value of type [T]. + */ + interface Visitor { - /** - * Returns the raw multipart value of [extensions]. - * - * Unlike [extensions], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("extensions") - @ExcludeMissing - fun _extensions(): MultipartField> = extensions + fun visitRemoveBg(removeBg: RemoveBg): T - /** - * Returns the raw multipart value of [folder]. - * - * Unlike [folder], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("folder") @ExcludeMissing fun _folder(): MultipartField = folder + fun visitAutoTagging(autoTagging: AutoTaggingExtension): T - /** - * Returns the raw multipart value of [isPrivateFile]. - * - * Unlike [isPrivateFile], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("isPrivateFile") - @ExcludeMissing - fun _isPrivateFile(): MultipartField = isPrivateFile + fun visitAiAutoDescription(aiAutoDescription: JsonValue): T /** - * Returns the raw multipart value of [isPublished]. + * Maps an unknown variant of [Extension] to a value of type [T]. * - * Unlike [isPublished], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("isPublished") - @ExcludeMissing - fun _isPublished(): MultipartField = isPublished - - /** - * Returns the raw multipart value of [overwriteAiTags]. + * An instance of [Extension] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. * - * Unlike [overwriteAiTags], this method doesn't throw if the multipart field has an - * unexpected type. + * @throws ImageKitInvalidDataException in the default implementation. */ - @JsonProperty("overwriteAITags") - @ExcludeMissing - fun _overwriteAiTags(): MultipartField = overwriteAiTags + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Extension: $json") + } + } - /** - * Returns the raw multipart value of [overwriteCustomMetadata]. - * - * Unlike [overwriteCustomMetadata], this method doesn't throw if the multipart field - * has an unexpected type. - */ - @JsonProperty("overwriteCustomMetadata") - @ExcludeMissing - fun _overwriteCustomMetadata(): MultipartField = overwriteCustomMetadata + internal class Deserializer : BaseDeserializer(Extension::class) { - /** - * Returns the raw multipart value of [overwriteFile]. - * - * Unlike [overwriteFile], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("overwriteFile") - @ExcludeMissing - fun _overwriteFile(): MultipartField = overwriteFile + override fun ObjectCodec.deserialize(node: JsonNode): Extension { + val json = JsonValue.fromJsonNode(node) + val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() - /** - * Returns the raw multipart value of [overwriteTags]. - * - * Unlike [overwriteTags], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("overwriteTags") - @ExcludeMissing - fun _overwriteTags(): MultipartField = overwriteTags + when (name) { + "remove-bg" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Extension(removeBg = it, _json = json) + } ?: Extension(_json = json) + } + "ai-auto-description" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Extension(aiAutoDescription = it, _json = json) } + ?.takeIf { it.isValid() } ?: Extension(_json = json) + } + } - /** - * Returns the raw multipart value of [publicKey]. - * - * Unlike [publicKey], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("publicKey") - @ExcludeMissing - fun _publicKey(): MultipartField = publicKey + return tryDeserialize(node, jacksonTypeRef())?.let { + Extension(autoTagging = it, _json = json) + } ?: Extension(_json = json) + } + } - /** - * Returns the raw multipart value of [responseFields]. - * - * Unlike [responseFields], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("responseFields") - @ExcludeMissing - fun _responseFields(): MultipartField> = responseFields + internal class Serializer : BaseSerializer(Extension::class) { - /** - * Returns the raw multipart value of [signature]. - * - * Unlike [signature], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("signature") - @ExcludeMissing - fun _signature(): MultipartField = signature + override fun serialize( + value: Extension, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.removeBg != null -> generator.writeObject(value.removeBg) + value.autoTagging != null -> generator.writeObject(value.autoTagging) + value.aiAutoDescription != null -> + generator.writeObject(value.aiAutoDescription) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Extension") + } + } + } - /** - * Returns the raw multipart value of [tags]. - * - * Unlike [tags], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): MultipartField> = tags + class RemoveBg + private constructor( + private val name: JsonValue, + private val options: MultipartField, + private val additionalProperties: MutableMap, + ) { /** - * Returns the raw multipart value of [transformation]. + * Specifies the background removal extension. * - * Unlike [transformation], this method doesn't throw if the multipart field has an - * unexpected type. + * Expected to always return the following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - @JsonProperty("transformation") - @ExcludeMissing - fun _transformation(): MultipartField = transformation + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name /** - * Returns the raw multipart value of [useUniqueFileName]. - * - * Unlike [useUniqueFileName], this method doesn't throw if the multipart field has an - * unexpected type. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("useUniqueFileName") - @ExcludeMissing - fun _useUniqueFileName(): MultipartField = useUniqueFileName + fun options(): Optional = options.value.getOptional("options") /** - * Returns the raw multipart value of [webhookUrl]. + * Returns the raw multipart value of [options]. * - * Unlike [webhookUrl], this method doesn't throw if the multipart field has an - * unexpected type. + * Unlike [options], this method doesn't throw if the multipart field has an unexpected + * type. */ - @JsonProperty("webhookUrl") + @JsonProperty("options") @ExcludeMissing - fun _webhookUrl(): MultipartField = webhookUrl + fun _options(): MultipartField = options @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -4983,558 +2806,543 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveBg]. */ + class Builder internal constructor() { + + private var name: JsonValue = JsonValue.from("remove-bg") + private var options: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removeBg: RemoveBg) = apply { + name = removeBg.name + options = removeBg.options + additionalProperties = removeBg.additionalProperties.toMutableMap() + } + /** - * Returns a mutable builder for constructing an instance of [FileUploadV1ByUrl]. + * Sets the field to an arbitrary JSON value. * - * The following fields are required: + * It is usually unnecessary to call this method because the field defaults to the + * following: * ```java - * .file() - * .fileName() + * JsonValue.from("remove-bg") * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - @JvmStatic fun builder() = Builder() + fun name(name: JsonValue) = apply { this.name = name } + + fun options(options: Options) = options(MultipartField.of(options)) + + /** + * Sets [Builder.options] to an arbitrary multipart value. + * + * You should usually call [Builder.options] with a well-typed [Options] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun options(options: MultipartField) = apply { this.options = options } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemoveBg]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemoveBg = RemoveBg(name, options, additionalProperties.toMutableMap()) } - /** A builder for [FileUploadV1ByUrl]. */ - class Builder internal constructor() { + private var validated: Boolean = false - private var file: MultipartField? = null - private var fileName: MultipartField? = null - private var token: MultipartField = MultipartField.of(null) - private var checks: MultipartField = MultipartField.of(null) - private var customCoordinates: MultipartField = MultipartField.of(null) - private var customMetadata: MultipartField = MultipartField.of(null) - private var description: MultipartField = MultipartField.of(null) - private var expire: MultipartField = MultipartField.of(null) - private var extensions: MultipartField>? = null - private var folder: MultipartField = MultipartField.of(null) - private var isPrivateFile: MultipartField = MultipartField.of(null) - private var isPublished: MultipartField = MultipartField.of(null) - private var overwriteAiTags: MultipartField = MultipartField.of(null) - private var overwriteCustomMetadata: MultipartField = - MultipartField.of(null) - private var overwriteFile: MultipartField = MultipartField.of(null) - private var overwriteTags: MultipartField = MultipartField.of(null) - private var publicKey: MultipartField = MultipartField.of(null) - private var responseFields: MultipartField>? = null - private var signature: MultipartField = MultipartField.of(null) - private var tags: MultipartField>? = null - private var transformation: MultipartField = MultipartField.of(null) - private var useUniqueFileName: MultipartField = MultipartField.of(null) - private var webhookUrl: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = mutableMapOf() + fun validate(): RemoveBg = apply { + if (validated) { + return@apply + } - @JvmSynthetic - internal fun from(fileUploadV1ByUrl: FileUploadV1ByUrl) = apply { - file = fileUploadV1ByUrl.file - fileName = fileUploadV1ByUrl.fileName - token = fileUploadV1ByUrl.token - checks = fileUploadV1ByUrl.checks - customCoordinates = fileUploadV1ByUrl.customCoordinates - customMetadata = fileUploadV1ByUrl.customMetadata - description = fileUploadV1ByUrl.description - expire = fileUploadV1ByUrl.expire - extensions = fileUploadV1ByUrl.extensions.map { it.toMutableList() } - folder = fileUploadV1ByUrl.folder - isPrivateFile = fileUploadV1ByUrl.isPrivateFile - isPublished = fileUploadV1ByUrl.isPublished - overwriteAiTags = fileUploadV1ByUrl.overwriteAiTags - overwriteCustomMetadata = fileUploadV1ByUrl.overwriteCustomMetadata - overwriteFile = fileUploadV1ByUrl.overwriteFile - overwriteTags = fileUploadV1ByUrl.overwriteTags - publicKey = fileUploadV1ByUrl.publicKey - responseFields = fileUploadV1ByUrl.responseFields.map { it.toMutableList() } - signature = fileUploadV1ByUrl.signature - tags = fileUploadV1ByUrl.tags.map { it.toMutableList() } - transformation = fileUploadV1ByUrl.transformation - useUniqueFileName = fileUploadV1ByUrl.useUniqueFileName - webhookUrl = fileUploadV1ByUrl.webhookUrl - additionalProperties = fileUploadV1ByUrl.additionalProperties.toMutableMap() + _name().let { + if (it != JsonValue.from("remove-bg")) { + throw ImageKitInvalidDataException("'name' is invalid, received $it") + } + } + options().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false } - /** - * A publicly reachable URL that ImageKit’s servers can fetch. The server must - * receive the response headers within 8 seconds; otherwise the request fails with - * 400 Bad Request. - */ - fun file(file: String) = file(MultipartField.of(file)) + class Options + private constructor( + private val addShadow: MultipartField, + private val bgColor: MultipartField, + private val bgImageUrl: MultipartField, + private val semitransparency: MultipartField, + private val additionalProperties: MutableMap, + ) { /** - * Sets [Builder.file] to an arbitrary multipart value. + * Whether to add an artificial shadow to the result. Default is false. Note: Adding + * shadows is currently only supported for car photos. * - * You should usually call [Builder.file] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun file(file: MultipartField) = apply { this.file = file } + fun addShadow(): Optional = addShadow.value.getOptional("add_shadow") /** - * The name with which the file has to be uploaded. The file name can contain: - * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - * - Special Characters: `.`, `-` + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or + * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be + * empty. * - * Any other character including space will be replaced by `_` + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun fileName(fileName: String) = fileName(MultipartField.of(fileName)) + fun bgColor(): Optional = bgColor.value.getOptional("bg_color") /** - * Sets [Builder.fileName] to an arbitrary multipart value. + * Sets a background image from a URL. If this parameter is set, `bg_color` must be + * empty. * - * You should usually call [Builder.fileName] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun fileName(fileName: MultipartField) = apply { this.fileName = fileName } + fun bgImageUrl(): Optional = bgImageUrl.value.getOptional("bg_image_url") /** - * A unique value that the ImageKit.io server will use to recognize and prevent - * subsequent retries for the same request. We suggest using V4 UUIDs, or another - * random string with enough entropy to avoid collisions. This field is only - * required for authentication when uploading a file from the client side. + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. * - * **Note**: Sending a value that has been used in the past will result in a - * validation error. Even if your previous request resulted in an error, you should - * always send a new value for this field. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun token(token: String) = token(MultipartField.of(token)) + fun semitransparency(): Optional = + semitransparency.value.getOptional("semitransparency") /** - * Sets [Builder.token] to an arbitrary multipart value. + * Returns the raw multipart value of [addShadow]. * - * You should usually call [Builder.token] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun token(token: MultipartField) = apply { this.token = token } - - /** - * Server-side checks to run on the asset. Read more about - * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + * Unlike [addShadow], this method doesn't throw if the multipart field has an + * unexpected type. */ - fun checks(checks: String) = checks(MultipartField.of(checks)) + @JsonProperty("add_shadow") + @ExcludeMissing + fun _addShadow(): MultipartField = addShadow /** - * Sets [Builder.checks] to an arbitrary multipart value. + * Returns the raw multipart value of [bgColor]. * - * You should usually call [Builder.checks] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * Unlike [bgColor], this method doesn't throw if the multipart field has an + * unexpected type. */ - fun checks(checks: MultipartField) = apply { this.checks = checks } + @JsonProperty("bg_color") + @ExcludeMissing + fun _bgColor(): MultipartField = bgColor /** - * Define an important area in the image. This is only relevant for image type - * files. - * - To be passed as a string with the x and y coordinates of the top-left corner, - * and width and height of the area of interest in the format `x,y,width,height`. - * For example - `10,10,100,100` - * - Can be used with fo-customtransformation. - * - If this field is not specified and the file is overwritten, then - * customCoordinates will be removed. + * Returns the raw multipart value of [bgImageUrl]. + * + * Unlike [bgImageUrl], this method doesn't throw if the multipart field has an + * unexpected type. */ - fun customCoordinates(customCoordinates: String) = - customCoordinates(MultipartField.of(customCoordinates)) + @JsonProperty("bg_image_url") + @ExcludeMissing + fun _bgImageUrl(): MultipartField = bgImageUrl /** - * Sets [Builder.customCoordinates] to an arbitrary multipart value. + * Returns the raw multipart value of [semitransparency]. * - * You should usually call [Builder.customCoordinates] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * Unlike [semitransparency], this method doesn't throw if the multipart field has + * an unexpected type. */ - fun customCoordinates(customCoordinates: MultipartField) = apply { - this.customCoordinates = customCoordinates + @JsonProperty("semitransparency") + @ExcludeMissing + fun _semitransparency(): MultipartField = semitransparency + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** - * JSON key-value pairs to associate with the asset. Create the custom metadata - * fields before setting these values. - */ - fun customMetadata(customMetadata: CustomMetadata) = - customMetadata(MultipartField.of(customMetadata)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Sets [Builder.customMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.customMetadata] with a well-typed - * [CustomMetadata] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun customMetadata(customMetadata: MultipartField) = apply { - this.customMetadata = customMetadata - } + fun toBuilder() = Builder().from(this) - /** Optional text to describe the contents of the file. */ - fun description(description: String) = description(MultipartField.of(description)) + companion object { - /** - * Sets [Builder.description] to an arbitrary multipart 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: MultipartField) = apply { - this.description = description + /** Returns a mutable builder for constructing an instance of [Options]. */ + @JvmStatic fun builder() = Builder() } - /** - * The time until your signature is valid. It must be a - * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the - * future. It should be in seconds. This field is only required for authentication - * when uploading a file from the client side. - */ - fun expire(expire: Long) = expire(MultipartField.of(expire)) + /** A builder for [Options]. */ + class Builder internal constructor() { - /** - * Sets [Builder.expire] to an arbitrary multipart value. - * - * You should usually call [Builder.expire] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun expire(expire: MultipartField) = apply { this.expire = expire } + private var addShadow: MultipartField = MultipartField.of(null) + private var bgColor: MultipartField = MultipartField.of(null) + private var bgImageUrl: MultipartField = MultipartField.of(null) + private var semitransparency: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Array of extensions to be applied to the image. Each extension can be configured - * with specific parameters based on the extension type. - */ - fun extensions(extensions: List) = - extensions(MultipartField.of(extensions)) + @JvmSynthetic + internal fun from(options: Options) = apply { + addShadow = options.addShadow + bgColor = options.bgColor + bgImageUrl = options.bgImageUrl + semitransparency = options.semitransparency + additionalProperties = options.additionalProperties.toMutableMap() + } - /** - * Sets [Builder.extensions] to an arbitrary multipart value. - * - * You should usually call [Builder.extensions] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun extensions(extensions: MultipartField>) = apply { - this.extensions = extensions.map { it.toMutableList() } - } + /** + * Whether to add an artificial shadow to the result. Default is false. Note: + * Adding shadows is currently only supported for car photos. + */ + fun addShadow(addShadow: Boolean) = addShadow(MultipartField.of(addShadow)) - /** - * Adds a single [Extension] to [extensions]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addExtension(extension: Extension) = apply { - extensions = - (extensions ?: MultipartField.of(mutableListOf())).also { - checkKnown("extensions", it).add(extension) - } - } + /** + * Sets [Builder.addShadow] to an arbitrary multipart value. + * + * You should usually call [Builder.addShadow] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun addShadow(addShadow: MultipartField) = apply { + this.addShadow = addShadow + } - /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: Extension.RemoveBg) = - addExtension(Extension.ofRemoveBg(removeBg)) + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or + * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be + * empty. + */ + fun bgColor(bgColor: String) = bgColor(MultipartField.of(bgColor)) - /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: Extension.AutoTaggingExtension) = - addExtension(Extension.ofAutoTagging(autoTagging)) + /** + * Sets [Builder.bgColor] to an arbitrary multipart value. + * + * You should usually call [Builder.bgColor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun bgColor(bgColor: MultipartField) = apply { this.bgColor = bgColor } - /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ - fun addExtensionAiAutoDescription() = addExtension(Extension.ofAiAutoDescription()) + /** + * Sets a background image from a URL. If this parameter is set, `bg_color` must + * be empty. + */ + fun bgImageUrl(bgImageUrl: String) = bgImageUrl(MultipartField.of(bgImageUrl)) - /** - * The folder path in which the image has to be uploaded. If the folder(s) didn't - * exist before, a new folder(s) is created. - * - * The folder name can contain: - * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - * - Special Characters: `/` , `_` , `-` - * - * Using multiple `/` creates a nested folder. - */ - fun folder(folder: String) = folder(MultipartField.of(folder)) + /** + * Sets [Builder.bgImageUrl] to an arbitrary multipart value. + * + * You should usually call [Builder.bgImageUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun bgImageUrl(bgImageUrl: MultipartField) = apply { + this.bgImageUrl = bgImageUrl + } - /** - * Sets [Builder.folder] to an arbitrary multipart value. - * - * You should usually call [Builder.folder] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun folder(folder: MultipartField) = apply { this.folder = folder } + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + */ + fun semitransparency(semitransparency: Boolean) = + semitransparency(MultipartField.of(semitransparency)) - /** - * Whether to mark the file as private or not. - * - * If `true`, the file is marked as private and is accessible only using named - * transformation or signed URL. - */ - fun isPrivateFile(isPrivateFile: Boolean) = - isPrivateFile(MultipartField.of(isPrivateFile)) + /** + * Sets [Builder.semitransparency] to an arbitrary multipart value. + * + * You should usually call [Builder.semitransparency] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun semitransparency(semitransparency: MultipartField) = apply { + this.semitransparency = semitransparency + } - /** - * Sets [Builder.isPrivateFile] to an arbitrary multipart value. - * - * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun isPrivateFile(isPrivateFile: MultipartField) = apply { - this.isPrivateFile = isPrivateFile - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Whether to upload file as published or not. - * - * If `false`, the file is marked as unpublished, which restricts access to the file - * only via the media library. Files in draft or unpublished state can only be - * publicly accessed after being published. - * - * The option to upload in draft state is only available in custom enterprise - * pricing plans. - */ - fun isPublished(isPublished: Boolean) = isPublished(MultipartField.of(isPublished)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.isPublished] to an arbitrary multipart value. - * - * You should usually call [Builder.isPublished] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun isPublished(isPublished: MultipartField) = apply { - this.isPublished = isPublished + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Options]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Options = + Options( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties.toMutableMap(), + ) } - /** - * If set to `true` and a file already exists at the exact location, its AITags will - * be removed. Set `overwriteAITags` to `false` to preserve AITags. - */ - fun overwriteAiTags(overwriteAiTags: Boolean) = - overwriteAiTags(MultipartField.of(overwriteAiTags)) + private var validated: Boolean = false - /** - * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteAiTags] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun overwriteAiTags(overwriteAiTags: MultipartField) = apply { - this.overwriteAiTags = overwriteAiTags + fun validate(): Options = apply { + if (validated) { + return@apply + } + + addShadow() + bgColor() + bgImageUrl() + semitransparency() + validated = true } - /** - * If the request does not have `customMetadata`, and a file already exists at the - * exact location, existing customMetadata will be removed. - */ - fun overwriteCustomMetadata(overwriteCustomMetadata: Boolean) = - overwriteCustomMetadata(MultipartField.of(overwriteCustomMetadata)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - /** - * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteCustomMetadata] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun overwriteCustomMetadata(overwriteCustomMetadata: MultipartField) = - apply { - this.overwriteCustomMetadata = overwriteCustomMetadata + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** - * If `false` and `useUniqueFileName` is also `false`, and a file already exists at - * the exact location, upload API will return an error immediately. - */ - fun overwriteFile(overwriteFile: Boolean) = - overwriteFile(MultipartField.of(overwriteFile)) + return other is Options && + addShadow == other.addShadow && + bgColor == other.bgColor && + bgImageUrl == other.bgImageUrl && + semitransparency == other.semitransparency && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.overwriteFile] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteFile] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun overwriteFile(overwriteFile: MultipartField) = apply { - this.overwriteFile = overwriteFile + private val hashCode: Int by lazy { + Objects.hash( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties, + ) } - /** - * If the request does not have `tags`, and a file already exists at the exact - * location, existing tags will be removed. - */ - fun overwriteTags(overwriteTags: Boolean) = - overwriteTags(MultipartField.of(overwriteTags)) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.overwriteTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteTags] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun overwriteTags(overwriteTags: MultipartField) = apply { - this.overwriteTags = overwriteTags + override fun toString() = + "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** - * Your ImageKit.io public key. This field is only required for authentication when - * uploading a file from the client side. - */ - fun publicKey(publicKey: String) = publicKey(MultipartField.of(publicKey)) + return other is RemoveBg && + name == other.name && + options == other.options && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.publicKey] to an arbitrary multipart value. - * - * You should usually call [Builder.publicKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun publicKey(publicKey: MultipartField) = apply { - this.publicKey = publicKey - } + private val hashCode: Int by lazy { Objects.hash(name, options, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" + } + + class AutoTaggingExtension + private constructor( + private val maxTags: MultipartField, + private val minConfidence: MultipartField, + private val name: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Maximum number of tags to attach to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun maxTags(): Long = maxTags.value.getRequired("maxTags") + + /** + * Minimum confidence level for tags to be considered valid. + * + * @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 minConfidence(): Long = minConfidence.value.getRequired("minConfidence") + + /** + * Specifies the auto-tagging extension used. + * + * @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(): Name = name.value.getRequired("name") + + /** + * Returns the raw multipart value of [maxTags]. + * + * Unlike [maxTags], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("maxTags") @ExcludeMissing fun _maxTags(): MultipartField = maxTags + + /** + * Returns the raw multipart value of [minConfidence]. + * + * Unlike [minConfidence], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("minConfidence") + @ExcludeMissing + fun _minConfidence(): MultipartField = minConfidence - /** Array of response field keys to include in the API response body. */ - fun responseFields(responseFields: List) = - responseFields(MultipartField.of(responseFields)) + /** + * Returns the raw multipart value of [name]. + * + * Unlike [name], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name - /** - * Sets [Builder.responseFields] to an arbitrary multipart value. - * - * You should usually call [Builder.responseFields] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun responseFields(responseFields: MultipartField>) = apply { - this.responseFields = responseFields.map { it.toMutableList() } - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Adds a single [ResponseField] to [responseFields]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addResponseField(responseField: ResponseField) = apply { - responseFields = - (responseFields ?: MultipartField.of(mutableListOf())).also { - checkKnown("responseFields", it).add(responseField) - } - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a - * key. Learn how to create a signature on the page below. This should be in - * lowercase. - * - * Signature must be calculated on the server-side. This field is only required for - * authentication when uploading a file from the client side. - */ - fun signature(signature: String) = signature(MultipartField.of(signature)) + fun toBuilder() = Builder().from(this) + + companion object { /** - * Sets [Builder.signature] to an arbitrary multipart value. + * Returns a mutable builder for constructing an instance of [AutoTaggingExtension]. * - * You should usually call [Builder.signature] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` */ - fun signature(signature: MultipartField) = apply { - this.signature = signature - } + @JvmStatic fun builder() = Builder() + } - /** - * Set the tags while uploading the file. Provide an array of tag strings (e.g. - * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not - * exceed 500, and the `%` character is not allowed. If this field is not specified - * and the file is overwritten, the existing tags will be removed. - */ - fun tags(tags: List) = tags(MultipartField.of(tags)) + /** A builder for [AutoTaggingExtension]. */ + class Builder internal constructor() { - /** - * Sets [Builder.tags] to an arbitrary multipart value. - * - * You should usually call [Builder.tags] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun tags(tags: MultipartField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + private var maxTags: MultipartField? = null + private var minConfidence: MultipartField? = null + private var name: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Adds a single [String] to [tags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTag(tag: String) = apply { - tags = - (tags ?: MultipartField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } + @JvmSynthetic + internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { + maxTags = autoTaggingExtension.maxTags + minConfidence = autoTaggingExtension.minConfidence + name = autoTaggingExtension.name + additionalProperties = autoTaggingExtension.additionalProperties.toMutableMap() } - /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for - * reducing file size or applying basic optimizations upfront (e.g., resize, - * compress). - * - `post` — applied immediately after upload. Ideal for generating transformed - * versions (like video encodes or thumbnails) in advance, so they're ready for - * delivery without delay. - * - * You can mix and match any combination of post-processing types. - */ - fun transformation(transformation: Transformation) = - transformation(MultipartField.of(transformation)) + /** Maximum number of tags to attach to the asset. */ + fun maxTags(maxTags: Long) = maxTags(MultipartField.of(maxTags)) /** - * Sets [Builder.transformation] to an arbitrary multipart value. + * Sets [Builder.maxTags] to an arbitrary multipart value. * - * You should usually call [Builder.transformation] with a well-typed - * [Transformation] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.maxTags] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun transformation(transformation: MultipartField) = apply { - this.transformation = transformation - } + fun maxTags(maxTags: MultipartField) = apply { this.maxTags = maxTags } - /** - * Whether to use a unique filename for this file or not. - * - * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get - * a unique filename. - * - * If `false`, then the image is uploaded with the provided filename parameter, and - * any existing file with the same name is replaced. - */ - fun useUniqueFileName(useUniqueFileName: Boolean) = - useUniqueFileName(MultipartField.of(useUniqueFileName)) + /** Minimum confidence level for tags to be considered valid. */ + fun minConfidence(minConfidence: Long) = + minConfidence(MultipartField.of(minConfidence)) /** - * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. + * Sets [Builder.minConfidence] to an arbitrary multipart value. * - * You should usually call [Builder.useUniqueFileName] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * You should usually call [Builder.minConfidence] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun useUniqueFileName(useUniqueFileName: MultipartField) = apply { - this.useUniqueFileName = useUniqueFileName + fun minConfidence(minConfidence: MultipartField) = apply { + this.minConfidence = minConfidence } - /** - * The final status of extensions after they have completed execution will be - * delivered to this endpoint as a POST request. - * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - * about the webhook payload structure. - */ - fun webhookUrl(webhookUrl: String) = webhookUrl(MultipartField.of(webhookUrl)) + /** Specifies the auto-tagging extension used. */ + fun name(name: Name) = name(MultipartField.of(name)) /** - * Sets [Builder.webhookUrl] to an arbitrary multipart value. + * Sets [Builder.name] to an arbitrary multipart value. * - * You should usually call [Builder.webhookUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.name] with a well-typed [Name] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun webhookUrl(webhookUrl: MultipartField) = apply { - this.webhookUrl = webhookUrl - } + fun name(name: MultipartField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -5559,77 +3367,38 @@ private constructor( } /** - * Returns an immutable instance of [FileUploadV1ByUrl]. + * Returns an immutable instance of [AutoTaggingExtension]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .file() - * .fileName() + * .maxTags() + * .minConfidence() + * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): FileUploadV1ByUrl = - FileUploadV1ByUrl( - checkRequired("file", file), - checkRequired("fileName", fileName), - token, - checks, - customCoordinates, - customMetadata, - description, - expire, - (extensions ?: MultipartField.of(null)).map { it.toImmutable() }, - folder, - isPrivateFile, - isPublished, - overwriteAiTags, - overwriteCustomMetadata, - overwriteFile, - overwriteTags, - publicKey, - (responseFields ?: MultipartField.of(null)).map { it.toImmutable() }, - signature, - (tags ?: MultipartField.of(null)).map { it.toImmutable() }, - transformation, - useUniqueFileName, - webhookUrl, + fun build(): AutoTaggingExtension = + AutoTaggingExtension( + checkRequired("maxTags", maxTags), + checkRequired("minConfidence", minConfidence), + checkRequired("name", name), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): FileUploadV1ByUrl = apply { + fun validate(): AutoTaggingExtension = apply { if (validated) { return@apply } - file() - fileName() - token() - checks() - customCoordinates() - customMetadata().ifPresent { it.validate() } - description() - expire() - extensions().ifPresent { it.forEach { it.validate() } } - folder() - isPrivateFile() - isPublished() - overwriteAiTags() - overwriteCustomMetadata() - overwriteFile() - overwriteTags() - publicKey() - responseFields().ifPresent { it.forEach { it.validate() } } - signature() - tags() - transformation().ifPresent { it.validate() } - useUniqueFileName() - webhookUrl() + maxTags() + minConfidence() + name().validate() validated = true } @@ -5641,176 +3410,105 @@ private constructor( false } - /** - * JSON key-value pairs to associate with the asset. Create the custom metadata fields - * before setting these values. - */ - class CustomMetadata - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** Specifies the auto-tagging extension used. */ + class Name @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - /** - * Returns a mutable builder for constructing an instance of [CustomMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customMetadata: CustomMetadata) = apply { - additionalProperties = customMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** An enum containing [Name]'s known values. */ + enum class Known { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + } + /** + * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Name] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, /** - * Returns an immutable instance of [CustomMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * An enum member indicating that [Name] was instantiated with an unknown value. */ - fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): CustomMetadata = apply { - if (validated) { - return@apply - } - - validated = true + _UNKNOWN, } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING + else -> Value._UNKNOWN } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING + else -> throw ImageKitInvalidDataException("Unknown Name: $value") } - return other is CustomMetadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CustomMetadata{additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = Extension.Deserializer::class) - @JsonSerialize(using = Extension.Serializer::class) - class Extension - private constructor( - private val removeBg: RemoveBg? = null, - private val autoTagging: AutoTaggingExtension? = null, - private val aiAutoDescription: JsonValue? = null, - private val _json: JsonValue? = null, - ) { - - fun removeBg(): Optional = Optional.ofNullable(removeBg) - - fun autoTagging(): Optional = Optional.ofNullable(autoTagging) - - fun aiAutoDescription(): Optional = - Optional.ofNullable(aiAutoDescription) - - fun isRemoveBg(): Boolean = removeBg != null - - fun isAutoTagging(): Boolean = autoTagging != null - - fun isAiAutoDescription(): Boolean = aiAutoDescription != null - - fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") - - fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") - - fun asAiAutoDescription(): JsonValue = - aiAutoDescription.getOrThrow("aiAutoDescription") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - removeBg != null -> visitor.visitRemoveBg(removeBg) - autoTagging != null -> visitor.visitAutoTagging(autoTagging) - aiAutoDescription != null -> - visitor.visitAiAutoDescription(aiAutoDescription) - else -> visitor.unknown(_json) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") } private var validated: Boolean = false - fun validate(): Extension = apply { + fun validate(): Name = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitRemoveBg(removeBg: RemoveBg) { - removeBg.validate() - } - - override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { - autoTagging.validate() - } - - override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { - aiAutoDescription.let { - if ( - it != JsonValue.from(mapOf("name" to "ai-auto-description")) - ) { - throw ImageKitInvalidDataException( - "'aiAutoDescription' is invalid, received $it" - ) - } - } - } - } - ) + known() validated = true } @@ -5827,1110 +3525,793 @@ private constructor( * recursively. * * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() - - override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = - autoTagging.validity() - - override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = - aiAutoDescription.let { - if ( - it == JsonValue.from(mapOf("name" to "ai-auto-description")) - ) - 1 - else 0 - } - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Extension && - removeBg == other.removeBg && - autoTagging == other.autoTagging && - aiAutoDescription == other.aiAutoDescription - } - - override fun hashCode(): Int = - Objects.hash(removeBg, autoTagging, aiAutoDescription) - - override fun toString(): String = - when { - removeBg != null -> "Extension{removeBg=$removeBg}" - autoTagging != null -> "Extension{autoTagging=$autoTagging}" - aiAutoDescription != null -> - "Extension{aiAutoDescription=$aiAutoDescription}" - _json != null -> "Extension{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Extension") - } - - companion object { - - @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = Extension(removeBg = removeBg) - - @JvmStatic - fun ofAutoTagging(autoTagging: AutoTaggingExtension) = - Extension(autoTagging = autoTagging) - - @JvmStatic - fun ofAiAutoDescription() = - Extension( - aiAutoDescription = - JsonValue.from(mapOf("name" to "ai-auto-description")) - ) - } - - /** - * An interface that defines how to map each variant of [Extension] to a value of - * type [T]. - */ - interface Visitor { - - fun visitRemoveBg(removeBg: RemoveBg): T - - fun visitAutoTagging(autoTagging: AutoTaggingExtension): T - - fun visitAiAutoDescription(aiAutoDescription: JsonValue): T - - /** - * Maps an unknown variant of [Extension] to a value of type [T]. - * - * An instance of [Extension] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Extension: $json") - } - } - - internal class Deserializer : BaseDeserializer(Extension::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Extension { - val json = JsonValue.fromJsonNode(node) - val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() - - when (name) { - "remove-bg" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Extension(removeBg = it, _json = json) - } ?: Extension(_json = json) - } - "ai-auto-description" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Extension(aiAutoDescription = it, _json = json) } - ?.takeIf { it.isValid() } ?: Extension(_json = json) - } - } + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - return tryDeserialize(node, jacksonTypeRef())?.let { - Extension(autoTagging = it, _json = json) - } ?: Extension(_json = json) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - } - internal class Serializer : BaseSerializer(Extension::class) { - - override fun serialize( - value: Extension, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.removeBg != null -> generator.writeObject(value.removeBg) - value.autoTagging != null -> generator.writeObject(value.autoTagging) - value.aiAutoDescription != null -> - generator.writeObject(value.aiAutoDescription) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Extension") - } - } + return other is Name && value == other.value } - class RemoveBg - private constructor( - private val name: JsonValue, - private val options: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Specifies the background removal extension. - * - * Expected to always return the following: - * ```java - * JsonValue.from("remove-bg") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + override fun hashCode() = value.hashCode() - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun options(): Optional = options.value.getOptional("options") + override fun toString() = value.toString() + } - /** - * Returns the raw multipart value of [options]. - * - * Unlike [options], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("options") - @ExcludeMissing - fun _options(): MultipartField = options + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + return other is AutoTaggingExtension && + maxTags == other.maxTags && + minConfidence == other.minConfidence && + name == other.name && + additionalProperties == other.additionalProperties + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + private val hashCode: Int by lazy { + Objects.hash(maxTags, minConfidence, name, additionalProperties) + } - fun toBuilder() = Builder().from(this) + override fun hashCode(): Int = hashCode - companion object { + override fun toString() = + "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" + } + } - /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ - @JvmStatic fun builder() = Builder() - } + class ResponseField @JsonCreator private constructor(private val value: JsonField) : + Enum { - /** A builder for [RemoveBg]. */ - class Builder internal constructor() { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - private var name: JsonValue = JsonValue.from("remove-bg") - private var options: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = - mutableMapOf() + companion object { - @JvmSynthetic - internal fun from(removeBg: RemoveBg) = apply { - name = removeBg.name - options = removeBg.options - additionalProperties = removeBg.additionalProperties.toMutableMap() - } + @JvmField val TAGS = of("tags") - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults - * to the following: - * ```java - * JsonValue.from("remove-bg") - * ``` - * - * This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun name(name: JsonValue) = apply { this.name = name } + @JvmField val CUSTOM_COORDINATES = of("customCoordinates") - fun options(options: Options) = options(MultipartField.of(options)) + @JvmField val IS_PRIVATE_FILE = of("isPrivateFile") - /** - * Sets [Builder.options] to an arbitrary multipart value. - * - * You should usually call [Builder.options] with a well-typed [Options] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun options(options: MultipartField) = apply { - this.options = options - } + @JvmField val EMBEDDED_METADATA = of("embeddedMetadata") - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmField val IS_PUBLISHED = of("isPublished") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmField val CUSTOM_METADATA = of("customMetadata") - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + @JvmField val METADATA = of("metadata") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmStatic fun of(value: String) = ResponseField(JsonField.of(value)) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** An enum containing [ResponseField]'s known values. */ + enum class Known { + TAGS, + CUSTOM_COORDINATES, + IS_PRIVATE_FILE, + EMBEDDED_METADATA, + IS_PUBLISHED, + CUSTOM_METADATA, + METADATA, + } - /** - * Returns an immutable instance of [RemoveBg]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemoveBg = - RemoveBg(name, options, additionalProperties.toMutableMap()) - } + /** + * An enum containing [ResponseField]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ResponseField] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TAGS, + CUSTOM_COORDINATES, + IS_PRIVATE_FILE, + EMBEDDED_METADATA, + IS_PUBLISHED, + CUSTOM_METADATA, + METADATA, + /** + * An enum member indicating that [ResponseField] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - private var validated: Boolean = false + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TAGS -> Value.TAGS + CUSTOM_COORDINATES -> Value.CUSTOM_COORDINATES + IS_PRIVATE_FILE -> Value.IS_PRIVATE_FILE + EMBEDDED_METADATA -> Value.EMBEDDED_METADATA + IS_PUBLISHED -> Value.IS_PUBLISHED + CUSTOM_METADATA -> Value.CUSTOM_METADATA + METADATA -> Value.METADATA + else -> Value._UNKNOWN + } - fun validate(): RemoveBg = apply { - if (validated) { - return@apply - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TAGS -> Known.TAGS + CUSTOM_COORDINATES -> Known.CUSTOM_COORDINATES + IS_PRIVATE_FILE -> Known.IS_PRIVATE_FILE + EMBEDDED_METADATA -> Known.EMBEDDED_METADATA + IS_PUBLISHED -> Known.IS_PUBLISHED + CUSTOM_METADATA -> Known.CUSTOM_METADATA + METADATA -> Known.METADATA + else -> throw ImageKitInvalidDataException("Unknown ResponseField: $value") + } - _name().let { - if (it != JsonValue.from("remove-bg")) { - throw ImageKitInvalidDataException( - "'name' is invalid, received $it" - ) - } - } - options().ifPresent { it.validate() } - validated = true - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + private var validated: Boolean = false - class Options - private constructor( - private val addShadow: MultipartField, - private val bgColor: MultipartField, - private val bgImageUrl: MultipartField, - private val semitransparency: MultipartField, - private val additionalProperties: MutableMap, - ) { + fun validate(): ResponseField = apply { + if (validated) { + return@apply + } - /** - * Whether to add an artificial shadow to the result. Default is false. - * Note: Adding shadows is currently only supported for car photos. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun addShadow(): Optional = - addShadow.value.getOptional("add_shadow") + known() + validated = true + } - /** - * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") - * or color name (e.g., "green"). If this parameter is set, `bg_image_url` - * must be empty. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun bgColor(): Optional = bgColor.value.getOptional("bg_color") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - /** - * Sets a background image from a URL. If this parameter is set, `bg_color` - * must be empty. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun bgImageUrl(): Optional = - bgImageUrl.value.getOptional("bg_image_url") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Allows semi-transparent regions in the result. Default is true. Note: - * Semitransparency is currently only supported for car windows. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun semitransparency(): Optional = - semitransparency.value.getOptional("semitransparency") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw multipart value of [addShadow]. - * - * Unlike [addShadow], this method doesn't throw if the multipart field has - * an unexpected type. - */ - @JsonProperty("add_shadow") - @ExcludeMissing - fun _addShadow(): MultipartField = addShadow + return other is ResponseField && value == other.value + } - /** - * Returns the raw multipart value of [bgColor]. - * - * Unlike [bgColor], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("bg_color") - @ExcludeMissing - fun _bgColor(): MultipartField = bgColor + override fun hashCode() = value.hashCode() - /** - * Returns the raw multipart value of [bgImageUrl]. - * - * Unlike [bgImageUrl], this method doesn't throw if the multipart field has - * an unexpected type. - */ - @JsonProperty("bg_image_url") - @ExcludeMissing - fun _bgImageUrl(): MultipartField = bgImageUrl + override fun toString() = value.toString() + } - /** - * Returns the raw multipart value of [semitransparency]. - * - * Unlike [semitransparency], this method doesn't throw if the multipart - * field has an unexpected type. - */ - @JsonProperty("semitransparency") - @ExcludeMissing - fun _semitransparency(): MultipartField = semitransparency + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing file + * size or applying basic optimizations upfront (e.g., resize, compress). + * - `post` — applied immediately after upload. Ideal for generating transformed versions (like + * video encodes or thumbnails) in advance, so they're ready for delivery without delay. + * + * You can mix and match any combination of post-processing types. + */ + class Transformation + private constructor( + private val post: MultipartField>, + private val pre: MultipartField, + private val additionalProperties: MutableMap, + ) { - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * List of transformations to apply _after_ the file is uploaded. Each item must match one + * of the following types: `transformation`, `gif-to-video`, `thumbnail`, `abs`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun post(): Optional> = post.value.getOptional("post") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Transformation string to apply before uploading the file to the Media Library. Useful for + * optimizing files at ingestion. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun pre(): Optional = pre.value.getOptional("pre") - fun toBuilder() = Builder().from(this) + /** + * Returns the raw multipart value of [post]. + * + * Unlike [post], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("post") @ExcludeMissing fun _post(): MultipartField> = post - companion object { + /** + * Returns the raw multipart value of [pre]. + * + * Unlike [pre], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("pre") @ExcludeMissing fun _pre(): MultipartField = pre - /** - * Returns a mutable builder for constructing an instance of [Options]. - */ - @JvmStatic fun builder() = Builder() - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** A builder for [Options]. */ - class Builder internal constructor() { - - private var addShadow: MultipartField = MultipartField.of(null) - private var bgColor: MultipartField = MultipartField.of(null) - private var bgImageUrl: MultipartField = MultipartField.of(null) - private var semitransparency: MultipartField = - MultipartField.of(null) - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(options: Options) = apply { - addShadow = options.addShadow - bgColor = options.bgColor - bgImageUrl = options.bgImageUrl - semitransparency = options.semitransparency - additionalProperties = options.additionalProperties.toMutableMap() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Whether to add an artificial shadow to the result. Default is false. - * Note: Adding shadows is currently only supported for car photos. - */ - fun addShadow(addShadow: Boolean) = - addShadow(MultipartField.of(addShadow)) - - /** - * Sets [Builder.addShadow] to an arbitrary multipart value. - * - * You should usually call [Builder.addShadow] with a well-typed - * [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun addShadow(addShadow: MultipartField) = apply { - this.addShadow = addShadow - } + fun toBuilder() = Builder().from(this) - /** - * Specifies a solid color background using hex code (e.g., "81d4fa", - * "fff") or color name (e.g., "green"). If this parameter is set, - * `bg_image_url` must be empty. - */ - fun bgColor(bgColor: String) = bgColor(MultipartField.of(bgColor)) - - /** - * Sets [Builder.bgColor] to an arbitrary multipart value. - * - * You should usually call [Builder.bgColor] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun bgColor(bgColor: MultipartField) = apply { - this.bgColor = bgColor - } + companion object { - /** - * Sets a background image from a URL. If this parameter is set, - * `bg_color` must be empty. - */ - fun bgImageUrl(bgImageUrl: String) = - bgImageUrl(MultipartField.of(bgImageUrl)) - - /** - * Sets [Builder.bgImageUrl] to an arbitrary multipart value. - * - * You should usually call [Builder.bgImageUrl] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun bgImageUrl(bgImageUrl: MultipartField) = apply { - this.bgImageUrl = bgImageUrl - } + /** Returns a mutable builder for constructing an instance of [Transformation]. */ + @JvmStatic fun builder() = Builder() + } - /** - * Allows semi-transparent regions in the result. Default is true. Note: - * Semitransparency is currently only supported for car windows. - */ - fun semitransparency(semitransparency: Boolean) = - semitransparency(MultipartField.of(semitransparency)) - - /** - * Sets [Builder.semitransparency] to an arbitrary multipart value. - * - * You should usually call [Builder.semitransparency] with a well-typed - * [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun semitransparency(semitransparency: MultipartField) = - apply { - this.semitransparency = semitransparency - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** A builder for [Transformation]. */ + class Builder internal constructor() { - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + private var post: MultipartField>? = null + private var pre: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmSynthetic + internal fun from(transformation: Transformation) = apply { + post = transformation.post.map { it.toMutableList() } + pre = transformation.pre + additionalProperties = transformation.additionalProperties.toMutableMap() + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * List of transformations to apply _after_ the file is uploaded. Each item must match + * one of the following types: `transformation`, `gif-to-video`, `thumbnail`, `abs`. + */ + fun post(post: List) = post(MultipartField.of(post)) - /** - * Returns an immutable instance of [Options]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): Options = - Options( - addShadow, - bgColor, - bgImageUrl, - semitransparency, - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.post] to an arbitrary multipart value. + * + * You should usually call [Builder.post] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun post(post: MultipartField>) = apply { + this.post = post.map { it.toMutableList() } + } - private var validated: Boolean = false + /** + * Adds a single [Post] to [Builder.post]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPost(post: Post) = apply { + this.post = + (this.post ?: MultipartField.of(mutableListOf())).also { + checkKnown("post", it).add(post) + } + } - fun validate(): Options = apply { - if (validated) { - return@apply - } + /** Alias for calling [addPost] with `Post.ofTransformation(transformation)`. */ + fun addPost(transformation: Post.InnerTransformation) = + addPost(Post.ofTransformation(transformation)) - addShadow() - bgColor() - bgImageUrl() - semitransparency() - validated = true - } + /** + * Alias for calling [addPost] with the following: + * ```java + * Post.InnerTransformation.builder() + * .value(value) + * .build() + * ``` + */ + fun addTransformationPost(value: String) = + addPost(Post.InnerTransformation.builder().value(value).build()) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + /** Alias for calling [addPost] with `Post.ofGifToVideo(gifToVideo)`. */ + fun addPost(gifToVideo: Post.GifToVideo) = addPost(Post.ofGifToVideo(gifToVideo)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** Alias for calling [addPost] with `Post.ofThumbnail(thumbnail)`. */ + fun addPost(thumbnail: Post.Thumbnail) = addPost(Post.ofThumbnail(thumbnail)) - return other is Options && - addShadow == other.addShadow && - bgColor == other.bgColor && - bgImageUrl == other.bgImageUrl && - semitransparency == other.semitransparency && - additionalProperties == other.additionalProperties - } + /** Alias for calling [addPost] with `Post.ofAbs(abs)`. */ + fun addPost(abs: Post.Abs) = addPost(Post.ofAbs(abs)) - private val hashCode: Int by lazy { - Objects.hash( - addShadow, - bgColor, - bgImageUrl, - semitransparency, - additionalProperties, - ) - } + /** + * Transformation string to apply before uploading the file to the Media Library. Useful + * for optimizing files at ingestion. + */ + fun pre(pre: String) = pre(MultipartField.of(pre)) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.pre] to an arbitrary multipart value. + * + * You should usually call [Builder.pre] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pre(pre: MultipartField) = apply { this.pre = pre } - override fun toString() = - "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return other is RemoveBg && - name == other.name && - options == other.options && - additionalProperties == other.additionalProperties - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - private val hashCode: Int by lazy { - Objects.hash(name, options, additionalProperties) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" - } + /** + * Returns an immutable instance of [Transformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Transformation = + Transformation( + (post ?: MultipartField.of(null)).map { it.toImmutable() }, + pre, + additionalProperties.toMutableMap(), + ) + } - class AutoTaggingExtension - private constructor( - private val maxTags: MultipartField, - private val minConfidence: MultipartField, - private val name: MultipartField, - private val additionalProperties: MutableMap, - ) { + private var validated: Boolean = false - /** - * Maximum number of tags to attach to the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun maxTags(): Long = maxTags.value.getRequired("maxTags") + fun validate(): Transformation = apply { + if (validated) { + return@apply + } - /** - * Minimum confidence level for tags to be considered valid. - * - * @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 minConfidence(): Long = minConfidence.value.getRequired("minConfidence") + post().ifPresent { it.forEach { it.validate() } } + pre() + validated = true + } - /** - * Specifies the auto-tagging extension used. - * - * @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(): Name = name.value.getRequired("name") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - /** - * Returns the raw multipart value of [maxTags]. - * - * Unlike [maxTags], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("maxTags") - @ExcludeMissing - fun _maxTags(): MultipartField = maxTags + @JsonDeserialize(using = Post.Deserializer::class) + @JsonSerialize(using = Post.Serializer::class) + class Post + private constructor( + private val transformation: InnerTransformation? = null, + private val gifToVideo: GifToVideo? = null, + private val thumbnail: Thumbnail? = null, + private val abs: Abs? = null, + private val _json: JsonValue? = null, + ) { - /** - * Returns the raw multipart value of [minConfidence]. - * - * Unlike [minConfidence], this method doesn't throw if the multipart field has - * an unexpected type. - */ - @JsonProperty("minConfidence") - @ExcludeMissing - fun _minConfidence(): MultipartField = minConfidence + fun transformation(): Optional = + Optional.ofNullable(transformation) - /** - * Returns the raw multipart value of [name]. - * - * Unlike [name], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name + fun gifToVideo(): Optional = Optional.ofNullable(gifToVideo) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun thumbnail(): Optional = Optional.ofNullable(thumbnail) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun abs(): Optional = Optional.ofNullable(abs) - fun toBuilder() = Builder().from(this) + fun isTransformation(): Boolean = transformation != null - companion object { + fun isGifToVideo(): Boolean = gifToVideo != null - /** - * Returns a mutable builder for constructing an instance of - * [AutoTaggingExtension]. - * - * The following fields are required: - * ```java - * .maxTags() - * .minConfidence() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + fun isThumbnail(): Boolean = thumbnail != null - /** A builder for [AutoTaggingExtension]. */ - class Builder internal constructor() { - - private var maxTags: MultipartField? = null - private var minConfidence: MultipartField? = null - private var name: MultipartField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { - maxTags = autoTaggingExtension.maxTags - minConfidence = autoTaggingExtension.minConfidence - name = autoTaggingExtension.name - additionalProperties = - autoTaggingExtension.additionalProperties.toMutableMap() - } + fun isAbs(): Boolean = abs != null - /** Maximum number of tags to attach to the asset. */ - fun maxTags(maxTags: Long) = maxTags(MultipartField.of(maxTags)) + fun asTransformation(): InnerTransformation = + transformation.getOrThrow("transformation") - /** - * Sets [Builder.maxTags] to an arbitrary multipart value. - * - * You should usually call [Builder.maxTags] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun maxTags(maxTags: MultipartField) = apply { - this.maxTags = maxTags - } + fun asGifToVideo(): GifToVideo = gifToVideo.getOrThrow("gifToVideo") - /** Minimum confidence level for tags to be considered valid. */ - fun minConfidence(minConfidence: Long) = - minConfidence(MultipartField.of(minConfidence)) + fun asThumbnail(): Thumbnail = thumbnail.getOrThrow("thumbnail") - /** - * Sets [Builder.minConfidence] to an arbitrary multipart value. - * - * You should usually call [Builder.minConfidence] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun minConfidence(minConfidence: MultipartField) = apply { - this.minConfidence = minConfidence - } + fun asAbs(): Abs = abs.getOrThrow("abs") - /** Specifies the auto-tagging extension used. */ - fun name(name: Name) = name(MultipartField.of(name)) + fun _json(): Optional = Optional.ofNullable(_json) - /** - * Sets [Builder.name] to an arbitrary multipart value. - * - * You should usually call [Builder.name] with a well-typed [Name] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun name(name: MultipartField) = apply { this.name = name } + fun accept(visitor: Visitor): T = + when { + transformation != null -> visitor.visitTransformation(transformation) + gifToVideo != null -> visitor.visitGifToVideo(gifToVideo) + thumbnail != null -> visitor.visitThumbnail(thumbnail) + abs != null -> visitor.visitAbs(abs) + else -> visitor.unknown(_json) + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + private var validated: Boolean = false - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun validate(): Post = apply { + if (validated) { + return@apply + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + accept( + object : Visitor { + override fun visitTransformation(transformation: InnerTransformation) { + transformation.validate() + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + override fun visitGifToVideo(gifToVideo: GifToVideo) { + gifToVideo.validate() } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + override fun visitThumbnail(thumbnail: Thumbnail) { + thumbnail.validate() } - /** - * Returns an immutable instance of [AutoTaggingExtension]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .maxTags() - * .minConfidence() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AutoTaggingExtension = - AutoTaggingExtension( - checkRequired("maxTags", maxTags), - checkRequired("minConfidence", minConfidence), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) + override fun visitAbs(abs: Abs) { + abs.validate() + } } + ) + validated = true + } - private var validated: Boolean = false - - fun validate(): AutoTaggingExtension = apply { - if (validated) { - return@apply - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - maxTags() - minConfidence() - name().validate() - validated = true - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitTransformation(transformation: InnerTransformation) = + transformation.validity() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + override fun visitGifToVideo(gifToVideo: GifToVideo) = gifToVideo.validity() - /** Specifies the auto-tagging extension used. */ - class Name - @JsonCreator - private constructor(private val value: JsonField) : Enum { + override fun visitThumbnail(thumbnail: Thumbnail) = thumbnail.validity() - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + override fun visitAbs(abs: Abs) = abs.validity() - companion object { + override fun unknown(json: JsonValue?) = 0 + } + ) - @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") + return other is Post && + transformation == other.transformation && + gifToVideo == other.gifToVideo && + thumbnail == other.thumbnail && + abs == other.abs + } - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } + override fun hashCode(): Int = Objects.hash(transformation, gifToVideo, thumbnail, abs) - /** An enum containing [Name]'s known values. */ - enum class Known { - GOOGLE_AUTO_TAGGING, - AWS_AUTO_TAGGING, - } + override fun toString(): String = + when { + transformation != null -> "Post{transformation=$transformation}" + gifToVideo != null -> "Post{gifToVideo=$gifToVideo}" + thumbnail != null -> "Post{thumbnail=$thumbnail}" + abs != null -> "Post{abs=$abs}" + _json != null -> "Post{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Post") + } - /** - * An enum containing [Name]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Name] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GOOGLE_AUTO_TAGGING, - AWS_AUTO_TAGGING, - /** - * An enum member indicating that [Name] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + companion object { - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING - AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING - else -> Value._UNKNOWN - } + @JvmStatic + fun ofTransformation(transformation: InnerTransformation) = + Post(transformation = transformation) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value is a - * not a known member. - */ - fun known(): Known = - when (this) { - GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING - AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING - else -> throw ImageKitInvalidDataException("Unknown Name: $value") - } + @JvmStatic fun ofGifToVideo(gifToVideo: GifToVideo) = Post(gifToVideo = gifToVideo) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value does - * not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") - } + @JvmStatic fun ofThumbnail(thumbnail: Thumbnail) = Post(thumbnail = thumbnail) - private var validated: Boolean = false + @JvmStatic fun ofAbs(abs: Abs) = Post(abs = abs) + } - fun validate(): Name = apply { - if (validated) { - return@apply - } + /** + * An interface that defines how to map each variant of [Post] to a value of type [T]. + */ + interface Visitor { - known() - validated = true - } + fun visitTransformation(transformation: InnerTransformation): T - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + fun visitGifToVideo(gifToVideo: GifToVideo): T - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun visitThumbnail(thumbnail: Thumbnail): T - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun visitAbs(abs: Abs): T - return other is Name && value == other.value - } + /** + * Maps an unknown variant of [Post] to a value of type [T]. + * + * An instance of [Post] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Post: $json") + } + } - override fun hashCode() = value.hashCode() + internal class Deserializer : BaseDeserializer(Post::class) { - override fun toString() = value.toString() - } + override fun ObjectCodec.deserialize(node: JsonNode): Post { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + when (type) { + "transformation" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Post(transformation = it, _json = json) } + ?: Post(_json = json) + } + "gif-to-video" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(gifToVideo = it, _json = json) + } ?: Post(_json = json) + } + "thumbnail" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(thumbnail = it, _json = json) + } ?: Post(_json = json) + } + "abs" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(abs = it, _json = json) + } ?: Post(_json = json) } - - return other is AutoTaggingExtension && - maxTags == other.maxTags && - minConfidence == other.minConfidence && - name == other.name && - additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(maxTags, minConfidence, name, additionalProperties) - } + return Post(_json = json) + } + } - override fun hashCode(): Int = hashCode + internal class Serializer : BaseSerializer(Post::class) { - override fun toString() = - "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" + override fun serialize( + value: Post, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.transformation != null -> generator.writeObject(value.transformation) + value.gifToVideo != null -> generator.writeObject(value.gifToVideo) + value.thumbnail != null -> generator.writeObject(value.thumbnail) + value.abs != null -> generator.writeObject(value.abs) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Post") + } } } - class ResponseField - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class InnerTransformation + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { /** - * Returns this class instance's raw value. + * Transformation type. * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * Expected to always return the following: + * ```java + * JsonValue.from("transformation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - companion object { + /** + * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based + * 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 value(): String = value.value.getRequired("value") + + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JvmField val TAGS = of("tags") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmField val CUSTOM_COORDINATES = of("customCoordinates") + fun toBuilder() = Builder().from(this) - @JvmField val IS_PRIVATE_FILE = of("isPrivateFile") + companion object { - @JvmField val EMBEDDED_METADATA = of("embeddedMetadata") + /** + * Returns a mutable builder for constructing an instance of + * [InnerTransformation]. + * + * The following fields are required: + * ```java + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - @JvmField val IS_PUBLISHED = of("isPublished") + /** A builder for [InnerTransformation]. */ + class Builder internal constructor() { - @JvmField val CUSTOM_METADATA = of("customMetadata") + private var type: JsonValue = JsonValue.from("transformation") + private var value: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() - @JvmField val METADATA = of("metadata") + @JvmSynthetic + internal fun from(innerTransformation: InnerTransformation) = apply { + type = innerTransformation.type + value = innerTransformation.value + additionalProperties = + innerTransformation.additionalProperties.toMutableMap() + } - @JvmStatic fun of(value: String) = ResponseField(JsonField.of(value)) - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("transformation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } - /** An enum containing [ResponseField]'s known values. */ - enum class Known { - TAGS, - CUSTOM_COORDINATES, - IS_PRIVATE_FILE, - EMBEDDED_METADATA, - IS_PUBLISHED, - CUSTOM_METADATA, - METADATA, - } + /** + * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based + * transformations. + */ + fun value(value: String) = value(MultipartField.of(value)) - /** - * An enum containing [ResponseField]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ResponseField] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TAGS, - CUSTOM_COORDINATES, - IS_PRIVATE_FILE, - EMBEDDED_METADATA, - IS_PUBLISHED, - CUSTOM_METADATA, - METADATA, /** - * An enum member indicating that [ResponseField] was instantiated with an - * unknown value. + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - _UNKNOWN, - } + fun value(value: MultipartField) = apply { this.value = value } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TAGS -> Value.TAGS - CUSTOM_COORDINATES -> Value.CUSTOM_COORDINATES - IS_PRIVATE_FILE -> Value.IS_PRIVATE_FILE - EMBEDDED_METADATA -> Value.EMBEDDED_METADATA - IS_PUBLISHED -> Value.IS_PUBLISHED - CUSTOM_METADATA -> Value.CUSTOM_METADATA - METADATA -> Value.METADATA - else -> Value._UNKNOWN + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TAGS -> Known.TAGS - CUSTOM_COORDINATES -> Known.CUSTOM_COORDINATES - IS_PRIVATE_FILE -> Known.IS_PRIVATE_FILE - EMBEDDED_METADATA -> Known.EMBEDDED_METADATA - IS_PUBLISHED -> Known.IS_PUBLISHED - CUSTOM_METADATA -> Known.CUSTOM_METADATA - METADATA -> Known.METADATA - else -> throw ImageKitInvalidDataException("Unknown ResponseField: $value") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [InnerTransformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InnerTransformation = + InnerTransformation( + type, + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false - fun validate(): ResponseField = apply { + fun validate(): InnerTransformation = apply { if (validated) { return@apply } - known() + _type().let { + if (it != JsonValue.from("transformation")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + value() validated = true } @@ -6942,79 +4323,62 @@ private constructor( false } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is ResponseField && value == other.value + return other is InnerTransformation && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } - /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for - * reducing file size or applying basic optimizations upfront (e.g., resize, - * compress). - * - `post` — applied immediately after upload. Ideal for generating transformed - * versions (like video encodes or thumbnails) in advance, so they're ready for - * delivery without delay. - * - * You can mix and match any combination of post-processing types. - */ - class Transformation + override fun hashCode(): Int = hashCode + + override fun toString() = + "InnerTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" + } + + class GifToVideo private constructor( - private val post: MultipartField>, - private val pre: MultipartField, + private val type: JsonValue, + private val value: MultipartField, private val additionalProperties: MutableMap, ) { /** - * List of transformations to apply _after_ the file is uploaded. Each item must - * match one of the following types: `transformation`, `gif-to-video`, `thumbnail`, - * `abs`. + * Converts an animated GIF into an MP4. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("gif-to-video") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun post(): Optional> = post.value.getOptional("post") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** - * Transformation string to apply before uploading the file to the Media Library. - * Useful for optimizing files at ingestion. + * Optional transformation string to apply to the output video. **Example**: `q-80` * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun pre(): Optional = pre.value.getOptional("pre") - - /** - * Returns the raw multipart value of [post]. - * - * Unlike [post], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("post") @ExcludeMissing fun _post(): MultipartField> = post + fun value(): Optional = value.value.getOptional("value") /** - * Returns the raw multipart value of [pre]. + * Returns the raw multipart value of [value]. * - * Unlike [pre], this method doesn't throw if the multipart field has an unexpected - * type. + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. */ - @JsonProperty("pre") @ExcludeMissing fun _pre(): MultipartField = pre + @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -7030,95 +4394,52 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [Transformation]. - */ + /** Returns a mutable builder for constructing an instance of [GifToVideo]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Transformation]. */ + /** A builder for [GifToVideo]. */ class Builder internal constructor() { - private var post: MultipartField>? = null - private var pre: MultipartField = MultipartField.of(null) + private var type: JsonValue = JsonValue.from("gif-to-video") + private var value: MultipartField = MultipartField.of(null) private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(transformation: Transformation) = apply { - post = transformation.post.map { it.toMutableList() } - pre = transformation.pre - additionalProperties = transformation.additionalProperties.toMutableMap() + internal fun from(gifToVideo: GifToVideo) = apply { + type = gifToVideo.type + value = gifToVideo.value + additionalProperties = gifToVideo.additionalProperties.toMutableMap() } /** - * List of transformations to apply _after_ the file is uploaded. Each item must - * match one of the following types: `transformation`, `gif-to-video`, - * `thumbnail`, `abs`. - */ - fun post(post: List) = post(MultipartField.of(post)) - - /** - * Sets [Builder.post] to an arbitrary multipart value. - * - * You should usually call [Builder.post] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun post(post: MultipartField>) = apply { - this.post = post.map { it.toMutableList() } - } - - /** - * Adds a single [Post] to [Builder.post]. + * Sets the field to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPost(post: Post) = apply { - this.post = - (this.post ?: MultipartField.of(mutableListOf())).also { - checkKnown("post", it).add(post) - } - } - - /** Alias for calling [addPost] with `Post.ofTransformation(transformation)`. */ - fun addPost(transformation: Post.InnerTransformation) = - addPost(Post.ofTransformation(transformation)) - - /** - * Alias for calling [addPost] with the following: + * It is usually unnecessary to call this method because the field defaults to + * the following: * ```java - * Post.InnerTransformation.builder() - * .value(value) - * .build() + * JsonValue.from("gif-to-video") * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun addTransformationPost(value: String) = - addPost(Post.InnerTransformation.builder().value(value).build()) - - /** Alias for calling [addPost] with `Post.ofGifToVideo(gifToVideo)`. */ - fun addPost(gifToVideo: Post.GifToVideo) = - addPost(Post.ofGifToVideo(gifToVideo)) - - /** Alias for calling [addPost] with `Post.ofThumbnail(thumbnail)`. */ - fun addPost(thumbnail: Post.Thumbnail) = addPost(Post.ofThumbnail(thumbnail)) - - /** Alias for calling [addPost] with `Post.ofAbs(abs)`. */ - fun addPost(abs: Post.Abs) = addPost(Post.ofAbs(abs)) + fun type(type: JsonValue) = apply { this.type = type } /** - * Transformation string to apply before uploading the file to the Media - * Library. Useful for optimizing files at ingestion. + * Optional transformation string to apply to the output video. **Example**: + * `q-80` */ - fun pre(pre: String) = pre(MultipartField.of(pre)) + fun value(value: String) = value(MultipartField.of(value)) /** - * Sets [Builder.pre] to an arbitrary multipart value. + * Sets [Builder.value] to an arbitrary multipart value. * - * You should usually call [Builder.pre] with a well-typed [String] value + * You should usually call [Builder.value] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun pre(pre: MultipartField) = apply { this.pre = pre } + fun value(value: MultipartField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -7143,27 +4464,27 @@ private constructor( } /** - * Returns an immutable instance of [Transformation]. + * Returns an immutable instance of [GifToVideo]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Transformation = - Transformation( - (post ?: MultipartField.of(null)).map { it.toImmutable() }, - pre, - additionalProperties.toMutableMap(), - ) + fun build(): GifToVideo = + GifToVideo(type, value, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): Transformation = apply { + fun validate(): GifToVideo = apply { if (validated) { return@apply } - post().ifPresent { it.forEach { it.validate() } } - pre() + _type().let { + if (it != JsonValue.from("gif-to-video")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + value() validated = true } @@ -7175,1188 +4496,542 @@ private constructor( false } - @JsonDeserialize(using = Post.Deserializer::class) - @JsonSerialize(using = Post.Serializer::class) - class Post - private constructor( - private val transformation: InnerTransformation? = null, - private val gifToVideo: GifToVideo? = null, - private val thumbnail: Thumbnail? = null, - private val abs: Abs? = null, - private val _json: JsonValue? = null, - ) { - - fun transformation(): Optional = - Optional.ofNullable(transformation) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun gifToVideo(): Optional = Optional.ofNullable(gifToVideo) + return other is GifToVideo && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } - fun thumbnail(): Optional = Optional.ofNullable(thumbnail) + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } - fun abs(): Optional = Optional.ofNullable(abs) + override fun hashCode(): Int = hashCode - fun isTransformation(): Boolean = transformation != null + override fun toString() = + "GifToVideo{type=$type, value=$value, additionalProperties=$additionalProperties}" + } - fun isGifToVideo(): Boolean = gifToVideo != null + class Thumbnail + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { - fun isThumbnail(): Boolean = thumbnail != null + /** + * Generates a thumbnail image. + * + * Expected to always return the following: + * ```java + * JsonValue.from("thumbnail") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - fun isAbs(): Boolean = abs != null + /** + * Optional transformation string. **Example**: `w-150,h-150` + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.value.getOptional("value") - fun asTransformation(): InnerTransformation = - transformation.getOrThrow("transformation") + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value - fun asGifToVideo(): GifToVideo = gifToVideo.getOrThrow("gifToVideo") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asThumbnail(): Thumbnail = thumbnail.getOrThrow("thumbnail") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun asAbs(): Abs = abs.getOrThrow("abs") + fun toBuilder() = Builder().from(this) - fun _json(): Optional = Optional.ofNullable(_json) + companion object { - fun accept(visitor: Visitor): T = - when { - transformation != null -> visitor.visitTransformation(transformation) - gifToVideo != null -> visitor.visitGifToVideo(gifToVideo) - thumbnail != null -> visitor.visitThumbnail(thumbnail) - abs != null -> visitor.visitAbs(abs) - else -> visitor.unknown(_json) - } + /** Returns a mutable builder for constructing an instance of [Thumbnail]. */ + @JvmStatic fun builder() = Builder() + } - private var validated: Boolean = false + /** A builder for [Thumbnail]. */ + class Builder internal constructor() { - fun validate(): Post = apply { - if (validated) { - return@apply - } + private var type: JsonValue = JsonValue.from("thumbnail") + private var value: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() - accept( - object : Visitor { - override fun visitTransformation( - transformation: InnerTransformation - ) { - transformation.validate() - } - - override fun visitGifToVideo(gifToVideo: GifToVideo) { - gifToVideo.validate() - } - - override fun visitThumbnail(thumbnail: Thumbnail) { - thumbnail.validate() - } - - override fun visitAbs(abs: Abs) { - abs.validate() - } - } - ) - validated = true + @JvmSynthetic + internal fun from(thumbnail: Thumbnail) = apply { + type = thumbnail.type + value = thumbnail.value + additionalProperties = thumbnail.additionalProperties.toMutableMap() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets the field to an arbitrary JSON value. * - * Used for best match union deserialization. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("thumbnail") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitTransformation( - transformation: InnerTransformation - ) = transformation.validity() - - override fun visitGifToVideo(gifToVideo: GifToVideo) = - gifToVideo.validity() - - override fun visitThumbnail(thumbnail: Thumbnail) = - thumbnail.validity() - - override fun visitAbs(abs: Abs) = abs.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Post && - transformation == other.transformation && - gifToVideo == other.gifToVideo && - thumbnail == other.thumbnail && - abs == other.abs - } + fun type(type: JsonValue) = apply { this.type = type } - override fun hashCode(): Int = - Objects.hash(transformation, gifToVideo, thumbnail, abs) - - override fun toString(): String = - when { - transformation != null -> "Post{transformation=$transformation}" - gifToVideo != null -> "Post{gifToVideo=$gifToVideo}" - thumbnail != null -> "Post{thumbnail=$thumbnail}" - abs != null -> "Post{abs=$abs}" - _json != null -> "Post{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Post") - } - - companion object { - - @JvmStatic - fun ofTransformation(transformation: InnerTransformation) = - Post(transformation = transformation) - - @JvmStatic - fun ofGifToVideo(gifToVideo: GifToVideo) = Post(gifToVideo = gifToVideo) - - @JvmStatic - fun ofThumbnail(thumbnail: Thumbnail) = Post(thumbnail = thumbnail) - - @JvmStatic fun ofAbs(abs: Abs) = Post(abs = abs) - } + /** Optional transformation string. **Example**: `w-150,h-150` */ + fun value(value: String) = value(MultipartField.of(value)) /** - * An interface that defines how to map each variant of [Post] to a value of - * type [T]. + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - interface Visitor { - - fun visitTransformation(transformation: InnerTransformation): T - - fun visitGifToVideo(gifToVideo: GifToVideo): T - - fun visitThumbnail(thumbnail: Thumbnail): T - - fun visitAbs(abs: Abs): T - - /** - * Maps an unknown variant of [Post] to a value of type [T]. - * - * An instance of [Post] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, - * if the SDK is on an older version than the API, then the API may respond - * with new variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Post: $json") - } - } + fun value(value: MultipartField) = apply { this.value = value } - internal class Deserializer : BaseDeserializer(Post::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Post { - val json = JsonValue.fromJsonNode(node) - val type = - json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - - when (type) { - "transformation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Post(transformation = it, _json = json) } - ?: Post(_json = json) - } - "gif-to-video" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(gifToVideo = it, _json = json) - } ?: Post(_json = json) - } - "thumbnail" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(thumbnail = it, _json = json) - } ?: Post(_json = json) - } - "abs" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(abs = it, _json = json) - } ?: Post(_json = json) - } - } - - return Post(_json = json) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - internal class Serializer : BaseSerializer(Post::class) { - - override fun serialize( - value: Post, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.transformation != null -> - generator.writeObject(value.transformation) - value.gifToVideo != null -> generator.writeObject(value.gifToVideo) - value.thumbnail != null -> generator.writeObject(value.thumbnail) - value.abs != null -> generator.writeObject(value.abs) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Post") - } - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - class InnerTransformation - private constructor( - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Transformation type. - * - * Expected to always return the following: - * ```java - * JsonValue.from("transformation") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit - * URL-based 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 value(): String = value.value.getRequired("value") - - /** - * Returns the raw multipart value of [value]. - * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): MultipartField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InnerTransformation]. - * - * The following fields are required: - * ```java - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerTransformation]. */ - class Builder internal constructor() { - - private var type: JsonValue = JsonValue.from("transformation") - private var value: MultipartField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerTransformation: InnerTransformation) = apply { - type = innerTransformation.type - value = innerTransformation.value - additionalProperties = - innerTransformation.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field - * defaults to the following: - * ```java - * JsonValue.from("transformation") - * ``` - * - * This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** - * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit - * URL-based transformations. - */ - fun value(value: String) = value(MultipartField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun value(value: MultipartField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InnerTransformation]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): InnerTransformation = - InnerTransformation( - type, - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): InnerTransformation = apply { - if (validated) { - return@apply - } - - _type().let { - if (it != JsonValue.from("transformation")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - value() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InnerTransformation && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(type, value, additionalProperties) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - class GifToVideo - private constructor( - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Converts an animated GIF into an MP4. - * - * Expected to always return the following: - * ```java - * JsonValue.from("gif-to-video") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Optional transformation string to apply to the output video. **Example**: - * `q-80` - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun value(): Optional = value.value.getOptional("value") - - /** - * Returns the raw multipart value of [value]. - * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): MultipartField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [GifToVideo]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GifToVideo]. */ - class Builder internal constructor() { - - private var type: JsonValue = JsonValue.from("gif-to-video") - private var value: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(gifToVideo: GifToVideo) = apply { - type = gifToVideo.type - value = gifToVideo.value - additionalProperties = - gifToVideo.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field - * defaults to the following: - * ```java - * JsonValue.from("gif-to-video") - * ``` - * - * This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** - * Optional transformation string to apply to the output video. - * **Example**: `q-80` - */ - fun value(value: String) = value(MultipartField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun value(value: MultipartField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [GifToVideo]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): GifToVideo = - GifToVideo(type, value, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): GifToVideo = apply { - if (validated) { - return@apply - } - - _type().let { - if (it != JsonValue.from("gif-to-video")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - value() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GifToVideo && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(type, value, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GifToVideo{type=$type, value=$value, additionalProperties=$additionalProperties}" + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - class Thumbnail - private constructor( - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Generates a thumbnail image. - * - * Expected to always return the following: - * ```java - * JsonValue.from("thumbnail") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * Returns an immutable instance of [Thumbnail]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Thumbnail = + Thumbnail(type, value, additionalProperties.toMutableMap()) + } - /** - * Optional transformation string. **Example**: `w-150,h-150` - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun value(): Optional = value.value.getOptional("value") + private var validated: Boolean = false - /** - * Returns the raw multipart value of [value]. - * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): MultipartField = value + fun validate(): Thumbnail = apply { + if (validated) { + return@apply + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + _type().let { + if (it != JsonValue.from("thumbnail")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") } + } + value() + validated = true + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - companion object { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns a mutable builder for constructing an instance of - * [Thumbnail]. - */ - @JvmStatic fun builder() = Builder() - } + return other is Thumbnail && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } - /** A builder for [Thumbnail]. */ - class Builder internal constructor() { + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } - private var type: JsonValue = JsonValue.from("thumbnail") - private var value: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = - mutableMapOf() + override fun hashCode(): Int = hashCode - @JvmSynthetic - internal fun from(thumbnail: Thumbnail) = apply { - type = thumbnail.type - value = thumbnail.value - additionalProperties = thumbnail.additionalProperties.toMutableMap() - } + override fun toString() = + "Thumbnail{type=$type, value=$value, additionalProperties=$additionalProperties}" + } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field - * defaults to the following: - * ```java - * JsonValue.from("thumbnail") - * ``` - * - * This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** Optional transformation string. **Example**: `w-150,h-150` */ - fun value(value: String) = value(MultipartField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun value(value: MultipartField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + class Abs + private constructor( + private val protocol: MultipartField, + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Streaming protocol to use (`hls` or `dash`). + * + * @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 protocol(): Protocol = protocol.value.getRequired("protocol") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Adaptive Bitrate Streaming (ABS) setup. + * + * Expected to always return the following: + * ```java + * JsonValue.from("abs") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * List of different representations you want to create separated by an underscore. + * + * @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 value(): String = value.value.getRequired("value") - /** - * Returns an immutable instance of [Thumbnail]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): Thumbnail = - Thumbnail(type, value, additionalProperties.toMutableMap()) - } + /** + * Returns the raw multipart value of [protocol]. + * + * Unlike [protocol], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("protocol") + @ExcludeMissing + fun _protocol(): MultipartField = protocol - private var validated: Boolean = false + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value - fun validate(): Thumbnail = apply { - if (validated) { - return@apply - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - _type().let { - if (it != JsonValue.from("thumbnail")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - value() - validated = true - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + companion object { - return other is Thumbnail && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } + /** + * Returns a mutable builder for constructing an instance of [Abs]. + * + * The following fields are required: + * ```java + * .protocol() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - private val hashCode: Int by lazy { - Objects.hash(type, value, additionalProperties) - } + /** A builder for [Abs]. */ + class Builder internal constructor() { - override fun hashCode(): Int = hashCode + private var protocol: MultipartField? = null + private var type: JsonValue = JsonValue.from("abs") + private var value: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() - override fun toString() = - "Thumbnail{type=$type, value=$value, additionalProperties=$additionalProperties}" + @JvmSynthetic + internal fun from(abs: Abs) = apply { + protocol = abs.protocol + type = abs.type + value = abs.value + additionalProperties = abs.additionalProperties.toMutableMap() } - class Abs - private constructor( - private val protocol: MultipartField, - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { + /** Streaming protocol to use (`hls` or `dash`). */ + fun protocol(protocol: Protocol) = protocol(MultipartField.of(protocol)) - /** - * Streaming protocol to use (`hls` or `dash`). - * - * @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 protocol(): Protocol = protocol.value.getRequired("protocol") + /** + * Sets [Builder.protocol] to an arbitrary multipart value. + * + * You should usually call [Builder.protocol] with a well-typed [Protocol] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun protocol(protocol: MultipartField) = apply { + this.protocol = protocol + } - /** - * Adaptive Bitrate Streaming (ABS) setup. - * - * Expected to always return the following: - * ```java - * JsonValue.from("abs") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("abs") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } - /** - * List of different representations you want to create separated by an - * underscore. - * - * @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 value(): String = value.value.getRequired("value") + /** + * List of different representations you want to create separated by an + * underscore. + */ + fun value(value: String) = value(MultipartField.of(value)) - /** - * Returns the raw multipart value of [protocol]. - * - * Unlike [protocol], this method doesn't throw if the multipart field has - * an unexpected type. - */ - @JsonProperty("protocol") - @ExcludeMissing - fun _protocol(): MultipartField = protocol + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } - /** - * Returns the raw multipart value of [value]. - * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): MultipartField = value + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Abs]. - * - * The following fields are required: - * ```java - * .protocol() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - /** A builder for [Abs]. */ - class Builder internal constructor() { - - private var protocol: MultipartField? = null - private var type: JsonValue = JsonValue.from("abs") - private var value: MultipartField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(abs: Abs) = apply { - protocol = abs.protocol - type = abs.type - value = abs.value - additionalProperties = abs.additionalProperties.toMutableMap() - } - - /** Streaming protocol to use (`hls` or `dash`). */ - fun protocol(protocol: Protocol) = protocol(MultipartField.of(protocol)) - - /** - * Sets [Builder.protocol] to an arbitrary multipart value. - * - * You should usually call [Builder.protocol] with a well-typed - * [Protocol] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun protocol(protocol: MultipartField) = apply { - this.protocol = protocol - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field - * defaults to the following: - * ```java - * JsonValue.from("abs") - * ``` - * - * This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** - * List of different representations you want to create separated by an - * underscore. - */ - fun value(value: String) = value(MultipartField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun value(value: MultipartField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Returns an immutable instance of [Abs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .protocol() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Abs = + Abs( + checkRequired("protocol", protocol), + type, + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + private var validated: Boolean = false - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun validate(): Abs = apply { + if (validated) { + return@apply + } - /** - * Returns an immutable instance of [Abs]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .protocol() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Abs = - Abs( - checkRequired("protocol", protocol), - type, - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) + protocol().validate() + _type().let { + if (it != JsonValue.from("abs")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") } + } + value() + validated = true + } - private var validated: Boolean = false + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - fun validate(): Abs = apply { - if (validated) { - return@apply - } + /** Streaming protocol to use (`hls` or `dash`). */ + class Protocol + @JsonCreator + private constructor(private val value: JsonField) : Enum { - protocol().validate() - _type().let { - if (it != JsonValue.from("abs")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - value() - validated = true - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + companion object { - /** Streaming protocol to use (`hls` or `dash`). */ - class Protocol - @JsonCreator - private constructor(private val value: JsonField) : Enum { + @JvmField val HLS = of("hls") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from - * data that doesn't match any known member, and you want to know that - * value. For example, if the SDK is on an older version than the API, - * then the API may respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @JvmField val DASH = of("dash") - companion object { + @JvmStatic fun of(value: String) = Protocol(JsonField.of(value)) + } - @JvmField val HLS = of("hls") + /** An enum containing [Protocol]'s known values. */ + enum class Known { + HLS, + DASH, + } - @JvmField val DASH = of("dash") + /** + * An enum containing [Protocol]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Protocol] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HLS, + DASH, + /** + * An enum member indicating that [Protocol] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - @JvmStatic fun of(value: String) = Protocol(JsonField.of(value)) - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HLS -> Value.HLS + DASH -> Value.DASH + else -> Value._UNKNOWN + } - /** An enum containing [Protocol]'s known values. */ - enum class Known { - HLS, - DASH, - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HLS -> Known.HLS + DASH -> Known.DASH + else -> throw ImageKitInvalidDataException("Unknown Protocol: $value") + } - /** - * An enum containing [Protocol]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [Protocol] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. - * For example, if the SDK is on an older version than the API, then - * the API may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - HLS, - DASH, - /** - * An enum member indicating that [Protocol] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } - /** - * Returns an enum member corresponding to this class instance's value, - * or [Value._UNKNOWN] if the class was instantiated with an unknown - * value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - HLS -> Value.HLS - DASH -> Value.DASH - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is - * always known and don't want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value - * is a not a known member. - */ - fun known(): Known = - when (this) { - HLS -> Known.HLS - DASH -> Known.DASH - else -> - throw ImageKitInvalidDataException( - "Unknown Protocol: $value" - ) - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is - * primarily for debugging and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value - * does not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Protocol = apply { - if (validated) { - return@apply - } - - known() - validated = true - } + private var validated: Boolean = false - 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 (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Protocol && value == other.value - } + fun validate(): Protocol = apply { + if (validated) { + return@apply + } - override fun hashCode() = value.hashCode() + known() + validated = true + } - override fun toString() = value.toString() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - return other is Abs && - protocol == other.protocol && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - private val hashCode: Int by lazy { - Objects.hash(protocol, type, value, additionalProperties) - } + return other is Protocol && value == other.value + } - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "Abs{protocol=$protocol, type=$type, value=$value, additionalProperties=$additionalProperties}" - } + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -8364,86 +5039,41 @@ private constructor( return true } - return other is Transformation && - post == other.post && - pre == other.pre && + return other is Abs && + protocol == other.protocol && + type == other.type && + value == other.value && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(post, pre, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(protocol, type, value, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "Transformation{post=$post, pre=$pre, additionalProperties=$additionalProperties}" + "Abs{protocol=$protocol, type=$type, value=$value, additionalProperties=$additionalProperties}" } + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FileUploadV1ByUrl && - file == other.file && - fileName == other.fileName && - token == other.token && - checks == other.checks && - customCoordinates == other.customCoordinates && - customMetadata == other.customMetadata && - description == other.description && - expire == other.expire && - extensions == other.extensions && - folder == other.folder && - isPrivateFile == other.isPrivateFile && - isPublished == other.isPublished && - overwriteAiTags == other.overwriteAiTags && - overwriteCustomMetadata == other.overwriteCustomMetadata && - overwriteFile == other.overwriteFile && - overwriteTags == other.overwriteTags && - publicKey == other.publicKey && - responseFields == other.responseFields && - signature == other.signature && - tags == other.tags && - transformation == other.transformation && - useUniqueFileName == other.useUniqueFileName && - webhookUrl == other.webhookUrl && - additionalProperties == other.additionalProperties + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - private val hashCode: Int by lazy { - Objects.hash( - file, - fileName, - token, - checks, - customCoordinates, - customMetadata, - description, - expire, - extensions, - folder, - isPrivateFile, - isPublished, - overwriteAiTags, - overwriteCustomMetadata, - overwriteFile, - overwriteTags, - publicKey, - responseFields, - signature, - tags, - transformation, - useUniqueFileName, - webhookUrl, - additionalProperties, - ) - } + return other is Transformation && + post == other.post && + pre == other.pre && + additionalProperties == other.additionalProperties + } - override fun hashCode(): Int = hashCode + private val hashCode: Int by lazy { Objects.hash(post, pre, additionalProperties) } - override fun toString() = - "FileUploadV1ByUrl{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, expire=$expire, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, publicKey=$publicKey, responseFields=$responseFields, signature=$signature, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" - } + override fun hashCode(): Int = hashCode + + override fun toString() = + "Transformation{post=$post, pre=$pre, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt index addd9d29..f5db6fe3 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt @@ -220,23 +220,15 @@ interface FileServiceAsync { * file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. * - [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies. */ - fun upload(): CompletableFuture = upload(FileUploadParams.none()) + fun upload(params: FileUploadParams): CompletableFuture = + upload(params, RequestOptions.none()) /** @see upload */ fun upload( - params: FileUploadParams = FileUploadParams.none(), + params: FileUploadParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see upload */ - fun upload( - params: FileUploadParams = FileUploadParams.none() - ): CompletableFuture = upload(params, RequestOptions.none()) - - /** @see upload */ - fun upload(requestOptions: RequestOptions): CompletableFuture = - upload(FileUploadParams.none(), requestOptions) - /** A view of [FileServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -414,25 +406,15 @@ interface FileServiceAsync { * Returns a raw HTTP response for `post /api/v1/files/upload`, but is otherwise the same as * [FileServiceAsync.upload]. */ - fun upload(): CompletableFuture> = - upload(FileUploadParams.none()) - - /** @see upload */ fun upload( - params: FileUploadParams = FileUploadParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see upload */ - fun upload( - params: FileUploadParams = FileUploadParams.none() + params: FileUploadParams ): CompletableFuture> = upload(params, RequestOptions.none()) /** @see upload */ fun upload( - requestOptions: RequestOptions - ): CompletableFuture> = - upload(FileUploadParams.none(), requestOptions) + params: FileUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt index 5743ebbd..bafc4724 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt @@ -346,11 +346,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien else "https://upload.imagekit.io" ) .addPathSegments("api", "v1", "files", "upload") - .apply { - params._body().ifPresent { - body(multipartFormData(clientOptions.jsonMapper, it)) - } - } + .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt index 51e5acf6..8f4e8f80 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt @@ -202,22 +202,14 @@ interface FileService { * file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. * - [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies. */ - fun upload(): FileUploadResponse = upload(FileUploadParams.none()) + fun upload(params: FileUploadParams): FileUploadResponse = upload(params, RequestOptions.none()) /** @see upload */ fun upload( - params: FileUploadParams = FileUploadParams.none(), + params: FileUploadParams, requestOptions: RequestOptions = RequestOptions.none(), ): FileUploadResponse - /** @see upload */ - fun upload(params: FileUploadParams = FileUploadParams.none()): FileUploadResponse = - upload(params, RequestOptions.none()) - - /** @see upload */ - fun upload(requestOptions: RequestOptions): FileUploadResponse = - upload(FileUploadParams.none(), requestOptions) - /** A view of [FileService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -404,24 +396,14 @@ interface FileService { * [FileService.upload]. */ @MustBeClosed - fun upload(): HttpResponseFor = upload(FileUploadParams.none()) + fun upload(params: FileUploadParams): HttpResponseFor = + upload(params, RequestOptions.none()) /** @see upload */ @MustBeClosed fun upload( - params: FileUploadParams = FileUploadParams.none(), + params: FileUploadParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - - /** @see upload */ - @MustBeClosed - fun upload( - params: FileUploadParams = FileUploadParams.none() - ): HttpResponseFor = upload(params, RequestOptions.none()) - - /** @see upload */ - @MustBeClosed - fun upload(requestOptions: RequestOptions): HttpResponseFor = - upload(FileUploadParams.none(), requestOptions) } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt index 85fd05b1..6448f2b3 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt @@ -315,11 +315,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti else "https://upload.imagekit.io" ) .addPathSegments("api", "v1", "files", "upload") - .apply { - params._body().ifPresent { - body(multipartFormData(clientOptions.jsonMapper, it)) - } - } + .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt index 7957b53f..11752909 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt @@ -5,7 +5,6 @@ package com.imagekit.api.models.files import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField import java.io.InputStream -import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,95 +13,81 @@ internal class FileUploadParamsTest { @Test fun create() { FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg.builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension.AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post.Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() } @@ -110,101 +95,84 @@ internal class FileUploadParamsTest { fun body() { val params = FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg.builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post.Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() - val body = params._body().getOrNull() + val body = params._body() assertThat(body.filterValues { !it.value.isNull() }) .usingRecursiveComparison() @@ -216,135 +184,89 @@ internal class FileUploadParamsTest { ) .isEqualTo( mapOf( - "body" to - MultipartField.builder() - .value( - FileUploadParams.Body.ofFileUploadV1( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata + "file" to MultipartField.of("some content".byteInputStream()), + "fileName" to MultipartField.of("fileName"), + "token" to MultipartField.of("token"), + "checks" to MultipartField.of("\"request.folder\" : \"marketing/\"\n"), + "customCoordinates" to MultipartField.of("customCoordinates"), + "customMetadata" to + MultipartField.of( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ), + "description" to MultipartField.of("Running shoes"), + "expire" to MultipartField.of(0L), + "extensions" to + MultipartField.of( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options .builder() - .putAdditionalProperty( - "brand", - JsonValue.from("bar"), - ) - .putAdditionalProperty( - "color", - JsonValue.from("bar"), - ) + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension - .ofRemoveBg( - FileUploadParams.Body.FileUploadV1 - .Extension - .RemoveBg - .builder() - .options( - FileUploadParams.Body - .FileUploadV1 - .Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAutoTagging( - FileUploadParams.Body.FileUploadV1 - .Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body - .FileUploadV1 - .Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField - .TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation - .builder() - .addPost( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Thumbnail - .builder() - .value("w-150,h-150") - .build() - ) - .addPost( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() - ) - .pre("w-300,h-300,q-80") - .build() + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ), + "folder" to MultipartField.of("folder"), + "isPrivateFile" to MultipartField.of(true), + "isPublished" to MultipartField.of(true), + "overwriteAITags" to MultipartField.of(true), + "overwriteCustomMetadata" to MultipartField.of(true), + "overwriteFile" to MultipartField.of(true), + "overwriteTags" to MultipartField.of(true), + "publicKey" to MultipartField.of("publicKey"), + "responseFields" to + MultipartField.of( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ), + "signature" to MultipartField.of("signature"), + "tags" to MultipartField.of(listOf("t-shirt", "round-neck", "men")), + "transformation" to + MultipartField.of( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol + .DASH ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .value("sr-240_360_480_720_1080") .build() ) - ) - .contentType("application/octet-stream") - .build() + .pre("w-300,h-300,q-80") + .build() + ), + "useUniqueFileName" to MultipartField.of(true), + "webhookUrl" to MultipartField.of("https://example.com"), ) .mapValues { (_, field) -> field.map { (it as? ByteArray)?.inputStream() ?: it } @@ -354,10 +276,30 @@ internal class FileUploadParamsTest { @Test fun bodyWithoutOptionalFields() { - val params = FileUploadParams.builder().build() + val params = + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .build() - val body = params._body().getOrNull() + val body = params._body() - assertThat(body.filterValues { !it.value.isNull() }).isEmpty() + assertThat(body.filterValues { !it.value.isNull() }) + .usingRecursiveComparison() + // TODO(AssertJ): Replace this and the `mapValues` below with: + // https://github.com/assertj/assertj/issues/3165 + .withEqualsForType( + { a, b -> a.readBytes() contentEquals b.readBytes() }, + InputStream::class.java, + ) + .isEqualTo( + mapOf( + "file" to MultipartField.of("some content".byteInputStream()), + "fileName" to MultipartField.of("fileName"), + ) + .mapValues { (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt index ff35db98..33349dd2 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt @@ -73,107 +73,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) - .pre("w-300,h-300,q-80") + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -197,107 +173,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -321,107 +273,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -445,107 +373,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -569,107 +473,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -693,107 +573,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -817,107 +673,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -941,107 +773,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) - .pre("w-300,h-300,q-80") + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -1065,107 +873,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -1189,107 +973,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -1313,107 +1073,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -1437,107 +1173,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) - .pre("w-300,h-300,q-80") + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -1561,107 +1273,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) - .pre("w-300,h-300,q-80") + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -1685,107 +1373,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) - .pre("w-300,h-300,q-80") + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -1809,107 +1473,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) - .pre("w-300,h-300,q-80") + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -1933,107 +1573,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) - .pre("w-300,h-300,q-80") + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -2055,107 +1671,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) - .pre("w-300,h-300,q-80") + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt index 6a14b916..f26281ec 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt @@ -4,6 +4,7 @@ package com.imagekit.api.services import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.equalTo +import com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath import com.github.tomakehurst.wiremock.client.WireMock.ok import com.github.tomakehurst.wiremock.client.WireMock.post import com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor @@ -44,100 +45,84 @@ internal class ServiceParamsTest { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg.builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post.Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .putAdditionalHeader("Secret-Header", "42") .putAdditionalQueryParam("secret_query_param", "42") + .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) .build() ) @@ -145,6 +130,7 @@ internal class ServiceParamsTest { postRequestedFor(anyUrl()) .withHeader("Secret-Header", equalTo("42")) .withQueryParam("secret_query_param", equalTo("42")) + .withRequestBody(matchingJsonPath("$.secretProperty", equalTo("42"))) ) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index 3acc3a30..6e8d541b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -227,104 +227,83 @@ internal class FileServiceAsyncTest { val responseFuture = fileServiceAsync.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1.Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) - .pre("w-300,h-300,q-80") + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index 89de610f..2e932b81 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -220,104 +220,83 @@ internal class FileServiceTest { val response = fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1.Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) - .pre("w-300,h-300,q-80") + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) From 1341b6282b4a32013cb60f11ee0ec9aaef8acac4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 11:42:44 +0000 Subject: [PATCH 012/142] feat(api): manual updates --- .stats.yml | 4 +- README.md | 93 +- .../api/models/files/FileUploadParams.kt | 11478 ++++++++++------ .../api/services/async/FileServiceAsync.kt | 32 +- .../services/async/FileServiceAsyncImpl.kt | 6 +- .../api/services/blocking/FileService.kt | 28 +- .../api/services/blocking/FileServiceImpl.kt | 6 +- .../api/models/files/FileUploadParamsTest.kt | 530 +- .../api/services/ErrorHandlingTest.kt | 2788 ++-- .../api/services/ServiceParamsTest.kt | 156 +- .../services/async/FileServiceAsyncTest.kt | 161 +- .../api/services/blocking/FileServiceTest.kt | 161 +- 12 files changed, 9677 insertions(+), 5766 deletions(-) diff --git a/.stats.yml b/.stats.yml index cfcbd7f7..db7d8f1e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml -openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-9ae7b43dcfd6208ca37c32c887630ae186ec338bcdd36902b6fe5d1cc66459dc.yml +openapi_spec_hash: 25fb64c067e64bcff6eaaabda26de397 config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c diff --git a/README.md b/README.md index 4e268347..d7b4537c 100644 --- a/README.md +++ b/README.md @@ -50,17 +50,12 @@ import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; -import java.io.ByteArrayInputStream; // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); -FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) - .fileName("file-name.jpg") - .build(); -FileUploadResponse response = client.files().upload(params); +FileUploadResponse response = client.files().upload(); ``` ## Client configuration @@ -155,18 +150,13 @@ import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; -import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); -FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) - .fileName("file-name.jpg") - .build(); -CompletableFuture response = client.async().files().upload(params); +CompletableFuture response = client.async().files().upload(); ``` Or create an asynchronous client from the beginning: @@ -176,18 +166,13 @@ import com.imagekit.api.client.ImageKitClientAsync; import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; -import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv(); -FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) - .fileName("file-name.jpg") - .build(); -CompletableFuture response = client.files().upload(params); +CompletableFuture response = client.files().upload(); ``` The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. @@ -199,50 +184,50 @@ The SDK defines methods that accept files. To upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html): ```java -import com.imagekit.api.models.files.FileUploadParams; -import com.imagekit.api.models.files.FileUploadResponse; +import com.imagekit.api.models.beta.v2.files.FileUploadParams; +import com.imagekit.api.models.beta.v2.files.FileUploadResponse; import java.nio.file.Paths; FileUploadParams params = FileUploadParams.builder() .fileName("fileName") .file(Paths.get("/path/to/file")) .build(); -FileUploadResponse response = client.files().upload(params); +FileUploadResponse response = client.beta().v2().files().upload(params); ``` Or an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html): ```java -import com.imagekit.api.models.files.FileUploadParams; -import com.imagekit.api.models.files.FileUploadResponse; +import com.imagekit.api.models.beta.v2.files.FileUploadParams; +import com.imagekit.api.models.beta.v2.files.FileUploadResponse; import java.net.URL; FileUploadParams params = FileUploadParams.builder() .fileName("fileName") .file(new URL("https://example.com//path/to/file").openStream()) .build(); -FileUploadResponse response = client.files().upload(params); +FileUploadResponse response = client.beta().v2().files().upload(params); ``` Or a `byte[]` array: ```java -import com.imagekit.api.models.files.FileUploadParams; -import com.imagekit.api.models.files.FileUploadResponse; +import com.imagekit.api.models.beta.v2.files.FileUploadParams; +import com.imagekit.api.models.beta.v2.files.FileUploadResponse; FileUploadParams params = FileUploadParams.builder() .fileName("fileName") .file("content".getBytes()) .build(); -FileUploadResponse response = client.files().upload(params); +FileUploadResponse response = client.beta().v2().files().upload(params); ``` Note that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt): ```java import com.imagekit.api.core.MultipartField; -import com.imagekit.api.models.files.FileUploadParams; -import com.imagekit.api.models.files.FileUploadResponse; +import com.imagekit.api.models.beta.v2.files.FileUploadParams; +import com.imagekit.api.models.beta.v2.files.FileUploadResponse; import java.io.InputStream; import java.net.URL; @@ -253,7 +238,7 @@ FileUploadParams params = FileUploadParams.builder() .filename("/path/to/file") .build()) .build(); -FileUploadResponse response = client.files().upload(params); +FileUploadResponse response = client.beta().v2().files().upload(params); ``` ## Raw responses @@ -267,13 +252,8 @@ import com.imagekit.api.core.http.Headers; import com.imagekit.api.core.http.HttpResponseFor; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; -import java.io.ByteArrayInputStream; -FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) - .fileName("file-name.jpg") - .build(); -HttpResponseFor response = client.files().withRawResponse().upload(params); +HttpResponseFor response = client.files().withRawResponse().upload(); int statusCode = response.statusCode(); Headers headers = response.headers(); @@ -382,9 +362,7 @@ To set a custom timeout, configure the method call using the `timeout` method: ```java import com.imagekit.api.models.files.FileUploadResponse; -FileUploadResponse response = client.files().upload( - params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build() -); +FileUploadResponse response = client.files().upload(RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()); ``` Or configure the default for all method calls at the client level: @@ -502,10 +480,10 @@ To set undocumented parameters on _nested_ headers, query params, or body classe ```java import com.imagekit.api.core.JsonValue; -import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams; -FileUploadParams params = FileUploadParams.builder() - .transformation(FileUploadParams.Transformation.builder() +CustomMetadataFieldCreateParams params = CustomMetadataFieldCreateParams.builder() + .schema(CustomMetadataFieldCreateParams.Schema.builder() .putAdditionalProperty("secretProperty", JsonValue.from("42")) .build()) .build(); @@ -516,13 +494,9 @@ These properties can be accessed on the nested built object later using the `_ad To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter: ```java -import com.imagekit.api.core.JsonValue; import com.imagekit.api.models.files.FileUploadParams; -FileUploadParams params = FileUploadParams.builder() - .file(JsonValue.from(42)) - .fileName("file-name.jpg") - .build(); +FileUploadParams params = FileUploadParams.builder().build(); ``` The most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method: @@ -570,11 +544,15 @@ To forcibly omit a required parameter or property, pass [`JsonMissing`](image-ki ```java import com.imagekit.api.core.JsonMissing; +import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams; import com.imagekit.api.models.files.FileUploadParams; -FileUploadParams params = FileUploadParams.builder() - .fileName("fileName") - .file(JsonMissing.of()) +FileUploadParams params = CustomMetadataFieldCreateParams.builder() + .name("price") + .schema(CustomMetadataFieldCreateParams.Schema.builder() + .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) + .build()) + .label(JsonMissing.of()) .build(); ``` @@ -614,22 +592,21 @@ To access a property's raw JSON value, which may be undocumented, call its `_` p ```java import com.imagekit.api.core.JsonField; -import java.io.InputStream; import java.util.Optional; -JsonField file = client.files().upload(params)._file(); +JsonField field = client.files().upload(params)._field(); -if (file.isMissing()) { +if (field.isMissing()) { // The property is absent from the JSON response -} else if (file.isNull()) { +} else if (field.isNull()) { // The property was set to literal null } else { // Check if value was provided as a string // Other methods include `asNumber()`, `asBoolean()`, etc. - Optional jsonString = file.asString(); + Optional jsonString = field.asString(); // Try to deserialize into a custom type - MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class); + MyClass myObject = field.asUnknown().orElseThrow().convert(MyClass.class); } ``` @@ -652,9 +629,7 @@ Or configure the method call to validate the response using the `responseValidat ```java import com.imagekit.api.models.files.FileUploadResponse; -FileUploadResponse response = client.files().upload( - params, RequestOptions.builder().responseValidation(true).build() -); +FileUploadResponse response = client.files().upload(RequestOptions.builder().responseValidation(true).build()); ``` Or configure the default for all method calls at the client level: diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt index e50852f0..f50bfafd 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -21,6 +21,7 @@ import com.imagekit.api.core.JsonField import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField import com.imagekit.api.core.Params +import com.imagekit.api.core.allMaxBy import com.imagekit.api.core.checkKnown import com.imagekit.api.core.checkRequired import com.imagekit.api.core.getOrThrow @@ -61,1771 +62,4438 @@ import kotlin.jvm.optionals.getOrNull */ class FileUploadParams private constructor( - private val body: Body, + private val body: MultipartField, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. - * - * @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 file(): InputStream = body.file() - - /** - * The name with which the file has to be uploaded. The file name can contain: - * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - * - Special Characters: `.`, `-` - * - * Any other character including space will be replaced by `_` - * - * @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 fileName(): String = body.fileName() - - /** - * A unique value that the ImageKit.io server will use to recognize and prevent subsequent - * retries for the same request. We suggest using V4 UUIDs, or another random string with enough - * entropy to avoid collisions. This field is only required for authentication when uploading a - * file from the client side. - * - * **Note**: Sending a value that has been used in the past will result in a validation error. - * Even if your previous request resulted in an error, you should always send a new value for - * this field. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun token(): Optional = body.token() - - /** - * Server-side checks to run on the asset. Read more about - * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). - * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun checks(): Optional = body.checks() + fun body(): Optional = body.value.getOptional("body") /** - * Define an important area in the image. This is only relevant for image type files. - * - To be passed as a string with the x and y coordinates of the top-left corner, and width and - * height of the area of interest in the format `x,y,width,height`. For example - - * `10,10,100,100` - * - Can be used with fo-customtransformation. - * - If this field is not specified and the file is overwritten, then customCoordinates will be - * removed. + * Returns the raw multipart value of [body]. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * Unlike [body], this method doesn't throw if the multipart field has an unexpected type. */ - fun customCoordinates(): Optional = body.customCoordinates() + @JsonProperty("body") @ExcludeMissing fun _body(): MultipartField = body - /** - * JSON key-value pairs to associate with the asset. Create the custom metadata fields before - * setting these values. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun customMetadata(): Optional = body.customMetadata() + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders - /** - * Optional text to describe the contents of the file. - * - * @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() + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams - /** - * The time until your signature is valid. It must be a - * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. It - * should be in seconds. This field is only required for authentication when uploading a file - * from the client side. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun expire(): Optional = body.expire() + fun toBuilder() = Builder().from(this) - /** - * Array of extensions to be applied to the image. Each extension can be configured with - * specific parameters based on the extension type. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun extensions(): Optional> = body.extensions() + companion object { - /** - * The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, - * a new folder(s) is created. - * - * The folder name can contain: - * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - * - Special Characters: `/` , `_` , `-` - * - * Using multiple `/` creates a nested folder. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun folder(): Optional = body.folder() + @JvmStatic fun none(): FileUploadParams = builder().build() - /** - * Whether to mark the file as private or not. - * - * If `true`, the file is marked as private and is accessible only using named transformation or - * signed URL. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun isPrivateFile(): Optional = body.isPrivateFile() + /** Returns a mutable builder for constructing an instance of [FileUploadParams]. */ + @JvmStatic fun builder() = Builder() + } - /** - * Whether to upload file as published or not. - * - * If `false`, the file is marked as unpublished, which restricts access to the file only via - * the media library. Files in draft or unpublished state can only be publicly accessed after - * being published. - * - * The option to upload in draft state is only available in custom enterprise pricing plans. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun isPublished(): Optional = body.isPublished() + /** A builder for [FileUploadParams]. */ + class Builder internal constructor() { - /** - * If set to `true` and a file already exists at the exact location, its AITags will be removed. - * Set `overwriteAITags` to `false` to preserve AITags. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun overwriteAiTags(): Optional = body.overwriteAiTags() + private var body: MultipartField = MultipartField.of(null) + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - /** - * If the request does not have `customMetadata`, and a file already exists at the exact - * location, existing customMetadata will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun overwriteCustomMetadata(): Optional = body.overwriteCustomMetadata() + @JvmSynthetic + internal fun from(fileUploadParams: FileUploadParams) = apply { + body = fileUploadParams.body + additionalHeaders = fileUploadParams.additionalHeaders.toBuilder() + additionalQueryParams = fileUploadParams.additionalQueryParams.toBuilder() + } - /** - * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact - * location, upload API will return an error immediately. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun overwriteFile(): Optional = body.overwriteFile() + fun body(body: Body) = + body( + MultipartField.builder() + .value(body) + .contentType("application/octet-stream") + .build() + ) - /** - * If the request does not have `tags`, and a file already exists at the exact location, - * existing tags will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun overwriteTags(): Optional = body.overwriteTags() + /** + * Sets [Builder.body] to an arbitrary multipart value. + * + * You should usually call [Builder.body] with a well-typed [Body] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun body(body: MultipartField) = apply { this.body = body } - /** - * Your ImageKit.io public key. This field is only required for authentication when uploading a - * file from the client side. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun publicKey(): Optional = body.publicKey() + /** Alias for calling [body] with `Body.ofFileUploadV1(fileUploadV1)`. */ + fun body(fileUploadV1: Body.FileUploadV1) = body(Body.ofFileUploadV1(fileUploadV1)) - /** - * Array of response field keys to include in the API response body. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun responseFields(): Optional> = body.responseFields() + /** Alias for calling [body] with `Body.ofFileUploadByUrlv1(fileUploadByUrlv1)`. */ + fun body(fileUploadByUrlv1: Body.FileUploadByUrlv1) = + body(Body.ofFileUploadByUrlv1(fileUploadByUrlv1)) - /** - * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. Learn - * how to create a signature on the page below. This should be in lowercase. - * - * Signature must be calculated on the server-side. This field is only required for - * authentication when uploading a file from the client side. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun signature(): Optional = body.signature() + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - /** - * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", - * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the `%` - * character is not allowed. If this field is not specified and the file is overwritten, the - * existing tags will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun tags(): Optional> = body.tags() + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing file - * size or applying basic optimizations upfront (e.g., resize, compress). - * - `post` — applied immediately after upload. Ideal for generating transformed versions (like - * video encodes or thumbnails) in advance, so they're ready for delivery without delay. - * - * You can mix and match any combination of post-processing types. - * - * @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() + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - /** - * Whether to use a unique filename for this file or not. - * - * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique - * filename. - * - * If `false`, then the image is uploaded with the provided filename parameter, and any existing - * file with the same name is replaced. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun useUniqueFileName(): Optional = body.useUniqueFileName() + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - /** - * The final status of extensions after they have completed execution will be delivered to this - * endpoint as a POST request. - * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - * about the webhook payload structure. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun webhookUrl(): Optional = body.webhookUrl() + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - /** - * Returns the raw multipart value of [file]. - * - * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _file(): MultipartField = body._file() + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - /** - * Returns the raw multipart value of [fileName]. - * - * Unlike [fileName], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _fileName(): MultipartField = body._fileName() + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - /** - * Returns the raw multipart value of [token]. - * - * Unlike [token], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _token(): MultipartField = body._token() + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - /** - * Returns the raw multipart value of [checks]. - * - * Unlike [checks], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _checks(): MultipartField = body._checks() + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - /** - * Returns the raw multipart value of [customCoordinates]. - * - * Unlike [customCoordinates], this method doesn't throw if the multipart field has an - * unexpected type. - */ - fun _customCoordinates(): MultipartField = body._customCoordinates() + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - /** - * Returns the raw multipart value of [customMetadata]. - * - * Unlike [customMetadata], this method doesn't throw if the multipart field has an unexpected - * type. - */ - fun _customMetadata(): MultipartField = body._customMetadata() + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - /** - * Returns the raw multipart value of [description]. - * - * Unlike [description], this method doesn't throw if the multipart field has an unexpected - * type. - */ - fun _description(): MultipartField = body._description() + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - /** - * Returns the raw multipart value of [expire]. - * - * Unlike [expire], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _expire(): MultipartField = body._expire() + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - /** - * Returns the raw multipart value of [extensions]. - * - * Unlike [extensions], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _extensions(): MultipartField> = body._extensions() + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - /** - * Returns the raw multipart value of [folder]. - * - * Unlike [folder], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _folder(): MultipartField = body._folder() + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - /** - * Returns the raw multipart value of [isPrivateFile]. - * - * Unlike [isPrivateFile], this method doesn't throw if the multipart field has an unexpected - * type. - */ - fun _isPrivateFile(): MultipartField = body._isPrivateFile() + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - /** - * Returns the raw multipart value of [isPublished]. - * - * Unlike [isPublished], this method doesn't throw if the multipart field has an unexpected - * type. - */ - fun _isPublished(): MultipartField = body._isPublished() + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } - /** - * Returns the raw multipart value of [overwriteAiTags]. - * - * Unlike [overwriteAiTags], this method doesn't throw if the multipart field has an unexpected - * type. - */ - fun _overwriteAiTags(): MultipartField = body._overwriteAiTags() + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } - /** - * Returns the raw multipart value of [overwriteCustomMetadata]. - * - * Unlike [overwriteCustomMetadata], this method doesn't throw if the multipart field has an - * unexpected type. - */ - fun _overwriteCustomMetadata(): MultipartField = body._overwriteCustomMetadata() + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - /** - * Returns the raw multipart value of [overwriteFile]. - * - * Unlike [overwriteFile], this method doesn't throw if the multipart field has an unexpected - * type. - */ - fun _overwriteFile(): MultipartField = body._overwriteFile() + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - /** - * Returns the raw multipart value of [overwriteTags]. - * - * Unlike [overwriteTags], this method doesn't throw if the multipart field has an unexpected - * type. - */ - fun _overwriteTags(): MultipartField = body._overwriteTags() + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } - /** - * Returns the raw multipart value of [publicKey]. - * - * Unlike [publicKey], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _publicKey(): MultipartField = body._publicKey() - - /** - * Returns the raw multipart value of [responseFields]. - * - * Unlike [responseFields], this method doesn't throw if the multipart field has an unexpected - * type. - */ - fun _responseFields(): MultipartField> = body._responseFields() - - /** - * Returns the raw multipart value of [signature]. - * - * Unlike [signature], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _signature(): MultipartField = body._signature() - - /** - * Returns the raw multipart value of [tags]. - * - * Unlike [tags], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _tags(): MultipartField> = body._tags() - - /** - * Returns the raw multipart value of [transformation]. - * - * Unlike [transformation], this method doesn't throw if the multipart field has an unexpected - * type. - */ - fun _transformation(): MultipartField = body._transformation() - - /** - * Returns the raw multipart value of [useUniqueFileName]. - * - * Unlike [useUniqueFileName], this method doesn't throw if the multipart field has an - * unexpected type. - */ - fun _useUniqueFileName(): MultipartField = body._useUniqueFileName() - - /** - * Returns the raw multipart value of [webhookUrl]. - * - * Unlike [webhookUrl], this method doesn't throw if the multipart field has an unexpected type. - */ - fun _webhookUrl(): MultipartField = body._webhookUrl() - - 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 [FileUploadParams]. - * - * The following fields are required: - * ```java - * .file() - * .fileName() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FileUploadParams]. */ - class Builder internal constructor() { + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - @JvmSynthetic - internal fun from(fileUploadParams: FileUploadParams) = apply { - body = fileUploadParams.body.toBuilder() - additionalHeaders = fileUploadParams.additionalHeaders.toBuilder() - additionalQueryParams = fileUploadParams.additionalQueryParams.toBuilder() + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) } /** - * Sets the entire request body. + * Returns an immutable instance of [FileUploadParams]. * - * 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: - * - [file] - * - [fileName] - * - [token] - * - [checks] - * - [customCoordinates] - * - etc. + * Further updates to this [Builder] will not mutate the returned instance. */ - fun body(body: Body) = apply { this.body = body.toBuilder() } + fun build(): FileUploadParams = + FileUploadParams(body, additionalHeaders.build(), additionalQueryParams.build()) + } - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. - */ - fun file(file: InputStream) = apply { body.file(file) } + fun _body(): Map> = + (mapOf("body" to _body()) + + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) + .toImmutable() - /** - * Sets [Builder.file] to an arbitrary multipart value. - * - * You should usually call [Builder.file] with a well-typed [InputStream] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun file(file: MultipartField) = apply { body.file(file) } + override fun _headers(): Headers = additionalHeaders - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. - */ - fun file(file: ByteArray) = apply { body.file(file) } + override fun _queryParams(): QueryParams = additionalQueryParams - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. - */ - fun file(path: Path) = apply { body.file(path) } + @JsonDeserialize(using = Body.Deserializer::class) + @JsonSerialize(using = Body.Serializer::class) + class Body + private constructor( + private val fileUploadV1: FileUploadV1? = null, + private val fileUploadByUrlv1: FileUploadByUrlv1? = null, + private val _json: JsonValue? = null, + ) { - /** - * The name with which the file has to be uploaded. The file name can contain: - * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - * - Special Characters: `.`, `-` - * - * Any other character including space will be replaced by `_` - */ - fun fileName(fileName: String) = apply { body.fileName(fileName) } + fun fileUploadV1(): Optional = Optional.ofNullable(fileUploadV1) - /** - * Sets [Builder.fileName] to an arbitrary multipart value. - * - * You should usually call [Builder.fileName] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun fileName(fileName: MultipartField) = apply { body.fileName(fileName) } + fun fileUploadByUrlv1(): Optional = + Optional.ofNullable(fileUploadByUrlv1) - /** - * A unique value that the ImageKit.io server will use to recognize and prevent subsequent - * retries for the same request. We suggest using V4 UUIDs, or another random string with - * enough entropy to avoid collisions. This field is only required for authentication when - * uploading a file from the client side. - * - * **Note**: Sending a value that has been used in the past will result in a validation - * error. Even if your previous request resulted in an error, you should always send a new - * value for this field. - */ - fun token(token: String) = apply { body.token(token) } + fun isFileUploadV1(): Boolean = fileUploadV1 != null - /** - * Sets [Builder.token] to an arbitrary multipart value. - * - * You should usually call [Builder.token] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun token(token: MultipartField) = apply { body.token(token) } + fun isFileUploadByUrlv1(): Boolean = fileUploadByUrlv1 != null - /** - * Server-side checks to run on the asset. Read more about - * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). - */ - fun checks(checks: String) = apply { body.checks(checks) } + fun asFileUploadV1(): FileUploadV1 = fileUploadV1.getOrThrow("fileUploadV1") - /** - * Sets [Builder.checks] to an arbitrary multipart value. - * - * You should usually call [Builder.checks] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun checks(checks: MultipartField) = apply { body.checks(checks) } + fun asFileUploadByUrlv1(): FileUploadByUrlv1 = + fileUploadByUrlv1.getOrThrow("fileUploadByUrlv1") - /** - * Define an important area in the image. This is only relevant for image type files. - * - To be passed as a string with the x and y coordinates of the top-left corner, and width - * and height of the area of interest in the format `x,y,width,height`. For example - - * `10,10,100,100` - * - Can be used with fo-customtransformation. - * - If this field is not specified and the file is overwritten, then customCoordinates will - * be removed. - */ - fun customCoordinates(customCoordinates: String) = apply { - body.customCoordinates(customCoordinates) - } + fun _json(): Optional = Optional.ofNullable(_json) - /** - * Sets [Builder.customCoordinates] to an arbitrary multipart value. - * - * You should usually call [Builder.customCoordinates] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun customCoordinates(customCoordinates: MultipartField) = apply { - body.customCoordinates(customCoordinates) - } + fun accept(visitor: Visitor): T = + when { + fileUploadV1 != null -> visitor.visitFileUploadV1(fileUploadV1) + fileUploadByUrlv1 != null -> visitor.visitFileUploadByUrlv1(fileUploadByUrlv1) + else -> visitor.unknown(_json) + } - /** - * JSON key-value pairs to associate with the asset. Create the custom metadata fields - * before setting these values. - */ - fun customMetadata(customMetadata: CustomMetadata) = apply { - body.customMetadata(customMetadata) - } + private var validated: Boolean = false - /** - * Sets [Builder.customMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.customMetadata] with a well-typed [CustomMetadata] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun customMetadata(customMetadata: MultipartField) = apply { - body.customMetadata(customMetadata) - } + fun validate(): Body = apply { + if (validated) { + return@apply + } - /** Optional text to describe the contents of the file. */ - fun description(description: String) = apply { body.description(description) } + accept( + object : Visitor { + override fun visitFileUploadV1(fileUploadV1: FileUploadV1) { + fileUploadV1.validate() + } - /** - * Sets [Builder.description] to an arbitrary multipart 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: MultipartField) = apply { - body.description(description) + override fun visitFileUploadByUrlv1(fileUploadByUrlv1: FileUploadByUrlv1) { + fileUploadByUrlv1.validate() + } + } + ) + validated = true } - /** - * The time until your signature is valid. It must be a - * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. - * It should be in seconds. This field is only required for authentication when uploading a - * file from the client side. - */ - fun expire(expire: Long) = apply { body.expire(expire) } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } /** - * Sets [Builder.expire] to an arbitrary multipart value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.expire] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun expire(expire: MultipartField) = apply { body.expire(expire) } - - /** - * Array of extensions to be applied to the image. Each extension can be configured with - * specific parameters based on the extension type. + * Used for best match union deserialization. */ - fun extensions(extensions: List) = apply { body.extensions(extensions) } + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitFileUploadV1(fileUploadV1: FileUploadV1) = + fileUploadV1.validity() - /** - * Sets [Builder.extensions] to an arbitrary multipart value. - * - * You should usually call [Builder.extensions] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun extensions(extensions: MultipartField>) = apply { - body.extensions(extensions) - } + override fun visitFileUploadByUrlv1(fileUploadByUrlv1: FileUploadByUrlv1) = + fileUploadByUrlv1.validity() - /** - * Adds a single [Extension] to [extensions]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addExtension(extension: Extension) = apply { body.addExtension(extension) } + override fun unknown(json: JsonValue?) = 0 + } + ) - /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: Extension.RemoveBg) = apply { body.addExtension(removeBg) } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: Extension.AutoTaggingExtension) = apply { - body.addExtension(autoTagging) + return other is Body && + fileUploadV1 == other.fileUploadV1 && + fileUploadByUrlv1 == other.fileUploadByUrlv1 } - /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ - fun addExtensionAiAutoDescription() = apply { body.addExtensionAiAutoDescription() } + override fun hashCode(): Int = Objects.hash(fileUploadV1, fileUploadByUrlv1) - /** - * The folder path in which the image has to be uploaded. If the folder(s) didn't exist - * before, a new folder(s) is created. - * - * The folder name can contain: - * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - * - Special Characters: `/` , `_` , `-` - * - * Using multiple `/` creates a nested folder. - */ - fun folder(folder: String) = apply { body.folder(folder) } + override fun toString(): String = + when { + fileUploadV1 != null -> "Body{fileUploadV1=$fileUploadV1}" + fileUploadByUrlv1 != null -> "Body{fileUploadByUrlv1=$fileUploadByUrlv1}" + _json != null -> "Body{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Body") + } - /** - * Sets [Builder.folder] to an arbitrary multipart value. - * - * You should usually call [Builder.folder] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun folder(folder: MultipartField) = apply { body.folder(folder) } + companion object { - /** - * Whether to mark the file as private or not. - * - * If `true`, the file is marked as private and is accessible only using named - * transformation or signed URL. - */ - fun isPrivateFile(isPrivateFile: Boolean) = apply { body.isPrivateFile(isPrivateFile) } + @JvmStatic + fun ofFileUploadV1(fileUploadV1: FileUploadV1) = Body(fileUploadV1 = fileUploadV1) - /** - * Sets [Builder.isPrivateFile] to an arbitrary multipart value. - * - * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun isPrivateFile(isPrivateFile: MultipartField) = apply { - body.isPrivateFile(isPrivateFile) + @JvmStatic + fun ofFileUploadByUrlv1(fileUploadByUrlv1: FileUploadByUrlv1) = + Body(fileUploadByUrlv1 = fileUploadByUrlv1) } - /** - * Whether to upload file as published or not. - * - * If `false`, the file is marked as unpublished, which restricts access to the file only - * via the media library. Files in draft or unpublished state can only be publicly accessed - * after being published. - * - * The option to upload in draft state is only available in custom enterprise pricing plans. - */ - fun isPublished(isPublished: Boolean) = apply { body.isPublished(isPublished) } - - /** - * Sets [Builder.isPublished] to an arbitrary multipart value. - * - * You should usually call [Builder.isPublished] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun isPublished(isPublished: MultipartField) = apply { - body.isPublished(isPublished) - } + /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ + interface Visitor { - /** - * If set to `true` and a file already exists at the exact location, its AITags will be - * removed. Set `overwriteAITags` to `false` to preserve AITags. - */ - fun overwriteAiTags(overwriteAiTags: Boolean) = apply { - body.overwriteAiTags(overwriteAiTags) - } + fun visitFileUploadV1(fileUploadV1: FileUploadV1): T - /** - * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteAiTags] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun overwriteAiTags(overwriteAiTags: MultipartField) = apply { - body.overwriteAiTags(overwriteAiTags) - } + fun visitFileUploadByUrlv1(fileUploadByUrlv1: FileUploadByUrlv1): T - /** - * If the request does not have `customMetadata`, and a file already exists at the exact - * location, existing customMetadata will be removed. - */ - fun overwriteCustomMetadata(overwriteCustomMetadata: Boolean) = apply { - body.overwriteCustomMetadata(overwriteCustomMetadata) + /** + * Maps an unknown variant of [Body] to a value of type [T]. + * + * An instance of [Body] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Body: $json") + } } - /** - * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteCustomMetadata] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun overwriteCustomMetadata(overwriteCustomMetadata: MultipartField) = apply { - body.overwriteCustomMetadata(overwriteCustomMetadata) - } + internal class Deserializer : BaseDeserializer(Body::class) { - /** - * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the - * exact location, upload API will return an error immediately. - */ - fun overwriteFile(overwriteFile: Boolean) = apply { body.overwriteFile(overwriteFile) } + override fun ObjectCodec.deserialize(node: JsonNode): Body { + val json = JsonValue.fromJsonNode(node) - /** - * Sets [Builder.overwriteFile] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteFile] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun overwriteFile(overwriteFile: MultipartField) = apply { - body.overwriteFile(overwriteFile) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Body(fileUploadV1 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(fileUploadByUrlv1 = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Body(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } } - /** - * If the request does not have `tags`, and a file already exists at the exact location, - * existing tags will be removed. - */ - fun overwriteTags(overwriteTags: Boolean) = apply { body.overwriteTags(overwriteTags) } + internal class Serializer : BaseSerializer(Body::class) { - /** - * Sets [Builder.overwriteTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteTags] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun overwriteTags(overwriteTags: MultipartField) = apply { - body.overwriteTags(overwriteTags) + override fun serialize( + value: Body, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.fileUploadV1 != null -> generator.writeObject(value.fileUploadV1) + value.fileUploadByUrlv1 != null -> + generator.writeObject(value.fileUploadByUrlv1) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Body") + } + } } - /** - * Your ImageKit.io public key. This field is only required for authentication when - * uploading a file from the client side. - */ - fun publicKey(publicKey: String) = apply { body.publicKey(publicKey) } - - /** - * Sets [Builder.publicKey] to an arbitrary multipart value. - * - * You should usually call [Builder.publicKey] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun publicKey(publicKey: MultipartField) = apply { body.publicKey(publicKey) } - - /** Array of response field keys to include in the API response body. */ - fun responseFields(responseFields: List) = apply { - body.responseFields(responseFields) - } + class FileUploadV1 + private constructor( + private val file: MultipartField, + private val fileName: MultipartField, + private val token: MultipartField, + private val checks: MultipartField, + private val customCoordinates: MultipartField, + private val customMetadata: MultipartField, + private val description: MultipartField, + private val expire: MultipartField, + private val extensions: MultipartField>, + private val folder: MultipartField, + private val isPrivateFile: MultipartField, + private val isPublished: MultipartField, + private val overwriteAiTags: MultipartField, + private val overwriteCustomMetadata: MultipartField, + private val overwriteFile: MultipartField, + private val overwriteTags: MultipartField, + private val publicKey: MultipartField, + private val responseFields: MultipartField>, + private val signature: MultipartField, + private val tags: MultipartField>, + private val transformation: MultipartField, + private val useUniqueFileName: MultipartField, + private val webhookUrl: MultipartField, + private val additionalProperties: MutableMap, + ) { - /** - * Sets [Builder.responseFields] to an arbitrary multipart value. - * - * You should usually call [Builder.responseFields] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun responseFields(responseFields: MultipartField>) = apply { - body.responseFields(responseFields) - } + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + * + * @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 file(): InputStream = file.value.getRequired("file") + + /** + * The name with which the file has to be uploaded. The file name can contain: + * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + * - Special Characters: `.`, `-` + * + * Any other character including space will be replaced by `_` + * + * @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 fileName(): String = fileName.value.getRequired("fileName") + + /** + * A unique value that the ImageKit.io server will use to recognize and prevent + * subsequent retries for the same request. We suggest using V4 UUIDs, or another random + * string with enough entropy to avoid collisions. This field is only required for + * authentication when uploading a file from the client side. + * + * **Note**: Sending a value that has been used in the past will result in a validation + * error. Even if your previous request resulted in an error, you should always send a + * new value for this field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun token(): Optional = token.value.getOptional("token") + + /** + * Server-side checks to run on the asset. Read more about + * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun checks(): Optional = checks.value.getOptional("checks") + + /** + * Define an important area in the image. This is only relevant for image type files. + * - To be passed as a string with the x and y coordinates of the top-left corner, and + * width and height of the area of interest in the format `x,y,width,height`. For + * example - `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates + * will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun customCoordinates(): Optional = + customCoordinates.value.getOptional("customCoordinates") + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields + * before setting these values. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun customMetadata(): Optional = + customMetadata.value.getOptional("customMetadata") + + /** + * Optional text to describe the contents of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional = description.value.getOptional("description") + + /** + * The time until your signature is valid. It must be a + * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the + * future. It should be in seconds. This field is only required for authentication when + * uploading a file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun expire(): Optional = expire.value.getOptional("expire") + + /** + * Array of extensions to be applied to the image. Each extension can be configured with + * specific parameters based on the extension type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun extensions(): Optional> = extensions.value.getOptional("extensions") + + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't exist + * before, a new folder(s) is created. + * + * The folder name can contain: + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun folder(): Optional = folder.value.getOptional("folder") + + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named + * transformation or signed URL. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun isPrivateFile(): Optional = + isPrivateFile.value.getOptional("isPrivateFile") + + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file + * only via the media library. Files in draft or unpublished state can only be publicly + * accessed after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing + * plans. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun isPublished(): Optional = isPublished.value.getOptional("isPublished") + + /** + * If set to `true` and a file already exists at the exact location, its AITags will be + * removed. Set `overwriteAITags` to `false` to preserve AITags. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun overwriteAiTags(): Optional = + overwriteAiTags.value.getOptional("overwriteAITags") + + /** + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun overwriteCustomMetadata(): Optional = + overwriteCustomMetadata.value.getOptional("overwriteCustomMetadata") + + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the + * exact location, upload API will return an error immediately. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun overwriteFile(): Optional = + overwriteFile.value.getOptional("overwriteFile") + + /** + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun overwriteTags(): Optional = + overwriteTags.value.getOptional("overwriteTags") + + /** + * Your ImageKit.io public key. This field is only required for authentication when + * uploading a file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun publicKey(): Optional = publicKey.value.getOptional("publicKey") + + /** + * Array of response field keys to include in the API response body. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun responseFields(): Optional> = + responseFields.value.getOptional("responseFields") + + /** + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. + * Learn how to create a signature on the page below. This should be in lowercase. + * + * Signature must be calculated on the server-side. This field is only required for + * authentication when uploading a file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun signature(): Optional = signature.value.getOptional("signature") + + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. + * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not + * exceed 500, and the `%` character is not allowed. If this field is not specified and + * the file is overwritten, the existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tags(): Optional> = tags.value.getOptional("tags") + + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for + * reducing file size or applying basic optimizations upfront (e.g., resize, + * compress). + * - `post` — applied immediately after upload. Ideal for generating transformed + * versions (like video encodes or thumbnails) in advance, so they're ready for + * delivery without delay. + * + * You can mix and match any combination of post-processing types. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun transformation(): Optional = + transformation.value.getOptional("transformation") + + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a + * unique filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any + * existing file with the same name is replaced. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun useUniqueFileName(): Optional = + useUniqueFileName.value.getOptional("useUniqueFileName") + + /** + * The final status of extensions after they have completed execution will be delivered + * to this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun webhookUrl(): Optional = webhookUrl.value.getOptional("webhookUrl") + + /** + * Returns the raw multipart value of [file]. + * + * Unlike [file], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField = file + + /** + * Returns the raw multipart value of [fileName]. + * + * Unlike [fileName], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("fileName") + @ExcludeMissing + fun _fileName(): MultipartField = fileName + + /** + * Returns the raw multipart value of [token]. + * + * Unlike [token], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): MultipartField = token + + /** + * Returns the raw multipart value of [checks]. + * + * Unlike [checks], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("checks") @ExcludeMissing fun _checks(): MultipartField = checks + + /** + * Returns the raw multipart value of [customCoordinates]. + * + * Unlike [customCoordinates], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("customCoordinates") + @ExcludeMissing + fun _customCoordinates(): MultipartField = customCoordinates + + /** + * Returns the raw multipart value of [customMetadata]. + * + * Unlike [customMetadata], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): MultipartField = customMetadata + + /** + * Returns the raw multipart value of [description]. + * + * Unlike [description], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): MultipartField = description + + /** + * Returns the raw multipart value of [expire]. + * + * Unlike [expire], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("expire") @ExcludeMissing fun _expire(): MultipartField = expire + + /** + * Returns the raw multipart value of [extensions]. + * + * Unlike [extensions], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("extensions") + @ExcludeMissing + fun _extensions(): MultipartField> = extensions + + /** + * Returns the raw multipart value of [folder]. + * + * Unlike [folder], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("folder") @ExcludeMissing fun _folder(): MultipartField = folder + + /** + * Returns the raw multipart value of [isPrivateFile]. + * + * Unlike [isPrivateFile], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("isPrivateFile") + @ExcludeMissing + fun _isPrivateFile(): MultipartField = isPrivateFile + + /** + * Returns the raw multipart value of [isPublished]. + * + * Unlike [isPublished], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("isPublished") + @ExcludeMissing + fun _isPublished(): MultipartField = isPublished + + /** + * Returns the raw multipart value of [overwriteAiTags]. + * + * Unlike [overwriteAiTags], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteAITags") + @ExcludeMissing + fun _overwriteAiTags(): MultipartField = overwriteAiTags + + /** + * Returns the raw multipart value of [overwriteCustomMetadata]. + * + * Unlike [overwriteCustomMetadata], this method doesn't throw if the multipart field + * has an unexpected type. + */ + @JsonProperty("overwriteCustomMetadata") + @ExcludeMissing + fun _overwriteCustomMetadata(): MultipartField = overwriteCustomMetadata + + /** + * Returns the raw multipart value of [overwriteFile]. + * + * Unlike [overwriteFile], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteFile") + @ExcludeMissing + fun _overwriteFile(): MultipartField = overwriteFile + + /** + * Returns the raw multipart value of [overwriteTags]. + * + * Unlike [overwriteTags], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteTags") + @ExcludeMissing + fun _overwriteTags(): MultipartField = overwriteTags + + /** + * Returns the raw multipart value of [publicKey]. + * + * Unlike [publicKey], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("publicKey") + @ExcludeMissing + fun _publicKey(): MultipartField = publicKey + + /** + * Returns the raw multipart value of [responseFields]. + * + * Unlike [responseFields], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("responseFields") + @ExcludeMissing + fun _responseFields(): MultipartField> = responseFields + + /** + * Returns the raw multipart value of [signature]. + * + * Unlike [signature], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("signature") + @ExcludeMissing + fun _signature(): MultipartField = signature + + /** + * Returns the raw multipart value of [tags]. + * + * Unlike [tags], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): MultipartField> = tags + + /** + * Returns the raw multipart value of [transformation]. + * + * Unlike [transformation], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("transformation") + @ExcludeMissing + fun _transformation(): MultipartField = transformation + + /** + * Returns the raw multipart value of [useUniqueFileName]. + * + * Unlike [useUniqueFileName], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("useUniqueFileName") + @ExcludeMissing + fun _useUniqueFileName(): MultipartField = useUniqueFileName + + /** + * Returns the raw multipart value of [webhookUrl]. + * + * Unlike [webhookUrl], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("webhookUrl") + @ExcludeMissing + fun _webhookUrl(): MultipartField = webhookUrl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FileUploadV1]. + * + * The following fields are required: + * ```java + * .file() + * .fileName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileUploadV1]. */ + class Builder internal constructor() { + + private var file: MultipartField? = null + private var fileName: MultipartField? = null + private var token: MultipartField = MultipartField.of(null) + private var checks: MultipartField = MultipartField.of(null) + private var customCoordinates: MultipartField = MultipartField.of(null) + private var customMetadata: MultipartField = MultipartField.of(null) + private var description: MultipartField = MultipartField.of(null) + private var expire: MultipartField = MultipartField.of(null) + private var extensions: MultipartField>? = null + private var folder: MultipartField = MultipartField.of(null) + private var isPrivateFile: MultipartField = MultipartField.of(null) + private var isPublished: MultipartField = MultipartField.of(null) + private var overwriteAiTags: MultipartField = MultipartField.of(null) + private var overwriteCustomMetadata: MultipartField = + MultipartField.of(null) + private var overwriteFile: MultipartField = MultipartField.of(null) + private var overwriteTags: MultipartField = MultipartField.of(null) + private var publicKey: MultipartField = MultipartField.of(null) + private var responseFields: MultipartField>? = null + private var signature: MultipartField = MultipartField.of(null) + private var tags: MultipartField>? = null + private var transformation: MultipartField = MultipartField.of(null) + private var useUniqueFileName: MultipartField = MultipartField.of(null) + private var webhookUrl: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fileUploadV1: FileUploadV1) = apply { + file = fileUploadV1.file + fileName = fileUploadV1.fileName + token = fileUploadV1.token + checks = fileUploadV1.checks + customCoordinates = fileUploadV1.customCoordinates + customMetadata = fileUploadV1.customMetadata + description = fileUploadV1.description + expire = fileUploadV1.expire + extensions = fileUploadV1.extensions.map { it.toMutableList() } + folder = fileUploadV1.folder + isPrivateFile = fileUploadV1.isPrivateFile + isPublished = fileUploadV1.isPublished + overwriteAiTags = fileUploadV1.overwriteAiTags + overwriteCustomMetadata = fileUploadV1.overwriteCustomMetadata + overwriteFile = fileUploadV1.overwriteFile + overwriteTags = fileUploadV1.overwriteTags + publicKey = fileUploadV1.publicKey + responseFields = fileUploadV1.responseFields.map { it.toMutableList() } + signature = fileUploadV1.signature + tags = fileUploadV1.tags.map { it.toMutableList() } + transformation = fileUploadV1.transformation + useUniqueFileName = fileUploadV1.useUniqueFileName + webhookUrl = fileUploadV1.webhookUrl + additionalProperties = fileUploadV1.additionalProperties.toMutableMap() + } + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can + * fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 + * seconds; otherwise the request fails with 400 Bad Request. + */ + fun file(file: InputStream) = file(MultipartField.of(file)) + + /** + * Sets [Builder.file] to an arbitrary multipart value. + * + * You should usually call [Builder.file] with a well-typed [InputStream] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun file(file: MultipartField) = apply { this.file = file } + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can + * fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 + * seconds; otherwise the request fails with 400 Bad Request. + */ + fun file(file: ByteArray) = file(file.inputStream()) + + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can + * fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 + * seconds; otherwise the request fails with 400 Bad Request. + */ + fun file(path: Path) = + file( + MultipartField.builder() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + /** + * The name with which the file has to be uploaded. The file name can contain: + * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + * - Special Characters: `.`, `-` + * + * Any other character including space will be replaced by `_` + */ + fun fileName(fileName: String) = fileName(MultipartField.of(fileName)) + + /** + * Sets [Builder.fileName] to an arbitrary multipart value. + * + * You should usually call [Builder.fileName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun fileName(fileName: MultipartField) = apply { this.fileName = fileName } + + /** + * A unique value that the ImageKit.io server will use to recognize and prevent + * subsequent retries for the same request. We suggest using V4 UUIDs, or another + * random string with enough entropy to avoid collisions. This field is only + * required for authentication when uploading a file from the client side. + * + * **Note**: Sending a value that has been used in the past will result in a + * validation error. Even if your previous request resulted in an error, you should + * always send a new value for this field. + */ + fun token(token: String) = token(MultipartField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary multipart value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: MultipartField) = apply { this.token = token } + + /** + * Server-side checks to run on the asset. Read more about + * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + */ + fun checks(checks: String) = checks(MultipartField.of(checks)) + + /** + * Sets [Builder.checks] to an arbitrary multipart value. + * + * You should usually call [Builder.checks] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun checks(checks: MultipartField) = apply { this.checks = checks } + + /** + * Define an important area in the image. This is only relevant for image type + * files. + * - To be passed as a string with the x and y coordinates of the top-left corner, + * and width and height of the area of interest in the format `x,y,width,height`. + * For example - `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then + * customCoordinates will be removed. + */ + fun customCoordinates(customCoordinates: String) = + customCoordinates(MultipartField.of(customCoordinates)) + + /** + * Sets [Builder.customCoordinates] to an arbitrary multipart value. + * + * You should usually call [Builder.customCoordinates] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun customCoordinates(customCoordinates: MultipartField) = apply { + this.customCoordinates = customCoordinates + } + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata + * fields before setting these values. + */ + fun customMetadata(customMetadata: CustomMetadata) = + customMetadata(MultipartField.of(customMetadata)) + + /** + * Sets [Builder.customMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.customMetadata] with a well-typed + * [CustomMetadata] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun customMetadata(customMetadata: MultipartField) = apply { + this.customMetadata = customMetadata + } + + /** Optional text to describe the contents of the file. */ + fun description(description: String) = description(MultipartField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary multipart 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: MultipartField) = apply { + this.description = description + } + + /** + * The time until your signature is valid. It must be a + * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the + * future. It should be in seconds. This field is only required for authentication + * when uploading a file from the client side. + */ + fun expire(expire: Long) = expire(MultipartField.of(expire)) + + /** + * Sets [Builder.expire] to an arbitrary multipart value. + * + * You should usually call [Builder.expire] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expire(expire: MultipartField) = apply { this.expire = expire } + + /** + * Array of extensions to be applied to the image. Each extension can be configured + * with specific parameters based on the extension type. + */ + fun extensions(extensions: List) = + extensions(MultipartField.of(extensions)) + + /** + * Sets [Builder.extensions] to an arbitrary multipart value. + * + * You should usually call [Builder.extensions] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun extensions(extensions: MultipartField>) = apply { + this.extensions = extensions.map { it.toMutableList() } + } + + /** + * Adds a single [Extension] to [extensions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExtension(extension: Extension) = apply { + extensions = + (extensions ?: MultipartField.of(mutableListOf())).also { + checkKnown("extensions", it).add(extension) + } + } + + /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ + fun addExtension(removeBg: Extension.RemoveBg) = + addExtension(Extension.ofRemoveBg(removeBg)) + + /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = + addExtension(Extension.ofAutoTagging(autoTagging)) + + /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ + fun addExtensionAiAutoDescription() = addExtension(Extension.ofAiAutoDescription()) + + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't + * exist before, a new folder(s) is created. + * + * The folder name can contain: + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. + */ + fun folder(folder: String) = folder(MultipartField.of(folder)) + + /** + * Sets [Builder.folder] to an arbitrary multipart value. + * + * You should usually call [Builder.folder] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun folder(folder: MultipartField) = apply { this.folder = folder } + + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named + * transformation or signed URL. + */ + fun isPrivateFile(isPrivateFile: Boolean) = + isPrivateFile(MultipartField.of(isPrivateFile)) + + /** + * Sets [Builder.isPrivateFile] to an arbitrary multipart value. + * + * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun isPrivateFile(isPrivateFile: MultipartField) = apply { + this.isPrivateFile = isPrivateFile + } + + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file + * only via the media library. Files in draft or unpublished state can only be + * publicly accessed after being published. + * + * The option to upload in draft state is only available in custom enterprise + * pricing plans. + */ + fun isPublished(isPublished: Boolean) = isPublished(MultipartField.of(isPublished)) + + /** + * Sets [Builder.isPublished] to an arbitrary multipart value. + * + * You should usually call [Builder.isPublished] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun isPublished(isPublished: MultipartField) = apply { + this.isPublished = isPublished + } + + /** + * If set to `true` and a file already exists at the exact location, its AITags will + * be removed. Set `overwriteAITags` to `false` to preserve AITags. + */ + fun overwriteAiTags(overwriteAiTags: Boolean) = + overwriteAiTags(MultipartField.of(overwriteAiTags)) + + /** + * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteAiTags] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun overwriteAiTags(overwriteAiTags: MultipartField) = apply { + this.overwriteAiTags = overwriteAiTags + } + + /** + * If the request does not have `customMetadata`, and a file already exists at the + * exact location, existing customMetadata will be removed. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: Boolean) = + overwriteCustomMetadata(MultipartField.of(overwriteCustomMetadata)) + + /** + * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteCustomMetadata] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: MultipartField) = + apply { + this.overwriteCustomMetadata = overwriteCustomMetadata + } + + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at + * the exact location, upload API will return an error immediately. + */ + fun overwriteFile(overwriteFile: Boolean) = + overwriteFile(MultipartField.of(overwriteFile)) + + /** + * Sets [Builder.overwriteFile] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun overwriteFile(overwriteFile: MultipartField) = apply { + this.overwriteFile = overwriteFile + } + + /** + * If the request does not have `tags`, and a file already exists at the exact + * location, existing tags will be removed. + */ + fun overwriteTags(overwriteTags: Boolean) = + overwriteTags(MultipartField.of(overwriteTags)) + + /** + * Sets [Builder.overwriteTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteTags] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun overwriteTags(overwriteTags: MultipartField) = apply { + this.overwriteTags = overwriteTags + } + + /** + * Your ImageKit.io public key. This field is only required for authentication when + * uploading a file from the client side. + */ + fun publicKey(publicKey: String) = publicKey(MultipartField.of(publicKey)) + + /** + * Sets [Builder.publicKey] to an arbitrary multipart value. + * + * You should usually call [Builder.publicKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun publicKey(publicKey: MultipartField) = apply { + this.publicKey = publicKey + } + + /** Array of response field keys to include in the API response body. */ + fun responseFields(responseFields: List) = + responseFields(MultipartField.of(responseFields)) + + /** + * Sets [Builder.responseFields] to an arbitrary multipart value. + * + * You should usually call [Builder.responseFields] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun responseFields(responseFields: MultipartField>) = apply { + this.responseFields = responseFields.map { it.toMutableList() } + } + + /** + * Adds a single [ResponseField] to [responseFields]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResponseField(responseField: ResponseField) = apply { + responseFields = + (responseFields ?: MultipartField.of(mutableListOf())).also { + checkKnown("responseFields", it).add(responseField) + } + } + + /** + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a + * key. Learn how to create a signature on the page below. This should be in + * lowercase. + * + * Signature must be calculated on the server-side. This field is only required for + * authentication when uploading a file from the client side. + */ + fun signature(signature: String) = signature(MultipartField.of(signature)) + + /** + * Sets [Builder.signature] to an arbitrary multipart value. + * + * You should usually call [Builder.signature] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun signature(signature: MultipartField) = apply { + this.signature = signature + } + + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. + * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not + * exceed 500, and the `%` character is not allowed. If this field is not specified + * and the file is overwritten, the existing tags will be removed. + */ + fun tags(tags: List) = tags(MultipartField.of(tags)) + + /** + * Sets [Builder.tags] to an arbitrary multipart value. + * + * You should usually call [Builder.tags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tags(tags: MultipartField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = + (tags ?: MultipartField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } + + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for + * reducing file size or applying basic optimizations upfront (e.g., resize, + * compress). + * - `post` — applied immediately after upload. Ideal for generating transformed + * versions (like video encodes or thumbnails) in advance, so they're ready for + * delivery without delay. + * + * You can mix and match any combination of post-processing types. + */ + fun transformation(transformation: Transformation) = + transformation(MultipartField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary multipart value. + * + * You should usually call [Builder.transformation] with a well-typed + * [Transformation] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun transformation(transformation: MultipartField) = apply { + this.transformation = transformation + } + + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get + * a unique filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and + * any existing file with the same name is replaced. + */ + fun useUniqueFileName(useUniqueFileName: Boolean) = + useUniqueFileName(MultipartField.of(useUniqueFileName)) + + /** + * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. + * + * You should usually call [Builder.useUniqueFileName] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun useUniqueFileName(useUniqueFileName: MultipartField) = apply { + this.useUniqueFileName = useUniqueFileName + } + + /** + * The final status of extensions after they have completed execution will be + * delivered to this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + */ + fun webhookUrl(webhookUrl: String) = webhookUrl(MultipartField.of(webhookUrl)) + + /** + * Sets [Builder.webhookUrl] to an arbitrary multipart value. + * + * You should usually call [Builder.webhookUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun webhookUrl(webhookUrl: MultipartField) = apply { + this.webhookUrl = webhookUrl + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FileUploadV1]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .file() + * .fileName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FileUploadV1 = + FileUploadV1( + checkRequired("file", file), + checkRequired("fileName", fileName), + token, + checks, + customCoordinates, + customMetadata, + description, + expire, + (extensions ?: MultipartField.of(null)).map { it.toImmutable() }, + folder, + isPrivateFile, + isPublished, + overwriteAiTags, + overwriteCustomMetadata, + overwriteFile, + overwriteTags, + publicKey, + (responseFields ?: MultipartField.of(null)).map { it.toImmutable() }, + signature, + (tags ?: MultipartField.of(null)).map { it.toImmutable() }, + transformation, + useUniqueFileName, + webhookUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FileUploadV1 = apply { + if (validated) { + return@apply + } + + file() + fileName() + token() + checks() + customCoordinates() + customMetadata().ifPresent { it.validate() } + description() + expire() + extensions().ifPresent { it.forEach { it.validate() } } + folder() + isPrivateFile() + isPublished() + overwriteAiTags() + overwriteCustomMetadata() + overwriteFile() + overwriteTags() + publicKey() + responseFields().ifPresent { it.forEach { it.validate() } } + signature() + tags() + transformation().ifPresent { it.validate() } + useUniqueFileName() + webhookUrl() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields + * before setting these values. + */ + class CustomMetadata + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomMetadata]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customMetadata: CustomMetadata) = apply { + additionalProperties = customMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CustomMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomMetadata{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Extension.Deserializer::class) + @JsonSerialize(using = Extension.Serializer::class) + class Extension + private constructor( + private val removeBg: RemoveBg? = null, + private val autoTagging: AutoTaggingExtension? = null, + private val aiAutoDescription: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun removeBg(): Optional = Optional.ofNullable(removeBg) + + fun autoTagging(): Optional = Optional.ofNullable(autoTagging) + + fun aiAutoDescription(): Optional = + Optional.ofNullable(aiAutoDescription) + + fun isRemoveBg(): Boolean = removeBg != null + + fun isAutoTagging(): Boolean = autoTagging != null + + fun isAiAutoDescription(): Boolean = aiAutoDescription != null + + fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") + + fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") + + fun asAiAutoDescription(): JsonValue = + aiAutoDescription.getOrThrow("aiAutoDescription") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + removeBg != null -> visitor.visitRemoveBg(removeBg) + autoTagging != null -> visitor.visitAutoTagging(autoTagging) + aiAutoDescription != null -> + visitor.visitAiAutoDescription(aiAutoDescription) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Extension = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) { + removeBg.validate() + } + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { + autoTagging.validate() + } + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { + aiAutoDescription.let { + if ( + it != JsonValue.from(mapOf("name" to "ai-auto-description")) + ) { + throw ImageKitInvalidDataException( + "'aiAutoDescription' is invalid, received $it" + ) + } + } + } + } + ) + 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 = + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = + autoTagging.validity() + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = + aiAutoDescription.let { + if ( + it == JsonValue.from(mapOf("name" to "ai-auto-description")) + ) + 1 + else 0 + } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extension && + removeBg == other.removeBg && + autoTagging == other.autoTagging && + aiAutoDescription == other.aiAutoDescription + } + + override fun hashCode(): Int = + Objects.hash(removeBg, autoTagging, aiAutoDescription) + + override fun toString(): String = + when { + removeBg != null -> "Extension{removeBg=$removeBg}" + autoTagging != null -> "Extension{autoTagging=$autoTagging}" + aiAutoDescription != null -> + "Extension{aiAutoDescription=$aiAutoDescription}" + _json != null -> "Extension{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Extension") + } + + companion object { + + @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = Extension(removeBg = removeBg) + + @JvmStatic + fun ofAutoTagging(autoTagging: AutoTaggingExtension) = + Extension(autoTagging = autoTagging) + + @JvmStatic + fun ofAiAutoDescription() = + Extension( + aiAutoDescription = + JsonValue.from(mapOf("name" to "ai-auto-description")) + ) + } + + /** + * An interface that defines how to map each variant of [Extension] to a value of + * type [T]. + */ + interface Visitor { + + fun visitRemoveBg(removeBg: RemoveBg): T + + fun visitAutoTagging(autoTagging: AutoTaggingExtension): T + + fun visitAiAutoDescription(aiAutoDescription: JsonValue): T + + /** + * Maps an unknown variant of [Extension] to a value of type [T]. + * + * An instance of [Extension] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Extension: $json") + } + } + + internal class Deserializer : BaseDeserializer(Extension::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Extension { + val json = JsonValue.fromJsonNode(node) + val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() + + when (name) { + "remove-bg" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Extension(removeBg = it, _json = json) + } ?: Extension(_json = json) + } + "ai-auto-description" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Extension(aiAutoDescription = it, _json = json) } + ?.takeIf { it.isValid() } ?: Extension(_json = json) + } + } + + return tryDeserialize(node, jacksonTypeRef())?.let { + Extension(autoTagging = it, _json = json) + } ?: Extension(_json = json) + } + } + + internal class Serializer : BaseSerializer(Extension::class) { + + override fun serialize( + value: Extension, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.removeBg != null -> generator.writeObject(value.removeBg) + value.autoTagging != null -> generator.writeObject(value.autoTagging) + value.aiAutoDescription != null -> + generator.writeObject(value.aiAutoDescription) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Extension") + } + } + } + + class RemoveBg + private constructor( + private val name: JsonValue, + private val options: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Specifies the background removal extension. + * + * Expected to always return the following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun options(): Optional = options.value.getOptional("options") + + /** + * Returns the raw multipart value of [options]. + * + * Unlike [options], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("options") + @ExcludeMissing + fun _options(): MultipartField = options + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveBg]. */ + class Builder internal constructor() { + + private var name: JsonValue = JsonValue.from("remove-bg") + private var options: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(removeBg: RemoveBg) = apply { + name = removeBg.name + options = removeBg.options + additionalProperties = removeBg.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + fun options(options: Options) = options(MultipartField.of(options)) + + /** + * Sets [Builder.options] to an arbitrary multipart value. + * + * You should usually call [Builder.options] with a well-typed [Options] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun options(options: MultipartField) = apply { + this.options = options + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemoveBg]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemoveBg = + RemoveBg(name, options, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): RemoveBg = apply { + if (validated) { + return@apply + } + + _name().let { + if (it != JsonValue.from("remove-bg")) { + throw ImageKitInvalidDataException( + "'name' is invalid, received $it" + ) + } + } + options().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + class Options + private constructor( + private val addShadow: MultipartField, + private val bgColor: MultipartField, + private val bgImageUrl: MultipartField, + private val semitransparency: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Whether to add an artificial shadow to the result. Default is false. + * Note: Adding shadows is currently only supported for car photos. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun addShadow(): Optional = + addShadow.value.getOptional("add_shadow") + + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") + * or color name (e.g., "green"). If this parameter is set, `bg_image_url` + * must be empty. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun bgColor(): Optional = bgColor.value.getOptional("bg_color") + + /** + * Sets a background image from a URL. If this parameter is set, `bg_color` + * must be empty. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun bgImageUrl(): Optional = + bgImageUrl.value.getOptional("bg_image_url") + + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun semitransparency(): Optional = + semitransparency.value.getOptional("semitransparency") + + /** + * Returns the raw multipart value of [addShadow]. + * + * Unlike [addShadow], this method doesn't throw if the multipart field has + * an unexpected type. + */ + @JsonProperty("add_shadow") + @ExcludeMissing + fun _addShadow(): MultipartField = addShadow + + /** + * Returns the raw multipart value of [bgColor]. + * + * Unlike [bgColor], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("bg_color") + @ExcludeMissing + fun _bgColor(): MultipartField = bgColor + + /** + * Returns the raw multipart value of [bgImageUrl]. + * + * Unlike [bgImageUrl], this method doesn't throw if the multipart field has + * an unexpected type. + */ + @JsonProperty("bg_image_url") + @ExcludeMissing + fun _bgImageUrl(): MultipartField = bgImageUrl + + /** + * Returns the raw multipart value of [semitransparency]. + * + * Unlike [semitransparency], this method doesn't throw if the multipart + * field has an unexpected type. + */ + @JsonProperty("semitransparency") + @ExcludeMissing + fun _semitransparency(): MultipartField = semitransparency + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Options]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Options]. */ + class Builder internal constructor() { + + private var addShadow: MultipartField = MultipartField.of(null) + private var bgColor: MultipartField = MultipartField.of(null) + private var bgImageUrl: MultipartField = MultipartField.of(null) + private var semitransparency: MultipartField = + MultipartField.of(null) + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(options: Options) = apply { + addShadow = options.addShadow + bgColor = options.bgColor + bgImageUrl = options.bgImageUrl + semitransparency = options.semitransparency + additionalProperties = options.additionalProperties.toMutableMap() + } + + /** + * Whether to add an artificial shadow to the result. Default is false. + * Note: Adding shadows is currently only supported for car photos. + */ + fun addShadow(addShadow: Boolean) = + addShadow(MultipartField.of(addShadow)) + + /** + * Sets [Builder.addShadow] to an arbitrary multipart value. + * + * You should usually call [Builder.addShadow] with a well-typed + * [Boolean] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun addShadow(addShadow: MultipartField) = apply { + this.addShadow = addShadow + } + + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", + * "fff") or color name (e.g., "green"). If this parameter is set, + * `bg_image_url` must be empty. + */ + fun bgColor(bgColor: String) = bgColor(MultipartField.of(bgColor)) + + /** + * Sets [Builder.bgColor] to an arbitrary multipart value. + * + * You should usually call [Builder.bgColor] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun bgColor(bgColor: MultipartField) = apply { + this.bgColor = bgColor + } + + /** + * Sets a background image from a URL. If this parameter is set, + * `bg_color` must be empty. + */ + fun bgImageUrl(bgImageUrl: String) = + bgImageUrl(MultipartField.of(bgImageUrl)) + + /** + * Sets [Builder.bgImageUrl] to an arbitrary multipart value. + * + * You should usually call [Builder.bgImageUrl] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun bgImageUrl(bgImageUrl: MultipartField) = apply { + this.bgImageUrl = bgImageUrl + } + + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + */ + fun semitransparency(semitransparency: Boolean) = + semitransparency(MultipartField.of(semitransparency)) + + /** + * Sets [Builder.semitransparency] to an arbitrary multipart value. + * + * You should usually call [Builder.semitransparency] with a well-typed + * [Boolean] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun semitransparency(semitransparency: MultipartField) = + apply { + this.semitransparency = semitransparency + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Options]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): Options = + Options( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Options = apply { + if (validated) { + return@apply + } + + addShadow() + bgColor() + bgImageUrl() + semitransparency() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Options && + addShadow == other.addShadow && + bgColor == other.bgColor && + bgImageUrl == other.bgImageUrl && + semitransparency == other.semitransparency && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveBg && + name == other.name && + options == other.options && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(name, options, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" + } + + class AutoTaggingExtension + private constructor( + private val maxTags: MultipartField, + private val minConfidence: MultipartField, + private val name: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Maximum number of tags to attach to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maxTags(): Long = maxTags.value.getRequired("maxTags") + + /** + * Minimum confidence level for tags to be considered valid. + * + * @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 minConfidence(): Long = minConfidence.value.getRequired("minConfidence") + + /** + * Specifies the auto-tagging extension used. + * + * @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(): Name = name.value.getRequired("name") + + /** + * Returns the raw multipart value of [maxTags]. + * + * Unlike [maxTags], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("maxTags") + @ExcludeMissing + fun _maxTags(): MultipartField = maxTags + + /** + * Returns the raw multipart value of [minConfidence]. + * + * Unlike [minConfidence], this method doesn't throw if the multipart field has + * an unexpected type. + */ + @JsonProperty("minConfidence") + @ExcludeMissing + fun _minConfidence(): MultipartField = minConfidence + + /** + * Returns the raw multipart value of [name]. + * + * Unlike [name], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AutoTaggingExtension]. + * + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutoTaggingExtension]. */ + class Builder internal constructor() { + + private var maxTags: MultipartField? = null + private var minConfidence: MultipartField? = null + private var name: MultipartField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { + maxTags = autoTaggingExtension.maxTags + minConfidence = autoTaggingExtension.minConfidence + name = autoTaggingExtension.name + additionalProperties = + autoTaggingExtension.additionalProperties.toMutableMap() + } + + /** Maximum number of tags to attach to the asset. */ + fun maxTags(maxTags: Long) = maxTags(MultipartField.of(maxTags)) + + /** + * Sets [Builder.maxTags] to an arbitrary multipart value. + * + * You should usually call [Builder.maxTags] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun maxTags(maxTags: MultipartField) = apply { + this.maxTags = maxTags + } + + /** Minimum confidence level for tags to be considered valid. */ + fun minConfidence(minConfidence: Long) = + minConfidence(MultipartField.of(minConfidence)) + + /** + * Sets [Builder.minConfidence] to an arbitrary multipart value. + * + * You should usually call [Builder.minConfidence] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minConfidence(minConfidence: MultipartField) = apply { + this.minConfidence = minConfidence + } + + /** Specifies the auto-tagging extension used. */ + fun name(name: Name) = name(MultipartField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary multipart value. + * + * You should usually call [Builder.name] with a well-typed [Name] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun name(name: MultipartField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutoTaggingExtension]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutoTaggingExtension = + AutoTaggingExtension( + checkRequired("maxTags", maxTags), + checkRequired("minConfidence", minConfidence), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutoTaggingExtension = apply { + if (validated) { + return@apply + } + + maxTags() + minConfidence() + name().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Specifies the auto-tagging extension used. */ + class Name + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") + + @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + } + + /** + * An enum containing [Name]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Name] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + /** + * An enum member indicating that [Name] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING + else -> throw ImageKitInvalidDataException("Unknown Name: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Name = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Name && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutoTaggingExtension && + maxTags == other.maxTags && + minConfidence == other.minConfidence && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(maxTags, minConfidence, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" + } + } + + class ResponseField + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TAGS = of("tags") + + @JvmField val CUSTOM_COORDINATES = of("customCoordinates") + + @JvmField val IS_PRIVATE_FILE = of("isPrivateFile") + + @JvmField val EMBEDDED_METADATA = of("embeddedMetadata") + + @JvmField val IS_PUBLISHED = of("isPublished") + + @JvmField val CUSTOM_METADATA = of("customMetadata") + + @JvmField val METADATA = of("metadata") + + @JvmStatic fun of(value: String) = ResponseField(JsonField.of(value)) + } + + /** An enum containing [ResponseField]'s known values. */ + enum class Known { + TAGS, + CUSTOM_COORDINATES, + IS_PRIVATE_FILE, + EMBEDDED_METADATA, + IS_PUBLISHED, + CUSTOM_METADATA, + METADATA, + } + + /** + * An enum containing [ResponseField]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ResponseField] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TAGS, + CUSTOM_COORDINATES, + IS_PRIVATE_FILE, + EMBEDDED_METADATA, + IS_PUBLISHED, + CUSTOM_METADATA, + METADATA, + /** + * An enum member indicating that [ResponseField] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TAGS -> Value.TAGS + CUSTOM_COORDINATES -> Value.CUSTOM_COORDINATES + IS_PRIVATE_FILE -> Value.IS_PRIVATE_FILE + EMBEDDED_METADATA -> Value.EMBEDDED_METADATA + IS_PUBLISHED -> Value.IS_PUBLISHED + CUSTOM_METADATA -> Value.CUSTOM_METADATA + METADATA -> Value.METADATA + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + TAGS -> Known.TAGS + CUSTOM_COORDINATES -> Known.CUSTOM_COORDINATES + IS_PRIVATE_FILE -> Known.IS_PRIVATE_FILE + EMBEDDED_METADATA -> Known.EMBEDDED_METADATA + IS_PUBLISHED -> Known.IS_PUBLISHED + CUSTOM_METADATA -> Known.CUSTOM_METADATA + METADATA -> Known.METADATA + else -> throw ImageKitInvalidDataException("Unknown ResponseField: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ResponseField = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResponseField && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for + * reducing file size or applying basic optimizations upfront (e.g., resize, + * compress). + * - `post` — applied immediately after upload. Ideal for generating transformed + * versions (like video encodes or thumbnails) in advance, so they're ready for + * delivery without delay. + * + * You can mix and match any combination of post-processing types. + */ + class Transformation + private constructor( + private val post: MultipartField>, + private val pre: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * List of transformations to apply _after_ the file is uploaded. Each item must + * match one of the following types: `transformation`, `gif-to-video`, `thumbnail`, + * `abs`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun post(): Optional> = post.value.getOptional("post") + + /** + * Transformation string to apply before uploading the file to the Media Library. + * Useful for optimizing files at ingestion. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun pre(): Optional = pre.value.getOptional("pre") + + /** + * Returns the raw multipart value of [post]. + * + * Unlike [post], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("post") @ExcludeMissing fun _post(): MultipartField> = post + + /** + * Returns the raw multipart value of [pre]. + * + * Unlike [pre], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("pre") @ExcludeMissing fun _pre(): MultipartField = pre + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Transformation]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Transformation]. */ + class Builder internal constructor() { + + private var post: MultipartField>? = null + private var pre: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(transformation: Transformation) = apply { + post = transformation.post.map { it.toMutableList() } + pre = transformation.pre + additionalProperties = transformation.additionalProperties.toMutableMap() + } + + /** + * List of transformations to apply _after_ the file is uploaded. Each item must + * match one of the following types: `transformation`, `gif-to-video`, + * `thumbnail`, `abs`. + */ + fun post(post: List) = post(MultipartField.of(post)) + + /** + * Sets [Builder.post] to an arbitrary multipart value. + * + * You should usually call [Builder.post] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun post(post: MultipartField>) = apply { + this.post = post.map { it.toMutableList() } + } + + /** + * Adds a single [Post] to [Builder.post]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPost(post: Post) = apply { + this.post = + (this.post ?: MultipartField.of(mutableListOf())).also { + checkKnown("post", it).add(post) + } + } + + /** Alias for calling [addPost] with `Post.ofTransformation(transformation)`. */ + fun addPost(transformation: Post.InnerTransformation) = + addPost(Post.ofTransformation(transformation)) + + /** + * Alias for calling [addPost] with the following: + * ```java + * Post.InnerTransformation.builder() + * .value(value) + * .build() + * ``` + */ + fun addTransformationPost(value: String) = + addPost(Post.InnerTransformation.builder().value(value).build()) + + /** Alias for calling [addPost] with `Post.ofGifToVideo(gifToVideo)`. */ + fun addPost(gifToVideo: Post.GifToVideo) = + addPost(Post.ofGifToVideo(gifToVideo)) + + /** Alias for calling [addPost] with `Post.ofThumbnail(thumbnail)`. */ + fun addPost(thumbnail: Post.Thumbnail) = addPost(Post.ofThumbnail(thumbnail)) + + /** Alias for calling [addPost] with `Post.ofAbs(abs)`. */ + fun addPost(abs: Post.Abs) = addPost(Post.ofAbs(abs)) + + /** + * Transformation string to apply before uploading the file to the Media + * Library. Useful for optimizing files at ingestion. + */ + fun pre(pre: String) = pre(MultipartField.of(pre)) + + /** + * Sets [Builder.pre] to an arbitrary multipart value. + * + * You should usually call [Builder.pre] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun pre(pre: MultipartField) = apply { this.pre = pre } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Adds a single [ResponseField] to [responseFields]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addResponseField(responseField: ResponseField) = apply { - body.addResponseField(responseField) - } + /** + * Returns an immutable instance of [Transformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Transformation = + Transformation( + (post ?: MultipartField.of(null)).map { it.toImmutable() }, + pre, + additionalProperties.toMutableMap(), + ) + } - /** - * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. - * Learn how to create a signature on the page below. This should be in lowercase. - * - * Signature must be calculated on the server-side. This field is only required for - * authentication when uploading a file from the client side. - */ - fun signature(signature: String) = apply { body.signature(signature) } + private var validated: Boolean = false - /** - * Sets [Builder.signature] to an arbitrary multipart value. - * - * You should usually call [Builder.signature] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun signature(signature: MultipartField) = apply { body.signature(signature) } + fun validate(): Transformation = apply { + if (validated) { + return@apply + } - /** - * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", - * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the - * `%` character is not allowed. If this field is not specified and the file is overwritten, - * the existing tags will be removed. - */ - fun tags(tags: List) = apply { body.tags(tags) } + post().ifPresent { it.forEach { it.validate() } } + pre() + validated = true + } - /** - * Sets [Builder.tags] to an arbitrary multipart value. - * - * You should usually call [Builder.tags] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun tags(tags: MultipartField>) = apply { body.tags(tags) } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - /** - * Adds a single [String] to [tags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTag(tag: String) = apply { body.addTag(tag) } + @JsonDeserialize(using = Post.Deserializer::class) + @JsonSerialize(using = Post.Serializer::class) + class Post + private constructor( + private val transformation: InnerTransformation? = null, + private val gifToVideo: GifToVideo? = null, + private val thumbnail: Thumbnail? = null, + private val abs: Abs? = null, + private val _json: JsonValue? = null, + ) { - /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing - * file size or applying basic optimizations upfront (e.g., resize, compress). - * - `post` — applied immediately after upload. Ideal for generating transformed versions - * (like video encodes or thumbnails) in advance, so they're ready for delivery without - * delay. - * - * You can mix and match any combination of post-processing types. - */ - fun transformation(transformation: Transformation) = apply { - body.transformation(transformation) - } + fun transformation(): Optional = + Optional.ofNullable(transformation) - /** - * Sets [Builder.transformation] to an arbitrary multipart value. - * - * You should usually call [Builder.transformation] with a well-typed [Transformation] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun transformation(transformation: MultipartField) = apply { - body.transformation(transformation) - } + fun gifToVideo(): Optional = Optional.ofNullable(gifToVideo) - /** - * Whether to use a unique filename for this file or not. - * - * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique - * filename. - * - * If `false`, then the image is uploaded with the provided filename parameter, and any - * existing file with the same name is replaced. - */ - fun useUniqueFileName(useUniqueFileName: Boolean) = apply { - body.useUniqueFileName(useUniqueFileName) - } + fun thumbnail(): Optional = Optional.ofNullable(thumbnail) - /** - * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. - * - * You should usually call [Builder.useUniqueFileName] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun useUniqueFileName(useUniqueFileName: MultipartField) = apply { - body.useUniqueFileName(useUniqueFileName) - } + fun abs(): Optional = Optional.ofNullable(abs) - /** - * The final status of extensions after they have completed execution will be delivered to - * this endpoint as a POST request. - * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - * about the webhook payload structure. - */ - fun webhookUrl(webhookUrl: String) = apply { body.webhookUrl(webhookUrl) } + fun isTransformation(): Boolean = transformation != null - /** - * Sets [Builder.webhookUrl] to an arbitrary multipart value. - * - * You should usually call [Builder.webhookUrl] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun webhookUrl(webhookUrl: MultipartField) = apply { body.webhookUrl(webhookUrl) } + fun isGifToVideo(): Boolean = gifToVideo != null - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } + fun isThumbnail(): Boolean = thumbnail != null - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } + fun isAbs(): Boolean = abs != null - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } + fun asTransformation(): InnerTransformation = + transformation.getOrThrow("transformation") - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + fun asGifToVideo(): GifToVideo = gifToVideo.getOrThrow("gifToVideo") - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } + fun asThumbnail(): Thumbnail = thumbnail.getOrThrow("thumbnail") - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun asAbs(): Abs = abs.getOrThrow("abs") - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + fun _json(): Optional = Optional.ofNullable(_json) - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + fun accept(visitor: Visitor): T = + when { + transformation != null -> visitor.visitTransformation(transformation) + gifToVideo != null -> visitor.visitGifToVideo(gifToVideo) + thumbnail != null -> visitor.visitThumbnail(thumbnail) + abs != null -> visitor.visitAbs(abs) + else -> visitor.unknown(_json) + } - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + private var validated: Boolean = false - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + fun validate(): Post = apply { + if (validated) { + return@apply + } - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + accept( + object : Visitor { + override fun visitTransformation( + transformation: InnerTransformation + ) { + transformation.validate() + } + + override fun visitGifToVideo(gifToVideo: GifToVideo) { + gifToVideo.validate() + } + + override fun visitThumbnail(thumbnail: Thumbnail) { + thumbnail.validate() + } + + override fun visitAbs(abs: Abs) { + abs.validate() + } + } + ) + validated = true + } - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitTransformation( + transformation: InnerTransformation + ) = transformation.validity() - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + override fun visitGifToVideo(gifToVideo: GifToVideo) = + gifToVideo.validity() - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + override fun visitThumbnail(thumbnail: Thumbnail) = + thumbnail.validity() - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + override fun visitAbs(abs: Abs) = abs.validity() - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Post && + transformation == other.transformation && + gifToVideo == other.gifToVideo && + thumbnail == other.thumbnail && + abs == other.abs + } + + override fun hashCode(): Int = + Objects.hash(transformation, gifToVideo, thumbnail, abs) + + override fun toString(): String = + when { + transformation != null -> "Post{transformation=$transformation}" + gifToVideo != null -> "Post{gifToVideo=$gifToVideo}" + thumbnail != null -> "Post{thumbnail=$thumbnail}" + abs != null -> "Post{abs=$abs}" + _json != null -> "Post{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Post") + } + + companion object { + + @JvmStatic + fun ofTransformation(transformation: InnerTransformation) = + Post(transformation = transformation) + + @JvmStatic + fun ofGifToVideo(gifToVideo: GifToVideo) = Post(gifToVideo = gifToVideo) + + @JvmStatic + fun ofThumbnail(thumbnail: Thumbnail) = Post(thumbnail = thumbnail) + + @JvmStatic fun ofAbs(abs: Abs) = Post(abs = abs) + } + + /** + * An interface that defines how to map each variant of [Post] to a value of + * type [T]. + */ + interface Visitor { + + fun visitTransformation(transformation: InnerTransformation): T + + fun visitGifToVideo(gifToVideo: GifToVideo): T + + fun visitThumbnail(thumbnail: Thumbnail): T + + fun visitAbs(abs: Abs): T + + /** + * Maps an unknown variant of [Post] to a value of type [T]. + * + * An instance of [Post] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the API may respond + * with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Post: $json") + } + } + + internal class Deserializer : BaseDeserializer(Post::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Post { + val json = JsonValue.fromJsonNode(node) + val type = + json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "transformation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Post(transformation = it, _json = json) } + ?: Post(_json = json) + } + "gif-to-video" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(gifToVideo = it, _json = json) + } ?: Post(_json = json) + } + "thumbnail" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(thumbnail = it, _json = json) + } ?: Post(_json = json) + } + "abs" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(abs = it, _json = json) + } ?: Post(_json = json) + } + } + + return Post(_json = json) + } + } + + internal class Serializer : BaseSerializer(Post::class) { + + override fun serialize( + value: Post, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.transformation != null -> + generator.writeObject(value.transformation) + value.gifToVideo != null -> generator.writeObject(value.gifToVideo) + value.thumbnail != null -> generator.writeObject(value.thumbnail) + value.abs != null -> generator.writeObject(value.abs) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Post") + } + } + } + + class InnerTransformation + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Transformation type. + * + * Expected to always return the following: + * ```java + * JsonValue.from("transformation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit + * URL-based 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 value(): String = value.value.getRequired("value") + + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): MultipartField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InnerTransformation]. + * + * The following fields are required: + * ```java + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InnerTransformation]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("transformation") + private var value: MultipartField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(innerTransformation: InnerTransformation) = apply { + type = innerTransformation.type + value = innerTransformation.value + additionalProperties = + innerTransformation.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("transformation") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit + * URL-based transformations. + */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InnerTransformation]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InnerTransformation = + InnerTransformation( + type, + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InnerTransformation = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("transformation")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InnerTransformation && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InnerTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" + } + + class GifToVideo + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Converts an animated GIF into an MP4. + * + * Expected to always return the following: + * ```java + * JsonValue.from("gif-to-video") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Optional transformation string to apply to the output video. **Example**: + * `q-80` + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.value.getOptional("value") + + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): MultipartField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GifToVideo]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GifToVideo]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("gif-to-video") + private var value: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(gifToVideo: GifToVideo) = apply { + type = gifToVideo.type + value = gifToVideo.value + additionalProperties = + gifToVideo.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("gif-to-video") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Optional transformation string to apply to the output video. + * **Example**: `q-80` + */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GifToVideo]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): GifToVideo = + GifToVideo(type, value, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): GifToVideo = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("gif-to-video")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GifToVideo && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GifToVideo{type=$type, value=$value, additionalProperties=$additionalProperties}" + } - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + class Thumbnail + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + /** + * Generates a thumbnail image. + * + * Expected to always return the following: + * ```java + * JsonValue.from("thumbnail") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + /** + * Optional transformation string. **Example**: `w-150,h-150` + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.value.getOptional("value") - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): MultipartField = value - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + fun toBuilder() = Builder().from(this) - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + companion object { - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + /** + * Returns a mutable builder for constructing an instance of + * [Thumbnail]. + */ + @JvmStatic fun builder() = Builder() + } - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + /** A builder for [Thumbnail]. */ + class Builder internal constructor() { - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + private var type: JsonValue = JsonValue.from("thumbnail") + private var value: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = + mutableMapOf() - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + @JvmSynthetic + internal fun from(thumbnail: Thumbnail) = apply { + type = thumbnail.type + value = thumbnail.value + additionalProperties = thumbnail.additionalProperties.toMutableMap() + } - /** - * Returns an immutable instance of [FileUploadParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .file() - * .fileName() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): FileUploadParams = - FileUploadParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("thumbnail") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Optional transformation string. **Example**: `w-150,h-150` */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun _body(): Map> = - (mapOf( - "file" to _file(), - "fileName" to _fileName(), - "token" to _token(), - "checks" to _checks(), - "customCoordinates" to _customCoordinates(), - "customMetadata" to _customMetadata(), - "description" to _description(), - "expire" to _expire(), - "extensions" to _extensions(), - "folder" to _folder(), - "isPrivateFile" to _isPrivateFile(), - "isPublished" to _isPublished(), - "overwriteAITags" to _overwriteAiTags(), - "overwriteCustomMetadata" to _overwriteCustomMetadata(), - "overwriteFile" to _overwriteFile(), - "overwriteTags" to _overwriteTags(), - "publicKey" to _publicKey(), - "responseFields" to _responseFields(), - "signature" to _signature(), - "tags" to _tags(), - "transformation" to _transformation(), - "useUniqueFileName" to _useUniqueFileName(), - "webhookUrl" to _webhookUrl(), - ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) - .toImmutable() + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun _headers(): Headers = additionalHeaders + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - override fun _queryParams(): QueryParams = additionalQueryParams + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - class Body - private constructor( - private val file: MultipartField, - private val fileName: MultipartField, - private val token: MultipartField, - private val checks: MultipartField, - private val customCoordinates: MultipartField, - private val customMetadata: MultipartField, - private val description: MultipartField, - private val expire: MultipartField, - private val extensions: MultipartField>, - private val folder: MultipartField, - private val isPrivateFile: MultipartField, - private val isPublished: MultipartField, - private val overwriteAiTags: MultipartField, - private val overwriteCustomMetadata: MultipartField, - private val overwriteFile: MultipartField, - private val overwriteTags: MultipartField, - private val publicKey: MultipartField, - private val responseFields: MultipartField>, - private val signature: MultipartField, - private val tags: MultipartField>, - private val transformation: MultipartField, - private val useUniqueFileName: MultipartField, - private val webhookUrl: MultipartField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns an immutable instance of [Thumbnail]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): Thumbnail = + Thumbnail(type, value, additionalProperties.toMutableMap()) + } - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. - * - * @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 file(): InputStream = file.value.getRequired("file") + private var validated: Boolean = false - /** - * The name with which the file has to be uploaded. The file name can contain: - * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - * - Special Characters: `.`, `-` - * - * Any other character including space will be replaced by `_` - * - * @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 fileName(): String = fileName.value.getRequired("fileName") + fun validate(): Thumbnail = apply { + if (validated) { + return@apply + } - /** - * A unique value that the ImageKit.io server will use to recognize and prevent subsequent - * retries for the same request. We suggest using V4 UUIDs, or another random string with - * enough entropy to avoid collisions. This field is only required for authentication when - * uploading a file from the client side. - * - * **Note**: Sending a value that has been used in the past will result in a validation - * error. Even if your previous request resulted in an error, you should always send a new - * value for this field. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun token(): Optional = token.value.getOptional("token") + _type().let { + if (it != JsonValue.from("thumbnail")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + value() + validated = true + } - /** - * Server-side checks to run on the asset. Read more about - * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun checks(): Optional = checks.value.getOptional("checks") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - /** - * Define an important area in the image. This is only relevant for image type files. - * - To be passed as a string with the x and y coordinates of the top-left corner, and width - * and height of the area of interest in the format `x,y,width,height`. For example - - * `10,10,100,100` - * - Can be used with fo-customtransformation. - * - If this field is not specified and the file is overwritten, then customCoordinates will - * be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun customCoordinates(): Optional = - customCoordinates.value.getOptional("customCoordinates") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * JSON key-value pairs to associate with the asset. Create the custom metadata fields - * before setting these values. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun customMetadata(): Optional = - customMetadata.value.getOptional("customMetadata") + return other is Thumbnail && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } - /** - * Optional text to describe the contents of the file. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun description(): Optional = description.value.getOptional("description") + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } - /** - * The time until your signature is valid. It must be a - * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. - * It should be in seconds. This field is only required for authentication when uploading a - * file from the client side. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun expire(): Optional = expire.value.getOptional("expire") + override fun hashCode(): Int = hashCode - /** - * Array of extensions to be applied to the image. Each extension can be configured with - * specific parameters based on the extension type. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun extensions(): Optional> = extensions.value.getOptional("extensions") + override fun toString() = + "Thumbnail{type=$type, value=$value, additionalProperties=$additionalProperties}" + } - /** - * The folder path in which the image has to be uploaded. If the folder(s) didn't exist - * before, a new folder(s) is created. - * - * The folder name can contain: - * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - * - Special Characters: `/` , `_` , `-` - * - * Using multiple `/` creates a nested folder. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun folder(): Optional = folder.value.getOptional("folder") + class Abs + private constructor( + private val protocol: MultipartField, + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { - /** - * Whether to mark the file as private or not. - * - * If `true`, the file is marked as private and is accessible only using named - * transformation or signed URL. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun isPrivateFile(): Optional = isPrivateFile.value.getOptional("isPrivateFile") + /** + * Streaming protocol to use (`hls` or `dash`). + * + * @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 protocol(): Protocol = protocol.value.getRequired("protocol") - /** - * Whether to upload file as published or not. - * - * If `false`, the file is marked as unpublished, which restricts access to the file only - * via the media library. Files in draft or unpublished state can only be publicly accessed - * after being published. - * - * The option to upload in draft state is only available in custom enterprise pricing plans. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun isPublished(): Optional = isPublished.value.getOptional("isPublished") + /** + * Adaptive Bitrate Streaming (ABS) setup. + * + * Expected to always return the following: + * ```java + * JsonValue.from("abs") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * If set to `true` and a file already exists at the exact location, its AITags will be - * removed. Set `overwriteAITags` to `false` to preserve AITags. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun overwriteAiTags(): Optional = - overwriteAiTags.value.getOptional("overwriteAITags") + /** + * List of different representations you want to create separated by an + * underscore. + * + * @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 value(): String = value.value.getRequired("value") - /** - * If the request does not have `customMetadata`, and a file already exists at the exact - * location, existing customMetadata will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun overwriteCustomMetadata(): Optional = - overwriteCustomMetadata.value.getOptional("overwriteCustomMetadata") + /** + * Returns the raw multipart value of [protocol]. + * + * Unlike [protocol], this method doesn't throw if the multipart field has + * an unexpected type. + */ + @JsonProperty("protocol") + @ExcludeMissing + fun _protocol(): MultipartField = protocol - /** - * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the - * exact location, upload API will return an error immediately. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun overwriteFile(): Optional = overwriteFile.value.getOptional("overwriteFile") + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): MultipartField = value - /** - * If the request does not have `tags`, and a file already exists at the exact location, - * existing tags will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun overwriteTags(): Optional = overwriteTags.value.getOptional("overwriteTags") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Your ImageKit.io public key. This field is only required for authentication when - * uploading a file from the client side. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun publicKey(): Optional = publicKey.value.getOptional("publicKey") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Abs]. + * + * The following fields are required: + * ```java + * .protocol() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Array of response field keys to include in the API response body. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun responseFields(): Optional> = - responseFields.value.getOptional("responseFields") + /** A builder for [Abs]. */ + class Builder internal constructor() { + + private var protocol: MultipartField? = null + private var type: JsonValue = JsonValue.from("abs") + private var value: MultipartField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(abs: Abs) = apply { + protocol = abs.protocol + type = abs.type + value = abs.value + additionalProperties = abs.additionalProperties.toMutableMap() + } - /** - * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. - * Learn how to create a signature on the page below. This should be in lowercase. - * - * Signature must be calculated on the server-side. This field is only required for - * authentication when uploading a file from the client side. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun signature(): Optional = signature.value.getOptional("signature") + /** Streaming protocol to use (`hls` or `dash`). */ + fun protocol(protocol: Protocol) = protocol(MultipartField.of(protocol)) + + /** + * Sets [Builder.protocol] to an arbitrary multipart value. + * + * You should usually call [Builder.protocol] with a well-typed + * [Protocol] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun protocol(protocol: MultipartField) = apply { + this.protocol = protocol + } - /** - * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", - * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the - * `%` character is not allowed. If this field is not specified and the file is overwritten, - * the existing tags will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun tags(): Optional> = tags.value.getOptional("tags") + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("abs") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * List of different representations you want to create separated by an + * underscore. + */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing - * file size or applying basic optimizations upfront (e.g., resize, compress). - * - `post` — applied immediately after upload. Ideal for generating transformed versions - * (like video encodes or thumbnails) in advance, so they're ready for delivery without - * delay. - * - * You can mix and match any combination of post-processing types. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun transformation(): Optional = - transformation.value.getOptional("transformation") + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * Whether to use a unique filename for this file or not. - * - * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique - * filename. - * - * If `false`, then the image is uploaded with the provided filename parameter, and any - * existing file with the same name is replaced. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun useUniqueFileName(): Optional = - useUniqueFileName.value.getOptional("useUniqueFileName") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * The final status of extensions after they have completed execution will be delivered to - * this endpoint as a POST request. - * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - * about the webhook payload structure. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun webhookUrl(): Optional = webhookUrl.value.getOptional("webhookUrl") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw multipart value of [file]. - * - * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. - */ - @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField = file + /** + * Returns an immutable instance of [Abs]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .protocol() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Abs = + Abs( + checkRequired("protocol", protocol), + type, + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } - /** - * Returns the raw multipart value of [fileName]. - * - * Unlike [fileName], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("fileName") @ExcludeMissing fun _fileName(): MultipartField = fileName + private var validated: Boolean = false - /** - * Returns the raw multipart value of [token]. - * - * Unlike [token], this method doesn't throw if the multipart field has an unexpected type. - */ - @JsonProperty("token") @ExcludeMissing fun _token(): MultipartField = token + fun validate(): Abs = apply { + if (validated) { + return@apply + } - /** - * Returns the raw multipart value of [checks]. - * - * Unlike [checks], this method doesn't throw if the multipart field has an unexpected type. - */ - @JsonProperty("checks") @ExcludeMissing fun _checks(): MultipartField = checks + protocol().validate() + _type().let { + if (it != JsonValue.from("abs")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + value() + validated = true + } - /** - * Returns the raw multipart value of [customCoordinates]. - * - * Unlike [customCoordinates], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("customCoordinates") - @ExcludeMissing - fun _customCoordinates(): MultipartField = customCoordinates + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - /** - * Returns the raw multipart value of [customMetadata]. - * - * Unlike [customMetadata], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("customMetadata") - @ExcludeMissing - fun _customMetadata(): MultipartField = customMetadata + /** Streaming protocol to use (`hls` or `dash`). */ + class Protocol + @JsonCreator + private constructor(private val value: JsonField) : Enum { - /** - * Returns the raw multipart value of [description]. - * - * Unlike [description], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): MultipartField = description + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from + * data that doesn't match any known member, and you want to know that + * value. For example, if the SDK is on an older version than the API, + * then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - /** - * Returns the raw multipart value of [expire]. - * - * Unlike [expire], this method doesn't throw if the multipart field has an unexpected type. - */ - @JsonProperty("expire") @ExcludeMissing fun _expire(): MultipartField = expire + companion object { - /** - * Returns the raw multipart value of [extensions]. - * - * Unlike [extensions], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("extensions") - @ExcludeMissing - fun _extensions(): MultipartField> = extensions + @JvmField val HLS = of("hls") - /** - * Returns the raw multipart value of [folder]. - * - * Unlike [folder], this method doesn't throw if the multipart field has an unexpected type. - */ - @JsonProperty("folder") @ExcludeMissing fun _folder(): MultipartField = folder + @JvmField val DASH = of("dash") - /** - * Returns the raw multipart value of [isPrivateFile]. - * - * Unlike [isPrivateFile], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("isPrivateFile") - @ExcludeMissing - fun _isPrivateFile(): MultipartField = isPrivateFile + @JvmStatic fun of(value: String) = Protocol(JsonField.of(value)) + } - /** - * Returns the raw multipart value of [isPublished]. - * - * Unlike [isPublished], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("isPublished") - @ExcludeMissing - fun _isPublished(): MultipartField = isPublished + /** An enum containing [Protocol]'s known values. */ + enum class Known { + HLS, + DASH, + } - /** - * Returns the raw multipart value of [overwriteAiTags]. - * - * Unlike [overwriteAiTags], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("overwriteAITags") - @ExcludeMissing - fun _overwriteAiTags(): MultipartField = overwriteAiTags + /** + * An enum containing [Protocol]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [Protocol] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HLS, + DASH, + /** + * An enum member indicating that [Protocol] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } - /** - * Returns the raw multipart value of [overwriteCustomMetadata]. - * - * Unlike [overwriteCustomMetadata], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("overwriteCustomMetadata") - @ExcludeMissing - fun _overwriteCustomMetadata(): MultipartField = overwriteCustomMetadata + /** + * Returns an enum member corresponding to this class instance's value, + * or [Value._UNKNOWN] if the class was instantiated with an unknown + * value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HLS -> Value.HLS + DASH -> Value.DASH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + HLS -> Known.HLS + DASH -> Known.DASH + else -> + throw ImageKitInvalidDataException( + "Unknown Protocol: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Protocol = apply { + if (validated) { + return@apply + } + + known() + validated = true + } - /** - * Returns the raw multipart value of [overwriteFile]. - * - * Unlike [overwriteFile], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("overwriteFile") - @ExcludeMissing - fun _overwriteFile(): MultipartField = overwriteFile + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Protocol && value == other.value + } - /** - * Returns the raw multipart value of [overwriteTags]. - * - * Unlike [overwriteTags], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("overwriteTags") - @ExcludeMissing - fun _overwriteTags(): MultipartField = overwriteTags + override fun hashCode() = value.hashCode() - /** - * Returns the raw multipart value of [publicKey]. - * - * Unlike [publicKey], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("publicKey") - @ExcludeMissing - fun _publicKey(): MultipartField = publicKey + override fun toString() = value.toString() + } - /** - * Returns the raw multipart value of [responseFields]. - * - * Unlike [responseFields], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("responseFields") - @ExcludeMissing - fun _responseFields(): MultipartField> = responseFields + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw multipart value of [signature]. - * - * Unlike [signature], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("signature") - @ExcludeMissing - fun _signature(): MultipartField = signature + return other is Abs && + protocol == other.protocol && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } - /** - * Returns the raw multipart value of [tags]. - * - * Unlike [tags], this method doesn't throw if the multipart field has an unexpected type. - */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): MultipartField> = tags + private val hashCode: Int by lazy { + Objects.hash(protocol, type, value, additionalProperties) + } - /** - * Returns the raw multipart value of [transformation]. - * - * Unlike [transformation], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("transformation") - @ExcludeMissing - fun _transformation(): MultipartField = transformation + override fun hashCode(): Int = hashCode - /** - * Returns the raw multipart value of [useUniqueFileName]. - * - * Unlike [useUniqueFileName], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("useUniqueFileName") - @ExcludeMissing - fun _useUniqueFileName(): MultipartField = useUniqueFileName + override fun toString() = + "Abs{protocol=$protocol, type=$type, value=$value, additionalProperties=$additionalProperties}" + } + } - /** - * Returns the raw multipart value of [webhookUrl]. - * - * Unlike [webhookUrl], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("webhookUrl") - @ExcludeMissing - fun _webhookUrl(): MultipartField = webhookUrl + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + return other is Transformation && + post == other.post && + pre == other.pre && + additionalProperties == other.additionalProperties + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + private val hashCode: Int by lazy { Objects.hash(post, pre, additionalProperties) } - fun toBuilder() = Builder().from(this) + override fun hashCode(): Int = hashCode - companion object { + override fun toString() = + "Transformation{post=$post, pre=$pre, additionalProperties=$additionalProperties}" + } - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .file() - * .fileName() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var file: MultipartField? = null - private var fileName: MultipartField? = null - private var token: MultipartField = MultipartField.of(null) - private var checks: MultipartField = MultipartField.of(null) - private var customCoordinates: MultipartField = MultipartField.of(null) - private var customMetadata: MultipartField = MultipartField.of(null) - private var description: MultipartField = MultipartField.of(null) - private var expire: MultipartField = MultipartField.of(null) - private var extensions: MultipartField>? = null - private var folder: MultipartField = MultipartField.of(null) - private var isPrivateFile: MultipartField = MultipartField.of(null) - private var isPublished: MultipartField = MultipartField.of(null) - private var overwriteAiTags: MultipartField = MultipartField.of(null) - private var overwriteCustomMetadata: MultipartField = MultipartField.of(null) - private var overwriteFile: MultipartField = MultipartField.of(null) - private var overwriteTags: MultipartField = MultipartField.of(null) - private var publicKey: MultipartField = MultipartField.of(null) - private var responseFields: MultipartField>? = null - private var signature: MultipartField = MultipartField.of(null) - private var tags: MultipartField>? = null - private var transformation: MultipartField = MultipartField.of(null) - private var useUniqueFileName: MultipartField = MultipartField.of(null) - private var webhookUrl: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - file = body.file - fileName = body.fileName - token = body.token - checks = body.checks - customCoordinates = body.customCoordinates - customMetadata = body.customMetadata - description = body.description - expire = body.expire - extensions = body.extensions.map { it.toMutableList() } - folder = body.folder - isPrivateFile = body.isPrivateFile - isPublished = body.isPublished - overwriteAiTags = body.overwriteAiTags - overwriteCustomMetadata = body.overwriteCustomMetadata - overwriteFile = body.overwriteFile - overwriteTags = body.overwriteTags - publicKey = body.publicKey - responseFields = body.responseFields.map { it.toMutableList() } - signature = body.signature - tags = body.tags.map { it.toMutableList() } - transformation = body.transformation - useUniqueFileName = body.useUniqueFileName - webhookUrl = body.webhookUrl - additionalProperties = body.additionalProperties.toMutableMap() + return other is FileUploadV1 && + file == other.file && + fileName == other.fileName && + token == other.token && + checks == other.checks && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + description == other.description && + expire == other.expire && + extensions == other.extensions && + folder == other.folder && + isPrivateFile == other.isPrivateFile && + isPublished == other.isPublished && + overwriteAiTags == other.overwriteAiTags && + overwriteCustomMetadata == other.overwriteCustomMetadata && + overwriteFile == other.overwriteFile && + overwriteTags == other.overwriteTags && + publicKey == other.publicKey && + responseFields == other.responseFields && + signature == other.signature && + tags == other.tags && + transformation == other.transformation && + useUniqueFileName == other.useUniqueFileName && + webhookUrl == other.webhookUrl && + additionalProperties == other.additionalProperties } - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. - */ - fun file(file: InputStream) = file(MultipartField.of(file)) + private val hashCode: Int by lazy { + Objects.hash( + file, + fileName, + token, + checks, + customCoordinates, + customMetadata, + description, + expire, + extensions, + folder, + isPrivateFile, + isPublished, + overwriteAiTags, + overwriteCustomMetadata, + overwriteFile, + overwriteTags, + publicKey, + responseFields, + signature, + tags, + transformation, + useUniqueFileName, + webhookUrl, + additionalProperties, + ) + } - /** - * Sets [Builder.file] to an arbitrary multipart value. - * - * You should usually call [Builder.file] with a well-typed [InputStream] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun file(file: MultipartField) = apply { this.file = file } + override fun hashCode(): Int = hashCode - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. - */ - fun file(file: ByteArray) = file(file.inputStream()) + override fun toString() = + "FileUploadV1{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, expire=$expire, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, publicKey=$publicKey, responseFields=$responseFields, signature=$signature, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + } + + class FileUploadByUrlv1 + private constructor( + private val file: MultipartField, + private val fileName: MultipartField, + private val token: MultipartField, + private val checks: MultipartField, + private val customCoordinates: MultipartField, + private val customMetadata: MultipartField, + private val description: MultipartField, + private val expire: MultipartField, + private val extensions: MultipartField>, + private val folder: MultipartField, + private val isPrivateFile: MultipartField, + private val isPublished: MultipartField, + private val overwriteAiTags: MultipartField, + private val overwriteCustomMetadata: MultipartField, + private val overwriteFile: MultipartField, + private val overwriteTags: MultipartField, + private val publicKey: MultipartField, + private val responseFields: MultipartField>, + private val signature: MultipartField, + private val tags: MultipartField>, + private val transformation: MultipartField, + private val useUniqueFileName: MultipartField, + private val webhookUrl: MultipartField, + private val additionalProperties: MutableMap, + ) { /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * The URL of the file to upload. A publicly reachable URL that ImageKit servers can + * fetch. The server must receive the response headers within 8 seconds; otherwise the + * request fails with 400 Bad Request. * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. + * @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 file(path: Path) = - file( - MultipartField.builder() - .value(path.inputStream()) - .filename(path.name) - .build() - ) + fun file(): String = file.value.getRequired("file") /** * The name with which the file has to be uploaded. The file name can contain: @@ -1833,17 +4501,12 @@ private constructor( * - Special Characters: `.`, `-` * * Any other character including space will be replaced by `_` - */ - fun fileName(fileName: String) = fileName(MultipartField.of(fileName)) - - /** - * Sets [Builder.fileName] to an arbitrary multipart value. * - * You should usually call [Builder.fileName] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun fileName(fileName: MultipartField) = apply { this.fileName = fileName } + fun fileName(): String = fileName.value.getRequired("fileName") /** * A unique value that the ImageKit.io server will use to recognize and prevent @@ -1854,32 +4517,20 @@ private constructor( * **Note**: Sending a value that has been used in the past will result in a validation * error. Even if your previous request resulted in an error, you should always send a * new value for this field. - */ - fun token(token: String) = token(MultipartField.of(token)) - - /** - * Sets [Builder.token] to an arbitrary multipart value. * - * You should usually call [Builder.token] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun token(token: MultipartField) = apply { this.token = token } + fun token(): Optional = token.value.getOptional("token") /** * Server-side checks to run on the asset. Read more about * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). - */ - fun checks(checks: String) = checks(MultipartField.of(checks)) - - /** - * Sets [Builder.checks] to an arbitrary multipart value. * - * You should usually call [Builder.checks] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun checks(checks: MultipartField) = apply { this.checks = checks } + fun checks(): Optional = checks.value.getOptional("checks") /** * Define an important area in the image. This is only relevant for image type files. @@ -1889,908 +4540,434 @@ private constructor( * - Can be used with fo-customtransformation. * - If this field is not specified and the file is overwritten, then customCoordinates * will be removed. - */ - fun customCoordinates(customCoordinates: String) = - customCoordinates(MultipartField.of(customCoordinates)) - - /** - * Sets [Builder.customCoordinates] to an arbitrary multipart value. * - * You should usually call [Builder.customCoordinates] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun customCoordinates(customCoordinates: MultipartField) = apply { - this.customCoordinates = customCoordinates - } + fun customCoordinates(): Optional = + customCoordinates.value.getOptional("customCoordinates") /** * JSON key-value pairs to associate with the asset. Create the custom metadata fields * before setting these values. - */ - fun customMetadata(customMetadata: CustomMetadata) = - customMetadata(MultipartField.of(customMetadata)) - - /** - * Sets [Builder.customMetadata] to an arbitrary multipart value. * - * You should usually call [Builder.customMetadata] with a well-typed [CustomMetadata] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun customMetadata(customMetadata: MultipartField) = apply { - this.customMetadata = customMetadata - } - - /** Optional text to describe the contents of the file. */ - fun description(description: String) = description(MultipartField.of(description)) + fun customMetadata(): Optional = + customMetadata.value.getOptional("customMetadata") /** - * Sets [Builder.description] to an arbitrary multipart value. + * Optional text to describe the contents of the file. * - * 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. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun description(description: MultipartField) = apply { - this.description = description - } + fun description(): Optional = description.value.getOptional("description") /** * The time until your signature is valid. It must be a * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the * future. It should be in seconds. This field is only required for authentication when * uploading a file from the client side. - */ - fun expire(expire: Long) = expire(MultipartField.of(expire)) - - /** - * Sets [Builder.expire] to an arbitrary multipart value. * - * You should usually call [Builder.expire] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun expire(expire: MultipartField) = apply { this.expire = expire } + fun expire(): Optional = expire.value.getOptional("expire") /** * Array of extensions to be applied to the image. Each extension can be configured with * specific parameters based on the extension type. - */ - fun extensions(extensions: List) = extensions(MultipartField.of(extensions)) - - /** - * Sets [Builder.extensions] to an arbitrary multipart value. - * - * You should usually call [Builder.extensions] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun extensions(extensions: MultipartField>) = apply { - this.extensions = extensions.map { it.toMutableList() } - } - - /** - * Adds a single [Extension] to [extensions]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun addExtension(extension: Extension) = apply { - extensions = - (extensions ?: MultipartField.of(mutableListOf())).also { - checkKnown("extensions", it).add(extension) - } - } - - /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: Extension.RemoveBg) = - addExtension(Extension.ofRemoveBg(removeBg)) - - /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: Extension.AutoTaggingExtension) = - addExtension(Extension.ofAutoTagging(autoTagging)) - - /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ - fun addExtensionAiAutoDescription() = addExtension(Extension.ofAiAutoDescription()) + fun extensions(): Optional> = extensions.value.getOptional("extensions") /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist * before, a new folder(s) is created. * - * The folder name can contain: - * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - * - Special Characters: `/` , `_` , `-` - * - * Using multiple `/` creates a nested folder. - */ - fun folder(folder: String) = folder(MultipartField.of(folder)) - - /** - * Sets [Builder.folder] to an arbitrary multipart value. - * - * You should usually call [Builder.folder] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun folder(folder: MultipartField) = apply { this.folder = folder } - - /** - * Whether to mark the file as private or not. - * - * If `true`, the file is marked as private and is accessible only using named - * transformation or signed URL. - */ - fun isPrivateFile(isPrivateFile: Boolean) = - isPrivateFile(MultipartField.of(isPrivateFile)) - - /** - * Sets [Builder.isPrivateFile] to an arbitrary multipart value. - * - * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun isPrivateFile(isPrivateFile: MultipartField) = apply { - this.isPrivateFile = isPrivateFile - } - - /** - * Whether to upload file as published or not. - * - * If `false`, the file is marked as unpublished, which restricts access to the file - * only via the media library. Files in draft or unpublished state can only be publicly - * accessed after being published. - * - * The option to upload in draft state is only available in custom enterprise pricing - * plans. - */ - fun isPublished(isPublished: Boolean) = isPublished(MultipartField.of(isPublished)) - - /** - * Sets [Builder.isPublished] to an arbitrary multipart value. - * - * You should usually call [Builder.isPublished] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun isPublished(isPublished: MultipartField) = apply { - this.isPublished = isPublished - } - - /** - * If set to `true` and a file already exists at the exact location, its AITags will be - * removed. Set `overwriteAITags` to `false` to preserve AITags. - */ - fun overwriteAiTags(overwriteAiTags: Boolean) = - overwriteAiTags(MultipartField.of(overwriteAiTags)) - - /** - * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteAiTags] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun overwriteAiTags(overwriteAiTags: MultipartField) = apply { - this.overwriteAiTags = overwriteAiTags - } - - /** - * If the request does not have `customMetadata`, and a file already exists at the exact - * location, existing customMetadata will be removed. - */ - fun overwriteCustomMetadata(overwriteCustomMetadata: Boolean) = - overwriteCustomMetadata(MultipartField.of(overwriteCustomMetadata)) - - /** - * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteCustomMetadata] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun overwriteCustomMetadata(overwriteCustomMetadata: MultipartField) = apply { - this.overwriteCustomMetadata = overwriteCustomMetadata - } - - /** - * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the - * exact location, upload API will return an error immediately. - */ - fun overwriteFile(overwriteFile: Boolean) = - overwriteFile(MultipartField.of(overwriteFile)) - - /** - * Sets [Builder.overwriteFile] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteFile] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun overwriteFile(overwriteFile: MultipartField) = apply { - this.overwriteFile = overwriteFile - } - - /** - * If the request does not have `tags`, and a file already exists at the exact location, - * existing tags will be removed. - */ - fun overwriteTags(overwriteTags: Boolean) = - overwriteTags(MultipartField.of(overwriteTags)) - - /** - * Sets [Builder.overwriteTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteTags] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun overwriteTags(overwriteTags: MultipartField) = apply { - this.overwriteTags = overwriteTags - } - - /** - * Your ImageKit.io public key. This field is only required for authentication when - * uploading a file from the client side. - */ - fun publicKey(publicKey: String) = publicKey(MultipartField.of(publicKey)) - - /** - * Sets [Builder.publicKey] to an arbitrary multipart value. - * - * You should usually call [Builder.publicKey] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun publicKey(publicKey: MultipartField) = apply { this.publicKey = publicKey } - - /** Array of response field keys to include in the API response body. */ - fun responseFields(responseFields: List) = - responseFields(MultipartField.of(responseFields)) - - /** - * Sets [Builder.responseFields] to an arbitrary multipart value. - * - * You should usually call [Builder.responseFields] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun responseFields(responseFields: MultipartField>) = apply { - this.responseFields = responseFields.map { it.toMutableList() } - } - - /** - * Adds a single [ResponseField] to [responseFields]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addResponseField(responseField: ResponseField) = apply { - responseFields = - (responseFields ?: MultipartField.of(mutableListOf())).also { - checkKnown("responseFields", it).add(responseField) - } - } - - /** - * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. - * Learn how to create a signature on the page below. This should be in lowercase. - * - * Signature must be calculated on the server-side. This field is only required for - * authentication when uploading a file from the client side. - */ - fun signature(signature: String) = signature(MultipartField.of(signature)) - - /** - * Sets [Builder.signature] to an arbitrary multipart value. - * - * You should usually call [Builder.signature] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun signature(signature: MultipartField) = apply { this.signature = signature } - - /** - * Set the tags while uploading the file. Provide an array of tag strings (e.g. - * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not - * exceed 500, and the `%` character is not allowed. If this field is not specified and - * the file is overwritten, the existing tags will be removed. - */ - fun tags(tags: List) = tags(MultipartField.of(tags)) - - /** - * Sets [Builder.tags] to an arbitrary multipart value. + * The folder name can contain: + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. * - * You should usually call [Builder.tags] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun tags(tags: MultipartField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + fun folder(): Optional = folder.value.getOptional("folder") /** - * Adds a single [String] to [tags]. + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named + * transformation or signed URL. * - * @throws IllegalStateException if the field was previously set to a non-list. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun addTag(tag: String) = apply { - tags = - (tags ?: MultipartField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } + fun isPrivateFile(): Optional = + isPrivateFile.value.getOptional("isPrivateFile") /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for - * reducing file size or applying basic optimizations upfront (e.g., resize, - * compress). - * - `post` — applied immediately after upload. Ideal for generating transformed - * versions (like video encodes or thumbnails) in advance, so they're ready for - * delivery without delay. + * Whether to upload file as published or not. * - * You can mix and match any combination of post-processing types. + * If `false`, the file is marked as unpublished, which restricts access to the file + * only via the media library. Files in draft or unpublished state can only be publicly + * accessed after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing + * plans. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun transformation(transformation: Transformation) = - transformation(MultipartField.of(transformation)) + fun isPublished(): Optional = isPublished.value.getOptional("isPublished") /** - * Sets [Builder.transformation] to an arbitrary multipart value. + * If set to `true` and a file already exists at the exact location, its AITags will be + * removed. Set `overwriteAITags` to `false` to preserve AITags. * - * You should usually call [Builder.transformation] with a well-typed [Transformation] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun transformation(transformation: MultipartField) = apply { - this.transformation = transformation - } + fun overwriteAiTags(): Optional = + overwriteAiTags.value.getOptional("overwriteAITags") /** - * Whether to use a unique filename for this file or not. - * - * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a - * unique filename. + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. * - * If `false`, then the image is uploaded with the provided filename parameter, and any - * existing file with the same name is replaced. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun useUniqueFileName(useUniqueFileName: Boolean) = - useUniqueFileName(MultipartField.of(useUniqueFileName)) + fun overwriteCustomMetadata(): Optional = + overwriteCustomMetadata.value.getOptional("overwriteCustomMetadata") /** - * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the + * exact location, upload API will return an error immediately. * - * You should usually call [Builder.useUniqueFileName] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun useUniqueFileName(useUniqueFileName: MultipartField) = apply { - this.useUniqueFileName = useUniqueFileName - } + fun overwriteFile(): Optional = + overwriteFile.value.getOptional("overwriteFile") /** - * The final status of extensions after they have completed execution will be delivered - * to this endpoint as a POST request. - * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - * about the webhook payload structure. + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun webhookUrl(webhookUrl: String) = webhookUrl(MultipartField.of(webhookUrl)) + fun overwriteTags(): Optional = + overwriteTags.value.getOptional("overwriteTags") /** - * Sets [Builder.webhookUrl] to an arbitrary multipart value. + * Your ImageKit.io public key. This field is only required for authentication when + * uploading a file from the client side. * - * You should usually call [Builder.webhookUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun webhookUrl(webhookUrl: MultipartField) = apply { - this.webhookUrl = webhookUrl - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun publicKey(): Optional = publicKey.value.getOptional("publicKey") /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .file() - * .fileName() - * ``` + * Array of response field keys to include in the API response body. * - * @throws IllegalStateException if any required field is unset. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - fun build(): Body = - Body( - checkRequired("file", file), - checkRequired("fileName", fileName), - token, - checks, - customCoordinates, - customMetadata, - description, - expire, - (extensions ?: MultipartField.of(null)).map { it.toImmutable() }, - folder, - isPrivateFile, - isPublished, - overwriteAiTags, - overwriteCustomMetadata, - overwriteFile, - overwriteTags, - publicKey, - (responseFields ?: MultipartField.of(null)).map { it.toImmutable() }, - signature, - (tags ?: MultipartField.of(null)).map { it.toImmutable() }, - transformation, - useUniqueFileName, - webhookUrl, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - file() - fileName() - token() - checks() - customCoordinates() - customMetadata().ifPresent { it.validate() } - description() - expire() - extensions().ifPresent { it.forEach { it.validate() } } - folder() - isPrivateFile() - isPublished() - overwriteAiTags() - overwriteCustomMetadata() - overwriteFile() - overwriteTags() - publicKey() - responseFields().ifPresent { it.forEach { it.validate() } } - signature() - tags() - transformation().ifPresent { it.validate() } - useUniqueFileName() - webhookUrl() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - file == other.file && - fileName == other.fileName && - token == other.token && - checks == other.checks && - customCoordinates == other.customCoordinates && - customMetadata == other.customMetadata && - description == other.description && - expire == other.expire && - extensions == other.extensions && - folder == other.folder && - isPrivateFile == other.isPrivateFile && - isPublished == other.isPublished && - overwriteAiTags == other.overwriteAiTags && - overwriteCustomMetadata == other.overwriteCustomMetadata && - overwriteFile == other.overwriteFile && - overwriteTags == other.overwriteTags && - publicKey == other.publicKey && - responseFields == other.responseFields && - signature == other.signature && - tags == other.tags && - transformation == other.transformation && - useUniqueFileName == other.useUniqueFileName && - webhookUrl == other.webhookUrl && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - file, - fileName, - token, - checks, - customCoordinates, - customMetadata, - description, - expire, - extensions, - folder, - isPrivateFile, - isPublished, - overwriteAiTags, - overwriteCustomMetadata, - overwriteFile, - overwriteTags, - publicKey, - responseFields, - signature, - tags, - transformation, - useUniqueFileName, - webhookUrl, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, expire=$expire, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, publicKey=$publicKey, responseFields=$responseFields, signature=$signature, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" - } - - /** - * JSON key-value pairs to associate with the asset. Create the custom metadata fields before - * setting these values. - */ - class CustomMetadata - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [CustomMetadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customMetadata: CustomMetadata) = apply { - additionalProperties = customMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun responseFields(): Optional> = + responseFields.value.getOptional("responseFields") /** - * Returns an immutable instance of [CustomMetadata]. + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. + * Learn how to create a signature on the page below. This should be in lowercase. * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): CustomMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CustomMetadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = Extension.Deserializer::class) - @JsonSerialize(using = Extension.Serializer::class) - class Extension - private constructor( - private val removeBg: RemoveBg? = null, - private val autoTagging: AutoTaggingExtension? = null, - private val aiAutoDescription: JsonValue? = null, - private val _json: JsonValue? = null, - ) { - - fun removeBg(): Optional = Optional.ofNullable(removeBg) - - fun autoTagging(): Optional = Optional.ofNullable(autoTagging) - - fun aiAutoDescription(): Optional = Optional.ofNullable(aiAutoDescription) - - fun isRemoveBg(): Boolean = removeBg != null - - fun isAutoTagging(): Boolean = autoTagging != null - - fun isAiAutoDescription(): Boolean = aiAutoDescription != null - - fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") - - fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") - - fun asAiAutoDescription(): JsonValue = aiAutoDescription.getOrThrow("aiAutoDescription") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - removeBg != null -> visitor.visitRemoveBg(removeBg) - autoTagging != null -> visitor.visitAutoTagging(autoTagging) - aiAutoDescription != null -> visitor.visitAiAutoDescription(aiAutoDescription) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Extension = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitRemoveBg(removeBg: RemoveBg) { - removeBg.validate() - } - - override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { - autoTagging.validate() - } - - override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { - aiAutoDescription.let { - if (it != JsonValue.from(mapOf("name" to "ai-auto-description"))) { - throw ImageKitInvalidDataException( - "'aiAutoDescription' is invalid, received $it" - ) - } - } - } - } - ) - 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 = - accept( - object : Visitor { - override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() - - override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = - autoTagging.validity() + * Signature must be calculated on the server-side. This field is only required for + * authentication when uploading a file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun signature(): Optional = signature.value.getOptional("signature") - override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = - aiAutoDescription.let { - if (it == JsonValue.from(mapOf("name" to "ai-auto-description"))) 1 - else 0 - } + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. + * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not + * exceed 500, and the `%` character is not allowed. If this field is not specified and + * the file is overwritten, the existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tags(): Optional> = tags.value.getOptional("tags") - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for + * reducing file size or applying basic optimizations upfront (e.g., resize, + * compress). + * - `post` — applied immediately after upload. Ideal for generating transformed + * versions (like video encodes or thumbnails) in advance, so they're ready for + * delivery without delay. + * + * You can mix and match any combination of post-processing types. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun transformation(): Optional = + transformation.value.getOptional("transformation") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a + * unique filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any + * existing file with the same name is replaced. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun useUniqueFileName(): Optional = + useUniqueFileName.value.getOptional("useUniqueFileName") - return other is Extension && - removeBg == other.removeBg && - autoTagging == other.autoTagging && - aiAutoDescription == other.aiAutoDescription - } + /** + * The final status of extensions after they have completed execution will be delivered + * to this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun webhookUrl(): Optional = webhookUrl.value.getOptional("webhookUrl") - override fun hashCode(): Int = Objects.hash(removeBg, autoTagging, aiAutoDescription) + /** + * Returns the raw multipart value of [file]. + * + * Unlike [file], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField = file - override fun toString(): String = - when { - removeBg != null -> "Extension{removeBg=$removeBg}" - autoTagging != null -> "Extension{autoTagging=$autoTagging}" - aiAutoDescription != null -> "Extension{aiAutoDescription=$aiAutoDescription}" - _json != null -> "Extension{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Extension") - } + /** + * Returns the raw multipart value of [fileName]. + * + * Unlike [fileName], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("fileName") + @ExcludeMissing + fun _fileName(): MultipartField = fileName - companion object { + /** + * Returns the raw multipart value of [token]. + * + * Unlike [token], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): MultipartField = token - @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = Extension(removeBg = removeBg) + /** + * Returns the raw multipart value of [checks]. + * + * Unlike [checks], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("checks") @ExcludeMissing fun _checks(): MultipartField = checks - @JvmStatic - fun ofAutoTagging(autoTagging: AutoTaggingExtension) = - Extension(autoTagging = autoTagging) + /** + * Returns the raw multipart value of [customCoordinates]. + * + * Unlike [customCoordinates], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("customCoordinates") + @ExcludeMissing + fun _customCoordinates(): MultipartField = customCoordinates - @JvmStatic - fun ofAiAutoDescription() = - Extension( - aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) - ) - } + /** + * Returns the raw multipart value of [customMetadata]. + * + * Unlike [customMetadata], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): MultipartField = customMetadata - /** - * An interface that defines how to map each variant of [Extension] to a value of type [T]. - */ - interface Visitor { + /** + * Returns the raw multipart value of [description]. + * + * Unlike [description], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): MultipartField = description - fun visitRemoveBg(removeBg: RemoveBg): T + /** + * Returns the raw multipart value of [expire]. + * + * Unlike [expire], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("expire") @ExcludeMissing fun _expire(): MultipartField = expire - fun visitAutoTagging(autoTagging: AutoTaggingExtension): T + /** + * Returns the raw multipart value of [extensions]. + * + * Unlike [extensions], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("extensions") + @ExcludeMissing + fun _extensions(): MultipartField> = extensions - fun visitAiAutoDescription(aiAutoDescription: JsonValue): T + /** + * Returns the raw multipart value of [folder]. + * + * Unlike [folder], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("folder") @ExcludeMissing fun _folder(): MultipartField = folder /** - * Maps an unknown variant of [Extension] to a value of type [T]. + * Returns the raw multipart value of [isPrivateFile]. * - * An instance of [Extension] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * Unlike [isPrivateFile], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("isPrivateFile") + @ExcludeMissing + fun _isPrivateFile(): MultipartField = isPrivateFile + + /** + * Returns the raw multipart value of [isPublished]. * - * @throws ImageKitInvalidDataException in the default implementation. + * Unlike [isPublished], this method doesn't throw if the multipart field has an + * unexpected type. */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Extension: $json") - } - } + @JsonProperty("isPublished") + @ExcludeMissing + fun _isPublished(): MultipartField = isPublished - internal class Deserializer : BaseDeserializer(Extension::class) { + /** + * Returns the raw multipart value of [overwriteAiTags]. + * + * Unlike [overwriteAiTags], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteAITags") + @ExcludeMissing + fun _overwriteAiTags(): MultipartField = overwriteAiTags - override fun ObjectCodec.deserialize(node: JsonNode): Extension { - val json = JsonValue.fromJsonNode(node) - val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() + /** + * Returns the raw multipart value of [overwriteCustomMetadata]. + * + * Unlike [overwriteCustomMetadata], this method doesn't throw if the multipart field + * has an unexpected type. + */ + @JsonProperty("overwriteCustomMetadata") + @ExcludeMissing + fun _overwriteCustomMetadata(): MultipartField = overwriteCustomMetadata - when (name) { - "remove-bg" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Extension(removeBg = it, _json = json) - } ?: Extension(_json = json) - } - "ai-auto-description" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Extension(aiAutoDescription = it, _json = json) } - ?.takeIf { it.isValid() } ?: Extension(_json = json) - } - } + /** + * Returns the raw multipart value of [overwriteFile]. + * + * Unlike [overwriteFile], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteFile") + @ExcludeMissing + fun _overwriteFile(): MultipartField = overwriteFile - return tryDeserialize(node, jacksonTypeRef())?.let { - Extension(autoTagging = it, _json = json) - } ?: Extension(_json = json) - } - } + /** + * Returns the raw multipart value of [overwriteTags]. + * + * Unlike [overwriteTags], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteTags") + @ExcludeMissing + fun _overwriteTags(): MultipartField = overwriteTags - internal class Serializer : BaseSerializer(Extension::class) { + /** + * Returns the raw multipart value of [publicKey]. + * + * Unlike [publicKey], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("publicKey") + @ExcludeMissing + fun _publicKey(): MultipartField = publicKey - override fun serialize( - value: Extension, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.removeBg != null -> generator.writeObject(value.removeBg) - value.autoTagging != null -> generator.writeObject(value.autoTagging) - value.aiAutoDescription != null -> - generator.writeObject(value.aiAutoDescription) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Extension") - } - } - } + /** + * Returns the raw multipart value of [responseFields]. + * + * Unlike [responseFields], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("responseFields") + @ExcludeMissing + fun _responseFields(): MultipartField> = responseFields - class RemoveBg - private constructor( - private val name: JsonValue, - private val options: MultipartField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw multipart value of [signature]. + * + * Unlike [signature], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("signature") + @ExcludeMissing + fun _signature(): MultipartField = signature /** - * Specifies the background removal extension. + * Returns the raw multipart value of [tags]. * - * Expected to always return the following: - * ```java - * JsonValue.from("remove-bg") - * ``` + * Unlike [tags], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): MultipartField> = tags + + /** + * Returns the raw multipart value of [transformation]. * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). + * Unlike [transformation], this method doesn't throw if the multipart field has an + * unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + @JsonProperty("transformation") + @ExcludeMissing + fun _transformation(): MultipartField = transformation /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * Returns the raw multipart value of [useUniqueFileName]. + * + * Unlike [useUniqueFileName], this method doesn't throw if the multipart field has an + * unexpected type. */ - fun options(): Optional = options.value.getOptional("options") + @JsonProperty("useUniqueFileName") + @ExcludeMissing + fun _useUniqueFileName(): MultipartField = useUniqueFileName /** - * Returns the raw multipart value of [options]. + * Returns the raw multipart value of [webhookUrl]. * - * Unlike [options], this method doesn't throw if the multipart field has an unexpected - * type. + * Unlike [webhookUrl], this method doesn't throw if the multipart field has an + * unexpected type. */ - @JsonProperty("options") + @JsonProperty("webhookUrl") @ExcludeMissing - fun _options(): MultipartField = options + fun _webhookUrl(): MultipartField = webhookUrl @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -2806,543 +4983,558 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RemoveBg]. */ - class Builder internal constructor() { - - private var name: JsonValue = JsonValue.from("remove-bg") - private var options: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(removeBg: RemoveBg) = apply { - name = removeBg.name - options = removeBg.options - additionalProperties = removeBg.additionalProperties.toMutableMap() - } - /** - * Sets the field to an arbitrary JSON value. + * Returns a mutable builder for constructing an instance of [FileUploadByUrlv1]. * - * It is usually unnecessary to call this method because the field defaults to the - * following: + * The following fields are required: * ```java - * JsonValue.from("remove-bg") + * .file() + * .fileName() * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonValue) = apply { this.name = name } - - fun options(options: Options) = options(MultipartField.of(options)) - - /** - * Sets [Builder.options] to an arbitrary multipart value. - * - * You should usually call [Builder.options] with a well-typed [Options] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun options(options: MultipartField) = apply { this.options = options } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [RemoveBg]. - * - * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): RemoveBg = RemoveBg(name, options, additionalProperties.toMutableMap()) + @JvmStatic fun builder() = Builder() } - private var validated: Boolean = false - - fun validate(): RemoveBg = apply { - if (validated) { - return@apply - } + /** A builder for [FileUploadByUrlv1]. */ + class Builder internal constructor() { - _name().let { - if (it != JsonValue.from("remove-bg")) { - throw ImageKitInvalidDataException("'name' is invalid, received $it") - } - } - options().ifPresent { it.validate() } - validated = true - } + private var file: MultipartField? = null + private var fileName: MultipartField? = null + private var token: MultipartField = MultipartField.of(null) + private var checks: MultipartField = MultipartField.of(null) + private var customCoordinates: MultipartField = MultipartField.of(null) + private var customMetadata: MultipartField = MultipartField.of(null) + private var description: MultipartField = MultipartField.of(null) + private var expire: MultipartField = MultipartField.of(null) + private var extensions: MultipartField>? = null + private var folder: MultipartField = MultipartField.of(null) + private var isPrivateFile: MultipartField = MultipartField.of(null) + private var isPublished: MultipartField = MultipartField.of(null) + private var overwriteAiTags: MultipartField = MultipartField.of(null) + private var overwriteCustomMetadata: MultipartField = + MultipartField.of(null) + private var overwriteFile: MultipartField = MultipartField.of(null) + private var overwriteTags: MultipartField = MultipartField.of(null) + private var publicKey: MultipartField = MultipartField.of(null) + private var responseFields: MultipartField>? = null + private var signature: MultipartField = MultipartField.of(null) + private var tags: MultipartField>? = null + private var transformation: MultipartField = MultipartField.of(null) + private var useUniqueFileName: MultipartField = MultipartField.of(null) + private var webhookUrl: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false + @JvmSynthetic + internal fun from(fileUploadByUrlv1: FileUploadByUrlv1) = apply { + file = fileUploadByUrlv1.file + fileName = fileUploadByUrlv1.fileName + token = fileUploadByUrlv1.token + checks = fileUploadByUrlv1.checks + customCoordinates = fileUploadByUrlv1.customCoordinates + customMetadata = fileUploadByUrlv1.customMetadata + description = fileUploadByUrlv1.description + expire = fileUploadByUrlv1.expire + extensions = fileUploadByUrlv1.extensions.map { it.toMutableList() } + folder = fileUploadByUrlv1.folder + isPrivateFile = fileUploadByUrlv1.isPrivateFile + isPublished = fileUploadByUrlv1.isPublished + overwriteAiTags = fileUploadByUrlv1.overwriteAiTags + overwriteCustomMetadata = fileUploadByUrlv1.overwriteCustomMetadata + overwriteFile = fileUploadByUrlv1.overwriteFile + overwriteTags = fileUploadByUrlv1.overwriteTags + publicKey = fileUploadByUrlv1.publicKey + responseFields = fileUploadByUrlv1.responseFields.map { it.toMutableList() } + signature = fileUploadByUrlv1.signature + tags = fileUploadByUrlv1.tags.map { it.toMutableList() } + transformation = fileUploadByUrlv1.transformation + useUniqueFileName = fileUploadByUrlv1.useUniqueFileName + webhookUrl = fileUploadByUrlv1.webhookUrl + additionalProperties = fileUploadByUrlv1.additionalProperties.toMutableMap() } - class Options - private constructor( - private val addShadow: MultipartField, - private val bgColor: MultipartField, - private val bgImageUrl: MultipartField, - private val semitransparency: MultipartField, - private val additionalProperties: MutableMap, - ) { + /** + * The URL of the file to upload. A publicly reachable URL that ImageKit servers can + * fetch. The server must receive the response headers within 8 seconds; otherwise + * the request fails with 400 Bad Request. + */ + fun file(file: String) = file(MultipartField.of(file)) /** - * Whether to add an artificial shadow to the result. Default is false. Note: Adding - * shadows is currently only supported for car photos. + * Sets [Builder.file] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * You should usually call [Builder.file] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun addShadow(): Optional = addShadow.value.getOptional("add_shadow") + fun file(file: MultipartField) = apply { this.file = file } /** - * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or - * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be - * empty. + * The name with which the file has to be uploaded. The file name can contain: + * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + * - Special Characters: `.`, `-` * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * Any other character including space will be replaced by `_` */ - fun bgColor(): Optional = bgColor.value.getOptional("bg_color") + fun fileName(fileName: String) = fileName(MultipartField.of(fileName)) /** - * Sets a background image from a URL. If this parameter is set, `bg_color` must be - * empty. + * Sets [Builder.fileName] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * You should usually call [Builder.fileName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun bgImageUrl(): Optional = bgImageUrl.value.getOptional("bg_image_url") + fun fileName(fileName: MultipartField) = apply { this.fileName = fileName } /** - * Allows semi-transparent regions in the result. Default is true. Note: - * Semitransparency is currently only supported for car windows. + * A unique value that the ImageKit.io server will use to recognize and prevent + * subsequent retries for the same request. We suggest using V4 UUIDs, or another + * random string with enough entropy to avoid collisions. This field is only + * required for authentication when uploading a file from the client side. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * **Note**: Sending a value that has been used in the past will result in a + * validation error. Even if your previous request resulted in an error, you should + * always send a new value for this field. */ - fun semitransparency(): Optional = - semitransparency.value.getOptional("semitransparency") + fun token(token: String) = token(MultipartField.of(token)) /** - * Returns the raw multipart value of [addShadow]. + * Sets [Builder.token] to an arbitrary multipart value. * - * Unlike [addShadow], this method doesn't throw if the multipart field has an - * unexpected type. + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - @JsonProperty("add_shadow") - @ExcludeMissing - fun _addShadow(): MultipartField = addShadow + fun token(token: MultipartField) = apply { this.token = token } /** - * Returns the raw multipart value of [bgColor]. - * - * Unlike [bgColor], this method doesn't throw if the multipart field has an - * unexpected type. + * Server-side checks to run on the asset. Read more about + * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). */ - @JsonProperty("bg_color") - @ExcludeMissing - fun _bgColor(): MultipartField = bgColor + fun checks(checks: String) = checks(MultipartField.of(checks)) /** - * Returns the raw multipart value of [bgImageUrl]. + * Sets [Builder.checks] to an arbitrary multipart value. * - * Unlike [bgImageUrl], this method doesn't throw if the multipart field has an - * unexpected type. + * You should usually call [Builder.checks] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - @JsonProperty("bg_image_url") - @ExcludeMissing - fun _bgImageUrl(): MultipartField = bgImageUrl + fun checks(checks: MultipartField) = apply { this.checks = checks } /** - * Returns the raw multipart value of [semitransparency]. - * - * Unlike [semitransparency], this method doesn't throw if the multipart field has - * an unexpected type. + * Define an important area in the image. This is only relevant for image type + * files. + * - To be passed as a string with the x and y coordinates of the top-left corner, + * and width and height of the area of interest in the format `x,y,width,height`. + * For example - `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then + * customCoordinates will be removed. */ - @JsonProperty("semitransparency") - @ExcludeMissing - fun _semitransparency(): MultipartField = semitransparency + fun customCoordinates(customCoordinates: String) = + customCoordinates(MultipartField.of(customCoordinates)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + /** + * Sets [Builder.customCoordinates] to an arbitrary multipart value. + * + * You should usually call [Builder.customCoordinates] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun customCoordinates(customCoordinates: MultipartField) = apply { + this.customCoordinates = customCoordinates } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata + * fields before setting these values. + */ + fun customMetadata(customMetadata: CustomMetadata) = + customMetadata(MultipartField.of(customMetadata)) - /** Returns a mutable builder for constructing an instance of [Options]. */ - @JvmStatic fun builder() = Builder() + /** + * Sets [Builder.customMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.customMetadata] with a well-typed + * [CustomMetadata] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun customMetadata(customMetadata: MultipartField) = apply { + this.customMetadata = customMetadata } - /** A builder for [Options]. */ - class Builder internal constructor() { - - private var addShadow: MultipartField = MultipartField.of(null) - private var bgColor: MultipartField = MultipartField.of(null) - private var bgImageUrl: MultipartField = MultipartField.of(null) - private var semitransparency: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(options: Options) = apply { - addShadow = options.addShadow - bgColor = options.bgColor - bgImageUrl = options.bgImageUrl - semitransparency = options.semitransparency - additionalProperties = options.additionalProperties.toMutableMap() - } - - /** - * Whether to add an artificial shadow to the result. Default is false. Note: - * Adding shadows is currently only supported for car photos. - */ - fun addShadow(addShadow: Boolean) = addShadow(MultipartField.of(addShadow)) - - /** - * Sets [Builder.addShadow] to an arbitrary multipart value. - * - * You should usually call [Builder.addShadow] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun addShadow(addShadow: MultipartField) = apply { - this.addShadow = addShadow - } - - /** - * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or - * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be - * empty. - */ - fun bgColor(bgColor: String) = bgColor(MultipartField.of(bgColor)) - - /** - * Sets [Builder.bgColor] to an arbitrary multipart value. - * - * You should usually call [Builder.bgColor] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun bgColor(bgColor: MultipartField) = apply { this.bgColor = bgColor } + /** Optional text to describe the contents of the file. */ + fun description(description: String) = description(MultipartField.of(description)) - /** - * Sets a background image from a URL. If this parameter is set, `bg_color` must - * be empty. - */ - fun bgImageUrl(bgImageUrl: String) = bgImageUrl(MultipartField.of(bgImageUrl)) - - /** - * Sets [Builder.bgImageUrl] to an arbitrary multipart value. - * - * You should usually call [Builder.bgImageUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun bgImageUrl(bgImageUrl: MultipartField) = apply { - this.bgImageUrl = bgImageUrl - } + /** + * Sets [Builder.description] to an arbitrary multipart 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: MultipartField) = apply { + this.description = description + } - /** - * Allows semi-transparent regions in the result. Default is true. Note: - * Semitransparency is currently only supported for car windows. - */ - fun semitransparency(semitransparency: Boolean) = - semitransparency(MultipartField.of(semitransparency)) + /** + * The time until your signature is valid. It must be a + * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the + * future. It should be in seconds. This field is only required for authentication + * when uploading a file from the client side. + */ + fun expire(expire: Long) = expire(MultipartField.of(expire)) - /** - * Sets [Builder.semitransparency] to an arbitrary multipart value. - * - * You should usually call [Builder.semitransparency] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun semitransparency(semitransparency: MultipartField) = apply { - this.semitransparency = semitransparency - } + /** + * Sets [Builder.expire] to an arbitrary multipart value. + * + * You should usually call [Builder.expire] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expire(expire: MultipartField) = apply { this.expire = expire } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Array of extensions to be applied to the image. Each extension can be configured + * with specific parameters based on the extension type. + */ + fun extensions(extensions: List) = + extensions(MultipartField.of(extensions)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.extensions] to an arbitrary multipart value. + * + * You should usually call [Builder.extensions] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun extensions(extensions: MultipartField>) = apply { + this.extensions = extensions.map { it.toMutableList() } + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + /** + * Adds a single [Extension] to [extensions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExtension(extension: Extension) = apply { + extensions = + (extensions ?: MultipartField.of(mutableListOf())).also { + checkKnown("extensions", it).add(extension) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Options]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Options = - Options( - addShadow, - bgColor, - bgImageUrl, - semitransparency, - additionalProperties.toMutableMap(), - ) } - private var validated: Boolean = false + /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ + fun addExtension(removeBg: Extension.RemoveBg) = + addExtension(Extension.ofRemoveBg(removeBg)) - fun validate(): Options = apply { - if (validated) { - return@apply - } + /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = + addExtension(Extension.ofAutoTagging(autoTagging)) - addShadow() - bgColor() - bgImageUrl() - semitransparency() - validated = true - } + /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ + fun addExtensionAiAutoDescription() = addExtension(Extension.ofAiAutoDescription()) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't + * exist before, a new folder(s) is created. + * + * The folder name can contain: + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. + */ + fun folder(folder: String) = folder(MultipartField.of(folder)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.folder] to an arbitrary multipart value. + * + * You should usually call [Builder.folder] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun folder(folder: MultipartField) = apply { this.folder = folder } - return other is Options && - addShadow == other.addShadow && - bgColor == other.bgColor && - bgImageUrl == other.bgImageUrl && - semitransparency == other.semitransparency && - additionalProperties == other.additionalProperties - } + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named + * transformation or signed URL. + */ + fun isPrivateFile(isPrivateFile: Boolean) = + isPrivateFile(MultipartField.of(isPrivateFile)) - private val hashCode: Int by lazy { - Objects.hash( - addShadow, - bgColor, - bgImageUrl, - semitransparency, - additionalProperties, - ) + /** + * Sets [Builder.isPrivateFile] to an arbitrary multipart value. + * + * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun isPrivateFile(isPrivateFile: MultipartField) = apply { + this.isPrivateFile = isPrivateFile } - override fun hashCode(): Int = hashCode - - override fun toString() = - "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" - } + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file + * only via the media library. Files in draft or unpublished state can only be + * publicly accessed after being published. + * + * The option to upload in draft state is only available in custom enterprise + * pricing plans. + */ + fun isPublished(isPublished: Boolean) = isPublished(MultipartField.of(isPublished)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * Sets [Builder.isPublished] to an arbitrary multipart value. + * + * You should usually call [Builder.isPublished] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun isPublished(isPublished: MultipartField) = apply { + this.isPublished = isPublished } - return other is RemoveBg && - name == other.name && - options == other.options && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(name, options, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" - } - - class AutoTaggingExtension - private constructor( - private val maxTags: MultipartField, - private val minConfidence: MultipartField, - private val name: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Maximum number of tags to attach to the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun maxTags(): Long = maxTags.value.getRequired("maxTags") - - /** - * Minimum confidence level for tags to be considered valid. - * - * @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 minConfidence(): Long = minConfidence.value.getRequired("minConfidence") + /** + * If set to `true` and a file already exists at the exact location, its AITags will + * be removed. Set `overwriteAITags` to `false` to preserve AITags. + */ + fun overwriteAiTags(overwriteAiTags: Boolean) = + overwriteAiTags(MultipartField.of(overwriteAiTags)) - /** - * Specifies the auto-tagging extension used. - * - * @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(): Name = name.value.getRequired("name") + /** + * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteAiTags] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun overwriteAiTags(overwriteAiTags: MultipartField) = apply { + this.overwriteAiTags = overwriteAiTags + } - /** - * Returns the raw multipart value of [maxTags]. - * - * Unlike [maxTags], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("maxTags") @ExcludeMissing fun _maxTags(): MultipartField = maxTags + /** + * If the request does not have `customMetadata`, and a file already exists at the + * exact location, existing customMetadata will be removed. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: Boolean) = + overwriteCustomMetadata(MultipartField.of(overwriteCustomMetadata)) - /** - * Returns the raw multipart value of [minConfidence]. - * - * Unlike [minConfidence], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("minConfidence") - @ExcludeMissing - fun _minConfidence(): MultipartField = minConfidence + /** + * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteCustomMetadata] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: MultipartField) = + apply { + this.overwriteCustomMetadata = overwriteCustomMetadata + } - /** - * Returns the raw multipart value of [name]. - * - * Unlike [name], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at + * the exact location, upload API will return an error immediately. + */ + fun overwriteFile(overwriteFile: Boolean) = + overwriteFile(MultipartField.of(overwriteFile)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.overwriteFile] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun overwriteFile(overwriteFile: MultipartField) = apply { + this.overwriteFile = overwriteFile + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * If the request does not have `tags`, and a file already exists at the exact + * location, existing tags will be removed. + */ + fun overwriteTags(overwriteTags: Boolean) = + overwriteTags(MultipartField.of(overwriteTags)) - fun toBuilder() = Builder().from(this) + /** + * Sets [Builder.overwriteTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteTags] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun overwriteTags(overwriteTags: MultipartField) = apply { + this.overwriteTags = overwriteTags + } - companion object { + /** + * Your ImageKit.io public key. This field is only required for authentication when + * uploading a file from the client side. + */ + fun publicKey(publicKey: String) = publicKey(MultipartField.of(publicKey)) /** - * Returns a mutable builder for constructing an instance of [AutoTaggingExtension]. + * Sets [Builder.publicKey] to an arbitrary multipart value. * - * The following fields are required: - * ```java - * .maxTags() - * .minConfidence() - * .name() - * ``` + * You should usually call [Builder.publicKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - @JvmStatic fun builder() = Builder() - } + fun publicKey(publicKey: MultipartField) = apply { + this.publicKey = publicKey + } - /** A builder for [AutoTaggingExtension]. */ - class Builder internal constructor() { + /** Array of response field keys to include in the API response body. */ + fun responseFields(responseFields: List) = + responseFields(MultipartField.of(responseFields)) - private var maxTags: MultipartField? = null - private var minConfidence: MultipartField? = null - private var name: MultipartField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Sets [Builder.responseFields] to an arbitrary multipart value. + * + * You should usually call [Builder.responseFields] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun responseFields(responseFields: MultipartField>) = apply { + this.responseFields = responseFields.map { it.toMutableList() } + } - @JvmSynthetic - internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { - maxTags = autoTaggingExtension.maxTags - minConfidence = autoTaggingExtension.minConfidence - name = autoTaggingExtension.name - additionalProperties = autoTaggingExtension.additionalProperties.toMutableMap() + /** + * Adds a single [ResponseField] to [responseFields]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResponseField(responseField: ResponseField) = apply { + responseFields = + (responseFields ?: MultipartField.of(mutableListOf())).also { + checkKnown("responseFields", it).add(responseField) + } } - /** Maximum number of tags to attach to the asset. */ - fun maxTags(maxTags: Long) = maxTags(MultipartField.of(maxTags)) + /** + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a + * key. Learn how to create a signature on the page below. This should be in + * lowercase. + * + * Signature must be calculated on the server-side. This field is only required for + * authentication when uploading a file from the client side. + */ + fun signature(signature: String) = signature(MultipartField.of(signature)) /** - * Sets [Builder.maxTags] to an arbitrary multipart value. + * Sets [Builder.signature] to an arbitrary multipart value. * - * You should usually call [Builder.maxTags] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.signature] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun maxTags(maxTags: MultipartField) = apply { this.maxTags = maxTags } + fun signature(signature: MultipartField) = apply { + this.signature = signature + } - /** Minimum confidence level for tags to be considered valid. */ - fun minConfidence(minConfidence: Long) = - minConfidence(MultipartField.of(minConfidence)) + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. + * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not + * exceed 500, and the `%` character is not allowed. If this field is not specified + * and the file is overwritten, the existing tags will be removed. + */ + fun tags(tags: List) = tags(MultipartField.of(tags)) /** - * Sets [Builder.minConfidence] to an arbitrary multipart value. + * Sets [Builder.tags] to an arbitrary multipart value. * - * You should usually call [Builder.minConfidence] with a well-typed [Long] value + * You should usually call [Builder.tags] with a well-typed `List` value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun minConfidence(minConfidence: MultipartField) = apply { - this.minConfidence = minConfidence + fun tags(tags: MultipartField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = + (tags ?: MultipartField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } } - /** Specifies the auto-tagging extension used. */ - fun name(name: Name) = name(MultipartField.of(name)) + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for + * reducing file size or applying basic optimizations upfront (e.g., resize, + * compress). + * - `post` — applied immediately after upload. Ideal for generating transformed + * versions (like video encodes or thumbnails) in advance, so they're ready for + * delivery without delay. + * + * You can mix and match any combination of post-processing types. + */ + fun transformation(transformation: Transformation) = + transformation(MultipartField.of(transformation)) /** - * Sets [Builder.name] to an arbitrary multipart value. + * Sets [Builder.transformation] to an arbitrary multipart value. * - * You should usually call [Builder.name] with a well-typed [Name] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.transformation] with a well-typed + * [Transformation] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun transformation(transformation: MultipartField) = apply { + this.transformation = transformation + } + + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get + * a unique filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and + * any existing file with the same name is replaced. + */ + fun useUniqueFileName(useUniqueFileName: Boolean) = + useUniqueFileName(MultipartField.of(useUniqueFileName)) + + /** + * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. + * + * You should usually call [Builder.useUniqueFileName] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun useUniqueFileName(useUniqueFileName: MultipartField) = apply { + this.useUniqueFileName = useUniqueFileName + } + + /** + * The final status of extensions after they have completed execution will be + * delivered to this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + */ + fun webhookUrl(webhookUrl: String) = webhookUrl(MultipartField.of(webhookUrl)) + + /** + * Sets [Builder.webhookUrl] to an arbitrary multipart value. + * + * You should usually call [Builder.webhookUrl] 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: MultipartField) = apply { this.name = name } + fun webhookUrl(webhookUrl: MultipartField) = apply { + this.webhookUrl = webhookUrl + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3367,38 +5559,77 @@ private constructor( } /** - * Returns an immutable instance of [AutoTaggingExtension]. + * Returns an immutable instance of [FileUploadByUrlv1]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .maxTags() - * .minConfidence() - * .name() + * .file() + * .fileName() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AutoTaggingExtension = - AutoTaggingExtension( - checkRequired("maxTags", maxTags), - checkRequired("minConfidence", minConfidence), - checkRequired("name", name), + fun build(): FileUploadByUrlv1 = + FileUploadByUrlv1( + checkRequired("file", file), + checkRequired("fileName", fileName), + token, + checks, + customCoordinates, + customMetadata, + description, + expire, + (extensions ?: MultipartField.of(null)).map { it.toImmutable() }, + folder, + isPrivateFile, + isPublished, + overwriteAiTags, + overwriteCustomMetadata, + overwriteFile, + overwriteTags, + publicKey, + (responseFields ?: MultipartField.of(null)).map { it.toImmutable() }, + signature, + (tags ?: MultipartField.of(null)).map { it.toImmutable() }, + transformation, + useUniqueFileName, + webhookUrl, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): AutoTaggingExtension = apply { + fun validate(): FileUploadByUrlv1 = apply { if (validated) { return@apply } - maxTags() - minConfidence() - name().validate() + file() + fileName() + token() + checks() + customCoordinates() + customMetadata().ifPresent { it.validate() } + description() + expire() + extensions().ifPresent { it.forEach { it.validate() } } + folder() + isPrivateFile() + isPublished() + overwriteAiTags() + overwriteCustomMetadata() + overwriteFile() + overwriteTags() + publicKey() + responseFields().ifPresent { it.forEach { it.validate() } } + signature() + tags() + transformation().ifPresent { it.validate() } + useUniqueFileName() + webhookUrl() validated = true } @@ -3410,105 +5641,176 @@ private constructor( false } - /** Specifies the auto-tagging extension used. */ - class Name @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields + * before setting these values. + */ + class CustomMetadata + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun toBuilder() = Builder().from(this) companion object { - @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") + /** + * Returns a mutable builder for constructing an instance of [CustomMetadata]. + */ + @JvmStatic fun builder() = Builder() + } - @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") + /** A builder for [CustomMetadata]. */ + class Builder internal constructor() { - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } + private var additionalProperties: MutableMap = mutableMapOf() - /** An enum containing [Name]'s known values. */ - enum class Known { - GOOGLE_AUTO_TAGGING, - AWS_AUTO_TAGGING, - } + @JvmSynthetic + internal fun from(customMetadata: CustomMetadata) = apply { + additionalProperties = customMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Name] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GOOGLE_AUTO_TAGGING, - AWS_AUTO_TAGGING, /** - * An enum member indicating that [Name] was instantiated with an unknown value. + * Returns an immutable instance of [CustomMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. */ - _UNKNOWN, + fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING - AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING - else -> Value._UNKNOWN + private var validated: Boolean = false + + fun validate(): CustomMetadata = apply { + if (validated) { + return@apply } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING - AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING - else -> throw ImageKitInvalidDataException("Unknown Name: $value") + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomMetadata{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Extension.Deserializer::class) + @JsonSerialize(using = Extension.Serializer::class) + class Extension + private constructor( + private val removeBg: RemoveBg? = null, + private val autoTagging: AutoTaggingExtension? = null, + private val aiAutoDescription: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun removeBg(): Optional = Optional.ofNullable(removeBg) + + fun autoTagging(): Optional = Optional.ofNullable(autoTagging) + + fun aiAutoDescription(): Optional = + Optional.ofNullable(aiAutoDescription) + + fun isRemoveBg(): Boolean = removeBg != null + + fun isAutoTagging(): Boolean = autoTagging != null + + fun isAiAutoDescription(): Boolean = aiAutoDescription != null + + fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") + + fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") + + fun asAiAutoDescription(): JsonValue = + aiAutoDescription.getOrThrow("aiAutoDescription") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + removeBg != null -> visitor.visitRemoveBg(removeBg) + autoTagging != null -> visitor.visitAutoTagging(autoTagging) + aiAutoDescription != null -> + visitor.visitAiAutoDescription(aiAutoDescription) + else -> visitor.unknown(_json) } private var validated: Boolean = false - fun validate(): Name = apply { + fun validate(): Extension = apply { if (validated) { return@apply } - known() + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) { + removeBg.validate() + } + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { + autoTagging.validate() + } + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { + aiAutoDescription.let { + if ( + it != JsonValue.from(mapOf("name" to "ai-auto-description")) + ) { + throw ImageKitInvalidDataException( + "'aiAutoDescription' is invalid, received $it" + ) + } + } + } + } + ) validated = true } @@ -3526,792 +5828,1109 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = + autoTagging.validity() + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = + aiAutoDescription.let { + if ( + it == JsonValue.from(mapOf("name" to "ai-auto-description")) + ) + 1 + else 0 + } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Extension && + removeBg == other.removeBg && + autoTagging == other.autoTagging && + aiAutoDescription == other.aiAutoDescription + } + + override fun hashCode(): Int = + Objects.hash(removeBg, autoTagging, aiAutoDescription) + + override fun toString(): String = + when { + removeBg != null -> "Extension{removeBg=$removeBg}" + autoTagging != null -> "Extension{autoTagging=$autoTagging}" + aiAutoDescription != null -> + "Extension{aiAutoDescription=$aiAutoDescription}" + _json != null -> "Extension{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Extension") + } + + companion object { + + @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = Extension(removeBg = removeBg) + + @JvmStatic + fun ofAutoTagging(autoTagging: AutoTaggingExtension) = + Extension(autoTagging = autoTagging) + + @JvmStatic + fun ofAiAutoDescription() = + Extension( + aiAutoDescription = + JsonValue.from(mapOf("name" to "ai-auto-description")) + ) + } + + /** + * An interface that defines how to map each variant of [Extension] to a value of + * type [T]. + */ + interface Visitor { + + fun visitRemoveBg(removeBg: RemoveBg): T + + fun visitAutoTagging(autoTagging: AutoTaggingExtension): T + + fun visitAiAutoDescription(aiAutoDescription: JsonValue): T + + /** + * Maps an unknown variant of [Extension] to a value of type [T]. + * + * An instance of [Extension] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Extension: $json") + } + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + internal class Deserializer : BaseDeserializer(Extension::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Extension { + val json = JsonValue.fromJsonNode(node) + val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() + + when (name) { + "remove-bg" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Extension(removeBg = it, _json = json) + } ?: Extension(_json = json) + } + "ai-auto-description" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Extension(aiAutoDescription = it, _json = json) } + ?.takeIf { it.isValid() } ?: Extension(_json = json) + } + } + + return tryDeserialize(node, jacksonTypeRef())?.let { + Extension(autoTagging = it, _json = json) + } ?: Extension(_json = json) } + } - return other is Name && value == other.value + internal class Serializer : BaseSerializer(Extension::class) { + + override fun serialize( + value: Extension, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.removeBg != null -> generator.writeObject(value.removeBg) + value.autoTagging != null -> generator.writeObject(value.autoTagging) + value.aiAutoDescription != null -> + generator.writeObject(value.aiAutoDescription) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Extension") + } + } } - override fun hashCode() = value.hashCode() + class RemoveBg + private constructor( + private val name: JsonValue, + private val options: MultipartField, + private val additionalProperties: MutableMap, + ) { - override fun toString() = value.toString() - } + /** + * Specifies the background removal extension. + * + * Expected to always return the following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun options(): Optional = options.value.getOptional("options") - return other is AutoTaggingExtension && - maxTags == other.maxTags && - minConfidence == other.minConfidence && - name == other.name && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw multipart value of [options]. + * + * Unlike [options], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("options") + @ExcludeMissing + fun _options(): MultipartField = options - private val hashCode: Int by lazy { - Objects.hash(maxTags, minConfidence, name, additionalProperties) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun hashCode(): Int = hashCode + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun toString() = - "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" - } - } + fun toBuilder() = Builder().from(this) - class ResponseField @JsonCreator private constructor(private val value: JsonField) : - Enum { + companion object { - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ + @JvmStatic fun builder() = Builder() + } - companion object { + /** A builder for [RemoveBg]. */ + class Builder internal constructor() { - @JvmField val TAGS = of("tags") + private var name: JsonValue = JsonValue.from("remove-bg") + private var options: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = + mutableMapOf() - @JvmField val CUSTOM_COORDINATES = of("customCoordinates") + @JvmSynthetic + internal fun from(removeBg: RemoveBg) = apply { + name = removeBg.name + options = removeBg.options + additionalProperties = removeBg.additionalProperties.toMutableMap() + } - @JvmField val IS_PRIVATE_FILE = of("isPrivateFile") + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun name(name: JsonValue) = apply { this.name = name } - @JvmField val EMBEDDED_METADATA = of("embeddedMetadata") + fun options(options: Options) = options(MultipartField.of(options)) - @JvmField val IS_PUBLISHED = of("isPublished") + /** + * Sets [Builder.options] to an arbitrary multipart value. + * + * You should usually call [Builder.options] with a well-typed [Options] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun options(options: MultipartField) = apply { + this.options = options + } - @JvmField val CUSTOM_METADATA = of("customMetadata") + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JvmField val METADATA = of("metadata") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JvmStatic fun of(value: String) = ResponseField(JsonField.of(value)) - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** An enum containing [ResponseField]'s known values. */ - enum class Known { - TAGS, - CUSTOM_COORDINATES, - IS_PRIVATE_FILE, - EMBEDDED_METADATA, - IS_PUBLISHED, - CUSTOM_METADATA, - METADATA, - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * An enum containing [ResponseField]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ResponseField] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TAGS, - CUSTOM_COORDINATES, - IS_PRIVATE_FILE, - EMBEDDED_METADATA, - IS_PUBLISHED, - CUSTOM_METADATA, - METADATA, - /** - * An enum member indicating that [ResponseField] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TAGS -> Value.TAGS - CUSTOM_COORDINATES -> Value.CUSTOM_COORDINATES - IS_PRIVATE_FILE -> Value.IS_PRIVATE_FILE - EMBEDDED_METADATA -> Value.EMBEDDED_METADATA - IS_PUBLISHED -> Value.IS_PUBLISHED - CUSTOM_METADATA -> Value.CUSTOM_METADATA - METADATA -> Value.METADATA - else -> Value._UNKNOWN - } + /** + * Returns an immutable instance of [RemoveBg]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemoveBg = + RemoveBg(name, options, additionalProperties.toMutableMap()) + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TAGS -> Known.TAGS - CUSTOM_COORDINATES -> Known.CUSTOM_COORDINATES - IS_PRIVATE_FILE -> Known.IS_PRIVATE_FILE - EMBEDDED_METADATA -> Known.EMBEDDED_METADATA - IS_PUBLISHED -> Known.IS_PUBLISHED - CUSTOM_METADATA -> Known.CUSTOM_METADATA - METADATA -> Known.METADATA - else -> throw ImageKitInvalidDataException("Unknown ResponseField: $value") - } + private var validated: Boolean = false - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") - } + fun validate(): RemoveBg = apply { + if (validated) { + return@apply + } - private var validated: Boolean = false + _name().let { + if (it != JsonValue.from("remove-bg")) { + throw ImageKitInvalidDataException( + "'name' is invalid, received $it" + ) + } + } + options().ifPresent { it.validate() } + validated = true + } - fun validate(): ResponseField = apply { - if (validated) { - return@apply - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - known() - validated = true - } + class Options + private constructor( + private val addShadow: MultipartField, + private val bgColor: MultipartField, + private val bgImageUrl: MultipartField, + private val semitransparency: MultipartField, + private val additionalProperties: MutableMap, + ) { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + /** + * Whether to add an artificial shadow to the result. Default is false. + * Note: Adding shadows is currently only supported for car photos. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun addShadow(): Optional = + addShadow.value.getOptional("add_shadow") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") + * or color name (e.g., "green"). If this parameter is set, `bg_image_url` + * must be empty. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun bgColor(): Optional = bgColor.value.getOptional("bg_color") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets a background image from a URL. If this parameter is set, `bg_color` + * must be empty. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun bgImageUrl(): Optional = + bgImageUrl.value.getOptional("bg_image_url") - return other is ResponseField && value == other.value - } + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun semitransparency(): Optional = + semitransparency.value.getOptional("semitransparency") - override fun hashCode() = value.hashCode() + /** + * Returns the raw multipart value of [addShadow]. + * + * Unlike [addShadow], this method doesn't throw if the multipart field has + * an unexpected type. + */ + @JsonProperty("add_shadow") + @ExcludeMissing + fun _addShadow(): MultipartField = addShadow - override fun toString() = value.toString() - } + /** + * Returns the raw multipart value of [bgColor]. + * + * Unlike [bgColor], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("bg_color") + @ExcludeMissing + fun _bgColor(): MultipartField = bgColor - /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing file - * size or applying basic optimizations upfront (e.g., resize, compress). - * - `post` — applied immediately after upload. Ideal for generating transformed versions (like - * video encodes or thumbnails) in advance, so they're ready for delivery without delay. - * - * You can mix and match any combination of post-processing types. - */ - class Transformation - private constructor( - private val post: MultipartField>, - private val pre: MultipartField, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw multipart value of [bgImageUrl]. + * + * Unlike [bgImageUrl], this method doesn't throw if the multipart field has + * an unexpected type. + */ + @JsonProperty("bg_image_url") + @ExcludeMissing + fun _bgImageUrl(): MultipartField = bgImageUrl - /** - * List of transformations to apply _after_ the file is uploaded. Each item must match one - * of the following types: `transformation`, `gif-to-video`, `thumbnail`, `abs`. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun post(): Optional> = post.value.getOptional("post") + /** + * Returns the raw multipart value of [semitransparency]. + * + * Unlike [semitransparency], this method doesn't throw if the multipart + * field has an unexpected type. + */ + @JsonProperty("semitransparency") + @ExcludeMissing + fun _semitransparency(): MultipartField = semitransparency - /** - * Transformation string to apply before uploading the file to the Media Library. Useful for - * optimizing files at ingestion. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun pre(): Optional = pre.value.getOptional("pre") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Returns the raw multipart value of [post]. - * - * Unlike [post], this method doesn't throw if the multipart field has an unexpected type. - */ - @JsonProperty("post") @ExcludeMissing fun _post(): MultipartField> = post + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Returns the raw multipart value of [pre]. - * - * Unlike [pre], this method doesn't throw if the multipart field has an unexpected type. - */ - @JsonProperty("pre") @ExcludeMissing fun _pre(): MultipartField = pre + fun toBuilder() = Builder().from(this) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Returns a mutable builder for constructing an instance of [Options]. + */ + @JvmStatic fun builder() = Builder() + } - fun toBuilder() = Builder().from(this) + /** A builder for [Options]. */ + class Builder internal constructor() { + + private var addShadow: MultipartField = MultipartField.of(null) + private var bgColor: MultipartField = MultipartField.of(null) + private var bgImageUrl: MultipartField = MultipartField.of(null) + private var semitransparency: MultipartField = + MultipartField.of(null) + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(options: Options) = apply { + addShadow = options.addShadow + bgColor = options.bgColor + bgImageUrl = options.bgImageUrl + semitransparency = options.semitransparency + additionalProperties = options.additionalProperties.toMutableMap() + } - companion object { + /** + * Whether to add an artificial shadow to the result. Default is false. + * Note: Adding shadows is currently only supported for car photos. + */ + fun addShadow(addShadow: Boolean) = + addShadow(MultipartField.of(addShadow)) + + /** + * Sets [Builder.addShadow] to an arbitrary multipart value. + * + * You should usually call [Builder.addShadow] with a well-typed + * [Boolean] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun addShadow(addShadow: MultipartField) = apply { + this.addShadow = addShadow + } - /** Returns a mutable builder for constructing an instance of [Transformation]. */ - @JvmStatic fun builder() = Builder() - } + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", + * "fff") or color name (e.g., "green"). If this parameter is set, + * `bg_image_url` must be empty. + */ + fun bgColor(bgColor: String) = bgColor(MultipartField.of(bgColor)) + + /** + * Sets [Builder.bgColor] to an arbitrary multipart value. + * + * You should usually call [Builder.bgColor] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun bgColor(bgColor: MultipartField) = apply { + this.bgColor = bgColor + } - /** A builder for [Transformation]. */ - class Builder internal constructor() { + /** + * Sets a background image from a URL. If this parameter is set, + * `bg_color` must be empty. + */ + fun bgImageUrl(bgImageUrl: String) = + bgImageUrl(MultipartField.of(bgImageUrl)) + + /** + * Sets [Builder.bgImageUrl] to an arbitrary multipart value. + * + * You should usually call [Builder.bgImageUrl] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun bgImageUrl(bgImageUrl: MultipartField) = apply { + this.bgImageUrl = bgImageUrl + } - private var post: MultipartField>? = null - private var pre: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + */ + fun semitransparency(semitransparency: Boolean) = + semitransparency(MultipartField.of(semitransparency)) + + /** + * Sets [Builder.semitransparency] to an arbitrary multipart value. + * + * You should usually call [Builder.semitransparency] with a well-typed + * [Boolean] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun semitransparency(semitransparency: MultipartField) = + apply { + this.semitransparency = semitransparency + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JvmSynthetic - internal fun from(transformation: Transformation) = apply { - post = transformation.post.map { it.toMutableList() } - pre = transformation.pre - additionalProperties = transformation.additionalProperties.toMutableMap() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * List of transformations to apply _after_ the file is uploaded. Each item must match - * one of the following types: `transformation`, `gif-to-video`, `thumbnail`, `abs`. - */ - fun post(post: List) = post(MultipartField.of(post)) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets [Builder.post] to an arbitrary multipart value. - * - * You should usually call [Builder.post] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun post(post: MultipartField>) = apply { - this.post = post.map { it.toMutableList() } - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Adds a single [Post] to [Builder.post]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPost(post: Post) = apply { - this.post = - (this.post ?: MultipartField.of(mutableListOf())).also { - checkKnown("post", it).add(post) - } - } + /** + * Returns an immutable instance of [Options]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): Options = + Options( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties.toMutableMap(), + ) + } - /** Alias for calling [addPost] with `Post.ofTransformation(transformation)`. */ - fun addPost(transformation: Post.InnerTransformation) = - addPost(Post.ofTransformation(transformation)) + private var validated: Boolean = false - /** - * Alias for calling [addPost] with the following: - * ```java - * Post.InnerTransformation.builder() - * .value(value) - * .build() - * ``` - */ - fun addTransformationPost(value: String) = - addPost(Post.InnerTransformation.builder().value(value).build()) + fun validate(): Options = apply { + if (validated) { + return@apply + } - /** Alias for calling [addPost] with `Post.ofGifToVideo(gifToVideo)`. */ - fun addPost(gifToVideo: Post.GifToVideo) = addPost(Post.ofGifToVideo(gifToVideo)) + addShadow() + bgColor() + bgImageUrl() + semitransparency() + validated = true + } - /** Alias for calling [addPost] with `Post.ofThumbnail(thumbnail)`. */ - fun addPost(thumbnail: Post.Thumbnail) = addPost(Post.ofThumbnail(thumbnail)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - /** Alias for calling [addPost] with `Post.ofAbs(abs)`. */ - fun addPost(abs: Post.Abs) = addPost(Post.ofAbs(abs)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Transformation string to apply before uploading the file to the Media Library. Useful - * for optimizing files at ingestion. - */ - fun pre(pre: String) = pre(MultipartField.of(pre)) + return other is Options && + addShadow == other.addShadow && + bgColor == other.bgColor && + bgImageUrl == other.bgImageUrl && + semitransparency == other.semitransparency && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.pre] to an arbitrary multipart value. - * - * You should usually call [Builder.pre] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun pre(pre: MultipartField) = apply { this.pre = pre } + private val hashCode: Int by lazy { + Objects.hash( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties, + ) + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + override fun hashCode(): Int = hashCode - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun toString() = + "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + return other is RemoveBg && + name == other.name && + options == other.options && + additionalProperties == other.additionalProperties + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private val hashCode: Int by lazy { + Objects.hash(name, options, additionalProperties) + } - /** - * Returns an immutable instance of [Transformation]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Transformation = - Transformation( - (post ?: MultipartField.of(null)).map { it.toImmutable() }, - pre, - additionalProperties.toMutableMap(), - ) - } + override fun hashCode(): Int = hashCode - private var validated: Boolean = false + override fun toString() = + "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" + } - fun validate(): Transformation = apply { - if (validated) { - return@apply - } + class AutoTaggingExtension + private constructor( + private val maxTags: MultipartField, + private val minConfidence: MultipartField, + private val name: MultipartField, + private val additionalProperties: MutableMap, + ) { - post().ifPresent { it.forEach { it.validate() } } - pre() - validated = true - } + /** + * Maximum number of tags to attach to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maxTags(): Long = maxTags.value.getRequired("maxTags") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + /** + * Minimum confidence level for tags to be considered valid. + * + * @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 minConfidence(): Long = minConfidence.value.getRequired("minConfidence") - @JsonDeserialize(using = Post.Deserializer::class) - @JsonSerialize(using = Post.Serializer::class) - class Post - private constructor( - private val transformation: InnerTransformation? = null, - private val gifToVideo: GifToVideo? = null, - private val thumbnail: Thumbnail? = null, - private val abs: Abs? = null, - private val _json: JsonValue? = null, - ) { + /** + * Specifies the auto-tagging extension used. + * + * @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(): Name = name.value.getRequired("name") - fun transformation(): Optional = - Optional.ofNullable(transformation) + /** + * Returns the raw multipart value of [maxTags]. + * + * Unlike [maxTags], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("maxTags") + @ExcludeMissing + fun _maxTags(): MultipartField = maxTags - fun gifToVideo(): Optional = Optional.ofNullable(gifToVideo) + /** + * Returns the raw multipart value of [minConfidence]. + * + * Unlike [minConfidence], this method doesn't throw if the multipart field has + * an unexpected type. + */ + @JsonProperty("minConfidence") + @ExcludeMissing + fun _minConfidence(): MultipartField = minConfidence - fun thumbnail(): Optional = Optional.ofNullable(thumbnail) + /** + * Returns the raw multipart value of [name]. + * + * Unlike [name], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name - fun abs(): Optional = Optional.ofNullable(abs) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun isTransformation(): Boolean = transformation != null + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isGifToVideo(): Boolean = gifToVideo != null + fun toBuilder() = Builder().from(this) - fun isThumbnail(): Boolean = thumbnail != null + companion object { - fun isAbs(): Boolean = abs != null + /** + * Returns a mutable builder for constructing an instance of + * [AutoTaggingExtension]. + * + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun asTransformation(): InnerTransformation = - transformation.getOrThrow("transformation") + /** A builder for [AutoTaggingExtension]. */ + class Builder internal constructor() { + + private var maxTags: MultipartField? = null + private var minConfidence: MultipartField? = null + private var name: MultipartField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { + maxTags = autoTaggingExtension.maxTags + minConfidence = autoTaggingExtension.minConfidence + name = autoTaggingExtension.name + additionalProperties = + autoTaggingExtension.additionalProperties.toMutableMap() + } - fun asGifToVideo(): GifToVideo = gifToVideo.getOrThrow("gifToVideo") + /** Maximum number of tags to attach to the asset. */ + fun maxTags(maxTags: Long) = maxTags(MultipartField.of(maxTags)) - fun asThumbnail(): Thumbnail = thumbnail.getOrThrow("thumbnail") + /** + * Sets [Builder.maxTags] to an arbitrary multipart value. + * + * You should usually call [Builder.maxTags] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun maxTags(maxTags: MultipartField) = apply { + this.maxTags = maxTags + } - fun asAbs(): Abs = abs.getOrThrow("abs") + /** Minimum confidence level for tags to be considered valid. */ + fun minConfidence(minConfidence: Long) = + minConfidence(MultipartField.of(minConfidence)) - fun _json(): Optional = Optional.ofNullable(_json) + /** + * Sets [Builder.minConfidence] to an arbitrary multipart value. + * + * You should usually call [Builder.minConfidence] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minConfidence(minConfidence: MultipartField) = apply { + this.minConfidence = minConfidence + } - fun accept(visitor: Visitor): T = - when { - transformation != null -> visitor.visitTransformation(transformation) - gifToVideo != null -> visitor.visitGifToVideo(gifToVideo) - thumbnail != null -> visitor.visitThumbnail(thumbnail) - abs != null -> visitor.visitAbs(abs) - else -> visitor.unknown(_json) - } + /** Specifies the auto-tagging extension used. */ + fun name(name: Name) = name(MultipartField.of(name)) - private var validated: Boolean = false + /** + * Sets [Builder.name] to an arbitrary multipart value. + * + * You should usually call [Builder.name] with a well-typed [Name] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun name(name: MultipartField) = apply { this.name = name } - fun validate(): Post = apply { - if (validated) { - return@apply - } + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - accept( - object : Visitor { - override fun visitTransformation(transformation: InnerTransformation) { - transformation.validate() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - override fun visitGifToVideo(gifToVideo: GifToVideo) { - gifToVideo.validate() - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - override fun visitThumbnail(thumbnail: Thumbnail) { - thumbnail.validate() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - override fun visitAbs(abs: Abs) { - abs.validate() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + + /** + * Returns an immutable instance of [AutoTaggingExtension]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutoTaggingExtension = + AutoTaggingExtension( + checkRequired("maxTags", maxTags), + checkRequired("minConfidence", minConfidence), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + private var validated: Boolean = false - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitTransformation(transformation: InnerTransformation) = - transformation.validity() + fun validate(): AutoTaggingExtension = apply { + if (validated) { + return@apply + } - override fun visitGifToVideo(gifToVideo: GifToVideo) = gifToVideo.validity() + maxTags() + minConfidence() + name().validate() + validated = true + } - override fun visitThumbnail(thumbnail: Thumbnail) = thumbnail.validity() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - override fun visitAbs(abs: Abs) = abs.validity() + /** Specifies the auto-tagging extension used. */ + class Name + @JsonCreator + private constructor(private val value: JsonField) : Enum { - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + companion object { - return other is Post && - transformation == other.transformation && - gifToVideo == other.gifToVideo && - thumbnail == other.thumbnail && - abs == other.abs - } + @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") - override fun hashCode(): Int = Objects.hash(transformation, gifToVideo, thumbnail, abs) + @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") - override fun toString(): String = - when { - transformation != null -> "Post{transformation=$transformation}" - gifToVideo != null -> "Post{gifToVideo=$gifToVideo}" - thumbnail != null -> "Post{thumbnail=$thumbnail}" - abs != null -> "Post{abs=$abs}" - _json != null -> "Post{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Post") - } + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } - companion object { + /** An enum containing [Name]'s known values. */ + enum class Known { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + } + + /** + * An enum containing [Name]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Name] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + /** + * An enum member indicating that [Name] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - @JvmStatic - fun ofTransformation(transformation: InnerTransformation) = - Post(transformation = transformation) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING + else -> Value._UNKNOWN + } - @JvmStatic fun ofGifToVideo(gifToVideo: GifToVideo) = Post(gifToVideo = gifToVideo) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING + else -> throw ImageKitInvalidDataException("Unknown Name: $value") + } - @JvmStatic fun ofThumbnail(thumbnail: Thumbnail) = Post(thumbnail = thumbnail) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } - @JvmStatic fun ofAbs(abs: Abs) = Post(abs = abs) - } + private var validated: Boolean = false - /** - * An interface that defines how to map each variant of [Post] to a value of type [T]. - */ - interface Visitor { + fun validate(): Name = apply { + if (validated) { + return@apply + } - fun visitTransformation(transformation: InnerTransformation): T + known() + validated = true + } - fun visitGifToVideo(gifToVideo: GifToVideo): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - fun visitThumbnail(thumbnail: Thumbnail): T + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun visitAbs(abs: Abs): T + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Maps an unknown variant of [Post] to a value of type [T]. - * - * An instance of [Post] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Post: $json") - } - } + return other is Name && value == other.value + } - internal class Deserializer : BaseDeserializer(Post::class) { + override fun hashCode() = value.hashCode() - override fun ObjectCodec.deserialize(node: JsonNode): Post { - val json = JsonValue.fromJsonNode(node) - val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + override fun toString() = value.toString() + } - when (type) { - "transformation" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Post(transformation = it, _json = json) } - ?: Post(_json = json) - } - "gif-to-video" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(gifToVideo = it, _json = json) - } ?: Post(_json = json) - } - "thumbnail" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(thumbnail = it, _json = json) - } ?: Post(_json = json) - } - "abs" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(abs = it, _json = json) - } ?: Post(_json = json) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is AutoTaggingExtension && + maxTags == other.maxTags && + minConfidence == other.minConfidence && + name == other.name && + additionalProperties == other.additionalProperties } - return Post(_json = json) - } - } + private val hashCode: Int by lazy { + Objects.hash(maxTags, minConfidence, name, additionalProperties) + } - internal class Serializer : BaseSerializer(Post::class) { + override fun hashCode(): Int = hashCode - override fun serialize( - value: Post, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.transformation != null -> generator.writeObject(value.transformation) - value.gifToVideo != null -> generator.writeObject(value.gifToVideo) - value.thumbnail != null -> generator.writeObject(value.thumbnail) - value.abs != null -> generator.writeObject(value.abs) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Post") - } + override fun toString() = + "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" } } - class InnerTransformation - private constructor( - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Transformation type. - * - * Expected to always return the following: - * ```java - * JsonValue.from("transformation") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based - * 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 value(): String = value.value.getRequired("value") + class ResponseField + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** - * Returns the raw multipart value of [value]. + * Returns this class instance's raw value. * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmField val TAGS = of("tags") - fun toBuilder() = Builder().from(this) + @JvmField val CUSTOM_COORDINATES = of("customCoordinates") - companion object { + @JvmField val IS_PRIVATE_FILE = of("isPrivateFile") - /** - * Returns a mutable builder for constructing an instance of - * [InnerTransformation]. - * - * The following fields are required: - * ```java - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + @JvmField val EMBEDDED_METADATA = of("embeddedMetadata") - /** A builder for [InnerTransformation]. */ - class Builder internal constructor() { + @JvmField val IS_PUBLISHED = of("isPublished") - private var type: JsonValue = JsonValue.from("transformation") - private var value: MultipartField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val CUSTOM_METADATA = of("customMetadata") - @JvmSynthetic - internal fun from(innerTransformation: InnerTransformation) = apply { - type = innerTransformation.type - value = innerTransformation.value - additionalProperties = - innerTransformation.additionalProperties.toMutableMap() - } + @JvmField val METADATA = of("metadata") - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```java - * JsonValue.from("transformation") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } + @JvmStatic fun of(value: String) = ResponseField(JsonField.of(value)) + } - /** - * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based - * transformations. - */ - fun value(value: String) = value(MultipartField.of(value)) + /** An enum containing [ResponseField]'s known values. */ + enum class Known { + TAGS, + CUSTOM_COORDINATES, + IS_PRIVATE_FILE, + EMBEDDED_METADATA, + IS_PUBLISHED, + CUSTOM_METADATA, + METADATA, + } + /** + * An enum containing [ResponseField]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ResponseField] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TAGS, + CUSTOM_COORDINATES, + IS_PRIVATE_FILE, + EMBEDDED_METADATA, + IS_PUBLISHED, + CUSTOM_METADATA, + METADATA, /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * An enum member indicating that [ResponseField] was instantiated with an + * unknown value. */ - fun value(value: MultipartField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + _UNKNOWN, + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TAGS -> Value.TAGS + CUSTOM_COORDINATES -> Value.CUSTOM_COORDINATES + IS_PRIVATE_FILE -> Value.IS_PRIVATE_FILE + EMBEDDED_METADATA -> Value.EMBEDDED_METADATA + IS_PUBLISHED -> Value.IS_PUBLISHED + CUSTOM_METADATA -> Value.CUSTOM_METADATA + METADATA -> Value.METADATA + else -> Value._UNKNOWN } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + TAGS -> Known.TAGS + CUSTOM_COORDINATES -> Known.CUSTOM_COORDINATES + IS_PRIVATE_FILE -> Known.IS_PRIVATE_FILE + EMBEDDED_METADATA -> Known.EMBEDDED_METADATA + IS_PUBLISHED -> Known.IS_PUBLISHED + CUSTOM_METADATA -> Known.CUSTOM_METADATA + METADATA -> Known.METADATA + else -> throw ImageKitInvalidDataException("Unknown ResponseField: $value") } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") } - /** - * Returns an immutable instance of [InnerTransformation]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): InnerTransformation = - InnerTransformation( - type, - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - private var validated: Boolean = false - fun validate(): InnerTransformation = apply { + fun validate(): ResponseField = apply { if (validated) { return@apply } - _type().let { - if (it != JsonValue.from("transformation")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } - value() + known() validated = true } @@ -4323,62 +6942,79 @@ private constructor( false } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is InnerTransformation && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(type, value, additionalProperties) + return other is ResponseField && value == other.value } - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "InnerTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - class GifToVideo + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for + * reducing file size or applying basic optimizations upfront (e.g., resize, + * compress). + * - `post` — applied immediately after upload. Ideal for generating transformed + * versions (like video encodes or thumbnails) in advance, so they're ready for + * delivery without delay. + * + * You can mix and match any combination of post-processing types. + */ + class Transformation private constructor( - private val type: JsonValue, - private val value: MultipartField, + private val post: MultipartField>, + private val pre: MultipartField, private val additionalProperties: MutableMap, ) { /** - * Converts an animated GIF into an MP4. - * - * Expected to always return the following: - * ```java - * JsonValue.from("gif-to-video") - * ``` + * List of transformations to apply _after_ the file is uploaded. Each item must + * match one of the following types: `transformation`, `gif-to-video`, `thumbnail`, + * `abs`. * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + fun post(): Optional> = post.value.getOptional("post") /** - * Optional transformation string to apply to the output video. **Example**: `q-80` + * Transformation string to apply before uploading the file to the Media Library. + * Useful for optimizing files at ingestion. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun value(): Optional = value.value.getOptional("value") + fun pre(): Optional = pre.value.getOptional("pre") + + /** + * Returns the raw multipart value of [post]. + * + * Unlike [post], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("post") @ExcludeMissing fun _post(): MultipartField> = post /** - * Returns the raw multipart value of [value]. + * Returns the raw multipart value of [pre]. * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. + * Unlike [pre], this method doesn't throw if the multipart field has an unexpected + * type. */ - @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value + @JsonProperty("pre") @ExcludeMissing fun _pre(): MultipartField = pre @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -4394,52 +7030,95 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [GifToVideo]. */ + /** + * Returns a mutable builder for constructing an instance of [Transformation]. + */ @JvmStatic fun builder() = Builder() } - /** A builder for [GifToVideo]. */ + /** A builder for [Transformation]. */ class Builder internal constructor() { - private var type: JsonValue = JsonValue.from("gif-to-video") - private var value: MultipartField = MultipartField.of(null) + private var post: MultipartField>? = null + private var pre: MultipartField = MultipartField.of(null) private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(gifToVideo: GifToVideo) = apply { - type = gifToVideo.type - value = gifToVideo.value - additionalProperties = gifToVideo.additionalProperties.toMutableMap() + internal fun from(transformation: Transformation) = apply { + post = transformation.post.map { it.toMutableList() } + pre = transformation.pre + additionalProperties = transformation.additionalProperties.toMutableMap() } /** - * Sets the field to an arbitrary JSON value. + * List of transformations to apply _after_ the file is uploaded. Each item must + * match one of the following types: `transformation`, `gif-to-video`, + * `thumbnail`, `abs`. + */ + fun post(post: List) = post(MultipartField.of(post)) + + /** + * Sets [Builder.post] to an arbitrary multipart value. + * + * You should usually call [Builder.post] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun post(post: MultipartField>) = apply { + this.post = post.map { it.toMutableList() } + } + + /** + * Adds a single [Post] to [Builder.post]. * - * It is usually unnecessary to call this method because the field defaults to - * the following: + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPost(post: Post) = apply { + this.post = + (this.post ?: MultipartField.of(mutableListOf())).also { + checkKnown("post", it).add(post) + } + } + + /** Alias for calling [addPost] with `Post.ofTransformation(transformation)`. */ + fun addPost(transformation: Post.InnerTransformation) = + addPost(Post.ofTransformation(transformation)) + + /** + * Alias for calling [addPost] with the following: * ```java - * JsonValue.from("gif-to-video") + * Post.InnerTransformation.builder() + * .value(value) + * .build() * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. */ - fun type(type: JsonValue) = apply { this.type = type } + fun addTransformationPost(value: String) = + addPost(Post.InnerTransformation.builder().value(value).build()) + + /** Alias for calling [addPost] with `Post.ofGifToVideo(gifToVideo)`. */ + fun addPost(gifToVideo: Post.GifToVideo) = + addPost(Post.ofGifToVideo(gifToVideo)) + + /** Alias for calling [addPost] with `Post.ofThumbnail(thumbnail)`. */ + fun addPost(thumbnail: Post.Thumbnail) = addPost(Post.ofThumbnail(thumbnail)) + + /** Alias for calling [addPost] with `Post.ofAbs(abs)`. */ + fun addPost(abs: Post.Abs) = addPost(Post.ofAbs(abs)) /** - * Optional transformation string to apply to the output video. **Example**: - * `q-80` + * Transformation string to apply before uploading the file to the Media + * Library. Useful for optimizing files at ingestion. */ - fun value(value: String) = value(MultipartField.of(value)) + fun pre(pre: String) = pre(MultipartField.of(pre)) /** - * Sets [Builder.value] to an arbitrary multipart value. + * Sets [Builder.pre] to an arbitrary multipart value. * - * You should usually call [Builder.value] with a well-typed [String] value + * You should usually call [Builder.pre] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun value(value: MultipartField) = apply { this.value = value } + fun pre(pre: MultipartField) = apply { this.pre = pre } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4464,27 +7143,27 @@ private constructor( } /** - * Returns an immutable instance of [GifToVideo]. + * Returns an immutable instance of [Transformation]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): GifToVideo = - GifToVideo(type, value, additionalProperties.toMutableMap()) + fun build(): Transformation = + Transformation( + (post ?: MultipartField.of(null)).map { it.toImmutable() }, + pre, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): GifToVideo = apply { + fun validate(): Transformation = apply { if (validated) { return@apply } - _type().let { - if (it != JsonValue.from("gif-to-video")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") - } - } - value() + post().ifPresent { it.forEach { it.validate() } } + pre() validated = true } @@ -4496,542 +7175,1188 @@ private constructor( false } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonDeserialize(using = Post.Deserializer::class) + @JsonSerialize(using = Post.Serializer::class) + class Post + private constructor( + private val transformation: InnerTransformation? = null, + private val gifToVideo: GifToVideo? = null, + private val thumbnail: Thumbnail? = null, + private val abs: Abs? = null, + private val _json: JsonValue? = null, + ) { - return other is GifToVideo && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } + fun transformation(): Optional = + Optional.ofNullable(transformation) - private val hashCode: Int by lazy { - Objects.hash(type, value, additionalProperties) - } + fun gifToVideo(): Optional = Optional.ofNullable(gifToVideo) - override fun hashCode(): Int = hashCode + fun thumbnail(): Optional = Optional.ofNullable(thumbnail) - override fun toString() = - "GifToVideo{type=$type, value=$value, additionalProperties=$additionalProperties}" - } + fun abs(): Optional = Optional.ofNullable(abs) - class Thumbnail - private constructor( - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { + fun isTransformation(): Boolean = transformation != null - /** - * Generates a thumbnail image. - * - * Expected to always return the following: - * ```java - * JsonValue.from("thumbnail") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + fun isGifToVideo(): Boolean = gifToVideo != null - /** - * Optional transformation string. **Example**: `w-150,h-150` - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun value(): Optional = value.value.getOptional("value") + fun isThumbnail(): Boolean = thumbnail != null - /** - * Returns the raw multipart value of [value]. - * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value + fun isAbs(): Boolean = abs != null - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun asTransformation(): InnerTransformation = + transformation.getOrThrow("transformation") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun asGifToVideo(): GifToVideo = gifToVideo.getOrThrow("gifToVideo") - fun toBuilder() = Builder().from(this) + fun asThumbnail(): Thumbnail = thumbnail.getOrThrow("thumbnail") - companion object { + fun asAbs(): Abs = abs.getOrThrow("abs") - /** Returns a mutable builder for constructing an instance of [Thumbnail]. */ - @JvmStatic fun builder() = Builder() - } + fun _json(): Optional = Optional.ofNullable(_json) - /** A builder for [Thumbnail]. */ - class Builder internal constructor() { + fun accept(visitor: Visitor): T = + when { + transformation != null -> visitor.visitTransformation(transformation) + gifToVideo != null -> visitor.visitGifToVideo(gifToVideo) + thumbnail != null -> visitor.visitThumbnail(thumbnail) + abs != null -> visitor.visitAbs(abs) + else -> visitor.unknown(_json) + } - private var type: JsonValue = JsonValue.from("thumbnail") - private var value: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = mutableMapOf() + private var validated: Boolean = false - @JvmSynthetic - internal fun from(thumbnail: Thumbnail) = apply { - type = thumbnail.type - value = thumbnail.value - additionalProperties = thumbnail.additionalProperties.toMutableMap() + fun validate(): Post = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTransformation( + transformation: InnerTransformation + ) { + transformation.validate() + } + + override fun visitGifToVideo(gifToVideo: GifToVideo) { + gifToVideo.validate() + } + + override fun visitThumbnail(thumbnail: Thumbnail) { + thumbnail.validate() + } + + override fun visitAbs(abs: Abs) { + abs.validate() + } + } + ) + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```java - * JsonValue.from("thumbnail") - * ``` + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Used for best match union deserialization. */ - fun type(type: JsonValue) = apply { this.type = type } + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitTransformation( + transformation: InnerTransformation + ) = transformation.validity() + + override fun visitGifToVideo(gifToVideo: GifToVideo) = + gifToVideo.validity() + + override fun visitThumbnail(thumbnail: Thumbnail) = + thumbnail.validity() + + override fun visitAbs(abs: Abs) = abs.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Post && + transformation == other.transformation && + gifToVideo == other.gifToVideo && + thumbnail == other.thumbnail && + abs == other.abs + } - /** Optional transformation string. **Example**: `w-150,h-150` */ - fun value(value: String) = value(MultipartField.of(value)) + override fun hashCode(): Int = + Objects.hash(transformation, gifToVideo, thumbnail, abs) + + override fun toString(): String = + when { + transformation != null -> "Post{transformation=$transformation}" + gifToVideo != null -> "Post{gifToVideo=$gifToVideo}" + thumbnail != null -> "Post{thumbnail=$thumbnail}" + abs != null -> "Post{abs=$abs}" + _json != null -> "Post{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Post") + } + + companion object { + + @JvmStatic + fun ofTransformation(transformation: InnerTransformation) = + Post(transformation = transformation) + + @JvmStatic + fun ofGifToVideo(gifToVideo: GifToVideo) = Post(gifToVideo = gifToVideo) + + @JvmStatic + fun ofThumbnail(thumbnail: Thumbnail) = Post(thumbnail = thumbnail) + + @JvmStatic fun ofAbs(abs: Abs) = Post(abs = abs) + } /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * An interface that defines how to map each variant of [Post] to a value of + * type [T]. */ - fun value(value: MultipartField) = apply { this.value = value } + interface Visitor { - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun visitTransformation(transformation: InnerTransformation): T - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + fun visitGifToVideo(gifToVideo: GifToVideo): T + + fun visitThumbnail(thumbnail: Thumbnail): T + + fun visitAbs(abs: Abs): T + + /** + * Maps an unknown variant of [Post] to a value of type [T]. + * + * An instance of [Post] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the API may respond + * with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Post: $json") + } } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + internal class Deserializer : BaseDeserializer(Post::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Post { + val json = JsonValue.fromJsonNode(node) + val type = + json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "transformation" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Post(transformation = it, _json = json) } + ?: Post(_json = json) + } + "gif-to-video" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(gifToVideo = it, _json = json) + } ?: Post(_json = json) + } + "thumbnail" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(thumbnail = it, _json = json) + } ?: Post(_json = json) + } + "abs" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(abs = it, _json = json) + } ?: Post(_json = json) + } + } + + return Post(_json = json) } + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + internal class Serializer : BaseSerializer(Post::class) { + + override fun serialize( + value: Post, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.transformation != null -> + generator.writeObject(value.transformation) + value.gifToVideo != null -> generator.writeObject(value.gifToVideo) + value.thumbnail != null -> generator.writeObject(value.thumbnail) + value.abs != null -> generator.writeObject(value.abs) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Post") + } + } } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + class InnerTransformation + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Transformation type. + * + * Expected to always return the following: + * ```java + * JsonValue.from("transformation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit + * URL-based 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 value(): String = value.value.getRequired("value") + + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): MultipartField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InnerTransformation]. + * + * The following fields are required: + * ```java + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InnerTransformation]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("transformation") + private var value: MultipartField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(innerTransformation: InnerTransformation) = apply { + type = innerTransformation.type + value = innerTransformation.value + additionalProperties = + innerTransformation.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("transformation") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit + * URL-based transformations. + */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InnerTransformation]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InnerTransformation = + InnerTransformation( + type, + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InnerTransformation = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("transformation")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InnerTransformation && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InnerTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" } - /** - * Returns an immutable instance of [Thumbnail]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Thumbnail = - Thumbnail(type, value, additionalProperties.toMutableMap()) - } + class GifToVideo + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { - private var validated: Boolean = false + /** + * Converts an animated GIF into an MP4. + * + * Expected to always return the following: + * ```java + * JsonValue.from("gif-to-video") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - fun validate(): Thumbnail = apply { - if (validated) { - return@apply + /** + * Optional transformation string to apply to the output video. **Example**: + * `q-80` + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.value.getOptional("value") + + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): MultipartField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GifToVideo]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GifToVideo]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("gif-to-video") + private var value: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(gifToVideo: GifToVideo) = apply { + type = gifToVideo.type + value = gifToVideo.value + additionalProperties = + gifToVideo.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("gif-to-video") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Optional transformation string to apply to the output video. + * **Example**: `q-80` + */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GifToVideo]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): GifToVideo = + GifToVideo(type, value, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): GifToVideo = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("gif-to-video")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GifToVideo && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GifToVideo{type=$type, value=$value, additionalProperties=$additionalProperties}" } - _type().let { - if (it != JsonValue.from("thumbnail")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") + class Thumbnail + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Generates a thumbnail image. + * + * Expected to always return the following: + * ```java + * JsonValue.from("thumbnail") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Optional transformation string. **Example**: `w-150,h-150` + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.value.getOptional("value") + + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): MultipartField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - } - value() - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun toBuilder() = Builder().from(this) - return other is Thumbnail && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } + companion object { - private val hashCode: Int by lazy { - Objects.hash(type, value, additionalProperties) - } + /** + * Returns a mutable builder for constructing an instance of + * [Thumbnail]. + */ + @JvmStatic fun builder() = Builder() + } - override fun hashCode(): Int = hashCode + /** A builder for [Thumbnail]. */ + class Builder internal constructor() { - override fun toString() = - "Thumbnail{type=$type, value=$value, additionalProperties=$additionalProperties}" - } + private var type: JsonValue = JsonValue.from("thumbnail") + private var value: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = + mutableMapOf() - class Abs - private constructor( - private val protocol: MultipartField, - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { + @JvmSynthetic + internal fun from(thumbnail: Thumbnail) = apply { + type = thumbnail.type + value = thumbnail.value + additionalProperties = thumbnail.additionalProperties.toMutableMap() + } - /** - * Streaming protocol to use (`hls` or `dash`). - * - * @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 protocol(): Protocol = protocol.value.getRequired("protocol") + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("thumbnail") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Optional transformation string. **Example**: `w-150,h-150` */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Adaptive Bitrate Streaming (ABS) setup. - * - * Expected to always return the following: - * ```java - * JsonValue.from("abs") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - /** - * List of different representations you want to create separated by an underscore. - * - * @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 value(): String = value.value.getRequired("value") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Returns the raw multipart value of [protocol]. - * - * Unlike [protocol], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("protocol") - @ExcludeMissing - fun _protocol(): MultipartField = protocol + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** - * Returns the raw multipart value of [value]. - * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value + /** + * Returns an immutable instance of [Thumbnail]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): Thumbnail = + Thumbnail(type, value, additionalProperties.toMutableMap()) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + private var validated: Boolean = false - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun validate(): Thumbnail = apply { + if (validated) { + return@apply + } - fun toBuilder() = Builder().from(this) + _type().let { + if (it != JsonValue.from("thumbnail")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + value() + validated = true + } - companion object { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - /** - * Returns a mutable builder for constructing an instance of [Abs]. - * - * The following fields are required: - * ```java - * .protocol() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** A builder for [Abs]. */ - class Builder internal constructor() { + return other is Thumbnail && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } - private var protocol: MultipartField? = null - private var type: JsonValue = JsonValue.from("abs") - private var value: MultipartField? = null - private var additionalProperties: MutableMap = mutableMapOf() + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } - @JvmSynthetic - internal fun from(abs: Abs) = apply { - protocol = abs.protocol - type = abs.type - value = abs.value - additionalProperties = abs.additionalProperties.toMutableMap() + override fun hashCode(): Int = hashCode + + override fun toString() = + "Thumbnail{type=$type, value=$value, additionalProperties=$additionalProperties}" } - /** Streaming protocol to use (`hls` or `dash`). */ - fun protocol(protocol: Protocol) = protocol(MultipartField.of(protocol)) + class Abs + private constructor( + private val protocol: MultipartField, + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { - /** - * Sets [Builder.protocol] to an arbitrary multipart value. - * - * You should usually call [Builder.protocol] with a well-typed [Protocol] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun protocol(protocol: MultipartField) = apply { - this.protocol = protocol - } + /** + * Streaming protocol to use (`hls` or `dash`). + * + * @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 protocol(): Protocol = protocol.value.getRequired("protocol") - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```java - * JsonValue.from("abs") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } + /** + * Adaptive Bitrate Streaming (ABS) setup. + * + * Expected to always return the following: + * ```java + * JsonValue.from("abs") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * List of different representations you want to create separated by an - * underscore. - */ - fun value(value: String) = value(MultipartField.of(value)) + /** + * List of different representations you want to create separated by an + * underscore. + * + * @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 value(): String = value.value.getRequired("value") - /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun value(value: MultipartField) = apply { this.value = value } + /** + * Returns the raw multipart value of [protocol]. + * + * Unlike [protocol], this method doesn't throw if the multipart field has + * an unexpected type. + */ + @JsonProperty("protocol") + @ExcludeMissing + fun _protocol(): MultipartField = protocol - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): MultipartField = value - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Abs]. + * + * The following fields are required: + * ```java + * .protocol() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** A builder for [Abs]. */ + class Builder internal constructor() { + + private var protocol: MultipartField? = null + private var type: JsonValue = JsonValue.from("abs") + private var value: MultipartField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(abs: Abs) = apply { + protocol = abs.protocol + type = abs.type + value = abs.value + additionalProperties = abs.additionalProperties.toMutableMap() + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** Streaming protocol to use (`hls` or `dash`). */ + fun protocol(protocol: Protocol) = protocol(MultipartField.of(protocol)) + + /** + * Sets [Builder.protocol] to an arbitrary multipart value. + * + * You should usually call [Builder.protocol] with a well-typed + * [Protocol] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun protocol(protocol: MultipartField) = apply { + this.protocol = protocol + } - /** - * Returns an immutable instance of [Abs]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .protocol() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Abs = - Abs( - checkRequired("protocol", protocol), - type, - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("abs") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * List of different representations you want to create separated by an + * underscore. + */ + fun value(value: String) = value(MultipartField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - private var validated: Boolean = false + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - fun validate(): Abs = apply { - if (validated) { - return@apply - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - protocol().validate() - _type().let { - if (it != JsonValue.from("abs")) { - throw ImageKitInvalidDataException("'type' is invalid, received $it") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Abs]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .protocol() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Abs = + Abs( + checkRequired("protocol", protocol), + type, + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) } - } - value() - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + private var validated: Boolean = false - /** Streaming protocol to use (`hls` or `dash`). */ - class Protocol - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun validate(): Abs = apply { + if (validated) { + return@apply + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + protocol().validate() + _type().let { + if (it != JsonValue.from("abs")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + value() + validated = true + } - companion object { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - @JvmField val HLS = of("hls") + /** Streaming protocol to use (`hls` or `dash`). */ + class Protocol + @JsonCreator + private constructor(private val value: JsonField) : Enum { - @JvmField val DASH = of("dash") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from + * data that doesn't match any known member, and you want to know that + * value. For example, if the SDK is on an older version than the API, + * then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - @JvmStatic fun of(value: String) = Protocol(JsonField.of(value)) - } + companion object { - /** An enum containing [Protocol]'s known values. */ - enum class Known { - HLS, - DASH, - } + @JvmField val HLS = of("hls") - /** - * An enum containing [Protocol]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Protocol] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - HLS, - DASH, - /** - * An enum member indicating that [Protocol] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + @JvmField val DASH = of("dash") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - HLS -> Value.HLS - DASH -> Value.DASH - else -> Value._UNKNOWN - } + @JvmStatic fun of(value: String) = Protocol(JsonField.of(value)) + } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - HLS -> Known.HLS - DASH -> Known.DASH - else -> throw ImageKitInvalidDataException("Unknown Protocol: $value") - } + /** An enum containing [Protocol]'s known values. */ + enum class Known { + HLS, + DASH, + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") - } + /** + * An enum containing [Protocol]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [Protocol] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HLS, + DASH, + /** + * An enum member indicating that [Protocol] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } - private var validated: Boolean = false + /** + * Returns an enum member corresponding to this class instance's value, + * or [Value._UNKNOWN] if the class was instantiated with an unknown + * value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HLS -> Value.HLS + DASH -> Value.DASH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + HLS -> Known.HLS + DASH -> Known.DASH + else -> + throw ImageKitInvalidDataException( + "Unknown Protocol: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Protocol = apply { + if (validated) { + return@apply + } + + known() + validated = true + } - fun validate(): Protocol = apply { - if (validated) { - return@apply - } + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Protocol && value == other.value + } - known() - validated = true - } + override fun hashCode() = value.hashCode() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false + override fun toString() = value.toString() } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + return other is Abs && + protocol == other.protocol && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties } - return other is Protocol && value == other.value - } + private val hashCode: Int by lazy { + Objects.hash(protocol, type, value, additionalProperties) + } - override fun hashCode() = value.hashCode() + override fun hashCode(): Int = hashCode - override fun toString() = value.toString() + override fun toString() = + "Abs{protocol=$protocol, type=$type, value=$value, additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { @@ -5039,41 +8364,86 @@ private constructor( return true } - return other is Abs && - protocol == other.protocol && - type == other.type && - value == other.value && + return other is Transformation && + post == other.post && + pre == other.pre && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(protocol, type, value, additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(post, pre, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Abs{protocol=$protocol, type=$type, value=$value, additionalProperties=$additionalProperties}" + "Transformation{post=$post, pre=$pre, additionalProperties=$additionalProperties}" } - } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - return other is Transformation && - post == other.post && - pre == other.pre && - additionalProperties == other.additionalProperties - } + return other is FileUploadByUrlv1 && + file == other.file && + fileName == other.fileName && + token == other.token && + checks == other.checks && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + description == other.description && + expire == other.expire && + extensions == other.extensions && + folder == other.folder && + isPrivateFile == other.isPrivateFile && + isPublished == other.isPublished && + overwriteAiTags == other.overwriteAiTags && + overwriteCustomMetadata == other.overwriteCustomMetadata && + overwriteFile == other.overwriteFile && + overwriteTags == other.overwriteTags && + publicKey == other.publicKey && + responseFields == other.responseFields && + signature == other.signature && + tags == other.tags && + transformation == other.transformation && + useUniqueFileName == other.useUniqueFileName && + webhookUrl == other.webhookUrl && + additionalProperties == other.additionalProperties + } - private val hashCode: Int by lazy { Objects.hash(post, pre, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + file, + fileName, + token, + checks, + customCoordinates, + customMetadata, + description, + expire, + extensions, + folder, + isPrivateFile, + isPublished, + overwriteAiTags, + overwriteCustomMetadata, + overwriteFile, + overwriteTags, + publicKey, + responseFields, + signature, + tags, + transformation, + useUniqueFileName, + webhookUrl, + additionalProperties, + ) + } - override fun hashCode(): Int = hashCode + override fun hashCode(): Int = hashCode - override fun toString() = - "Transformation{post=$post, pre=$pre, additionalProperties=$additionalProperties}" + override fun toString() = + "FileUploadByUrlv1{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, expire=$expire, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, publicKey=$publicKey, responseFields=$responseFields, signature=$signature, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + } } override fun equals(other: Any?): Boolean { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt index f5db6fe3..addd9d29 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt @@ -220,15 +220,23 @@ interface FileServiceAsync { * file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. * - [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies. */ - fun upload(params: FileUploadParams): CompletableFuture = - upload(params, RequestOptions.none()) + fun upload(): CompletableFuture = upload(FileUploadParams.none()) /** @see upload */ fun upload( - params: FileUploadParams, + params: FileUploadParams = FileUploadParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see upload */ + fun upload( + params: FileUploadParams = FileUploadParams.none() + ): CompletableFuture = upload(params, RequestOptions.none()) + + /** @see upload */ + fun upload(requestOptions: RequestOptions): CompletableFuture = + upload(FileUploadParams.none(), requestOptions) + /** A view of [FileServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -406,15 +414,25 @@ interface FileServiceAsync { * Returns a raw HTTP response for `post /api/v1/files/upload`, but is otherwise the same as * [FileServiceAsync.upload]. */ + fun upload(): CompletableFuture> = + upload(FileUploadParams.none()) + + /** @see upload */ fun upload( - params: FileUploadParams + params: FileUploadParams = FileUploadParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see upload */ + fun upload( + params: FileUploadParams = FileUploadParams.none() ): CompletableFuture> = upload(params, RequestOptions.none()) /** @see upload */ fun upload( - params: FileUploadParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + requestOptions: RequestOptions + ): CompletableFuture> = + upload(FileUploadParams.none(), requestOptions) } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt index bafc4724..5743ebbd 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt @@ -346,7 +346,11 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien else "https://upload.imagekit.io" ) .addPathSegments("api", "v1", "files", "upload") - .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .apply { + params._body().ifPresent { + body(multipartFormData(clientOptions.jsonMapper, it)) + } + } .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt index 8f4e8f80..51e5acf6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt @@ -202,14 +202,22 @@ interface FileService { * file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. * - [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies. */ - fun upload(params: FileUploadParams): FileUploadResponse = upload(params, RequestOptions.none()) + fun upload(): FileUploadResponse = upload(FileUploadParams.none()) /** @see upload */ fun upload( - params: FileUploadParams, + params: FileUploadParams = FileUploadParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): FileUploadResponse + /** @see upload */ + fun upload(params: FileUploadParams = FileUploadParams.none()): FileUploadResponse = + upload(params, RequestOptions.none()) + + /** @see upload */ + fun upload(requestOptions: RequestOptions): FileUploadResponse = + upload(FileUploadParams.none(), requestOptions) + /** A view of [FileService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -396,14 +404,24 @@ interface FileService { * [FileService.upload]. */ @MustBeClosed - fun upload(params: FileUploadParams): HttpResponseFor = - upload(params, RequestOptions.none()) + fun upload(): HttpResponseFor = upload(FileUploadParams.none()) /** @see upload */ @MustBeClosed fun upload( - params: FileUploadParams, + params: FileUploadParams = FileUploadParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see upload */ + @MustBeClosed + fun upload( + params: FileUploadParams = FileUploadParams.none() + ): HttpResponseFor = upload(params, RequestOptions.none()) + + /** @see upload */ + @MustBeClosed + fun upload(requestOptions: RequestOptions): HttpResponseFor = + upload(FileUploadParams.none(), requestOptions) } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt index 6448f2b3..85fd05b1 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt @@ -315,7 +315,11 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti else "https://upload.imagekit.io" ) .addPathSegments("api", "v1", "files", "upload") - .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .apply { + params._body().ifPresent { + body(multipartFormData(clientOptions.jsonMapper, it)) + } + } .build() .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt index 11752909..7957b53f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt @@ -5,6 +5,7 @@ package com.imagekit.api.models.files import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField import java.io.InputStream +import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,81 +14,95 @@ internal class FileUploadParamsTest { @Test fun create() { FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg.builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension.AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post.Thumbnail + .builder() + .value("w-150,h-150") .build() ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") - .build() - ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() } @@ -95,84 +110,101 @@ internal class FileUploadParamsTest { fun body() { val params = FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg.builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post.Thumbnail + .builder() + .value("w-150,h-150") .build() ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .pre("w-300,h-300,q-80") .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) - .value("sr-240_360_480_720_1080") - .build() - ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() - val body = params._body() + val body = params._body().getOrNull() assertThat(body.filterValues { !it.value.isNull() }) .usingRecursiveComparison() @@ -184,89 +216,135 @@ internal class FileUploadParamsTest { ) .isEqualTo( mapOf( - "file" to MultipartField.of("some content".byteInputStream()), - "fileName" to MultipartField.of("fileName"), - "token" to MultipartField.of("token"), - "checks" to MultipartField.of("\"request.folder\" : \"marketing/\"\n"), - "customCoordinates" to MultipartField.of("customCoordinates"), - "customMetadata" to - MultipartField.of( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ), - "description" to MultipartField.of("Running shoes"), - "expire" to MultipartField.of(0L), - "extensions" to - MultipartField.of( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options + "body" to + MultipartField.builder() + .value( + FileUploadParams.Body.ofFileUploadV1( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .putAdditionalProperty( + "brand", + JsonValue.from("bar"), + ) + .putAdditionalProperty( + "color", + JsonValue.from("bar"), + ) .build() ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension + .ofRemoveBg( + FileUploadParams.Body.FileUploadV1 + .Extension + .RemoveBg + .builder() + .options( + FileUploadParams.Body + .FileUploadV1 + .Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAutoTagging( + FileUploadParams.Body.FileUploadV1 + .Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body + .FileUploadV1 + .Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ), - "folder" to MultipartField.of("folder"), - "isPrivateFile" to MultipartField.of(true), - "isPublished" to MultipartField.of(true), - "overwriteAITags" to MultipartField.of(true), - "overwriteCustomMetadata" to MultipartField.of(true), - "overwriteFile" to MultipartField.of(true), - "overwriteTags" to MultipartField.of(true), - "publicKey" to MultipartField.of("publicKey"), - "responseFields" to - MultipartField.of( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ), - "signature" to MultipartField.of("signature"), - "tags" to MultipartField.of(listOf("t-shirt", "round-neck", "men")), - "transformation" to - MultipartField.of( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") - .build() - ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol - .DASH + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField + .TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation + .builder() + .addPost( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") + .build() ) - .value("sr-240_360_480_720_1080") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .pre("w-300,h-300,q-80") - .build() - ), - "useUniqueFileName" to MultipartField.of(true), - "webhookUrl" to MultipartField.of("https://example.com"), + ) + .contentType("application/octet-stream") + .build() ) .mapValues { (_, field) -> field.map { (it as? ByteArray)?.inputStream() ?: it } @@ -276,30 +354,10 @@ internal class FileUploadParamsTest { @Test fun bodyWithoutOptionalFields() { - val params = - FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .build() + val params = FileUploadParams.builder().build() - val body = params._body() + val body = params._body().getOrNull() - assertThat(body.filterValues { !it.value.isNull() }) - .usingRecursiveComparison() - // TODO(AssertJ): Replace this and the `mapValues` below with: - // https://github.com/assertj/assertj/issues/3165 - .withEqualsForType( - { a, b -> a.readBytes() contentEquals b.readBytes() }, - InputStream::class.java, - ) - .isEqualTo( - mapOf( - "file" to MultipartField.of("some content".byteInputStream()), - "fileName" to MultipartField.of("fileName"), - ) - .mapValues { (_, field) -> - field.map { (it as? ByteArray)?.inputStream() ?: it } - } - ) + assertThat(body.filterValues { !it.value.isNull() }).isEmpty() } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt index 33349dd2..ff35db98 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt @@ -73,83 +73,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -173,83 +197,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() ) - .value("sr-240_360_480_720_1080") + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -273,83 +321,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -373,83 +445,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -473,83 +569,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -573,83 +693,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() ) - .value("sr-240_360_480_720_1080") + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -673,83 +817,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() ) - .value("sr-240_360_480_720_1080") + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -773,83 +941,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -873,83 +1065,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -973,83 +1189,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() ) - .value("sr-240_360_480_720_1080") + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -1073,83 +1313,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() ) - .value("sr-240_360_480_720_1080") + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -1173,83 +1437,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -1273,83 +1561,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() ) - .value("sr-240_360_480_720_1080") + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -1373,83 +1685,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -1473,83 +1809,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() ) - .value("sr-240_360_480_720_1080") + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -1573,83 +1933,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } @@ -1671,83 +2055,107 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField + .IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1 + .Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt index f26281ec..6a14b916 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt @@ -4,7 +4,6 @@ package com.imagekit.api.services import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.equalTo -import com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath import com.github.tomakehurst.wiremock.client.WireMock.ok import com.github.tomakehurst.wiremock.client.WireMock.post import com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor @@ -45,84 +44,100 @@ internal class ServiceParamsTest { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg.builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post.Thumbnail + .builder() + .value("w-150,h-150") .build() ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") - .build() - ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .putAdditionalHeader("Secret-Header", "42") .putAdditionalQueryParam("secret_query_param", "42") - .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) .build() ) @@ -130,7 +145,6 @@ internal class ServiceParamsTest { postRequestedFor(anyUrl()) .withHeader("Secret-Header", equalTo("42")) .withQueryParam("secret_query_param", equalTo("42")) - .withRequestBody(matchingJsonPath("$.secretProperty", equalTo("42"))) ) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index 6e8d541b..3acc3a30 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -227,83 +227,104 @@ internal class FileServiceAsyncTest { val responseFuture = fileServiceAsync.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1.Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index 2e932b81..89de610f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -220,83 +220,104 @@ internal class FileServiceTest { val response = fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() - .options( - FileUploadParams.Extension.RemoveBg.Options.builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Extension.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.ResponseField.TAGS, - FileUploadParams.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Transformation.builder() - .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() - .value("w-150,h-150") + .body( + FileUploadParams.Body.FileUploadV1.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) - .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( + FileUploadParams.Body.FileUploadV1.Extension.RemoveBg + .builder() + .options( + FileUploadParams.Body.FileUploadV1.Extension + .RemoveBg + .Options + .builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Body.FileUploadV1.Extension + .AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Body.FileUploadV1.Extension + .ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, + FileUploadParams.Body.FileUploadV1.ResponseField + .CUSTOM_COORDINATES, + FileUploadParams.Body.FileUploadV1.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Body.FileUploadV1.Transformation.builder() + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post + .Thumbnail + .builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs + .builder() + .protocol( + FileUploadParams.Body.FileUploadV1.Transformation + .Post + .Abs + .Protocol + .DASH + ) + .value("sr-240_360_480_720_1080") + .build() ) - .value("sr-240_360_480_720_1080") + .pre("w-300,h-300,q-80") .build() ) - .pre("w-300,h-300,q-80") + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") .build() ) From 924fef868b56dea71b882e386da248ed8e2a5213 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 11:46:59 +0000 Subject: [PATCH 013/142] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index db7d8f1e..f8166f44 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-9ae7b43dcfd6208ca37c32c887630ae186ec338bcdd36902b6fe5d1cc66459dc.yml -openapi_spec_hash: 25fb64c067e64bcff6eaaabda26de397 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-5ce78cb448cc4520f5fbcc753452e0237b50a4bf64902e0548a8ad24bbdc82cf.yml +openapi_spec_hash: fd8ac4c2cdddc3d3a0b0c81be6a9edfe config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c From 181fbe5360fbc5820cb9df684d242896ec146049 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 4 Sep 2025 02:27:55 +0000 Subject: [PATCH 014/142] fix(ci): use java-version 21 for publish step --- .github/workflows/publish-sonatype.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index 59853755..9207f7f8 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -22,7 +22,7 @@ jobs: distribution: temurin java-version: | 8 - 17 + 21 cache: gradle - name: Set up Gradle From cd2b64ef8d6324264a71321bb11a7849260d98fc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 4 Sep 2025 05:45:12 +0000 Subject: [PATCH 015/142] feat(api): manual updates --- .stats.yml | 4 +- README.md | 93 +- .../api/models/files/FileUploadParams.kt | 11454 ++++++---------- .../api/services/async/FileServiceAsync.kt | 32 +- .../services/async/FileServiceAsyncImpl.kt | 6 +- .../api/services/blocking/FileService.kt | 28 +- .../api/services/blocking/FileServiceImpl.kt | 6 +- .../api/models/files/FileUploadParamsTest.kt | 530 +- .../api/services/ErrorHandlingTest.kt | 2788 ++-- .../api/services/ServiceParamsTest.kt | 156 +- .../services/async/FileServiceAsyncTest.kt | 161 +- .../api/services/blocking/FileServiceTest.kt | 161 +- 12 files changed, 5754 insertions(+), 9665 deletions(-) diff --git a/.stats.yml b/.stats.yml index f8166f44..cfcbd7f7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-5ce78cb448cc4520f5fbcc753452e0237b50a4bf64902e0548a8ad24bbdc82cf.yml -openapi_spec_hash: fd8ac4c2cdddc3d3a0b0c81be6a9edfe +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml +openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c diff --git a/README.md b/README.md index d7b4537c..4e268347 100644 --- a/README.md +++ b/README.md @@ -50,12 +50,17 @@ import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); -FileUploadResponse response = client.files().upload(); +FileUploadParams params = FileUploadParams.builder() + .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") + .build(); +FileUploadResponse response = client.files().upload(params); ``` ## Client configuration @@ -150,13 +155,18 @@ import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); -CompletableFuture response = client.async().files().upload(); +FileUploadParams params = FileUploadParams.builder() + .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") + .build(); +CompletableFuture response = client.async().files().upload(params); ``` Or create an asynchronous client from the beginning: @@ -166,13 +176,18 @@ import com.imagekit.api.client.ImageKitClientAsync; import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv(); -CompletableFuture response = client.files().upload(); +FileUploadParams params = FileUploadParams.builder() + .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") + .build(); +CompletableFuture response = client.files().upload(params); ``` The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. @@ -184,50 +199,50 @@ The SDK defines methods that accept files. To upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html): ```java -import com.imagekit.api.models.beta.v2.files.FileUploadParams; -import com.imagekit.api.models.beta.v2.files.FileUploadResponse; +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; import java.nio.file.Paths; FileUploadParams params = FileUploadParams.builder() .fileName("fileName") .file(Paths.get("/path/to/file")) .build(); -FileUploadResponse response = client.beta().v2().files().upload(params); +FileUploadResponse response = client.files().upload(params); ``` Or an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html): ```java -import com.imagekit.api.models.beta.v2.files.FileUploadParams; -import com.imagekit.api.models.beta.v2.files.FileUploadResponse; +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; import java.net.URL; FileUploadParams params = FileUploadParams.builder() .fileName("fileName") .file(new URL("https://example.com//path/to/file").openStream()) .build(); -FileUploadResponse response = client.beta().v2().files().upload(params); +FileUploadResponse response = client.files().upload(params); ``` Or a `byte[]` array: ```java -import com.imagekit.api.models.beta.v2.files.FileUploadParams; -import com.imagekit.api.models.beta.v2.files.FileUploadResponse; +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; FileUploadParams params = FileUploadParams.builder() .fileName("fileName") .file("content".getBytes()) .build(); -FileUploadResponse response = client.beta().v2().files().upload(params); +FileUploadResponse response = client.files().upload(params); ``` Note that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt): ```java import com.imagekit.api.core.MultipartField; -import com.imagekit.api.models.beta.v2.files.FileUploadParams; -import com.imagekit.api.models.beta.v2.files.FileUploadResponse; +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; import java.io.InputStream; import java.net.URL; @@ -238,7 +253,7 @@ FileUploadParams params = FileUploadParams.builder() .filename("/path/to/file") .build()) .build(); -FileUploadResponse response = client.beta().v2().files().upload(params); +FileUploadResponse response = client.files().upload(params); ``` ## Raw responses @@ -252,8 +267,13 @@ import com.imagekit.api.core.http.Headers; import com.imagekit.api.core.http.HttpResponseFor; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; -HttpResponseFor response = client.files().withRawResponse().upload(); +FileUploadParams params = FileUploadParams.builder() + .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") + .build(); +HttpResponseFor response = client.files().withRawResponse().upload(params); int statusCode = response.statusCode(); Headers headers = response.headers(); @@ -362,7 +382,9 @@ To set a custom timeout, configure the method call using the `timeout` method: ```java import com.imagekit.api.models.files.FileUploadResponse; -FileUploadResponse response = client.files().upload(RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()); +FileUploadResponse response = client.files().upload( + params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build() +); ``` Or configure the default for all method calls at the client level: @@ -480,10 +502,10 @@ To set undocumented parameters on _nested_ headers, query params, or body classe ```java import com.imagekit.api.core.JsonValue; -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams; +import com.imagekit.api.models.files.FileUploadParams; -CustomMetadataFieldCreateParams params = CustomMetadataFieldCreateParams.builder() - .schema(CustomMetadataFieldCreateParams.Schema.builder() +FileUploadParams params = FileUploadParams.builder() + .transformation(FileUploadParams.Transformation.builder() .putAdditionalProperty("secretProperty", JsonValue.from("42")) .build()) .build(); @@ -494,9 +516,13 @@ These properties can be accessed on the nested built object later using the `_ad To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter: ```java +import com.imagekit.api.core.JsonValue; import com.imagekit.api.models.files.FileUploadParams; -FileUploadParams params = FileUploadParams.builder().build(); +FileUploadParams params = FileUploadParams.builder() + .file(JsonValue.from(42)) + .fileName("file-name.jpg") + .build(); ``` The most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method: @@ -544,15 +570,11 @@ To forcibly omit a required parameter or property, pass [`JsonMissing`](image-ki ```java import com.imagekit.api.core.JsonMissing; -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams; import com.imagekit.api.models.files.FileUploadParams; -FileUploadParams params = CustomMetadataFieldCreateParams.builder() - .name("price") - .schema(CustomMetadataFieldCreateParams.Schema.builder() - .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) - .build()) - .label(JsonMissing.of()) +FileUploadParams params = FileUploadParams.builder() + .fileName("fileName") + .file(JsonMissing.of()) .build(); ``` @@ -592,21 +614,22 @@ To access a property's raw JSON value, which may be undocumented, call its `_` p ```java import com.imagekit.api.core.JsonField; +import java.io.InputStream; import java.util.Optional; -JsonField field = client.files().upload(params)._field(); +JsonField file = client.files().upload(params)._file(); -if (field.isMissing()) { +if (file.isMissing()) { // The property is absent from the JSON response -} else if (field.isNull()) { +} else if (file.isNull()) { // The property was set to literal null } else { // Check if value was provided as a string // Other methods include `asNumber()`, `asBoolean()`, etc. - Optional jsonString = field.asString(); + Optional jsonString = file.asString(); // Try to deserialize into a custom type - MyClass myObject = field.asUnknown().orElseThrow().convert(MyClass.class); + MyClass myObject = file.asUnknown().orElseThrow().convert(MyClass.class); } ``` @@ -629,7 +652,9 @@ Or configure the method call to validate the response using the `responseValidat ```java import com.imagekit.api.models.files.FileUploadResponse; -FileUploadResponse response = client.files().upload(RequestOptions.builder().responseValidation(true).build()); +FileUploadResponse response = client.files().upload( + params, RequestOptions.builder().responseValidation(true).build() +); ``` Or configure the default for all method calls at the client level: diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt index f50bfafd..e50852f0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -21,7 +21,6 @@ import com.imagekit.api.core.JsonField import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField import com.imagekit.api.core.Params -import com.imagekit.api.core.allMaxBy import com.imagekit.api.core.checkKnown import com.imagekit.api.core.checkRequired import com.imagekit.api.core.getOrThrow @@ -62,4438 +61,1771 @@ import kotlin.jvm.optionals.getOrNull */ class FileUploadParams private constructor( - private val body: MultipartField, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + * + * @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 file(): InputStream = body.file() + + /** + * The name with which the file has to be uploaded. The file name can contain: + * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + * - Special Characters: `.`, `-` + * + * Any other character including space will be replaced by `_` + * + * @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 fileName(): String = body.fileName() + + /** + * A unique value that the ImageKit.io server will use to recognize and prevent subsequent + * retries for the same request. We suggest using V4 UUIDs, or another random string with enough + * entropy to avoid collisions. This field is only required for authentication when uploading a + * file from the client side. + * + * **Note**: Sending a value that has been used in the past will result in a validation error. + * Even if your previous request resulted in an error, you should always send a new value for + * this field. + * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun body(): Optional = body.value.getOptional("body") + fun token(): Optional = body.token() /** - * Returns the raw multipart value of [body]. + * Server-side checks to run on the asset. Read more about + * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). * - * Unlike [body], this method doesn't throw if the multipart field has an unexpected type. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("body") @ExcludeMissing fun _body(): MultipartField = body - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders + fun checks(): Optional = body.checks() - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * Define an important area in the image. This is only relevant for image type files. + * - To be passed as a string with the x and y coordinates of the top-left corner, and width and + * height of the area of interest in the format `x,y,width,height`. For example - + * `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates will be + * removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customCoordinates(): Optional = body.customCoordinates() - fun toBuilder() = Builder().from(this) + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields before + * setting these values. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customMetadata(): Optional = body.customMetadata() - companion object { + /** + * Optional text to describe the contents of the file. + * + * @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() - @JvmStatic fun none(): FileUploadParams = builder().build() + /** + * The time until your signature is valid. It must be a + * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. It + * should be in seconds. This field is only required for authentication when uploading a file + * from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expire(): Optional = body.expire() - /** Returns a mutable builder for constructing an instance of [FileUploadParams]. */ - @JvmStatic fun builder() = Builder() - } + /** + * Array of extensions to be applied to the image. Each extension can be configured with + * specific parameters based on the extension type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun extensions(): Optional> = body.extensions() - /** A builder for [FileUploadParams]. */ - class Builder internal constructor() { + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, + * a new folder(s) is created. + * + * The folder name can contain: + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun folder(): Optional = body.folder() - private var body: MultipartField = MultipartField.of(null) - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named transformation or + * signed URL. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isPrivateFile(): Optional = body.isPrivateFile() - @JvmSynthetic - internal fun from(fileUploadParams: FileUploadParams) = apply { - body = fileUploadParams.body - additionalHeaders = fileUploadParams.additionalHeaders.toBuilder() - additionalQueryParams = fileUploadParams.additionalQueryParams.toBuilder() - } + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file only via + * the media library. Files in draft or unpublished state can only be publicly accessed after + * being published. + * + * The option to upload in draft state is only available in custom enterprise pricing plans. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isPublished(): Optional = body.isPublished() - fun body(body: Body) = - body( - MultipartField.builder() - .value(body) - .contentType("application/octet-stream") - .build() - ) + /** + * If set to `true` and a file already exists at the exact location, its AITags will be removed. + * Set `overwriteAITags` to `false` to preserve AITags. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun overwriteAiTags(): Optional = body.overwriteAiTags() - /** - * Sets [Builder.body] to an arbitrary multipart value. - * - * You should usually call [Builder.body] with a well-typed [Body] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun body(body: MultipartField) = apply { this.body = body } + /** + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun overwriteCustomMetadata(): Optional = body.overwriteCustomMetadata() - /** Alias for calling [body] with `Body.ofFileUploadV1(fileUploadV1)`. */ - fun body(fileUploadV1: Body.FileUploadV1) = body(Body.ofFileUploadV1(fileUploadV1)) + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the exact + * location, upload API will return an error immediately. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun overwriteFile(): Optional = body.overwriteFile() - /** Alias for calling [body] with `Body.ofFileUploadByUrlv1(fileUploadByUrlv1)`. */ - fun body(fileUploadByUrlv1: Body.FileUploadByUrlv1) = - body(Body.ofFileUploadByUrlv1(fileUploadByUrlv1)) + /** + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun overwriteTags(): Optional = body.overwriteTags() - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + /** + * Your ImageKit.io public key. This field is only required for authentication when uploading a + * file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun publicKey(): Optional = body.publicKey() - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } + /** + * Array of response field keys to include in the API response body. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun responseFields(): Optional> = body.responseFields() - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } + /** + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. Learn + * how to create a signature on the page below. This should be in lowercase. + * + * Signature must be calculated on the server-side. This field is only required for + * authentication when uploading a file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun signature(): Optional = body.signature() - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", + * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the `%` + * character is not allowed. If this field is not specified and the file is overwritten, the + * existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tags(): Optional> = body.tags() - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing file + * size or applying basic optimizations upfront (e.g., resize, compress). + * - `post` — applied immediately after upload. Ideal for generating transformed versions (like + * video encodes or thumbnails) in advance, so they're ready for delivery without delay. + * + * You can mix and match any combination of post-processing types. + * + * @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() - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique + * filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any existing + * file with the same name is replaced. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun useUniqueFileName(): Optional = body.useUniqueFileName() - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } + /** + * The final status of extensions after they have completed execution will be delivered to this + * endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookUrl(): Optional = body.webhookUrl() - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } + /** + * Returns the raw multipart value of [file]. + * + * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _file(): MultipartField = body._file() - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + /** + * Returns the raw multipart value of [fileName]. + * + * Unlike [fileName], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _fileName(): MultipartField = body._fileName() - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } + /** + * Returns the raw multipart value of [token]. + * + * Unlike [token], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _token(): MultipartField = body._token() - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + /** + * Returns the raw multipart value of [checks]. + * + * Unlike [checks], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _checks(): MultipartField = body._checks() - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } + /** + * Returns the raw multipart value of [customCoordinates]. + * + * Unlike [customCoordinates], this method doesn't throw if the multipart field has an + * unexpected type. + */ + fun _customCoordinates(): MultipartField = body._customCoordinates() - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + /** + * Returns the raw multipart value of [customMetadata]. + * + * Unlike [customMetadata], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _customMetadata(): MultipartField = body._customMetadata() - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } + /** + * Returns the raw multipart value of [description]. + * + * Unlike [description], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _description(): MultipartField = body._description() - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } + /** + * Returns the raw multipart value of [expire]. + * + * Unlike [expire], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _expire(): MultipartField = body._expire() - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } + /** + * Returns the raw multipart value of [extensions]. + * + * Unlike [extensions], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _extensions(): MultipartField> = body._extensions() - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + /** + * Returns the raw multipart value of [folder]. + * + * Unlike [folder], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _folder(): MultipartField = body._folder() - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } + /** + * Returns the raw multipart value of [isPrivateFile]. + * + * Unlike [isPrivateFile], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _isPrivateFile(): MultipartField = body._isPrivateFile() - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } + /** + * Returns the raw multipart value of [isPublished]. + * + * Unlike [isPublished], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _isPublished(): MultipartField = body._isPublished() - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } + /** + * Returns the raw multipart value of [overwriteAiTags]. + * + * Unlike [overwriteAiTags], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _overwriteAiTags(): MultipartField = body._overwriteAiTags() - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + /** + * Returns the raw multipart value of [overwriteCustomMetadata]. + * + * Unlike [overwriteCustomMetadata], this method doesn't throw if the multipart field has an + * unexpected type. + */ + fun _overwriteCustomMetadata(): MultipartField = body._overwriteCustomMetadata() - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } + /** + * Returns the raw multipart value of [overwriteFile]. + * + * Unlike [overwriteFile], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _overwriteFile(): MultipartField = body._overwriteFile() - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + /** + * Returns the raw multipart value of [overwriteTags]. + * + * Unlike [overwriteTags], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _overwriteTags(): MultipartField = body._overwriteTags() - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } + /** + * Returns the raw multipart value of [publicKey]. + * + * Unlike [publicKey], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _publicKey(): MultipartField = body._publicKey() + + /** + * Returns the raw multipart value of [responseFields]. + * + * Unlike [responseFields], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _responseFields(): MultipartField> = body._responseFields() + + /** + * Returns the raw multipart value of [signature]. + * + * Unlike [signature], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _signature(): MultipartField = body._signature() + + /** + * Returns the raw multipart value of [tags]. + * + * Unlike [tags], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _tags(): MultipartField> = body._tags() + + /** + * Returns the raw multipart value of [transformation]. + * + * Unlike [transformation], this method doesn't throw if the multipart field has an unexpected + * type. + */ + fun _transformation(): MultipartField = body._transformation() + + /** + * Returns the raw multipart value of [useUniqueFileName]. + * + * Unlike [useUniqueFileName], this method doesn't throw if the multipart field has an + * unexpected type. + */ + fun _useUniqueFileName(): MultipartField = body._useUniqueFileName() + + /** + * Returns the raw multipart value of [webhookUrl]. + * + * Unlike [webhookUrl], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _webhookUrl(): MultipartField = body._webhookUrl() + + 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 an immutable instance of [FileUploadParams]. + * Returns a mutable builder for constructing an instance of [FileUploadParams]. * - * Further updates to this [Builder] will not mutate the returned instance. + * The following fields are required: + * ```java + * .file() + * .fileName() + * ``` */ - fun build(): FileUploadParams = - FileUploadParams(body, additionalHeaders.build(), additionalQueryParams.build()) + @JvmStatic fun builder() = Builder() } - fun _body(): Map> = - (mapOf("body" to _body()) + - _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) - .toImmutable() + /** A builder for [FileUploadParams]. */ + class Builder internal constructor() { - override fun _headers(): Headers = additionalHeaders + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - override fun _queryParams(): QueryParams = additionalQueryParams + @JvmSynthetic + internal fun from(fileUploadParams: FileUploadParams) = apply { + body = fileUploadParams.body.toBuilder() + additionalHeaders = fileUploadParams.additionalHeaders.toBuilder() + additionalQueryParams = fileUploadParams.additionalQueryParams.toBuilder() + } - @JsonDeserialize(using = Body.Deserializer::class) - @JsonSerialize(using = Body.Serializer::class) - class Body - private constructor( - private val fileUploadV1: FileUploadV1? = null, - private val fileUploadByUrlv1: FileUploadByUrlv1? = null, - private val _json: JsonValue? = null, - ) { + /** + * 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: + * - [file] + * - [fileName] + * - [token] + * - [checks] + * - [customCoordinates] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } - fun fileUploadV1(): Optional = Optional.ofNullable(fileUploadV1) + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(file: InputStream) = apply { body.file(file) } - fun fileUploadByUrlv1(): Optional = - Optional.ofNullable(fileUploadByUrlv1) + /** + * Sets [Builder.file] to an arbitrary multipart value. + * + * You should usually call [Builder.file] with a well-typed [InputStream] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun file(file: MultipartField) = apply { body.file(file) } - fun isFileUploadV1(): Boolean = fileUploadV1 != null + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(file: ByteArray) = apply { body.file(file) } - fun isFileUploadByUrlv1(): Boolean = fileUploadByUrlv1 != null + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(path: Path) = apply { body.file(path) } - fun asFileUploadV1(): FileUploadV1 = fileUploadV1.getOrThrow("fileUploadV1") + /** + * The name with which the file has to be uploaded. The file name can contain: + * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + * - Special Characters: `.`, `-` + * + * Any other character including space will be replaced by `_` + */ + fun fileName(fileName: String) = apply { body.fileName(fileName) } - fun asFileUploadByUrlv1(): FileUploadByUrlv1 = - fileUploadByUrlv1.getOrThrow("fileUploadByUrlv1") + /** + * Sets [Builder.fileName] to an arbitrary multipart value. + * + * You should usually call [Builder.fileName] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fileName(fileName: MultipartField) = apply { body.fileName(fileName) } - fun _json(): Optional = Optional.ofNullable(_json) + /** + * A unique value that the ImageKit.io server will use to recognize and prevent subsequent + * retries for the same request. We suggest using V4 UUIDs, or another random string with + * enough entropy to avoid collisions. This field is only required for authentication when + * uploading a file from the client side. + * + * **Note**: Sending a value that has been used in the past will result in a validation + * error. Even if your previous request resulted in an error, you should always send a new + * value for this field. + */ + fun token(token: String) = apply { body.token(token) } - fun accept(visitor: Visitor): T = - when { - fileUploadV1 != null -> visitor.visitFileUploadV1(fileUploadV1) - fileUploadByUrlv1 != null -> visitor.visitFileUploadByUrlv1(fileUploadByUrlv1) - else -> visitor.unknown(_json) - } + /** + * Sets [Builder.token] to an arbitrary multipart value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: MultipartField) = apply { body.token(token) } - private var validated: Boolean = false + /** + * Server-side checks to run on the asset. Read more about + * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + */ + fun checks(checks: String) = apply { body.checks(checks) } - fun validate(): Body = apply { - if (validated) { - return@apply - } + /** + * Sets [Builder.checks] to an arbitrary multipart value. + * + * You should usually call [Builder.checks] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun checks(checks: MultipartField) = apply { body.checks(checks) } - accept( - object : Visitor { - override fun visitFileUploadV1(fileUploadV1: FileUploadV1) { - fileUploadV1.validate() - } + /** + * Define an important area in the image. This is only relevant for image type files. + * - To be passed as a string with the x and y coordinates of the top-left corner, and width + * and height of the area of interest in the format `x,y,width,height`. For example - + * `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates will + * be removed. + */ + fun customCoordinates(customCoordinates: String) = apply { + body.customCoordinates(customCoordinates) + } - override fun visitFileUploadByUrlv1(fileUploadByUrlv1: FileUploadByUrlv1) { - fileUploadByUrlv1.validate() - } - } - ) - validated = true + /** + * Sets [Builder.customCoordinates] to an arbitrary multipart value. + * + * You should usually call [Builder.customCoordinates] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customCoordinates(customCoordinates: MultipartField) = apply { + body.customCoordinates(customCoordinates) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields + * before setting these values. + */ + fun customMetadata(customMetadata: CustomMetadata) = apply { + body.customMetadata(customMetadata) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.customMetadata] to an arbitrary multipart value. * - * Used for best match union deserialization. + * You should usually call [Builder.customMetadata] with a well-typed [CustomMetadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitFileUploadV1(fileUploadV1: FileUploadV1) = - fileUploadV1.validity() + fun customMetadata(customMetadata: MultipartField) = apply { + body.customMetadata(customMetadata) + } - override fun visitFileUploadByUrlv1(fileUploadByUrlv1: FileUploadByUrlv1) = - fileUploadByUrlv1.validity() + /** Optional text to describe the contents of the file. */ + fun description(description: String) = apply { body.description(description) } - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * Sets [Builder.description] to an arbitrary multipart 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: MultipartField) = apply { + body.description(description) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The time until your signature is valid. It must be a + * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. + * It should be in seconds. This field is only required for authentication when uploading a + * file from the client side. + */ + fun expire(expire: Long) = apply { body.expire(expire) } - return other is Body && - fileUploadV1 == other.fileUploadV1 && - fileUploadByUrlv1 == other.fileUploadByUrlv1 - } + /** + * Sets [Builder.expire] to an arbitrary multipart value. + * + * You should usually call [Builder.expire] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun expire(expire: MultipartField) = apply { body.expire(expire) } - override fun hashCode(): Int = Objects.hash(fileUploadV1, fileUploadByUrlv1) + /** + * Array of extensions to be applied to the image. Each extension can be configured with + * specific parameters based on the extension type. + */ + fun extensions(extensions: List) = apply { body.extensions(extensions) } - override fun toString(): String = - when { - fileUploadV1 != null -> "Body{fileUploadV1=$fileUploadV1}" - fileUploadByUrlv1 != null -> "Body{fileUploadByUrlv1=$fileUploadByUrlv1}" - _json != null -> "Body{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Body") - } + /** + * Sets [Builder.extensions] to an arbitrary multipart value. + * + * You should usually call [Builder.extensions] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun extensions(extensions: MultipartField>) = apply { + body.extensions(extensions) + } - companion object { + /** + * Adds a single [Extension] to [extensions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExtension(extension: Extension) = apply { body.addExtension(extension) } - @JvmStatic - fun ofFileUploadV1(fileUploadV1: FileUploadV1) = Body(fileUploadV1 = fileUploadV1) + /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ + fun addExtension(removeBg: Extension.RemoveBg) = apply { body.addExtension(removeBg) } - @JvmStatic - fun ofFileUploadByUrlv1(fileUploadByUrlv1: FileUploadByUrlv1) = - Body(fileUploadByUrlv1 = fileUploadByUrlv1) + /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = apply { + body.addExtension(autoTagging) } - /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ - interface Visitor { + /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ + fun addExtensionAiAutoDescription() = apply { body.addExtensionAiAutoDescription() } - fun visitFileUploadV1(fileUploadV1: FileUploadV1): T + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't exist + * before, a new folder(s) is created. + * + * The folder name can contain: + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. + */ + fun folder(folder: String) = apply { body.folder(folder) } - fun visitFileUploadByUrlv1(fileUploadByUrlv1: FileUploadByUrlv1): T + /** + * Sets [Builder.folder] to an arbitrary multipart value. + * + * You should usually call [Builder.folder] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun folder(folder: MultipartField) = apply { body.folder(folder) } - /** - * Maps an unknown variant of [Body] to a value of type [T]. - * - * An instance of [Body] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Body: $json") - } + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named + * transformation or signed URL. + */ + fun isPrivateFile(isPrivateFile: Boolean) = apply { body.isPrivateFile(isPrivateFile) } + + /** + * Sets [Builder.isPrivateFile] to an arbitrary multipart value. + * + * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPrivateFile(isPrivateFile: MultipartField) = apply { + body.isPrivateFile(isPrivateFile) } - internal class Deserializer : BaseDeserializer(Body::class) { + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file only + * via the media library. Files in draft or unpublished state can only be publicly accessed + * after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing plans. + */ + fun isPublished(isPublished: Boolean) = apply { body.isPublished(isPublished) } - override fun ObjectCodec.deserialize(node: JsonNode): Body { - val json = JsonValue.fromJsonNode(node) + /** + * Sets [Builder.isPublished] to an arbitrary multipart value. + * + * You should usually call [Builder.isPublished] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isPublished(isPublished: MultipartField) = apply { + body.isPublished(isPublished) + } - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Body(fileUploadV1 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(fileUploadByUrlv1 = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from boolean). - 0 -> Body(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely - // valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } + /** + * If set to `true` and a file already exists at the exact location, its AITags will be + * removed. Set `overwriteAITags` to `false` to preserve AITags. + */ + fun overwriteAiTags(overwriteAiTags: Boolean) = apply { + body.overwriteAiTags(overwriteAiTags) } - internal class Serializer : BaseSerializer(Body::class) { + /** + * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteAiTags] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteAiTags(overwriteAiTags: MultipartField) = apply { + body.overwriteAiTags(overwriteAiTags) + } - override fun serialize( - value: Body, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.fileUploadV1 != null -> generator.writeObject(value.fileUploadV1) - value.fileUploadByUrlv1 != null -> - generator.writeObject(value.fileUploadByUrlv1) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Body") - } - } + /** + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: Boolean) = apply { + body.overwriteCustomMetadata(overwriteCustomMetadata) } - class FileUploadV1 - private constructor( - private val file: MultipartField, - private val fileName: MultipartField, - private val token: MultipartField, - private val checks: MultipartField, - private val customCoordinates: MultipartField, - private val customMetadata: MultipartField, - private val description: MultipartField, - private val expire: MultipartField, - private val extensions: MultipartField>, - private val folder: MultipartField, - private val isPrivateFile: MultipartField, - private val isPublished: MultipartField, - private val overwriteAiTags: MultipartField, - private val overwriteCustomMetadata: MultipartField, - private val overwriteFile: MultipartField, - private val overwriteTags: MultipartField, - private val publicKey: MultipartField, - private val responseFields: MultipartField>, - private val signature: MultipartField, - private val tags: MultipartField>, - private val transformation: MultipartField, - private val useUniqueFileName: MultipartField, - private val webhookUrl: MultipartField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteCustomMetadata] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: MultipartField) = apply { + body.overwriteCustomMetadata(overwriteCustomMetadata) + } - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 seconds; - * otherwise the request fails with 400 Bad Request. - * - * @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 file(): InputStream = file.value.getRequired("file") + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the + * exact location, upload API will return an error immediately. + */ + fun overwriteFile(overwriteFile: Boolean) = apply { body.overwriteFile(overwriteFile) } - /** - * The name with which the file has to be uploaded. The file name can contain: - * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - * - Special Characters: `.`, `-` - * - * Any other character including space will be replaced by `_` - * - * @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 fileName(): String = fileName.value.getRequired("fileName") - - /** - * A unique value that the ImageKit.io server will use to recognize and prevent - * subsequent retries for the same request. We suggest using V4 UUIDs, or another random - * string with enough entropy to avoid collisions. This field is only required for - * authentication when uploading a file from the client side. - * - * **Note**: Sending a value that has been used in the past will result in a validation - * error. Even if your previous request resulted in an error, you should always send a - * new value for this field. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun token(): Optional = token.value.getOptional("token") - - /** - * Server-side checks to run on the asset. Read more about - * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun checks(): Optional = checks.value.getOptional("checks") - - /** - * Define an important area in the image. This is only relevant for image type files. - * - To be passed as a string with the x and y coordinates of the top-left corner, and - * width and height of the area of interest in the format `x,y,width,height`. For - * example - `10,10,100,100` - * - Can be used with fo-customtransformation. - * - If this field is not specified and the file is overwritten, then customCoordinates - * will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun customCoordinates(): Optional = - customCoordinates.value.getOptional("customCoordinates") - - /** - * JSON key-value pairs to associate with the asset. Create the custom metadata fields - * before setting these values. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun customMetadata(): Optional = - customMetadata.value.getOptional("customMetadata") - - /** - * Optional text to describe the contents of the file. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun description(): Optional = description.value.getOptional("description") - - /** - * The time until your signature is valid. It must be a - * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the - * future. It should be in seconds. This field is only required for authentication when - * uploading a file from the client side. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun expire(): Optional = expire.value.getOptional("expire") - - /** - * Array of extensions to be applied to the image. Each extension can be configured with - * specific parameters based on the extension type. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun extensions(): Optional> = extensions.value.getOptional("extensions") - - /** - * The folder path in which the image has to be uploaded. If the folder(s) didn't exist - * before, a new folder(s) is created. - * - * The folder name can contain: - * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - * - Special Characters: `/` , `_` , `-` - * - * Using multiple `/` creates a nested folder. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun folder(): Optional = folder.value.getOptional("folder") - - /** - * Whether to mark the file as private or not. - * - * If `true`, the file is marked as private and is accessible only using named - * transformation or signed URL. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun isPrivateFile(): Optional = - isPrivateFile.value.getOptional("isPrivateFile") - - /** - * Whether to upload file as published or not. - * - * If `false`, the file is marked as unpublished, which restricts access to the file - * only via the media library. Files in draft or unpublished state can only be publicly - * accessed after being published. - * - * The option to upload in draft state is only available in custom enterprise pricing - * plans. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun isPublished(): Optional = isPublished.value.getOptional("isPublished") - - /** - * If set to `true` and a file already exists at the exact location, its AITags will be - * removed. Set `overwriteAITags` to `false` to preserve AITags. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun overwriteAiTags(): Optional = - overwriteAiTags.value.getOptional("overwriteAITags") - - /** - * If the request does not have `customMetadata`, and a file already exists at the exact - * location, existing customMetadata will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun overwriteCustomMetadata(): Optional = - overwriteCustomMetadata.value.getOptional("overwriteCustomMetadata") - - /** - * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the - * exact location, upload API will return an error immediately. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun overwriteFile(): Optional = - overwriteFile.value.getOptional("overwriteFile") - - /** - * If the request does not have `tags`, and a file already exists at the exact location, - * existing tags will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun overwriteTags(): Optional = - overwriteTags.value.getOptional("overwriteTags") - - /** - * Your ImageKit.io public key. This field is only required for authentication when - * uploading a file from the client side. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun publicKey(): Optional = publicKey.value.getOptional("publicKey") - - /** - * Array of response field keys to include in the API response body. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun responseFields(): Optional> = - responseFields.value.getOptional("responseFields") - - /** - * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. - * Learn how to create a signature on the page below. This should be in lowercase. - * - * Signature must be calculated on the server-side. This field is only required for - * authentication when uploading a file from the client side. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun signature(): Optional = signature.value.getOptional("signature") - - /** - * Set the tags while uploading the file. Provide an array of tag strings (e.g. - * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not - * exceed 500, and the `%` character is not allowed. If this field is not specified and - * the file is overwritten, the existing tags will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun tags(): Optional> = tags.value.getOptional("tags") - - /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for - * reducing file size or applying basic optimizations upfront (e.g., resize, - * compress). - * - `post` — applied immediately after upload. Ideal for generating transformed - * versions (like video encodes or thumbnails) in advance, so they're ready for - * delivery without delay. - * - * You can mix and match any combination of post-processing types. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun transformation(): Optional = - transformation.value.getOptional("transformation") - - /** - * Whether to use a unique filename for this file or not. - * - * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a - * unique filename. - * - * If `false`, then the image is uploaded with the provided filename parameter, and any - * existing file with the same name is replaced. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun useUniqueFileName(): Optional = - useUniqueFileName.value.getOptional("useUniqueFileName") - - /** - * The final status of extensions after they have completed execution will be delivered - * to this endpoint as a POST request. - * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - * about the webhook payload structure. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun webhookUrl(): Optional = webhookUrl.value.getOptional("webhookUrl") - - /** - * Returns the raw multipart value of [file]. - * - * Unlike [file], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField = file - - /** - * Returns the raw multipart value of [fileName]. - * - * Unlike [fileName], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("fileName") - @ExcludeMissing - fun _fileName(): MultipartField = fileName - - /** - * Returns the raw multipart value of [token]. - * - * Unlike [token], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("token") @ExcludeMissing fun _token(): MultipartField = token - - /** - * Returns the raw multipart value of [checks]. - * - * Unlike [checks], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("checks") @ExcludeMissing fun _checks(): MultipartField = checks - - /** - * Returns the raw multipart value of [customCoordinates]. - * - * Unlike [customCoordinates], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("customCoordinates") - @ExcludeMissing - fun _customCoordinates(): MultipartField = customCoordinates - - /** - * Returns the raw multipart value of [customMetadata]. - * - * Unlike [customMetadata], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("customMetadata") - @ExcludeMissing - fun _customMetadata(): MultipartField = customMetadata - - /** - * Returns the raw multipart value of [description]. - * - * Unlike [description], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): MultipartField = description - - /** - * Returns the raw multipart value of [expire]. - * - * Unlike [expire], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("expire") @ExcludeMissing fun _expire(): MultipartField = expire - - /** - * Returns the raw multipart value of [extensions]. - * - * Unlike [extensions], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("extensions") - @ExcludeMissing - fun _extensions(): MultipartField> = extensions - - /** - * Returns the raw multipart value of [folder]. - * - * Unlike [folder], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("folder") @ExcludeMissing fun _folder(): MultipartField = folder - - /** - * Returns the raw multipart value of [isPrivateFile]. - * - * Unlike [isPrivateFile], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("isPrivateFile") - @ExcludeMissing - fun _isPrivateFile(): MultipartField = isPrivateFile - - /** - * Returns the raw multipart value of [isPublished]. - * - * Unlike [isPublished], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("isPublished") - @ExcludeMissing - fun _isPublished(): MultipartField = isPublished - - /** - * Returns the raw multipart value of [overwriteAiTags]. - * - * Unlike [overwriteAiTags], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("overwriteAITags") - @ExcludeMissing - fun _overwriteAiTags(): MultipartField = overwriteAiTags - - /** - * Returns the raw multipart value of [overwriteCustomMetadata]. - * - * Unlike [overwriteCustomMetadata], this method doesn't throw if the multipart field - * has an unexpected type. - */ - @JsonProperty("overwriteCustomMetadata") - @ExcludeMissing - fun _overwriteCustomMetadata(): MultipartField = overwriteCustomMetadata - - /** - * Returns the raw multipart value of [overwriteFile]. - * - * Unlike [overwriteFile], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("overwriteFile") - @ExcludeMissing - fun _overwriteFile(): MultipartField = overwriteFile - - /** - * Returns the raw multipart value of [overwriteTags]. - * - * Unlike [overwriteTags], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("overwriteTags") - @ExcludeMissing - fun _overwriteTags(): MultipartField = overwriteTags - - /** - * Returns the raw multipart value of [publicKey]. - * - * Unlike [publicKey], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("publicKey") - @ExcludeMissing - fun _publicKey(): MultipartField = publicKey - - /** - * Returns the raw multipart value of [responseFields]. - * - * Unlike [responseFields], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("responseFields") - @ExcludeMissing - fun _responseFields(): MultipartField> = responseFields - - /** - * Returns the raw multipart value of [signature]. - * - * Unlike [signature], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("signature") - @ExcludeMissing - fun _signature(): MultipartField = signature - - /** - * Returns the raw multipart value of [tags]. - * - * Unlike [tags], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): MultipartField> = tags - - /** - * Returns the raw multipart value of [transformation]. - * - * Unlike [transformation], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("transformation") - @ExcludeMissing - fun _transformation(): MultipartField = transformation - - /** - * Returns the raw multipart value of [useUniqueFileName]. - * - * Unlike [useUniqueFileName], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("useUniqueFileName") - @ExcludeMissing - fun _useUniqueFileName(): MultipartField = useUniqueFileName - - /** - * Returns the raw multipart value of [webhookUrl]. - * - * Unlike [webhookUrl], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("webhookUrl") - @ExcludeMissing - fun _webhookUrl(): MultipartField = webhookUrl - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [FileUploadV1]. - * - * The following fields are required: - * ```java - * .file() - * .fileName() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FileUploadV1]. */ - class Builder internal constructor() { - - private var file: MultipartField? = null - private var fileName: MultipartField? = null - private var token: MultipartField = MultipartField.of(null) - private var checks: MultipartField = MultipartField.of(null) - private var customCoordinates: MultipartField = MultipartField.of(null) - private var customMetadata: MultipartField = MultipartField.of(null) - private var description: MultipartField = MultipartField.of(null) - private var expire: MultipartField = MultipartField.of(null) - private var extensions: MultipartField>? = null - private var folder: MultipartField = MultipartField.of(null) - private var isPrivateFile: MultipartField = MultipartField.of(null) - private var isPublished: MultipartField = MultipartField.of(null) - private var overwriteAiTags: MultipartField = MultipartField.of(null) - private var overwriteCustomMetadata: MultipartField = - MultipartField.of(null) - private var overwriteFile: MultipartField = MultipartField.of(null) - private var overwriteTags: MultipartField = MultipartField.of(null) - private var publicKey: MultipartField = MultipartField.of(null) - private var responseFields: MultipartField>? = null - private var signature: MultipartField = MultipartField.of(null) - private var tags: MultipartField>? = null - private var transformation: MultipartField = MultipartField.of(null) - private var useUniqueFileName: MultipartField = MultipartField.of(null) - private var webhookUrl: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fileUploadV1: FileUploadV1) = apply { - file = fileUploadV1.file - fileName = fileUploadV1.fileName - token = fileUploadV1.token - checks = fileUploadV1.checks - customCoordinates = fileUploadV1.customCoordinates - customMetadata = fileUploadV1.customMetadata - description = fileUploadV1.description - expire = fileUploadV1.expire - extensions = fileUploadV1.extensions.map { it.toMutableList() } - folder = fileUploadV1.folder - isPrivateFile = fileUploadV1.isPrivateFile - isPublished = fileUploadV1.isPublished - overwriteAiTags = fileUploadV1.overwriteAiTags - overwriteCustomMetadata = fileUploadV1.overwriteCustomMetadata - overwriteFile = fileUploadV1.overwriteFile - overwriteTags = fileUploadV1.overwriteTags - publicKey = fileUploadV1.publicKey - responseFields = fileUploadV1.responseFields.map { it.toMutableList() } - signature = fileUploadV1.signature - tags = fileUploadV1.tags.map { it.toMutableList() } - transformation = fileUploadV1.transformation - useUniqueFileName = fileUploadV1.useUniqueFileName - webhookUrl = fileUploadV1.webhookUrl - additionalProperties = fileUploadV1.additionalProperties.toMutableMap() - } - - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can - * fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 - * seconds; otherwise the request fails with 400 Bad Request. - */ - fun file(file: InputStream) = file(MultipartField.of(file)) - - /** - * Sets [Builder.file] to an arbitrary multipart value. - * - * You should usually call [Builder.file] with a well-typed [InputStream] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun file(file: MultipartField) = apply { this.file = file } - - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can - * fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 - * seconds; otherwise the request fails with 400 Bad Request. - */ - fun file(file: ByteArray) = file(file.inputStream()) - - /** - * The API accepts any of the following: - * - **Binary data** – send the raw bytes as `multipart/form-data`. - * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can - * fetch. - * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. - * - * When supplying a URL, the server must receive the response headers within 8 - * seconds; otherwise the request fails with 400 Bad Request. - */ - fun file(path: Path) = - file( - MultipartField.builder() - .value(path.inputStream()) - .filename(path.name) - .build() - ) - - /** - * The name with which the file has to be uploaded. The file name can contain: - * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - * - Special Characters: `.`, `-` - * - * Any other character including space will be replaced by `_` - */ - fun fileName(fileName: String) = fileName(MultipartField.of(fileName)) - - /** - * Sets [Builder.fileName] to an arbitrary multipart value. - * - * You should usually call [Builder.fileName] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun fileName(fileName: MultipartField) = apply { this.fileName = fileName } - - /** - * A unique value that the ImageKit.io server will use to recognize and prevent - * subsequent retries for the same request. We suggest using V4 UUIDs, or another - * random string with enough entropy to avoid collisions. This field is only - * required for authentication when uploading a file from the client side. - * - * **Note**: Sending a value that has been used in the past will result in a - * validation error. Even if your previous request resulted in an error, you should - * always send a new value for this field. - */ - fun token(token: String) = token(MultipartField.of(token)) - - /** - * Sets [Builder.token] to an arbitrary multipart value. - * - * You should usually call [Builder.token] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun token(token: MultipartField) = apply { this.token = token } - - /** - * Server-side checks to run on the asset. Read more about - * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). - */ - fun checks(checks: String) = checks(MultipartField.of(checks)) - - /** - * Sets [Builder.checks] to an arbitrary multipart value. - * - * You should usually call [Builder.checks] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun checks(checks: MultipartField) = apply { this.checks = checks } - - /** - * Define an important area in the image. This is only relevant for image type - * files. - * - To be passed as a string with the x and y coordinates of the top-left corner, - * and width and height of the area of interest in the format `x,y,width,height`. - * For example - `10,10,100,100` - * - Can be used with fo-customtransformation. - * - If this field is not specified and the file is overwritten, then - * customCoordinates will be removed. - */ - fun customCoordinates(customCoordinates: String) = - customCoordinates(MultipartField.of(customCoordinates)) - - /** - * Sets [Builder.customCoordinates] to an arbitrary multipart value. - * - * You should usually call [Builder.customCoordinates] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun customCoordinates(customCoordinates: MultipartField) = apply { - this.customCoordinates = customCoordinates - } - - /** - * JSON key-value pairs to associate with the asset. Create the custom metadata - * fields before setting these values. - */ - fun customMetadata(customMetadata: CustomMetadata) = - customMetadata(MultipartField.of(customMetadata)) - - /** - * Sets [Builder.customMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.customMetadata] with a well-typed - * [CustomMetadata] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun customMetadata(customMetadata: MultipartField) = apply { - this.customMetadata = customMetadata - } - - /** Optional text to describe the contents of the file. */ - fun description(description: String) = description(MultipartField.of(description)) - - /** - * Sets [Builder.description] to an arbitrary multipart 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: MultipartField) = apply { - this.description = description - } - - /** - * The time until your signature is valid. It must be a - * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the - * future. It should be in seconds. This field is only required for authentication - * when uploading a file from the client side. - */ - fun expire(expire: Long) = expire(MultipartField.of(expire)) - - /** - * Sets [Builder.expire] to an arbitrary multipart value. - * - * You should usually call [Builder.expire] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun expire(expire: MultipartField) = apply { this.expire = expire } - - /** - * Array of extensions to be applied to the image. Each extension can be configured - * with specific parameters based on the extension type. - */ - fun extensions(extensions: List) = - extensions(MultipartField.of(extensions)) - - /** - * Sets [Builder.extensions] to an arbitrary multipart value. - * - * You should usually call [Builder.extensions] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun extensions(extensions: MultipartField>) = apply { - this.extensions = extensions.map { it.toMutableList() } - } - - /** - * Adds a single [Extension] to [extensions]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addExtension(extension: Extension) = apply { - extensions = - (extensions ?: MultipartField.of(mutableListOf())).also { - checkKnown("extensions", it).add(extension) - } - } - - /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: Extension.RemoveBg) = - addExtension(Extension.ofRemoveBg(removeBg)) - - /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: Extension.AutoTaggingExtension) = - addExtension(Extension.ofAutoTagging(autoTagging)) - - /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ - fun addExtensionAiAutoDescription() = addExtension(Extension.ofAiAutoDescription()) - - /** - * The folder path in which the image has to be uploaded. If the folder(s) didn't - * exist before, a new folder(s) is created. - * - * The folder name can contain: - * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - * - Special Characters: `/` , `_` , `-` - * - * Using multiple `/` creates a nested folder. - */ - fun folder(folder: String) = folder(MultipartField.of(folder)) - - /** - * Sets [Builder.folder] to an arbitrary multipart value. - * - * You should usually call [Builder.folder] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun folder(folder: MultipartField) = apply { this.folder = folder } - - /** - * Whether to mark the file as private or not. - * - * If `true`, the file is marked as private and is accessible only using named - * transformation or signed URL. - */ - fun isPrivateFile(isPrivateFile: Boolean) = - isPrivateFile(MultipartField.of(isPrivateFile)) - - /** - * Sets [Builder.isPrivateFile] to an arbitrary multipart value. - * - * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun isPrivateFile(isPrivateFile: MultipartField) = apply { - this.isPrivateFile = isPrivateFile - } - - /** - * Whether to upload file as published or not. - * - * If `false`, the file is marked as unpublished, which restricts access to the file - * only via the media library. Files in draft or unpublished state can only be - * publicly accessed after being published. - * - * The option to upload in draft state is only available in custom enterprise - * pricing plans. - */ - fun isPublished(isPublished: Boolean) = isPublished(MultipartField.of(isPublished)) - - /** - * Sets [Builder.isPublished] to an arbitrary multipart value. - * - * You should usually call [Builder.isPublished] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun isPublished(isPublished: MultipartField) = apply { - this.isPublished = isPublished - } - - /** - * If set to `true` and a file already exists at the exact location, its AITags will - * be removed. Set `overwriteAITags` to `false` to preserve AITags. - */ - fun overwriteAiTags(overwriteAiTags: Boolean) = - overwriteAiTags(MultipartField.of(overwriteAiTags)) - - /** - * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteAiTags] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun overwriteAiTags(overwriteAiTags: MultipartField) = apply { - this.overwriteAiTags = overwriteAiTags - } - - /** - * If the request does not have `customMetadata`, and a file already exists at the - * exact location, existing customMetadata will be removed. - */ - fun overwriteCustomMetadata(overwriteCustomMetadata: Boolean) = - overwriteCustomMetadata(MultipartField.of(overwriteCustomMetadata)) - - /** - * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteCustomMetadata] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun overwriteCustomMetadata(overwriteCustomMetadata: MultipartField) = - apply { - this.overwriteCustomMetadata = overwriteCustomMetadata - } - - /** - * If `false` and `useUniqueFileName` is also `false`, and a file already exists at - * the exact location, upload API will return an error immediately. - */ - fun overwriteFile(overwriteFile: Boolean) = - overwriteFile(MultipartField.of(overwriteFile)) - - /** - * Sets [Builder.overwriteFile] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteFile] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun overwriteFile(overwriteFile: MultipartField) = apply { - this.overwriteFile = overwriteFile - } - - /** - * If the request does not have `tags`, and a file already exists at the exact - * location, existing tags will be removed. - */ - fun overwriteTags(overwriteTags: Boolean) = - overwriteTags(MultipartField.of(overwriteTags)) - - /** - * Sets [Builder.overwriteTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteTags] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun overwriteTags(overwriteTags: MultipartField) = apply { - this.overwriteTags = overwriteTags - } - - /** - * Your ImageKit.io public key. This field is only required for authentication when - * uploading a file from the client side. - */ - fun publicKey(publicKey: String) = publicKey(MultipartField.of(publicKey)) - - /** - * Sets [Builder.publicKey] to an arbitrary multipart value. - * - * You should usually call [Builder.publicKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun publicKey(publicKey: MultipartField) = apply { - this.publicKey = publicKey - } - - /** Array of response field keys to include in the API response body. */ - fun responseFields(responseFields: List) = - responseFields(MultipartField.of(responseFields)) - - /** - * Sets [Builder.responseFields] to an arbitrary multipart value. - * - * You should usually call [Builder.responseFields] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun responseFields(responseFields: MultipartField>) = apply { - this.responseFields = responseFields.map { it.toMutableList() } - } - - /** - * Adds a single [ResponseField] to [responseFields]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addResponseField(responseField: ResponseField) = apply { - responseFields = - (responseFields ?: MultipartField.of(mutableListOf())).also { - checkKnown("responseFields", it).add(responseField) - } - } - - /** - * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a - * key. Learn how to create a signature on the page below. This should be in - * lowercase. - * - * Signature must be calculated on the server-side. This field is only required for - * authentication when uploading a file from the client side. - */ - fun signature(signature: String) = signature(MultipartField.of(signature)) - - /** - * Sets [Builder.signature] to an arbitrary multipart value. - * - * You should usually call [Builder.signature] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun signature(signature: MultipartField) = apply { - this.signature = signature - } - - /** - * Set the tags while uploading the file. Provide an array of tag strings (e.g. - * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not - * exceed 500, and the `%` character is not allowed. If this field is not specified - * and the file is overwritten, the existing tags will be removed. - */ - fun tags(tags: List) = tags(MultipartField.of(tags)) - - /** - * Sets [Builder.tags] to an arbitrary multipart value. - * - * You should usually call [Builder.tags] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun tags(tags: MultipartField>) = apply { - this.tags = tags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [tags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTag(tag: String) = apply { - tags = - (tags ?: MultipartField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } - - /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for - * reducing file size or applying basic optimizations upfront (e.g., resize, - * compress). - * - `post` — applied immediately after upload. Ideal for generating transformed - * versions (like video encodes or thumbnails) in advance, so they're ready for - * delivery without delay. - * - * You can mix and match any combination of post-processing types. - */ - fun transformation(transformation: Transformation) = - transformation(MultipartField.of(transformation)) - - /** - * Sets [Builder.transformation] to an arbitrary multipart value. - * - * You should usually call [Builder.transformation] with a well-typed - * [Transformation] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun transformation(transformation: MultipartField) = apply { - this.transformation = transformation - } - - /** - * Whether to use a unique filename for this file or not. - * - * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get - * a unique filename. - * - * If `false`, then the image is uploaded with the provided filename parameter, and - * any existing file with the same name is replaced. - */ - fun useUniqueFileName(useUniqueFileName: Boolean) = - useUniqueFileName(MultipartField.of(useUniqueFileName)) - - /** - * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. - * - * You should usually call [Builder.useUniqueFileName] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun useUniqueFileName(useUniqueFileName: MultipartField) = apply { - this.useUniqueFileName = useUniqueFileName - } - - /** - * The final status of extensions after they have completed execution will be - * delivered to this endpoint as a POST request. - * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - * about the webhook payload structure. - */ - fun webhookUrl(webhookUrl: String) = webhookUrl(MultipartField.of(webhookUrl)) - - /** - * Sets [Builder.webhookUrl] to an arbitrary multipart value. - * - * You should usually call [Builder.webhookUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun webhookUrl(webhookUrl: MultipartField) = apply { - this.webhookUrl = webhookUrl - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [FileUploadV1]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .file() - * .fileName() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): FileUploadV1 = - FileUploadV1( - checkRequired("file", file), - checkRequired("fileName", fileName), - token, - checks, - customCoordinates, - customMetadata, - description, - expire, - (extensions ?: MultipartField.of(null)).map { it.toImmutable() }, - folder, - isPrivateFile, - isPublished, - overwriteAiTags, - overwriteCustomMetadata, - overwriteFile, - overwriteTags, - publicKey, - (responseFields ?: MultipartField.of(null)).map { it.toImmutable() }, - signature, - (tags ?: MultipartField.of(null)).map { it.toImmutable() }, - transformation, - useUniqueFileName, - webhookUrl, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): FileUploadV1 = apply { - if (validated) { - return@apply - } - - file() - fileName() - token() - checks() - customCoordinates() - customMetadata().ifPresent { it.validate() } - description() - expire() - extensions().ifPresent { it.forEach { it.validate() } } - folder() - isPrivateFile() - isPublished() - overwriteAiTags() - overwriteCustomMetadata() - overwriteFile() - overwriteTags() - publicKey() - responseFields().ifPresent { it.forEach { it.validate() } } - signature() - tags() - transformation().ifPresent { it.validate() } - useUniqueFileName() - webhookUrl() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * JSON key-value pairs to associate with the asset. Create the custom metadata fields - * before setting these values. - */ - class CustomMetadata - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [CustomMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customMetadata: CustomMetadata) = apply { - additionalProperties = customMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [CustomMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): CustomMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CustomMetadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CustomMetadata{additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = Extension.Deserializer::class) - @JsonSerialize(using = Extension.Serializer::class) - class Extension - private constructor( - private val removeBg: RemoveBg? = null, - private val autoTagging: AutoTaggingExtension? = null, - private val aiAutoDescription: JsonValue? = null, - private val _json: JsonValue? = null, - ) { - - fun removeBg(): Optional = Optional.ofNullable(removeBg) - - fun autoTagging(): Optional = Optional.ofNullable(autoTagging) - - fun aiAutoDescription(): Optional = - Optional.ofNullable(aiAutoDescription) - - fun isRemoveBg(): Boolean = removeBg != null - - fun isAutoTagging(): Boolean = autoTagging != null - - fun isAiAutoDescription(): Boolean = aiAutoDescription != null - - fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") - - fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") - - fun asAiAutoDescription(): JsonValue = - aiAutoDescription.getOrThrow("aiAutoDescription") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - removeBg != null -> visitor.visitRemoveBg(removeBg) - autoTagging != null -> visitor.visitAutoTagging(autoTagging) - aiAutoDescription != null -> - visitor.visitAiAutoDescription(aiAutoDescription) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Extension = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitRemoveBg(removeBg: RemoveBg) { - removeBg.validate() - } - - override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { - autoTagging.validate() - } - - override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { - aiAutoDescription.let { - if ( - it != JsonValue.from(mapOf("name" to "ai-auto-description")) - ) { - throw ImageKitInvalidDataException( - "'aiAutoDescription' is invalid, received $it" - ) - } - } - } - } - ) - 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 = - accept( - object : Visitor { - override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() - - override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = - autoTagging.validity() - - override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = - aiAutoDescription.let { - if ( - it == JsonValue.from(mapOf("name" to "ai-auto-description")) - ) - 1 - else 0 - } - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Extension && - removeBg == other.removeBg && - autoTagging == other.autoTagging && - aiAutoDescription == other.aiAutoDescription - } - - override fun hashCode(): Int = - Objects.hash(removeBg, autoTagging, aiAutoDescription) - - override fun toString(): String = - when { - removeBg != null -> "Extension{removeBg=$removeBg}" - autoTagging != null -> "Extension{autoTagging=$autoTagging}" - aiAutoDescription != null -> - "Extension{aiAutoDescription=$aiAutoDescription}" - _json != null -> "Extension{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Extension") - } - - companion object { - - @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = Extension(removeBg = removeBg) - - @JvmStatic - fun ofAutoTagging(autoTagging: AutoTaggingExtension) = - Extension(autoTagging = autoTagging) - - @JvmStatic - fun ofAiAutoDescription() = - Extension( - aiAutoDescription = - JsonValue.from(mapOf("name" to "ai-auto-description")) - ) - } - - /** - * An interface that defines how to map each variant of [Extension] to a value of - * type [T]. - */ - interface Visitor { - - fun visitRemoveBg(removeBg: RemoveBg): T - - fun visitAutoTagging(autoTagging: AutoTaggingExtension): T - - fun visitAiAutoDescription(aiAutoDescription: JsonValue): T - - /** - * Maps an unknown variant of [Extension] to a value of type [T]. - * - * An instance of [Extension] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Extension: $json") - } - } - - internal class Deserializer : BaseDeserializer(Extension::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Extension { - val json = JsonValue.fromJsonNode(node) - val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() - - when (name) { - "remove-bg" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Extension(removeBg = it, _json = json) - } ?: Extension(_json = json) - } - "ai-auto-description" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Extension(aiAutoDescription = it, _json = json) } - ?.takeIf { it.isValid() } ?: Extension(_json = json) - } - } - - return tryDeserialize(node, jacksonTypeRef())?.let { - Extension(autoTagging = it, _json = json) - } ?: Extension(_json = json) - } - } - - internal class Serializer : BaseSerializer(Extension::class) { - - override fun serialize( - value: Extension, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.removeBg != null -> generator.writeObject(value.removeBg) - value.autoTagging != null -> generator.writeObject(value.autoTagging) - value.aiAutoDescription != null -> - generator.writeObject(value.aiAutoDescription) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Extension") - } - } - } - - class RemoveBg - private constructor( - private val name: JsonValue, - private val options: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Specifies the background removal extension. - * - * Expected to always return the following: - * ```java - * JsonValue.from("remove-bg") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun options(): Optional = options.value.getOptional("options") - - /** - * Returns the raw multipart value of [options]. - * - * Unlike [options], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("options") - @ExcludeMissing - fun _options(): MultipartField = options - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RemoveBg]. */ - class Builder internal constructor() { - - private var name: JsonValue = JsonValue.from("remove-bg") - private var options: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(removeBg: RemoveBg) = apply { - name = removeBg.name - options = removeBg.options - additionalProperties = removeBg.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults - * to the following: - * ```java - * JsonValue.from("remove-bg") - * ``` - * - * This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun name(name: JsonValue) = apply { this.name = name } - - fun options(options: Options) = options(MultipartField.of(options)) - - /** - * Sets [Builder.options] to an arbitrary multipart value. - * - * You should usually call [Builder.options] with a well-typed [Options] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun options(options: MultipartField) = apply { - this.options = options - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [RemoveBg]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemoveBg = - RemoveBg(name, options, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): RemoveBg = apply { - if (validated) { - return@apply - } - - _name().let { - if (it != JsonValue.from("remove-bg")) { - throw ImageKitInvalidDataException( - "'name' is invalid, received $it" - ) - } - } - options().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - class Options - private constructor( - private val addShadow: MultipartField, - private val bgColor: MultipartField, - private val bgImageUrl: MultipartField, - private val semitransparency: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Whether to add an artificial shadow to the result. Default is false. - * Note: Adding shadows is currently only supported for car photos. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun addShadow(): Optional = - addShadow.value.getOptional("add_shadow") - - /** - * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") - * or color name (e.g., "green"). If this parameter is set, `bg_image_url` - * must be empty. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun bgColor(): Optional = bgColor.value.getOptional("bg_color") - - /** - * Sets a background image from a URL. If this parameter is set, `bg_color` - * must be empty. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun bgImageUrl(): Optional = - bgImageUrl.value.getOptional("bg_image_url") - - /** - * Allows semi-transparent regions in the result. Default is true. Note: - * Semitransparency is currently only supported for car windows. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun semitransparency(): Optional = - semitransparency.value.getOptional("semitransparency") - - /** - * Returns the raw multipart value of [addShadow]. - * - * Unlike [addShadow], this method doesn't throw if the multipart field has - * an unexpected type. - */ - @JsonProperty("add_shadow") - @ExcludeMissing - fun _addShadow(): MultipartField = addShadow - - /** - * Returns the raw multipart value of [bgColor]. - * - * Unlike [bgColor], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("bg_color") - @ExcludeMissing - fun _bgColor(): MultipartField = bgColor - - /** - * Returns the raw multipart value of [bgImageUrl]. - * - * Unlike [bgImageUrl], this method doesn't throw if the multipart field has - * an unexpected type. - */ - @JsonProperty("bg_image_url") - @ExcludeMissing - fun _bgImageUrl(): MultipartField = bgImageUrl - - /** - * Returns the raw multipart value of [semitransparency]. - * - * Unlike [semitransparency], this method doesn't throw if the multipart - * field has an unexpected type. - */ - @JsonProperty("semitransparency") - @ExcludeMissing - fun _semitransparency(): MultipartField = semitransparency - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Options]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Options]. */ - class Builder internal constructor() { - - private var addShadow: MultipartField = MultipartField.of(null) - private var bgColor: MultipartField = MultipartField.of(null) - private var bgImageUrl: MultipartField = MultipartField.of(null) - private var semitransparency: MultipartField = - MultipartField.of(null) - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(options: Options) = apply { - addShadow = options.addShadow - bgColor = options.bgColor - bgImageUrl = options.bgImageUrl - semitransparency = options.semitransparency - additionalProperties = options.additionalProperties.toMutableMap() - } - - /** - * Whether to add an artificial shadow to the result. Default is false. - * Note: Adding shadows is currently only supported for car photos. - */ - fun addShadow(addShadow: Boolean) = - addShadow(MultipartField.of(addShadow)) - - /** - * Sets [Builder.addShadow] to an arbitrary multipart value. - * - * You should usually call [Builder.addShadow] with a well-typed - * [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun addShadow(addShadow: MultipartField) = apply { - this.addShadow = addShadow - } - - /** - * Specifies a solid color background using hex code (e.g., "81d4fa", - * "fff") or color name (e.g., "green"). If this parameter is set, - * `bg_image_url` must be empty. - */ - fun bgColor(bgColor: String) = bgColor(MultipartField.of(bgColor)) - - /** - * Sets [Builder.bgColor] to an arbitrary multipart value. - * - * You should usually call [Builder.bgColor] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun bgColor(bgColor: MultipartField) = apply { - this.bgColor = bgColor - } - - /** - * Sets a background image from a URL. If this parameter is set, - * `bg_color` must be empty. - */ - fun bgImageUrl(bgImageUrl: String) = - bgImageUrl(MultipartField.of(bgImageUrl)) - - /** - * Sets [Builder.bgImageUrl] to an arbitrary multipart value. - * - * You should usually call [Builder.bgImageUrl] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun bgImageUrl(bgImageUrl: MultipartField) = apply { - this.bgImageUrl = bgImageUrl - } - - /** - * Allows semi-transparent regions in the result. Default is true. Note: - * Semitransparency is currently only supported for car windows. - */ - fun semitransparency(semitransparency: Boolean) = - semitransparency(MultipartField.of(semitransparency)) - - /** - * Sets [Builder.semitransparency] to an arbitrary multipart value. - * - * You should usually call [Builder.semitransparency] with a well-typed - * [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun semitransparency(semitransparency: MultipartField) = - apply { - this.semitransparency = semitransparency - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Options]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): Options = - Options( - addShadow, - bgColor, - bgImageUrl, - semitransparency, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Options = apply { - if (validated) { - return@apply - } - - addShadow() - bgColor() - bgImageUrl() - semitransparency() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - addShadow == other.addShadow && - bgColor == other.bgColor && - bgImageUrl == other.bgImageUrl && - semitransparency == other.semitransparency && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - addShadow, - bgColor, - bgImageUrl, - semitransparency, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemoveBg && - name == other.name && - options == other.options && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(name, options, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" - } - - class AutoTaggingExtension - private constructor( - private val maxTags: MultipartField, - private val minConfidence: MultipartField, - private val name: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Maximum number of tags to attach to the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun maxTags(): Long = maxTags.value.getRequired("maxTags") - - /** - * Minimum confidence level for tags to be considered valid. - * - * @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 minConfidence(): Long = minConfidence.value.getRequired("minConfidence") - - /** - * Specifies the auto-tagging extension used. - * - * @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(): Name = name.value.getRequired("name") - - /** - * Returns the raw multipart value of [maxTags]. - * - * Unlike [maxTags], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("maxTags") - @ExcludeMissing - fun _maxTags(): MultipartField = maxTags - - /** - * Returns the raw multipart value of [minConfidence]. - * - * Unlike [minConfidence], this method doesn't throw if the multipart field has - * an unexpected type. - */ - @JsonProperty("minConfidence") - @ExcludeMissing - fun _minConfidence(): MultipartField = minConfidence - - /** - * Returns the raw multipart value of [name]. - * - * Unlike [name], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AutoTaggingExtension]. - * - * The following fields are required: - * ```java - * .maxTags() - * .minConfidence() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutoTaggingExtension]. */ - class Builder internal constructor() { - - private var maxTags: MultipartField? = null - private var minConfidence: MultipartField? = null - private var name: MultipartField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { - maxTags = autoTaggingExtension.maxTags - minConfidence = autoTaggingExtension.minConfidence - name = autoTaggingExtension.name - additionalProperties = - autoTaggingExtension.additionalProperties.toMutableMap() - } - - /** Maximum number of tags to attach to the asset. */ - fun maxTags(maxTags: Long) = maxTags(MultipartField.of(maxTags)) - - /** - * Sets [Builder.maxTags] to an arbitrary multipart value. - * - * You should usually call [Builder.maxTags] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun maxTags(maxTags: MultipartField) = apply { - this.maxTags = maxTags - } - - /** Minimum confidence level for tags to be considered valid. */ - fun minConfidence(minConfidence: Long) = - minConfidence(MultipartField.of(minConfidence)) - - /** - * Sets [Builder.minConfidence] to an arbitrary multipart value. - * - * You should usually call [Builder.minConfidence] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun minConfidence(minConfidence: MultipartField) = apply { - this.minConfidence = minConfidence - } - - /** Specifies the auto-tagging extension used. */ - fun name(name: Name) = name(MultipartField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary multipart value. - * - * You should usually call [Builder.name] with a well-typed [Name] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun name(name: MultipartField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AutoTaggingExtension]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .maxTags() - * .minConfidence() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AutoTaggingExtension = - AutoTaggingExtension( - checkRequired("maxTags", maxTags), - checkRequired("minConfidence", minConfidence), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutoTaggingExtension = apply { - if (validated) { - return@apply - } - - maxTags() - minConfidence() - name().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** Specifies the auto-tagging extension used. */ - class Name - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") - - @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") - - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } - - /** An enum containing [Name]'s known values. */ - enum class Known { - GOOGLE_AUTO_TAGGING, - AWS_AUTO_TAGGING, - } - - /** - * An enum containing [Name]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Name] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GOOGLE_AUTO_TAGGING, - AWS_AUTO_TAGGING, - /** - * An enum member indicating that [Name] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING - AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value is a - * not a known member. - */ - fun known(): Known = - when (this) { - GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING - AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING - else -> throw ImageKitInvalidDataException("Unknown Name: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value does - * not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Name = apply { - if (validated) { - return@apply - } - - known() - 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 (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Name && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AutoTaggingExtension && - maxTags == other.maxTags && - minConfidence == other.minConfidence && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(maxTags, minConfidence, name, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" - } - } - - class ResponseField - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TAGS = of("tags") - - @JvmField val CUSTOM_COORDINATES = of("customCoordinates") - - @JvmField val IS_PRIVATE_FILE = of("isPrivateFile") - - @JvmField val EMBEDDED_METADATA = of("embeddedMetadata") - - @JvmField val IS_PUBLISHED = of("isPublished") - - @JvmField val CUSTOM_METADATA = of("customMetadata") - - @JvmField val METADATA = of("metadata") - - @JvmStatic fun of(value: String) = ResponseField(JsonField.of(value)) - } - - /** An enum containing [ResponseField]'s known values. */ - enum class Known { - TAGS, - CUSTOM_COORDINATES, - IS_PRIVATE_FILE, - EMBEDDED_METADATA, - IS_PUBLISHED, - CUSTOM_METADATA, - METADATA, - } - - /** - * An enum containing [ResponseField]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ResponseField] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TAGS, - CUSTOM_COORDINATES, - IS_PRIVATE_FILE, - EMBEDDED_METADATA, - IS_PUBLISHED, - CUSTOM_METADATA, - METADATA, - /** - * An enum member indicating that [ResponseField] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TAGS -> Value.TAGS - CUSTOM_COORDINATES -> Value.CUSTOM_COORDINATES - IS_PRIVATE_FILE -> Value.IS_PRIVATE_FILE - EMBEDDED_METADATA -> Value.EMBEDDED_METADATA - IS_PUBLISHED -> Value.IS_PUBLISHED - CUSTOM_METADATA -> Value.CUSTOM_METADATA - METADATA -> Value.METADATA - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TAGS -> Known.TAGS - CUSTOM_COORDINATES -> Known.CUSTOM_COORDINATES - IS_PRIVATE_FILE -> Known.IS_PRIVATE_FILE - EMBEDDED_METADATA -> Known.EMBEDDED_METADATA - IS_PUBLISHED -> Known.IS_PUBLISHED - CUSTOM_METADATA -> Known.CUSTOM_METADATA - METADATA -> Known.METADATA - else -> throw ImageKitInvalidDataException("Unknown ResponseField: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): ResponseField = apply { - if (validated) { - return@apply - } - - known() - 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 (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ResponseField && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for - * reducing file size or applying basic optimizations upfront (e.g., resize, - * compress). - * - `post` — applied immediately after upload. Ideal for generating transformed - * versions (like video encodes or thumbnails) in advance, so they're ready for - * delivery without delay. - * - * You can mix and match any combination of post-processing types. - */ - class Transformation - private constructor( - private val post: MultipartField>, - private val pre: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * List of transformations to apply _after_ the file is uploaded. Each item must - * match one of the following types: `transformation`, `gif-to-video`, `thumbnail`, - * `abs`. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun post(): Optional> = post.value.getOptional("post") - - /** - * Transformation string to apply before uploading the file to the Media Library. - * Useful for optimizing files at ingestion. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun pre(): Optional = pre.value.getOptional("pre") - - /** - * Returns the raw multipart value of [post]. - * - * Unlike [post], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("post") @ExcludeMissing fun _post(): MultipartField> = post - - /** - * Returns the raw multipart value of [pre]. - * - * Unlike [pre], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("pre") @ExcludeMissing fun _pre(): MultipartField = pre - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Transformation]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Transformation]. */ - class Builder internal constructor() { - - private var post: MultipartField>? = null - private var pre: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(transformation: Transformation) = apply { - post = transformation.post.map { it.toMutableList() } - pre = transformation.pre - additionalProperties = transformation.additionalProperties.toMutableMap() - } - - /** - * List of transformations to apply _after_ the file is uploaded. Each item must - * match one of the following types: `transformation`, `gif-to-video`, - * `thumbnail`, `abs`. - */ - fun post(post: List) = post(MultipartField.of(post)) - - /** - * Sets [Builder.post] to an arbitrary multipart value. - * - * You should usually call [Builder.post] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun post(post: MultipartField>) = apply { - this.post = post.map { it.toMutableList() } - } - - /** - * Adds a single [Post] to [Builder.post]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPost(post: Post) = apply { - this.post = - (this.post ?: MultipartField.of(mutableListOf())).also { - checkKnown("post", it).add(post) - } - } - - /** Alias for calling [addPost] with `Post.ofTransformation(transformation)`. */ - fun addPost(transformation: Post.InnerTransformation) = - addPost(Post.ofTransformation(transformation)) - - /** - * Alias for calling [addPost] with the following: - * ```java - * Post.InnerTransformation.builder() - * .value(value) - * .build() - * ``` - */ - fun addTransformationPost(value: String) = - addPost(Post.InnerTransformation.builder().value(value).build()) - - /** Alias for calling [addPost] with `Post.ofGifToVideo(gifToVideo)`. */ - fun addPost(gifToVideo: Post.GifToVideo) = - addPost(Post.ofGifToVideo(gifToVideo)) - - /** Alias for calling [addPost] with `Post.ofThumbnail(thumbnail)`. */ - fun addPost(thumbnail: Post.Thumbnail) = addPost(Post.ofThumbnail(thumbnail)) - - /** Alias for calling [addPost] with `Post.ofAbs(abs)`. */ - fun addPost(abs: Post.Abs) = addPost(Post.ofAbs(abs)) - - /** - * Transformation string to apply before uploading the file to the Media - * Library. Useful for optimizing files at ingestion. - */ - fun pre(pre: String) = pre(MultipartField.of(pre)) - - /** - * Sets [Builder.pre] to an arbitrary multipart value. - * - * You should usually call [Builder.pre] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun pre(pre: MultipartField) = apply { this.pre = pre } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Transformation]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Transformation = - Transformation( - (post ?: MultipartField.of(null)).map { it.toImmutable() }, - pre, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Transformation = apply { - if (validated) { - return@apply - } - - post().ifPresent { it.forEach { it.validate() } } - pre() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - @JsonDeserialize(using = Post.Deserializer::class) - @JsonSerialize(using = Post.Serializer::class) - class Post - private constructor( - private val transformation: InnerTransformation? = null, - private val gifToVideo: GifToVideo? = null, - private val thumbnail: Thumbnail? = null, - private val abs: Abs? = null, - private val _json: JsonValue? = null, - ) { - - fun transformation(): Optional = - Optional.ofNullable(transformation) - - fun gifToVideo(): Optional = Optional.ofNullable(gifToVideo) - - fun thumbnail(): Optional = Optional.ofNullable(thumbnail) - - fun abs(): Optional = Optional.ofNullable(abs) - - fun isTransformation(): Boolean = transformation != null - - fun isGifToVideo(): Boolean = gifToVideo != null - - fun isThumbnail(): Boolean = thumbnail != null - - fun isAbs(): Boolean = abs != null - - fun asTransformation(): InnerTransformation = - transformation.getOrThrow("transformation") - - fun asGifToVideo(): GifToVideo = gifToVideo.getOrThrow("gifToVideo") - - fun asThumbnail(): Thumbnail = thumbnail.getOrThrow("thumbnail") - - fun asAbs(): Abs = abs.getOrThrow("abs") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - transformation != null -> visitor.visitTransformation(transformation) - gifToVideo != null -> visitor.visitGifToVideo(gifToVideo) - thumbnail != null -> visitor.visitThumbnail(thumbnail) - abs != null -> visitor.visitAbs(abs) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Post = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitTransformation( - transformation: InnerTransformation - ) { - transformation.validate() - } - - override fun visitGifToVideo(gifToVideo: GifToVideo) { - gifToVideo.validate() - } - - override fun visitThumbnail(thumbnail: Thumbnail) { - thumbnail.validate() - } - - override fun visitAbs(abs: Abs) { - abs.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitTransformation( - transformation: InnerTransformation - ) = transformation.validity() - - override fun visitGifToVideo(gifToVideo: GifToVideo) = - gifToVideo.validity() - - override fun visitThumbnail(thumbnail: Thumbnail) = - thumbnail.validity() - - override fun visitAbs(abs: Abs) = abs.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Post && - transformation == other.transformation && - gifToVideo == other.gifToVideo && - thumbnail == other.thumbnail && - abs == other.abs - } - - override fun hashCode(): Int = - Objects.hash(transformation, gifToVideo, thumbnail, abs) - - override fun toString(): String = - when { - transformation != null -> "Post{transformation=$transformation}" - gifToVideo != null -> "Post{gifToVideo=$gifToVideo}" - thumbnail != null -> "Post{thumbnail=$thumbnail}" - abs != null -> "Post{abs=$abs}" - _json != null -> "Post{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Post") - } - - companion object { - - @JvmStatic - fun ofTransformation(transformation: InnerTransformation) = - Post(transformation = transformation) - - @JvmStatic - fun ofGifToVideo(gifToVideo: GifToVideo) = Post(gifToVideo = gifToVideo) - - @JvmStatic - fun ofThumbnail(thumbnail: Thumbnail) = Post(thumbnail = thumbnail) - - @JvmStatic fun ofAbs(abs: Abs) = Post(abs = abs) - } - - /** - * An interface that defines how to map each variant of [Post] to a value of - * type [T]. - */ - interface Visitor { - - fun visitTransformation(transformation: InnerTransformation): T - - fun visitGifToVideo(gifToVideo: GifToVideo): T - - fun visitThumbnail(thumbnail: Thumbnail): T - - fun visitAbs(abs: Abs): T - - /** - * Maps an unknown variant of [Post] to a value of type [T]. - * - * An instance of [Post] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, - * if the SDK is on an older version than the API, then the API may respond - * with new variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Post: $json") - } - } - - internal class Deserializer : BaseDeserializer(Post::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Post { - val json = JsonValue.fromJsonNode(node) - val type = - json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - - when (type) { - "transformation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Post(transformation = it, _json = json) } - ?: Post(_json = json) - } - "gif-to-video" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(gifToVideo = it, _json = json) - } ?: Post(_json = json) - } - "thumbnail" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(thumbnail = it, _json = json) - } ?: Post(_json = json) - } - "abs" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(abs = it, _json = json) - } ?: Post(_json = json) - } - } - - return Post(_json = json) - } - } - - internal class Serializer : BaseSerializer(Post::class) { - - override fun serialize( - value: Post, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.transformation != null -> - generator.writeObject(value.transformation) - value.gifToVideo != null -> generator.writeObject(value.gifToVideo) - value.thumbnail != null -> generator.writeObject(value.thumbnail) - value.abs != null -> generator.writeObject(value.abs) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Post") - } - } - } - - class InnerTransformation - private constructor( - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Transformation type. - * - * Expected to always return the following: - * ```java - * JsonValue.from("transformation") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit - * URL-based 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 value(): String = value.value.getRequired("value") - - /** - * Returns the raw multipart value of [value]. - * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): MultipartField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InnerTransformation]. - * - * The following fields are required: - * ```java - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerTransformation]. */ - class Builder internal constructor() { - - private var type: JsonValue = JsonValue.from("transformation") - private var value: MultipartField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerTransformation: InnerTransformation) = apply { - type = innerTransformation.type - value = innerTransformation.value - additionalProperties = - innerTransformation.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field - * defaults to the following: - * ```java - * JsonValue.from("transformation") - * ``` - * - * This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** - * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit - * URL-based transformations. - */ - fun value(value: String) = value(MultipartField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun value(value: MultipartField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InnerTransformation]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): InnerTransformation = - InnerTransformation( - type, - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false + /** + * Sets [Builder.overwriteFile] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteFile(overwriteFile: MultipartField) = apply { + body.overwriteFile(overwriteFile) + } - fun validate(): InnerTransformation = apply { - if (validated) { - return@apply - } + /** + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + */ + fun overwriteTags(overwriteTags: Boolean) = apply { body.overwriteTags(overwriteTags) } - _type().let { - if (it != JsonValue.from("transformation")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - value() - validated = true - } + /** + * Sets [Builder.overwriteTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteTags] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteTags(overwriteTags: MultipartField) = apply { + body.overwriteTags(overwriteTags) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + /** + * Your ImageKit.io public key. This field is only required for authentication when + * uploading a file from the client side. + */ + fun publicKey(publicKey: String) = apply { body.publicKey(publicKey) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.publicKey] to an arbitrary multipart value. + * + * You should usually call [Builder.publicKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun publicKey(publicKey: MultipartField) = apply { body.publicKey(publicKey) } - return other is InnerTransformation && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } + /** Array of response field keys to include in the API response body. */ + fun responseFields(responseFields: List) = apply { + body.responseFields(responseFields) + } - private val hashCode: Int by lazy { - Objects.hash(type, value, additionalProperties) - } + /** + * Sets [Builder.responseFields] to an arbitrary multipart value. + * + * You should usually call [Builder.responseFields] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun responseFields(responseFields: MultipartField>) = apply { + body.responseFields(responseFields) + } - override fun hashCode(): Int = hashCode + /** + * Adds a single [ResponseField] to [responseFields]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResponseField(responseField: ResponseField) = apply { + body.addResponseField(responseField) + } - override fun toString() = - "InnerTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" - } + /** + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. + * Learn how to create a signature on the page below. This should be in lowercase. + * + * Signature must be calculated on the server-side. This field is only required for + * authentication when uploading a file from the client side. + */ + fun signature(signature: String) = apply { body.signature(signature) } - class GifToVideo - private constructor( - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.signature] to an arbitrary multipart value. + * + * You should usually call [Builder.signature] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun signature(signature: MultipartField) = apply { body.signature(signature) } - /** - * Converts an animated GIF into an MP4. - * - * Expected to always return the following: - * ```java - * JsonValue.from("gif-to-video") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", + * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the + * `%` character is not allowed. If this field is not specified and the file is overwritten, + * the existing tags will be removed. + */ + fun tags(tags: List) = apply { body.tags(tags) } - /** - * Optional transformation string to apply to the output video. **Example**: - * `q-80` - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun value(): Optional = value.value.getOptional("value") + /** + * Sets [Builder.tags] to an arbitrary multipart value. + * + * You should usually call [Builder.tags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: MultipartField>) = apply { body.tags(tags) } - /** - * Returns the raw multipart value of [value]. - * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): MultipartField = value + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { body.addTag(tag) } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing + * file size or applying basic optimizations upfront (e.g., resize, compress). + * - `post` — applied immediately after upload. Ideal for generating transformed versions + * (like video encodes or thumbnails) in advance, so they're ready for delivery without + * delay. + * + * You can mix and match any combination of post-processing types. + */ + fun transformation(transformation: Transformation) = apply { + body.transformation(transformation) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.transformation] to an arbitrary multipart value. + * + * You should usually call [Builder.transformation] with a well-typed [Transformation] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun transformation(transformation: MultipartField) = apply { + body.transformation(transformation) + } - fun toBuilder() = Builder().from(this) + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique + * filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any + * existing file with the same name is replaced. + */ + fun useUniqueFileName(useUniqueFileName: Boolean) = apply { + body.useUniqueFileName(useUniqueFileName) + } - companion object { + /** + * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. + * + * You should usually call [Builder.useUniqueFileName] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useUniqueFileName(useUniqueFileName: MultipartField) = apply { + body.useUniqueFileName(useUniqueFileName) + } - /** - * Returns a mutable builder for constructing an instance of - * [GifToVideo]. - */ - @JvmStatic fun builder() = Builder() - } + /** + * The final status of extensions after they have completed execution will be delivered to + * this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + */ + fun webhookUrl(webhookUrl: String) = apply { body.webhookUrl(webhookUrl) } - /** A builder for [GifToVideo]. */ - class Builder internal constructor() { + /** + * Sets [Builder.webhookUrl] to an arbitrary multipart value. + * + * You should usually call [Builder.webhookUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun webhookUrl(webhookUrl: MultipartField) = apply { body.webhookUrl(webhookUrl) } - private var type: JsonValue = JsonValue.from("gif-to-video") - private var value: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = - mutableMapOf() + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } - @JvmSynthetic - internal fun from(gifToVideo: GifToVideo) = apply { - type = gifToVideo.type - value = gifToVideo.value - additionalProperties = - gifToVideo.additionalProperties.toMutableMap() - } + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field - * defaults to the following: - * ```java - * JsonValue.from("gif-to-video") - * ``` - * - * This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** - * Optional transformation string to apply to the output video. - * **Example**: `q-80` - */ - fun value(value: String) = value(MultipartField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun value(value: MultipartField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - /** - * Returns an immutable instance of [GifToVideo]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): GifToVideo = - GifToVideo(type, value, additionalProperties.toMutableMap()) - } + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - private var validated: Boolean = false + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - fun validate(): GifToVideo = apply { - if (validated) { - return@apply - } + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } - _type().let { - if (it != JsonValue.from("gif-to-video")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - value() - validated = true - } + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - return other is GifToVideo && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - private val hashCode: Int by lazy { - Objects.hash(type, value, additionalProperties) - } + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - override fun hashCode(): Int = hashCode + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } - override fun toString() = - "GifToVideo{type=$type, value=$value, additionalProperties=$additionalProperties}" - } + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - class Thumbnail - private constructor( - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } - /** - * Generates a thumbnail image. - * - * Expected to always return the following: - * ```java - * JsonValue.from("thumbnail") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - /** - * Optional transformation string. **Example**: `w-150,h-150` - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun value(): Optional = value.value.getOptional("value") + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } - /** - * Returns the raw multipart value of [value]. - * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): MultipartField = value + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } - fun toBuilder() = Builder().from(this) + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } - companion object { + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } - /** - * Returns a mutable builder for constructing an instance of - * [Thumbnail]. - */ - @JvmStatic fun builder() = Builder() - } + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } - /** A builder for [Thumbnail]. */ - class Builder internal constructor() { + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } - private var type: JsonValue = JsonValue.from("thumbnail") - private var value: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = - mutableMapOf() + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } - @JvmSynthetic - internal fun from(thumbnail: Thumbnail) = apply { - type = thumbnail.type - value = thumbnail.value - additionalProperties = thumbnail.additionalProperties.toMutableMap() - } + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field - * defaults to the following: - * ```java - * JsonValue.from("thumbnail") - * ``` - * - * This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** Optional transformation string. **Example**: `w-150,h-150` */ - fun value(value: String) = value(MultipartField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun value(value: MultipartField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Returns an immutable instance of [FileUploadParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .file() + * .fileName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FileUploadParams = + FileUploadParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun _body(): Map> = + (mapOf( + "file" to _file(), + "fileName" to _fileName(), + "token" to _token(), + "checks" to _checks(), + "customCoordinates" to _customCoordinates(), + "customMetadata" to _customMetadata(), + "description" to _description(), + "expire" to _expire(), + "extensions" to _extensions(), + "folder" to _folder(), + "isPrivateFile" to _isPrivateFile(), + "isPublished" to _isPublished(), + "overwriteAITags" to _overwriteAiTags(), + "overwriteCustomMetadata" to _overwriteCustomMetadata(), + "overwriteFile" to _overwriteFile(), + "overwriteTags" to _overwriteTags(), + "publicKey" to _publicKey(), + "responseFields" to _responseFields(), + "signature" to _signature(), + "tags" to _tags(), + "transformation" to _transformation(), + "useUniqueFileName" to _useUniqueFileName(), + "webhookUrl" to _webhookUrl(), + ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) + .toImmutable() - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + override fun _headers(): Headers = additionalHeaders - /** - * Returns an immutable instance of [Thumbnail]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): Thumbnail = - Thumbnail(type, value, additionalProperties.toMutableMap()) - } + override fun _queryParams(): QueryParams = additionalQueryParams - private var validated: Boolean = false + class Body + private constructor( + private val file: MultipartField, + private val fileName: MultipartField, + private val token: MultipartField, + private val checks: MultipartField, + private val customCoordinates: MultipartField, + private val customMetadata: MultipartField, + private val description: MultipartField, + private val expire: MultipartField, + private val extensions: MultipartField>, + private val folder: MultipartField, + private val isPrivateFile: MultipartField, + private val isPublished: MultipartField, + private val overwriteAiTags: MultipartField, + private val overwriteCustomMetadata: MultipartField, + private val overwriteFile: MultipartField, + private val overwriteTags: MultipartField, + private val publicKey: MultipartField, + private val responseFields: MultipartField>, + private val signature: MultipartField, + private val tags: MultipartField>, + private val transformation: MultipartField, + private val useUniqueFileName: MultipartField, + private val webhookUrl: MultipartField, + private val additionalProperties: MutableMap, + ) { - fun validate(): Thumbnail = apply { - if (validated) { - return@apply - } + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + * + * @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 file(): InputStream = file.value.getRequired("file") - _type().let { - if (it != JsonValue.from("thumbnail")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - value() - validated = true - } + /** + * The name with which the file has to be uploaded. The file name can contain: + * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. + * - Special Characters: `.`, `-` + * + * Any other character including space will be replaced by `_` + * + * @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 fileName(): String = fileName.value.getRequired("fileName") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + /** + * A unique value that the ImageKit.io server will use to recognize and prevent subsequent + * retries for the same request. We suggest using V4 UUIDs, or another random string with + * enough entropy to avoid collisions. This field is only required for authentication when + * uploading a file from the client side. + * + * **Note**: Sending a value that has been used in the past will result in a validation + * error. Even if your previous request resulted in an error, you should always send a new + * value for this field. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun token(): Optional = token.value.getOptional("token") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Server-side checks to run on the asset. Read more about + * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun checks(): Optional = checks.value.getOptional("checks") - return other is Thumbnail && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } + /** + * Define an important area in the image. This is only relevant for image type files. + * - To be passed as a string with the x and y coordinates of the top-left corner, and width + * and height of the area of interest in the format `x,y,width,height`. For example - + * `10,10,100,100` + * - Can be used with fo-customtransformation. + * - If this field is not specified and the file is overwritten, then customCoordinates will + * be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customCoordinates(): Optional = + customCoordinates.value.getOptional("customCoordinates") - private val hashCode: Int by lazy { - Objects.hash(type, value, additionalProperties) - } + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields + * before setting these values. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customMetadata(): Optional = + customMetadata.value.getOptional("customMetadata") - override fun hashCode(): Int = hashCode + /** + * Optional text to describe the contents of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.value.getOptional("description") - override fun toString() = - "Thumbnail{type=$type, value=$value, additionalProperties=$additionalProperties}" - } + /** + * The time until your signature is valid. It must be a + * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the future. + * It should be in seconds. This field is only required for authentication when uploading a + * file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun expire(): Optional = expire.value.getOptional("expire") - class Abs - private constructor( - private val protocol: MultipartField, - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { + /** + * Array of extensions to be applied to the image. Each extension can be configured with + * specific parameters based on the extension type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun extensions(): Optional> = extensions.value.getOptional("extensions") - /** - * Streaming protocol to use (`hls` or `dash`). - * - * @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 protocol(): Protocol = protocol.value.getRequired("protocol") + /** + * The folder path in which the image has to be uploaded. If the folder(s) didn't exist + * before, a new folder(s) is created. + * + * The folder name can contain: + * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` + * - Special Characters: `/` , `_` , `-` + * + * Using multiple `/` creates a nested folder. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun folder(): Optional = folder.value.getOptional("folder") - /** - * Adaptive Bitrate Streaming (ABS) setup. - * - * Expected to always return the following: - * ```java - * JsonValue.from("abs") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named + * transformation or signed URL. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isPrivateFile(): Optional = isPrivateFile.value.getOptional("isPrivateFile") - /** - * List of different representations you want to create separated by an - * underscore. - * - * @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 value(): String = value.value.getRequired("value") + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file only + * via the media library. Files in draft or unpublished state can only be publicly accessed + * after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing plans. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isPublished(): Optional = isPublished.value.getOptional("isPublished") - /** - * Returns the raw multipart value of [protocol]. - * - * Unlike [protocol], this method doesn't throw if the multipart field has - * an unexpected type. - */ - @JsonProperty("protocol") - @ExcludeMissing - fun _protocol(): MultipartField = protocol + /** + * If set to `true` and a file already exists at the exact location, its AITags will be + * removed. Set `overwriteAITags` to `false` to preserve AITags. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun overwriteAiTags(): Optional = + overwriteAiTags.value.getOptional("overwriteAITags") - /** - * Returns the raw multipart value of [value]. - * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): MultipartField = value + /** + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun overwriteCustomMetadata(): Optional = + overwriteCustomMetadata.value.getOptional("overwriteCustomMetadata") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the + * exact location, upload API will return an error immediately. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun overwriteFile(): Optional = overwriteFile.value.getOptional("overwriteFile") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Abs]. - * - * The following fields are required: - * ```java - * .protocol() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + /** + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun overwriteTags(): Optional = overwriteTags.value.getOptional("overwriteTags") - /** A builder for [Abs]. */ - class Builder internal constructor() { - - private var protocol: MultipartField? = null - private var type: JsonValue = JsonValue.from("abs") - private var value: MultipartField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(abs: Abs) = apply { - protocol = abs.protocol - type = abs.type - value = abs.value - additionalProperties = abs.additionalProperties.toMutableMap() - } + /** + * Your ImageKit.io public key. This field is only required for authentication when + * uploading a file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun publicKey(): Optional = publicKey.value.getOptional("publicKey") - /** Streaming protocol to use (`hls` or `dash`). */ - fun protocol(protocol: Protocol) = protocol(MultipartField.of(protocol)) - - /** - * Sets [Builder.protocol] to an arbitrary multipart value. - * - * You should usually call [Builder.protocol] with a well-typed - * [Protocol] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun protocol(protocol: MultipartField) = apply { - this.protocol = protocol - } + /** + * Array of response field keys to include in the API response body. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun responseFields(): Optional> = + responseFields.value.getOptional("responseFields") - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field - * defaults to the following: - * ```java - * JsonValue.from("abs") - * ``` - * - * This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** - * List of different representations you want to create separated by an - * underscore. - */ - fun value(value: String) = value(MultipartField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun value(value: MultipartField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. + * Learn how to create a signature on the page below. This should be in lowercase. + * + * Signature must be calculated on the server-side. This field is only required for + * authentication when uploading a file from the client side. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun signature(): Optional = signature.value.getOptional("signature") - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", + * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the + * `%` character is not allowed. If this field is not specified and the file is overwritten, + * the existing tags will be removed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tags(): Optional> = tags.value.getOptional("tags") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing + * file size or applying basic optimizations upfront (e.g., resize, compress). + * - `post` — applied immediately after upload. Ideal for generating transformed versions + * (like video encodes or thumbnails) in advance, so they're ready for delivery without + * delay. + * + * You can mix and match any combination of post-processing types. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun transformation(): Optional = + transformation.value.getOptional("transformation") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Whether to use a unique filename for this file or not. + * + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a unique + * filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any + * existing file with the same name is replaced. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun useUniqueFileName(): Optional = + useUniqueFileName.value.getOptional("useUniqueFileName") - /** - * Returns an immutable instance of [Abs]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .protocol() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Abs = - Abs( - checkRequired("protocol", protocol), - type, - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } + /** + * The final status of extensions after they have completed execution will be delivered to + * this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookUrl(): Optional = webhookUrl.value.getOptional("webhookUrl") - private var validated: Boolean = false + /** + * Returns the raw multipart value of [file]. + * + * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField = file - fun validate(): Abs = apply { - if (validated) { - return@apply - } + /** + * Returns the raw multipart value of [fileName]. + * + * Unlike [fileName], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("fileName") @ExcludeMissing fun _fileName(): MultipartField = fileName - protocol().validate() - _type().let { - if (it != JsonValue.from("abs")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - value() - validated = true - } + /** + * Returns the raw multipart value of [token]. + * + * Unlike [token], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): MultipartField = token - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + /** + * Returns the raw multipart value of [checks]. + * + * Unlike [checks], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("checks") @ExcludeMissing fun _checks(): MultipartField = checks - /** Streaming protocol to use (`hls` or `dash`). */ - class Protocol - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * Returns the raw multipart value of [customCoordinates]. + * + * Unlike [customCoordinates], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("customCoordinates") + @ExcludeMissing + fun _customCoordinates(): MultipartField = customCoordinates - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from - * data that doesn't match any known member, and you want to know that - * value. For example, if the SDK is on an older version than the API, - * then the API may respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * Returns the raw multipart value of [customMetadata]. + * + * Unlike [customMetadata], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): MultipartField = customMetadata - companion object { + /** + * Returns the raw multipart value of [description]. + * + * Unlike [description], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): MultipartField = description - @JvmField val HLS = of("hls") + /** + * Returns the raw multipart value of [expire]. + * + * Unlike [expire], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("expire") @ExcludeMissing fun _expire(): MultipartField = expire - @JvmField val DASH = of("dash") + /** + * Returns the raw multipart value of [extensions]. + * + * Unlike [extensions], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("extensions") + @ExcludeMissing + fun _extensions(): MultipartField> = extensions - @JvmStatic fun of(value: String) = Protocol(JsonField.of(value)) - } + /** + * Returns the raw multipart value of [folder]. + * + * Unlike [folder], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("folder") @ExcludeMissing fun _folder(): MultipartField = folder - /** An enum containing [Protocol]'s known values. */ - enum class Known { - HLS, - DASH, - } + /** + * Returns the raw multipart value of [isPrivateFile]. + * + * Unlike [isPrivateFile], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("isPrivateFile") + @ExcludeMissing + fun _isPrivateFile(): MultipartField = isPrivateFile - /** - * An enum containing [Protocol]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [Protocol] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. - * For example, if the SDK is on an older version than the API, then - * the API may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - HLS, - DASH, - /** - * An enum member indicating that [Protocol] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } + /** + * Returns the raw multipart value of [isPublished]. + * + * Unlike [isPublished], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("isPublished") + @ExcludeMissing + fun _isPublished(): MultipartField = isPublished - /** - * Returns an enum member corresponding to this class instance's value, - * or [Value._UNKNOWN] if the class was instantiated with an unknown - * value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - HLS -> Value.HLS - DASH -> Value.DASH - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is - * always known and don't want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value - * is a not a known member. - */ - fun known(): Known = - when (this) { - HLS -> Known.HLS - DASH -> Known.DASH - else -> - throw ImageKitInvalidDataException( - "Unknown Protocol: $value" - ) - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is - * primarily for debugging and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value - * does not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Protocol = apply { - if (validated) { - return@apply - } - - known() - validated = true - } + /** + * Returns the raw multipart value of [overwriteAiTags]. + * + * Unlike [overwriteAiTags], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteAITags") + @ExcludeMissing + fun _overwriteAiTags(): MultipartField = overwriteAiTags - 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 (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Protocol && value == other.value - } + /** + * Returns the raw multipart value of [overwriteCustomMetadata]. + * + * Unlike [overwriteCustomMetadata], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteCustomMetadata") + @ExcludeMissing + fun _overwriteCustomMetadata(): MultipartField = overwriteCustomMetadata - override fun hashCode() = value.hashCode() + /** + * Returns the raw multipart value of [overwriteFile]. + * + * Unlike [overwriteFile], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteFile") + @ExcludeMissing + fun _overwriteFile(): MultipartField = overwriteFile - override fun toString() = value.toString() - } + /** + * Returns the raw multipart value of [overwriteTags]. + * + * Unlike [overwriteTags], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("overwriteTags") + @ExcludeMissing + fun _overwriteTags(): MultipartField = overwriteTags - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw multipart value of [publicKey]. + * + * Unlike [publicKey], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("publicKey") + @ExcludeMissing + fun _publicKey(): MultipartField = publicKey - return other is Abs && - protocol == other.protocol && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw multipart value of [responseFields]. + * + * Unlike [responseFields], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("responseFields") + @ExcludeMissing + fun _responseFields(): MultipartField> = responseFields - private val hashCode: Int by lazy { - Objects.hash(protocol, type, value, additionalProperties) - } + /** + * Returns the raw multipart value of [signature]. + * + * Unlike [signature], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("signature") + @ExcludeMissing + fun _signature(): MultipartField = signature - override fun hashCode(): Int = hashCode + /** + * Returns the raw multipart value of [tags]. + * + * Unlike [tags], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): MultipartField> = tags - override fun toString() = - "Abs{protocol=$protocol, type=$type, value=$value, additionalProperties=$additionalProperties}" - } - } + /** + * Returns the raw multipart value of [transformation]. + * + * Unlike [transformation], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("transformation") + @ExcludeMissing + fun _transformation(): MultipartField = transformation - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw multipart value of [useUniqueFileName]. + * + * Unlike [useUniqueFileName], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("useUniqueFileName") + @ExcludeMissing + fun _useUniqueFileName(): MultipartField = useUniqueFileName - return other is Transformation && - post == other.post && - pre == other.pre && - additionalProperties == other.additionalProperties - } + /** + * Returns the raw multipart value of [webhookUrl]. + * + * Unlike [webhookUrl], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("webhookUrl") + @ExcludeMissing + fun _webhookUrl(): MultipartField = webhookUrl - private val hashCode: Int by lazy { Objects.hash(post, pre, additionalProperties) } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - override fun hashCode(): Int = hashCode + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun toString() = - "Transformation{post=$post, pre=$pre, additionalProperties=$additionalProperties}" - } + fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + companion object { - return other is FileUploadV1 && - file == other.file && - fileName == other.fileName && - token == other.token && - checks == other.checks && - customCoordinates == other.customCoordinates && - customMetadata == other.customMetadata && - description == other.description && - expire == other.expire && - extensions == other.extensions && - folder == other.folder && - isPrivateFile == other.isPrivateFile && - isPublished == other.isPublished && - overwriteAiTags == other.overwriteAiTags && - overwriteCustomMetadata == other.overwriteCustomMetadata && - overwriteFile == other.overwriteFile && - overwriteTags == other.overwriteTags && - publicKey == other.publicKey && - responseFields == other.responseFields && - signature == other.signature && - tags == other.tags && - transformation == other.transformation && - useUniqueFileName == other.useUniqueFileName && - webhookUrl == other.webhookUrl && - additionalProperties == other.additionalProperties - } + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .file() + * .fileName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - private val hashCode: Int by lazy { - Objects.hash( - file, - fileName, - token, - checks, - customCoordinates, - customMetadata, - description, - expire, - extensions, - folder, - isPrivateFile, - isPublished, - overwriteAiTags, - overwriteCustomMetadata, - overwriteFile, - overwriteTags, - publicKey, - responseFields, - signature, - tags, - transformation, - useUniqueFileName, - webhookUrl, - additionalProperties, - ) + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var file: MultipartField? = null + private var fileName: MultipartField? = null + private var token: MultipartField = MultipartField.of(null) + private var checks: MultipartField = MultipartField.of(null) + private var customCoordinates: MultipartField = MultipartField.of(null) + private var customMetadata: MultipartField = MultipartField.of(null) + private var description: MultipartField = MultipartField.of(null) + private var expire: MultipartField = MultipartField.of(null) + private var extensions: MultipartField>? = null + private var folder: MultipartField = MultipartField.of(null) + private var isPrivateFile: MultipartField = MultipartField.of(null) + private var isPublished: MultipartField = MultipartField.of(null) + private var overwriteAiTags: MultipartField = MultipartField.of(null) + private var overwriteCustomMetadata: MultipartField = MultipartField.of(null) + private var overwriteFile: MultipartField = MultipartField.of(null) + private var overwriteTags: MultipartField = MultipartField.of(null) + private var publicKey: MultipartField = MultipartField.of(null) + private var responseFields: MultipartField>? = null + private var signature: MultipartField = MultipartField.of(null) + private var tags: MultipartField>? = null + private var transformation: MultipartField = MultipartField.of(null) + private var useUniqueFileName: MultipartField = MultipartField.of(null) + private var webhookUrl: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + file = body.file + fileName = body.fileName + token = body.token + checks = body.checks + customCoordinates = body.customCoordinates + customMetadata = body.customMetadata + description = body.description + expire = body.expire + extensions = body.extensions.map { it.toMutableList() } + folder = body.folder + isPrivateFile = body.isPrivateFile + isPublished = body.isPublished + overwriteAiTags = body.overwriteAiTags + overwriteCustomMetadata = body.overwriteCustomMetadata + overwriteFile = body.overwriteFile + overwriteTags = body.overwriteTags + publicKey = body.publicKey + responseFields = body.responseFields.map { it.toMutableList() } + signature = body.signature + tags = body.tags.map { it.toMutableList() } + transformation = body.transformation + useUniqueFileName = body.useUniqueFileName + webhookUrl = body.webhookUrl + additionalProperties = body.additionalProperties.toMutableMap() } - override fun hashCode(): Int = hashCode + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(file: InputStream) = file(MultipartField.of(file)) - override fun toString() = - "FileUploadV1{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, expire=$expire, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, publicKey=$publicKey, responseFields=$responseFields, signature=$signature, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.file] to an arbitrary multipart value. + * + * You should usually call [Builder.file] with a well-typed [InputStream] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun file(file: MultipartField) = apply { this.file = file } - class FileUploadByUrlv1 - private constructor( - private val file: MultipartField, - private val fileName: MultipartField, - private val token: MultipartField, - private val checks: MultipartField, - private val customCoordinates: MultipartField, - private val customMetadata: MultipartField, - private val description: MultipartField, - private val expire: MultipartField, - private val extensions: MultipartField>, - private val folder: MultipartField, - private val isPrivateFile: MultipartField, - private val isPublished: MultipartField, - private val overwriteAiTags: MultipartField, - private val overwriteCustomMetadata: MultipartField, - private val overwriteFile: MultipartField, - private val overwriteTags: MultipartField, - private val publicKey: MultipartField, - private val responseFields: MultipartField>, - private val signature: MultipartField, - private val tags: MultipartField>, - private val transformation: MultipartField, - private val useUniqueFileName: MultipartField, - private val webhookUrl: MultipartField, - private val additionalProperties: MutableMap, - ) { + /** + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. + * + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. + */ + fun file(file: ByteArray) = file(file.inputStream()) /** - * The URL of the file to upload. A publicly reachable URL that ImageKit servers can - * fetch. The server must receive the response headers within 8 seconds; otherwise the - * request fails with 400 Bad Request. + * The API accepts any of the following: + * - **Binary data** – send the raw bytes as `multipart/form-data`. + * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch. + * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64. * - * @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). + * When supplying a URL, the server must receive the response headers within 8 seconds; + * otherwise the request fails with 400 Bad Request. */ - fun file(): String = file.value.getRequired("file") + fun file(path: Path) = + file( + MultipartField.builder() + .value(path.inputStream()) + .filename(path.name) + .build() + ) /** * The name with which the file has to be uploaded. The file name can contain: @@ -4501,12 +1833,17 @@ private constructor( * - Special Characters: `.`, `-` * * Any other character including space will be replaced by `_` + */ + fun fileName(fileName: String) = fileName(MultipartField.of(fileName)) + + /** + * Sets [Builder.fileName] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * You should usually call [Builder.fileName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun fileName(): String = fileName.value.getRequired("fileName") + fun fileName(fileName: MultipartField) = apply { this.fileName = fileName } /** * A unique value that the ImageKit.io server will use to recognize and prevent @@ -4517,20 +1854,32 @@ private constructor( * **Note**: Sending a value that has been used in the past will result in a validation * error. Even if your previous request resulted in an error, you should always send a * new value for this field. + */ + fun token(token: String) = token(MultipartField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun token(): Optional = token.value.getOptional("token") + fun token(token: MultipartField) = apply { this.token = token } /** * Server-side checks to run on the asset. Read more about * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + */ + fun checks(checks: String) = checks(MultipartField.of(checks)) + + /** + * Sets [Builder.checks] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.checks] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun checks(): Optional = checks.value.getOptional("checks") + fun checks(checks: MultipartField) = apply { this.checks = checks } /** * Define an important area in the image. This is only relevant for image type files. @@ -4540,50 +1889,109 @@ private constructor( * - Can be used with fo-customtransformation. * - If this field is not specified and the file is overwritten, then customCoordinates * will be removed. + */ + fun customCoordinates(customCoordinates: String) = + customCoordinates(MultipartField.of(customCoordinates)) + + /** + * Sets [Builder.customCoordinates] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.customCoordinates] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun customCoordinates(): Optional = - customCoordinates.value.getOptional("customCoordinates") + fun customCoordinates(customCoordinates: MultipartField) = apply { + this.customCoordinates = customCoordinates + } /** * JSON key-value pairs to associate with the asset. Create the custom metadata fields * before setting these values. + */ + fun customMetadata(customMetadata: CustomMetadata) = + customMetadata(MultipartField.of(customMetadata)) + + /** + * Sets [Builder.customMetadata] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.customMetadata] with a well-typed [CustomMetadata] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun customMetadata(): Optional = - customMetadata.value.getOptional("customMetadata") + fun customMetadata(customMetadata: MultipartField) = apply { + this.customMetadata = customMetadata + } + + /** Optional text to describe the contents of the file. */ + fun description(description: String) = description(MultipartField.of(description)) /** - * Optional text to describe the contents of the file. + * Sets [Builder.description] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected 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(): Optional = description.value.getOptional("description") + fun description(description: MultipartField) = apply { + this.description = description + } /** * The time until your signature is valid. It must be a * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the * future. It should be in seconds. This field is only required for authentication when * uploading a file from the client side. + */ + fun expire(expire: Long) = expire(MultipartField.of(expire)) + + /** + * Sets [Builder.expire] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.expire] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun expire(): Optional = expire.value.getOptional("expire") + fun expire(expire: MultipartField) = apply { this.expire = expire } /** * Array of extensions to be applied to the image. Each extension can be configured with * specific parameters based on the extension type. + */ + fun extensions(extensions: List) = extensions(MultipartField.of(extensions)) + + /** + * Sets [Builder.extensions] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.extensions] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun extensions(extensions: MultipartField>) = apply { + this.extensions = extensions.map { it.toMutableList() } + } + + /** + * Adds a single [Extension] to [extensions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun extensions(): Optional> = extensions.value.getOptional("extensions") + fun addExtension(extension: Extension) = apply { + extensions = + (extensions ?: MultipartField.of(mutableListOf())).also { + checkKnown("extensions", it).add(extension) + } + } + + /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ + fun addExtension(removeBg: Extension.RemoveBg) = + addExtension(Extension.ofRemoveBg(removeBg)) + + /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ + fun addExtension(autoTagging: Extension.AutoTaggingExtension) = + addExtension(Extension.ofAutoTagging(autoTagging)) + + /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ + fun addExtensionAiAutoDescription() = addExtension(Extension.ofAiAutoDescription()) /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist @@ -4594,380 +2002,795 @@ private constructor( * - Special Characters: `/` , `_` , `-` * * Using multiple `/` creates a nested folder. + */ + fun folder(folder: String) = folder(MultipartField.of(folder)) + + /** + * Sets [Builder.folder] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.folder] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun folder(folder: MultipartField) = apply { this.folder = folder } + + /** + * Whether to mark the file as private or not. + * + * If `true`, the file is marked as private and is accessible only using named + * transformation or signed URL. + */ + fun isPrivateFile(isPrivateFile: Boolean) = + isPrivateFile(MultipartField.of(isPrivateFile)) + + /** + * Sets [Builder.isPrivateFile] to an arbitrary multipart value. + * + * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPrivateFile(isPrivateFile: MultipartField) = apply { + this.isPrivateFile = isPrivateFile + } + + /** + * Whether to upload file as published or not. + * + * If `false`, the file is marked as unpublished, which restricts access to the file + * only via the media library. Files in draft or unpublished state can only be publicly + * accessed after being published. + * + * The option to upload in draft state is only available in custom enterprise pricing + * plans. + */ + fun isPublished(isPublished: Boolean) = isPublished(MultipartField.of(isPublished)) + + /** + * Sets [Builder.isPublished] to an arbitrary multipart value. + * + * You should usually call [Builder.isPublished] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isPublished(isPublished: MultipartField) = apply { + this.isPublished = isPublished + } + + /** + * If set to `true` and a file already exists at the exact location, its AITags will be + * removed. Set `overwriteAITags` to `false` to preserve AITags. + */ + fun overwriteAiTags(overwriteAiTags: Boolean) = + overwriteAiTags(MultipartField.of(overwriteAiTags)) + + /** + * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteAiTags] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteAiTags(overwriteAiTags: MultipartField) = apply { + this.overwriteAiTags = overwriteAiTags + } + + /** + * If the request does not have `customMetadata`, and a file already exists at the exact + * location, existing customMetadata will be removed. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: Boolean) = + overwriteCustomMetadata(MultipartField.of(overwriteCustomMetadata)) + + /** + * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteCustomMetadata] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun overwriteCustomMetadata(overwriteCustomMetadata: MultipartField) = apply { + this.overwriteCustomMetadata = overwriteCustomMetadata + } + + /** + * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the + * exact location, upload API will return an error immediately. + */ + fun overwriteFile(overwriteFile: Boolean) = + overwriteFile(MultipartField.of(overwriteFile)) + + /** + * Sets [Builder.overwriteFile] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteFile] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteFile(overwriteFile: MultipartField) = apply { + this.overwriteFile = overwriteFile + } + + /** + * If the request does not have `tags`, and a file already exists at the exact location, + * existing tags will be removed. + */ + fun overwriteTags(overwriteTags: Boolean) = + overwriteTags(MultipartField.of(overwriteTags)) + + /** + * Sets [Builder.overwriteTags] to an arbitrary multipart value. + * + * You should usually call [Builder.overwriteTags] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overwriteTags(overwriteTags: MultipartField) = apply { + this.overwriteTags = overwriteTags + } + + /** + * Your ImageKit.io public key. This field is only required for authentication when + * uploading a file from the client side. + */ + fun publicKey(publicKey: String) = publicKey(MultipartField.of(publicKey)) + + /** + * Sets [Builder.publicKey] to an arbitrary multipart value. + * + * You should usually call [Builder.publicKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun publicKey(publicKey: MultipartField) = apply { this.publicKey = publicKey } + + /** Array of response field keys to include in the API response body. */ + fun responseFields(responseFields: List) = + responseFields(MultipartField.of(responseFields)) + + /** + * Sets [Builder.responseFields] to an arbitrary multipart value. + * + * You should usually call [Builder.responseFields] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun responseFields(responseFields: MultipartField>) = apply { + this.responseFields = responseFields.map { it.toMutableList() } + } + + /** + * Adds a single [ResponseField] to [responseFields]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResponseField(responseField: ResponseField) = apply { + responseFields = + (responseFields ?: MultipartField.of(mutableListOf())).also { + checkKnown("responseFields", it).add(responseField) + } + } + + /** + * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. + * Learn how to create a signature on the page below. This should be in lowercase. + * + * Signature must be calculated on the server-side. This field is only required for + * authentication when uploading a file from the client side. + */ + fun signature(signature: String) = signature(MultipartField.of(signature)) + + /** + * Sets [Builder.signature] to an arbitrary multipart value. + * + * You should usually call [Builder.signature] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun folder(): Optional = folder.value.getOptional("folder") + fun signature(signature: MultipartField) = apply { this.signature = signature } /** - * Whether to mark the file as private or not. - * - * If `true`, the file is marked as private and is accessible only using named - * transformation or signed URL. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * Set the tags while uploading the file. Provide an array of tag strings (e.g. + * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not + * exceed 500, and the `%` character is not allowed. If this field is not specified and + * the file is overwritten, the existing tags will be removed. */ - fun isPrivateFile(): Optional = - isPrivateFile.value.getOptional("isPrivateFile") + fun tags(tags: List) = tags(MultipartField.of(tags)) /** - * Whether to upload file as published or not. - * - * If `false`, the file is marked as unpublished, which restricts access to the file - * only via the media library. Files in draft or unpublished state can only be publicly - * accessed after being published. + * Sets [Builder.tags] to an arbitrary multipart value. * - * The option to upload in draft state is only available in custom enterprise pricing - * plans. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.tags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun isPublished(): Optional = isPublished.value.getOptional("isPublished") + fun tags(tags: MultipartField>) = apply { + this.tags = tags.map { it.toMutableList() } + } /** - * If set to `true` and a file already exists at the exact location, its AITags will be - * removed. Set `overwriteAITags` to `false` to preserve AITags. + * Adds a single [String] to [tags]. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun overwriteAiTags(): Optional = - overwriteAiTags.value.getOptional("overwriteAITags") + fun addTag(tag: String) = apply { + tags = + (tags ?: MultipartField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } /** - * If the request does not have `customMetadata`, and a file already exists at the exact - * location, existing customMetadata will be removed. + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for + * reducing file size or applying basic optimizations upfront (e.g., resize, + * compress). + * - `post` — applied immediately after upload. Ideal for generating transformed + * versions (like video encodes or thumbnails) in advance, so they're ready for + * delivery without delay. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You can mix and match any combination of post-processing types. */ - fun overwriteCustomMetadata(): Optional = - overwriteCustomMetadata.value.getOptional("overwriteCustomMetadata") + fun transformation(transformation: Transformation) = + transformation(MultipartField.of(transformation)) /** - * If `false` and `useUniqueFileName` is also `false`, and a file already exists at the - * exact location, upload API will return an error immediately. + * Sets [Builder.transformation] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.transformation] with a well-typed [Transformation] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun overwriteFile(): Optional = - overwriteFile.value.getOptional("overwriteFile") + fun transformation(transformation: MultipartField) = apply { + this.transformation = transformation + } /** - * If the request does not have `tags`, and a file already exists at the exact location, - * existing tags will be removed. + * Whether to use a unique filename for this file or not. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a + * unique filename. + * + * If `false`, then the image is uploaded with the provided filename parameter, and any + * existing file with the same name is replaced. */ - fun overwriteTags(): Optional = - overwriteTags.value.getOptional("overwriteTags") + fun useUniqueFileName(useUniqueFileName: Boolean) = + useUniqueFileName(MultipartField.of(useUniqueFileName)) /** - * Your ImageKit.io public key. This field is only required for authentication when - * uploading a file from the client side. + * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.useUniqueFileName] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useUniqueFileName(useUniqueFileName: MultipartField) = apply { + this.useUniqueFileName = useUniqueFileName + } + + /** + * The final status of extensions after they have completed execution will be delivered + * to this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. */ - fun publicKey(): Optional = publicKey.value.getOptional("publicKey") + fun webhookUrl(webhookUrl: String) = webhookUrl(MultipartField.of(webhookUrl)) /** - * Array of response field keys to include in the API response body. + * Sets [Builder.webhookUrl] to an arbitrary multipart value. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.webhookUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun responseFields(): Optional> = - responseFields.value.getOptional("responseFields") + fun webhookUrl(webhookUrl: MultipartField) = apply { + this.webhookUrl = webhookUrl + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. - * Learn how to create a signature on the page below. This should be in lowercase. + * Returns an immutable instance of [Body]. * - * Signature must be calculated on the server-side. This field is only required for - * authentication when uploading a file from the client side. + * Further updates to this [Builder] will not mutate the returned instance. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * The following fields are required: + * ```java + * .file() + * .fileName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("file", file), + checkRequired("fileName", fileName), + token, + checks, + customCoordinates, + customMetadata, + description, + expire, + (extensions ?: MultipartField.of(null)).map { it.toImmutable() }, + folder, + isPrivateFile, + isPublished, + overwriteAiTags, + overwriteCustomMetadata, + overwriteFile, + overwriteTags, + publicKey, + (responseFields ?: MultipartField.of(null)).map { it.toImmutable() }, + signature, + (tags ?: MultipartField.of(null)).map { it.toImmutable() }, + transformation, + useUniqueFileName, + webhookUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + file() + fileName() + token() + checks() + customCoordinates() + customMetadata().ifPresent { it.validate() } + description() + expire() + extensions().ifPresent { it.forEach { it.validate() } } + folder() + isPrivateFile() + isPublished() + overwriteAiTags() + overwriteCustomMetadata() + overwriteFile() + overwriteTags() + publicKey() + responseFields().ifPresent { it.forEach { it.validate() } } + signature() + tags() + transformation().ifPresent { it.validate() } + useUniqueFileName() + webhookUrl() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + file == other.file && + fileName == other.fileName && + token == other.token && + checks == other.checks && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + description == other.description && + expire == other.expire && + extensions == other.extensions && + folder == other.folder && + isPrivateFile == other.isPrivateFile && + isPublished == other.isPublished && + overwriteAiTags == other.overwriteAiTags && + overwriteCustomMetadata == other.overwriteCustomMetadata && + overwriteFile == other.overwriteFile && + overwriteTags == other.overwriteTags && + publicKey == other.publicKey && + responseFields == other.responseFields && + signature == other.signature && + tags == other.tags && + transformation == other.transformation && + useUniqueFileName == other.useUniqueFileName && + webhookUrl == other.webhookUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + file, + fileName, + token, + checks, + customCoordinates, + customMetadata, + description, + expire, + extensions, + folder, + isPrivateFile, + isPublished, + overwriteAiTags, + overwriteCustomMetadata, + overwriteFile, + overwriteTags, + publicKey, + responseFields, + signature, + tags, + transformation, + useUniqueFileName, + webhookUrl, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, expire=$expire, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, publicKey=$publicKey, responseFields=$responseFields, signature=$signature, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + } + + /** + * JSON key-value pairs to associate with the asset. Create the custom metadata fields before + * setting these values. + */ + class CustomMetadata + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CustomMetadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customMetadata: CustomMetadata) = apply { + additionalProperties = customMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. */ - fun signature(): Optional = signature.value.getOptional("signature") + fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CustomMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomMetadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Extension.Deserializer::class) + @JsonSerialize(using = Extension.Serializer::class) + class Extension + private constructor( + private val removeBg: RemoveBg? = null, + private val autoTagging: AutoTaggingExtension? = null, + private val aiAutoDescription: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun removeBg(): Optional = Optional.ofNullable(removeBg) + + fun autoTagging(): Optional = Optional.ofNullable(autoTagging) + + fun aiAutoDescription(): Optional = Optional.ofNullable(aiAutoDescription) + + fun isRemoveBg(): Boolean = removeBg != null + + fun isAutoTagging(): Boolean = autoTagging != null + + fun isAiAutoDescription(): Boolean = aiAutoDescription != null + + fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") + + fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") + + fun asAiAutoDescription(): JsonValue = aiAutoDescription.getOrThrow("aiAutoDescription") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + removeBg != null -> visitor.visitRemoveBg(removeBg) + autoTagging != null -> visitor.visitAutoTagging(autoTagging) + aiAutoDescription != null -> visitor.visitAiAutoDescription(aiAutoDescription) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Extension = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) { + removeBg.validate() + } + + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { + autoTagging.validate() + } + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { + aiAutoDescription.let { + if (it != JsonValue.from(mapOf("name" to "ai-auto-description"))) { + throw ImageKitInvalidDataException( + "'aiAutoDescription' is invalid, received $it" + ) + } + } + } + } + ) + 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 = + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() - /** - * Set the tags while uploading the file. Provide an array of tag strings (e.g. - * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not - * exceed 500, and the `%` character is not allowed. If this field is not specified and - * the file is overwritten, the existing tags will be removed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun tags(): Optional> = tags.value.getOptional("tags") + override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = + autoTagging.validity() - /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for - * reducing file size or applying basic optimizations upfront (e.g., resize, - * compress). - * - `post` — applied immediately after upload. Ideal for generating transformed - * versions (like video encodes or thumbnails) in advance, so they're ready for - * delivery without delay. - * - * You can mix and match any combination of post-processing types. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun transformation(): Optional = - transformation.value.getOptional("transformation") + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = + aiAutoDescription.let { + if (it == JsonValue.from(mapOf("name" to "ai-auto-description"))) 1 + else 0 + } - /** - * Whether to use a unique filename for this file or not. - * - * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get a - * unique filename. - * - * If `false`, then the image is uploaded with the provided filename parameter, and any - * existing file with the same name is replaced. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun useUniqueFileName(): Optional = - useUniqueFileName.value.getOptional("useUniqueFileName") + override fun unknown(json: JsonValue?) = 0 + } + ) - /** - * The final status of extensions after they have completed execution will be delivered - * to this endpoint as a POST request. - * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - * about the webhook payload structure. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun webhookUrl(): Optional = webhookUrl.value.getOptional("webhookUrl") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw multipart value of [file]. - * - * Unlike [file], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField = file + return other is Extension && + removeBg == other.removeBg && + autoTagging == other.autoTagging && + aiAutoDescription == other.aiAutoDescription + } - /** - * Returns the raw multipart value of [fileName]. - * - * Unlike [fileName], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("fileName") - @ExcludeMissing - fun _fileName(): MultipartField = fileName + override fun hashCode(): Int = Objects.hash(removeBg, autoTagging, aiAutoDescription) - /** - * Returns the raw multipart value of [token]. - * - * Unlike [token], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("token") @ExcludeMissing fun _token(): MultipartField = token + override fun toString(): String = + when { + removeBg != null -> "Extension{removeBg=$removeBg}" + autoTagging != null -> "Extension{autoTagging=$autoTagging}" + aiAutoDescription != null -> "Extension{aiAutoDescription=$aiAutoDescription}" + _json != null -> "Extension{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Extension") + } - /** - * Returns the raw multipart value of [checks]. - * - * Unlike [checks], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("checks") @ExcludeMissing fun _checks(): MultipartField = checks + companion object { - /** - * Returns the raw multipart value of [customCoordinates]. - * - * Unlike [customCoordinates], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("customCoordinates") - @ExcludeMissing - fun _customCoordinates(): MultipartField = customCoordinates + @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = Extension(removeBg = removeBg) - /** - * Returns the raw multipart value of [customMetadata]. - * - * Unlike [customMetadata], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("customMetadata") - @ExcludeMissing - fun _customMetadata(): MultipartField = customMetadata + @JvmStatic + fun ofAutoTagging(autoTagging: AutoTaggingExtension) = + Extension(autoTagging = autoTagging) - /** - * Returns the raw multipart value of [description]. - * - * Unlike [description], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): MultipartField = description + @JvmStatic + fun ofAiAutoDescription() = + Extension( + aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) + ) + } - /** - * Returns the raw multipart value of [expire]. - * - * Unlike [expire], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("expire") @ExcludeMissing fun _expire(): MultipartField = expire + /** + * An interface that defines how to map each variant of [Extension] to a value of type [T]. + */ + interface Visitor { - /** - * Returns the raw multipart value of [extensions]. - * - * Unlike [extensions], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("extensions") - @ExcludeMissing - fun _extensions(): MultipartField> = extensions + fun visitRemoveBg(removeBg: RemoveBg): T - /** - * Returns the raw multipart value of [folder]. - * - * Unlike [folder], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("folder") @ExcludeMissing fun _folder(): MultipartField = folder + fun visitAutoTagging(autoTagging: AutoTaggingExtension): T - /** - * Returns the raw multipart value of [isPrivateFile]. - * - * Unlike [isPrivateFile], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("isPrivateFile") - @ExcludeMissing - fun _isPrivateFile(): MultipartField = isPrivateFile + fun visitAiAutoDescription(aiAutoDescription: JsonValue): T /** - * Returns the raw multipart value of [isPublished]. + * Maps an unknown variant of [Extension] to a value of type [T]. * - * Unlike [isPublished], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("isPublished") - @ExcludeMissing - fun _isPublished(): MultipartField = isPublished - - /** - * Returns the raw multipart value of [overwriteAiTags]. + * An instance of [Extension] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. * - * Unlike [overwriteAiTags], this method doesn't throw if the multipart field has an - * unexpected type. + * @throws ImageKitInvalidDataException in the default implementation. */ - @JsonProperty("overwriteAITags") - @ExcludeMissing - fun _overwriteAiTags(): MultipartField = overwriteAiTags + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Extension: $json") + } + } - /** - * Returns the raw multipart value of [overwriteCustomMetadata]. - * - * Unlike [overwriteCustomMetadata], this method doesn't throw if the multipart field - * has an unexpected type. - */ - @JsonProperty("overwriteCustomMetadata") - @ExcludeMissing - fun _overwriteCustomMetadata(): MultipartField = overwriteCustomMetadata + internal class Deserializer : BaseDeserializer(Extension::class) { - /** - * Returns the raw multipart value of [overwriteFile]. - * - * Unlike [overwriteFile], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("overwriteFile") - @ExcludeMissing - fun _overwriteFile(): MultipartField = overwriteFile + override fun ObjectCodec.deserialize(node: JsonNode): Extension { + val json = JsonValue.fromJsonNode(node) + val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() - /** - * Returns the raw multipart value of [overwriteTags]. - * - * Unlike [overwriteTags], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("overwriteTags") - @ExcludeMissing - fun _overwriteTags(): MultipartField = overwriteTags + when (name) { + "remove-bg" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Extension(removeBg = it, _json = json) + } ?: Extension(_json = json) + } + "ai-auto-description" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Extension(aiAutoDescription = it, _json = json) } + ?.takeIf { it.isValid() } ?: Extension(_json = json) + } + } - /** - * Returns the raw multipart value of [publicKey]. - * - * Unlike [publicKey], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("publicKey") - @ExcludeMissing - fun _publicKey(): MultipartField = publicKey + return tryDeserialize(node, jacksonTypeRef())?.let { + Extension(autoTagging = it, _json = json) + } ?: Extension(_json = json) + } + } - /** - * Returns the raw multipart value of [responseFields]. - * - * Unlike [responseFields], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("responseFields") - @ExcludeMissing - fun _responseFields(): MultipartField> = responseFields + internal class Serializer : BaseSerializer(Extension::class) { - /** - * Returns the raw multipart value of [signature]. - * - * Unlike [signature], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("signature") - @ExcludeMissing - fun _signature(): MultipartField = signature + override fun serialize( + value: Extension, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.removeBg != null -> generator.writeObject(value.removeBg) + value.autoTagging != null -> generator.writeObject(value.autoTagging) + value.aiAutoDescription != null -> + generator.writeObject(value.aiAutoDescription) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Extension") + } + } + } - /** - * Returns the raw multipart value of [tags]. - * - * Unlike [tags], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): MultipartField> = tags + class RemoveBg + private constructor( + private val name: JsonValue, + private val options: MultipartField, + private val additionalProperties: MutableMap, + ) { /** - * Returns the raw multipart value of [transformation]. + * Specifies the background removal extension. * - * Unlike [transformation], this method doesn't throw if the multipart field has an - * unexpected type. + * Expected to always return the following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - @JsonProperty("transformation") - @ExcludeMissing - fun _transformation(): MultipartField = transformation + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name /** - * Returns the raw multipart value of [useUniqueFileName]. - * - * Unlike [useUniqueFileName], this method doesn't throw if the multipart field has an - * unexpected type. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("useUniqueFileName") - @ExcludeMissing - fun _useUniqueFileName(): MultipartField = useUniqueFileName + fun options(): Optional = options.value.getOptional("options") /** - * Returns the raw multipart value of [webhookUrl]. + * Returns the raw multipart value of [options]. * - * Unlike [webhookUrl], this method doesn't throw if the multipart field has an - * unexpected type. + * Unlike [options], this method doesn't throw if the multipart field has an unexpected + * type. */ - @JsonProperty("webhookUrl") + @JsonProperty("options") @ExcludeMissing - fun _webhookUrl(): MultipartField = webhookUrl + fun _options(): MultipartField = options @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -4983,558 +2806,543 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveBg]. */ + class Builder internal constructor() { + + private var name: JsonValue = JsonValue.from("remove-bg") + private var options: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removeBg: RemoveBg) = apply { + name = removeBg.name + options = removeBg.options + additionalProperties = removeBg.additionalProperties.toMutableMap() + } + /** - * Returns a mutable builder for constructing an instance of [FileUploadByUrlv1]. + * Sets the field to an arbitrary JSON value. * - * The following fields are required: + * It is usually unnecessary to call this method because the field defaults to the + * following: * ```java - * .file() - * .fileName() + * JsonValue.from("remove-bg") * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - @JvmStatic fun builder() = Builder() + fun name(name: JsonValue) = apply { this.name = name } + + fun options(options: Options) = options(MultipartField.of(options)) + + /** + * Sets [Builder.options] to an arbitrary multipart value. + * + * You should usually call [Builder.options] with a well-typed [Options] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun options(options: MultipartField) = apply { this.options = options } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemoveBg]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemoveBg = RemoveBg(name, options, additionalProperties.toMutableMap()) } - /** A builder for [FileUploadByUrlv1]. */ - class Builder internal constructor() { + private var validated: Boolean = false - private var file: MultipartField? = null - private var fileName: MultipartField? = null - private var token: MultipartField = MultipartField.of(null) - private var checks: MultipartField = MultipartField.of(null) - private var customCoordinates: MultipartField = MultipartField.of(null) - private var customMetadata: MultipartField = MultipartField.of(null) - private var description: MultipartField = MultipartField.of(null) - private var expire: MultipartField = MultipartField.of(null) - private var extensions: MultipartField>? = null - private var folder: MultipartField = MultipartField.of(null) - private var isPrivateFile: MultipartField = MultipartField.of(null) - private var isPublished: MultipartField = MultipartField.of(null) - private var overwriteAiTags: MultipartField = MultipartField.of(null) - private var overwriteCustomMetadata: MultipartField = - MultipartField.of(null) - private var overwriteFile: MultipartField = MultipartField.of(null) - private var overwriteTags: MultipartField = MultipartField.of(null) - private var publicKey: MultipartField = MultipartField.of(null) - private var responseFields: MultipartField>? = null - private var signature: MultipartField = MultipartField.of(null) - private var tags: MultipartField>? = null - private var transformation: MultipartField = MultipartField.of(null) - private var useUniqueFileName: MultipartField = MultipartField.of(null) - private var webhookUrl: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = mutableMapOf() + fun validate(): RemoveBg = apply { + if (validated) { + return@apply + } - @JvmSynthetic - internal fun from(fileUploadByUrlv1: FileUploadByUrlv1) = apply { - file = fileUploadByUrlv1.file - fileName = fileUploadByUrlv1.fileName - token = fileUploadByUrlv1.token - checks = fileUploadByUrlv1.checks - customCoordinates = fileUploadByUrlv1.customCoordinates - customMetadata = fileUploadByUrlv1.customMetadata - description = fileUploadByUrlv1.description - expire = fileUploadByUrlv1.expire - extensions = fileUploadByUrlv1.extensions.map { it.toMutableList() } - folder = fileUploadByUrlv1.folder - isPrivateFile = fileUploadByUrlv1.isPrivateFile - isPublished = fileUploadByUrlv1.isPublished - overwriteAiTags = fileUploadByUrlv1.overwriteAiTags - overwriteCustomMetadata = fileUploadByUrlv1.overwriteCustomMetadata - overwriteFile = fileUploadByUrlv1.overwriteFile - overwriteTags = fileUploadByUrlv1.overwriteTags - publicKey = fileUploadByUrlv1.publicKey - responseFields = fileUploadByUrlv1.responseFields.map { it.toMutableList() } - signature = fileUploadByUrlv1.signature - tags = fileUploadByUrlv1.tags.map { it.toMutableList() } - transformation = fileUploadByUrlv1.transformation - useUniqueFileName = fileUploadByUrlv1.useUniqueFileName - webhookUrl = fileUploadByUrlv1.webhookUrl - additionalProperties = fileUploadByUrlv1.additionalProperties.toMutableMap() + _name().let { + if (it != JsonValue.from("remove-bg")) { + throw ImageKitInvalidDataException("'name' is invalid, received $it") + } + } + options().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false } - /** - * The URL of the file to upload. A publicly reachable URL that ImageKit servers can - * fetch. The server must receive the response headers within 8 seconds; otherwise - * the request fails with 400 Bad Request. - */ - fun file(file: String) = file(MultipartField.of(file)) + class Options + private constructor( + private val addShadow: MultipartField, + private val bgColor: MultipartField, + private val bgImageUrl: MultipartField, + private val semitransparency: MultipartField, + private val additionalProperties: MutableMap, + ) { /** - * Sets [Builder.file] to an arbitrary multipart value. + * Whether to add an artificial shadow to the result. Default is false. Note: Adding + * shadows is currently only supported for car photos. * - * You should usually call [Builder.file] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun file(file: MultipartField) = apply { this.file = file } + fun addShadow(): Optional = addShadow.value.getOptional("add_shadow") /** - * The name with which the file has to be uploaded. The file name can contain: - * - Alphanumeric Characters: `a-z`, `A-Z`, `0-9`. - * - Special Characters: `.`, `-` + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or + * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be + * empty. * - * Any other character including space will be replaced by `_` + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun fileName(fileName: String) = fileName(MultipartField.of(fileName)) + fun bgColor(): Optional = bgColor.value.getOptional("bg_color") /** - * Sets [Builder.fileName] to an arbitrary multipart value. + * Sets a background image from a URL. If this parameter is set, `bg_color` must be + * empty. * - * You should usually call [Builder.fileName] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun fileName(fileName: MultipartField) = apply { this.fileName = fileName } + fun bgImageUrl(): Optional = bgImageUrl.value.getOptional("bg_image_url") /** - * A unique value that the ImageKit.io server will use to recognize and prevent - * subsequent retries for the same request. We suggest using V4 UUIDs, or another - * random string with enough entropy to avoid collisions. This field is only - * required for authentication when uploading a file from the client side. + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. * - * **Note**: Sending a value that has been used in the past will result in a - * validation error. Even if your previous request resulted in an error, you should - * always send a new value for this field. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun token(token: String) = token(MultipartField.of(token)) + fun semitransparency(): Optional = + semitransparency.value.getOptional("semitransparency") /** - * Sets [Builder.token] to an arbitrary multipart value. + * Returns the raw multipart value of [addShadow]. * - * You should usually call [Builder.token] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun token(token: MultipartField) = apply { this.token = token } - - /** - * Server-side checks to run on the asset. Read more about - * [Upload API checks](/docs/api-reference/upload-file/upload-file#upload-api-checks). + * Unlike [addShadow], this method doesn't throw if the multipart field has an + * unexpected type. */ - fun checks(checks: String) = checks(MultipartField.of(checks)) + @JsonProperty("add_shadow") + @ExcludeMissing + fun _addShadow(): MultipartField = addShadow /** - * Sets [Builder.checks] to an arbitrary multipart value. + * Returns the raw multipart value of [bgColor]. * - * You should usually call [Builder.checks] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * Unlike [bgColor], this method doesn't throw if the multipart field has an + * unexpected type. */ - fun checks(checks: MultipartField) = apply { this.checks = checks } + @JsonProperty("bg_color") + @ExcludeMissing + fun _bgColor(): MultipartField = bgColor /** - * Define an important area in the image. This is only relevant for image type - * files. - * - To be passed as a string with the x and y coordinates of the top-left corner, - * and width and height of the area of interest in the format `x,y,width,height`. - * For example - `10,10,100,100` - * - Can be used with fo-customtransformation. - * - If this field is not specified and the file is overwritten, then - * customCoordinates will be removed. + * Returns the raw multipart value of [bgImageUrl]. + * + * Unlike [bgImageUrl], this method doesn't throw if the multipart field has an + * unexpected type. */ - fun customCoordinates(customCoordinates: String) = - customCoordinates(MultipartField.of(customCoordinates)) + @JsonProperty("bg_image_url") + @ExcludeMissing + fun _bgImageUrl(): MultipartField = bgImageUrl /** - * Sets [Builder.customCoordinates] to an arbitrary multipart value. + * Returns the raw multipart value of [semitransparency]. * - * You should usually call [Builder.customCoordinates] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * Unlike [semitransparency], this method doesn't throw if the multipart field has + * an unexpected type. */ - fun customCoordinates(customCoordinates: MultipartField) = apply { - this.customCoordinates = customCoordinates + @JsonProperty("semitransparency") + @ExcludeMissing + fun _semitransparency(): MultipartField = semitransparency + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** - * JSON key-value pairs to associate with the asset. Create the custom metadata - * fields before setting these values. - */ - fun customMetadata(customMetadata: CustomMetadata) = - customMetadata(MultipartField.of(customMetadata)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Sets [Builder.customMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.customMetadata] with a well-typed - * [CustomMetadata] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun customMetadata(customMetadata: MultipartField) = apply { - this.customMetadata = customMetadata - } + fun toBuilder() = Builder().from(this) - /** Optional text to describe the contents of the file. */ - fun description(description: String) = description(MultipartField.of(description)) + companion object { - /** - * Sets [Builder.description] to an arbitrary multipart 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: MultipartField) = apply { - this.description = description + /** Returns a mutable builder for constructing an instance of [Options]. */ + @JvmStatic fun builder() = Builder() } - /** - * The time until your signature is valid. It must be a - * [Unix time](https://en.wikipedia.org/wiki/Unix_time) in less than 1 hour into the - * future. It should be in seconds. This field is only required for authentication - * when uploading a file from the client side. - */ - fun expire(expire: Long) = expire(MultipartField.of(expire)) + /** A builder for [Options]. */ + class Builder internal constructor() { - /** - * Sets [Builder.expire] to an arbitrary multipart value. - * - * You should usually call [Builder.expire] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun expire(expire: MultipartField) = apply { this.expire = expire } + private var addShadow: MultipartField = MultipartField.of(null) + private var bgColor: MultipartField = MultipartField.of(null) + private var bgImageUrl: MultipartField = MultipartField.of(null) + private var semitransparency: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Array of extensions to be applied to the image. Each extension can be configured - * with specific parameters based on the extension type. - */ - fun extensions(extensions: List) = - extensions(MultipartField.of(extensions)) + @JvmSynthetic + internal fun from(options: Options) = apply { + addShadow = options.addShadow + bgColor = options.bgColor + bgImageUrl = options.bgImageUrl + semitransparency = options.semitransparency + additionalProperties = options.additionalProperties.toMutableMap() + } - /** - * Sets [Builder.extensions] to an arbitrary multipart value. - * - * You should usually call [Builder.extensions] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun extensions(extensions: MultipartField>) = apply { - this.extensions = extensions.map { it.toMutableList() } - } + /** + * Whether to add an artificial shadow to the result. Default is false. Note: + * Adding shadows is currently only supported for car photos. + */ + fun addShadow(addShadow: Boolean) = addShadow(MultipartField.of(addShadow)) - /** - * Adds a single [Extension] to [extensions]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addExtension(extension: Extension) = apply { - extensions = - (extensions ?: MultipartField.of(mutableListOf())).also { - checkKnown("extensions", it).add(extension) - } - } + /** + * Sets [Builder.addShadow] to an arbitrary multipart value. + * + * You should usually call [Builder.addShadow] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun addShadow(addShadow: MultipartField) = apply { + this.addShadow = addShadow + } - /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: Extension.RemoveBg) = - addExtension(Extension.ofRemoveBg(removeBg)) + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or + * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be + * empty. + */ + fun bgColor(bgColor: String) = bgColor(MultipartField.of(bgColor)) - /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: Extension.AutoTaggingExtension) = - addExtension(Extension.ofAutoTagging(autoTagging)) + /** + * Sets [Builder.bgColor] to an arbitrary multipart value. + * + * You should usually call [Builder.bgColor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun bgColor(bgColor: MultipartField) = apply { this.bgColor = bgColor } - /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ - fun addExtensionAiAutoDescription() = addExtension(Extension.ofAiAutoDescription()) + /** + * Sets a background image from a URL. If this parameter is set, `bg_color` must + * be empty. + */ + fun bgImageUrl(bgImageUrl: String) = bgImageUrl(MultipartField.of(bgImageUrl)) - /** - * The folder path in which the image has to be uploaded. If the folder(s) didn't - * exist before, a new folder(s) is created. - * - * The folder name can contain: - * - Alphanumeric Characters: `a-z` , `A-Z` , `0-9` - * - Special Characters: `/` , `_` , `-` - * - * Using multiple `/` creates a nested folder. - */ - fun folder(folder: String) = folder(MultipartField.of(folder)) + /** + * Sets [Builder.bgImageUrl] to an arbitrary multipart value. + * + * You should usually call [Builder.bgImageUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun bgImageUrl(bgImageUrl: MultipartField) = apply { + this.bgImageUrl = bgImageUrl + } - /** - * Sets [Builder.folder] to an arbitrary multipart value. - * - * You should usually call [Builder.folder] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun folder(folder: MultipartField) = apply { this.folder = folder } + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + */ + fun semitransparency(semitransparency: Boolean) = + semitransparency(MultipartField.of(semitransparency)) - /** - * Whether to mark the file as private or not. - * - * If `true`, the file is marked as private and is accessible only using named - * transformation or signed URL. - */ - fun isPrivateFile(isPrivateFile: Boolean) = - isPrivateFile(MultipartField.of(isPrivateFile)) + /** + * Sets [Builder.semitransparency] to an arbitrary multipart value. + * + * You should usually call [Builder.semitransparency] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun semitransparency(semitransparency: MultipartField) = apply { + this.semitransparency = semitransparency + } - /** - * Sets [Builder.isPrivateFile] to an arbitrary multipart value. - * - * You should usually call [Builder.isPrivateFile] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun isPrivateFile(isPrivateFile: MultipartField) = apply { - this.isPrivateFile = isPrivateFile - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Whether to upload file as published or not. - * - * If `false`, the file is marked as unpublished, which restricts access to the file - * only via the media library. Files in draft or unpublished state can only be - * publicly accessed after being published. - * - * The option to upload in draft state is only available in custom enterprise - * pricing plans. - */ - fun isPublished(isPublished: Boolean) = isPublished(MultipartField.of(isPublished)) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.isPublished] to an arbitrary multipart value. - * - * You should usually call [Builder.isPublished] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun isPublished(isPublished: MultipartField) = apply { - this.isPublished = isPublished + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Options]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Options = + Options( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties.toMutableMap(), + ) } - /** - * If set to `true` and a file already exists at the exact location, its AITags will - * be removed. Set `overwriteAITags` to `false` to preserve AITags. - */ - fun overwriteAiTags(overwriteAiTags: Boolean) = - overwriteAiTags(MultipartField.of(overwriteAiTags)) + private var validated: Boolean = false - /** - * Sets [Builder.overwriteAiTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteAiTags] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun overwriteAiTags(overwriteAiTags: MultipartField) = apply { - this.overwriteAiTags = overwriteAiTags + fun validate(): Options = apply { + if (validated) { + return@apply + } + + addShadow() + bgColor() + bgImageUrl() + semitransparency() + validated = true } - /** - * If the request does not have `customMetadata`, and a file already exists at the - * exact location, existing customMetadata will be removed. - */ - fun overwriteCustomMetadata(overwriteCustomMetadata: Boolean) = - overwriteCustomMetadata(MultipartField.of(overwriteCustomMetadata)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - /** - * Sets [Builder.overwriteCustomMetadata] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteCustomMetadata] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun overwriteCustomMetadata(overwriteCustomMetadata: MultipartField) = - apply { - this.overwriteCustomMetadata = overwriteCustomMetadata + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** - * If `false` and `useUniqueFileName` is also `false`, and a file already exists at - * the exact location, upload API will return an error immediately. - */ - fun overwriteFile(overwriteFile: Boolean) = - overwriteFile(MultipartField.of(overwriteFile)) + return other is Options && + addShadow == other.addShadow && + bgColor == other.bgColor && + bgImageUrl == other.bgImageUrl && + semitransparency == other.semitransparency && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.overwriteFile] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteFile] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun overwriteFile(overwriteFile: MultipartField) = apply { - this.overwriteFile = overwriteFile + private val hashCode: Int by lazy { + Objects.hash( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties, + ) } - /** - * If the request does not have `tags`, and a file already exists at the exact - * location, existing tags will be removed. - */ - fun overwriteTags(overwriteTags: Boolean) = - overwriteTags(MultipartField.of(overwriteTags)) + override fun hashCode(): Int = hashCode - /** - * Sets [Builder.overwriteTags] to an arbitrary multipart value. - * - * You should usually call [Builder.overwriteTags] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun overwriteTags(overwriteTags: MultipartField) = apply { - this.overwriteTags = overwriteTags + override fun toString() = + "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** - * Your ImageKit.io public key. This field is only required for authentication when - * uploading a file from the client side. - */ - fun publicKey(publicKey: String) = publicKey(MultipartField.of(publicKey)) + return other is RemoveBg && + name == other.name && + options == other.options && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.publicKey] to an arbitrary multipart value. - * - * You should usually call [Builder.publicKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun publicKey(publicKey: MultipartField) = apply { - this.publicKey = publicKey - } + private val hashCode: Int by lazy { Objects.hash(name, options, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" + } + + class AutoTaggingExtension + private constructor( + private val maxTags: MultipartField, + private val minConfidence: MultipartField, + private val name: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Maximum number of tags to attach to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun maxTags(): Long = maxTags.value.getRequired("maxTags") + + /** + * Minimum confidence level for tags to be considered valid. + * + * @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 minConfidence(): Long = minConfidence.value.getRequired("minConfidence") + + /** + * Specifies the auto-tagging extension used. + * + * @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(): Name = name.value.getRequired("name") + + /** + * Returns the raw multipart value of [maxTags]. + * + * Unlike [maxTags], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("maxTags") @ExcludeMissing fun _maxTags(): MultipartField = maxTags + + /** + * Returns the raw multipart value of [minConfidence]. + * + * Unlike [minConfidence], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("minConfidence") + @ExcludeMissing + fun _minConfidence(): MultipartField = minConfidence - /** Array of response field keys to include in the API response body. */ - fun responseFields(responseFields: List) = - responseFields(MultipartField.of(responseFields)) + /** + * Returns the raw multipart value of [name]. + * + * Unlike [name], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name - /** - * Sets [Builder.responseFields] to an arbitrary multipart value. - * - * You should usually call [Builder.responseFields] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun responseFields(responseFields: MultipartField>) = apply { - this.responseFields = responseFields.map { it.toMutableList() } - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Adds a single [ResponseField] to [responseFields]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addResponseField(responseField: ResponseField) = apply { - responseFields = - (responseFields ?: MultipartField.of(mutableListOf())).also { - checkKnown("responseFields", it).add(responseField) - } - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a - * key. Learn how to create a signature on the page below. This should be in - * lowercase. - * - * Signature must be calculated on the server-side. This field is only required for - * authentication when uploading a file from the client side. - */ - fun signature(signature: String) = signature(MultipartField.of(signature)) + fun toBuilder() = Builder().from(this) + + companion object { /** - * Sets [Builder.signature] to an arbitrary multipart value. + * Returns a mutable builder for constructing an instance of [AutoTaggingExtension]. * - * You should usually call [Builder.signature] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` */ - fun signature(signature: MultipartField) = apply { - this.signature = signature - } + @JvmStatic fun builder() = Builder() + } - /** - * Set the tags while uploading the file. Provide an array of tag strings (e.g. - * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not - * exceed 500, and the `%` character is not allowed. If this field is not specified - * and the file is overwritten, the existing tags will be removed. - */ - fun tags(tags: List) = tags(MultipartField.of(tags)) + /** A builder for [AutoTaggingExtension]. */ + class Builder internal constructor() { - /** - * Sets [Builder.tags] to an arbitrary multipart value. - * - * You should usually call [Builder.tags] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun tags(tags: MultipartField>) = apply { - this.tags = tags.map { it.toMutableList() } - } + private var maxTags: MultipartField? = null + private var minConfidence: MultipartField? = null + private var name: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Adds a single [String] to [tags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTag(tag: String) = apply { - tags = - (tags ?: MultipartField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } + @JvmSynthetic + internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { + maxTags = autoTaggingExtension.maxTags + minConfidence = autoTaggingExtension.minConfidence + name = autoTaggingExtension.name + additionalProperties = autoTaggingExtension.additionalProperties.toMutableMap() } - /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for - * reducing file size or applying basic optimizations upfront (e.g., resize, - * compress). - * - `post` — applied immediately after upload. Ideal for generating transformed - * versions (like video encodes or thumbnails) in advance, so they're ready for - * delivery without delay. - * - * You can mix and match any combination of post-processing types. - */ - fun transformation(transformation: Transformation) = - transformation(MultipartField.of(transformation)) + /** Maximum number of tags to attach to the asset. */ + fun maxTags(maxTags: Long) = maxTags(MultipartField.of(maxTags)) /** - * Sets [Builder.transformation] to an arbitrary multipart value. + * Sets [Builder.maxTags] to an arbitrary multipart value. * - * You should usually call [Builder.transformation] with a well-typed - * [Transformation] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.maxTags] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun transformation(transformation: MultipartField) = apply { - this.transformation = transformation - } + fun maxTags(maxTags: MultipartField) = apply { this.maxTags = maxTags } - /** - * Whether to use a unique filename for this file or not. - * - * If `true`, ImageKit.io will add a unique suffix to the filename parameter to get - * a unique filename. - * - * If `false`, then the image is uploaded with the provided filename parameter, and - * any existing file with the same name is replaced. - */ - fun useUniqueFileName(useUniqueFileName: Boolean) = - useUniqueFileName(MultipartField.of(useUniqueFileName)) + /** Minimum confidence level for tags to be considered valid. */ + fun minConfidence(minConfidence: Long) = + minConfidence(MultipartField.of(minConfidence)) /** - * Sets [Builder.useUniqueFileName] to an arbitrary multipart value. + * Sets [Builder.minConfidence] to an arbitrary multipart value. * - * You should usually call [Builder.useUniqueFileName] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * You should usually call [Builder.minConfidence] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun useUniqueFileName(useUniqueFileName: MultipartField) = apply { - this.useUniqueFileName = useUniqueFileName + fun minConfidence(minConfidence: MultipartField) = apply { + this.minConfidence = minConfidence } - /** - * The final status of extensions after they have completed execution will be - * delivered to this endpoint as a POST request. - * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - * about the webhook payload structure. - */ - fun webhookUrl(webhookUrl: String) = webhookUrl(MultipartField.of(webhookUrl)) + /** Specifies the auto-tagging extension used. */ + fun name(name: Name) = name(MultipartField.of(name)) /** - * Sets [Builder.webhookUrl] to an arbitrary multipart value. + * Sets [Builder.name] to an arbitrary multipart value. * - * You should usually call [Builder.webhookUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.name] with a well-typed [Name] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun webhookUrl(webhookUrl: MultipartField) = apply { - this.webhookUrl = webhookUrl - } + fun name(name: MultipartField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -5559,77 +3367,38 @@ private constructor( } /** - * Returns an immutable instance of [FileUploadByUrlv1]. + * Returns an immutable instance of [AutoTaggingExtension]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .file() - * .fileName() + * .maxTags() + * .minConfidence() + * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): FileUploadByUrlv1 = - FileUploadByUrlv1( - checkRequired("file", file), - checkRequired("fileName", fileName), - token, - checks, - customCoordinates, - customMetadata, - description, - expire, - (extensions ?: MultipartField.of(null)).map { it.toImmutable() }, - folder, - isPrivateFile, - isPublished, - overwriteAiTags, - overwriteCustomMetadata, - overwriteFile, - overwriteTags, - publicKey, - (responseFields ?: MultipartField.of(null)).map { it.toImmutable() }, - signature, - (tags ?: MultipartField.of(null)).map { it.toImmutable() }, - transformation, - useUniqueFileName, - webhookUrl, + fun build(): AutoTaggingExtension = + AutoTaggingExtension( + checkRequired("maxTags", maxTags), + checkRequired("minConfidence", minConfidence), + checkRequired("name", name), additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): FileUploadByUrlv1 = apply { + fun validate(): AutoTaggingExtension = apply { if (validated) { return@apply } - file() - fileName() - token() - checks() - customCoordinates() - customMetadata().ifPresent { it.validate() } - description() - expire() - extensions().ifPresent { it.forEach { it.validate() } } - folder() - isPrivateFile() - isPublished() - overwriteAiTags() - overwriteCustomMetadata() - overwriteFile() - overwriteTags() - publicKey() - responseFields().ifPresent { it.forEach { it.validate() } } - signature() - tags() - transformation().ifPresent { it.validate() } - useUniqueFileName() - webhookUrl() + maxTags() + minConfidence() + name().validate() validated = true } @@ -5641,176 +3410,105 @@ private constructor( false } - /** - * JSON key-value pairs to associate with the asset. Create the custom metadata fields - * before setting these values. - */ - class CustomMetadata - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** Specifies the auto-tagging extension used. */ + class Name @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - /** - * Returns a mutable builder for constructing an instance of [CustomMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customMetadata: CustomMetadata) = apply { - additionalProperties = customMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** An enum containing [Name]'s known values. */ + enum class Known { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + } + /** + * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Name] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, /** - * Returns an immutable instance of [CustomMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * An enum member indicating that [Name] was instantiated with an unknown value. */ - fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): CustomMetadata = apply { - if (validated) { - return@apply - } - - validated = true + _UNKNOWN, } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING + else -> Value._UNKNOWN } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING + else -> throw ImageKitInvalidDataException("Unknown Name: $value") } - return other is CustomMetadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CustomMetadata{additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = Extension.Deserializer::class) - @JsonSerialize(using = Extension.Serializer::class) - class Extension - private constructor( - private val removeBg: RemoveBg? = null, - private val autoTagging: AutoTaggingExtension? = null, - private val aiAutoDescription: JsonValue? = null, - private val _json: JsonValue? = null, - ) { - - fun removeBg(): Optional = Optional.ofNullable(removeBg) - - fun autoTagging(): Optional = Optional.ofNullable(autoTagging) - - fun aiAutoDescription(): Optional = - Optional.ofNullable(aiAutoDescription) - - fun isRemoveBg(): Boolean = removeBg != null - - fun isAutoTagging(): Boolean = autoTagging != null - - fun isAiAutoDescription(): Boolean = aiAutoDescription != null - - fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") - - fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") - - fun asAiAutoDescription(): JsonValue = - aiAutoDescription.getOrThrow("aiAutoDescription") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - removeBg != null -> visitor.visitRemoveBg(removeBg) - autoTagging != null -> visitor.visitAutoTagging(autoTagging) - aiAutoDescription != null -> - visitor.visitAiAutoDescription(aiAutoDescription) - else -> visitor.unknown(_json) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") } private var validated: Boolean = false - fun validate(): Extension = apply { + fun validate(): Name = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitRemoveBg(removeBg: RemoveBg) { - removeBg.validate() - } - - override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { - autoTagging.validate() - } - - override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { - aiAutoDescription.let { - if ( - it != JsonValue.from(mapOf("name" to "ai-auto-description")) - ) { - throw ImageKitInvalidDataException( - "'aiAutoDescription' is invalid, received $it" - ) - } - } - } - } - ) + known() validated = true } @@ -5827,1110 +3525,793 @@ private constructor( * recursively. * * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() - - override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = - autoTagging.validity() - - override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = - aiAutoDescription.let { - if ( - it == JsonValue.from(mapOf("name" to "ai-auto-description")) - ) - 1 - else 0 - } - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Extension && - removeBg == other.removeBg && - autoTagging == other.autoTagging && - aiAutoDescription == other.aiAutoDescription - } - - override fun hashCode(): Int = - Objects.hash(removeBg, autoTagging, aiAutoDescription) - - override fun toString(): String = - when { - removeBg != null -> "Extension{removeBg=$removeBg}" - autoTagging != null -> "Extension{autoTagging=$autoTagging}" - aiAutoDescription != null -> - "Extension{aiAutoDescription=$aiAutoDescription}" - _json != null -> "Extension{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Extension") - } - - companion object { - - @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = Extension(removeBg = removeBg) - - @JvmStatic - fun ofAutoTagging(autoTagging: AutoTaggingExtension) = - Extension(autoTagging = autoTagging) - - @JvmStatic - fun ofAiAutoDescription() = - Extension( - aiAutoDescription = - JsonValue.from(mapOf("name" to "ai-auto-description")) - ) - } - - /** - * An interface that defines how to map each variant of [Extension] to a value of - * type [T]. - */ - interface Visitor { - - fun visitRemoveBg(removeBg: RemoveBg): T - - fun visitAutoTagging(autoTagging: AutoTaggingExtension): T - - fun visitAiAutoDescription(aiAutoDescription: JsonValue): T - - /** - * Maps an unknown variant of [Extension] to a value of type [T]. - * - * An instance of [Extension] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Extension: $json") - } - } - - internal class Deserializer : BaseDeserializer(Extension::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Extension { - val json = JsonValue.fromJsonNode(node) - val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() - - when (name) { - "remove-bg" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Extension(removeBg = it, _json = json) - } ?: Extension(_json = json) - } - "ai-auto-description" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Extension(aiAutoDescription = it, _json = json) } - ?.takeIf { it.isValid() } ?: Extension(_json = json) - } - } + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - return tryDeserialize(node, jacksonTypeRef())?.let { - Extension(autoTagging = it, _json = json) - } ?: Extension(_json = json) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - } - internal class Serializer : BaseSerializer(Extension::class) { - - override fun serialize( - value: Extension, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.removeBg != null -> generator.writeObject(value.removeBg) - value.autoTagging != null -> generator.writeObject(value.autoTagging) - value.aiAutoDescription != null -> - generator.writeObject(value.aiAutoDescription) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Extension") - } - } + return other is Name && value == other.value } - class RemoveBg - private constructor( - private val name: JsonValue, - private val options: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Specifies the background removal extension. - * - * Expected to always return the following: - * ```java - * JsonValue.from("remove-bg") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + override fun hashCode() = value.hashCode() - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun options(): Optional = options.value.getOptional("options") + override fun toString() = value.toString() + } - /** - * Returns the raw multipart value of [options]. - * - * Unlike [options], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("options") - @ExcludeMissing - fun _options(): MultipartField = options + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + return other is AutoTaggingExtension && + maxTags == other.maxTags && + minConfidence == other.minConfidence && + name == other.name && + additionalProperties == other.additionalProperties + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + private val hashCode: Int by lazy { + Objects.hash(maxTags, minConfidence, name, additionalProperties) + } - fun toBuilder() = Builder().from(this) + override fun hashCode(): Int = hashCode - companion object { + override fun toString() = + "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" + } + } - /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ - @JvmStatic fun builder() = Builder() - } + class ResponseField @JsonCreator private constructor(private val value: JsonField) : + Enum { - /** A builder for [RemoveBg]. */ - class Builder internal constructor() { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - private var name: JsonValue = JsonValue.from("remove-bg") - private var options: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = - mutableMapOf() + companion object { - @JvmSynthetic - internal fun from(removeBg: RemoveBg) = apply { - name = removeBg.name - options = removeBg.options - additionalProperties = removeBg.additionalProperties.toMutableMap() - } + @JvmField val TAGS = of("tags") - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults - * to the following: - * ```java - * JsonValue.from("remove-bg") - * ``` - * - * This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun name(name: JsonValue) = apply { this.name = name } + @JvmField val CUSTOM_COORDINATES = of("customCoordinates") - fun options(options: Options) = options(MultipartField.of(options)) + @JvmField val IS_PRIVATE_FILE = of("isPrivateFile") - /** - * Sets [Builder.options] to an arbitrary multipart value. - * - * You should usually call [Builder.options] with a well-typed [Options] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun options(options: MultipartField) = apply { - this.options = options - } + @JvmField val EMBEDDED_METADATA = of("embeddedMetadata") - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmField val IS_PUBLISHED = of("isPublished") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmField val CUSTOM_METADATA = of("customMetadata") - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + @JvmField val METADATA = of("metadata") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmStatic fun of(value: String) = ResponseField(JsonField.of(value)) + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** An enum containing [ResponseField]'s known values. */ + enum class Known { + TAGS, + CUSTOM_COORDINATES, + IS_PRIVATE_FILE, + EMBEDDED_METADATA, + IS_PUBLISHED, + CUSTOM_METADATA, + METADATA, + } - /** - * Returns an immutable instance of [RemoveBg]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemoveBg = - RemoveBg(name, options, additionalProperties.toMutableMap()) - } + /** + * An enum containing [ResponseField]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ResponseField] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TAGS, + CUSTOM_COORDINATES, + IS_PRIVATE_FILE, + EMBEDDED_METADATA, + IS_PUBLISHED, + CUSTOM_METADATA, + METADATA, + /** + * An enum member indicating that [ResponseField] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - private var validated: Boolean = false + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TAGS -> Value.TAGS + CUSTOM_COORDINATES -> Value.CUSTOM_COORDINATES + IS_PRIVATE_FILE -> Value.IS_PRIVATE_FILE + EMBEDDED_METADATA -> Value.EMBEDDED_METADATA + IS_PUBLISHED -> Value.IS_PUBLISHED + CUSTOM_METADATA -> Value.CUSTOM_METADATA + METADATA -> Value.METADATA + else -> Value._UNKNOWN + } - fun validate(): RemoveBg = apply { - if (validated) { - return@apply - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TAGS -> Known.TAGS + CUSTOM_COORDINATES -> Known.CUSTOM_COORDINATES + IS_PRIVATE_FILE -> Known.IS_PRIVATE_FILE + EMBEDDED_METADATA -> Known.EMBEDDED_METADATA + IS_PUBLISHED -> Known.IS_PUBLISHED + CUSTOM_METADATA -> Known.CUSTOM_METADATA + METADATA -> Known.METADATA + else -> throw ImageKitInvalidDataException("Unknown ResponseField: $value") + } - _name().let { - if (it != JsonValue.from("remove-bg")) { - throw ImageKitInvalidDataException( - "'name' is invalid, received $it" - ) - } - } - options().ifPresent { it.validate() } - validated = true - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + private var validated: Boolean = false - class Options - private constructor( - private val addShadow: MultipartField, - private val bgColor: MultipartField, - private val bgImageUrl: MultipartField, - private val semitransparency: MultipartField, - private val additionalProperties: MutableMap, - ) { + fun validate(): ResponseField = apply { + if (validated) { + return@apply + } - /** - * Whether to add an artificial shadow to the result. Default is false. - * Note: Adding shadows is currently only supported for car photos. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun addShadow(): Optional = - addShadow.value.getOptional("add_shadow") + known() + validated = true + } - /** - * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") - * or color name (e.g., "green"). If this parameter is set, `bg_image_url` - * must be empty. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun bgColor(): Optional = bgColor.value.getOptional("bg_color") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - /** - * Sets a background image from a URL. If this parameter is set, `bg_color` - * must be empty. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun bgImageUrl(): Optional = - bgImageUrl.value.getOptional("bg_image_url") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - /** - * Allows semi-transparent regions in the result. Default is true. Note: - * Semitransparency is currently only supported for car windows. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun semitransparency(): Optional = - semitransparency.value.getOptional("semitransparency") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw multipart value of [addShadow]. - * - * Unlike [addShadow], this method doesn't throw if the multipart field has - * an unexpected type. - */ - @JsonProperty("add_shadow") - @ExcludeMissing - fun _addShadow(): MultipartField = addShadow + return other is ResponseField && value == other.value + } - /** - * Returns the raw multipart value of [bgColor]. - * - * Unlike [bgColor], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("bg_color") - @ExcludeMissing - fun _bgColor(): MultipartField = bgColor + override fun hashCode() = value.hashCode() - /** - * Returns the raw multipart value of [bgImageUrl]. - * - * Unlike [bgImageUrl], this method doesn't throw if the multipart field has - * an unexpected type. - */ - @JsonProperty("bg_image_url") - @ExcludeMissing - fun _bgImageUrl(): MultipartField = bgImageUrl + override fun toString() = value.toString() + } - /** - * Returns the raw multipart value of [semitransparency]. - * - * Unlike [semitransparency], this method doesn't throw if the multipart - * field has an unexpected type. - */ - @JsonProperty("semitransparency") - @ExcludeMissing - fun _semitransparency(): MultipartField = semitransparency + /** + * Configure pre-processing (`pre`) and post-processing (`post`) transformations. + * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing file + * size or applying basic optimizations upfront (e.g., resize, compress). + * - `post` — applied immediately after upload. Ideal for generating transformed versions (like + * video encodes or thumbnails) in advance, so they're ready for delivery without delay. + * + * You can mix and match any combination of post-processing types. + */ + class Transformation + private constructor( + private val post: MultipartField>, + private val pre: MultipartField, + private val additionalProperties: MutableMap, + ) { - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * List of transformations to apply _after_ the file is uploaded. Each item must match one + * of the following types: `transformation`, `gif-to-video`, `thumbnail`, `abs`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun post(): Optional> = post.value.getOptional("post") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Transformation string to apply before uploading the file to the Media Library. Useful for + * optimizing files at ingestion. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun pre(): Optional = pre.value.getOptional("pre") - fun toBuilder() = Builder().from(this) + /** + * Returns the raw multipart value of [post]. + * + * Unlike [post], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("post") @ExcludeMissing fun _post(): MultipartField> = post - companion object { + /** + * Returns the raw multipart value of [pre]. + * + * Unlike [pre], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("pre") @ExcludeMissing fun _pre(): MultipartField = pre - /** - * Returns a mutable builder for constructing an instance of [Options]. - */ - @JvmStatic fun builder() = Builder() - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** A builder for [Options]. */ - class Builder internal constructor() { - - private var addShadow: MultipartField = MultipartField.of(null) - private var bgColor: MultipartField = MultipartField.of(null) - private var bgImageUrl: MultipartField = MultipartField.of(null) - private var semitransparency: MultipartField = - MultipartField.of(null) - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(options: Options) = apply { - addShadow = options.addShadow - bgColor = options.bgColor - bgImageUrl = options.bgImageUrl - semitransparency = options.semitransparency - additionalProperties = options.additionalProperties.toMutableMap() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Whether to add an artificial shadow to the result. Default is false. - * Note: Adding shadows is currently only supported for car photos. - */ - fun addShadow(addShadow: Boolean) = - addShadow(MultipartField.of(addShadow)) - - /** - * Sets [Builder.addShadow] to an arbitrary multipart value. - * - * You should usually call [Builder.addShadow] with a well-typed - * [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun addShadow(addShadow: MultipartField) = apply { - this.addShadow = addShadow - } + fun toBuilder() = Builder().from(this) - /** - * Specifies a solid color background using hex code (e.g., "81d4fa", - * "fff") or color name (e.g., "green"). If this parameter is set, - * `bg_image_url` must be empty. - */ - fun bgColor(bgColor: String) = bgColor(MultipartField.of(bgColor)) - - /** - * Sets [Builder.bgColor] to an arbitrary multipart value. - * - * You should usually call [Builder.bgColor] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun bgColor(bgColor: MultipartField) = apply { - this.bgColor = bgColor - } + companion object { - /** - * Sets a background image from a URL. If this parameter is set, - * `bg_color` must be empty. - */ - fun bgImageUrl(bgImageUrl: String) = - bgImageUrl(MultipartField.of(bgImageUrl)) - - /** - * Sets [Builder.bgImageUrl] to an arbitrary multipart value. - * - * You should usually call [Builder.bgImageUrl] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun bgImageUrl(bgImageUrl: MultipartField) = apply { - this.bgImageUrl = bgImageUrl - } + /** Returns a mutable builder for constructing an instance of [Transformation]. */ + @JvmStatic fun builder() = Builder() + } - /** - * Allows semi-transparent regions in the result. Default is true. Note: - * Semitransparency is currently only supported for car windows. - */ - fun semitransparency(semitransparency: Boolean) = - semitransparency(MultipartField.of(semitransparency)) - - /** - * Sets [Builder.semitransparency] to an arbitrary multipart value. - * - * You should usually call [Builder.semitransparency] with a well-typed - * [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun semitransparency(semitransparency: MultipartField) = - apply { - this.semitransparency = semitransparency - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** A builder for [Transformation]. */ + class Builder internal constructor() { - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + private var post: MultipartField>? = null + private var pre: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmSynthetic + internal fun from(transformation: Transformation) = apply { + post = transformation.post.map { it.toMutableList() } + pre = transformation.pre + additionalProperties = transformation.additionalProperties.toMutableMap() + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * List of transformations to apply _after_ the file is uploaded. Each item must match + * one of the following types: `transformation`, `gif-to-video`, `thumbnail`, `abs`. + */ + fun post(post: List) = post(MultipartField.of(post)) - /** - * Returns an immutable instance of [Options]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): Options = - Options( - addShadow, - bgColor, - bgImageUrl, - semitransparency, - additionalProperties.toMutableMap(), - ) - } + /** + * Sets [Builder.post] to an arbitrary multipart value. + * + * You should usually call [Builder.post] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun post(post: MultipartField>) = apply { + this.post = post.map { it.toMutableList() } + } - private var validated: Boolean = false + /** + * Adds a single [Post] to [Builder.post]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPost(post: Post) = apply { + this.post = + (this.post ?: MultipartField.of(mutableListOf())).also { + checkKnown("post", it).add(post) + } + } - fun validate(): Options = apply { - if (validated) { - return@apply - } + /** Alias for calling [addPost] with `Post.ofTransformation(transformation)`. */ + fun addPost(transformation: Post.InnerTransformation) = + addPost(Post.ofTransformation(transformation)) - addShadow() - bgColor() - bgImageUrl() - semitransparency() - validated = true - } + /** + * Alias for calling [addPost] with the following: + * ```java + * Post.InnerTransformation.builder() + * .value(value) + * .build() + * ``` + */ + fun addTransformationPost(value: String) = + addPost(Post.InnerTransformation.builder().value(value).build()) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + /** Alias for calling [addPost] with `Post.ofGifToVideo(gifToVideo)`. */ + fun addPost(gifToVideo: Post.GifToVideo) = addPost(Post.ofGifToVideo(gifToVideo)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** Alias for calling [addPost] with `Post.ofThumbnail(thumbnail)`. */ + fun addPost(thumbnail: Post.Thumbnail) = addPost(Post.ofThumbnail(thumbnail)) - return other is Options && - addShadow == other.addShadow && - bgColor == other.bgColor && - bgImageUrl == other.bgImageUrl && - semitransparency == other.semitransparency && - additionalProperties == other.additionalProperties - } + /** Alias for calling [addPost] with `Post.ofAbs(abs)`. */ + fun addPost(abs: Post.Abs) = addPost(Post.ofAbs(abs)) - private val hashCode: Int by lazy { - Objects.hash( - addShadow, - bgColor, - bgImageUrl, - semitransparency, - additionalProperties, - ) - } + /** + * Transformation string to apply before uploading the file to the Media Library. Useful + * for optimizing files at ingestion. + */ + fun pre(pre: String) = pre(MultipartField.of(pre)) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.pre] to an arbitrary multipart value. + * + * You should usually call [Builder.pre] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pre(pre: MultipartField) = apply { this.pre = pre } - override fun toString() = - "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return other is RemoveBg && - name == other.name && - options == other.options && - additionalProperties == other.additionalProperties - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - private val hashCode: Int by lazy { - Objects.hash(name, options, additionalProperties) - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" - } + /** + * Returns an immutable instance of [Transformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Transformation = + Transformation( + (post ?: MultipartField.of(null)).map { it.toImmutable() }, + pre, + additionalProperties.toMutableMap(), + ) + } - class AutoTaggingExtension - private constructor( - private val maxTags: MultipartField, - private val minConfidence: MultipartField, - private val name: MultipartField, - private val additionalProperties: MutableMap, - ) { + private var validated: Boolean = false - /** - * Maximum number of tags to attach to the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun maxTags(): Long = maxTags.value.getRequired("maxTags") + fun validate(): Transformation = apply { + if (validated) { + return@apply + } - /** - * Minimum confidence level for tags to be considered valid. - * - * @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 minConfidence(): Long = minConfidence.value.getRequired("minConfidence") + post().ifPresent { it.forEach { it.validate() } } + pre() + validated = true + } - /** - * Specifies the auto-tagging extension used. - * - * @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(): Name = name.value.getRequired("name") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - /** - * Returns the raw multipart value of [maxTags]. - * - * Unlike [maxTags], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("maxTags") - @ExcludeMissing - fun _maxTags(): MultipartField = maxTags + @JsonDeserialize(using = Post.Deserializer::class) + @JsonSerialize(using = Post.Serializer::class) + class Post + private constructor( + private val transformation: InnerTransformation? = null, + private val gifToVideo: GifToVideo? = null, + private val thumbnail: Thumbnail? = null, + private val abs: Abs? = null, + private val _json: JsonValue? = null, + ) { - /** - * Returns the raw multipart value of [minConfidence]. - * - * Unlike [minConfidence], this method doesn't throw if the multipart field has - * an unexpected type. - */ - @JsonProperty("minConfidence") - @ExcludeMissing - fun _minConfidence(): MultipartField = minConfidence + fun transformation(): Optional = + Optional.ofNullable(transformation) - /** - * Returns the raw multipart value of [name]. - * - * Unlike [name], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name + fun gifToVideo(): Optional = Optional.ofNullable(gifToVideo) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun thumbnail(): Optional = Optional.ofNullable(thumbnail) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun abs(): Optional = Optional.ofNullable(abs) - fun toBuilder() = Builder().from(this) + fun isTransformation(): Boolean = transformation != null - companion object { + fun isGifToVideo(): Boolean = gifToVideo != null - /** - * Returns a mutable builder for constructing an instance of - * [AutoTaggingExtension]. - * - * The following fields are required: - * ```java - * .maxTags() - * .minConfidence() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } + fun isThumbnail(): Boolean = thumbnail != null - /** A builder for [AutoTaggingExtension]. */ - class Builder internal constructor() { - - private var maxTags: MultipartField? = null - private var minConfidence: MultipartField? = null - private var name: MultipartField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { - maxTags = autoTaggingExtension.maxTags - minConfidence = autoTaggingExtension.minConfidence - name = autoTaggingExtension.name - additionalProperties = - autoTaggingExtension.additionalProperties.toMutableMap() - } + fun isAbs(): Boolean = abs != null - /** Maximum number of tags to attach to the asset. */ - fun maxTags(maxTags: Long) = maxTags(MultipartField.of(maxTags)) + fun asTransformation(): InnerTransformation = + transformation.getOrThrow("transformation") - /** - * Sets [Builder.maxTags] to an arbitrary multipart value. - * - * You should usually call [Builder.maxTags] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun maxTags(maxTags: MultipartField) = apply { - this.maxTags = maxTags - } + fun asGifToVideo(): GifToVideo = gifToVideo.getOrThrow("gifToVideo") - /** Minimum confidence level for tags to be considered valid. */ - fun minConfidence(minConfidence: Long) = - minConfidence(MultipartField.of(minConfidence)) + fun asThumbnail(): Thumbnail = thumbnail.getOrThrow("thumbnail") - /** - * Sets [Builder.minConfidence] to an arbitrary multipart value. - * - * You should usually call [Builder.minConfidence] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun minConfidence(minConfidence: MultipartField) = apply { - this.minConfidence = minConfidence - } + fun asAbs(): Abs = abs.getOrThrow("abs") - /** Specifies the auto-tagging extension used. */ - fun name(name: Name) = name(MultipartField.of(name)) + fun _json(): Optional = Optional.ofNullable(_json) - /** - * Sets [Builder.name] to an arbitrary multipart value. - * - * You should usually call [Builder.name] with a well-typed [Name] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun name(name: MultipartField) = apply { this.name = name } + fun accept(visitor: Visitor): T = + when { + transformation != null -> visitor.visitTransformation(transformation) + gifToVideo != null -> visitor.visitGifToVideo(gifToVideo) + thumbnail != null -> visitor.visitThumbnail(thumbnail) + abs != null -> visitor.visitAbs(abs) + else -> visitor.unknown(_json) + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + private var validated: Boolean = false - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun validate(): Post = apply { + if (validated) { + return@apply + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + accept( + object : Visitor { + override fun visitTransformation(transformation: InnerTransformation) { + transformation.validate() + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + override fun visitGifToVideo(gifToVideo: GifToVideo) { + gifToVideo.validate() } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + override fun visitThumbnail(thumbnail: Thumbnail) { + thumbnail.validate() } - /** - * Returns an immutable instance of [AutoTaggingExtension]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .maxTags() - * .minConfidence() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AutoTaggingExtension = - AutoTaggingExtension( - checkRequired("maxTags", maxTags), - checkRequired("minConfidence", minConfidence), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) + override fun visitAbs(abs: Abs) { + abs.validate() + } } + ) + validated = true + } - private var validated: Boolean = false - - fun validate(): AutoTaggingExtension = apply { - if (validated) { - return@apply - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - maxTags() - minConfidence() - name().validate() - validated = true - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitTransformation(transformation: InnerTransformation) = + transformation.validity() - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + override fun visitGifToVideo(gifToVideo: GifToVideo) = gifToVideo.validity() - /** Specifies the auto-tagging extension used. */ - class Name - @JsonCreator - private constructor(private val value: JsonField) : Enum { + override fun visitThumbnail(thumbnail: Thumbnail) = thumbnail.validity() - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + override fun visitAbs(abs: Abs) = abs.validity() - companion object { + override fun unknown(json: JsonValue?) = 0 + } + ) - @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") + return other is Post && + transformation == other.transformation && + gifToVideo == other.gifToVideo && + thumbnail == other.thumbnail && + abs == other.abs + } - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } + override fun hashCode(): Int = Objects.hash(transformation, gifToVideo, thumbnail, abs) - /** An enum containing [Name]'s known values. */ - enum class Known { - GOOGLE_AUTO_TAGGING, - AWS_AUTO_TAGGING, - } + override fun toString(): String = + when { + transformation != null -> "Post{transformation=$transformation}" + gifToVideo != null -> "Post{gifToVideo=$gifToVideo}" + thumbnail != null -> "Post{thumbnail=$thumbnail}" + abs != null -> "Post{abs=$abs}" + _json != null -> "Post{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Post") + } - /** - * An enum containing [Name]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Name] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GOOGLE_AUTO_TAGGING, - AWS_AUTO_TAGGING, - /** - * An enum member indicating that [Name] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + companion object { - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING - AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING - else -> Value._UNKNOWN - } + @JvmStatic + fun ofTransformation(transformation: InnerTransformation) = + Post(transformation = transformation) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value is a - * not a known member. - */ - fun known(): Known = - when (this) { - GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING - AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING - else -> throw ImageKitInvalidDataException("Unknown Name: $value") - } + @JvmStatic fun ofGifToVideo(gifToVideo: GifToVideo) = Post(gifToVideo = gifToVideo) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value does - * not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") - } + @JvmStatic fun ofThumbnail(thumbnail: Thumbnail) = Post(thumbnail = thumbnail) - private var validated: Boolean = false + @JvmStatic fun ofAbs(abs: Abs) = Post(abs = abs) + } - fun validate(): Name = apply { - if (validated) { - return@apply - } + /** + * An interface that defines how to map each variant of [Post] to a value of type [T]. + */ + interface Visitor { - known() - validated = true - } + fun visitTransformation(transformation: InnerTransformation): T - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + fun visitGifToVideo(gifToVideo: GifToVideo): T - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun visitThumbnail(thumbnail: Thumbnail): T - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun visitAbs(abs: Abs): T - return other is Name && value == other.value - } + /** + * Maps an unknown variant of [Post] to a value of type [T]. + * + * An instance of [Post] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Post: $json") + } + } - override fun hashCode() = value.hashCode() + internal class Deserializer : BaseDeserializer(Post::class) { - override fun toString() = value.toString() - } + override fun ObjectCodec.deserialize(node: JsonNode): Post { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + when (type) { + "transformation" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Post(transformation = it, _json = json) } + ?: Post(_json = json) + } + "gif-to-video" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(gifToVideo = it, _json = json) + } ?: Post(_json = json) + } + "thumbnail" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(thumbnail = it, _json = json) + } ?: Post(_json = json) + } + "abs" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Post(abs = it, _json = json) + } ?: Post(_json = json) } - - return other is AutoTaggingExtension && - maxTags == other.maxTags && - minConfidence == other.minConfidence && - name == other.name && - additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(maxTags, minConfidence, name, additionalProperties) - } + return Post(_json = json) + } + } - override fun hashCode(): Int = hashCode + internal class Serializer : BaseSerializer(Post::class) { - override fun toString() = - "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" + override fun serialize( + value: Post, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.transformation != null -> generator.writeObject(value.transformation) + value.gifToVideo != null -> generator.writeObject(value.gifToVideo) + value.thumbnail != null -> generator.writeObject(value.thumbnail) + value.abs != null -> generator.writeObject(value.abs) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Post") + } } } - class ResponseField - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class InnerTransformation + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { /** - * Returns this class instance's raw value. + * Transformation type. * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * Expected to always return the following: + * ```java + * JsonValue.from("transformation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - companion object { + /** + * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based + * 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 value(): String = value.value.getRequired("value") + + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JvmField val TAGS = of("tags") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmField val CUSTOM_COORDINATES = of("customCoordinates") + fun toBuilder() = Builder().from(this) - @JvmField val IS_PRIVATE_FILE = of("isPrivateFile") + companion object { - @JvmField val EMBEDDED_METADATA = of("embeddedMetadata") + /** + * Returns a mutable builder for constructing an instance of + * [InnerTransformation]. + * + * The following fields are required: + * ```java + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - @JvmField val IS_PUBLISHED = of("isPublished") + /** A builder for [InnerTransformation]. */ + class Builder internal constructor() { - @JvmField val CUSTOM_METADATA = of("customMetadata") + private var type: JsonValue = JsonValue.from("transformation") + private var value: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() - @JvmField val METADATA = of("metadata") + @JvmSynthetic + internal fun from(innerTransformation: InnerTransformation) = apply { + type = innerTransformation.type + value = innerTransformation.value + additionalProperties = + innerTransformation.additionalProperties.toMutableMap() + } - @JvmStatic fun of(value: String) = ResponseField(JsonField.of(value)) - } + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("transformation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } - /** An enum containing [ResponseField]'s known values. */ - enum class Known { - TAGS, - CUSTOM_COORDINATES, - IS_PRIVATE_FILE, - EMBEDDED_METADATA, - IS_PUBLISHED, - CUSTOM_METADATA, - METADATA, - } + /** + * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit URL-based + * transformations. + */ + fun value(value: String) = value(MultipartField.of(value)) - /** - * An enum containing [ResponseField]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ResponseField] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TAGS, - CUSTOM_COORDINATES, - IS_PRIVATE_FILE, - EMBEDDED_METADATA, - IS_PUBLISHED, - CUSTOM_METADATA, - METADATA, /** - * An enum member indicating that [ResponseField] was instantiated with an - * unknown value. + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - _UNKNOWN, - } + fun value(value: MultipartField) = apply { this.value = value } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TAGS -> Value.TAGS - CUSTOM_COORDINATES -> Value.CUSTOM_COORDINATES - IS_PRIVATE_FILE -> Value.IS_PRIVATE_FILE - EMBEDDED_METADATA -> Value.EMBEDDED_METADATA - IS_PUBLISHED -> Value.IS_PUBLISHED - CUSTOM_METADATA -> Value.CUSTOM_METADATA - METADATA -> Value.METADATA - else -> Value._UNKNOWN + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TAGS -> Known.TAGS - CUSTOM_COORDINATES -> Known.CUSTOM_COORDINATES - IS_PRIVATE_FILE -> Known.IS_PRIVATE_FILE - EMBEDDED_METADATA -> Known.EMBEDDED_METADATA - IS_PUBLISHED -> Known.IS_PUBLISHED - CUSTOM_METADATA -> Known.CUSTOM_METADATA - METADATA -> Known.METADATA - else -> throw ImageKitInvalidDataException("Unknown ResponseField: $value") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [InnerTransformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InnerTransformation = + InnerTransformation( + type, + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false - fun validate(): ResponseField = apply { + fun validate(): InnerTransformation = apply { if (validated) { return@apply } - known() + _type().let { + if (it != JsonValue.from("transformation")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + value() validated = true } @@ -6942,79 +4323,62 @@ private constructor( false } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is ResponseField && value == other.value + return other is InnerTransformation && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } - /** - * Configure pre-processing (`pre`) and post-processing (`post`) transformations. - * - `pre` — applied before the file is uploaded to the Media Library. Useful for - * reducing file size or applying basic optimizations upfront (e.g., resize, - * compress). - * - `post` — applied immediately after upload. Ideal for generating transformed - * versions (like video encodes or thumbnails) in advance, so they're ready for - * delivery without delay. - * - * You can mix and match any combination of post-processing types. - */ - class Transformation + override fun hashCode(): Int = hashCode + + override fun toString() = + "InnerTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" + } + + class GifToVideo private constructor( - private val post: MultipartField>, - private val pre: MultipartField, + private val type: JsonValue, + private val value: MultipartField, private val additionalProperties: MutableMap, ) { /** - * List of transformations to apply _after_ the file is uploaded. Each item must - * match one of the following types: `transformation`, `gif-to-video`, `thumbnail`, - * `abs`. + * Converts an animated GIF into an MP4. * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("gif-to-video") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun post(): Optional> = post.value.getOptional("post") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** - * Transformation string to apply before uploading the file to the Media Library. - * Useful for optimizing files at ingestion. + * Optional transformation string to apply to the output video. **Example**: `q-80` * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun pre(): Optional = pre.value.getOptional("pre") - - /** - * Returns the raw multipart value of [post]. - * - * Unlike [post], this method doesn't throw if the multipart field has an unexpected - * type. - */ - @JsonProperty("post") @ExcludeMissing fun _post(): MultipartField> = post + fun value(): Optional = value.value.getOptional("value") /** - * Returns the raw multipart value of [pre]. + * Returns the raw multipart value of [value]. * - * Unlike [pre], this method doesn't throw if the multipart field has an unexpected - * type. + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. */ - @JsonProperty("pre") @ExcludeMissing fun _pre(): MultipartField = pre + @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -7030,95 +4394,52 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [Transformation]. - */ + /** Returns a mutable builder for constructing an instance of [GifToVideo]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Transformation]. */ + /** A builder for [GifToVideo]. */ class Builder internal constructor() { - private var post: MultipartField>? = null - private var pre: MultipartField = MultipartField.of(null) + private var type: JsonValue = JsonValue.from("gif-to-video") + private var value: MultipartField = MultipartField.of(null) private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(transformation: Transformation) = apply { - post = transformation.post.map { it.toMutableList() } - pre = transformation.pre - additionalProperties = transformation.additionalProperties.toMutableMap() + internal fun from(gifToVideo: GifToVideo) = apply { + type = gifToVideo.type + value = gifToVideo.value + additionalProperties = gifToVideo.additionalProperties.toMutableMap() } /** - * List of transformations to apply _after_ the file is uploaded. Each item must - * match one of the following types: `transformation`, `gif-to-video`, - * `thumbnail`, `abs`. - */ - fun post(post: List) = post(MultipartField.of(post)) - - /** - * Sets [Builder.post] to an arbitrary multipart value. - * - * You should usually call [Builder.post] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun post(post: MultipartField>) = apply { - this.post = post.map { it.toMutableList() } - } - - /** - * Adds a single [Post] to [Builder.post]. + * Sets the field to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPost(post: Post) = apply { - this.post = - (this.post ?: MultipartField.of(mutableListOf())).also { - checkKnown("post", it).add(post) - } - } - - /** Alias for calling [addPost] with `Post.ofTransformation(transformation)`. */ - fun addPost(transformation: Post.InnerTransformation) = - addPost(Post.ofTransformation(transformation)) - - /** - * Alias for calling [addPost] with the following: + * It is usually unnecessary to call this method because the field defaults to + * the following: * ```java - * Post.InnerTransformation.builder() - * .value(value) - * .build() + * JsonValue.from("gif-to-video") * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun addTransformationPost(value: String) = - addPost(Post.InnerTransformation.builder().value(value).build()) - - /** Alias for calling [addPost] with `Post.ofGifToVideo(gifToVideo)`. */ - fun addPost(gifToVideo: Post.GifToVideo) = - addPost(Post.ofGifToVideo(gifToVideo)) - - /** Alias for calling [addPost] with `Post.ofThumbnail(thumbnail)`. */ - fun addPost(thumbnail: Post.Thumbnail) = addPost(Post.ofThumbnail(thumbnail)) - - /** Alias for calling [addPost] with `Post.ofAbs(abs)`. */ - fun addPost(abs: Post.Abs) = addPost(Post.ofAbs(abs)) + fun type(type: JsonValue) = apply { this.type = type } /** - * Transformation string to apply before uploading the file to the Media - * Library. Useful for optimizing files at ingestion. + * Optional transformation string to apply to the output video. **Example**: + * `q-80` */ - fun pre(pre: String) = pre(MultipartField.of(pre)) + fun value(value: String) = value(MultipartField.of(value)) /** - * Sets [Builder.pre] to an arbitrary multipart value. + * Sets [Builder.value] to an arbitrary multipart value. * - * You should usually call [Builder.pre] with a well-typed [String] value + * You should usually call [Builder.value] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun pre(pre: MultipartField) = apply { this.pre = pre } + fun value(value: MultipartField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -7143,27 +4464,27 @@ private constructor( } /** - * Returns an immutable instance of [Transformation]. + * Returns an immutable instance of [GifToVideo]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Transformation = - Transformation( - (post ?: MultipartField.of(null)).map { it.toImmutable() }, - pre, - additionalProperties.toMutableMap(), - ) + fun build(): GifToVideo = + GifToVideo(type, value, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): Transformation = apply { + fun validate(): GifToVideo = apply { if (validated) { return@apply } - post().ifPresent { it.forEach { it.validate() } } - pre() + _type().let { + if (it != JsonValue.from("gif-to-video")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + value() validated = true } @@ -7175,1188 +4496,542 @@ private constructor( false } - @JsonDeserialize(using = Post.Deserializer::class) - @JsonSerialize(using = Post.Serializer::class) - class Post - private constructor( - private val transformation: InnerTransformation? = null, - private val gifToVideo: GifToVideo? = null, - private val thumbnail: Thumbnail? = null, - private val abs: Abs? = null, - private val _json: JsonValue? = null, - ) { - - fun transformation(): Optional = - Optional.ofNullable(transformation) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun gifToVideo(): Optional = Optional.ofNullable(gifToVideo) + return other is GifToVideo && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } - fun thumbnail(): Optional = Optional.ofNullable(thumbnail) + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } - fun abs(): Optional = Optional.ofNullable(abs) + override fun hashCode(): Int = hashCode - fun isTransformation(): Boolean = transformation != null + override fun toString() = + "GifToVideo{type=$type, value=$value, additionalProperties=$additionalProperties}" + } - fun isGifToVideo(): Boolean = gifToVideo != null + class Thumbnail + private constructor( + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { - fun isThumbnail(): Boolean = thumbnail != null + /** + * Generates a thumbnail image. + * + * Expected to always return the following: + * ```java + * JsonValue.from("thumbnail") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - fun isAbs(): Boolean = abs != null + /** + * Optional transformation string. **Example**: `w-150,h-150` + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.value.getOptional("value") - fun asTransformation(): InnerTransformation = - transformation.getOrThrow("transformation") + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value - fun asGifToVideo(): GifToVideo = gifToVideo.getOrThrow("gifToVideo") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asThumbnail(): Thumbnail = thumbnail.getOrThrow("thumbnail") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun asAbs(): Abs = abs.getOrThrow("abs") + fun toBuilder() = Builder().from(this) - fun _json(): Optional = Optional.ofNullable(_json) + companion object { - fun accept(visitor: Visitor): T = - when { - transformation != null -> visitor.visitTransformation(transformation) - gifToVideo != null -> visitor.visitGifToVideo(gifToVideo) - thumbnail != null -> visitor.visitThumbnail(thumbnail) - abs != null -> visitor.visitAbs(abs) - else -> visitor.unknown(_json) - } + /** Returns a mutable builder for constructing an instance of [Thumbnail]. */ + @JvmStatic fun builder() = Builder() + } - private var validated: Boolean = false + /** A builder for [Thumbnail]. */ + class Builder internal constructor() { - fun validate(): Post = apply { - if (validated) { - return@apply - } + private var type: JsonValue = JsonValue.from("thumbnail") + private var value: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() - accept( - object : Visitor { - override fun visitTransformation( - transformation: InnerTransformation - ) { - transformation.validate() - } - - override fun visitGifToVideo(gifToVideo: GifToVideo) { - gifToVideo.validate() - } - - override fun visitThumbnail(thumbnail: Thumbnail) { - thumbnail.validate() - } - - override fun visitAbs(abs: Abs) { - abs.validate() - } - } - ) - validated = true + @JvmSynthetic + internal fun from(thumbnail: Thumbnail) = apply { + type = thumbnail.type + value = thumbnail.value + additionalProperties = thumbnail.additionalProperties.toMutableMap() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets the field to an arbitrary JSON value. * - * Used for best match union deserialization. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("thumbnail") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitTransformation( - transformation: InnerTransformation - ) = transformation.validity() - - override fun visitGifToVideo(gifToVideo: GifToVideo) = - gifToVideo.validity() - - override fun visitThumbnail(thumbnail: Thumbnail) = - thumbnail.validity() - - override fun visitAbs(abs: Abs) = abs.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Post && - transformation == other.transformation && - gifToVideo == other.gifToVideo && - thumbnail == other.thumbnail && - abs == other.abs - } + fun type(type: JsonValue) = apply { this.type = type } - override fun hashCode(): Int = - Objects.hash(transformation, gifToVideo, thumbnail, abs) - - override fun toString(): String = - when { - transformation != null -> "Post{transformation=$transformation}" - gifToVideo != null -> "Post{gifToVideo=$gifToVideo}" - thumbnail != null -> "Post{thumbnail=$thumbnail}" - abs != null -> "Post{abs=$abs}" - _json != null -> "Post{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Post") - } - - companion object { - - @JvmStatic - fun ofTransformation(transformation: InnerTransformation) = - Post(transformation = transformation) - - @JvmStatic - fun ofGifToVideo(gifToVideo: GifToVideo) = Post(gifToVideo = gifToVideo) - - @JvmStatic - fun ofThumbnail(thumbnail: Thumbnail) = Post(thumbnail = thumbnail) - - @JvmStatic fun ofAbs(abs: Abs) = Post(abs = abs) - } + /** Optional transformation string. **Example**: `w-150,h-150` */ + fun value(value: String) = value(MultipartField.of(value)) /** - * An interface that defines how to map each variant of [Post] to a value of - * type [T]. + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - interface Visitor { - - fun visitTransformation(transformation: InnerTransformation): T - - fun visitGifToVideo(gifToVideo: GifToVideo): T - - fun visitThumbnail(thumbnail: Thumbnail): T - - fun visitAbs(abs: Abs): T - - /** - * Maps an unknown variant of [Post] to a value of type [T]. - * - * An instance of [Post] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, - * if the SDK is on an older version than the API, then the API may respond - * with new variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Post: $json") - } - } + fun value(value: MultipartField) = apply { this.value = value } - internal class Deserializer : BaseDeserializer(Post::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Post { - val json = JsonValue.fromJsonNode(node) - val type = - json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - - when (type) { - "transformation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Post(transformation = it, _json = json) } - ?: Post(_json = json) - } - "gif-to-video" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(gifToVideo = it, _json = json) - } ?: Post(_json = json) - } - "thumbnail" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(thumbnail = it, _json = json) - } ?: Post(_json = json) - } - "abs" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(abs = it, _json = json) - } ?: Post(_json = json) - } - } - - return Post(_json = json) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - internal class Serializer : BaseSerializer(Post::class) { - - override fun serialize( - value: Post, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.transformation != null -> - generator.writeObject(value.transformation) - value.gifToVideo != null -> generator.writeObject(value.gifToVideo) - value.thumbnail != null -> generator.writeObject(value.thumbnail) - value.abs != null -> generator.writeObject(value.abs) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Post") - } - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - class InnerTransformation - private constructor( - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Transformation type. - * - * Expected to always return the following: - * ```java - * JsonValue.from("transformation") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit - * URL-based 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 value(): String = value.value.getRequired("value") - - /** - * Returns the raw multipart value of [value]. - * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): MultipartField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InnerTransformation]. - * - * The following fields are required: - * ```java - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerTransformation]. */ - class Builder internal constructor() { - - private var type: JsonValue = JsonValue.from("transformation") - private var value: MultipartField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerTransformation: InnerTransformation) = apply { - type = innerTransformation.type - value = innerTransformation.value - additionalProperties = - innerTransformation.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field - * defaults to the following: - * ```java - * JsonValue.from("transformation") - * ``` - * - * This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** - * Transformation string (e.g. `w-200,h-200`). Same syntax as ImageKit - * URL-based transformations. - */ - fun value(value: String) = value(MultipartField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun value(value: MultipartField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InnerTransformation]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): InnerTransformation = - InnerTransformation( - type, - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): InnerTransformation = apply { - if (validated) { - return@apply - } - - _type().let { - if (it != JsonValue.from("transformation")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - value() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InnerTransformation && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(type, value, additionalProperties) + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - class GifToVideo - private constructor( - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Converts an animated GIF into an MP4. - * - * Expected to always return the following: - * ```java - * JsonValue.from("gif-to-video") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Optional transformation string to apply to the output video. **Example**: - * `q-80` - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun value(): Optional = value.value.getOptional("value") - - /** - * Returns the raw multipart value of [value]. - * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): MultipartField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [GifToVideo]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GifToVideo]. */ - class Builder internal constructor() { - - private var type: JsonValue = JsonValue.from("gif-to-video") - private var value: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(gifToVideo: GifToVideo) = apply { - type = gifToVideo.type - value = gifToVideo.value - additionalProperties = - gifToVideo.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field - * defaults to the following: - * ```java - * JsonValue.from("gif-to-video") - * ``` - * - * This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** - * Optional transformation string to apply to the output video. - * **Example**: `q-80` - */ - fun value(value: String) = value(MultipartField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun value(value: MultipartField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [GifToVideo]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): GifToVideo = - GifToVideo(type, value, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): GifToVideo = apply { - if (validated) { - return@apply - } - - _type().let { - if (it != JsonValue.from("gif-to-video")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - value() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GifToVideo && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(type, value, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GifToVideo{type=$type, value=$value, additionalProperties=$additionalProperties}" + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - class Thumbnail - private constructor( - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { - - /** - * Generates a thumbnail image. - * - * Expected to always return the following: - * ```java - * JsonValue.from("thumbnail") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * Returns an immutable instance of [Thumbnail]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Thumbnail = + Thumbnail(type, value, additionalProperties.toMutableMap()) + } - /** - * Optional transformation string. **Example**: `w-150,h-150` - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun value(): Optional = value.value.getOptional("value") + private var validated: Boolean = false - /** - * Returns the raw multipart value of [value]. - * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): MultipartField = value + fun validate(): Thumbnail = apply { + if (validated) { + return@apply + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + _type().let { + if (it != JsonValue.from("thumbnail")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") } + } + value() + validated = true + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - companion object { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns a mutable builder for constructing an instance of - * [Thumbnail]. - */ - @JvmStatic fun builder() = Builder() - } + return other is Thumbnail && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } - /** A builder for [Thumbnail]. */ - class Builder internal constructor() { + private val hashCode: Int by lazy { + Objects.hash(type, value, additionalProperties) + } - private var type: JsonValue = JsonValue.from("thumbnail") - private var value: MultipartField = MultipartField.of(null) - private var additionalProperties: MutableMap = - mutableMapOf() + override fun hashCode(): Int = hashCode - @JvmSynthetic - internal fun from(thumbnail: Thumbnail) = apply { - type = thumbnail.type - value = thumbnail.value - additionalProperties = thumbnail.additionalProperties.toMutableMap() - } + override fun toString() = + "Thumbnail{type=$type, value=$value, additionalProperties=$additionalProperties}" + } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field - * defaults to the following: - * ```java - * JsonValue.from("thumbnail") - * ``` - * - * This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** Optional transformation string. **Example**: `w-150,h-150` */ - fun value(value: String) = value(MultipartField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun value(value: MultipartField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + class Abs + private constructor( + private val protocol: MultipartField, + private val type: JsonValue, + private val value: MultipartField, + private val additionalProperties: MutableMap, + ) { - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Streaming protocol to use (`hls` or `dash`). + * + * @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 protocol(): Protocol = protocol.value.getRequired("protocol") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Adaptive Bitrate Streaming (ABS) setup. + * + * Expected to always return the following: + * ```java + * JsonValue.from("abs") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * List of different representations you want to create separated by an underscore. + * + * @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 value(): String = value.value.getRequired("value") - /** - * Returns an immutable instance of [Thumbnail]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): Thumbnail = - Thumbnail(type, value, additionalProperties.toMutableMap()) - } + /** + * Returns the raw multipart value of [protocol]. + * + * Unlike [protocol], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("protocol") + @ExcludeMissing + fun _protocol(): MultipartField = protocol - private var validated: Boolean = false + /** + * Returns the raw multipart value of [value]. + * + * Unlike [value], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): MultipartField = value - fun validate(): Thumbnail = apply { - if (validated) { - return@apply - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - _type().let { - if (it != JsonValue.from("thumbnail")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - value() - validated = true - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + fun toBuilder() = Builder().from(this) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + companion object { - return other is Thumbnail && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties - } + /** + * Returns a mutable builder for constructing an instance of [Abs]. + * + * The following fields are required: + * ```java + * .protocol() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - private val hashCode: Int by lazy { - Objects.hash(type, value, additionalProperties) - } + /** A builder for [Abs]. */ + class Builder internal constructor() { - override fun hashCode(): Int = hashCode + private var protocol: MultipartField? = null + private var type: JsonValue = JsonValue.from("abs") + private var value: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() - override fun toString() = - "Thumbnail{type=$type, value=$value, additionalProperties=$additionalProperties}" + @JvmSynthetic + internal fun from(abs: Abs) = apply { + protocol = abs.protocol + type = abs.type + value = abs.value + additionalProperties = abs.additionalProperties.toMutableMap() } - class Abs - private constructor( - private val protocol: MultipartField, - private val type: JsonValue, - private val value: MultipartField, - private val additionalProperties: MutableMap, - ) { + /** Streaming protocol to use (`hls` or `dash`). */ + fun protocol(protocol: Protocol) = protocol(MultipartField.of(protocol)) - /** - * Streaming protocol to use (`hls` or `dash`). - * - * @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 protocol(): Protocol = protocol.value.getRequired("protocol") + /** + * Sets [Builder.protocol] to an arbitrary multipart value. + * + * You should usually call [Builder.protocol] with a well-typed [Protocol] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun protocol(protocol: MultipartField) = apply { + this.protocol = protocol + } - /** - * Adaptive Bitrate Streaming (ABS) setup. - * - * Expected to always return the following: - * ```java - * JsonValue.from("abs") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("abs") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } - /** - * List of different representations you want to create separated by an - * underscore. - * - * @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 value(): String = value.value.getRequired("value") + /** + * List of different representations you want to create separated by an + * underscore. + */ + fun value(value: String) = value(MultipartField.of(value)) - /** - * Returns the raw multipart value of [protocol]. - * - * Unlike [protocol], this method doesn't throw if the multipart field has - * an unexpected type. - */ - @JsonProperty("protocol") - @ExcludeMissing - fun _protocol(): MultipartField = protocol + /** + * Sets [Builder.value] to an arbitrary multipart value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: MultipartField) = apply { this.value = value } - /** - * Returns the raw multipart value of [value]. - * - * Unlike [value], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): MultipartField = value + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Abs]. - * - * The following fields are required: - * ```java - * .protocol() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - /** A builder for [Abs]. */ - class Builder internal constructor() { - - private var protocol: MultipartField? = null - private var type: JsonValue = JsonValue.from("abs") - private var value: MultipartField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(abs: Abs) = apply { - protocol = abs.protocol - type = abs.type - value = abs.value - additionalProperties = abs.additionalProperties.toMutableMap() - } - - /** Streaming protocol to use (`hls` or `dash`). */ - fun protocol(protocol: Protocol) = protocol(MultipartField.of(protocol)) - - /** - * Sets [Builder.protocol] to an arbitrary multipart value. - * - * You should usually call [Builder.protocol] with a well-typed - * [Protocol] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun protocol(protocol: MultipartField) = apply { - this.protocol = protocol - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field - * defaults to the following: - * ```java - * JsonValue.from("abs") - * ``` - * - * This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** - * List of different representations you want to create separated by an - * underscore. - */ - fun value(value: String) = value(MultipartField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary multipart value. - * - * You should usually call [Builder.value] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun value(value: MultipartField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Returns an immutable instance of [Abs]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .protocol() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Abs = + Abs( + checkRequired("protocol", protocol), + type, + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + private var validated: Boolean = false - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun validate(): Abs = apply { + if (validated) { + return@apply + } - /** - * Returns an immutable instance of [Abs]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .protocol() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Abs = - Abs( - checkRequired("protocol", protocol), - type, - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) + protocol().validate() + _type().let { + if (it != JsonValue.from("abs")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") } + } + value() + validated = true + } - private var validated: Boolean = false + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } - fun validate(): Abs = apply { - if (validated) { - return@apply - } + /** Streaming protocol to use (`hls` or `dash`). */ + class Protocol + @JsonCreator + private constructor(private val value: JsonField) : Enum { - protocol().validate() - _type().let { - if (it != JsonValue.from("abs")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - value() - validated = true - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } + companion object { - /** Streaming protocol to use (`hls` or `dash`). */ - class Protocol - @JsonCreator - private constructor(private val value: JsonField) : Enum { + @JvmField val HLS = of("hls") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from - * data that doesn't match any known member, and you want to know that - * value. For example, if the SDK is on an older version than the API, - * then the API may respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @JvmField val DASH = of("dash") - companion object { + @JvmStatic fun of(value: String) = Protocol(JsonField.of(value)) + } - @JvmField val HLS = of("hls") + /** An enum containing [Protocol]'s known values. */ + enum class Known { + HLS, + DASH, + } - @JvmField val DASH = of("dash") + /** + * An enum containing [Protocol]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Protocol] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HLS, + DASH, + /** + * An enum member indicating that [Protocol] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } - @JvmStatic fun of(value: String) = Protocol(JsonField.of(value)) - } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HLS -> Value.HLS + DASH -> Value.DASH + else -> Value._UNKNOWN + } - /** An enum containing [Protocol]'s known values. */ - enum class Known { - HLS, - DASH, - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + HLS -> Known.HLS + DASH -> Known.DASH + else -> throw ImageKitInvalidDataException("Unknown Protocol: $value") + } - /** - * An enum containing [Protocol]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [Protocol] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. - * For example, if the SDK is on an older version than the API, then - * the API may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - HLS, - DASH, - /** - * An enum member indicating that [Protocol] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } - /** - * Returns an enum member corresponding to this class instance's value, - * or [Value._UNKNOWN] if the class was instantiated with an unknown - * value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - HLS -> Value.HLS - DASH -> Value.DASH - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is - * always known and don't want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value - * is a not a known member. - */ - fun known(): Known = - when (this) { - HLS -> Known.HLS - DASH -> Known.DASH - else -> - throw ImageKitInvalidDataException( - "Unknown Protocol: $value" - ) - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is - * primarily for debugging and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value - * does not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Protocol = apply { - if (validated) { - return@apply - } - - known() - validated = true - } + private var validated: Boolean = false - 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 (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Protocol && value == other.value - } + fun validate(): Protocol = apply { + if (validated) { + return@apply + } - override fun hashCode() = value.hashCode() + known() + validated = true + } - override fun toString() = value.toString() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - return other is Abs && - protocol == other.protocol && - type == other.type && - value == other.value && - additionalProperties == other.additionalProperties + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - private val hashCode: Int by lazy { - Objects.hash(protocol, type, value, additionalProperties) - } + return other is Protocol && value == other.value + } - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "Abs{protocol=$protocol, type=$type, value=$value, additionalProperties=$additionalProperties}" - } + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -8364,86 +5039,41 @@ private constructor( return true } - return other is Transformation && - post == other.post && - pre == other.pre && + return other is Abs && + protocol == other.protocol && + type == other.type && + value == other.value && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(post, pre, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(protocol, type, value, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "Transformation{post=$post, pre=$pre, additionalProperties=$additionalProperties}" + "Abs{protocol=$protocol, type=$type, value=$value, additionalProperties=$additionalProperties}" } + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FileUploadByUrlv1 && - file == other.file && - fileName == other.fileName && - token == other.token && - checks == other.checks && - customCoordinates == other.customCoordinates && - customMetadata == other.customMetadata && - description == other.description && - expire == other.expire && - extensions == other.extensions && - folder == other.folder && - isPrivateFile == other.isPrivateFile && - isPublished == other.isPublished && - overwriteAiTags == other.overwriteAiTags && - overwriteCustomMetadata == other.overwriteCustomMetadata && - overwriteFile == other.overwriteFile && - overwriteTags == other.overwriteTags && - publicKey == other.publicKey && - responseFields == other.responseFields && - signature == other.signature && - tags == other.tags && - transformation == other.transformation && - useUniqueFileName == other.useUniqueFileName && - webhookUrl == other.webhookUrl && - additionalProperties == other.additionalProperties + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - private val hashCode: Int by lazy { - Objects.hash( - file, - fileName, - token, - checks, - customCoordinates, - customMetadata, - description, - expire, - extensions, - folder, - isPrivateFile, - isPublished, - overwriteAiTags, - overwriteCustomMetadata, - overwriteFile, - overwriteTags, - publicKey, - responseFields, - signature, - tags, - transformation, - useUniqueFileName, - webhookUrl, - additionalProperties, - ) - } + return other is Transformation && + post == other.post && + pre == other.pre && + additionalProperties == other.additionalProperties + } - override fun hashCode(): Int = hashCode + private val hashCode: Int by lazy { Objects.hash(post, pre, additionalProperties) } - override fun toString() = - "FileUploadByUrlv1{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, expire=$expire, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, publicKey=$publicKey, responseFields=$responseFields, signature=$signature, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" - } + override fun hashCode(): Int = hashCode + + override fun toString() = + "Transformation{post=$post, pre=$pre, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt index addd9d29..f5db6fe3 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt @@ -220,23 +220,15 @@ interface FileServiceAsync { * file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. * - [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies. */ - fun upload(): CompletableFuture = upload(FileUploadParams.none()) + fun upload(params: FileUploadParams): CompletableFuture = + upload(params, RequestOptions.none()) /** @see upload */ fun upload( - params: FileUploadParams = FileUploadParams.none(), + params: FileUploadParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see upload */ - fun upload( - params: FileUploadParams = FileUploadParams.none() - ): CompletableFuture = upload(params, RequestOptions.none()) - - /** @see upload */ - fun upload(requestOptions: RequestOptions): CompletableFuture = - upload(FileUploadParams.none(), requestOptions) - /** A view of [FileServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -414,25 +406,15 @@ interface FileServiceAsync { * Returns a raw HTTP response for `post /api/v1/files/upload`, but is otherwise the same as * [FileServiceAsync.upload]. */ - fun upload(): CompletableFuture> = - upload(FileUploadParams.none()) - - /** @see upload */ fun upload( - params: FileUploadParams = FileUploadParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see upload */ - fun upload( - params: FileUploadParams = FileUploadParams.none() + params: FileUploadParams ): CompletableFuture> = upload(params, RequestOptions.none()) /** @see upload */ fun upload( - requestOptions: RequestOptions - ): CompletableFuture> = - upload(FileUploadParams.none(), requestOptions) + params: FileUploadParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt index 5743ebbd..bafc4724 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt @@ -346,11 +346,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien else "https://upload.imagekit.io" ) .addPathSegments("api", "v1", "files", "upload") - .apply { - params._body().ifPresent { - body(multipartFormData(clientOptions.jsonMapper, it)) - } - } + .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt index 51e5acf6..8f4e8f80 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt @@ -202,22 +202,14 @@ interface FileService { * file selections from local storage, URL, Dropbox, Google Drive, Instagram, and more. * - [Quick start guides](/docs/quick-start-guides) for various frameworks and technologies. */ - fun upload(): FileUploadResponse = upload(FileUploadParams.none()) + fun upload(params: FileUploadParams): FileUploadResponse = upload(params, RequestOptions.none()) /** @see upload */ fun upload( - params: FileUploadParams = FileUploadParams.none(), + params: FileUploadParams, requestOptions: RequestOptions = RequestOptions.none(), ): FileUploadResponse - /** @see upload */ - fun upload(params: FileUploadParams = FileUploadParams.none()): FileUploadResponse = - upload(params, RequestOptions.none()) - - /** @see upload */ - fun upload(requestOptions: RequestOptions): FileUploadResponse = - upload(FileUploadParams.none(), requestOptions) - /** A view of [FileService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -404,24 +396,14 @@ interface FileService { * [FileService.upload]. */ @MustBeClosed - fun upload(): HttpResponseFor = upload(FileUploadParams.none()) + fun upload(params: FileUploadParams): HttpResponseFor = + upload(params, RequestOptions.none()) /** @see upload */ @MustBeClosed fun upload( - params: FileUploadParams = FileUploadParams.none(), + params: FileUploadParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - - /** @see upload */ - @MustBeClosed - fun upload( - params: FileUploadParams = FileUploadParams.none() - ): HttpResponseFor = upload(params, RequestOptions.none()) - - /** @see upload */ - @MustBeClosed - fun upload(requestOptions: RequestOptions): HttpResponseFor = - upload(FileUploadParams.none(), requestOptions) } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt index 85fd05b1..6448f2b3 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt @@ -315,11 +315,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti else "https://upload.imagekit.io" ) .addPathSegments("api", "v1", "files", "upload") - .apply { - params._body().ifPresent { - body(multipartFormData(clientOptions.jsonMapper, it)) - } - } + .body(multipartFormData(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt index 7957b53f..11752909 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt @@ -5,7 +5,6 @@ package com.imagekit.api.models.files import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField import java.io.InputStream -import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,95 +13,81 @@ internal class FileUploadParamsTest { @Test fun create() { FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg.builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension.AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post.Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs.builder() - .protocol( - FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() } @@ -110,101 +95,84 @@ internal class FileUploadParamsTest { fun body() { val params = FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg.builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post.Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() - val body = params._body().getOrNull() + val body = params._body() assertThat(body.filterValues { !it.value.isNull() }) .usingRecursiveComparison() @@ -216,135 +184,89 @@ internal class FileUploadParamsTest { ) .isEqualTo( mapOf( - "body" to - MultipartField.builder() - .value( - FileUploadParams.Body.ofFileUploadV1( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata + "file" to MultipartField.of("some content".byteInputStream()), + "fileName" to MultipartField.of("fileName"), + "token" to MultipartField.of("token"), + "checks" to MultipartField.of("\"request.folder\" : \"marketing/\"\n"), + "customCoordinates" to MultipartField.of("customCoordinates"), + "customMetadata" to + MultipartField.of( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ), + "description" to MultipartField.of("Running shoes"), + "expire" to MultipartField.of(0L), + "extensions" to + MultipartField.of( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options .builder() - .putAdditionalProperty( - "brand", - JsonValue.from("bar"), - ) - .putAdditionalProperty( - "color", - JsonValue.from("bar"), - ) + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension - .ofRemoveBg( - FileUploadParams.Body.FileUploadV1 - .Extension - .RemoveBg - .builder() - .options( - FileUploadParams.Body - .FileUploadV1 - .Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAutoTagging( - FileUploadParams.Body.FileUploadV1 - .Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body - .FileUploadV1 - .Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField - .TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation - .builder() - .addPost( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Thumbnail - .builder() - .value("w-150,h-150") - .build() - ) - .addPost( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() - ) - .pre("w-300,h-300,q-80") - .build() + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ), + "folder" to MultipartField.of("folder"), + "isPrivateFile" to MultipartField.of(true), + "isPublished" to MultipartField.of(true), + "overwriteAITags" to MultipartField.of(true), + "overwriteCustomMetadata" to MultipartField.of(true), + "overwriteFile" to MultipartField.of(true), + "overwriteTags" to MultipartField.of(true), + "publicKey" to MultipartField.of("publicKey"), + "responseFields" to + MultipartField.of( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ), + "signature" to MultipartField.of("signature"), + "tags" to MultipartField.of(listOf("t-shirt", "round-neck", "men")), + "transformation" to + MultipartField.of( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol + .DASH ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .value("sr-240_360_480_720_1080") .build() ) - ) - .contentType("application/octet-stream") - .build() + .pre("w-300,h-300,q-80") + .build() + ), + "useUniqueFileName" to MultipartField.of(true), + "webhookUrl" to MultipartField.of("https://example.com"), ) .mapValues { (_, field) -> field.map { (it as? ByteArray)?.inputStream() ?: it } @@ -354,10 +276,30 @@ internal class FileUploadParamsTest { @Test fun bodyWithoutOptionalFields() { - val params = FileUploadParams.builder().build() + val params = + FileUploadParams.builder() + .file("some content".byteInputStream()) + .fileName("fileName") + .build() - val body = params._body().getOrNull() + val body = params._body() - assertThat(body.filterValues { !it.value.isNull() }).isEmpty() + assertThat(body.filterValues { !it.value.isNull() }) + .usingRecursiveComparison() + // TODO(AssertJ): Replace this and the `mapValues` below with: + // https://github.com/assertj/assertj/issues/3165 + .withEqualsForType( + { a, b -> a.readBytes() contentEquals b.readBytes() }, + InputStream::class.java, + ) + .isEqualTo( + mapOf( + "file" to MultipartField.of("some content".byteInputStream()), + "fileName" to MultipartField.of("fileName"), + ) + .mapValues { (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt index ff35db98..33349dd2 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt @@ -73,107 +73,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) - .pre("w-300,h-300,q-80") + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -197,107 +173,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -321,107 +273,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -445,107 +373,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -569,107 +473,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -693,107 +573,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -817,107 +673,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -941,107 +773,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) - .pre("w-300,h-300,q-80") + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -1065,107 +873,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -1189,107 +973,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -1313,107 +1073,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH + ) + .value("sr-240_360_480_720_1080") + .build() + ) + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -1437,107 +1173,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) - .pre("w-300,h-300,q-80") + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -1561,107 +1273,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) - .pre("w-300,h-300,q-80") + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -1685,107 +1373,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) - .pre("w-300,h-300,q-80") + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -1809,107 +1473,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) - .pre("w-300,h-300,q-80") + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -1933,107 +1573,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) - .pre("w-300,h-300,q-80") + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } @@ -2055,107 +1671,83 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField - .IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1 - .Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) - .pre("w-300,h-300,q-80") + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt index 6a14b916..f26281ec 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt @@ -4,6 +4,7 @@ package com.imagekit.api.services import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.equalTo +import com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath import com.github.tomakehurst.wiremock.client.WireMock.ok import com.github.tomakehurst.wiremock.client.WireMock.post import com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor @@ -44,100 +45,84 @@ internal class ServiceParamsTest { fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg.builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField.CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post.Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING ) - .pre("w-300,h-300,q-80") + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .putAdditionalHeader("Secret-Header", "42") .putAdditionalQueryParam("secret_query_param", "42") + .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) .build() ) @@ -145,6 +130,7 @@ internal class ServiceParamsTest { postRequestedFor(anyUrl()) .withHeader("Secret-Header", equalTo("42")) .withQueryParam("secret_query_param", equalTo("42")) + .withRequestBody(matchingJsonPath("$.secretProperty", equalTo("42"))) ) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index 3acc3a30..6e8d541b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -227,104 +227,83 @@ internal class FileServiceAsyncTest { val responseFuture = fileServiceAsync.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1.Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) - .pre("w-300,h-300,q-80") + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index 89de610f..2e932b81 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -220,104 +220,83 @@ internal class FileServiceTest { val response = fileService.upload( FileUploadParams.builder() - .body( - FileUploadParams.Body.FileUploadV1.builder() - .file("some content".byteInputStream()) - .fileName("fileName") - .token("token") - .checks("\"request.folder\" : \"marketing/\"\n") - .customCoordinates("customCoordinates") - .customMetadata( - FileUploadParams.Body.FileUploadV1.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) - .build() - ) - .description("Running shoes") - .expire(0L) - .extensions( - listOf( - FileUploadParams.Body.FileUploadV1.Extension.ofRemoveBg( - FileUploadParams.Body.FileUploadV1.Extension.RemoveBg - .builder() - .options( - FileUploadParams.Body.FileUploadV1.Extension - .RemoveBg - .Options - .builder() - .addShadow(true) - .bgColor("bg_color") - .bgImageUrl("bg_image_url") - .semitransparency(true) - .build() - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension.ofAutoTagging( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .builder() - .maxTags(5L) - .minConfidence(95L) - .name( - FileUploadParams.Body.FileUploadV1.Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUploadParams.Body.FileUploadV1.Extension - .ofAiAutoDescription(), - ) - ) - .folder("folder") - .isPrivateFile(true) - .isPublished(true) - .overwriteAiTags(true) - .overwriteCustomMetadata(true) - .overwriteFile(true) - .overwriteTags(true) - .publicKey("publicKey") - .responseFields( - listOf( - FileUploadParams.Body.FileUploadV1.ResponseField.TAGS, - FileUploadParams.Body.FileUploadV1.ResponseField - .CUSTOM_COORDINATES, - FileUploadParams.Body.FileUploadV1.ResponseField.IS_PRIVATE_FILE, - ) - ) - .signature("signature") - .tags(listOf("t-shirt", "round-neck", "men")) - .transformation( - FileUploadParams.Body.FileUploadV1.Transformation.builder() - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post - .Thumbnail - .builder() - .value("w-150,h-150") + .file("some content".byteInputStream()) + .fileName("fileName") + .token("token") + .checks("\"request.folder\" : \"marketing/\"\n") + .customCoordinates("customCoordinates") + .customMetadata( + FileUploadParams.CustomMetadata.builder() + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) + .build() + ) + .description("Running shoes") + .expire(0L) + .extensions( + listOf( + FileUploadParams.Extension.ofRemoveBg( + FileUploadParams.Extension.RemoveBg.builder() + .options( + FileUploadParams.Extension.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) .build() ) - .addPost( - FileUploadParams.Body.FileUploadV1.Transformation.Post.Abs - .builder() - .protocol( - FileUploadParams.Body.FileUploadV1.Transformation - .Post - .Abs - .Protocol - .DASH - ) - .value("sr-240_360_480_720_1080") - .build() + .build() + ), + FileUploadParams.Extension.ofAutoTagging( + FileUploadParams.Extension.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + FileUploadParams.Extension.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + FileUploadParams.Extension.ofAiAutoDescription(), + ) + ) + .folder("folder") + .isPrivateFile(true) + .isPublished(true) + .overwriteAiTags(true) + .overwriteCustomMetadata(true) + .overwriteFile(true) + .overwriteTags(true) + .publicKey("publicKey") + .responseFields( + listOf( + FileUploadParams.ResponseField.TAGS, + FileUploadParams.ResponseField.CUSTOM_COORDINATES, + FileUploadParams.ResponseField.IS_PRIVATE_FILE, + ) + ) + .signature("signature") + .tags(listOf("t-shirt", "round-neck", "men")) + .transformation( + FileUploadParams.Transformation.builder() + .addPost( + FileUploadParams.Transformation.Post.Thumbnail.builder() + .value("w-150,h-150") + .build() + ) + .addPost( + FileUploadParams.Transformation.Post.Abs.builder() + .protocol( + FileUploadParams.Transformation.Post.Abs.Protocol.DASH ) - .pre("w-300,h-300,q-80") + .value("sr-240_360_480_720_1080") .build() ) - .useUniqueFileName(true) - .webhookUrl("https://example.com") + .pre("w-300,h-300,q-80") .build() ) + .useUniqueFileName(true) + .webhookUrl("https://example.com") .build() ) From 1c762344ee41aa7099febdca72f368943ee8428b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 4 Sep 2025 06:01:46 +0000 Subject: [PATCH 016/142] feat(api): manual updates --- .stats.yml | 4 ++-- .../imagekit/api/models/beta/v2/files/FileUploadParams.kt | 8 ++++---- .../com/imagekit/api/models/files/FileUploadParams.kt | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.stats.yml b/.stats.yml index cfcbd7f7..5908457a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml -openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-0470196862abd722b09f1af798d6f2bcbdeba0f82d1162f57c287b1a43233531.yml +openapi_spec_hash: 043dd7c67d741d0034b86f2fc0bce072 config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt index a8caac42..1549d6ae 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt @@ -146,7 +146,7 @@ private constructor( fun description(): Optional = body.description() /** - * Array of extensions to be applied to the image. Each extension can be configured with + * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -634,7 +634,7 @@ private constructor( } /** - * Array of extensions to be applied to the image. Each extension can be configured with + * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ fun extensions(extensions: List) = apply { body.extensions(extensions) } @@ -1181,7 +1181,7 @@ private constructor( fun description(): Optional = description.value.getOptional("description") /** - * Array of extensions to be applied to the image. Each extension can be configured with + * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -1739,7 +1739,7 @@ private constructor( } /** - * Array of extensions to be applied to the image. Each extension can be configured with + * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ fun extensions(extensions: List) = extensions(MultipartField.of(extensions)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt index e50852f0..2e8828a4 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -159,7 +159,7 @@ private constructor( fun expire(): Optional = body.expire() /** - * Array of extensions to be applied to the image. Each extension can be configured with + * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -714,7 +714,7 @@ private constructor( fun expire(expire: MultipartField) = apply { body.expire(expire) } /** - * Array of extensions to be applied to the image. Each extension can be configured with + * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ fun extensions(extensions: List) = apply { body.extensions(extensions) } @@ -1318,7 +1318,7 @@ private constructor( fun expire(): Optional = expire.value.getOptional("expire") /** - * Array of extensions to be applied to the image. Each extension can be configured with + * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -1954,7 +1954,7 @@ private constructor( fun expire(expire: MultipartField) = apply { this.expire = expire } /** - * Array of extensions to be applied to the image. Each extension can be configured with + * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ fun extensions(extensions: List) = extensions(MultipartField.of(extensions)) From c6e61f8ca6b3a9485ab15d0221842ef76b6cae32 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 4 Sep 2025 06:17:45 +0000 Subject: [PATCH 017/142] feat(api): manual updates --- .stats.yml | 2 +- .../models/beta/v2/files/FileUploadParams.kt | 445 +++++++++++------- .../api/models/files/FileUpdateParams.kt | 178 ++++--- .../api/models/files/FileUploadParams.kt | 445 +++++++++++------- .../beta/v2/files/FileUploadParamsTest.kt | 44 +- .../api/models/files/FileUpdateParamsTest.kt | 99 ++-- .../api/models/files/FileUploadParamsTest.kt | 44 +- .../api/services/ErrorHandlingTest.kt | 239 +++++----- .../api/services/ServiceParamsTest.kt | 15 +- .../services/async/FileServiceAsyncTest.kt | 81 ++-- .../async/beta/v2/FileServiceAsyncTest.kt | 15 +- .../api/services/blocking/FileServiceTest.kt | 81 ++-- .../blocking/beta/v2/FileServiceTest.kt | 15 +- 13 files changed, 964 insertions(+), 739 deletions(-) diff --git a/.stats.yml b/.stats.yml index 5908457a..2dc65d21 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-0470196862abd722b09f1af798d6f2bcbdeba0f82d1162f57c287b1a43233531.yml openapi_spec_hash: 043dd7c67d741d0034b86f2fc0bce072 -config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c +config_hash: da949a1217f48ac01676eab81ca9d1b1 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt index 1549d6ae..9c220c91 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt @@ -18,6 +18,7 @@ import com.imagekit.api.core.BaseSerializer import com.imagekit.api.core.Enum import com.imagekit.api.core.ExcludeMissing import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField import com.imagekit.api.core.Params @@ -28,6 +29,7 @@ import com.imagekit.api.core.http.Headers import com.imagekit.api.core.http.QueryParams import com.imagekit.api.core.toImmutable import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 import java.io.InputStream import java.nio.file.Path import java.util.Collections @@ -152,7 +154,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun extensions(): Optional> = body.extensions() + fun extensions(): Optional> = body.extensions() /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, @@ -339,7 +341,7 @@ private constructor( * * Unlike [extensions], this method doesn't throw if the multipart field has an unexpected type. */ - fun _extensions(): MultipartField> = body._extensions() + fun _extensions(): MultipartField> = body._extensions() /** * Returns the raw multipart value of [folder]. @@ -637,35 +639,51 @@ private constructor( * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ - fun extensions(extensions: List) = apply { body.extensions(extensions) } + fun extensions(extensions: List) = apply { + body.extensions(extensions) + } /** * Sets [Builder.extensions] to an arbitrary multipart value. * - * You should usually call [Builder.extensions] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.extensions] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun extensions(extensions: MultipartField>) = apply { + fun extensions(extensions: MultipartField>) = apply { body.extensions(extensions) } /** - * Adds a single [Extension] to [extensions]. + * Adds a single [UnnamedSchemaWithArrayParent3] to [extensions]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addExtension(extension: Extension) = apply { body.addExtension(extension) } - - /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: Extension.RemoveBg) = apply { body.addExtension(removeBg) } + fun addExtension(extension: UnnamedSchemaWithArrayParent3) = apply { + body.addExtension(extension) + } - /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: Extension.AutoTaggingExtension) = apply { - body.addExtension(autoTagging) + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent3.ofRemoveBg(removeBg)`. + */ + fun addExtension(removeBg: UnnamedSchemaWithArrayParent3.RemoveBg) = apply { + body.addExtension(removeBg) } - /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension(autoTaggingExtension)`. + */ + fun addExtension(autoTaggingExtension: UnnamedSchemaWithArrayParent3.AutoTaggingExtension) = + apply { + body.addExtension(autoTaggingExtension) + } + + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent3.ofAiAutoDescription()`. + */ fun addExtensionAiAutoDescription() = apply { body.addExtensionAiAutoDescription() } /** @@ -1082,7 +1100,7 @@ private constructor( private val customCoordinates: MultipartField, private val customMetadata: MultipartField, private val description: MultipartField, - private val extensions: MultipartField>, + private val extensions: MultipartField>, private val folder: MultipartField, private val isPrivateFile: MultipartField, private val isPublished: MultipartField, @@ -1187,7 +1205,8 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun extensions(): Optional> = extensions.value.getOptional("extensions") + fun extensions(): Optional> = + extensions.value.getOptional("extensions") /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist @@ -1390,7 +1409,7 @@ private constructor( */ @JsonProperty("extensions") @ExcludeMissing - fun _extensions(): MultipartField> = extensions + fun _extensions(): MultipartField> = extensions /** * Returns the raw multipart value of [folder]. @@ -1542,7 +1561,8 @@ private constructor( private var customCoordinates: MultipartField = MultipartField.of(null) private var customMetadata: MultipartField = MultipartField.of(null) private var description: MultipartField = MultipartField.of(null) - private var extensions: MultipartField>? = null + private var extensions: MultipartField>? = + null private var folder: MultipartField = MultipartField.of(null) private var isPrivateFile: MultipartField = MultipartField.of(null) private var isPublished: MultipartField = MultipartField.of(null) @@ -1742,41 +1762,57 @@ private constructor( * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ - fun extensions(extensions: List) = extensions(MultipartField.of(extensions)) + fun extensions(extensions: List) = + extensions(MultipartField.of(extensions)) /** * Sets [Builder.extensions] to an arbitrary multipart value. * - * You should usually call [Builder.extensions] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.extensions] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - fun extensions(extensions: MultipartField>) = apply { - this.extensions = extensions.map { it.toMutableList() } - } + fun extensions(extensions: MultipartField>) = + apply { + this.extensions = extensions.map { it.toMutableList() } + } /** - * Adds a single [Extension] to [extensions]. + * Adds a single [UnnamedSchemaWithArrayParent3] to [extensions]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addExtension(extension: Extension) = apply { + fun addExtension(extension: UnnamedSchemaWithArrayParent3) = apply { extensions = (extensions ?: MultipartField.of(mutableListOf())).also { checkKnown("extensions", it).add(extension) } } - /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: Extension.RemoveBg) = - addExtension(Extension.ofRemoveBg(removeBg)) + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent3.ofRemoveBg(removeBg)`. + */ + fun addExtension(removeBg: UnnamedSchemaWithArrayParent3.RemoveBg) = + addExtension(UnnamedSchemaWithArrayParent3.ofRemoveBg(removeBg)) - /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: Extension.AutoTaggingExtension) = - addExtension(Extension.ofAutoTagging(autoTagging)) + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension(autoTaggingExtension)`. + */ + fun addExtension( + autoTaggingExtension: UnnamedSchemaWithArrayParent3.AutoTaggingExtension + ) = + addExtension( + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension(autoTaggingExtension) + ) - /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ - fun addExtensionAiAutoDescription() = addExtension(Extension.ofAiAutoDescription()) + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent3.ofAiAutoDescription()`. + */ + fun addExtensionAiAutoDescription() = + addExtension(UnnamedSchemaWithArrayParent3.ofAiAutoDescription()) /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist @@ -2282,31 +2318,33 @@ private constructor( override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" } - @JsonDeserialize(using = Extension.Deserializer::class) - @JsonSerialize(using = Extension.Serializer::class) - class Extension + @JsonDeserialize(using = UnnamedSchemaWithArrayParent3.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent3.Serializer::class) + class UnnamedSchemaWithArrayParent3 private constructor( private val removeBg: RemoveBg? = null, - private val autoTagging: AutoTaggingExtension? = null, + private val autoTaggingExtension: AutoTaggingExtension? = null, private val aiAutoDescription: JsonValue? = null, private val _json: JsonValue? = null, ) { fun removeBg(): Optional = Optional.ofNullable(removeBg) - fun autoTagging(): Optional = Optional.ofNullable(autoTagging) + fun autoTaggingExtension(): Optional = + Optional.ofNullable(autoTaggingExtension) fun aiAutoDescription(): Optional = Optional.ofNullable(aiAutoDescription) fun isRemoveBg(): Boolean = removeBg != null - fun isAutoTagging(): Boolean = autoTagging != null + fun isAutoTaggingExtension(): Boolean = autoTaggingExtension != null fun isAiAutoDescription(): Boolean = aiAutoDescription != null fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") - fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") + fun asAutoTaggingExtension(): AutoTaggingExtension = + autoTaggingExtension.getOrThrow("autoTaggingExtension") fun asAiAutoDescription(): JsonValue = aiAutoDescription.getOrThrow("aiAutoDescription") @@ -2315,14 +2353,15 @@ private constructor( fun accept(visitor: Visitor): T = when { removeBg != null -> visitor.visitRemoveBg(removeBg) - autoTagging != null -> visitor.visitAutoTagging(autoTagging) + autoTaggingExtension != null -> + visitor.visitAutoTaggingExtension(autoTaggingExtension) aiAutoDescription != null -> visitor.visitAiAutoDescription(aiAutoDescription) else -> visitor.unknown(_json) } private var validated: Boolean = false - fun validate(): Extension = apply { + fun validate(): UnnamedSchemaWithArrayParent3 = apply { if (validated) { return@apply } @@ -2333,8 +2372,10 @@ private constructor( removeBg.validate() } - override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { - autoTagging.validate() + override fun visitAutoTaggingExtension( + autoTaggingExtension: AutoTaggingExtension + ) { + autoTaggingExtension.validate() } override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { @@ -2371,8 +2412,9 @@ private constructor( object : Visitor { override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() - override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = - autoTagging.validity() + override fun visitAutoTaggingExtension( + autoTaggingExtension: AutoTaggingExtension + ) = autoTaggingExtension.validity() override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = aiAutoDescription.let { @@ -2389,103 +2431,113 @@ private constructor( return true } - return other is Extension && + return other is UnnamedSchemaWithArrayParent3 && removeBg == other.removeBg && - autoTagging == other.autoTagging && + autoTaggingExtension == other.autoTaggingExtension && aiAutoDescription == other.aiAutoDescription } - override fun hashCode(): Int = Objects.hash(removeBg, autoTagging, aiAutoDescription) + override fun hashCode(): Int = + Objects.hash(removeBg, autoTaggingExtension, aiAutoDescription) override fun toString(): String = when { - removeBg != null -> "Extension{removeBg=$removeBg}" - autoTagging != null -> "Extension{autoTagging=$autoTagging}" - aiAutoDescription != null -> "Extension{aiAutoDescription=$aiAutoDescription}" - _json != null -> "Extension{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Extension") + removeBg != null -> "UnnamedSchemaWithArrayParent3{removeBg=$removeBg}" + autoTaggingExtension != null -> + "UnnamedSchemaWithArrayParent3{autoTaggingExtension=$autoTaggingExtension}" + aiAutoDescription != null -> + "UnnamedSchemaWithArrayParent3{aiAutoDescription=$aiAutoDescription}" + _json != null -> "UnnamedSchemaWithArrayParent3{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") } companion object { - @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = Extension(removeBg = removeBg) + @JvmStatic + fun ofRemoveBg(removeBg: RemoveBg) = UnnamedSchemaWithArrayParent3(removeBg = removeBg) @JvmStatic - fun ofAutoTagging(autoTagging: AutoTaggingExtension) = - Extension(autoTagging = autoTagging) + fun ofAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension) = + UnnamedSchemaWithArrayParent3(autoTaggingExtension = autoTaggingExtension) @JvmStatic fun ofAiAutoDescription() = - Extension( + UnnamedSchemaWithArrayParent3( aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) ) } /** - * An interface that defines how to map each variant of [Extension] to a value of type [T]. + * An interface that defines how to map each variant of [UnnamedSchemaWithArrayParent3] to a + * value of type [T]. */ interface Visitor { fun visitRemoveBg(removeBg: RemoveBg): T - fun visitAutoTagging(autoTagging: AutoTaggingExtension): T + fun visitAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension): T fun visitAiAutoDescription(aiAutoDescription: JsonValue): T /** - * Maps an unknown variant of [Extension] to a value of type [T]. + * Maps an unknown variant of [UnnamedSchemaWithArrayParent3] to a value of type [T]. * - * An instance of [Extension] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [UnnamedSchemaWithArrayParent3] can contain an unknown variant if it + * was deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. * * @throws ImageKitInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Extension: $json") + throw ImageKitInvalidDataException("Unknown UnnamedSchemaWithArrayParent3: $json") } } - internal class Deserializer : BaseDeserializer(Extension::class) { + internal class Deserializer : + BaseDeserializer(UnnamedSchemaWithArrayParent3::class) { - override fun ObjectCodec.deserialize(node: JsonNode): Extension { + override fun ObjectCodec.deserialize(node: JsonNode): UnnamedSchemaWithArrayParent3 { val json = JsonValue.fromJsonNode(node) val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() when (name) { "remove-bg" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Extension(removeBg = it, _json = json) - } ?: Extension(_json = json) + UnnamedSchemaWithArrayParent3(removeBg = it, _json = json) + } ?: UnnamedSchemaWithArrayParent3(_json = json) } "ai-auto-description" -> { return tryDeserialize(node, jacksonTypeRef()) - ?.let { Extension(aiAutoDescription = it, _json = json) } - ?.takeIf { it.isValid() } ?: Extension(_json = json) + ?.let { + UnnamedSchemaWithArrayParent3(aiAutoDescription = it, _json = json) + } + ?.takeIf { it.isValid() } ?: UnnamedSchemaWithArrayParent3(_json = json) } } return tryDeserialize(node, jacksonTypeRef())?.let { - Extension(autoTagging = it, _json = json) - } ?: Extension(_json = json) + UnnamedSchemaWithArrayParent3(autoTaggingExtension = it, _json = json) + } ?: UnnamedSchemaWithArrayParent3(_json = json) } } - internal class Serializer : BaseSerializer(Extension::class) { + internal class Serializer : + BaseSerializer(UnnamedSchemaWithArrayParent3::class) { override fun serialize( - value: Extension, + value: UnnamedSchemaWithArrayParent3, generator: JsonGenerator, provider: SerializerProvider, ) { when { value.removeBg != null -> generator.writeObject(value.removeBg) - value.autoTagging != null -> generator.writeObject(value.autoTagging) + value.autoTaggingExtension != null -> + generator.writeObject(value.autoTaggingExtension) value.aiAutoDescription != null -> generator.writeObject(value.aiAutoDescription) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Extension") + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") } } } @@ -2493,10 +2545,18 @@ private constructor( class RemoveBg private constructor( private val name: JsonValue, - private val options: MultipartField, + private val options: JsonField, private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + options: JsonField = JsonMissing.of(), + ) : this(name, options, mutableMapOf()) + /** * Specifies the background removal extension. * @@ -2514,17 +2574,14 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun options(): Optional = options.value.getOptional("options") + fun options(): Optional = options.getOptional("options") /** - * Returns the raw multipart value of [options]. + * Returns the raw JSON value of [options]. * - * Unlike [options], this method doesn't throw if the multipart field has an unexpected - * type. + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("options") - @ExcludeMissing - fun _options(): MultipartField = options + @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -2548,7 +2605,7 @@ private constructor( class Builder internal constructor() { private var name: JsonValue = JsonValue.from("remove-bg") - private var options: MultipartField = MultipartField.of(null) + private var options: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2572,16 +2629,16 @@ private constructor( */ fun name(name: JsonValue) = apply { this.name = name } - fun options(options: Options) = options(MultipartField.of(options)) + fun options(options: Options) = options(JsonField.of(options)) /** - * Sets [Builder.options] to an arbitrary multipart value. + * Sets [Builder.options] to an arbitrary JSON value. * * You should usually call [Builder.options] with a well-typed [Options] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun options(options: MultipartField) = apply { this.options = options } + fun options(options: JsonField) = apply { this.options = options } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2637,15 +2694,42 @@ private constructor( false } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + name.let { if (it == JsonValue.from("remove-bg")) 1 else 0 } + + (options.asKnown().getOrNull()?.validity() ?: 0) + class Options private constructor( - private val addShadow: MultipartField, - private val bgColor: MultipartField, - private val bgImageUrl: MultipartField, - private val semitransparency: MultipartField, + private val addShadow: JsonField, + private val bgColor: JsonField, + private val bgImageUrl: JsonField, + private val semitransparency: JsonField, private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("add_shadow") + @ExcludeMissing + addShadow: JsonField = JsonMissing.of(), + @JsonProperty("bg_color") + @ExcludeMissing + bgColor: JsonField = JsonMissing.of(), + @JsonProperty("bg_image_url") + @ExcludeMissing + bgImageUrl: JsonField = JsonMissing.of(), + @JsonProperty("semitransparency") + @ExcludeMissing + semitransparency: JsonField = JsonMissing.of(), + ) : this(addShadow, bgColor, bgImageUrl, semitransparency, mutableMapOf()) + /** * Whether to add an artificial shadow to the result. Default is false. Note: Adding * shadows is currently only supported for car photos. @@ -2653,7 +2737,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun addShadow(): Optional = addShadow.value.getOptional("add_shadow") + fun addShadow(): Optional = addShadow.getOptional("add_shadow") /** * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or @@ -2663,7 +2747,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun bgColor(): Optional = bgColor.value.getOptional("bg_color") + fun bgColor(): Optional = bgColor.getOptional("bg_color") /** * Sets a background image from a URL. If this parameter is set, `bg_color` must be @@ -2672,7 +2756,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun bgImageUrl(): Optional = bgImageUrl.value.getOptional("bg_image_url") + fun bgImageUrl(): Optional = bgImageUrl.getOptional("bg_image_url") /** * Allows semi-transparent regions in the result. Default is true. Note: @@ -2682,47 +2766,47 @@ private constructor( * (e.g. if the server responded with an unexpected value). */ fun semitransparency(): Optional = - semitransparency.value.getOptional("semitransparency") + semitransparency.getOptional("semitransparency") /** - * Returns the raw multipart value of [addShadow]. + * Returns the raw JSON value of [addShadow]. * - * Unlike [addShadow], this method doesn't throw if the multipart field has an - * unexpected type. + * Unlike [addShadow], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("add_shadow") @ExcludeMissing - fun _addShadow(): MultipartField = addShadow + fun _addShadow(): JsonField = addShadow /** - * Returns the raw multipart value of [bgColor]. + * Returns the raw JSON value of [bgColor]. * - * Unlike [bgColor], this method doesn't throw if the multipart field has an - * unexpected type. + * Unlike [bgColor], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("bg_color") @ExcludeMissing - fun _bgColor(): MultipartField = bgColor + fun _bgColor(): JsonField = bgColor /** - * Returns the raw multipart value of [bgImageUrl]. + * Returns the raw JSON value of [bgImageUrl]. * - * Unlike [bgImageUrl], this method doesn't throw if the multipart field has an + * Unlike [bgImageUrl], this method doesn't throw if the JSON field has an * unexpected type. */ @JsonProperty("bg_image_url") @ExcludeMissing - fun _bgImageUrl(): MultipartField = bgImageUrl + fun _bgImageUrl(): JsonField = bgImageUrl /** - * Returns the raw multipart value of [semitransparency]. + * Returns the raw JSON value of [semitransparency]. * - * Unlike [semitransparency], this method doesn't throw if the multipart field has - * an unexpected type. + * Unlike [semitransparency], this method doesn't throw if the JSON field has an + * unexpected type. */ @JsonProperty("semitransparency") @ExcludeMissing - fun _semitransparency(): MultipartField = semitransparency + fun _semitransparency(): JsonField = semitransparency @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -2745,10 +2829,10 @@ private constructor( /** A builder for [Options]. */ class Builder internal constructor() { - private var addShadow: MultipartField = MultipartField.of(null) - private var bgColor: MultipartField = MultipartField.of(null) - private var bgImageUrl: MultipartField = MultipartField.of(null) - private var semitransparency: MultipartField = MultipartField.of(null) + private var addShadow: JsonField = JsonMissing.of() + private var bgColor: JsonField = JsonMissing.of() + private var bgImageUrl: JsonField = JsonMissing.of() + private var semitransparency: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2764,16 +2848,16 @@ private constructor( * Whether to add an artificial shadow to the result. Default is false. Note: * Adding shadows is currently only supported for car photos. */ - fun addShadow(addShadow: Boolean) = addShadow(MultipartField.of(addShadow)) + fun addShadow(addShadow: Boolean) = addShadow(JsonField.of(addShadow)) /** - * Sets [Builder.addShadow] to an arbitrary multipart value. + * Sets [Builder.addShadow] to an arbitrary JSON value. * * You should usually call [Builder.addShadow] with a well-typed [Boolean] value * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun addShadow(addShadow: MultipartField) = apply { + fun addShadow(addShadow: JsonField) = apply { this.addShadow = addShadow } @@ -2782,31 +2866,31 @@ private constructor( * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be * empty. */ - fun bgColor(bgColor: String) = bgColor(MultipartField.of(bgColor)) + fun bgColor(bgColor: String) = bgColor(JsonField.of(bgColor)) /** - * Sets [Builder.bgColor] to an arbitrary multipart value. + * Sets [Builder.bgColor] to an arbitrary JSON value. * * You should usually call [Builder.bgColor] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun bgColor(bgColor: MultipartField) = apply { this.bgColor = bgColor } + fun bgColor(bgColor: JsonField) = apply { this.bgColor = bgColor } /** * Sets a background image from a URL. If this parameter is set, `bg_color` must * be empty. */ - fun bgImageUrl(bgImageUrl: String) = bgImageUrl(MultipartField.of(bgImageUrl)) + fun bgImageUrl(bgImageUrl: String) = bgImageUrl(JsonField.of(bgImageUrl)) /** - * Sets [Builder.bgImageUrl] to an arbitrary multipart value. + * Sets [Builder.bgImageUrl] to an arbitrary JSON value. * * You should usually call [Builder.bgImageUrl] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun bgImageUrl(bgImageUrl: MultipartField) = apply { + fun bgImageUrl(bgImageUrl: JsonField) = apply { this.bgImageUrl = bgImageUrl } @@ -2815,16 +2899,16 @@ private constructor( * Semitransparency is currently only supported for car windows. */ fun semitransparency(semitransparency: Boolean) = - semitransparency(MultipartField.of(semitransparency)) + semitransparency(JsonField.of(semitransparency)) /** - * Sets [Builder.semitransparency] to an arbitrary multipart value. + * Sets [Builder.semitransparency] to an arbitrary JSON value. * * You should usually call [Builder.semitransparency] with a well-typed * [Boolean] value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun semitransparency(semitransparency: MultipartField) = apply { + fun semitransparency(semitransparency: JsonField) = apply { this.semitransparency = semitransparency } @@ -2887,6 +2971,19 @@ private constructor( false } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (addShadow.asKnown().isPresent) 1 else 0) + + (if (bgColor.asKnown().isPresent) 1 else 0) + + (if (bgImageUrl.asKnown().isPresent) 1 else 0) + + (if (semitransparency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2937,12 +3034,23 @@ private constructor( class AutoTaggingExtension private constructor( - private val maxTags: MultipartField, - private val minConfidence: MultipartField, - private val name: MultipartField, + private val maxTags: JsonField, + private val minConfidence: JsonField, + private val name: JsonField, private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("maxTags") + @ExcludeMissing + maxTags: JsonField = JsonMissing.of(), + @JsonProperty("minConfidence") + @ExcludeMissing + minConfidence: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(maxTags, minConfidence, name, mutableMapOf()) + /** * Maximum number of tags to attach to the asset. * @@ -2950,7 +3058,7 @@ private constructor( * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun maxTags(): Long = maxTags.value.getRequired("maxTags") + fun maxTags(): Long = maxTags.getRequired("maxTags") /** * Minimum confidence level for tags to be considered valid. @@ -2959,7 +3067,7 @@ private constructor( * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun minConfidence(): Long = minConfidence.value.getRequired("minConfidence") + fun minConfidence(): Long = minConfidence.getRequired("minConfidence") /** * Specifies the auto-tagging extension used. @@ -2968,33 +3076,31 @@ private constructor( * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun name(): Name = name.value.getRequired("name") + fun name(): Name = name.getRequired("name") /** - * Returns the raw multipart value of [maxTags]. + * Returns the raw JSON value of [maxTags]. * - * Unlike [maxTags], this method doesn't throw if the multipart field has an unexpected - * type. + * Unlike [maxTags], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("maxTags") @ExcludeMissing fun _maxTags(): MultipartField = maxTags + @JsonProperty("maxTags") @ExcludeMissing fun _maxTags(): JsonField = maxTags /** - * Returns the raw multipart value of [minConfidence]. + * Returns the raw JSON value of [minConfidence]. * - * Unlike [minConfidence], this method doesn't throw if the multipart field has an - * unexpected type. + * Unlike [minConfidence], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("minConfidence") @ExcludeMissing - fun _minConfidence(): MultipartField = minConfidence + fun _minConfidence(): JsonField = minConfidence /** - * Returns the raw multipart value of [name]. + * Returns the raw JSON value of [name]. * - * Unlike [name], this method doesn't throw if the multipart field has an unexpected - * type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -3026,9 +3132,9 @@ private constructor( /** A builder for [AutoTaggingExtension]. */ class Builder internal constructor() { - private var maxTags: MultipartField? = null - private var minConfidence: MultipartField? = null - private var name: MultipartField? = null + private var maxTags: JsonField? = null + private var minConfidence: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3040,43 +3146,42 @@ private constructor( } /** Maximum number of tags to attach to the asset. */ - fun maxTags(maxTags: Long) = maxTags(MultipartField.of(maxTags)) + fun maxTags(maxTags: Long) = maxTags(JsonField.of(maxTags)) /** - * Sets [Builder.maxTags] to an arbitrary multipart value. + * Sets [Builder.maxTags] to an arbitrary JSON value. * * You should usually call [Builder.maxTags] with a well-typed [Long] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun maxTags(maxTags: MultipartField) = apply { this.maxTags = maxTags } + fun maxTags(maxTags: JsonField) = apply { this.maxTags = maxTags } /** Minimum confidence level for tags to be considered valid. */ - fun minConfidence(minConfidence: Long) = - minConfidence(MultipartField.of(minConfidence)) + fun minConfidence(minConfidence: Long) = minConfidence(JsonField.of(minConfidence)) /** - * Sets [Builder.minConfidence] to an arbitrary multipart value. + * Sets [Builder.minConfidence] to an arbitrary JSON value. * * You should usually call [Builder.minConfidence] with a well-typed [Long] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun minConfidence(minConfidence: MultipartField) = apply { + fun minConfidence(minConfidence: JsonField) = apply { this.minConfidence = minConfidence } /** Specifies the auto-tagging extension used. */ - fun name(name: Name) = name(MultipartField.of(name)) + fun name(name: Name) = name(JsonField.of(name)) /** - * Sets [Builder.name] to an arbitrary multipart value. + * Sets [Builder.name] to an arbitrary JSON value. * * You should usually call [Builder.name] with a well-typed [Name] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun name(name: MultipartField) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3144,6 +3249,18 @@ private constructor( false } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (maxTags.asKnown().isPresent) 1 else 0) + + (if (minConfidence.asKnown().isPresent) 1 else 0) + + (name.asKnown().getOrNull()?.validity() ?: 0) + /** Specifies the auto-tagging extension used. */ class Name @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt index 2f8a39b0..186e95c7 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt @@ -29,6 +29,7 @@ import com.imagekit.api.core.http.Headers import com.imagekit.api.core.http.QueryParams import com.imagekit.api.core.toImmutable import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 import java.util.Collections import java.util.Objects import java.util.Optional @@ -418,7 +419,7 @@ private constructor( private val customCoordinates: JsonField, private val customMetadata: JsonField, private val description: JsonField, - private val extensions: JsonField>, + private val extensions: JsonField>, private val removeAiTags: JsonField, private val tags: JsonField>, private val webhookUrl: JsonField, @@ -438,7 +439,7 @@ private constructor( description: JsonField = JsonMissing.of(), @JsonProperty("extensions") @ExcludeMissing - extensions: JsonField> = JsonMissing.of(), + extensions: JsonField> = JsonMissing.of(), @JsonProperty("removeAITags") @ExcludeMissing removeAiTags: JsonField = JsonMissing.of(), @@ -495,7 +496,8 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun extensions(): Optional> = extensions.getOptional("extensions") + fun extensions(): Optional> = + extensions.getOptional("extensions") /** * An array of AITags associated with the file that you want to remove, e.g. `["car", @@ -569,7 +571,7 @@ private constructor( */ @JsonProperty("extensions") @ExcludeMissing - fun _extensions(): JsonField> = extensions + fun _extensions(): JsonField> = extensions /** * Returns the raw JSON value of [removeAiTags]. @@ -624,7 +626,8 @@ private constructor( private var customCoordinates: JsonField = JsonMissing.of() private var customMetadata: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() - private var extensions: JsonField>? = null + private var extensions: JsonField>? = + null private var removeAiTags: JsonField = JsonMissing.of() private var tags: JsonField>? = null private var webhookUrl: JsonField = JsonMissing.of() @@ -704,41 +707,56 @@ private constructor( * Array of extensions to be applied to the asset. Each extension can be configured * with specific parameters based on the extension type. */ - fun extensions(extensions: List) = extensions(JsonField.of(extensions)) + fun extensions(extensions: List) = + extensions(JsonField.of(extensions)) /** * Sets [Builder.extensions] to an arbitrary JSON value. * - * You should usually call [Builder.extensions] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * You should usually call [Builder.extensions] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - fun extensions(extensions: JsonField>) = apply { + fun extensions(extensions: JsonField>) = apply { this.extensions = extensions.map { it.toMutableList() } } /** - * Adds a single [Extension] to [extensions]. + * Adds a single [UnnamedSchemaWithArrayParent3] to [extensions]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addExtension(extension: Extension) = apply { + fun addExtension(extension: UnnamedSchemaWithArrayParent3) = apply { extensions = (extensions ?: JsonField.of(mutableListOf())).also { checkKnown("extensions", it).add(extension) } } - /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: Extension.RemoveBg) = - addExtension(Extension.ofRemoveBg(removeBg)) + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent3.ofRemoveBg(removeBg)`. + */ + fun addExtension(removeBg: UnnamedSchemaWithArrayParent3.RemoveBg) = + addExtension(UnnamedSchemaWithArrayParent3.ofRemoveBg(removeBg)) - /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: Extension.AutoTaggingExtension) = - addExtension(Extension.ofAutoTagging(autoTagging)) + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension(autoTaggingExtension)`. + */ + fun addExtension( + autoTaggingExtension: UnnamedSchemaWithArrayParent3.AutoTaggingExtension + ) = + addExtension( + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension(autoTaggingExtension) + ) - /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ - fun addExtensionAiAutoDescription() = addExtension(Extension.ofAiAutoDescription()) + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent3.ofAiAutoDescription()`. + */ + fun addExtensionAiAutoDescription() = + addExtension(UnnamedSchemaWithArrayParent3.ofAiAutoDescription()) /** * An array of AITags associated with the file that you want to remove, e.g. @@ -1015,32 +1033,34 @@ private constructor( "CustomMetadata{additionalProperties=$additionalProperties}" } - @JsonDeserialize(using = Extension.Deserializer::class) - @JsonSerialize(using = Extension.Serializer::class) - class Extension + @JsonDeserialize(using = UnnamedSchemaWithArrayParent3.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent3.Serializer::class) + class UnnamedSchemaWithArrayParent3 private constructor( private val removeBg: RemoveBg? = null, - private val autoTagging: AutoTaggingExtension? = null, + private val autoTaggingExtension: AutoTaggingExtension? = null, private val aiAutoDescription: JsonValue? = null, private val _json: JsonValue? = null, ) { fun removeBg(): Optional = Optional.ofNullable(removeBg) - fun autoTagging(): Optional = Optional.ofNullable(autoTagging) + fun autoTaggingExtension(): Optional = + Optional.ofNullable(autoTaggingExtension) fun aiAutoDescription(): Optional = Optional.ofNullable(aiAutoDescription) fun isRemoveBg(): Boolean = removeBg != null - fun isAutoTagging(): Boolean = autoTagging != null + fun isAutoTaggingExtension(): Boolean = autoTaggingExtension != null fun isAiAutoDescription(): Boolean = aiAutoDescription != null fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") - fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") + fun asAutoTaggingExtension(): AutoTaggingExtension = + autoTaggingExtension.getOrThrow("autoTaggingExtension") fun asAiAutoDescription(): JsonValue = aiAutoDescription.getOrThrow("aiAutoDescription") @@ -1050,7 +1070,8 @@ private constructor( fun accept(visitor: Visitor): T = when { removeBg != null -> visitor.visitRemoveBg(removeBg) - autoTagging != null -> visitor.visitAutoTagging(autoTagging) + autoTaggingExtension != null -> + visitor.visitAutoTaggingExtension(autoTaggingExtension) aiAutoDescription != null -> visitor.visitAiAutoDescription(aiAutoDescription) else -> visitor.unknown(_json) @@ -1058,7 +1079,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Extension = apply { + fun validate(): UnnamedSchemaWithArrayParent3 = apply { if (validated) { return@apply } @@ -1069,8 +1090,10 @@ private constructor( removeBg.validate() } - override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { - autoTagging.validate() + override fun visitAutoTaggingExtension( + autoTaggingExtension: AutoTaggingExtension + ) { + autoTaggingExtension.validate() } override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { @@ -1109,8 +1132,9 @@ private constructor( object : Visitor { override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() - override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = - autoTagging.validity() + override fun visitAutoTaggingExtension( + autoTaggingExtension: AutoTaggingExtension + ) = autoTaggingExtension.validity() override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = aiAutoDescription.let { @@ -1130,107 +1154,129 @@ private constructor( return true } - return other is Extension && + return other is UnnamedSchemaWithArrayParent3 && removeBg == other.removeBg && - autoTagging == other.autoTagging && + autoTaggingExtension == other.autoTaggingExtension && aiAutoDescription == other.aiAutoDescription } override fun hashCode(): Int = - Objects.hash(removeBg, autoTagging, aiAutoDescription) + Objects.hash(removeBg, autoTaggingExtension, aiAutoDescription) override fun toString(): String = when { - removeBg != null -> "Extension{removeBg=$removeBg}" - autoTagging != null -> "Extension{autoTagging=$autoTagging}" + removeBg != null -> "UnnamedSchemaWithArrayParent3{removeBg=$removeBg}" + autoTaggingExtension != null -> + "UnnamedSchemaWithArrayParent3{autoTaggingExtension=$autoTaggingExtension}" aiAutoDescription != null -> - "Extension{aiAutoDescription=$aiAutoDescription}" - _json != null -> "Extension{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Extension") + "UnnamedSchemaWithArrayParent3{aiAutoDescription=$aiAutoDescription}" + _json != null -> "UnnamedSchemaWithArrayParent3{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") } companion object { - @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = Extension(removeBg = removeBg) + @JvmStatic + fun ofRemoveBg(removeBg: RemoveBg) = + UnnamedSchemaWithArrayParent3(removeBg = removeBg) @JvmStatic - fun ofAutoTagging(autoTagging: AutoTaggingExtension) = - Extension(autoTagging = autoTagging) + fun ofAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension) = + UnnamedSchemaWithArrayParent3(autoTaggingExtension = autoTaggingExtension) @JvmStatic fun ofAiAutoDescription() = - Extension( + UnnamedSchemaWithArrayParent3( aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) ) } /** - * An interface that defines how to map each variant of [Extension] to a value of - * type [T]. + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent3] to a value of type [T]. */ interface Visitor { fun visitRemoveBg(removeBg: RemoveBg): T - fun visitAutoTagging(autoTagging: AutoTaggingExtension): T + fun visitAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension): T fun visitAiAutoDescription(aiAutoDescription: JsonValue): T /** - * Maps an unknown variant of [Extension] to a value of type [T]. + * Maps an unknown variant of [UnnamedSchemaWithArrayParent3] to a value of type + * [T]. * - * An instance of [Extension] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. + * An instance of [UnnamedSchemaWithArrayParent3] can contain an unknown variant + * if it was deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new variants that the SDK is unaware of. * * @throws ImageKitInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Extension: $json") + throw ImageKitInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent3: $json" + ) } } - internal class Deserializer : BaseDeserializer(Extension::class) { + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent3::class + ) { - override fun ObjectCodec.deserialize(node: JsonNode): Extension { + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent3 { val json = JsonValue.fromJsonNode(node) val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() when (name) { "remove-bg" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Extension(removeBg = it, _json = json) - } ?: Extension(_json = json) + UnnamedSchemaWithArrayParent3(removeBg = it, _json = json) + } ?: UnnamedSchemaWithArrayParent3(_json = json) } "ai-auto-description" -> { return tryDeserialize(node, jacksonTypeRef()) - ?.let { Extension(aiAutoDescription = it, _json = json) } - ?.takeIf { it.isValid() } ?: Extension(_json = json) + ?.let { + UnnamedSchemaWithArrayParent3( + aiAutoDescription = it, + _json = json, + ) + } + ?.takeIf { it.isValid() } + ?: UnnamedSchemaWithArrayParent3(_json = json) } } return tryDeserialize(node, jacksonTypeRef())?.let { - Extension(autoTagging = it, _json = json) - } ?: Extension(_json = json) + UnnamedSchemaWithArrayParent3(autoTaggingExtension = it, _json = json) + } ?: UnnamedSchemaWithArrayParent3(_json = json) } } - internal class Serializer : BaseSerializer(Extension::class) { + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent3::class + ) { override fun serialize( - value: Extension, + value: UnnamedSchemaWithArrayParent3, generator: JsonGenerator, provider: SerializerProvider, ) { when { value.removeBg != null -> generator.writeObject(value.removeBg) - value.autoTagging != null -> generator.writeObject(value.autoTagging) + value.autoTaggingExtension != null -> + generator.writeObject(value.autoTaggingExtension) value.aiAutoDescription != null -> generator.writeObject(value.aiAutoDescription) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Extension") + else -> + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") } } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt index 2e8828a4..5306b662 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -18,6 +18,7 @@ import com.imagekit.api.core.BaseSerializer import com.imagekit.api.core.Enum import com.imagekit.api.core.ExcludeMissing import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField import com.imagekit.api.core.Params @@ -28,6 +29,7 @@ import com.imagekit.api.core.http.Headers import com.imagekit.api.core.http.QueryParams import com.imagekit.api.core.toImmutable import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 import java.io.InputStream import java.nio.file.Path import java.util.Collections @@ -165,7 +167,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun extensions(): Optional> = body.extensions() + fun extensions(): Optional> = body.extensions() /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, @@ -386,7 +388,7 @@ private constructor( * * Unlike [extensions], this method doesn't throw if the multipart field has an unexpected type. */ - fun _extensions(): MultipartField> = body._extensions() + fun _extensions(): MultipartField> = body._extensions() /** * Returns the raw multipart value of [folder]. @@ -717,35 +719,51 @@ private constructor( * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ - fun extensions(extensions: List) = apply { body.extensions(extensions) } + fun extensions(extensions: List) = apply { + body.extensions(extensions) + } /** * Sets [Builder.extensions] to an arbitrary multipart value. * - * You should usually call [Builder.extensions] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.extensions] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun extensions(extensions: MultipartField>) = apply { + fun extensions(extensions: MultipartField>) = apply { body.extensions(extensions) } /** - * Adds a single [Extension] to [extensions]. + * Adds a single [UnnamedSchemaWithArrayParent3] to [extensions]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addExtension(extension: Extension) = apply { body.addExtension(extension) } - - /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: Extension.RemoveBg) = apply { body.addExtension(removeBg) } + fun addExtension(extension: UnnamedSchemaWithArrayParent3) = apply { + body.addExtension(extension) + } - /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: Extension.AutoTaggingExtension) = apply { - body.addExtension(autoTagging) + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent3.ofRemoveBg(removeBg)`. + */ + fun addExtension(removeBg: UnnamedSchemaWithArrayParent3.RemoveBg) = apply { + body.addExtension(removeBg) } - /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension(autoTaggingExtension)`. + */ + fun addExtension(autoTaggingExtension: UnnamedSchemaWithArrayParent3.AutoTaggingExtension) = + apply { + body.addExtension(autoTaggingExtension) + } + + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent3.ofAiAutoDescription()`. + */ fun addExtensionAiAutoDescription() = apply { body.addExtensionAiAutoDescription() } /** @@ -1205,7 +1223,7 @@ private constructor( private val customMetadata: MultipartField, private val description: MultipartField, private val expire: MultipartField, - private val extensions: MultipartField>, + private val extensions: MultipartField>, private val folder: MultipartField, private val isPrivateFile: MultipartField, private val isPublished: MultipartField, @@ -1324,7 +1342,8 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun extensions(): Optional> = extensions.value.getOptional("extensions") + fun extensions(): Optional> = + extensions.value.getOptional("extensions") /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist @@ -1561,7 +1580,7 @@ private constructor( */ @JsonProperty("extensions") @ExcludeMissing - fun _extensions(): MultipartField> = extensions + fun _extensions(): MultipartField> = extensions /** * Returns the raw multipart value of [folder]. @@ -1734,7 +1753,8 @@ private constructor( private var customMetadata: MultipartField = MultipartField.of(null) private var description: MultipartField = MultipartField.of(null) private var expire: MultipartField = MultipartField.of(null) - private var extensions: MultipartField>? = null + private var extensions: MultipartField>? = + null private var folder: MultipartField = MultipartField.of(null) private var isPrivateFile: MultipartField = MultipartField.of(null) private var isPublished: MultipartField = MultipartField.of(null) @@ -1957,41 +1977,57 @@ private constructor( * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ - fun extensions(extensions: List) = extensions(MultipartField.of(extensions)) + fun extensions(extensions: List) = + extensions(MultipartField.of(extensions)) /** * Sets [Builder.extensions] to an arbitrary multipart value. * - * You should usually call [Builder.extensions] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.extensions] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. */ - fun extensions(extensions: MultipartField>) = apply { - this.extensions = extensions.map { it.toMutableList() } - } + fun extensions(extensions: MultipartField>) = + apply { + this.extensions = extensions.map { it.toMutableList() } + } /** - * Adds a single [Extension] to [extensions]. + * Adds a single [UnnamedSchemaWithArrayParent3] to [extensions]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addExtension(extension: Extension) = apply { + fun addExtension(extension: UnnamedSchemaWithArrayParent3) = apply { extensions = (extensions ?: MultipartField.of(mutableListOf())).also { checkKnown("extensions", it).add(extension) } } - /** Alias for calling [addExtension] with `Extension.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: Extension.RemoveBg) = - addExtension(Extension.ofRemoveBg(removeBg)) + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent3.ofRemoveBg(removeBg)`. + */ + fun addExtension(removeBg: UnnamedSchemaWithArrayParent3.RemoveBg) = + addExtension(UnnamedSchemaWithArrayParent3.ofRemoveBg(removeBg)) - /** Alias for calling [addExtension] with `Extension.ofAutoTagging(autoTagging)`. */ - fun addExtension(autoTagging: Extension.AutoTaggingExtension) = - addExtension(Extension.ofAutoTagging(autoTagging)) + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension(autoTaggingExtension)`. + */ + fun addExtension( + autoTaggingExtension: UnnamedSchemaWithArrayParent3.AutoTaggingExtension + ) = + addExtension( + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension(autoTaggingExtension) + ) - /** Alias for calling [addExtension] with `Extension.ofAiAutoDescription()`. */ - fun addExtensionAiAutoDescription() = addExtension(Extension.ofAiAutoDescription()) + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent3.ofAiAutoDescription()`. + */ + fun addExtensionAiAutoDescription() = + addExtension(UnnamedSchemaWithArrayParent3.ofAiAutoDescription()) /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist @@ -2548,31 +2584,33 @@ private constructor( override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" } - @JsonDeserialize(using = Extension.Deserializer::class) - @JsonSerialize(using = Extension.Serializer::class) - class Extension + @JsonDeserialize(using = UnnamedSchemaWithArrayParent3.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent3.Serializer::class) + class UnnamedSchemaWithArrayParent3 private constructor( private val removeBg: RemoveBg? = null, - private val autoTagging: AutoTaggingExtension? = null, + private val autoTaggingExtension: AutoTaggingExtension? = null, private val aiAutoDescription: JsonValue? = null, private val _json: JsonValue? = null, ) { fun removeBg(): Optional = Optional.ofNullable(removeBg) - fun autoTagging(): Optional = Optional.ofNullable(autoTagging) + fun autoTaggingExtension(): Optional = + Optional.ofNullable(autoTaggingExtension) fun aiAutoDescription(): Optional = Optional.ofNullable(aiAutoDescription) fun isRemoveBg(): Boolean = removeBg != null - fun isAutoTagging(): Boolean = autoTagging != null + fun isAutoTaggingExtension(): Boolean = autoTaggingExtension != null fun isAiAutoDescription(): Boolean = aiAutoDescription != null fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") - fun asAutoTagging(): AutoTaggingExtension = autoTagging.getOrThrow("autoTagging") + fun asAutoTaggingExtension(): AutoTaggingExtension = + autoTaggingExtension.getOrThrow("autoTaggingExtension") fun asAiAutoDescription(): JsonValue = aiAutoDescription.getOrThrow("aiAutoDescription") @@ -2581,14 +2619,15 @@ private constructor( fun accept(visitor: Visitor): T = when { removeBg != null -> visitor.visitRemoveBg(removeBg) - autoTagging != null -> visitor.visitAutoTagging(autoTagging) + autoTaggingExtension != null -> + visitor.visitAutoTaggingExtension(autoTaggingExtension) aiAutoDescription != null -> visitor.visitAiAutoDescription(aiAutoDescription) else -> visitor.unknown(_json) } private var validated: Boolean = false - fun validate(): Extension = apply { + fun validate(): UnnamedSchemaWithArrayParent3 = apply { if (validated) { return@apply } @@ -2599,8 +2638,10 @@ private constructor( removeBg.validate() } - override fun visitAutoTagging(autoTagging: AutoTaggingExtension) { - autoTagging.validate() + override fun visitAutoTaggingExtension( + autoTaggingExtension: AutoTaggingExtension + ) { + autoTaggingExtension.validate() } override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { @@ -2637,8 +2678,9 @@ private constructor( object : Visitor { override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() - override fun visitAutoTagging(autoTagging: AutoTaggingExtension) = - autoTagging.validity() + override fun visitAutoTaggingExtension( + autoTaggingExtension: AutoTaggingExtension + ) = autoTaggingExtension.validity() override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = aiAutoDescription.let { @@ -2655,103 +2697,113 @@ private constructor( return true } - return other is Extension && + return other is UnnamedSchemaWithArrayParent3 && removeBg == other.removeBg && - autoTagging == other.autoTagging && + autoTaggingExtension == other.autoTaggingExtension && aiAutoDescription == other.aiAutoDescription } - override fun hashCode(): Int = Objects.hash(removeBg, autoTagging, aiAutoDescription) + override fun hashCode(): Int = + Objects.hash(removeBg, autoTaggingExtension, aiAutoDescription) override fun toString(): String = when { - removeBg != null -> "Extension{removeBg=$removeBg}" - autoTagging != null -> "Extension{autoTagging=$autoTagging}" - aiAutoDescription != null -> "Extension{aiAutoDescription=$aiAutoDescription}" - _json != null -> "Extension{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Extension") + removeBg != null -> "UnnamedSchemaWithArrayParent3{removeBg=$removeBg}" + autoTaggingExtension != null -> + "UnnamedSchemaWithArrayParent3{autoTaggingExtension=$autoTaggingExtension}" + aiAutoDescription != null -> + "UnnamedSchemaWithArrayParent3{aiAutoDescription=$aiAutoDescription}" + _json != null -> "UnnamedSchemaWithArrayParent3{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") } companion object { - @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = Extension(removeBg = removeBg) + @JvmStatic + fun ofRemoveBg(removeBg: RemoveBg) = UnnamedSchemaWithArrayParent3(removeBg = removeBg) @JvmStatic - fun ofAutoTagging(autoTagging: AutoTaggingExtension) = - Extension(autoTagging = autoTagging) + fun ofAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension) = + UnnamedSchemaWithArrayParent3(autoTaggingExtension = autoTaggingExtension) @JvmStatic fun ofAiAutoDescription() = - Extension( + UnnamedSchemaWithArrayParent3( aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) ) } /** - * An interface that defines how to map each variant of [Extension] to a value of type [T]. + * An interface that defines how to map each variant of [UnnamedSchemaWithArrayParent3] to a + * value of type [T]. */ interface Visitor { fun visitRemoveBg(removeBg: RemoveBg): T - fun visitAutoTagging(autoTagging: AutoTaggingExtension): T + fun visitAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension): T fun visitAiAutoDescription(aiAutoDescription: JsonValue): T /** - * Maps an unknown variant of [Extension] to a value of type [T]. + * Maps an unknown variant of [UnnamedSchemaWithArrayParent3] to a value of type [T]. * - * An instance of [Extension] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [UnnamedSchemaWithArrayParent3] can contain an unknown variant if it + * was deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. * * @throws ImageKitInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Extension: $json") + throw ImageKitInvalidDataException("Unknown UnnamedSchemaWithArrayParent3: $json") } } - internal class Deserializer : BaseDeserializer(Extension::class) { + internal class Deserializer : + BaseDeserializer(UnnamedSchemaWithArrayParent3::class) { - override fun ObjectCodec.deserialize(node: JsonNode): Extension { + override fun ObjectCodec.deserialize(node: JsonNode): UnnamedSchemaWithArrayParent3 { val json = JsonValue.fromJsonNode(node) val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() when (name) { "remove-bg" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - Extension(removeBg = it, _json = json) - } ?: Extension(_json = json) + UnnamedSchemaWithArrayParent3(removeBg = it, _json = json) + } ?: UnnamedSchemaWithArrayParent3(_json = json) } "ai-auto-description" -> { return tryDeserialize(node, jacksonTypeRef()) - ?.let { Extension(aiAutoDescription = it, _json = json) } - ?.takeIf { it.isValid() } ?: Extension(_json = json) + ?.let { + UnnamedSchemaWithArrayParent3(aiAutoDescription = it, _json = json) + } + ?.takeIf { it.isValid() } ?: UnnamedSchemaWithArrayParent3(_json = json) } } return tryDeserialize(node, jacksonTypeRef())?.let { - Extension(autoTagging = it, _json = json) - } ?: Extension(_json = json) + UnnamedSchemaWithArrayParent3(autoTaggingExtension = it, _json = json) + } ?: UnnamedSchemaWithArrayParent3(_json = json) } } - internal class Serializer : BaseSerializer(Extension::class) { + internal class Serializer : + BaseSerializer(UnnamedSchemaWithArrayParent3::class) { override fun serialize( - value: Extension, + value: UnnamedSchemaWithArrayParent3, generator: JsonGenerator, provider: SerializerProvider, ) { when { value.removeBg != null -> generator.writeObject(value.removeBg) - value.autoTagging != null -> generator.writeObject(value.autoTagging) + value.autoTaggingExtension != null -> + generator.writeObject(value.autoTaggingExtension) value.aiAutoDescription != null -> generator.writeObject(value.aiAutoDescription) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Extension") + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") } } } @@ -2759,10 +2811,18 @@ private constructor( class RemoveBg private constructor( private val name: JsonValue, - private val options: MultipartField, + private val options: JsonField, private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + options: JsonField = JsonMissing.of(), + ) : this(name, options, mutableMapOf()) + /** * Specifies the background removal extension. * @@ -2780,17 +2840,14 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun options(): Optional = options.value.getOptional("options") + fun options(): Optional = options.getOptional("options") /** - * Returns the raw multipart value of [options]. + * Returns the raw JSON value of [options]. * - * Unlike [options], this method doesn't throw if the multipart field has an unexpected - * type. + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("options") - @ExcludeMissing - fun _options(): MultipartField = options + @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -2814,7 +2871,7 @@ private constructor( class Builder internal constructor() { private var name: JsonValue = JsonValue.from("remove-bg") - private var options: MultipartField = MultipartField.of(null) + private var options: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2838,16 +2895,16 @@ private constructor( */ fun name(name: JsonValue) = apply { this.name = name } - fun options(options: Options) = options(MultipartField.of(options)) + fun options(options: Options) = options(JsonField.of(options)) /** - * Sets [Builder.options] to an arbitrary multipart value. + * Sets [Builder.options] to an arbitrary JSON value. * * You should usually call [Builder.options] with a well-typed [Options] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun options(options: MultipartField) = apply { this.options = options } + fun options(options: JsonField) = apply { this.options = options } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2903,15 +2960,42 @@ private constructor( false } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + name.let { if (it == JsonValue.from("remove-bg")) 1 else 0 } + + (options.asKnown().getOrNull()?.validity() ?: 0) + class Options private constructor( - private val addShadow: MultipartField, - private val bgColor: MultipartField, - private val bgImageUrl: MultipartField, - private val semitransparency: MultipartField, + private val addShadow: JsonField, + private val bgColor: JsonField, + private val bgImageUrl: JsonField, + private val semitransparency: JsonField, private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("add_shadow") + @ExcludeMissing + addShadow: JsonField = JsonMissing.of(), + @JsonProperty("bg_color") + @ExcludeMissing + bgColor: JsonField = JsonMissing.of(), + @JsonProperty("bg_image_url") + @ExcludeMissing + bgImageUrl: JsonField = JsonMissing.of(), + @JsonProperty("semitransparency") + @ExcludeMissing + semitransparency: JsonField = JsonMissing.of(), + ) : this(addShadow, bgColor, bgImageUrl, semitransparency, mutableMapOf()) + /** * Whether to add an artificial shadow to the result. Default is false. Note: Adding * shadows is currently only supported for car photos. @@ -2919,7 +3003,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun addShadow(): Optional = addShadow.value.getOptional("add_shadow") + fun addShadow(): Optional = addShadow.getOptional("add_shadow") /** * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or @@ -2929,7 +3013,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun bgColor(): Optional = bgColor.value.getOptional("bg_color") + fun bgColor(): Optional = bgColor.getOptional("bg_color") /** * Sets a background image from a URL. If this parameter is set, `bg_color` must be @@ -2938,7 +3022,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun bgImageUrl(): Optional = bgImageUrl.value.getOptional("bg_image_url") + fun bgImageUrl(): Optional = bgImageUrl.getOptional("bg_image_url") /** * Allows semi-transparent regions in the result. Default is true. Note: @@ -2948,47 +3032,47 @@ private constructor( * (e.g. if the server responded with an unexpected value). */ fun semitransparency(): Optional = - semitransparency.value.getOptional("semitransparency") + semitransparency.getOptional("semitransparency") /** - * Returns the raw multipart value of [addShadow]. + * Returns the raw JSON value of [addShadow]. * - * Unlike [addShadow], this method doesn't throw if the multipart field has an - * unexpected type. + * Unlike [addShadow], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("add_shadow") @ExcludeMissing - fun _addShadow(): MultipartField = addShadow + fun _addShadow(): JsonField = addShadow /** - * Returns the raw multipart value of [bgColor]. + * Returns the raw JSON value of [bgColor]. * - * Unlike [bgColor], this method doesn't throw if the multipart field has an - * unexpected type. + * Unlike [bgColor], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("bg_color") @ExcludeMissing - fun _bgColor(): MultipartField = bgColor + fun _bgColor(): JsonField = bgColor /** - * Returns the raw multipart value of [bgImageUrl]. + * Returns the raw JSON value of [bgImageUrl]. * - * Unlike [bgImageUrl], this method doesn't throw if the multipart field has an + * Unlike [bgImageUrl], this method doesn't throw if the JSON field has an * unexpected type. */ @JsonProperty("bg_image_url") @ExcludeMissing - fun _bgImageUrl(): MultipartField = bgImageUrl + fun _bgImageUrl(): JsonField = bgImageUrl /** - * Returns the raw multipart value of [semitransparency]. + * Returns the raw JSON value of [semitransparency]. * - * Unlike [semitransparency], this method doesn't throw if the multipart field has - * an unexpected type. + * Unlike [semitransparency], this method doesn't throw if the JSON field has an + * unexpected type. */ @JsonProperty("semitransparency") @ExcludeMissing - fun _semitransparency(): MultipartField = semitransparency + fun _semitransparency(): JsonField = semitransparency @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -3011,10 +3095,10 @@ private constructor( /** A builder for [Options]. */ class Builder internal constructor() { - private var addShadow: MultipartField = MultipartField.of(null) - private var bgColor: MultipartField = MultipartField.of(null) - private var bgImageUrl: MultipartField = MultipartField.of(null) - private var semitransparency: MultipartField = MultipartField.of(null) + private var addShadow: JsonField = JsonMissing.of() + private var bgColor: JsonField = JsonMissing.of() + private var bgImageUrl: JsonField = JsonMissing.of() + private var semitransparency: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3030,16 +3114,16 @@ private constructor( * Whether to add an artificial shadow to the result. Default is false. Note: * Adding shadows is currently only supported for car photos. */ - fun addShadow(addShadow: Boolean) = addShadow(MultipartField.of(addShadow)) + fun addShadow(addShadow: Boolean) = addShadow(JsonField.of(addShadow)) /** - * Sets [Builder.addShadow] to an arbitrary multipart value. + * Sets [Builder.addShadow] to an arbitrary JSON value. * * You should usually call [Builder.addShadow] with a well-typed [Boolean] value * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun addShadow(addShadow: MultipartField) = apply { + fun addShadow(addShadow: JsonField) = apply { this.addShadow = addShadow } @@ -3048,31 +3132,31 @@ private constructor( * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be * empty. */ - fun bgColor(bgColor: String) = bgColor(MultipartField.of(bgColor)) + fun bgColor(bgColor: String) = bgColor(JsonField.of(bgColor)) /** - * Sets [Builder.bgColor] to an arbitrary multipart value. + * Sets [Builder.bgColor] to an arbitrary JSON value. * * You should usually call [Builder.bgColor] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun bgColor(bgColor: MultipartField) = apply { this.bgColor = bgColor } + fun bgColor(bgColor: JsonField) = apply { this.bgColor = bgColor } /** * Sets a background image from a URL. If this parameter is set, `bg_color` must * be empty. */ - fun bgImageUrl(bgImageUrl: String) = bgImageUrl(MultipartField.of(bgImageUrl)) + fun bgImageUrl(bgImageUrl: String) = bgImageUrl(JsonField.of(bgImageUrl)) /** - * Sets [Builder.bgImageUrl] to an arbitrary multipart value. + * Sets [Builder.bgImageUrl] to an arbitrary JSON value. * * You should usually call [Builder.bgImageUrl] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or * not yet supported value. */ - fun bgImageUrl(bgImageUrl: MultipartField) = apply { + fun bgImageUrl(bgImageUrl: JsonField) = apply { this.bgImageUrl = bgImageUrl } @@ -3081,16 +3165,16 @@ private constructor( * Semitransparency is currently only supported for car windows. */ fun semitransparency(semitransparency: Boolean) = - semitransparency(MultipartField.of(semitransparency)) + semitransparency(JsonField.of(semitransparency)) /** - * Sets [Builder.semitransparency] to an arbitrary multipart value. + * Sets [Builder.semitransparency] to an arbitrary JSON value. * * You should usually call [Builder.semitransparency] with a well-typed * [Boolean] value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun semitransparency(semitransparency: MultipartField) = apply { + fun semitransparency(semitransparency: JsonField) = apply { this.semitransparency = semitransparency } @@ -3153,6 +3237,19 @@ private constructor( false } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (addShadow.asKnown().isPresent) 1 else 0) + + (if (bgColor.asKnown().isPresent) 1 else 0) + + (if (bgImageUrl.asKnown().isPresent) 1 else 0) + + (if (semitransparency.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3203,12 +3300,23 @@ private constructor( class AutoTaggingExtension private constructor( - private val maxTags: MultipartField, - private val minConfidence: MultipartField, - private val name: MultipartField, + private val maxTags: JsonField, + private val minConfidence: JsonField, + private val name: JsonField, private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("maxTags") + @ExcludeMissing + maxTags: JsonField = JsonMissing.of(), + @JsonProperty("minConfidence") + @ExcludeMissing + minConfidence: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(maxTags, minConfidence, name, mutableMapOf()) + /** * Maximum number of tags to attach to the asset. * @@ -3216,7 +3324,7 @@ private constructor( * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun maxTags(): Long = maxTags.value.getRequired("maxTags") + fun maxTags(): Long = maxTags.getRequired("maxTags") /** * Minimum confidence level for tags to be considered valid. @@ -3225,7 +3333,7 @@ private constructor( * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun minConfidence(): Long = minConfidence.value.getRequired("minConfidence") + fun minConfidence(): Long = minConfidence.getRequired("minConfidence") /** * Specifies the auto-tagging extension used. @@ -3234,33 +3342,31 @@ private constructor( * unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun name(): Name = name.value.getRequired("name") + fun name(): Name = name.getRequired("name") /** - * Returns the raw multipart value of [maxTags]. + * Returns the raw JSON value of [maxTags]. * - * Unlike [maxTags], this method doesn't throw if the multipart field has an unexpected - * type. + * Unlike [maxTags], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("maxTags") @ExcludeMissing fun _maxTags(): MultipartField = maxTags + @JsonProperty("maxTags") @ExcludeMissing fun _maxTags(): JsonField = maxTags /** - * Returns the raw multipart value of [minConfidence]. + * Returns the raw JSON value of [minConfidence]. * - * Unlike [minConfidence], this method doesn't throw if the multipart field has an - * unexpected type. + * Unlike [minConfidence], this method doesn't throw if the JSON field has an unexpected + * type. */ @JsonProperty("minConfidence") @ExcludeMissing - fun _minConfidence(): MultipartField = minConfidence + fun _minConfidence(): JsonField = minConfidence /** - * Returns the raw multipart value of [name]. + * Returns the raw JSON value of [name]. * - * Unlike [name], this method doesn't throw if the multipart field has an unexpected - * type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): MultipartField = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -3292,9 +3398,9 @@ private constructor( /** A builder for [AutoTaggingExtension]. */ class Builder internal constructor() { - private var maxTags: MultipartField? = null - private var minConfidence: MultipartField? = null - private var name: MultipartField? = null + private var maxTags: JsonField? = null + private var minConfidence: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3306,43 +3412,42 @@ private constructor( } /** Maximum number of tags to attach to the asset. */ - fun maxTags(maxTags: Long) = maxTags(MultipartField.of(maxTags)) + fun maxTags(maxTags: Long) = maxTags(JsonField.of(maxTags)) /** - * Sets [Builder.maxTags] to an arbitrary multipart value. + * Sets [Builder.maxTags] to an arbitrary JSON value. * * You should usually call [Builder.maxTags] with a well-typed [Long] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun maxTags(maxTags: MultipartField) = apply { this.maxTags = maxTags } + fun maxTags(maxTags: JsonField) = apply { this.maxTags = maxTags } /** Minimum confidence level for tags to be considered valid. */ - fun minConfidence(minConfidence: Long) = - minConfidence(MultipartField.of(minConfidence)) + fun minConfidence(minConfidence: Long) = minConfidence(JsonField.of(minConfidence)) /** - * Sets [Builder.minConfidence] to an arbitrary multipart value. + * Sets [Builder.minConfidence] to an arbitrary JSON value. * * You should usually call [Builder.minConfidence] with a well-typed [Long] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun minConfidence(minConfidence: MultipartField) = apply { + fun minConfidence(minConfidence: JsonField) = apply { this.minConfidence = minConfidence } /** Specifies the auto-tagging extension used. */ - fun name(name: Name) = name(MultipartField.of(name)) + fun name(name: Name) = name(JsonField.of(name)) /** - * Sets [Builder.name] to an arbitrary multipart value. + * Sets [Builder.name] to an arbitrary JSON value. * * You should usually call [Builder.name] with a well-typed [Name] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun name(name: MultipartField) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3410,6 +3515,18 @@ private constructor( false } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (maxTags.asKnown().isPresent) 1 else 0) + + (if (minConfidence.asKnown().isPresent) 1 else 0) + + (name.asKnown().getOrNull()?.validity() ?: 0) + /** Specifies the auto-tagging extension used. */ class Name @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt index 89ff5672..abc2c34f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt @@ -4,6 +4,7 @@ package com.imagekit.api.models.beta.v2.files import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField +import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -27,10 +28,10 @@ internal class FileUploadParamsTest { .description("Running shoes") .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -39,17 +40,17 @@ internal class FileUploadParamsTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") @@ -106,10 +107,10 @@ internal class FileUploadParamsTest { .description("Running shoes") .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -118,17 +119,17 @@ internal class FileUploadParamsTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") @@ -194,10 +195,10 @@ internal class FileUploadParamsTest { "extensions" to MultipartField.of( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options + UnnamedSchemaWithArrayParent3.RemoveBg.Options .builder() .addShadow(true) .bgColor("bg_color") @@ -207,17 +208,18 @@ internal class FileUploadParamsTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension + .Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ), "folder" to MultipartField.of("folder"), diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt index 41e97d1c..7dce3e33 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt @@ -3,6 +3,7 @@ package com.imagekit.api.models.files import com.imagekit.api.core.JsonValue +import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -25,13 +26,10 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - FileUpdateParams.Update.UpdateFileDetails.Extension.ofRemoveBg( - FileUpdateParams.Update.UpdateFileDetails.Extension.RemoveBg - .builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUpdateParams.Update.UpdateFileDetails.Extension.RemoveBg - .Options - .builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -40,36 +38,27 @@ internal class FileUpdateParamsTest { ) .build() ), - FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Update.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Update.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Update.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Update.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .AWS_AUTO_TAGGING ) .build() ), - FileUpdateParams.Update.UpdateFileDetails.Extension - .ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) @@ -107,14 +96,10 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - FileUpdateParams.Update.UpdateFileDetails.Extension.ofRemoveBg( - FileUpdateParams.Update.UpdateFileDetails.Extension.RemoveBg - .builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUpdateParams.Update.UpdateFileDetails.Extension - .RemoveBg - .Options - .builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -123,36 +108,27 @@ internal class FileUpdateParamsTest { ) .build() ), - FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Update.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Update.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Update.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Update.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .AWS_AUTO_TAGGING ) .build() ), - FileUpdateParams.Update.UpdateFileDetails.Extension - .ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) @@ -179,14 +155,10 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - FileUpdateParams.Update.UpdateFileDetails.Extension.ofRemoveBg( - FileUpdateParams.Update.UpdateFileDetails.Extension.RemoveBg - .builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUpdateParams.Update.UpdateFileDetails.Extension - .RemoveBg - .Options - .builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -195,36 +167,27 @@ internal class FileUpdateParamsTest { ) .build() ), - FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Update.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Update.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUpdateParams.Update.UpdateFileDetails.Extension.ofAutoTagging( - FileUpdateParams.Update.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - FileUpdateParams.Update.UpdateFileDetails.Extension - .AutoTaggingExtension - .Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .AWS_AUTO_TAGGING ) .build() ), - FileUpdateParams.Update.UpdateFileDetails.Extension - .ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt index 11752909..36a36468 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt @@ -4,6 +4,7 @@ package com.imagekit.api.models.files import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField +import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -28,10 +29,10 @@ internal class FileUploadParamsTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -40,17 +41,17 @@ internal class FileUploadParamsTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") @@ -110,10 +111,10 @@ internal class FileUploadParamsTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -122,17 +123,17 @@ internal class FileUploadParamsTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") @@ -201,10 +202,10 @@ internal class FileUploadParamsTest { "extensions" to MultipartField.of( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options + UnnamedSchemaWithArrayParent3.RemoveBg.Options .builder() .addShadow(true) .bgColor("bg_color") @@ -214,17 +215,18 @@ internal class FileUploadParamsTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension + .Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ), "folder" to MultipartField.of("folder"), diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt index 33349dd2..00dad8c0 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt @@ -22,6 +22,7 @@ import com.imagekit.api.errors.RateLimitException import com.imagekit.api.errors.UnauthorizedException import com.imagekit.api.errors.UnexpectedStatusCodeException import com.imagekit.api.errors.UnprocessableEntityException +import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 import com.imagekit.api.models.files.FileUploadParams import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.entry @@ -88,10 +89,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -100,17 +101,17 @@ internal class ErrorHandlingTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") @@ -188,10 +189,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -200,17 +201,17 @@ internal class ErrorHandlingTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") @@ -288,10 +289,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -300,17 +301,17 @@ internal class ErrorHandlingTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") @@ -388,10 +389,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -400,17 +401,17 @@ internal class ErrorHandlingTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") @@ -488,10 +489,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -500,17 +501,17 @@ internal class ErrorHandlingTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") @@ -588,10 +589,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -600,17 +601,17 @@ internal class ErrorHandlingTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") @@ -688,10 +689,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -700,17 +701,17 @@ internal class ErrorHandlingTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") @@ -788,10 +789,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -800,17 +801,17 @@ internal class ErrorHandlingTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") @@ -888,10 +889,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -900,17 +901,17 @@ internal class ErrorHandlingTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") @@ -988,10 +989,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1000,17 +1001,17 @@ internal class ErrorHandlingTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") @@ -1088,10 +1089,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1100,17 +1101,17 @@ internal class ErrorHandlingTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") @@ -1188,10 +1189,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1200,17 +1201,17 @@ internal class ErrorHandlingTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") @@ -1288,10 +1289,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1300,17 +1301,17 @@ internal class ErrorHandlingTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") @@ -1388,10 +1389,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1400,17 +1401,17 @@ internal class ErrorHandlingTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") @@ -1488,10 +1489,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1500,17 +1501,17 @@ internal class ErrorHandlingTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") @@ -1588,10 +1589,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1600,17 +1601,17 @@ internal class ErrorHandlingTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") @@ -1686,10 +1687,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1698,17 +1699,17 @@ internal class ErrorHandlingTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt index f26281ec..b6f83f99 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt @@ -15,6 +15,7 @@ import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.imagekit.api.client.ImageKitClient import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.core.JsonValue +import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 import com.imagekit.api.models.files.FileUploadParams import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Disabled @@ -60,10 +61,10 @@ internal class ServiceParamsTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -72,17 +73,17 @@ internal class ServiceParamsTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index 6e8d541b..ca8ccb4f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -5,6 +5,7 @@ package com.imagekit.api.services.async import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.core.JsonValue +import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 import com.imagekit.api.models.files.FileCopyParams import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileRenameParams @@ -44,13 +45,10 @@ internal class FileServiceAsyncTest { .description("description") .extensions( listOf( - FileUpdateParams.Update.UpdateFileDetails.Extension.ofRemoveBg( - FileUpdateParams.Update.UpdateFileDetails.Extension.RemoveBg - .builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUpdateParams.Update.UpdateFileDetails.Extension - .RemoveBg - .Options + UnnamedSchemaWithArrayParent3.RemoveBg.Options .builder() .addShadow(true) .bgColor("bg_color") @@ -60,40 +58,29 @@ internal class FileServiceAsyncTest { ) .build() ), - FileUpdateParams.Update.UpdateFileDetails.Extension - .ofAutoTagging( - FileUpdateParams.Update.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() - .maxTags(10L) - .minConfidence(80L) - .name( - FileUpdateParams.Update.UpdateFileDetails - .Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUpdateParams.Update.UpdateFileDetails.Extension - .ofAutoTagging( - FileUpdateParams.Update.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() - .maxTags(10L) - .minConfidence(80L) - .name( - FileUpdateParams.Update.UpdateFileDetails - .Extension - .AutoTaggingExtension - .Name - .AWS_AUTO_TAGGING - ) - .build() - ), - FileUpdateParams.Update.UpdateFileDetails.Extension - .ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + .maxTags(10L) + .minConfidence(80L) + .name( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + .maxTags(10L) + .minConfidence(80L) + .name( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) + .build() + ), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) @@ -242,10 +229,10 @@ internal class FileServiceAsyncTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -254,17 +241,17 @@ internal class FileServiceAsyncTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt index d98f98fc..b1fbb82e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt @@ -5,6 +5,7 @@ package com.imagekit.api.services.async.beta.v2 import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.core.JsonValue +import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 import com.imagekit.api.models.beta.v2.files.FileUploadParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -41,10 +42,10 @@ internal class FileServiceAsyncTest { .description("Running shoes") .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -53,17 +54,17 @@ internal class FileServiceAsyncTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index 2e932b81..64b9a85a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -5,6 +5,7 @@ package com.imagekit.api.services.blocking import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.core.JsonValue +import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 import com.imagekit.api.models.files.FileCopyParams import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileRenameParams @@ -44,13 +45,10 @@ internal class FileServiceTest { .description("description") .extensions( listOf( - FileUpdateParams.Update.UpdateFileDetails.Extension.ofRemoveBg( - FileUpdateParams.Update.UpdateFileDetails.Extension.RemoveBg - .builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUpdateParams.Update.UpdateFileDetails.Extension - .RemoveBg - .Options + UnnamedSchemaWithArrayParent3.RemoveBg.Options .builder() .addShadow(true) .bgColor("bg_color") @@ -60,40 +58,29 @@ internal class FileServiceTest { ) .build() ), - FileUpdateParams.Update.UpdateFileDetails.Extension - .ofAutoTagging( - FileUpdateParams.Update.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() - .maxTags(10L) - .minConfidence(80L) - .name( - FileUpdateParams.Update.UpdateFileDetails - .Extension - .AutoTaggingExtension - .Name - .GOOGLE_AUTO_TAGGING - ) - .build() - ), - FileUpdateParams.Update.UpdateFileDetails.Extension - .ofAutoTagging( - FileUpdateParams.Update.UpdateFileDetails.Extension - .AutoTaggingExtension - .builder() - .maxTags(10L) - .minConfidence(80L) - .name( - FileUpdateParams.Update.UpdateFileDetails - .Extension - .AutoTaggingExtension - .Name - .AWS_AUTO_TAGGING - ) - .build() - ), - FileUpdateParams.Update.UpdateFileDetails.Extension - .ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + .maxTags(10L) + .minConfidence(80L) + .name( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension + .Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + .maxTags(10L) + .minConfidence(80L) + .name( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) + .build() + ), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) @@ -235,10 +222,10 @@ internal class FileServiceTest { .expire(0L) .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -247,17 +234,17 @@ internal class FileServiceTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt index 07b702f8..852adefc 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt @@ -5,6 +5,7 @@ package com.imagekit.api.services.blocking.beta.v2 import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.core.JsonValue +import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 import com.imagekit.api.models.beta.v2.files.FileUploadParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -41,10 +42,10 @@ internal class FileServiceTest { .description("Running shoes") .extensions( listOf( - FileUploadParams.Extension.ofRemoveBg( - FileUploadParams.Extension.RemoveBg.builder() + UnnamedSchemaWithArrayParent3.ofRemoveBg( + UnnamedSchemaWithArrayParent3.RemoveBg.builder() .options( - FileUploadParams.Extension.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -53,17 +54,17 @@ internal class FileServiceTest { ) .build() ), - FileUploadParams.Extension.ofAutoTagging( - FileUploadParams.Extension.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - FileUploadParams.Extension.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - FileUploadParams.Extension.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), ) ) .folder("folder") From 2ef93ad3db97af5fef99687a4438c76e2220b384 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 4 Sep 2025 06:48:43 +0000 Subject: [PATCH 018/142] feat(api): manual updates --- .stats.yml | 2 +- .../accounts/origins/OriginCreateParams.kt | 79 ++++++----- .../accounts/origins/OriginUpdateParams.kt | 78 ++++++----- .../api/models/files/FileUpdateParams.kt | 123 +++++++++--------- .../origins/OriginCreateParamsTest.kt | 6 +- .../origins/OriginUpdateParamsTest.kt | 8 +- .../api/models/files/FileUpdateParamsTest.kt | 18 +-- .../services/async/FileServiceAsyncTest.kt | 6 +- .../async/accounts/OriginServiceAsyncTest.kt | 4 +- .../api/services/blocking/FileServiceTest.kt | 6 +- .../blocking/accounts/OriginServiceTest.kt | 4 +- 11 files changed, 172 insertions(+), 162 deletions(-) diff --git a/.stats.yml b/.stats.yml index 2dc65d21..335e38ec 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-0470196862abd722b09f1af798d6f2bcbdeba0f82d1162f57c287b1a43233531.yml openapi_spec_hash: 043dd7c67d741d0034b86f2fc0bce072 -config_hash: da949a1217f48ac01676eab81ca9d1b1 +config_hash: a652d68098d82eaf611a49507fb4b831 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParams.kt index 85b329b8..6ea32300 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParams.kt @@ -11,13 +11,13 @@ import java.util.Objects /** **Note:** This API is currently in beta. Creates a new origin and returns the origin object. */ class OriginCreateParams private constructor( - private val origin: OriginRequest, + private val originRequest: OriginRequest, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { /** Schema for origin request resources. */ - fun origin(): OriginRequest = origin + fun originRequest(): OriginRequest = originRequest /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -34,7 +34,7 @@ private constructor( * * The following fields are required: * ```java - * .origin() + * .originRequest() * ``` */ @JvmStatic fun builder() = Builder() @@ -43,59 +43,65 @@ private constructor( /** A builder for [OriginCreateParams]. */ class Builder internal constructor() { - private var origin: OriginRequest? = null + private var originRequest: OriginRequest? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(originCreateParams: OriginCreateParams) = apply { - origin = originCreateParams.origin + originRequest = originCreateParams.originRequest additionalHeaders = originCreateParams.additionalHeaders.toBuilder() additionalQueryParams = originCreateParams.additionalQueryParams.toBuilder() } /** Schema for origin request resources. */ - fun origin(origin: OriginRequest) = apply { this.origin = origin } + fun originRequest(originRequest: OriginRequest) = apply { + this.originRequest = originRequest + } - /** Alias for calling [origin] with `OriginRequest.ofS3(s3)`. */ - fun origin(s3: OriginRequest.S3) = origin(OriginRequest.ofS3(s3)) + /** Alias for calling [originRequest] with `OriginRequest.ofS3(s3)`. */ + fun originRequest(s3: OriginRequest.S3) = originRequest(OriginRequest.ofS3(s3)) - /** Alias for calling [origin] with `OriginRequest.ofS3Compatible(s3Compatible)`. */ - fun origin(s3Compatible: OriginRequest.S3Compatible) = - origin(OriginRequest.ofS3Compatible(s3Compatible)) + /** Alias for calling [originRequest] with `OriginRequest.ofS3Compatible(s3Compatible)`. */ + fun originRequest(s3Compatible: OriginRequest.S3Compatible) = + originRequest(OriginRequest.ofS3Compatible(s3Compatible)) - /** Alias for calling [origin] with `OriginRequest.ofCloudinaryBackup(cloudinaryBackup)`. */ - fun origin(cloudinaryBackup: OriginRequest.CloudinaryBackup) = - origin(OriginRequest.ofCloudinaryBackup(cloudinaryBackup)) + /** + * Alias for calling [originRequest] with + * `OriginRequest.ofCloudinaryBackup(cloudinaryBackup)`. + */ + fun originRequest(cloudinaryBackup: OriginRequest.CloudinaryBackup) = + originRequest(OriginRequest.ofCloudinaryBackup(cloudinaryBackup)) - /** Alias for calling [origin] with `OriginRequest.ofWebFolder(webFolder)`. */ - fun origin(webFolder: OriginRequest.WebFolder) = - origin(OriginRequest.ofWebFolder(webFolder)) + /** Alias for calling [originRequest] with `OriginRequest.ofWebFolder(webFolder)`. */ + fun originRequest(webFolder: OriginRequest.WebFolder) = + originRequest(OriginRequest.ofWebFolder(webFolder)) - /** Alias for calling [origin] with `OriginRequest.ofWebProxy(webProxy)`. */ - fun origin(webProxy: OriginRequest.WebProxy) = origin(OriginRequest.ofWebProxy(webProxy)) + /** Alias for calling [originRequest] with `OriginRequest.ofWebProxy(webProxy)`. */ + fun originRequest(webProxy: OriginRequest.WebProxy) = + originRequest(OriginRequest.ofWebProxy(webProxy)) /** - * Alias for calling [origin] with the following: + * Alias for calling [originRequest] with the following: * ```java * OriginRequest.WebProxy.builder() * .name(name) * .build() * ``` */ - fun webProxyOrigin(name: String) = - origin(OriginRequest.WebProxy.builder().name(name).build()) + fun webProxyOriginRequest(name: String) = + originRequest(OriginRequest.WebProxy.builder().name(name).build()) - /** Alias for calling [origin] with `OriginRequest.ofGcs(gcs)`. */ - fun origin(gcs: OriginRequest.Gcs) = origin(OriginRequest.ofGcs(gcs)) + /** Alias for calling [originRequest] with `OriginRequest.ofGcs(gcs)`. */ + fun originRequest(gcs: OriginRequest.Gcs) = originRequest(OriginRequest.ofGcs(gcs)) - /** Alias for calling [origin] with `OriginRequest.ofAzureBlob(azureBlob)`. */ - fun origin(azureBlob: OriginRequest.AzureBlob) = - origin(OriginRequest.ofAzureBlob(azureBlob)) + /** Alias for calling [originRequest] with `OriginRequest.ofAzureBlob(azureBlob)`. */ + fun originRequest(azureBlob: OriginRequest.AzureBlob) = + originRequest(OriginRequest.ofAzureBlob(azureBlob)) - /** Alias for calling [origin] with `OriginRequest.ofAkeneoPim(akeneoPim)`. */ - fun origin(akeneoPim: OriginRequest.AkeneoPim) = - origin(OriginRequest.ofAkeneoPim(akeneoPim)) + /** Alias for calling [originRequest] with `OriginRequest.ofAkeneoPim(akeneoPim)`. */ + fun originRequest(akeneoPim: OriginRequest.AkeneoPim) = + originRequest(OriginRequest.ofAkeneoPim(akeneoPim)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -202,20 +208,20 @@ private constructor( * * The following fields are required: * ```java - * .origin() + * .originRequest() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): OriginCreateParams = OriginCreateParams( - checkRequired("origin", origin), + checkRequired("originRequest", originRequest), additionalHeaders.build(), additionalQueryParams.build(), ) } - fun _body(): OriginRequest = origin + fun _body(): OriginRequest = originRequest override fun _headers(): Headers = additionalHeaders @@ -227,13 +233,14 @@ private constructor( } return other is OriginCreateParams && - origin == other.origin && + originRequest == other.originRequest && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = Objects.hash(origin, additionalHeaders, additionalQueryParams) + override fun hashCode(): Int = + Objects.hash(originRequest, additionalHeaders, additionalQueryParams) override fun toString() = - "OriginCreateParams{origin=$origin, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "OriginCreateParams{originRequest=$originRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParams.kt index 3b73cbad..fb70ae47 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParams.kt @@ -17,7 +17,7 @@ import kotlin.jvm.optionals.getOrNull class OriginUpdateParams private constructor( private val id: String?, - private val origin: OriginRequest, + private val originRequest: OriginRequest, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -28,7 +28,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) /** Schema for origin request resources. */ - fun origin(): OriginRequest = origin + fun originRequest(): OriginRequest = originRequest /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -45,7 +45,7 @@ private constructor( * * The following fields are required: * ```java - * .origin() + * .originRequest() * ``` */ @JvmStatic fun builder() = Builder() @@ -55,14 +55,14 @@ private constructor( class Builder internal constructor() { private var id: String? = null - private var origin: OriginRequest? = null + private var originRequest: OriginRequest? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(originUpdateParams: OriginUpdateParams) = apply { id = originUpdateParams.id - origin = originUpdateParams.origin + originRequest = originUpdateParams.originRequest additionalHeaders = originUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = originUpdateParams.additionalQueryParams.toBuilder() } @@ -77,47 +77,53 @@ private constructor( fun id(id: Optional) = id(id.getOrNull()) /** Schema for origin request resources. */ - fun origin(origin: OriginRequest) = apply { this.origin = origin } + fun originRequest(originRequest: OriginRequest) = apply { + this.originRequest = originRequest + } - /** Alias for calling [origin] with `OriginRequest.ofS3(s3)`. */ - fun origin(s3: OriginRequest.S3) = origin(OriginRequest.ofS3(s3)) + /** Alias for calling [originRequest] with `OriginRequest.ofS3(s3)`. */ + fun originRequest(s3: OriginRequest.S3) = originRequest(OriginRequest.ofS3(s3)) - /** Alias for calling [origin] with `OriginRequest.ofS3Compatible(s3Compatible)`. */ - fun origin(s3Compatible: OriginRequest.S3Compatible) = - origin(OriginRequest.ofS3Compatible(s3Compatible)) + /** Alias for calling [originRequest] with `OriginRequest.ofS3Compatible(s3Compatible)`. */ + fun originRequest(s3Compatible: OriginRequest.S3Compatible) = + originRequest(OriginRequest.ofS3Compatible(s3Compatible)) - /** Alias for calling [origin] with `OriginRequest.ofCloudinaryBackup(cloudinaryBackup)`. */ - fun origin(cloudinaryBackup: OriginRequest.CloudinaryBackup) = - origin(OriginRequest.ofCloudinaryBackup(cloudinaryBackup)) + /** + * Alias for calling [originRequest] with + * `OriginRequest.ofCloudinaryBackup(cloudinaryBackup)`. + */ + fun originRequest(cloudinaryBackup: OriginRequest.CloudinaryBackup) = + originRequest(OriginRequest.ofCloudinaryBackup(cloudinaryBackup)) - /** Alias for calling [origin] with `OriginRequest.ofWebFolder(webFolder)`. */ - fun origin(webFolder: OriginRequest.WebFolder) = - origin(OriginRequest.ofWebFolder(webFolder)) + /** Alias for calling [originRequest] with `OriginRequest.ofWebFolder(webFolder)`. */ + fun originRequest(webFolder: OriginRequest.WebFolder) = + originRequest(OriginRequest.ofWebFolder(webFolder)) - /** Alias for calling [origin] with `OriginRequest.ofWebProxy(webProxy)`. */ - fun origin(webProxy: OriginRequest.WebProxy) = origin(OriginRequest.ofWebProxy(webProxy)) + /** Alias for calling [originRequest] with `OriginRequest.ofWebProxy(webProxy)`. */ + fun originRequest(webProxy: OriginRequest.WebProxy) = + originRequest(OriginRequest.ofWebProxy(webProxy)) /** - * Alias for calling [origin] with the following: + * Alias for calling [originRequest] with the following: * ```java * OriginRequest.WebProxy.builder() * .name(name) * .build() * ``` */ - fun webProxyOrigin(name: String) = - origin(OriginRequest.WebProxy.builder().name(name).build()) + fun webProxyOriginRequest(name: String) = + originRequest(OriginRequest.WebProxy.builder().name(name).build()) - /** Alias for calling [origin] with `OriginRequest.ofGcs(gcs)`. */ - fun origin(gcs: OriginRequest.Gcs) = origin(OriginRequest.ofGcs(gcs)) + /** Alias for calling [originRequest] with `OriginRequest.ofGcs(gcs)`. */ + fun originRequest(gcs: OriginRequest.Gcs) = originRequest(OriginRequest.ofGcs(gcs)) - /** Alias for calling [origin] with `OriginRequest.ofAzureBlob(azureBlob)`. */ - fun origin(azureBlob: OriginRequest.AzureBlob) = - origin(OriginRequest.ofAzureBlob(azureBlob)) + /** Alias for calling [originRequest] with `OriginRequest.ofAzureBlob(azureBlob)`. */ + fun originRequest(azureBlob: OriginRequest.AzureBlob) = + originRequest(OriginRequest.ofAzureBlob(azureBlob)) - /** Alias for calling [origin] with `OriginRequest.ofAkeneoPim(akeneoPim)`. */ - fun origin(akeneoPim: OriginRequest.AkeneoPim) = - origin(OriginRequest.ofAkeneoPim(akeneoPim)) + /** Alias for calling [originRequest] with `OriginRequest.ofAkeneoPim(akeneoPim)`. */ + fun originRequest(akeneoPim: OriginRequest.AkeneoPim) = + originRequest(OriginRequest.ofAkeneoPim(akeneoPim)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -224,7 +230,7 @@ private constructor( * * The following fields are required: * ```java - * .origin() + * .originRequest() * ``` * * @throws IllegalStateException if any required field is unset. @@ -232,13 +238,13 @@ private constructor( fun build(): OriginUpdateParams = OriginUpdateParams( id, - checkRequired("origin", origin), + checkRequired("originRequest", originRequest), additionalHeaders.build(), additionalQueryParams.build(), ) } - fun _body(): OriginRequest = origin + fun _body(): OriginRequest = originRequest fun _pathParam(index: Int): String = when (index) { @@ -257,14 +263,14 @@ private constructor( return other is OriginUpdateParams && id == other.id && - origin == other.origin && + originRequest == other.originRequest && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(id, origin, additionalHeaders, additionalQueryParams) + Objects.hash(id, originRequest, additionalHeaders, additionalQueryParams) override fun toString() = - "OriginUpdateParams{id=$id, origin=$origin, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "OriginUpdateParams{id=$id, originRequest=$originRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt index 186e95c7..54d724d4 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt @@ -43,14 +43,14 @@ import kotlin.jvm.optionals.getOrNull class FileUpdateParams private constructor( private val fileId: String?, - private val update: Update?, + private val body: Body?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun fileId(): Optional = Optional.ofNullable(fileId) - fun update(): Optional = Optional.ofNullable(update) + fun body(): Optional = Optional.ofNullable(body) /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -72,14 +72,14 @@ private constructor( class Builder internal constructor() { private var fileId: String? = null - private var update: Update? = null + private var body: Body? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(fileUpdateParams: FileUpdateParams) = apply { fileId = fileUpdateParams.fileId - update = fileUpdateParams.update + body = fileUpdateParams.body additionalHeaders = fileUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = fileUpdateParams.additionalQueryParams.toBuilder() } @@ -89,21 +89,20 @@ private constructor( /** Alias for calling [Builder.fileId] with `fileId.orElse(null)`. */ fun fileId(fileId: Optional) = fileId(fileId.getOrNull()) - fun update(update: Update?) = apply { this.update = update } + fun body(body: Body?) = apply { this.body = body } - /** Alias for calling [Builder.update] with `update.orElse(null)`. */ - fun update(update: Optional) = update(update.getOrNull()) + /** Alias for calling [Builder.body] with `body.orElse(null)`. */ + fun body(body: Optional) = body(body.getOrNull()) - /** Alias for calling [update] with `Update.ofFileDetails(fileDetails)`. */ - fun update(fileDetails: Update.UpdateFileDetails) = - update(Update.ofFileDetails(fileDetails)) + /** Alias for calling [body] with `Body.ofUpdateFileDetails(updateFileDetails)`. */ + fun body(updateFileDetails: Body.UpdateFileDetails) = + body(Body.ofUpdateFileDetails(updateFileDetails)) /** - * Alias for calling [update] with - * `Update.ofChangePublicationStatus(changePublicationStatus)`. + * Alias for calling [body] with `Body.ofChangePublicationStatus(changePublicationStatus)`. */ - fun update(changePublicationStatus: Update.ChangePublicationStatus) = - update(Update.ofChangePublicationStatus(changePublicationStatus)) + fun body(changePublicationStatus: Body.ChangePublicationStatus) = + body(Body.ofChangePublicationStatus(changePublicationStatus)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -209,15 +208,10 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): FileUpdateParams = - FileUpdateParams( - fileId, - update, - additionalHeaders.build(), - additionalQueryParams.build(), - ) + FileUpdateParams(fileId, body, additionalHeaders.build(), additionalQueryParams.build()) } - fun _body(): Optional = Optional.ofNullable(update) + fun _body(): Optional = Optional.ofNullable(body) fun _pathParam(index: Int): String = when (index) { @@ -229,25 +223,27 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(using = Update.Deserializer::class) - @JsonSerialize(using = Update.Serializer::class) - class Update + @JsonDeserialize(using = Body.Deserializer::class) + @JsonSerialize(using = Body.Serializer::class) + class Body private constructor( - private val fileDetails: UpdateFileDetails? = null, + private val updateFileDetails: UpdateFileDetails? = null, private val changePublicationStatus: ChangePublicationStatus? = null, private val _json: JsonValue? = null, ) { - fun fileDetails(): Optional = Optional.ofNullable(fileDetails) + fun updateFileDetails(): Optional = + Optional.ofNullable(updateFileDetails) fun changePublicationStatus(): Optional = Optional.ofNullable(changePublicationStatus) - fun isFileDetails(): Boolean = fileDetails != null + fun isUpdateFileDetails(): Boolean = updateFileDetails != null fun isChangePublicationStatus(): Boolean = changePublicationStatus != null - fun asFileDetails(): UpdateFileDetails = fileDetails.getOrThrow("fileDetails") + fun asUpdateFileDetails(): UpdateFileDetails = + updateFileDetails.getOrThrow("updateFileDetails") fun asChangePublicationStatus(): ChangePublicationStatus = changePublicationStatus.getOrThrow("changePublicationStatus") @@ -256,7 +252,7 @@ private constructor( fun accept(visitor: Visitor): T = when { - fileDetails != null -> visitor.visitFileDetails(fileDetails) + updateFileDetails != null -> visitor.visitUpdateFileDetails(updateFileDetails) changePublicationStatus != null -> visitor.visitChangePublicationStatus(changePublicationStatus) else -> visitor.unknown(_json) @@ -264,15 +260,15 @@ private constructor( private var validated: Boolean = false - fun validate(): Update = apply { + fun validate(): Body = apply { if (validated) { return@apply } accept( object : Visitor { - override fun visitFileDetails(fileDetails: UpdateFileDetails) { - fileDetails.validate() + override fun visitUpdateFileDetails(updateFileDetails: UpdateFileDetails) { + updateFileDetails.validate() } override fun visitChangePublicationStatus( @@ -303,8 +299,8 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitFileDetails(fileDetails: UpdateFileDetails) = - fileDetails.validity() + override fun visitUpdateFileDetails(updateFileDetails: UpdateFileDetails) = + updateFileDetails.validity() override fun visitChangePublicationStatus( changePublicationStatus: ChangePublicationStatus @@ -319,66 +315,66 @@ private constructor( return true } - return other is Update && - fileDetails == other.fileDetails && + return other is Body && + updateFileDetails == other.updateFileDetails && changePublicationStatus == other.changePublicationStatus } - override fun hashCode(): Int = Objects.hash(fileDetails, changePublicationStatus) + override fun hashCode(): Int = Objects.hash(updateFileDetails, changePublicationStatus) override fun toString(): String = when { - fileDetails != null -> "Update{fileDetails=$fileDetails}" + updateFileDetails != null -> "Body{updateFileDetails=$updateFileDetails}" changePublicationStatus != null -> - "Update{changePublicationStatus=$changePublicationStatus}" - _json != null -> "Update{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Update") + "Body{changePublicationStatus=$changePublicationStatus}" + _json != null -> "Body{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Body") } companion object { @JvmStatic - fun ofFileDetails(fileDetails: UpdateFileDetails) = Update(fileDetails = fileDetails) + fun ofUpdateFileDetails(updateFileDetails: UpdateFileDetails) = + Body(updateFileDetails = updateFileDetails) @JvmStatic fun ofChangePublicationStatus(changePublicationStatus: ChangePublicationStatus) = - Update(changePublicationStatus = changePublicationStatus) + Body(changePublicationStatus = changePublicationStatus) } - /** An interface that defines how to map each variant of [Update] to a value of type [T]. */ + /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ interface Visitor { - fun visitFileDetails(fileDetails: UpdateFileDetails): T + fun visitUpdateFileDetails(updateFileDetails: UpdateFileDetails): T fun visitChangePublicationStatus(changePublicationStatus: ChangePublicationStatus): T /** - * Maps an unknown variant of [Update] to a value of type [T]. + * Maps an unknown variant of [Body] to a value of type [T]. * - * An instance of [Update] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [Body] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * * @throws ImageKitInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Update: $json") + throw ImageKitInvalidDataException("Unknown Body: $json") } } - internal class Deserializer : BaseDeserializer(Update::class) { + internal class Deserializer : BaseDeserializer(Body::class) { - override fun ObjectCodec.deserialize(node: JsonNode): Update { + override fun ObjectCodec.deserialize(node: JsonNode): Body { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - Update(fileDetails = it, _json = json) + Body(updateFileDetails = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - Update(changePublicationStatus = it, _json = json) + Body(changePublicationStatus = it, _json = json) }, ) .filterNotNull() @@ -387,7 +383,7 @@ private constructor( return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with // all the possible variants (e.g. deserializing from boolean). - 0 -> Update(_json = json) + 0 -> Body(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first // completely valid match, or simply the first match if none are completely @@ -397,19 +393,20 @@ private constructor( } } - internal class Serializer : BaseSerializer(Update::class) { + internal class Serializer : BaseSerializer(Body::class) { override fun serialize( - value: Update, + value: Body, generator: JsonGenerator, provider: SerializerProvider, ) { when { - value.fileDetails != null -> generator.writeObject(value.fileDetails) + value.updateFileDetails != null -> + generator.writeObject(value.updateFileDetails) value.changePublicationStatus != null -> generator.writeObject(value.changePublicationStatus) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Update") + else -> throw IllegalStateException("Invalid Body") } } } @@ -2792,14 +2789,14 @@ private constructor( return other is FileUpdateParams && fileId == other.fileId && - update == other.update && + body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(fileId, update, additionalHeaders, additionalQueryParams) + Objects.hash(fileId, body, additionalHeaders, additionalQueryParams) override fun toString() = - "FileUpdateParams{fileId=$fileId, update=$update, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "FileUpdateParams{fileId=$fileId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParamsTest.kt index 98b6d47a..7c03cc60 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParamsTest.kt @@ -10,7 +10,7 @@ internal class OriginCreateParamsTest { @Test fun create() { OriginCreateParams.builder() - .origin( + .originRequest( OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") @@ -28,7 +28,7 @@ internal class OriginCreateParamsTest { fun body() { val params = OriginCreateParams.builder() - .origin( + .originRequest( OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") @@ -63,7 +63,7 @@ internal class OriginCreateParamsTest { fun bodyWithoutOptionalFields() { val params = OriginCreateParams.builder() - .origin( + .originRequest( OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParamsTest.kt index f8a57949..d90d8ccb 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParamsTest.kt @@ -11,7 +11,7 @@ internal class OriginUpdateParamsTest { fun create() { OriginUpdateParams.builder() .id("id") - .origin( + .originRequest( OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") @@ -30,7 +30,7 @@ internal class OriginUpdateParamsTest { val params = OriginUpdateParams.builder() .id("id") - .origin( + .originRequest( OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") @@ -50,7 +50,7 @@ internal class OriginUpdateParamsTest { val params = OriginUpdateParams.builder() .id("id") - .origin( + .originRequest( OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") @@ -86,7 +86,7 @@ internal class OriginUpdateParamsTest { val params = OriginUpdateParams.builder() .id("id") - .origin( + .originRequest( OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt index 7dce3e33..d3d44b3e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt @@ -14,11 +14,11 @@ internal class FileUpdateParamsTest { fun create() { FileUpdateParams.builder() .fileId("fileId") - .update( - FileUpdateParams.Update.UpdateFileDetails.builder() + .body( + FileUpdateParams.Body.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - FileUpdateParams.Update.UpdateFileDetails.CustomMetadata.builder() + FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("brand", JsonValue.from("bar")) .putAdditionalProperty("color", JsonValue.from("bar")) .build() @@ -84,11 +84,11 @@ internal class FileUpdateParamsTest { val params = FileUpdateParams.builder() .fileId("fileId") - .update( - FileUpdateParams.Update.UpdateFileDetails.builder() + .body( + FileUpdateParams.Body.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - FileUpdateParams.Update.UpdateFileDetails.CustomMetadata.builder() + FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("brand", JsonValue.from("bar")) .putAdditionalProperty("color", JsonValue.from("bar")) .build() @@ -143,11 +143,11 @@ internal class FileUpdateParamsTest { assertThat(body) .isEqualTo( - FileUpdateParams.Update.ofFileDetails( - FileUpdateParams.Update.UpdateFileDetails.builder() + FileUpdateParams.Body.ofUpdateFileDetails( + FileUpdateParams.Body.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - FileUpdateParams.Update.UpdateFileDetails.CustomMetadata.builder() + FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("brand", JsonValue.from("bar")) .putAdditionalProperty("color", JsonValue.from("bar")) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index ca8ccb4f..971b0818 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -33,11 +33,11 @@ internal class FileServiceAsyncTest { fileServiceAsync.update( FileUpdateParams.builder() .fileId("fileId") - .update( - FileUpdateParams.Update.UpdateFileDetails.builder() + .body( + FileUpdateParams.Body.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - FileUpdateParams.Update.UpdateFileDetails.CustomMetadata.builder() + FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("brand", JsonValue.from("bar")) .putAdditionalProperty("color", JsonValue.from("bar")) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt index 55c67968..fb62ce18 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt @@ -28,7 +28,7 @@ internal class OriginServiceAsyncTest { val originResponseFuture = originServiceAsync.create( OriginCreateParams.builder() - .origin( + .originRequest( OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") @@ -61,7 +61,7 @@ internal class OriginServiceAsyncTest { originServiceAsync.update( OriginUpdateParams.builder() .id("id") - .origin( + .originRequest( OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index 64b9a85a..f9021b5e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -33,11 +33,11 @@ internal class FileServiceTest { fileService.update( FileUpdateParams.builder() .fileId("fileId") - .update( - FileUpdateParams.Update.UpdateFileDetails.builder() + .body( + FileUpdateParams.Body.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - FileUpdateParams.Update.UpdateFileDetails.CustomMetadata.builder() + FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("brand", JsonValue.from("bar")) .putAdditionalProperty("color", JsonValue.from("bar")) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt index 324a0687..2e20139f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt @@ -28,7 +28,7 @@ internal class OriginServiceTest { val originResponse = originService.create( OriginCreateParams.builder() - .origin( + .originRequest( OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") @@ -60,7 +60,7 @@ internal class OriginServiceTest { originService.update( OriginUpdateParams.builder() .id("id") - .origin( + .originRequest( OriginRequest.S3.builder() .accessKey("AKIATEST123") .bucket("test-bucket") From bb12ecffacdb5245da5c54087230c3da8ea4dce7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 4 Sep 2025 07:07:03 +0000 Subject: [PATCH 019/142] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 335e38ec..e13d3275 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-0470196862abd722b09f1af798d6f2bcbdeba0f82d1162f57c287b1a43233531.yml -openapi_spec_hash: 043dd7c67d741d0034b86f2fc0bce072 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-afb67c3a2098b1a2dca37d0995d183fa6cf59dd144ed47bcdb924f14e3cc90a3.yml +openapi_spec_hash: 55a2f38df85126a87d1be0b27b9b8470 config_hash: a652d68098d82eaf611a49507fb4b831 From 95ef7412f4b72b4e4cf07f814224714f0341245d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 4 Sep 2025 07:12:52 +0000 Subject: [PATCH 020/142] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index e13d3275..bbfdcb43 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-afb67c3a2098b1a2dca37d0995d183fa6cf59dd144ed47bcdb924f14e3cc90a3.yml -openapi_spec_hash: 55a2f38df85126a87d1be0b27b9b8470 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-bc7c0d27962b30c19c778656988e154b54696819389289f34420a5e5fdfbd3b8.yml +openapi_spec_hash: 1bfde02a63416c036e9545927f727459 config_hash: a652d68098d82eaf611a49507fb4b831 From c75a767180e2d032fc0ab1d2fe74e41795bd957d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 5 Sep 2025 20:09:08 +0000 Subject: [PATCH 021/142] feat(api): extract UpdateFileDetailsRequest to model --- .stats.yml | 2 +- .../models/beta/v2/files/FileUploadParams.kt | 116 +- .../CustomMetadataFieldCreateParams.kt | 74 +- .../CustomMetadataFieldUpdateParams.kt | 74 +- .../api/models/files/FileUpdateParams.kt | 2645 +---------------- .../api/models/files/FileUploadParams.kt | 116 +- .../models/files/UpdateFileDetailsRequest.kt | 2536 ++++++++++++++++ .../beta/v2/files/FileUploadParamsTest.kt | 44 +- .../api/models/files/FileUpdateParamsTest.kt | 80 +- .../api/models/files/FileUploadParamsTest.kt | 44 +- .../files/UpdateFileDetailsRequestTest.kt | 186 ++ .../api/services/ErrorHandlingTest.kt | 240 +- .../api/services/ServiceParamsTest.kt | 16 +- .../services/async/FileServiceAsyncTest.kt | 43 +- .../async/beta/v2/FileServiceAsyncTest.kt | 16 +- .../api/services/blocking/FileServiceTest.kt | 43 +- .../blocking/beta/v2/FileServiceTest.kt | 16 +- .../api/proguard/ProGuardCompatibilityTest.kt | 83 +- 18 files changed, 3274 insertions(+), 3100 deletions(-) create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileDetailsRequest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileDetailsRequestTest.kt diff --git a/.stats.yml b/.stats.yml index bbfdcb43..b0086e96 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-bc7c0d27962b30c19c778656988e154b54696819389289f34420a5e5fdfbd3b8.yml openapi_spec_hash: 1bfde02a63416c036e9545927f727459 -config_hash: a652d68098d82eaf611a49507fb4b831 +config_hash: b415c06a3b29485af4601beb94ae1aeb diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt index 9c220c91..798baef4 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt @@ -29,7 +29,7 @@ import com.imagekit.api.core.http.Headers import com.imagekit.api.core.http.QueryParams import com.imagekit.api.core.toImmutable import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 import java.io.InputStream import java.nio.file.Path import java.util.Collections @@ -154,7 +154,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun extensions(): Optional> = body.extensions() + fun extensions(): Optional> = body.extensions() /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, @@ -341,7 +341,7 @@ private constructor( * * Unlike [extensions], this method doesn't throw if the multipart field has an unexpected type. */ - fun _extensions(): MultipartField> = body._extensions() + fun _extensions(): MultipartField> = body._extensions() /** * Returns the raw multipart value of [folder]. @@ -639,7 +639,7 @@ private constructor( * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ - fun extensions(extensions: List) = apply { + fun extensions(extensions: List) = apply { body.extensions(extensions) } @@ -647,42 +647,42 @@ private constructor( * Sets [Builder.extensions] to an arbitrary multipart value. * * You should usually call [Builder.extensions] with a well-typed - * `List` value instead. This method is primarily for setting + * `List` value instead. This method is primarily for setting * the field to an undocumented or not yet supported value. */ - fun extensions(extensions: MultipartField>) = apply { + fun extensions(extensions: MultipartField>) = apply { body.extensions(extensions) } /** - * Adds a single [UnnamedSchemaWithArrayParent3] to [extensions]. + * Adds a single [UnnamedSchemaWithArrayParent1] to [extensions]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addExtension(extension: UnnamedSchemaWithArrayParent3) = apply { + fun addExtension(extension: UnnamedSchemaWithArrayParent1) = apply { body.addExtension(extension) } /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent3.ofRemoveBg(removeBg)`. + * `UnnamedSchemaWithArrayParent1.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: UnnamedSchemaWithArrayParent3.RemoveBg) = apply { + fun addExtension(removeBg: UnnamedSchemaWithArrayParent1.RemoveBg) = apply { body.addExtension(removeBg) } /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension(autoTaggingExtension)`. + * `UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(autoTaggingExtension)`. */ - fun addExtension(autoTaggingExtension: UnnamedSchemaWithArrayParent3.AutoTaggingExtension) = + fun addExtension(autoTaggingExtension: UnnamedSchemaWithArrayParent1.AutoTaggingExtension) = apply { body.addExtension(autoTaggingExtension) } /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent3.ofAiAutoDescription()`. + * `UnnamedSchemaWithArrayParent1.ofAiAutoDescription()`. */ fun addExtensionAiAutoDescription() = apply { body.addExtensionAiAutoDescription() } @@ -1100,7 +1100,7 @@ private constructor( private val customCoordinates: MultipartField, private val customMetadata: MultipartField, private val description: MultipartField, - private val extensions: MultipartField>, + private val extensions: MultipartField>, private val folder: MultipartField, private val isPrivateFile: MultipartField, private val isPublished: MultipartField, @@ -1205,7 +1205,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun extensions(): Optional> = + fun extensions(): Optional> = extensions.value.getOptional("extensions") /** @@ -1409,7 +1409,7 @@ private constructor( */ @JsonProperty("extensions") @ExcludeMissing - fun _extensions(): MultipartField> = extensions + fun _extensions(): MultipartField> = extensions /** * Returns the raw multipart value of [folder]. @@ -1561,7 +1561,7 @@ private constructor( private var customCoordinates: MultipartField = MultipartField.of(null) private var customMetadata: MultipartField = MultipartField.of(null) private var description: MultipartField = MultipartField.of(null) - private var extensions: MultipartField>? = + private var extensions: MultipartField>? = null private var folder: MultipartField = MultipartField.of(null) private var isPrivateFile: MultipartField = MultipartField.of(null) @@ -1762,27 +1762,27 @@ private constructor( * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ - fun extensions(extensions: List) = + fun extensions(extensions: List) = extensions(MultipartField.of(extensions)) /** * Sets [Builder.extensions] to an arbitrary multipart value. * * You should usually call [Builder.extensions] with a well-typed - * `List` value instead. This method is primarily for + * `List` value instead. This method is primarily for * setting the field to an undocumented or not yet supported value. */ - fun extensions(extensions: MultipartField>) = + fun extensions(extensions: MultipartField>) = apply { this.extensions = extensions.map { it.toMutableList() } } /** - * Adds a single [UnnamedSchemaWithArrayParent3] to [extensions]. + * Adds a single [UnnamedSchemaWithArrayParent1] to [extensions]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addExtension(extension: UnnamedSchemaWithArrayParent3) = apply { + fun addExtension(extension: UnnamedSchemaWithArrayParent1) = apply { extensions = (extensions ?: MultipartField.of(mutableListOf())).also { checkKnown("extensions", it).add(extension) @@ -1791,28 +1791,28 @@ private constructor( /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent3.ofRemoveBg(removeBg)`. + * `UnnamedSchemaWithArrayParent1.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: UnnamedSchemaWithArrayParent3.RemoveBg) = - addExtension(UnnamedSchemaWithArrayParent3.ofRemoveBg(removeBg)) + fun addExtension(removeBg: UnnamedSchemaWithArrayParent1.RemoveBg) = + addExtension(UnnamedSchemaWithArrayParent1.ofRemoveBg(removeBg)) /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension(autoTaggingExtension)`. + * `UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(autoTaggingExtension)`. */ fun addExtension( - autoTaggingExtension: UnnamedSchemaWithArrayParent3.AutoTaggingExtension + autoTaggingExtension: UnnamedSchemaWithArrayParent1.AutoTaggingExtension ) = addExtension( - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension(autoTaggingExtension) + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(autoTaggingExtension) ) /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent3.ofAiAutoDescription()`. + * `UnnamedSchemaWithArrayParent1.ofAiAutoDescription()`. */ fun addExtensionAiAutoDescription() = - addExtension(UnnamedSchemaWithArrayParent3.ofAiAutoDescription()) + addExtension(UnnamedSchemaWithArrayParent1.ofAiAutoDescription()) /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist @@ -2318,9 +2318,9 @@ private constructor( override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent3.Deserializer::class) - @JsonSerialize(using = UnnamedSchemaWithArrayParent3.Serializer::class) - class UnnamedSchemaWithArrayParent3 + @JsonDeserialize(using = UnnamedSchemaWithArrayParent1.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent1.Serializer::class) + class UnnamedSchemaWithArrayParent1 private constructor( private val removeBg: RemoveBg? = null, private val autoTaggingExtension: AutoTaggingExtension? = null, @@ -2361,7 +2361,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent3 = apply { + fun validate(): UnnamedSchemaWithArrayParent1 = apply { if (validated) { return@apply } @@ -2431,7 +2431,7 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent3 && + return other is UnnamedSchemaWithArrayParent1 && removeBg == other.removeBg && autoTaggingExtension == other.autoTaggingExtension && aiAutoDescription == other.aiAutoDescription @@ -2442,33 +2442,33 @@ private constructor( override fun toString(): String = when { - removeBg != null -> "UnnamedSchemaWithArrayParent3{removeBg=$removeBg}" + removeBg != null -> "UnnamedSchemaWithArrayParent1{removeBg=$removeBg}" autoTaggingExtension != null -> - "UnnamedSchemaWithArrayParent3{autoTaggingExtension=$autoTaggingExtension}" + "UnnamedSchemaWithArrayParent1{autoTaggingExtension=$autoTaggingExtension}" aiAutoDescription != null -> - "UnnamedSchemaWithArrayParent3{aiAutoDescription=$aiAutoDescription}" - _json != null -> "UnnamedSchemaWithArrayParent3{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") + "UnnamedSchemaWithArrayParent1{aiAutoDescription=$aiAutoDescription}" + _json != null -> "UnnamedSchemaWithArrayParent1{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") } companion object { @JvmStatic - fun ofRemoveBg(removeBg: RemoveBg) = UnnamedSchemaWithArrayParent3(removeBg = removeBg) + fun ofRemoveBg(removeBg: RemoveBg) = UnnamedSchemaWithArrayParent1(removeBg = removeBg) @JvmStatic fun ofAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension) = - UnnamedSchemaWithArrayParent3(autoTaggingExtension = autoTaggingExtension) + UnnamedSchemaWithArrayParent1(autoTaggingExtension = autoTaggingExtension) @JvmStatic fun ofAiAutoDescription() = - UnnamedSchemaWithArrayParent3( + UnnamedSchemaWithArrayParent1( aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) ) } /** - * An interface that defines how to map each variant of [UnnamedSchemaWithArrayParent3] to a + * An interface that defines how to map each variant of [UnnamedSchemaWithArrayParent1] to a * value of type [T]. */ interface Visitor { @@ -2480,9 +2480,9 @@ private constructor( fun visitAiAutoDescription(aiAutoDescription: JsonValue): T /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent3] to a value of type [T]. + * Maps an unknown variant of [UnnamedSchemaWithArrayParent1] to a value of type [T]. * - * An instance of [UnnamedSchemaWithArrayParent3] can contain an unknown variant if it + * An instance of [UnnamedSchemaWithArrayParent1] can contain an unknown variant if it * was deserialized from data that doesn't match any known variant. For example, if the * SDK is on an older version than the API, then the API may respond with new variants * that the SDK is unaware of. @@ -2490,43 +2490,43 @@ private constructor( * @throws ImageKitInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown UnnamedSchemaWithArrayParent3: $json") + throw ImageKitInvalidDataException("Unknown UnnamedSchemaWithArrayParent1: $json") } } internal class Deserializer : - BaseDeserializer(UnnamedSchemaWithArrayParent3::class) { + BaseDeserializer(UnnamedSchemaWithArrayParent1::class) { - override fun ObjectCodec.deserialize(node: JsonNode): UnnamedSchemaWithArrayParent3 { + override fun ObjectCodec.deserialize(node: JsonNode): UnnamedSchemaWithArrayParent1 { val json = JsonValue.fromJsonNode(node) val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() when (name) { "remove-bg" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent3(removeBg = it, _json = json) - } ?: UnnamedSchemaWithArrayParent3(_json = json) + UnnamedSchemaWithArrayParent1(removeBg = it, _json = json) + } ?: UnnamedSchemaWithArrayParent1(_json = json) } "ai-auto-description" -> { return tryDeserialize(node, jacksonTypeRef()) ?.let { - UnnamedSchemaWithArrayParent3(aiAutoDescription = it, _json = json) + UnnamedSchemaWithArrayParent1(aiAutoDescription = it, _json = json) } - ?.takeIf { it.isValid() } ?: UnnamedSchemaWithArrayParent3(_json = json) + ?.takeIf { it.isValid() } ?: UnnamedSchemaWithArrayParent1(_json = json) } } return tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent3(autoTaggingExtension = it, _json = json) - } ?: UnnamedSchemaWithArrayParent3(_json = json) + UnnamedSchemaWithArrayParent1(autoTaggingExtension = it, _json = json) + } ?: UnnamedSchemaWithArrayParent1(_json = json) } } internal class Serializer : - BaseSerializer(UnnamedSchemaWithArrayParent3::class) { + BaseSerializer(UnnamedSchemaWithArrayParent1::class) { override fun serialize( - value: UnnamedSchemaWithArrayParent3, + value: UnnamedSchemaWithArrayParent1, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -2537,7 +2537,7 @@ private constructor( value.aiAutoDescription != null -> generator.writeObject(value.aiAutoDescription) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") } } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt index fa4d61fe..254e574f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt @@ -854,7 +854,7 @@ private constructor( fun defaultValue(bool: Boolean) = defaultValue(DefaultValue.ofBool(bool)) /** Alias for calling [defaultValue] with `DefaultValue.ofMixed(mixed)`. */ - fun defaultValueOfMixed(mixed: List) = + fun defaultValueOfMixed(mixed: List) = defaultValue(DefaultValue.ofMixed(mixed)) /** @@ -1247,7 +1247,7 @@ private constructor( private val string: String? = null, private val number: Double? = null, private val bool: Boolean? = null, - private val mixed: List? = null, + private val mixed: List? = null, private val _json: JsonValue? = null, ) { @@ -1261,7 +1261,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun mixed(): Optional> = Optional.ofNullable(mixed) + fun mixed(): Optional> = Optional.ofNullable(mixed) fun isString(): Boolean = string != null @@ -1281,7 +1281,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun asMixed(): List = mixed.getOrThrow("mixed") + fun asMixed(): List = mixed.getOrThrow("mixed") fun _json(): Optional = Optional.ofNullable(_json) @@ -1309,7 +1309,7 @@ private constructor( override fun visitBool(bool: Boolean) {} - override fun visitMixed(mixed: List) { + override fun visitMixed(mixed: List) { mixed.forEach { it.validate() } } } @@ -1341,7 +1341,7 @@ private constructor( override fun visitBool(bool: Boolean) = 1 - override fun visitMixed(mixed: List) = + override fun visitMixed(mixed: List) = mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 @@ -1385,7 +1385,7 @@ private constructor( * `MultiSelect`. */ @JvmStatic - fun ofMixed(mixed: List) = + fun ofMixed(mixed: List) = DefaultValue(mixed = mixed.toImmutable()) } @@ -1405,7 +1405,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun visitMixed(mixed: List): T + fun visitMixed(mixed: List): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1440,7 +1440,7 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef>(), + jacksonTypeRef>(), ) ?.let { DefaultValue(mixed = it, _json = json) }, ) @@ -1478,9 +1478,9 @@ private constructor( } } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent1.Deserializer::class) - @JsonSerialize(using = UnnamedSchemaWithArrayParent1.Serializer::class) - class UnnamedSchemaWithArrayParent1 + @JsonDeserialize(using = UnnamedSchemaWithArrayParent2.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent2.Serializer::class) + class UnnamedSchemaWithArrayParent2 private constructor( private val string: String? = null, private val number: Double? = null, @@ -1518,7 +1518,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent1 = apply { + fun validate(): UnnamedSchemaWithArrayParent2 = apply { if (validated) { return@apply } @@ -1568,7 +1568,7 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent1 && + return other is UnnamedSchemaWithArrayParent2 && string == other.string && number == other.number && bool == other.bool @@ -1578,28 +1578,28 @@ private constructor( override fun toString(): String = when { - string != null -> "UnnamedSchemaWithArrayParent1{string=$string}" - number != null -> "UnnamedSchemaWithArrayParent1{number=$number}" - bool != null -> "UnnamedSchemaWithArrayParent1{bool=$bool}" - _json != null -> "UnnamedSchemaWithArrayParent1{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") + string != null -> "UnnamedSchemaWithArrayParent2{string=$string}" + number != null -> "UnnamedSchemaWithArrayParent2{number=$number}" + bool != null -> "UnnamedSchemaWithArrayParent2{bool=$bool}" + _json != null -> "UnnamedSchemaWithArrayParent2{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent2") } companion object { @JvmStatic - fun ofString(string: String) = UnnamedSchemaWithArrayParent1(string = string) + fun ofString(string: String) = UnnamedSchemaWithArrayParent2(string = string) @JvmStatic - fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent1(number = number) + fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent2(number = number) @JvmStatic - fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent1(bool = bool) + fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent2(bool = bool) } /** * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent1] to a value of type [T]. + * [UnnamedSchemaWithArrayParent2] to a value of type [T]. */ interface Visitor { @@ -1610,10 +1610,10 @@ private constructor( fun visitBool(bool: Boolean): T /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent1] to a value of type + * Maps an unknown variant of [UnnamedSchemaWithArrayParent2] to a value of type * [T]. * - * An instance of [UnnamedSchemaWithArrayParent1] can contain an unknown variant + * An instance of [UnnamedSchemaWithArrayParent2] can contain an unknown variant * if it was deserialized from data that doesn't match any known variant. For * example, if the SDK is on an older version than the API, then the API may * respond with new variants that the SDK is unaware of. @@ -1622,31 +1622,31 @@ private constructor( */ fun unknown(json: JsonValue?): T { throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent1: $json" + "Unknown UnnamedSchemaWithArrayParent2: $json" ) } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent1::class + BaseDeserializer( + UnnamedSchemaWithArrayParent2::class ) { override fun ObjectCodec.deserialize( node: JsonNode - ): UnnamedSchemaWithArrayParent1 { + ): UnnamedSchemaWithArrayParent2 { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent1(string = it, _json = json) + UnnamedSchemaWithArrayParent2(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent1(number = it, _json = json) + UnnamedSchemaWithArrayParent2(number = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent1(bool = it, _json = json) + UnnamedSchemaWithArrayParent2(bool = it, _json = json) }, ) .filterNotNull() @@ -1656,7 +1656,7 @@ private constructor( // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from // object). - 0 -> UnnamedSchemaWithArrayParent1(_json = json) + 0 -> UnnamedSchemaWithArrayParent2(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use // the first completely valid match, or simply the first match if none @@ -1667,12 +1667,12 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent1::class + BaseSerializer( + UnnamedSchemaWithArrayParent2::class ) { override fun serialize( - value: UnnamedSchemaWithArrayParent1, + value: UnnamedSchemaWithArrayParent2, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -1682,7 +1682,7 @@ private constructor( value.bool != null -> generator.writeObject(value.bool) value._json != null -> generator.writeObject(value._json) else -> - throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent2") } } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt index 2cedf446..b866dd92 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt @@ -744,7 +744,7 @@ private constructor( fun defaultValue(bool: Boolean) = defaultValue(DefaultValue.ofBool(bool)) /** Alias for calling [defaultValue] with `DefaultValue.ofMixed(mixed)`. */ - fun defaultValueOfMixed(mixed: List) = + fun defaultValueOfMixed(mixed: List) = defaultValue(DefaultValue.ofMixed(mixed)) /** @@ -969,7 +969,7 @@ private constructor( private val string: String? = null, private val number: Double? = null, private val bool: Boolean? = null, - private val mixed: List? = null, + private val mixed: List? = null, private val _json: JsonValue? = null, ) { @@ -983,7 +983,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun mixed(): Optional> = Optional.ofNullable(mixed) + fun mixed(): Optional> = Optional.ofNullable(mixed) fun isString(): Boolean = string != null @@ -1003,7 +1003,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun asMixed(): List = mixed.getOrThrow("mixed") + fun asMixed(): List = mixed.getOrThrow("mixed") fun _json(): Optional = Optional.ofNullable(_json) @@ -1031,7 +1031,7 @@ private constructor( override fun visitBool(bool: Boolean) {} - override fun visitMixed(mixed: List) { + override fun visitMixed(mixed: List) { mixed.forEach { it.validate() } } } @@ -1063,7 +1063,7 @@ private constructor( override fun visitBool(bool: Boolean) = 1 - override fun visitMixed(mixed: List) = + override fun visitMixed(mixed: List) = mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 @@ -1107,7 +1107,7 @@ private constructor( * `MultiSelect`. */ @JvmStatic - fun ofMixed(mixed: List) = + fun ofMixed(mixed: List) = DefaultValue(mixed = mixed.toImmutable()) } @@ -1127,7 +1127,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun visitMixed(mixed: List): T + fun visitMixed(mixed: List): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1162,7 +1162,7 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef>(), + jacksonTypeRef>(), ) ?.let { DefaultValue(mixed = it, _json = json) }, ) @@ -1200,9 +1200,9 @@ private constructor( } } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent2.Deserializer::class) - @JsonSerialize(using = UnnamedSchemaWithArrayParent2.Serializer::class) - class UnnamedSchemaWithArrayParent2 + @JsonDeserialize(using = UnnamedSchemaWithArrayParent3.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent3.Serializer::class) + class UnnamedSchemaWithArrayParent3 private constructor( private val string: String? = null, private val number: Double? = null, @@ -1240,7 +1240,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent2 = apply { + fun validate(): UnnamedSchemaWithArrayParent3 = apply { if (validated) { return@apply } @@ -1290,7 +1290,7 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent2 && + return other is UnnamedSchemaWithArrayParent3 && string == other.string && number == other.number && bool == other.bool @@ -1300,28 +1300,28 @@ private constructor( override fun toString(): String = when { - string != null -> "UnnamedSchemaWithArrayParent2{string=$string}" - number != null -> "UnnamedSchemaWithArrayParent2{number=$number}" - bool != null -> "UnnamedSchemaWithArrayParent2{bool=$bool}" - _json != null -> "UnnamedSchemaWithArrayParent2{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent2") + string != null -> "UnnamedSchemaWithArrayParent3{string=$string}" + number != null -> "UnnamedSchemaWithArrayParent3{number=$number}" + bool != null -> "UnnamedSchemaWithArrayParent3{bool=$bool}" + _json != null -> "UnnamedSchemaWithArrayParent3{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") } companion object { @JvmStatic - fun ofString(string: String) = UnnamedSchemaWithArrayParent2(string = string) + fun ofString(string: String) = UnnamedSchemaWithArrayParent3(string = string) @JvmStatic - fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent2(number = number) + fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent3(number = number) @JvmStatic - fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent2(bool = bool) + fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent3(bool = bool) } /** * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent2] to a value of type [T]. + * [UnnamedSchemaWithArrayParent3] to a value of type [T]. */ interface Visitor { @@ -1332,10 +1332,10 @@ private constructor( fun visitBool(bool: Boolean): T /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent2] to a value of type + * Maps an unknown variant of [UnnamedSchemaWithArrayParent3] to a value of type * [T]. * - * An instance of [UnnamedSchemaWithArrayParent2] can contain an unknown variant + * An instance of [UnnamedSchemaWithArrayParent3] can contain an unknown variant * if it was deserialized from data that doesn't match any known variant. For * example, if the SDK is on an older version than the API, then the API may * respond with new variants that the SDK is unaware of. @@ -1344,31 +1344,31 @@ private constructor( */ fun unknown(json: JsonValue?): T { throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent2: $json" + "Unknown UnnamedSchemaWithArrayParent3: $json" ) } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent2::class + BaseDeserializer( + UnnamedSchemaWithArrayParent3::class ) { override fun ObjectCodec.deserialize( node: JsonNode - ): UnnamedSchemaWithArrayParent2 { + ): UnnamedSchemaWithArrayParent3 { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent2(string = it, _json = json) + UnnamedSchemaWithArrayParent3(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent2(number = it, _json = json) + UnnamedSchemaWithArrayParent3(number = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent2(bool = it, _json = json) + UnnamedSchemaWithArrayParent3(bool = it, _json = json) }, ) .filterNotNull() @@ -1378,7 +1378,7 @@ private constructor( // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from // object). - 0 -> UnnamedSchemaWithArrayParent2(_json = json) + 0 -> UnnamedSchemaWithArrayParent3(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use // the first completely valid match, or simply the first match if none @@ -1389,12 +1389,12 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent2::class + BaseSerializer( + UnnamedSchemaWithArrayParent3::class ) { override fun serialize( - value: UnnamedSchemaWithArrayParent2, + value: UnnamedSchemaWithArrayParent3, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -1404,7 +1404,7 @@ private constructor( value.bool != null -> generator.writeObject(value.bool) value._json != null -> generator.writeObject(value._json) else -> - throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent2") + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") } } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt index 54d724d4..479191fb 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt @@ -2,35 +2,9 @@ package com.imagekit.api.models.files -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue import com.imagekit.api.core.Params -import com.imagekit.api.core.allMaxBy -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.getOrThrow import com.imagekit.api.core.http.Headers import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 -import java.util.Collections import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -43,14 +17,15 @@ import kotlin.jvm.optionals.getOrNull class FileUpdateParams private constructor( private val fileId: String?, - private val body: Body?, + private val updateFileDetailsRequest: UpdateFileDetailsRequest?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun fileId(): Optional = Optional.ofNullable(fileId) - fun body(): Optional = Optional.ofNullable(body) + fun updateFileDetailsRequest(): Optional = + Optional.ofNullable(updateFileDetailsRequest) /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -72,14 +47,14 @@ private constructor( class Builder internal constructor() { private var fileId: String? = null - private var body: Body? = null + private var updateFileDetailsRequest: UpdateFileDetailsRequest? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(fileUpdateParams: FileUpdateParams) = apply { fileId = fileUpdateParams.fileId - body = fileUpdateParams.body + updateFileDetailsRequest = fileUpdateParams.updateFileDetailsRequest additionalHeaders = fileUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = fileUpdateParams.additionalQueryParams.toBuilder() } @@ -89,20 +64,38 @@ private constructor( /** Alias for calling [Builder.fileId] with `fileId.orElse(null)`. */ fun fileId(fileId: Optional) = fileId(fileId.getOrNull()) - fun body(body: Body?) = apply { this.body = body } + fun updateFileDetailsRequest(updateFileDetailsRequest: UpdateFileDetailsRequest?) = apply { + this.updateFileDetailsRequest = updateFileDetailsRequest + } - /** Alias for calling [Builder.body] with `body.orElse(null)`. */ - fun body(body: Optional) = body(body.getOrNull()) + /** + * Alias for calling [Builder.updateFileDetailsRequest] with + * `updateFileDetailsRequest.orElse(null)`. + */ + fun updateFileDetailsRequest(updateFileDetailsRequest: Optional) = + updateFileDetailsRequest(updateFileDetailsRequest.getOrNull()) - /** Alias for calling [body] with `Body.ofUpdateFileDetails(updateFileDetails)`. */ - fun body(updateFileDetails: Body.UpdateFileDetails) = - body(Body.ofUpdateFileDetails(updateFileDetails)) + /** + * Alias for calling [updateFileDetailsRequest] with + * `UpdateFileDetailsRequest.ofUpdateFileDetails(updateFileDetails)`. + */ + fun updateFileDetailsRequest( + updateFileDetails: UpdateFileDetailsRequest.UpdateFileDetails + ) = + updateFileDetailsRequest( + UpdateFileDetailsRequest.ofUpdateFileDetails(updateFileDetails) + ) /** - * Alias for calling [body] with `Body.ofChangePublicationStatus(changePublicationStatus)`. + * Alias for calling [updateFileDetailsRequest] with + * `UpdateFileDetailsRequest.ofChangePublicationStatus(changePublicationStatus)`. */ - fun body(changePublicationStatus: Body.ChangePublicationStatus) = - body(Body.ofChangePublicationStatus(changePublicationStatus)) + fun updateFileDetailsRequest( + changePublicationStatus: UpdateFileDetailsRequest.ChangePublicationStatus + ) = + updateFileDetailsRequest( + UpdateFileDetailsRequest.ofChangePublicationStatus(changePublicationStatus) + ) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -208,10 +201,15 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): FileUpdateParams = - FileUpdateParams(fileId, body, additionalHeaders.build(), additionalQueryParams.build()) + FileUpdateParams( + fileId, + updateFileDetailsRequest, + additionalHeaders.build(), + additionalQueryParams.build(), + ) } - fun _body(): Optional = Optional.ofNullable(body) + fun _body(): Optional = Optional.ofNullable(updateFileDetailsRequest) fun _pathParam(index: Int): String = when (index) { @@ -223,2565 +221,6 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(using = Body.Deserializer::class) - @JsonSerialize(using = Body.Serializer::class) - class Body - private constructor( - private val updateFileDetails: UpdateFileDetails? = null, - private val changePublicationStatus: ChangePublicationStatus? = null, - private val _json: JsonValue? = null, - ) { - - fun updateFileDetails(): Optional = - Optional.ofNullable(updateFileDetails) - - fun changePublicationStatus(): Optional = - Optional.ofNullable(changePublicationStatus) - - fun isUpdateFileDetails(): Boolean = updateFileDetails != null - - fun isChangePublicationStatus(): Boolean = changePublicationStatus != null - - fun asUpdateFileDetails(): UpdateFileDetails = - updateFileDetails.getOrThrow("updateFileDetails") - - fun asChangePublicationStatus(): ChangePublicationStatus = - changePublicationStatus.getOrThrow("changePublicationStatus") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - updateFileDetails != null -> visitor.visitUpdateFileDetails(updateFileDetails) - changePublicationStatus != null -> - visitor.visitChangePublicationStatus(changePublicationStatus) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUpdateFileDetails(updateFileDetails: UpdateFileDetails) { - updateFileDetails.validate() - } - - override fun visitChangePublicationStatus( - changePublicationStatus: ChangePublicationStatus - ) { - changePublicationStatus.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUpdateFileDetails(updateFileDetails: UpdateFileDetails) = - updateFileDetails.validity() - - override fun visitChangePublicationStatus( - changePublicationStatus: ChangePublicationStatus - ) = changePublicationStatus.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - updateFileDetails == other.updateFileDetails && - changePublicationStatus == other.changePublicationStatus - } - - override fun hashCode(): Int = Objects.hash(updateFileDetails, changePublicationStatus) - - override fun toString(): String = - when { - updateFileDetails != null -> "Body{updateFileDetails=$updateFileDetails}" - changePublicationStatus != null -> - "Body{changePublicationStatus=$changePublicationStatus}" - _json != null -> "Body{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Body") - } - - companion object { - - @JvmStatic - fun ofUpdateFileDetails(updateFileDetails: UpdateFileDetails) = - Body(updateFileDetails = updateFileDetails) - - @JvmStatic - fun ofChangePublicationStatus(changePublicationStatus: ChangePublicationStatus) = - Body(changePublicationStatus = changePublicationStatus) - } - - /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ - interface Visitor { - - fun visitUpdateFileDetails(updateFileDetails: UpdateFileDetails): T - - fun visitChangePublicationStatus(changePublicationStatus: ChangePublicationStatus): T - - /** - * Maps an unknown variant of [Body] to a value of type [T]. - * - * An instance of [Body] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Body: $json") - } - } - - internal class Deserializer : BaseDeserializer(Body::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Body { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Body(updateFileDetails = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Body(changePublicationStatus = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from boolean). - 0 -> Body(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely - // valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Body::class) { - - override fun serialize( - value: Body, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.updateFileDetails != null -> - generator.writeObject(value.updateFileDetails) - value.changePublicationStatus != null -> - generator.writeObject(value.changePublicationStatus) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Body") - } - } - } - - class UpdateFileDetails - private constructor( - private val customCoordinates: JsonField, - private val customMetadata: JsonField, - private val description: JsonField, - private val extensions: JsonField>, - private val removeAiTags: JsonField, - private val tags: JsonField>, - private val webhookUrl: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("customCoordinates") - @ExcludeMissing - customCoordinates: JsonField = JsonMissing.of(), - @JsonProperty("customMetadata") - @ExcludeMissing - customMetadata: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("extensions") - @ExcludeMissing - extensions: JsonField> = JsonMissing.of(), - @JsonProperty("removeAITags") - @ExcludeMissing - removeAiTags: JsonField = JsonMissing.of(), - @JsonProperty("tags") - @ExcludeMissing - tags: JsonField> = JsonMissing.of(), - @JsonProperty("webhookUrl") - @ExcludeMissing - webhookUrl: JsonField = JsonMissing.of(), - ) : this( - customCoordinates, - customMetadata, - description, - extensions, - removeAiTags, - tags, - webhookUrl, - mutableMapOf(), - ) - - /** - * Define an important area in the image in the format `x,y,width,height` e.g. - * `10,10,100,100`. Send `null` to unset this value. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun customCoordinates(): Optional = - customCoordinates.getOptional("customCoordinates") - - /** - * A key-value data to be associated with the asset. To unset a key, send `null` value - * for that key. Before setting any custom metadata on an asset you have to create the - * field using custom metadata fields API. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun customMetadata(): Optional = - customMetadata.getOptional("customMetadata") - - /** - * Optional text to describe the contents of the file. - * - * @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") - - /** - * Array of extensions to be applied to the asset. Each extension can be configured with - * specific parameters based on the extension type. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun extensions(): Optional> = - extensions.getOptional("extensions") - - /** - * An array of AITags associated with the file that you want to remove, e.g. `["car", - * "vehicle", "motorsports"]`. - * - * If you want to remove all AITags associated with the file, send a string - "all". - * - * Note: The remove operation for `AITags` executes before any of the `extensions` are - * processed. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun removeAiTags(): Optional = removeAiTags.getOptional("removeAITags") - - /** - * An array of tags associated with the file, such as `["tag1", "tag2"]`. Send `null` to - * unset all tags associated with the file. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun tags(): Optional> = tags.getOptional("tags") - - /** - * The final status of extensions after they have completed execution will be delivered - * to this endpoint as a POST request. - * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - * about the webhook payload structure. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun webhookUrl(): Optional = webhookUrl.getOptional("webhookUrl") - - /** - * Returns the raw JSON value of [customCoordinates]. - * - * Unlike [customCoordinates], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("customCoordinates") - @ExcludeMissing - fun _customCoordinates(): JsonField = customCoordinates - - /** - * Returns the raw JSON value of [customMetadata]. - * - * Unlike [customMetadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("customMetadata") - @ExcludeMissing - fun _customMetadata(): JsonField = customMetadata - - /** - * 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 [extensions]. - * - * Unlike [extensions], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("extensions") - @ExcludeMissing - fun _extensions(): JsonField> = extensions - - /** - * Returns the raw JSON value of [removeAiTags]. - * - * Unlike [removeAiTags], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("removeAITags") - @ExcludeMissing - fun _removeAiTags(): JsonField = removeAiTags - - /** - * Returns the raw JSON value of [tags]. - * - * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags - - /** - * Returns the raw JSON value of [webhookUrl]. - * - * Unlike [webhookUrl], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("webhookUrl") - @ExcludeMissing - fun _webhookUrl(): JsonField = webhookUrl - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [UpdateFileDetails]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UpdateFileDetails]. */ - class Builder internal constructor() { - - private var customCoordinates: JsonField = JsonMissing.of() - private var customMetadata: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var extensions: JsonField>? = - null - private var removeAiTags: JsonField = JsonMissing.of() - private var tags: JsonField>? = null - private var webhookUrl: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(updateFileDetails: UpdateFileDetails) = apply { - customCoordinates = updateFileDetails.customCoordinates - customMetadata = updateFileDetails.customMetadata - description = updateFileDetails.description - extensions = updateFileDetails.extensions.map { it.toMutableList() } - removeAiTags = updateFileDetails.removeAiTags - tags = updateFileDetails.tags.map { it.toMutableList() } - webhookUrl = updateFileDetails.webhookUrl - additionalProperties = updateFileDetails.additionalProperties.toMutableMap() - } - - /** - * Define an important area in the image in the format `x,y,width,height` e.g. - * `10,10,100,100`. Send `null` to unset this value. - */ - fun customCoordinates(customCoordinates: String?) = - customCoordinates(JsonField.ofNullable(customCoordinates)) - - /** - * Alias for calling [Builder.customCoordinates] with - * `customCoordinates.orElse(null)`. - */ - fun customCoordinates(customCoordinates: Optional) = - customCoordinates(customCoordinates.getOrNull()) - - /** - * Sets [Builder.customCoordinates] to an arbitrary JSON value. - * - * You should usually call [Builder.customCoordinates] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun customCoordinates(customCoordinates: JsonField) = apply { - this.customCoordinates = customCoordinates - } - - /** - * A key-value data to be associated with the asset. To unset a key, send `null` - * value for that key. Before setting any custom metadata on an asset you have to - * create the field using custom metadata fields API. - */ - fun customMetadata(customMetadata: CustomMetadata) = - customMetadata(JsonField.of(customMetadata)) - - /** - * Sets [Builder.customMetadata] to an arbitrary JSON value. - * - * You should usually call [Builder.customMetadata] with a well-typed - * [CustomMetadata] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun customMetadata(customMetadata: JsonField) = apply { - this.customMetadata = customMetadata - } - - /** Optional text to describe the contents of the file. */ - 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 - } - - /** - * Array of extensions to be applied to the asset. Each extension can be configured - * with specific parameters based on the extension type. - */ - fun extensions(extensions: List) = - extensions(JsonField.of(extensions)) - - /** - * Sets [Builder.extensions] to an arbitrary JSON value. - * - * You should usually call [Builder.extensions] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun extensions(extensions: JsonField>) = apply { - this.extensions = extensions.map { it.toMutableList() } - } - - /** - * Adds a single [UnnamedSchemaWithArrayParent3] to [extensions]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addExtension(extension: UnnamedSchemaWithArrayParent3) = apply { - extensions = - (extensions ?: JsonField.of(mutableListOf())).also { - checkKnown("extensions", it).add(extension) - } - } - - /** - * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent3.ofRemoveBg(removeBg)`. - */ - fun addExtension(removeBg: UnnamedSchemaWithArrayParent3.RemoveBg) = - addExtension(UnnamedSchemaWithArrayParent3.ofRemoveBg(removeBg)) - - /** - * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension(autoTaggingExtension)`. - */ - fun addExtension( - autoTaggingExtension: UnnamedSchemaWithArrayParent3.AutoTaggingExtension - ) = - addExtension( - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension(autoTaggingExtension) - ) - - /** - * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent3.ofAiAutoDescription()`. - */ - fun addExtensionAiAutoDescription() = - addExtension(UnnamedSchemaWithArrayParent3.ofAiAutoDescription()) - - /** - * An array of AITags associated with the file that you want to remove, e.g. - * `["car", "vehicle", "motorsports"]`. - * - * If you want to remove all AITags associated with the file, send a string - "all". - * - * Note: The remove operation for `AITags` executes before any of the `extensions` - * are processed. - */ - fun removeAiTags(removeAiTags: RemoveAiTags) = - removeAiTags(JsonField.of(removeAiTags)) - - /** - * Sets [Builder.removeAiTags] to an arbitrary JSON value. - * - * You should usually call [Builder.removeAiTags] with a well-typed [RemoveAiTags] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun removeAiTags(removeAiTags: JsonField) = apply { - this.removeAiTags = removeAiTags - } - - /** Alias for calling [removeAiTags] with `RemoveAiTags.ofStrings(strings)`. */ - fun removeAiTagsOfStrings(strings: List) = - removeAiTags(RemoveAiTags.ofStrings(strings)) - - /** Alias for calling [removeAiTags] with `RemoveAiTags.ofAll()`. */ - fun removeAiTagsAll() = removeAiTags(RemoveAiTags.ofAll()) - - /** - * An array of tags associated with the file, such as `["tag1", "tag2"]`. Send - * `null` to unset all tags associated with the file. - */ - fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - - /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ - fun tags(tags: Optional>) = tags(tags.getOrNull()) - - /** - * Sets [Builder.tags] to an arbitrary JSON value. - * - * You should usually call [Builder.tags] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [tags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).also { - checkKnown("tags", it).add(tag) - } - } - - /** - * The final status of extensions after they have completed execution will be - * delivered to this endpoint as a POST request. - * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) - * about the webhook payload structure. - */ - fun webhookUrl(webhookUrl: String) = webhookUrl(JsonField.of(webhookUrl)) - - /** - * Sets [Builder.webhookUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun webhookUrl(webhookUrl: JsonField) = apply { - this.webhookUrl = webhookUrl - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UpdateFileDetails]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UpdateFileDetails = - UpdateFileDetails( - customCoordinates, - customMetadata, - description, - (extensions ?: JsonMissing.of()).map { it.toImmutable() }, - removeAiTags, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - webhookUrl, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UpdateFileDetails = apply { - if (validated) { - return@apply - } - - customCoordinates() - customMetadata().ifPresent { it.validate() } - description() - extensions().ifPresent { it.forEach { it.validate() } } - removeAiTags().ifPresent { it.validate() } - tags() - webhookUrl() - 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 (customCoordinates.asKnown().isPresent) 1 else 0) + - (customMetadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (extensions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (removeAiTags.asKnown().getOrNull()?.validity() ?: 0) + - (tags.asKnown().getOrNull()?.size ?: 0) + - (if (webhookUrl.asKnown().isPresent) 1 else 0) - - /** - * A key-value data to be associated with the asset. To unset a key, send `null` value - * for that key. Before setting any custom metadata on an asset you have to create the - * field using custom metadata fields API. - */ - class CustomMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [CustomMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customMetadata: CustomMetadata) = apply { - additionalProperties = customMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [CustomMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): CustomMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CustomMetadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CustomMetadata{additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = UnnamedSchemaWithArrayParent3.Deserializer::class) - @JsonSerialize(using = UnnamedSchemaWithArrayParent3.Serializer::class) - class UnnamedSchemaWithArrayParent3 - private constructor( - private val removeBg: RemoveBg? = null, - private val autoTaggingExtension: AutoTaggingExtension? = null, - private val aiAutoDescription: JsonValue? = null, - private val _json: JsonValue? = null, - ) { - - fun removeBg(): Optional = Optional.ofNullable(removeBg) - - fun autoTaggingExtension(): Optional = - Optional.ofNullable(autoTaggingExtension) - - fun aiAutoDescription(): Optional = - Optional.ofNullable(aiAutoDescription) - - fun isRemoveBg(): Boolean = removeBg != null - - fun isAutoTaggingExtension(): Boolean = autoTaggingExtension != null - - fun isAiAutoDescription(): Boolean = aiAutoDescription != null - - fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") - - fun asAutoTaggingExtension(): AutoTaggingExtension = - autoTaggingExtension.getOrThrow("autoTaggingExtension") - - fun asAiAutoDescription(): JsonValue = - aiAutoDescription.getOrThrow("aiAutoDescription") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - removeBg != null -> visitor.visitRemoveBg(removeBg) - autoTaggingExtension != null -> - visitor.visitAutoTaggingExtension(autoTaggingExtension) - aiAutoDescription != null -> - visitor.visitAiAutoDescription(aiAutoDescription) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): UnnamedSchemaWithArrayParent3 = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitRemoveBg(removeBg: RemoveBg) { - removeBg.validate() - } - - override fun visitAutoTaggingExtension( - autoTaggingExtension: AutoTaggingExtension - ) { - autoTaggingExtension.validate() - } - - override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { - aiAutoDescription.let { - if ( - it != JsonValue.from(mapOf("name" to "ai-auto-description")) - ) { - throw ImageKitInvalidDataException( - "'aiAutoDescription' is invalid, received $it" - ) - } - } - } - } - ) - 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 = - accept( - object : Visitor { - override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() - - override fun visitAutoTaggingExtension( - autoTaggingExtension: AutoTaggingExtension - ) = autoTaggingExtension.validity() - - override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = - aiAutoDescription.let { - if ( - it == JsonValue.from(mapOf("name" to "ai-auto-description")) - ) - 1 - else 0 - } - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnnamedSchemaWithArrayParent3 && - removeBg == other.removeBg && - autoTaggingExtension == other.autoTaggingExtension && - aiAutoDescription == other.aiAutoDescription - } - - override fun hashCode(): Int = - Objects.hash(removeBg, autoTaggingExtension, aiAutoDescription) - - override fun toString(): String = - when { - removeBg != null -> "UnnamedSchemaWithArrayParent3{removeBg=$removeBg}" - autoTaggingExtension != null -> - "UnnamedSchemaWithArrayParent3{autoTaggingExtension=$autoTaggingExtension}" - aiAutoDescription != null -> - "UnnamedSchemaWithArrayParent3{aiAutoDescription=$aiAutoDescription}" - _json != null -> "UnnamedSchemaWithArrayParent3{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") - } - - companion object { - - @JvmStatic - fun ofRemoveBg(removeBg: RemoveBg) = - UnnamedSchemaWithArrayParent3(removeBg = removeBg) - - @JvmStatic - fun ofAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension) = - UnnamedSchemaWithArrayParent3(autoTaggingExtension = autoTaggingExtension) - - @JvmStatic - fun ofAiAutoDescription() = - UnnamedSchemaWithArrayParent3( - aiAutoDescription = - JsonValue.from(mapOf("name" to "ai-auto-description")) - ) - } - - /** - * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent3] to a value of type [T]. - */ - interface Visitor { - - fun visitRemoveBg(removeBg: RemoveBg): T - - fun visitAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension): T - - fun visitAiAutoDescription(aiAutoDescription: JsonValue): T - - /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent3] to a value of type - * [T]. - * - * An instance of [UnnamedSchemaWithArrayParent3] can contain an unknown variant - * if it was deserialized from data that doesn't match any known variant. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent3: $json" - ) - } - } - - internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent3::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): UnnamedSchemaWithArrayParent3 { - val json = JsonValue.fromJsonNode(node) - val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() - - when (name) { - "remove-bg" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent3(removeBg = it, _json = json) - } ?: UnnamedSchemaWithArrayParent3(_json = json) - } - "ai-auto-description" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { - UnnamedSchemaWithArrayParent3( - aiAutoDescription = it, - _json = json, - ) - } - ?.takeIf { it.isValid() } - ?: UnnamedSchemaWithArrayParent3(_json = json) - } - } - - return tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent3(autoTaggingExtension = it, _json = json) - } ?: UnnamedSchemaWithArrayParent3(_json = json) - } - } - - internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent3::class - ) { - - override fun serialize( - value: UnnamedSchemaWithArrayParent3, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.removeBg != null -> generator.writeObject(value.removeBg) - value.autoTaggingExtension != null -> - generator.writeObject(value.autoTaggingExtension) - value.aiAutoDescription != null -> - generator.writeObject(value.aiAutoDescription) - value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") - } - } - } - - class RemoveBg - private constructor( - private val name: JsonValue, - private val options: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), - @JsonProperty("options") - @ExcludeMissing - options: JsonField = JsonMissing.of(), - ) : this(name, options, mutableMapOf()) - - /** - * Specifies the background removal extension. - * - * Expected to always return the following: - * ```java - * JsonValue.from("remove-bg") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun options(): Optional = options.getOptional("options") - - /** - * Returns the raw JSON value of [options]. - * - * Unlike [options], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("options") - @ExcludeMissing - fun _options(): JsonField = options - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RemoveBg]. */ - class Builder internal constructor() { - - private var name: JsonValue = JsonValue.from("remove-bg") - private var options: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(removeBg: RemoveBg) = apply { - name = removeBg.name - options = removeBg.options - additionalProperties = removeBg.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults - * to the following: - * ```java - * JsonValue.from("remove-bg") - * ``` - * - * This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun name(name: JsonValue) = apply { this.name = name } - - fun options(options: Options) = options(JsonField.of(options)) - - /** - * Sets [Builder.options] to an arbitrary JSON value. - * - * You should usually call [Builder.options] with a well-typed [Options] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun options(options: JsonField) = apply { this.options = options } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [RemoveBg]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemoveBg = - RemoveBg(name, options, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): RemoveBg = apply { - if (validated) { - return@apply - } - - _name().let { - if (it != JsonValue.from("remove-bg")) { - throw ImageKitInvalidDataException( - "'name' is invalid, received $it" - ) - } - } - options().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - name.let { if (it == JsonValue.from("remove-bg")) 1 else 0 } + - (options.asKnown().getOrNull()?.validity() ?: 0) - - class Options - private constructor( - private val addShadow: JsonField, - private val bgColor: JsonField, - private val bgImageUrl: JsonField, - private val semitransparency: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("add_shadow") - @ExcludeMissing - addShadow: JsonField = JsonMissing.of(), - @JsonProperty("bg_color") - @ExcludeMissing - bgColor: JsonField = JsonMissing.of(), - @JsonProperty("bg_image_url") - @ExcludeMissing - bgImageUrl: JsonField = JsonMissing.of(), - @JsonProperty("semitransparency") - @ExcludeMissing - semitransparency: JsonField = JsonMissing.of(), - ) : this(addShadow, bgColor, bgImageUrl, semitransparency, mutableMapOf()) - - /** - * Whether to add an artificial shadow to the result. Default is false. - * Note: Adding shadows is currently only supported for car photos. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun addShadow(): Optional = addShadow.getOptional("add_shadow") - - /** - * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") - * or color name (e.g., "green"). If this parameter is set, `bg_image_url` - * must be empty. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun bgColor(): Optional = bgColor.getOptional("bg_color") - - /** - * Sets a background image from a URL. If this parameter is set, `bg_color` - * must be empty. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun bgImageUrl(): Optional = bgImageUrl.getOptional("bg_image_url") - - /** - * Allows semi-transparent regions in the result. Default is true. Note: - * Semitransparency is currently only supported for car windows. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun semitransparency(): Optional = - semitransparency.getOptional("semitransparency") - - /** - * Returns the raw JSON value of [addShadow]. - * - * Unlike [addShadow], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("add_shadow") - @ExcludeMissing - fun _addShadow(): JsonField = addShadow - - /** - * Returns the raw JSON value of [bgColor]. - * - * Unlike [bgColor], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("bg_color") - @ExcludeMissing - fun _bgColor(): JsonField = bgColor - - /** - * Returns the raw JSON value of [bgImageUrl]. - * - * Unlike [bgImageUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("bg_image_url") - @ExcludeMissing - fun _bgImageUrl(): JsonField = bgImageUrl - - /** - * Returns the raw JSON value of [semitransparency]. - * - * Unlike [semitransparency], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("semitransparency") - @ExcludeMissing - fun _semitransparency(): JsonField = semitransparency - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Options]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Options]. */ - class Builder internal constructor() { - - private var addShadow: JsonField = JsonMissing.of() - private var bgColor: JsonField = JsonMissing.of() - private var bgImageUrl: JsonField = JsonMissing.of() - private var semitransparency: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(options: Options) = apply { - addShadow = options.addShadow - bgColor = options.bgColor - bgImageUrl = options.bgImageUrl - semitransparency = options.semitransparency - additionalProperties = options.additionalProperties.toMutableMap() - } - - /** - * Whether to add an artificial shadow to the result. Default is false. - * Note: Adding shadows is currently only supported for car photos. - */ - fun addShadow(addShadow: Boolean) = addShadow(JsonField.of(addShadow)) - - /** - * Sets [Builder.addShadow] to an arbitrary JSON value. - * - * You should usually call [Builder.addShadow] with a well-typed - * [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun addShadow(addShadow: JsonField) = apply { - this.addShadow = addShadow - } - - /** - * Specifies a solid color background using hex code (e.g., "81d4fa", - * "fff") or color name (e.g., "green"). If this parameter is set, - * `bg_image_url` must be empty. - */ - fun bgColor(bgColor: String) = bgColor(JsonField.of(bgColor)) - - /** - * Sets [Builder.bgColor] to an arbitrary JSON value. - * - * You should usually call [Builder.bgColor] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun bgColor(bgColor: JsonField) = apply { - this.bgColor = bgColor - } - - /** - * Sets a background image from a URL. If this parameter is set, - * `bg_color` must be empty. - */ - fun bgImageUrl(bgImageUrl: String) = - bgImageUrl(JsonField.of(bgImageUrl)) - - /** - * Sets [Builder.bgImageUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.bgImageUrl] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun bgImageUrl(bgImageUrl: JsonField) = apply { - this.bgImageUrl = bgImageUrl - } - - /** - * Allows semi-transparent regions in the result. Default is true. Note: - * Semitransparency is currently only supported for car windows. - */ - fun semitransparency(semitransparency: Boolean) = - semitransparency(JsonField.of(semitransparency)) - - /** - * Sets [Builder.semitransparency] to an arbitrary JSON value. - * - * You should usually call [Builder.semitransparency] with a well-typed - * [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun semitransparency(semitransparency: JsonField) = apply { - this.semitransparency = semitransparency - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Options]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): Options = - Options( - addShadow, - bgColor, - bgImageUrl, - semitransparency, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Options = apply { - if (validated) { - return@apply - } - - addShadow() - bgColor() - bgImageUrl() - semitransparency() - 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 (addShadow.asKnown().isPresent) 1 else 0) + - (if (bgColor.asKnown().isPresent) 1 else 0) + - (if (bgImageUrl.asKnown().isPresent) 1 else 0) + - (if (semitransparency.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - addShadow == other.addShadow && - bgColor == other.bgColor && - bgImageUrl == other.bgImageUrl && - semitransparency == other.semitransparency && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - addShadow, - bgColor, - bgImageUrl, - semitransparency, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemoveBg && - name == other.name && - options == other.options && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(name, options, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" - } - - class AutoTaggingExtension - private constructor( - private val maxTags: JsonField, - private val minConfidence: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("maxTags") - @ExcludeMissing - maxTags: JsonField = JsonMissing.of(), - @JsonProperty("minConfidence") - @ExcludeMissing - minConfidence: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - ) : this(maxTags, minConfidence, name, mutableMapOf()) - - /** - * Maximum number of tags to attach to the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun maxTags(): Long = maxTags.getRequired("maxTags") - - /** - * Minimum confidence level for tags to be considered valid. - * - * @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 minConfidence(): Long = minConfidence.getRequired("minConfidence") - - /** - * Specifies the auto-tagging extension used. - * - * @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(): Name = name.getRequired("name") - - /** - * Returns the raw JSON value of [maxTags]. - * - * Unlike [maxTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("maxTags") - @ExcludeMissing - fun _maxTags(): JsonField = maxTags - - /** - * Returns the raw JSON value of [minConfidence]. - * - * Unlike [minConfidence], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minConfidence") - @ExcludeMissing - fun _minConfidence(): JsonField = minConfidence - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AutoTaggingExtension]. - * - * The following fields are required: - * ```java - * .maxTags() - * .minConfidence() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutoTaggingExtension]. */ - class Builder internal constructor() { - - private var maxTags: JsonField? = null - private var minConfidence: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { - maxTags = autoTaggingExtension.maxTags - minConfidence = autoTaggingExtension.minConfidence - name = autoTaggingExtension.name - additionalProperties = - autoTaggingExtension.additionalProperties.toMutableMap() - } - - /** Maximum number of tags to attach to the asset. */ - fun maxTags(maxTags: Long) = maxTags(JsonField.of(maxTags)) - - /** - * Sets [Builder.maxTags] to an arbitrary JSON value. - * - * You should usually call [Builder.maxTags] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun maxTags(maxTags: JsonField) = apply { this.maxTags = maxTags } - - /** Minimum confidence level for tags to be considered valid. */ - fun minConfidence(minConfidence: Long) = - minConfidence(JsonField.of(minConfidence)) - - /** - * Sets [Builder.minConfidence] to an arbitrary JSON value. - * - * You should usually call [Builder.minConfidence] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun minConfidence(minConfidence: JsonField) = apply { - this.minConfidence = minConfidence - } - - /** Specifies the auto-tagging extension used. */ - fun name(name: Name) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [Name] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AutoTaggingExtension]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .maxTags() - * .minConfidence() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AutoTaggingExtension = - AutoTaggingExtension( - checkRequired("maxTags", maxTags), - checkRequired("minConfidence", minConfidence), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutoTaggingExtension = apply { - if (validated) { - return@apply - } - - maxTags() - minConfidence() - name().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (maxTags.asKnown().isPresent) 1 else 0) + - (if (minConfidence.asKnown().isPresent) 1 else 0) + - (name.asKnown().getOrNull()?.validity() ?: 0) - - /** Specifies the auto-tagging extension used. */ - class Name - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") - - @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") - - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } - - /** An enum containing [Name]'s known values. */ - enum class Known { - GOOGLE_AUTO_TAGGING, - AWS_AUTO_TAGGING, - } - - /** - * An enum containing [Name]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Name] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GOOGLE_AUTO_TAGGING, - AWS_AUTO_TAGGING, - /** - * An enum member indicating that [Name] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING - AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value is a - * not a known member. - */ - fun known(): Known = - when (this) { - GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING - AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING - else -> throw ImageKitInvalidDataException("Unknown Name: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value does - * not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Name = apply { - if (validated) { - return@apply - } - - known() - 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 (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Name && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AutoTaggingExtension && - maxTags == other.maxTags && - minConfidence == other.minConfidence && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(maxTags, minConfidence, name, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" - } - } - - /** - * An array of AITags associated with the file that you want to remove, e.g. `["car", - * "vehicle", "motorsports"]`. - * - * If you want to remove all AITags associated with the file, send a string - "all". - * - * Note: The remove operation for `AITags` executes before any of the `extensions` are - * processed. - */ - @JsonDeserialize(using = RemoveAiTags.Deserializer::class) - @JsonSerialize(using = RemoveAiTags.Serializer::class) - class RemoveAiTags - private constructor( - private val strings: List? = null, - private val all: JsonValue? = null, - private val _json: JsonValue? = null, - ) { - - fun strings(): Optional> = Optional.ofNullable(strings) - - fun all(): Optional = Optional.ofNullable(all) - - fun isStrings(): Boolean = strings != null - - fun isAll(): Boolean = all != null - - fun asStrings(): List = strings.getOrThrow("strings") - - fun asAll(): JsonValue = all.getOrThrow("all") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - strings != null -> visitor.visitStrings(strings) - all != null -> visitor.visitAll(all) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): RemoveAiTags = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitStrings(strings: List) {} - - override fun visitAll(all: JsonValue) { - all.let { - if (it != JsonValue.from("all")) { - throw ImageKitInvalidDataException( - "'all' is invalid, received $it" - ) - } - } - } - } - ) - 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 = - accept( - object : Visitor { - override fun visitStrings(strings: List) = strings.size - - override fun visitAll(all: JsonValue) = - all.let { if (it == JsonValue.from("all")) 1 else 0 } - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemoveAiTags && strings == other.strings && all == other.all - } - - override fun hashCode(): Int = Objects.hash(strings, all) - - override fun toString(): String = - when { - strings != null -> "RemoveAiTags{strings=$strings}" - all != null -> "RemoveAiTags{all=$all}" - _json != null -> "RemoveAiTags{_unknown=$_json}" - else -> throw IllegalStateException("Invalid RemoveAiTags") - } - - companion object { - - @JvmStatic - fun ofStrings(strings: List) = - RemoveAiTags(strings = strings.toImmutable()) - - @JvmStatic fun ofAll() = RemoveAiTags(all = JsonValue.from("all")) - } - - /** - * An interface that defines how to map each variant of [RemoveAiTags] to a value of - * type [T]. - */ - interface Visitor { - - fun visitStrings(strings: List): T - - fun visitAll(all: JsonValue): T - - /** - * Maps an unknown variant of [RemoveAiTags] to a value of type [T]. - * - * An instance of [RemoveAiTags] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown RemoveAiTags: $json") - } - } - - internal class Deserializer : BaseDeserializer(RemoveAiTags::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): RemoveAiTags { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { RemoveAiTags(all = it, _json = json) } - ?.takeIf { it.isValid() }, - tryDeserialize(node, jacksonTypeRef>())?.let { - RemoveAiTags(strings = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely - // incompatible with all the possible variants (e.g. deserializing from - // object). - 0 -> RemoveAiTags(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use - // the first completely valid match, or simply the first match if none - // are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(RemoveAiTags::class) { - - override fun serialize( - value: RemoveAiTags, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.strings != null -> generator.writeObject(value.strings) - value.all != null -> generator.writeObject(value.all) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid RemoveAiTags") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UpdateFileDetails && - customCoordinates == other.customCoordinates && - customMetadata == other.customMetadata && - description == other.description && - extensions == other.extensions && - removeAiTags == other.removeAiTags && - tags == other.tags && - webhookUrl == other.webhookUrl && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - customCoordinates, - customMetadata, - description, - extensions, - removeAiTags, - tags, - webhookUrl, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UpdateFileDetails{customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, extensions=$extensions, removeAiTags=$removeAiTags, tags=$tags, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" - } - - class ChangePublicationStatus - private constructor( - private val publish: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("publish") - @ExcludeMissing - publish: JsonField = JsonMissing.of() - ) : this(publish, mutableMapOf()) - - /** - * Configure the publication status of a file and its versions. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun publish(): Optional = publish.getOptional("publish") - - /** - * Returns the raw JSON value of [publish]. - * - * Unlike [publish], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("publish") @ExcludeMissing fun _publish(): JsonField = publish - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [ChangePublicationStatus]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ChangePublicationStatus]. */ - class Builder internal constructor() { - - private var publish: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(changePublicationStatus: ChangePublicationStatus) = apply { - publish = changePublicationStatus.publish - additionalProperties = - changePublicationStatus.additionalProperties.toMutableMap() - } - - /** Configure the publication status of a file and its versions. */ - fun publish(publish: Publish) = publish(JsonField.of(publish)) - - /** - * Sets [Builder.publish] to an arbitrary JSON value. - * - * You should usually call [Builder.publish] with a well-typed [Publish] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun publish(publish: JsonField) = apply { this.publish = publish } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ChangePublicationStatus]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): ChangePublicationStatus = - ChangePublicationStatus(publish, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): ChangePublicationStatus = apply { - if (validated) { - return@apply - } - - publish().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (publish.asKnown().getOrNull()?.validity() ?: 0) - - /** Configure the publication status of a file and its versions. */ - class Publish - private constructor( - private val isPublished: JsonField, - private val includeFileVersions: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("isPublished") - @ExcludeMissing - isPublished: JsonField = JsonMissing.of(), - @JsonProperty("includeFileVersions") - @ExcludeMissing - includeFileVersions: JsonField = JsonMissing.of(), - ) : this(isPublished, includeFileVersions, mutableMapOf()) - - /** - * Set to `true` to publish the file. Set to `false` to unpublish the file. - * - * @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 isPublished(): Boolean = isPublished.getRequired("isPublished") - - /** - * Set to `true` to publish/unpublish all versions of the file. Set to `false` to - * publish/unpublish only the current version of the file. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun includeFileVersions(): Optional = - includeFileVersions.getOptional("includeFileVersions") - - /** - * Returns the raw JSON value of [isPublished]. - * - * Unlike [isPublished], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("isPublished") - @ExcludeMissing - fun _isPublished(): JsonField = isPublished - - /** - * Returns the raw JSON value of [includeFileVersions]. - * - * Unlike [includeFileVersions], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("includeFileVersions") - @ExcludeMissing - fun _includeFileVersions(): JsonField = includeFileVersions - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Publish]. - * - * The following fields are required: - * ```java - * .isPublished() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Publish]. */ - class Builder internal constructor() { - - private var isPublished: JsonField? = null - private var includeFileVersions: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(publish: Publish) = apply { - isPublished = publish.isPublished - includeFileVersions = publish.includeFileVersions - additionalProperties = publish.additionalProperties.toMutableMap() - } - - /** Set to `true` to publish the file. Set to `false` to unpublish the file. */ - fun isPublished(isPublished: Boolean) = isPublished(JsonField.of(isPublished)) - - /** - * Sets [Builder.isPublished] to an arbitrary JSON value. - * - * You should usually call [Builder.isPublished] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun isPublished(isPublished: JsonField) = apply { - this.isPublished = isPublished - } - - /** - * Set to `true` to publish/unpublish all versions of the file. Set to `false` - * to publish/unpublish only the current version of the file. - */ - fun includeFileVersions(includeFileVersions: Boolean) = - includeFileVersions(JsonField.of(includeFileVersions)) - - /** - * Sets [Builder.includeFileVersions] to an arbitrary JSON value. - * - * You should usually call [Builder.includeFileVersions] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun includeFileVersions(includeFileVersions: JsonField) = apply { - this.includeFileVersions = includeFileVersions - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Publish]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .isPublished() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Publish = - Publish( - checkRequired("isPublished", isPublished), - includeFileVersions, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Publish = apply { - if (validated) { - return@apply - } - - isPublished() - includeFileVersions() - 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 (isPublished.asKnown().isPresent) 1 else 0) + - (if (includeFileVersions.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Publish && - isPublished == other.isPublished && - includeFileVersions == other.includeFileVersions && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(isPublished, includeFileVersions, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Publish{isPublished=$isPublished, includeFileVersions=$includeFileVersions, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ChangePublicationStatus && - publish == other.publish && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(publish, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ChangePublicationStatus{publish=$publish, additionalProperties=$additionalProperties}" - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2789,14 +228,14 @@ private constructor( return other is FileUpdateParams && fileId == other.fileId && - body == other.body && + updateFileDetailsRequest == other.updateFileDetailsRequest && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(fileId, body, additionalHeaders, additionalQueryParams) + Objects.hash(fileId, updateFileDetailsRequest, additionalHeaders, additionalQueryParams) override fun toString() = - "FileUpdateParams{fileId=$fileId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "FileUpdateParams{fileId=$fileId, updateFileDetailsRequest=$updateFileDetailsRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt index 5306b662..f25fac33 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -29,7 +29,7 @@ import com.imagekit.api.core.http.Headers import com.imagekit.api.core.http.QueryParams import com.imagekit.api.core.toImmutable import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 import java.io.InputStream import java.nio.file.Path import java.util.Collections @@ -167,7 +167,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun extensions(): Optional> = body.extensions() + fun extensions(): Optional> = body.extensions() /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, @@ -388,7 +388,7 @@ private constructor( * * Unlike [extensions], this method doesn't throw if the multipart field has an unexpected type. */ - fun _extensions(): MultipartField> = body._extensions() + fun _extensions(): MultipartField> = body._extensions() /** * Returns the raw multipart value of [folder]. @@ -719,7 +719,7 @@ private constructor( * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ - fun extensions(extensions: List) = apply { + fun extensions(extensions: List) = apply { body.extensions(extensions) } @@ -727,42 +727,42 @@ private constructor( * Sets [Builder.extensions] to an arbitrary multipart value. * * You should usually call [Builder.extensions] with a well-typed - * `List` value instead. This method is primarily for setting + * `List` value instead. This method is primarily for setting * the field to an undocumented or not yet supported value. */ - fun extensions(extensions: MultipartField>) = apply { + fun extensions(extensions: MultipartField>) = apply { body.extensions(extensions) } /** - * Adds a single [UnnamedSchemaWithArrayParent3] to [extensions]. + * Adds a single [UnnamedSchemaWithArrayParent1] to [extensions]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addExtension(extension: UnnamedSchemaWithArrayParent3) = apply { + fun addExtension(extension: UnnamedSchemaWithArrayParent1) = apply { body.addExtension(extension) } /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent3.ofRemoveBg(removeBg)`. + * `UnnamedSchemaWithArrayParent1.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: UnnamedSchemaWithArrayParent3.RemoveBg) = apply { + fun addExtension(removeBg: UnnamedSchemaWithArrayParent1.RemoveBg) = apply { body.addExtension(removeBg) } /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension(autoTaggingExtension)`. + * `UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(autoTaggingExtension)`. */ - fun addExtension(autoTaggingExtension: UnnamedSchemaWithArrayParent3.AutoTaggingExtension) = + fun addExtension(autoTaggingExtension: UnnamedSchemaWithArrayParent1.AutoTaggingExtension) = apply { body.addExtension(autoTaggingExtension) } /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent3.ofAiAutoDescription()`. + * `UnnamedSchemaWithArrayParent1.ofAiAutoDescription()`. */ fun addExtensionAiAutoDescription() = apply { body.addExtensionAiAutoDescription() } @@ -1223,7 +1223,7 @@ private constructor( private val customMetadata: MultipartField, private val description: MultipartField, private val expire: MultipartField, - private val extensions: MultipartField>, + private val extensions: MultipartField>, private val folder: MultipartField, private val isPrivateFile: MultipartField, private val isPublished: MultipartField, @@ -1342,7 +1342,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun extensions(): Optional> = + fun extensions(): Optional> = extensions.value.getOptional("extensions") /** @@ -1580,7 +1580,7 @@ private constructor( */ @JsonProperty("extensions") @ExcludeMissing - fun _extensions(): MultipartField> = extensions + fun _extensions(): MultipartField> = extensions /** * Returns the raw multipart value of [folder]. @@ -1753,7 +1753,7 @@ private constructor( private var customMetadata: MultipartField = MultipartField.of(null) private var description: MultipartField = MultipartField.of(null) private var expire: MultipartField = MultipartField.of(null) - private var extensions: MultipartField>? = + private var extensions: MultipartField>? = null private var folder: MultipartField = MultipartField.of(null) private var isPrivateFile: MultipartField = MultipartField.of(null) @@ -1977,27 +1977,27 @@ private constructor( * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ - fun extensions(extensions: List) = + fun extensions(extensions: List) = extensions(MultipartField.of(extensions)) /** * Sets [Builder.extensions] to an arbitrary multipart value. * * You should usually call [Builder.extensions] with a well-typed - * `List` value instead. This method is primarily for + * `List` value instead. This method is primarily for * setting the field to an undocumented or not yet supported value. */ - fun extensions(extensions: MultipartField>) = + fun extensions(extensions: MultipartField>) = apply { this.extensions = extensions.map { it.toMutableList() } } /** - * Adds a single [UnnamedSchemaWithArrayParent3] to [extensions]. + * Adds a single [UnnamedSchemaWithArrayParent1] to [extensions]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addExtension(extension: UnnamedSchemaWithArrayParent3) = apply { + fun addExtension(extension: UnnamedSchemaWithArrayParent1) = apply { extensions = (extensions ?: MultipartField.of(mutableListOf())).also { checkKnown("extensions", it).add(extension) @@ -2006,28 +2006,28 @@ private constructor( /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent3.ofRemoveBg(removeBg)`. + * `UnnamedSchemaWithArrayParent1.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: UnnamedSchemaWithArrayParent3.RemoveBg) = - addExtension(UnnamedSchemaWithArrayParent3.ofRemoveBg(removeBg)) + fun addExtension(removeBg: UnnamedSchemaWithArrayParent1.RemoveBg) = + addExtension(UnnamedSchemaWithArrayParent1.ofRemoveBg(removeBg)) /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension(autoTaggingExtension)`. + * `UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(autoTaggingExtension)`. */ fun addExtension( - autoTaggingExtension: UnnamedSchemaWithArrayParent3.AutoTaggingExtension + autoTaggingExtension: UnnamedSchemaWithArrayParent1.AutoTaggingExtension ) = addExtension( - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension(autoTaggingExtension) + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(autoTaggingExtension) ) /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent3.ofAiAutoDescription()`. + * `UnnamedSchemaWithArrayParent1.ofAiAutoDescription()`. */ fun addExtensionAiAutoDescription() = - addExtension(UnnamedSchemaWithArrayParent3.ofAiAutoDescription()) + addExtension(UnnamedSchemaWithArrayParent1.ofAiAutoDescription()) /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist @@ -2584,9 +2584,9 @@ private constructor( override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent3.Deserializer::class) - @JsonSerialize(using = UnnamedSchemaWithArrayParent3.Serializer::class) - class UnnamedSchemaWithArrayParent3 + @JsonDeserialize(using = UnnamedSchemaWithArrayParent1.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent1.Serializer::class) + class UnnamedSchemaWithArrayParent1 private constructor( private val removeBg: RemoveBg? = null, private val autoTaggingExtension: AutoTaggingExtension? = null, @@ -2627,7 +2627,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent3 = apply { + fun validate(): UnnamedSchemaWithArrayParent1 = apply { if (validated) { return@apply } @@ -2697,7 +2697,7 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent3 && + return other is UnnamedSchemaWithArrayParent1 && removeBg == other.removeBg && autoTaggingExtension == other.autoTaggingExtension && aiAutoDescription == other.aiAutoDescription @@ -2708,33 +2708,33 @@ private constructor( override fun toString(): String = when { - removeBg != null -> "UnnamedSchemaWithArrayParent3{removeBg=$removeBg}" + removeBg != null -> "UnnamedSchemaWithArrayParent1{removeBg=$removeBg}" autoTaggingExtension != null -> - "UnnamedSchemaWithArrayParent3{autoTaggingExtension=$autoTaggingExtension}" + "UnnamedSchemaWithArrayParent1{autoTaggingExtension=$autoTaggingExtension}" aiAutoDescription != null -> - "UnnamedSchemaWithArrayParent3{aiAutoDescription=$aiAutoDescription}" - _json != null -> "UnnamedSchemaWithArrayParent3{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") + "UnnamedSchemaWithArrayParent1{aiAutoDescription=$aiAutoDescription}" + _json != null -> "UnnamedSchemaWithArrayParent1{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") } companion object { @JvmStatic - fun ofRemoveBg(removeBg: RemoveBg) = UnnamedSchemaWithArrayParent3(removeBg = removeBg) + fun ofRemoveBg(removeBg: RemoveBg) = UnnamedSchemaWithArrayParent1(removeBg = removeBg) @JvmStatic fun ofAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension) = - UnnamedSchemaWithArrayParent3(autoTaggingExtension = autoTaggingExtension) + UnnamedSchemaWithArrayParent1(autoTaggingExtension = autoTaggingExtension) @JvmStatic fun ofAiAutoDescription() = - UnnamedSchemaWithArrayParent3( + UnnamedSchemaWithArrayParent1( aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) ) } /** - * An interface that defines how to map each variant of [UnnamedSchemaWithArrayParent3] to a + * An interface that defines how to map each variant of [UnnamedSchemaWithArrayParent1] to a * value of type [T]. */ interface Visitor { @@ -2746,9 +2746,9 @@ private constructor( fun visitAiAutoDescription(aiAutoDescription: JsonValue): T /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent3] to a value of type [T]. + * Maps an unknown variant of [UnnamedSchemaWithArrayParent1] to a value of type [T]. * - * An instance of [UnnamedSchemaWithArrayParent3] can contain an unknown variant if it + * An instance of [UnnamedSchemaWithArrayParent1] can contain an unknown variant if it * was deserialized from data that doesn't match any known variant. For example, if the * SDK is on an older version than the API, then the API may respond with new variants * that the SDK is unaware of. @@ -2756,43 +2756,43 @@ private constructor( * @throws ImageKitInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown UnnamedSchemaWithArrayParent3: $json") + throw ImageKitInvalidDataException("Unknown UnnamedSchemaWithArrayParent1: $json") } } internal class Deserializer : - BaseDeserializer(UnnamedSchemaWithArrayParent3::class) { + BaseDeserializer(UnnamedSchemaWithArrayParent1::class) { - override fun ObjectCodec.deserialize(node: JsonNode): UnnamedSchemaWithArrayParent3 { + override fun ObjectCodec.deserialize(node: JsonNode): UnnamedSchemaWithArrayParent1 { val json = JsonValue.fromJsonNode(node) val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() when (name) { "remove-bg" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent3(removeBg = it, _json = json) - } ?: UnnamedSchemaWithArrayParent3(_json = json) + UnnamedSchemaWithArrayParent1(removeBg = it, _json = json) + } ?: UnnamedSchemaWithArrayParent1(_json = json) } "ai-auto-description" -> { return tryDeserialize(node, jacksonTypeRef()) ?.let { - UnnamedSchemaWithArrayParent3(aiAutoDescription = it, _json = json) + UnnamedSchemaWithArrayParent1(aiAutoDescription = it, _json = json) } - ?.takeIf { it.isValid() } ?: UnnamedSchemaWithArrayParent3(_json = json) + ?.takeIf { it.isValid() } ?: UnnamedSchemaWithArrayParent1(_json = json) } } return tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent3(autoTaggingExtension = it, _json = json) - } ?: UnnamedSchemaWithArrayParent3(_json = json) + UnnamedSchemaWithArrayParent1(autoTaggingExtension = it, _json = json) + } ?: UnnamedSchemaWithArrayParent1(_json = json) } } internal class Serializer : - BaseSerializer(UnnamedSchemaWithArrayParent3::class) { + BaseSerializer(UnnamedSchemaWithArrayParent1::class) { override fun serialize( - value: UnnamedSchemaWithArrayParent3, + value: UnnamedSchemaWithArrayParent1, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -2803,7 +2803,7 @@ private constructor( value.aiAutoDescription != null -> generator.writeObject(value.aiAutoDescription) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") } } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileDetailsRequest.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileDetailsRequest.kt new file mode 100644 index 00000000..0fbdcd19 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileDetailsRequest.kt @@ -0,0 +1,2536 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.allMaxBy +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +@JsonDeserialize(using = UpdateFileDetailsRequest.Deserializer::class) +@JsonSerialize(using = UpdateFileDetailsRequest.Serializer::class) +class UpdateFileDetailsRequest +private constructor( + private val updateFileDetails: UpdateFileDetails? = null, + private val changePublicationStatus: ChangePublicationStatus? = null, + private val _json: JsonValue? = null, +) { + + fun updateFileDetails(): Optional = Optional.ofNullable(updateFileDetails) + + fun changePublicationStatus(): Optional = + Optional.ofNullable(changePublicationStatus) + + fun isUpdateFileDetails(): Boolean = updateFileDetails != null + + fun isChangePublicationStatus(): Boolean = changePublicationStatus != null + + fun asUpdateFileDetails(): UpdateFileDetails = updateFileDetails.getOrThrow("updateFileDetails") + + fun asChangePublicationStatus(): ChangePublicationStatus = + changePublicationStatus.getOrThrow("changePublicationStatus") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + updateFileDetails != null -> visitor.visitUpdateFileDetails(updateFileDetails) + changePublicationStatus != null -> + visitor.visitChangePublicationStatus(changePublicationStatus) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UpdateFileDetailsRequest = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUpdateFileDetails(updateFileDetails: UpdateFileDetails) { + updateFileDetails.validate() + } + + override fun visitChangePublicationStatus( + changePublicationStatus: ChangePublicationStatus + ) { + changePublicationStatus.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUpdateFileDetails(updateFileDetails: UpdateFileDetails) = + updateFileDetails.validity() + + override fun visitChangePublicationStatus( + changePublicationStatus: ChangePublicationStatus + ) = changePublicationStatus.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UpdateFileDetailsRequest && + updateFileDetails == other.updateFileDetails && + changePublicationStatus == other.changePublicationStatus + } + + override fun hashCode(): Int = Objects.hash(updateFileDetails, changePublicationStatus) + + override fun toString(): String = + when { + updateFileDetails != null -> + "UpdateFileDetailsRequest{updateFileDetails=$updateFileDetails}" + changePublicationStatus != null -> + "UpdateFileDetailsRequest{changePublicationStatus=$changePublicationStatus}" + _json != null -> "UpdateFileDetailsRequest{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UpdateFileDetailsRequest") + } + + companion object { + + @JvmStatic + fun ofUpdateFileDetails(updateFileDetails: UpdateFileDetails) = + UpdateFileDetailsRequest(updateFileDetails = updateFileDetails) + + @JvmStatic + fun ofChangePublicationStatus(changePublicationStatus: ChangePublicationStatus) = + UpdateFileDetailsRequest(changePublicationStatus = changePublicationStatus) + } + + /** + * An interface that defines how to map each variant of [UpdateFileDetailsRequest] to a value of + * type [T]. + */ + interface Visitor { + + fun visitUpdateFileDetails(updateFileDetails: UpdateFileDetails): T + + fun visitChangePublicationStatus(changePublicationStatus: ChangePublicationStatus): T + + /** + * Maps an unknown variant of [UpdateFileDetailsRequest] to a value of type [T]. + * + * An instance of [UpdateFileDetailsRequest] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK is + * on an older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown UpdateFileDetailsRequest: $json") + } + } + + internal class Deserializer : + BaseDeserializer(UpdateFileDetailsRequest::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): UpdateFileDetailsRequest { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + UpdateFileDetailsRequest(updateFileDetails = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UpdateFileDetailsRequest(changePublicationStatus = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> UpdateFileDetailsRequest(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(UpdateFileDetailsRequest::class) { + + override fun serialize( + value: UpdateFileDetailsRequest, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.updateFileDetails != null -> generator.writeObject(value.updateFileDetails) + value.changePublicationStatus != null -> + generator.writeObject(value.changePublicationStatus) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid UpdateFileDetailsRequest") + } + } + } + + class UpdateFileDetails + private constructor( + private val customCoordinates: JsonField, + private val customMetadata: JsonField, + private val description: JsonField, + private val extensions: JsonField>, + private val removeAiTags: JsonField, + private val tags: JsonField>, + private val webhookUrl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("customCoordinates") + @ExcludeMissing + customCoordinates: JsonField = JsonMissing.of(), + @JsonProperty("customMetadata") + @ExcludeMissing + customMetadata: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("extensions") + @ExcludeMissing + extensions: JsonField> = JsonMissing.of(), + @JsonProperty("removeAITags") + @ExcludeMissing + removeAiTags: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), + @JsonProperty("webhookUrl") + @ExcludeMissing + webhookUrl: JsonField = JsonMissing.of(), + ) : this( + customCoordinates, + customMetadata, + description, + extensions, + removeAiTags, + tags, + webhookUrl, + mutableMapOf(), + ) + + /** + * Define an important area in the image in the format `x,y,width,height` e.g. + * `10,10,100,100`. Send `null` to unset this value. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customCoordinates(): Optional = + customCoordinates.getOptional("customCoordinates") + + /** + * A key-value data to be associated with the asset. To unset a key, send `null` value for + * that key. Before setting any custom metadata on an asset you have to create the field + * using custom metadata fields API. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun customMetadata(): Optional = + customMetadata.getOptional("customMetadata") + + /** + * Optional text to describe the contents of the file. + * + * @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") + + /** + * Array of extensions to be applied to the asset. Each extension can be configured with + * specific parameters based on the extension type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun extensions(): Optional> = + extensions.getOptional("extensions") + + /** + * An array of AITags associated with the file that you want to remove, e.g. `["car", + * "vehicle", "motorsports"]`. + * + * If you want to remove all AITags associated with the file, send a string - "all". + * + * Note: The remove operation for `AITags` executes before any of the `extensions` are + * processed. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun removeAiTags(): Optional = removeAiTags.getOptional("removeAITags") + + /** + * An array of tags associated with the file, such as `["tag1", "tag2"]`. Send `null` to + * unset all tags associated with the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tags(): Optional> = tags.getOptional("tags") + + /** + * The final status of extensions after they have completed execution will be delivered to + * this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookUrl(): Optional = webhookUrl.getOptional("webhookUrl") + + /** + * Returns the raw JSON value of [customCoordinates]. + * + * Unlike [customCoordinates], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("customCoordinates") + @ExcludeMissing + fun _customCoordinates(): JsonField = customCoordinates + + /** + * Returns the raw JSON value of [customMetadata]. + * + * Unlike [customMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): JsonField = customMetadata + + /** + * 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 [extensions]. + * + * Unlike [extensions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("extensions") + @ExcludeMissing + fun _extensions(): JsonField> = extensions + + /** + * Returns the raw JSON value of [removeAiTags]. + * + * Unlike [removeAiTags], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("removeAITags") + @ExcludeMissing + fun _removeAiTags(): JsonField = removeAiTags + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + + /** + * Returns the raw JSON value of [webhookUrl]. + * + * Unlike [webhookUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("webhookUrl") + @ExcludeMissing + fun _webhookUrl(): JsonField = webhookUrl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UpdateFileDetails]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UpdateFileDetails]. */ + class Builder internal constructor() { + + private var customCoordinates: JsonField = JsonMissing.of() + private var customMetadata: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var extensions: JsonField>? = null + private var removeAiTags: JsonField = JsonMissing.of() + private var tags: JsonField>? = null + private var webhookUrl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(updateFileDetails: UpdateFileDetails) = apply { + customCoordinates = updateFileDetails.customCoordinates + customMetadata = updateFileDetails.customMetadata + description = updateFileDetails.description + extensions = updateFileDetails.extensions.map { it.toMutableList() } + removeAiTags = updateFileDetails.removeAiTags + tags = updateFileDetails.tags.map { it.toMutableList() } + webhookUrl = updateFileDetails.webhookUrl + additionalProperties = updateFileDetails.additionalProperties.toMutableMap() + } + + /** + * Define an important area in the image in the format `x,y,width,height` e.g. + * `10,10,100,100`. Send `null` to unset this value. + */ + fun customCoordinates(customCoordinates: String?) = + customCoordinates(JsonField.ofNullable(customCoordinates)) + + /** + * Alias for calling [Builder.customCoordinates] with `customCoordinates.orElse(null)`. + */ + fun customCoordinates(customCoordinates: Optional) = + customCoordinates(customCoordinates.getOrNull()) + + /** + * Sets [Builder.customCoordinates] to an arbitrary JSON value. + * + * You should usually call [Builder.customCoordinates] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customCoordinates(customCoordinates: JsonField) = apply { + this.customCoordinates = customCoordinates + } + + /** + * A key-value data to be associated with the asset. To unset a key, send `null` value + * for that key. Before setting any custom metadata on an asset you have to create the + * field using custom metadata fields API. + */ + fun customMetadata(customMetadata: CustomMetadata) = + customMetadata(JsonField.of(customMetadata)) + + /** + * Sets [Builder.customMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.customMetadata] with a well-typed [CustomMetadata] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun customMetadata(customMetadata: JsonField) = apply { + this.customMetadata = customMetadata + } + + /** Optional text to describe the contents of the file. */ + 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 + } + + /** + * Array of extensions to be applied to the asset. Each extension can be configured with + * specific parameters based on the extension type. + */ + fun extensions(extensions: List) = + extensions(JsonField.of(extensions)) + + /** + * Sets [Builder.extensions] to an arbitrary JSON value. + * + * You should usually call [Builder.extensions] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun extensions(extensions: JsonField>) = apply { + this.extensions = extensions.map { it.toMutableList() } + } + + /** + * Adds a single [UnnamedSchemaWithArrayParent1] to [extensions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExtension(extension: UnnamedSchemaWithArrayParent1) = apply { + extensions = + (extensions ?: JsonField.of(mutableListOf())).also { + checkKnown("extensions", it).add(extension) + } + } + + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent1.ofRemoveBg(removeBg)`. + */ + fun addExtension(removeBg: UnnamedSchemaWithArrayParent1.RemoveBg) = + addExtension(UnnamedSchemaWithArrayParent1.ofRemoveBg(removeBg)) + + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(autoTaggingExtension)`. + */ + fun addExtension( + autoTaggingExtension: UnnamedSchemaWithArrayParent1.AutoTaggingExtension + ) = + addExtension( + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(autoTaggingExtension) + ) + + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent1.ofAiAutoDescription()`. + */ + fun addExtensionAiAutoDescription() = + addExtension(UnnamedSchemaWithArrayParent1.ofAiAutoDescription()) + + /** + * An array of AITags associated with the file that you want to remove, e.g. `["car", + * "vehicle", "motorsports"]`. + * + * If you want to remove all AITags associated with the file, send a string - "all". + * + * Note: The remove operation for `AITags` executes before any of the `extensions` are + * processed. + */ + fun removeAiTags(removeAiTags: RemoveAiTags) = removeAiTags(JsonField.of(removeAiTags)) + + /** + * Sets [Builder.removeAiTags] to an arbitrary JSON value. + * + * You should usually call [Builder.removeAiTags] with a well-typed [RemoveAiTags] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun removeAiTags(removeAiTags: JsonField) = apply { + this.removeAiTags = removeAiTags + } + + /** Alias for calling [removeAiTags] with `RemoveAiTags.ofStrings(strings)`. */ + fun removeAiTagsOfStrings(strings: List) = + removeAiTags(RemoveAiTags.ofStrings(strings)) + + /** Alias for calling [removeAiTags] with `RemoveAiTags.ofAll()`. */ + fun removeAiTagsAll() = removeAiTags(RemoveAiTags.ofAll()) + + /** + * An array of tags associated with the file, such as `["tag1", "tag2"]`. Send `null` to + * unset all tags associated with the file. + */ + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + /** + * The final status of extensions after they have completed execution will be delivered + * to this endpoint as a POST request. + * [Learn more](/docs/api-reference/digital-asset-management-dam/managing-assets/update-file-details#webhook-payload-structure) + * about the webhook payload structure. + */ + fun webhookUrl(webhookUrl: String) = webhookUrl(JsonField.of(webhookUrl)) + + /** + * Sets [Builder.webhookUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun webhookUrl(webhookUrl: JsonField) = apply { this.webhookUrl = webhookUrl } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UpdateFileDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UpdateFileDetails = + UpdateFileDetails( + customCoordinates, + customMetadata, + description, + (extensions ?: JsonMissing.of()).map { it.toImmutable() }, + removeAiTags, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + webhookUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UpdateFileDetails = apply { + if (validated) { + return@apply + } + + customCoordinates() + customMetadata().ifPresent { it.validate() } + description() + extensions().ifPresent { it.forEach { it.validate() } } + removeAiTags().ifPresent { it.validate() } + tags() + webhookUrl() + 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 (customCoordinates.asKnown().isPresent) 1 else 0) + + (customMetadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (extensions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (removeAiTags.asKnown().getOrNull()?.validity() ?: 0) + + (tags.asKnown().getOrNull()?.size ?: 0) + + (if (webhookUrl.asKnown().isPresent) 1 else 0) + + /** + * A key-value data to be associated with the asset. To unset a key, send `null` value for + * that key. Before setting any custom metadata on an asset you have to create the field + * using custom metadata fields API. + */ + class CustomMetadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CustomMetadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customMetadata: CustomMetadata) = apply { + additionalProperties = customMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CustomMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomMetadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = UnnamedSchemaWithArrayParent1.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent1.Serializer::class) + class UnnamedSchemaWithArrayParent1 + private constructor( + private val removeBg: RemoveBg? = null, + private val autoTaggingExtension: AutoTaggingExtension? = null, + private val aiAutoDescription: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun removeBg(): Optional = Optional.ofNullable(removeBg) + + fun autoTaggingExtension(): Optional = + Optional.ofNullable(autoTaggingExtension) + + fun aiAutoDescription(): Optional = Optional.ofNullable(aiAutoDescription) + + fun isRemoveBg(): Boolean = removeBg != null + + fun isAutoTaggingExtension(): Boolean = autoTaggingExtension != null + + fun isAiAutoDescription(): Boolean = aiAutoDescription != null + + fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") + + fun asAutoTaggingExtension(): AutoTaggingExtension = + autoTaggingExtension.getOrThrow("autoTaggingExtension") + + fun asAiAutoDescription(): JsonValue = aiAutoDescription.getOrThrow("aiAutoDescription") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + removeBg != null -> visitor.visitRemoveBg(removeBg) + autoTaggingExtension != null -> + visitor.visitAutoTaggingExtension(autoTaggingExtension) + aiAutoDescription != null -> visitor.visitAiAutoDescription(aiAutoDescription) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent1 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) { + removeBg.validate() + } + + override fun visitAutoTaggingExtension( + autoTaggingExtension: AutoTaggingExtension + ) { + autoTaggingExtension.validate() + } + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { + aiAutoDescription.let { + if (it != JsonValue.from(mapOf("name" to "ai-auto-description"))) { + throw ImageKitInvalidDataException( + "'aiAutoDescription' is invalid, received $it" + ) + } + } + } + } + ) + 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 = + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() + + override fun visitAutoTaggingExtension( + autoTaggingExtension: AutoTaggingExtension + ) = autoTaggingExtension.validity() + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = + aiAutoDescription.let { + if (it == JsonValue.from(mapOf("name" to "ai-auto-description"))) 1 + else 0 + } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent1 && + removeBg == other.removeBg && + autoTaggingExtension == other.autoTaggingExtension && + aiAutoDescription == other.aiAutoDescription + } + + override fun hashCode(): Int = + Objects.hash(removeBg, autoTaggingExtension, aiAutoDescription) + + override fun toString(): String = + when { + removeBg != null -> "UnnamedSchemaWithArrayParent1{removeBg=$removeBg}" + autoTaggingExtension != null -> + "UnnamedSchemaWithArrayParent1{autoTaggingExtension=$autoTaggingExtension}" + aiAutoDescription != null -> + "UnnamedSchemaWithArrayParent1{aiAutoDescription=$aiAutoDescription}" + _json != null -> "UnnamedSchemaWithArrayParent1{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") + } + + companion object { + + @JvmStatic + fun ofRemoveBg(removeBg: RemoveBg) = + UnnamedSchemaWithArrayParent1(removeBg = removeBg) + + @JvmStatic + fun ofAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension) = + UnnamedSchemaWithArrayParent1(autoTaggingExtension = autoTaggingExtension) + + @JvmStatic + fun ofAiAutoDescription() = + UnnamedSchemaWithArrayParent1( + aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) + ) + } + + /** + * An interface that defines how to map each variant of [UnnamedSchemaWithArrayParent1] + * to a value of type [T]. + */ + interface Visitor { + + fun visitRemoveBg(removeBg: RemoveBg): T + + fun visitAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension): T + + fun visitAiAutoDescription(aiAutoDescription: JsonValue): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent1] to a value of type + * [T]. + * + * An instance of [UnnamedSchemaWithArrayParent1] can contain an unknown variant if + * it was deserialized from data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent1: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent1::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent1 { + val json = JsonValue.fromJsonNode(node) + val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() + + when (name) { + "remove-bg" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent1(removeBg = it, _json = json) + } ?: UnnamedSchemaWithArrayParent1(_json = json) + } + "ai-auto-description" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnnamedSchemaWithArrayParent1( + aiAutoDescription = it, + _json = json, + ) + } + ?.takeIf { it.isValid() } + ?: UnnamedSchemaWithArrayParent1(_json = json) + } + } + + return tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent1(autoTaggingExtension = it, _json = json) + } ?: UnnamedSchemaWithArrayParent1(_json = json) + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent1::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent1, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.removeBg != null -> generator.writeObject(value.removeBg) + value.autoTaggingExtension != null -> + generator.writeObject(value.autoTaggingExtension) + value.aiAutoDescription != null -> + generator.writeObject(value.aiAutoDescription) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") + } + } + } + + class RemoveBg + private constructor( + private val name: JsonValue, + private val options: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("options") + @ExcludeMissing + options: JsonField = JsonMissing.of(), + ) : this(name, options, mutableMapOf()) + + /** + * Specifies the background removal extension. + * + * Expected to always return the following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun options(): Optional = options.getOptional("options") + + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("options") + @ExcludeMissing + fun _options(): JsonField = options + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveBg]. */ + class Builder internal constructor() { + + private var name: JsonValue = JsonValue.from("remove-bg") + private var options: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removeBg: RemoveBg) = apply { + name = removeBg.name + options = removeBg.options + additionalProperties = removeBg.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + fun options(options: Options) = options(JsonField.of(options)) + + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [Options] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun options(options: JsonField) = apply { this.options = options } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemoveBg]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemoveBg = + RemoveBg(name, options, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): RemoveBg = apply { + if (validated) { + return@apply + } + + _name().let { + if (it != JsonValue.from("remove-bg")) { + throw ImageKitInvalidDataException("'name' is invalid, received $it") + } + } + options().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + name.let { if (it == JsonValue.from("remove-bg")) 1 else 0 } + + (options.asKnown().getOrNull()?.validity() ?: 0) + + class Options + private constructor( + private val addShadow: JsonField, + private val bgColor: JsonField, + private val bgImageUrl: JsonField, + private val semitransparency: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("add_shadow") + @ExcludeMissing + addShadow: JsonField = JsonMissing.of(), + @JsonProperty("bg_color") + @ExcludeMissing + bgColor: JsonField = JsonMissing.of(), + @JsonProperty("bg_image_url") + @ExcludeMissing + bgImageUrl: JsonField = JsonMissing.of(), + @JsonProperty("semitransparency") + @ExcludeMissing + semitransparency: JsonField = JsonMissing.of(), + ) : this(addShadow, bgColor, bgImageUrl, semitransparency, mutableMapOf()) + + /** + * Whether to add an artificial shadow to the result. Default is false. Note: + * Adding shadows is currently only supported for car photos. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun addShadow(): Optional = addShadow.getOptional("add_shadow") + + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or + * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be + * empty. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun bgColor(): Optional = bgColor.getOptional("bg_color") + + /** + * Sets a background image from a URL. If this parameter is set, `bg_color` must + * be empty. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun bgImageUrl(): Optional = bgImageUrl.getOptional("bg_image_url") + + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun semitransparency(): Optional = + semitransparency.getOptional("semitransparency") + + /** + * Returns the raw JSON value of [addShadow]. + * + * Unlike [addShadow], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_shadow") + @ExcludeMissing + fun _addShadow(): JsonField = addShadow + + /** + * Returns the raw JSON value of [bgColor]. + * + * Unlike [bgColor], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bg_color") + @ExcludeMissing + fun _bgColor(): JsonField = bgColor + + /** + * Returns the raw JSON value of [bgImageUrl]. + * + * Unlike [bgImageUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("bg_image_url") + @ExcludeMissing + fun _bgImageUrl(): JsonField = bgImageUrl + + /** + * Returns the raw JSON value of [semitransparency]. + * + * Unlike [semitransparency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("semitransparency") + @ExcludeMissing + fun _semitransparency(): JsonField = semitransparency + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Options]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Options]. */ + class Builder internal constructor() { + + private var addShadow: JsonField = JsonMissing.of() + private var bgColor: JsonField = JsonMissing.of() + private var bgImageUrl: JsonField = JsonMissing.of() + private var semitransparency: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(options: Options) = apply { + addShadow = options.addShadow + bgColor = options.bgColor + bgImageUrl = options.bgImageUrl + semitransparency = options.semitransparency + additionalProperties = options.additionalProperties.toMutableMap() + } + + /** + * Whether to add an artificial shadow to the result. Default is false. + * Note: Adding shadows is currently only supported for car photos. + */ + fun addShadow(addShadow: Boolean) = addShadow(JsonField.of(addShadow)) + + /** + * Sets [Builder.addShadow] to an arbitrary JSON value. + * + * You should usually call [Builder.addShadow] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun addShadow(addShadow: JsonField) = apply { + this.addShadow = addShadow + } + + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") + * or color name (e.g., "green"). If this parameter is set, `bg_image_url` + * must be empty. + */ + fun bgColor(bgColor: String) = bgColor(JsonField.of(bgColor)) + + /** + * Sets [Builder.bgColor] to an arbitrary JSON value. + * + * You should usually call [Builder.bgColor] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun bgColor(bgColor: JsonField) = apply { this.bgColor = bgColor } + + /** + * Sets a background image from a URL. If this parameter is set, `bg_color` + * must be empty. + */ + fun bgImageUrl(bgImageUrl: String) = bgImageUrl(JsonField.of(bgImageUrl)) + + /** + * Sets [Builder.bgImageUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.bgImageUrl] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun bgImageUrl(bgImageUrl: JsonField) = apply { + this.bgImageUrl = bgImageUrl + } + + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + */ + fun semitransparency(semitransparency: Boolean) = + semitransparency(JsonField.of(semitransparency)) + + /** + * Sets [Builder.semitransparency] to an arbitrary JSON value. + * + * You should usually call [Builder.semitransparency] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun semitransparency(semitransparency: JsonField) = apply { + this.semitransparency = semitransparency + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Options]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Options = + Options( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Options = apply { + if (validated) { + return@apply + } + + addShadow() + bgColor() + bgImageUrl() + semitransparency() + 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 (addShadow.asKnown().isPresent) 1 else 0) + + (if (bgColor.asKnown().isPresent) 1 else 0) + + (if (bgImageUrl.asKnown().isPresent) 1 else 0) + + (if (semitransparency.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Options && + addShadow == other.addShadow && + bgColor == other.bgColor && + bgImageUrl == other.bgImageUrl && + semitransparency == other.semitransparency && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveBg && + name == other.name && + options == other.options && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(name, options, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" + } + + class AutoTaggingExtension + private constructor( + private val maxTags: JsonField, + private val minConfidence: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("maxTags") + @ExcludeMissing + maxTags: JsonField = JsonMissing.of(), + @JsonProperty("minConfidence") + @ExcludeMissing + minConfidence: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(maxTags, minConfidence, name, mutableMapOf()) + + /** + * Maximum number of tags to attach to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maxTags(): Long = maxTags.getRequired("maxTags") + + /** + * Minimum confidence level for tags to be considered valid. + * + * @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 minConfidence(): Long = minConfidence.getRequired("minConfidence") + + /** + * Specifies the auto-tagging extension used. + * + * @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(): Name = name.getRequired("name") + + /** + * Returns the raw JSON value of [maxTags]. + * + * Unlike [maxTags], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("maxTags") @ExcludeMissing fun _maxTags(): JsonField = maxTags + + /** + * Returns the raw JSON value of [minConfidence]. + * + * Unlike [minConfidence], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("minConfidence") + @ExcludeMissing + fun _minConfidence(): JsonField = minConfidence + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AutoTaggingExtension]. + * + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutoTaggingExtension]. */ + class Builder internal constructor() { + + private var maxTags: JsonField? = null + private var minConfidence: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { + maxTags = autoTaggingExtension.maxTags + minConfidence = autoTaggingExtension.minConfidence + name = autoTaggingExtension.name + additionalProperties = + autoTaggingExtension.additionalProperties.toMutableMap() + } + + /** Maximum number of tags to attach to the asset. */ + fun maxTags(maxTags: Long) = maxTags(JsonField.of(maxTags)) + + /** + * Sets [Builder.maxTags] to an arbitrary JSON value. + * + * You should usually call [Builder.maxTags] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun maxTags(maxTags: JsonField) = apply { this.maxTags = maxTags } + + /** Minimum confidence level for tags to be considered valid. */ + fun minConfidence(minConfidence: Long) = + minConfidence(JsonField.of(minConfidence)) + + /** + * Sets [Builder.minConfidence] to an arbitrary JSON value. + * + * You should usually call [Builder.minConfidence] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minConfidence(minConfidence: JsonField) = apply { + this.minConfidence = minConfidence + } + + /** Specifies the auto-tagging extension used. */ + fun name(name: Name) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [Name] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutoTaggingExtension]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutoTaggingExtension = + AutoTaggingExtension( + checkRequired("maxTags", maxTags), + checkRequired("minConfidence", minConfidence), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutoTaggingExtension = apply { + if (validated) { + return@apply + } + + maxTags() + minConfidence() + name().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (maxTags.asKnown().isPresent) 1 else 0) + + (if (minConfidence.asKnown().isPresent) 1 else 0) + + (name.asKnown().getOrNull()?.validity() ?: 0) + + /** Specifies the auto-tagging extension used. */ + class Name @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") + + @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + } + + /** + * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Name] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + /** + * An enum member indicating that [Name] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING + else -> throw ImageKitInvalidDataException("Unknown Name: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Name = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Name && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutoTaggingExtension && + maxTags == other.maxTags && + minConfidence == other.minConfidence && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(maxTags, minConfidence, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" + } + } + + /** + * An array of AITags associated with the file that you want to remove, e.g. `["car", + * "vehicle", "motorsports"]`. + * + * If you want to remove all AITags associated with the file, send a string - "all". + * + * Note: The remove operation for `AITags` executes before any of the `extensions` are + * processed. + */ + @JsonDeserialize(using = RemoveAiTags.Deserializer::class) + @JsonSerialize(using = RemoveAiTags.Serializer::class) + class RemoveAiTags + private constructor( + private val strings: List? = null, + private val all: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun strings(): Optional> = Optional.ofNullable(strings) + + fun all(): Optional = Optional.ofNullable(all) + + fun isStrings(): Boolean = strings != null + + fun isAll(): Boolean = all != null + + fun asStrings(): List = strings.getOrThrow("strings") + + fun asAll(): JsonValue = all.getOrThrow("all") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + strings != null -> visitor.visitStrings(strings) + all != null -> visitor.visitAll(all) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): RemoveAiTags = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitStrings(strings: List) {} + + override fun visitAll(all: JsonValue) { + all.let { + if (it != JsonValue.from("all")) { + throw ImageKitInvalidDataException( + "'all' is invalid, received $it" + ) + } + } + } + } + ) + 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 = + accept( + object : Visitor { + override fun visitStrings(strings: List) = strings.size + + override fun visitAll(all: JsonValue) = + all.let { if (it == JsonValue.from("all")) 1 else 0 } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveAiTags && strings == other.strings && all == other.all + } + + override fun hashCode(): Int = Objects.hash(strings, all) + + override fun toString(): String = + when { + strings != null -> "RemoveAiTags{strings=$strings}" + all != null -> "RemoveAiTags{all=$all}" + _json != null -> "RemoveAiTags{_unknown=$_json}" + else -> throw IllegalStateException("Invalid RemoveAiTags") + } + + companion object { + + @JvmStatic + fun ofStrings(strings: List) = RemoveAiTags(strings = strings.toImmutable()) + + @JvmStatic fun ofAll() = RemoveAiTags(all = JsonValue.from("all")) + } + + /** + * An interface that defines how to map each variant of [RemoveAiTags] to a value of + * type [T]. + */ + interface Visitor { + + fun visitStrings(strings: List): T + + fun visitAll(all: JsonValue): T + + /** + * Maps an unknown variant of [RemoveAiTags] to a value of type [T]. + * + * An instance of [RemoveAiTags] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown RemoveAiTags: $json") + } + } + + internal class Deserializer : BaseDeserializer(RemoveAiTags::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): RemoveAiTags { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { RemoveAiTags(all = it, _json = json) } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef>())?.let { + RemoveAiTags(strings = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> RemoveAiTags(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(RemoveAiTags::class) { + + override fun serialize( + value: RemoveAiTags, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.strings != null -> generator.writeObject(value.strings) + value.all != null -> generator.writeObject(value.all) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid RemoveAiTags") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UpdateFileDetails && + customCoordinates == other.customCoordinates && + customMetadata == other.customMetadata && + description == other.description && + extensions == other.extensions && + removeAiTags == other.removeAiTags && + tags == other.tags && + webhookUrl == other.webhookUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + customCoordinates, + customMetadata, + description, + extensions, + removeAiTags, + tags, + webhookUrl, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UpdateFileDetails{customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, extensions=$extensions, removeAiTags=$removeAiTags, tags=$tags, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + } + + class ChangePublicationStatus + private constructor( + private val publish: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("publish") @ExcludeMissing publish: JsonField = JsonMissing.of() + ) : this(publish, mutableMapOf()) + + /** + * Configure the publication status of a file and its versions. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun publish(): Optional = publish.getOptional("publish") + + /** + * Returns the raw JSON value of [publish]. + * + * Unlike [publish], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("publish") @ExcludeMissing fun _publish(): JsonField = publish + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChangePublicationStatus]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChangePublicationStatus]. */ + class Builder internal constructor() { + + private var publish: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(changePublicationStatus: ChangePublicationStatus) = apply { + publish = changePublicationStatus.publish + additionalProperties = changePublicationStatus.additionalProperties.toMutableMap() + } + + /** Configure the publication status of a file and its versions. */ + fun publish(publish: Publish) = publish(JsonField.of(publish)) + + /** + * Sets [Builder.publish] to an arbitrary JSON value. + * + * You should usually call [Builder.publish] with a well-typed [Publish] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun publish(publish: JsonField) = apply { this.publish = publish } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChangePublicationStatus]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ChangePublicationStatus = + ChangePublicationStatus(publish, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ChangePublicationStatus = apply { + if (validated) { + return@apply + } + + publish().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (publish.asKnown().getOrNull()?.validity() ?: 0) + + /** Configure the publication status of a file and its versions. */ + class Publish + private constructor( + private val isPublished: JsonField, + private val includeFileVersions: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("isPublished") + @ExcludeMissing + isPublished: JsonField = JsonMissing.of(), + @JsonProperty("includeFileVersions") + @ExcludeMissing + includeFileVersions: JsonField = JsonMissing.of(), + ) : this(isPublished, includeFileVersions, mutableMapOf()) + + /** + * Set to `true` to publish the file. Set to `false` to unpublish the file. + * + * @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 isPublished(): Boolean = isPublished.getRequired("isPublished") + + /** + * Set to `true` to publish/unpublish all versions of the file. Set to `false` to + * publish/unpublish only the current version of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun includeFileVersions(): Optional = + includeFileVersions.getOptional("includeFileVersions") + + /** + * Returns the raw JSON value of [isPublished]. + * + * Unlike [isPublished], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("isPublished") + @ExcludeMissing + fun _isPublished(): JsonField = isPublished + + /** + * Returns the raw JSON value of [includeFileVersions]. + * + * Unlike [includeFileVersions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeFileVersions") + @ExcludeMissing + fun _includeFileVersions(): JsonField = includeFileVersions + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Publish]. + * + * The following fields are required: + * ```java + * .isPublished() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Publish]. */ + class Builder internal constructor() { + + private var isPublished: JsonField? = null + private var includeFileVersions: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(publish: Publish) = apply { + isPublished = publish.isPublished + includeFileVersions = publish.includeFileVersions + additionalProperties = publish.additionalProperties.toMutableMap() + } + + /** Set to `true` to publish the file. Set to `false` to unpublish the file. */ + fun isPublished(isPublished: Boolean) = isPublished(JsonField.of(isPublished)) + + /** + * Sets [Builder.isPublished] to an arbitrary JSON value. + * + * You should usually call [Builder.isPublished] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun isPublished(isPublished: JsonField) = apply { + this.isPublished = isPublished + } + + /** + * Set to `true` to publish/unpublish all versions of the file. Set to `false` to + * publish/unpublish only the current version of the file. + */ + fun includeFileVersions(includeFileVersions: Boolean) = + includeFileVersions(JsonField.of(includeFileVersions)) + + /** + * Sets [Builder.includeFileVersions] to an arbitrary JSON value. + * + * You should usually call [Builder.includeFileVersions] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun includeFileVersions(includeFileVersions: JsonField) = apply { + this.includeFileVersions = includeFileVersions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Publish]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .isPublished() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Publish = + Publish( + checkRequired("isPublished", isPublished), + includeFileVersions, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Publish = apply { + if (validated) { + return@apply + } + + isPublished() + includeFileVersions() + 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 (isPublished.asKnown().isPresent) 1 else 0) + + (if (includeFileVersions.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Publish && + isPublished == other.isPublished && + includeFileVersions == other.includeFileVersions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(isPublished, includeFileVersions, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Publish{isPublished=$isPublished, includeFileVersions=$includeFileVersions, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChangePublicationStatus && + publish == other.publish && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(publish, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChangePublicationStatus{publish=$publish, additionalProperties=$additionalProperties}" + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt index abc2c34f..e4adb865 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt @@ -4,7 +4,7 @@ package com.imagekit.api.models.beta.v2.files import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField -import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -28,10 +28,10 @@ internal class FileUploadParamsTest { .description("Running shoes") .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -40,17 +40,17 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") @@ -107,10 +107,10 @@ internal class FileUploadParamsTest { .description("Running shoes") .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -119,17 +119,17 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") @@ -195,10 +195,10 @@ internal class FileUploadParamsTest { "extensions" to MultipartField.of( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options + UnnamedSchemaWithArrayParent1.RemoveBg.Options .builder() .addShadow(true) .bgColor("bg_color") @@ -208,18 +208,18 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension + UnnamedSchemaWithArrayParent1.AutoTaggingExtension .Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ), "folder" to MultipartField.of("folder"), diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt index d3d44b3e..8687562a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt @@ -3,7 +3,7 @@ package com.imagekit.api.models.files import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,11 +14,11 @@ internal class FileUpdateParamsTest { fun create() { FileUpdateParams.builder() .fileId("fileId") - .body( - FileUpdateParams.Body.UpdateFileDetails.builder() + .updateFileDetailsRequest( + UpdateFileDetailsRequest.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() + UpdateFileDetailsRequest.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("brand", JsonValue.from("bar")) .putAdditionalProperty("color", JsonValue.from("bar")) .build() @@ -26,10 +26,10 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -38,27 +38,27 @@ internal class FileUpdateParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .AWS_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) @@ -84,11 +84,11 @@ internal class FileUpdateParamsTest { val params = FileUpdateParams.builder() .fileId("fileId") - .body( - FileUpdateParams.Body.UpdateFileDetails.builder() + .updateFileDetailsRequest( + UpdateFileDetailsRequest.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() + UpdateFileDetailsRequest.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("brand", JsonValue.from("bar")) .putAdditionalProperty("color", JsonValue.from("bar")) .build() @@ -96,10 +96,10 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -108,27 +108,27 @@ internal class FileUpdateParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .AWS_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) @@ -143,11 +143,11 @@ internal class FileUpdateParamsTest { assertThat(body) .isEqualTo( - FileUpdateParams.Body.ofUpdateFileDetails( - FileUpdateParams.Body.UpdateFileDetails.builder() + UpdateFileDetailsRequest.ofUpdateFileDetails( + UpdateFileDetailsRequest.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() + UpdateFileDetailsRequest.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("brand", JsonValue.from("bar")) .putAdditionalProperty("color", JsonValue.from("bar")) .build() @@ -155,10 +155,10 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -167,27 +167,27 @@ internal class FileUpdateParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .AWS_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt index 36a36468..fbea5ec8 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt @@ -4,7 +4,7 @@ package com.imagekit.api.models.files import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField -import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -29,10 +29,10 @@ internal class FileUploadParamsTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -41,17 +41,17 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") @@ -111,10 +111,10 @@ internal class FileUploadParamsTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -123,17 +123,17 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") @@ -202,10 +202,10 @@ internal class FileUploadParamsTest { "extensions" to MultipartField.of( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options + UnnamedSchemaWithArrayParent1.RemoveBg.Options .builder() .addShadow(true) .bgColor("bg_color") @@ -215,18 +215,18 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension + UnnamedSchemaWithArrayParent1.AutoTaggingExtension .Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ), "folder" to MultipartField.of("folder"), diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileDetailsRequestTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileDetailsRequestTest.kt new file mode 100644 index 00000000..f11323f1 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileDetailsRequestTest.kt @@ -0,0 +1,186 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.files + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class UpdateFileDetailsRequestTest { + + @Test + fun ofUpdateFileDetails() { + val updateFileDetails = + UpdateFileDetailsRequest.UpdateFileDetails.builder() + .customCoordinates("customCoordinates") + .customMetadata( + UpdateFileDetailsRequest.UpdateFileDetails.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .extensions( + listOf( + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() + .options( + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + ) + ) + .removeAiTagsOfStrings(listOf("string")) + .addTag("tag1") + .addTag("tag2") + .webhookUrl("https://example.com") + .build() + + val updateFileDetailsRequest = + UpdateFileDetailsRequest.ofUpdateFileDetails(updateFileDetails) + + assertThat(updateFileDetailsRequest.updateFileDetails()).contains(updateFileDetails) + assertThat(updateFileDetailsRequest.changePublicationStatus()).isEmpty + } + + @Test + fun ofUpdateFileDetailsRoundtrip() { + val jsonMapper = jsonMapper() + val updateFileDetailsRequest = + UpdateFileDetailsRequest.ofUpdateFileDetails( + UpdateFileDetailsRequest.UpdateFileDetails.builder() + .customCoordinates("customCoordinates") + .customMetadata( + UpdateFileDetailsRequest.UpdateFileDetails.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .extensions( + listOf( + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() + .options( + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + ) + ) + .removeAiTagsOfStrings(listOf("string")) + .addTag("tag1") + .addTag("tag2") + .webhookUrl("https://example.com") + .build() + ) + + val roundtrippedUpdateFileDetailsRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(updateFileDetailsRequest), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUpdateFileDetailsRequest).isEqualTo(updateFileDetailsRequest) + } + + @Test + fun ofChangePublicationStatus() { + val changePublicationStatus = + UpdateFileDetailsRequest.ChangePublicationStatus.builder() + .publish( + UpdateFileDetailsRequest.ChangePublicationStatus.Publish.builder() + .isPublished(true) + .includeFileVersions(true) + .build() + ) + .build() + + val updateFileDetailsRequest = + UpdateFileDetailsRequest.ofChangePublicationStatus(changePublicationStatus) + + assertThat(updateFileDetailsRequest.updateFileDetails()).isEmpty + assertThat(updateFileDetailsRequest.changePublicationStatus()) + .contains(changePublicationStatus) + } + + @Test + fun ofChangePublicationStatusRoundtrip() { + val jsonMapper = jsonMapper() + val updateFileDetailsRequest = + UpdateFileDetailsRequest.ofChangePublicationStatus( + UpdateFileDetailsRequest.ChangePublicationStatus.builder() + .publish( + UpdateFileDetailsRequest.ChangePublicationStatus.Publish.builder() + .isPublished(true) + .includeFileVersions(true) + .build() + ) + .build() + ) + + val roundtrippedUpdateFileDetailsRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(updateFileDetailsRequest), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUpdateFileDetailsRequest).isEqualTo(updateFileDetailsRequest) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val updateFileDetailsRequest = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { updateFileDetailsRequest.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt index 00dad8c0..3989b7eb 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt @@ -22,7 +22,7 @@ import com.imagekit.api.errors.RateLimitException import com.imagekit.api.errors.UnauthorizedException import com.imagekit.api.errors.UnexpectedStatusCodeException import com.imagekit.api.errors.UnprocessableEntityException -import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 import com.imagekit.api.models.files.FileUploadParams import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.entry @@ -89,10 +89,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -101,17 +101,17 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") @@ -189,10 +189,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -201,17 +201,17 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") @@ -289,10 +289,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -301,17 +301,17 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") @@ -389,10 +389,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -401,17 +401,17 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") @@ -489,10 +489,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -501,17 +501,17 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") @@ -589,10 +589,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -601,17 +601,17 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") @@ -689,10 +689,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -701,17 +701,17 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") @@ -789,10 +789,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -801,17 +801,17 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") @@ -889,10 +889,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -901,17 +901,17 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") @@ -989,10 +989,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1001,17 +1001,17 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") @@ -1089,10 +1089,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1101,17 +1101,17 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") @@ -1189,10 +1189,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1201,17 +1201,17 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") @@ -1289,10 +1289,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1301,17 +1301,17 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") @@ -1389,10 +1389,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1401,17 +1401,17 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") @@ -1489,10 +1489,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1501,17 +1501,17 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") @@ -1589,10 +1589,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1601,17 +1601,17 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") @@ -1687,10 +1687,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1699,17 +1699,17 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt index b6f83f99..9c978aeb 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt @@ -15,7 +15,7 @@ import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.imagekit.api.client.ImageKitClient import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 import com.imagekit.api.models.files.FileUploadParams import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Disabled @@ -61,10 +61,10 @@ internal class ServiceParamsTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -73,17 +73,17 @@ internal class ServiceParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index 971b0818..80dc9fc6 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -5,12 +5,13 @@ package com.imagekit.api.services.async import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 import com.imagekit.api.models.files.FileCopyParams import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileRenameParams import com.imagekit.api.models.files.FileUpdateParams import com.imagekit.api.models.files.FileUploadParams +import com.imagekit.api.models.files.UpdateFileDetailsRequest import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -33,11 +34,11 @@ internal class FileServiceAsyncTest { fileServiceAsync.update( FileUpdateParams.builder() .fileId("fileId") - .body( - FileUpdateParams.Body.UpdateFileDetails.builder() + .updateFileDetailsRequest( + UpdateFileDetailsRequest.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() + UpdateFileDetailsRequest.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("brand", JsonValue.from("bar")) .putAdditionalProperty("color", JsonValue.from("bar")) .build() @@ -45,10 +46,10 @@ internal class FileServiceAsyncTest { .description("description") .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options + UnnamedSchemaWithArrayParent1.RemoveBg.Options .builder() .addShadow(true) .bgColor("bg_color") @@ -58,29 +59,29 @@ internal class FileServiceAsyncTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension + UnnamedSchemaWithArrayParent1.AutoTaggingExtension .Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension + UnnamedSchemaWithArrayParent1.AutoTaggingExtension .Name .AWS_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) @@ -229,10 +230,10 @@ internal class FileServiceAsyncTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -241,17 +242,17 @@ internal class FileServiceAsyncTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt index b1fbb82e..868c4122 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt @@ -5,7 +5,7 @@ package com.imagekit.api.services.async.beta.v2 import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 import com.imagekit.api.models.beta.v2.files.FileUploadParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -42,10 +42,10 @@ internal class FileServiceAsyncTest { .description("Running shoes") .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -54,17 +54,17 @@ internal class FileServiceAsyncTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index f9021b5e..67c03035 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -5,12 +5,13 @@ package com.imagekit.api.services.blocking import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 import com.imagekit.api.models.files.FileCopyParams import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileRenameParams import com.imagekit.api.models.files.FileUpdateParams import com.imagekit.api.models.files.FileUploadParams +import com.imagekit.api.models.files.UpdateFileDetailsRequest import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -33,11 +34,11 @@ internal class FileServiceTest { fileService.update( FileUpdateParams.builder() .fileId("fileId") - .body( - FileUpdateParams.Body.UpdateFileDetails.builder() + .updateFileDetailsRequest( + UpdateFileDetailsRequest.UpdateFileDetails.builder() .customCoordinates("10,10,100,100") .customMetadata( - FileUpdateParams.Body.UpdateFileDetails.CustomMetadata.builder() + UpdateFileDetailsRequest.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("brand", JsonValue.from("bar")) .putAdditionalProperty("color", JsonValue.from("bar")) .build() @@ -45,10 +46,10 @@ internal class FileServiceTest { .description("description") .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options + UnnamedSchemaWithArrayParent1.RemoveBg.Options .builder() .addShadow(true) .bgColor("bg_color") @@ -58,29 +59,29 @@ internal class FileServiceTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension + UnnamedSchemaWithArrayParent1.AutoTaggingExtension .Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension + UnnamedSchemaWithArrayParent1.AutoTaggingExtension .Name .AWS_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) @@ -222,10 +223,10 @@ internal class FileServiceTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -234,17 +235,17 @@ internal class FileServiceTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt index 852adefc..31f1bce6 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt @@ -5,7 +5,7 @@ package com.imagekit.api.services.blocking.beta.v2 import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.UnnamedSchemaWithArrayParent3 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 import com.imagekit.api.models.beta.v2.files.FileUploadParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -42,10 +42,10 @@ internal class FileServiceTest { .description("Running shoes") .extensions( listOf( - UnnamedSchemaWithArrayParent3.ofRemoveBg( - UnnamedSchemaWithArrayParent3.RemoveBg.builder() + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent3.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -54,17 +54,17 @@ internal class FileServiceTest { ) .build() ), - UnnamedSchemaWithArrayParent3.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent3.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent3.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) .folder("folder") diff --git a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt index 6b3c1c94..00e09e47 100644 --- a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt +++ b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt @@ -6,13 +6,10 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper -import com.imagekit.api.models.Overlay -import com.imagekit.api.models.OverlayPosition -import com.imagekit.api.models.OverlayTiming import com.imagekit.api.models.StreamingResolution -import com.imagekit.api.models.TextOverlay -import com.imagekit.api.models.TextOverlayTransformation +import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 import com.imagekit.api.models.files.File +import com.imagekit.api.models.files.UpdateFileDetailsRequest import java.time.OffsetDateTime import kotlin.reflect.full.memberFunctions import kotlin.reflect.jvm.javaMethod @@ -111,45 +108,59 @@ internal class ProGuardCompatibilityTest { } @Test - fun overlayRoundtrip() { + fun updateFileDetailsRequestRoundtrip() { val jsonMapper = jsonMapper() - val overlay = - Overlay.ofText( - TextOverlay.builder() - .position( - OverlayPosition.builder() - .focus(OverlayPosition.Focus.CENTER) - .x(0.0) - .y(0.0) + val updateFileDetailsRequest = + UpdateFileDetailsRequest.ofUpdateFileDetails( + UpdateFileDetailsRequest.UpdateFileDetails.builder() + .customCoordinates("customCoordinates") + .customMetadata( + UpdateFileDetailsRequest.UpdateFileDetails.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) - .text("text") - .encoding(TextOverlay.Encoding.AUTO) - .addTransformation( - TextOverlayTransformation.builder() - .alpha(1.0) - .background("background") - .flip(TextOverlayTransformation.Flip.H) - .fontColor("fontColor") - .fontFamily("fontFamily") - .fontSize(0.0) - .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) - .lineHeight(0.0) - .padding(0.0) - .radius(0.0) - .rotation(0.0) - .typography("typography") - .width(0.0) - .build() + .description("description") + .extensions( + listOf( + UnnamedSchemaWithArrayParent1.ofRemoveBg( + UnnamedSchemaWithArrayParent1.RemoveBg.builder() + .options( + UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + .maxTags(5L) + .minConfidence(95L) + .name( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + .GOOGLE_AUTO_TAGGING + ) + .build() + ), + UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + ) ) + .removeAiTagsOfStrings(listOf("string")) + .addTag("tag1") + .addTag("tag2") + .webhookUrl("https://example.com") .build() ) - val roundtrippedOverlay = - jsonMapper.readValue(jsonMapper.writeValueAsString(overlay), jacksonTypeRef()) + val roundtrippedUpdateFileDetailsRequest = + jsonMapper.readValue( + jsonMapper.writeValueAsString(updateFileDetailsRequest), + jacksonTypeRef(), + ) - assertThat(roundtrippedOverlay).isEqualTo(overlay) + assertThat(roundtrippedUpdateFileDetailsRequest).isEqualTo(updateFileDetailsRequest) } @Test From 2d52469a65c898504a76adb6ab4826aa3febbbdc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 9 Sep 2025 02:21:59 +0000 Subject: [PATCH 022/142] chore(internal): remove redundant deserializer symbols --- .../models/beta/v2/files/FileUploadParams.kt | 189 ------------------ .../api/models/files/FileUploadParams.kt | 189 ------------------ 2 files changed, 378 deletions(-) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt index 798baef4..dfca90aa 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt @@ -7,13 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer import com.imagekit.api.core.BaseSerializer import com.imagekit.api.core.Enum import com.imagekit.api.core.ExcludeMissing @@ -37,7 +32,6 @@ import java.util.Objects import java.util.Optional import kotlin.io.path.inputStream import kotlin.io.path.name -import kotlin.jvm.optionals.getOrNull /** * The V2 API enhances security by verifying the entire payload using JWT. This API is in beta. @@ -2318,7 +2312,6 @@ private constructor( override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent1.Deserializer::class) @JsonSerialize(using = UnnamedSchemaWithArrayParent1.Serializer::class) class UnnamedSchemaWithArrayParent1 private constructor( @@ -2400,32 +2393,6 @@ private constructor( false } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() - - override fun visitAutoTaggingExtension( - autoTaggingExtension: AutoTaggingExtension - ) = autoTaggingExtension.validity() - - override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = - aiAutoDescription.let { - if (it == JsonValue.from(mapOf("name" to "ai-auto-description"))) 1 - else 0 - } - - override fun unknown(json: JsonValue?) = 0 - } - ) - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2494,34 +2461,6 @@ private constructor( } } - internal class Deserializer : - BaseDeserializer(UnnamedSchemaWithArrayParent1::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): UnnamedSchemaWithArrayParent1 { - val json = JsonValue.fromJsonNode(node) - val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() - - when (name) { - "remove-bg" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent1(removeBg = it, _json = json) - } ?: UnnamedSchemaWithArrayParent1(_json = json) - } - "ai-auto-description" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { - UnnamedSchemaWithArrayParent1(aiAutoDescription = it, _json = json) - } - ?.takeIf { it.isValid() } ?: UnnamedSchemaWithArrayParent1(_json = json) - } - } - - return tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent1(autoTaggingExtension = it, _json = json) - } ?: UnnamedSchemaWithArrayParent1(_json = json) - } - } - internal class Serializer : BaseSerializer(UnnamedSchemaWithArrayParent1::class) { @@ -2549,14 +2488,6 @@ private constructor( private val additionalProperties: MutableMap, ) { - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), - @JsonProperty("options") - @ExcludeMissing - options: JsonField = JsonMissing.of(), - ) : this(name, options, mutableMapOf()) - /** * Specifies the background removal extension. * @@ -2694,17 +2625,6 @@ private constructor( false } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - name.let { if (it == JsonValue.from("remove-bg")) 1 else 0 } + - (options.asKnown().getOrNull()?.validity() ?: 0) - class Options private constructor( private val addShadow: JsonField, @@ -2714,22 +2634,6 @@ private constructor( private val additionalProperties: MutableMap, ) { - @JsonCreator - private constructor( - @JsonProperty("add_shadow") - @ExcludeMissing - addShadow: JsonField = JsonMissing.of(), - @JsonProperty("bg_color") - @ExcludeMissing - bgColor: JsonField = JsonMissing.of(), - @JsonProperty("bg_image_url") - @ExcludeMissing - bgImageUrl: JsonField = JsonMissing.of(), - @JsonProperty("semitransparency") - @ExcludeMissing - semitransparency: JsonField = JsonMissing.of(), - ) : this(addShadow, bgColor, bgImageUrl, semitransparency, mutableMapOf()) - /** * Whether to add an artificial shadow to the result. Default is false. Note: Adding * shadows is currently only supported for car photos. @@ -2971,19 +2875,6 @@ private constructor( false } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (addShadow.asKnown().isPresent) 1 else 0) + - (if (bgColor.asKnown().isPresent) 1 else 0) + - (if (bgImageUrl.asKnown().isPresent) 1 else 0) + - (if (semitransparency.asKnown().isPresent) 1 else 0) - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3040,17 +2931,6 @@ private constructor( private val additionalProperties: MutableMap, ) { - @JsonCreator - private constructor( - @JsonProperty("maxTags") - @ExcludeMissing - maxTags: JsonField = JsonMissing.of(), - @JsonProperty("minConfidence") - @ExcludeMissing - minConfidence: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(maxTags, minConfidence, name, mutableMapOf()) - /** * Maximum number of tags to attach to the asset. * @@ -3249,18 +3129,6 @@ private constructor( false } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (maxTags.asKnown().isPresent) 1 else 0) + - (if (minConfidence.asKnown().isPresent) 1 else 0) + - (name.asKnown().getOrNull()?.validity() ?: 0) - /** Specifies the auto-tagging extension used. */ class Name @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3776,7 +3644,6 @@ private constructor( false } - @JsonDeserialize(using = Post.Deserializer::class) @JsonSerialize(using = Post.Serializer::class) class Post private constructor( @@ -3861,29 +3728,6 @@ private constructor( false } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitTransformation(transformation: InnerTransformation) = - transformation.validity() - - override fun visitGifToVideo(gifToVideo: GifToVideo) = gifToVideo.validity() - - override fun visitThumbnail(thumbnail: Thumbnail) = thumbnail.validity() - - override fun visitAbs(abs: Abs) = abs.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3949,39 +3793,6 @@ private constructor( } } - internal class Deserializer : BaseDeserializer(Post::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Post { - val json = JsonValue.fromJsonNode(node) - val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - - when (type) { - "transformation" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Post(transformation = it, _json = json) } - ?: Post(_json = json) - } - "gif-to-video" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(gifToVideo = it, _json = json) - } ?: Post(_json = json) - } - "thumbnail" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(thumbnail = it, _json = json) - } ?: Post(_json = json) - } - "abs" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(abs = it, _json = json) - } ?: Post(_json = json) - } - } - - return Post(_json = json) - } - } - internal class Serializer : BaseSerializer(Post::class) { override fun serialize( diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt index f25fac33..ad7c211a 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -7,13 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer import com.imagekit.api.core.BaseSerializer import com.imagekit.api.core.Enum import com.imagekit.api.core.ExcludeMissing @@ -37,7 +32,6 @@ import java.util.Objects import java.util.Optional import kotlin.io.path.inputStream import kotlin.io.path.name -import kotlin.jvm.optionals.getOrNull /** * ImageKit.io allows you to upload files directly from both the server and client sides. For @@ -2584,7 +2578,6 @@ private constructor( override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent1.Deserializer::class) @JsonSerialize(using = UnnamedSchemaWithArrayParent1.Serializer::class) class UnnamedSchemaWithArrayParent1 private constructor( @@ -2666,32 +2659,6 @@ private constructor( false } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() - - override fun visitAutoTaggingExtension( - autoTaggingExtension: AutoTaggingExtension - ) = autoTaggingExtension.validity() - - override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = - aiAutoDescription.let { - if (it == JsonValue.from(mapOf("name" to "ai-auto-description"))) 1 - else 0 - } - - override fun unknown(json: JsonValue?) = 0 - } - ) - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2760,34 +2727,6 @@ private constructor( } } - internal class Deserializer : - BaseDeserializer(UnnamedSchemaWithArrayParent1::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): UnnamedSchemaWithArrayParent1 { - val json = JsonValue.fromJsonNode(node) - val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() - - when (name) { - "remove-bg" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent1(removeBg = it, _json = json) - } ?: UnnamedSchemaWithArrayParent1(_json = json) - } - "ai-auto-description" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { - UnnamedSchemaWithArrayParent1(aiAutoDescription = it, _json = json) - } - ?.takeIf { it.isValid() } ?: UnnamedSchemaWithArrayParent1(_json = json) - } - } - - return tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent1(autoTaggingExtension = it, _json = json) - } ?: UnnamedSchemaWithArrayParent1(_json = json) - } - } - internal class Serializer : BaseSerializer(UnnamedSchemaWithArrayParent1::class) { @@ -2815,14 +2754,6 @@ private constructor( private val additionalProperties: MutableMap, ) { - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), - @JsonProperty("options") - @ExcludeMissing - options: JsonField = JsonMissing.of(), - ) : this(name, options, mutableMapOf()) - /** * Specifies the background removal extension. * @@ -2960,17 +2891,6 @@ private constructor( false } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - name.let { if (it == JsonValue.from("remove-bg")) 1 else 0 } + - (options.asKnown().getOrNull()?.validity() ?: 0) - class Options private constructor( private val addShadow: JsonField, @@ -2980,22 +2900,6 @@ private constructor( private val additionalProperties: MutableMap, ) { - @JsonCreator - private constructor( - @JsonProperty("add_shadow") - @ExcludeMissing - addShadow: JsonField = JsonMissing.of(), - @JsonProperty("bg_color") - @ExcludeMissing - bgColor: JsonField = JsonMissing.of(), - @JsonProperty("bg_image_url") - @ExcludeMissing - bgImageUrl: JsonField = JsonMissing.of(), - @JsonProperty("semitransparency") - @ExcludeMissing - semitransparency: JsonField = JsonMissing.of(), - ) : this(addShadow, bgColor, bgImageUrl, semitransparency, mutableMapOf()) - /** * Whether to add an artificial shadow to the result. Default is false. Note: Adding * shadows is currently only supported for car photos. @@ -3237,19 +3141,6 @@ private constructor( false } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (addShadow.asKnown().isPresent) 1 else 0) + - (if (bgColor.asKnown().isPresent) 1 else 0) + - (if (bgImageUrl.asKnown().isPresent) 1 else 0) + - (if (semitransparency.asKnown().isPresent) 1 else 0) - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3306,17 +3197,6 @@ private constructor( private val additionalProperties: MutableMap, ) { - @JsonCreator - private constructor( - @JsonProperty("maxTags") - @ExcludeMissing - maxTags: JsonField = JsonMissing.of(), - @JsonProperty("minConfidence") - @ExcludeMissing - minConfidence: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(maxTags, minConfidence, name, mutableMapOf()) - /** * Maximum number of tags to attach to the asset. * @@ -3515,18 +3395,6 @@ private constructor( false } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (maxTags.asKnown().isPresent) 1 else 0) + - (if (minConfidence.asKnown().isPresent) 1 else 0) + - (name.asKnown().getOrNull()?.validity() ?: 0) - /** Specifies the auto-tagging extension used. */ class Name @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4042,7 +3910,6 @@ private constructor( false } - @JsonDeserialize(using = Post.Deserializer::class) @JsonSerialize(using = Post.Serializer::class) class Post private constructor( @@ -4127,29 +3994,6 @@ private constructor( false } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitTransformation(transformation: InnerTransformation) = - transformation.validity() - - override fun visitGifToVideo(gifToVideo: GifToVideo) = gifToVideo.validity() - - override fun visitThumbnail(thumbnail: Thumbnail) = thumbnail.validity() - - override fun visitAbs(abs: Abs) = abs.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4215,39 +4059,6 @@ private constructor( } } - internal class Deserializer : BaseDeserializer(Post::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Post { - val json = JsonValue.fromJsonNode(node) - val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - - when (type) { - "transformation" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Post(transformation = it, _json = json) } - ?: Post(_json = json) - } - "gif-to-video" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(gifToVideo = it, _json = json) - } ?: Post(_json = json) - } - "thumbnail" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(thumbnail = it, _json = json) - } ?: Post(_json = json) - } - "abs" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Post(abs = it, _json = json) - } ?: Post(_json = json) - } - } - - return Post(_json = json) - } - } - internal class Serializer : BaseSerializer(Post::class) { override fun serialize( From f25c3c46f4104091a5e8e376c22727eb3aaa4611 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 12 Sep 2025 02:26:28 +0000 Subject: [PATCH 023/142] chore(internal): codegen related update --- scripts/fast-format | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 scripts/fast-format diff --git a/scripts/fast-format b/scripts/fast-format new file mode 100755 index 00000000..2aa524fd --- /dev/null +++ b/scripts/fast-format @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +set -euo pipefail + +cd "$(dirname "$0")/.." + +if [ $# -eq 0 ]; then + echo "Usage: $0 [additional-formatter-args...]" + echo "The file should contain one file path per line" + exit 1 +fi + +FILE_LIST="$1" + +if [ ! -f "$FILE_LIST" ]; then + echo "Error: File '$FILE_LIST' not found" + exit 1 +fi + +if command -v ktfmt-fast-format &> /dev/null; then + echo "Error: ktfmt-fast-format not found" + exit 1 +fi + +# Process Kotlin files +kt_files=$(grep -E '\.kt$' "$FILE_LIST" | grep -v './buildSrc/build/') +kt_files=$(grep -E '\.kt$' "$FILE_LIST" | grep -v './buildSrc/build/') +echo "==> Found $(echo "$kt_files" | wc -l) Kotlin files:" + +if [[ -n "$kt_files" ]]; then + echo "==> will format Kotlin files" + echo "$kt_files" | tr '\n' '\0' | xargs -0 ktfmt --kotlinlang-style "$@" +else + echo "No Kotlin files to format -- expected outcome during incremental formatting" +fi + +# TODO(mbudayr): support palantir-java-format +# Process Java files +# grep -E '\.java$' "$FILE_LIST" | grep -v './buildSrc/build/' | tr '\n' '\0' | xargs -0 -r palantir-java-format --palantir --replace "$@" From da788af79c52a70075f39b26776b203cd958ceb0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 13 Sep 2025 02:34:50 +0000 Subject: [PATCH 024/142] chore(internal): codegen related update --- scripts/fast-format | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/fast-format b/scripts/fast-format index 2aa524fd..c8b60da2 100755 --- a/scripts/fast-format +++ b/scripts/fast-format @@ -17,7 +17,7 @@ if [ ! -f "$FILE_LIST" ]; then exit 1 fi -if command -v ktfmt-fast-format &> /dev/null; then +if ! command -v ktfmt-fast-format &> /dev/null; then echo "Error: ktfmt-fast-format not found" exit 1 fi From cd82f981b54a9131ed8195f62de0bb65bb436b6d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 13 Sep 2025 02:39:55 +0000 Subject: [PATCH 025/142] chore(internal): codegen related update --- scripts/fast-format | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/fast-format b/scripts/fast-format index c8b60da2..e16bfc56 100755 --- a/scripts/fast-format +++ b/scripts/fast-format @@ -29,7 +29,7 @@ echo "==> Found $(echo "$kt_files" | wc -l) Kotlin files:" if [[ -n "$kt_files" ]]; then echo "==> will format Kotlin files" - echo "$kt_files" | tr '\n' '\0' | xargs -0 ktfmt --kotlinlang-style "$@" + echo "$kt_files" | tr '\n' '\0' | xargs -0 ktfmt-fast-format --kotlinlang-style "$@" else echo "No Kotlin files to format -- expected outcome during incremental formatting" fi From 078eab8cf903109aaead3f0e90a2ee0b14c9c9ce Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 16 Sep 2025 02:21:22 +0000 Subject: [PATCH 026/142] fix(client): incorrect `getPackageVersion` impl --- .../src/main/kotlin/com/imagekit/api/core/Properties.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Properties.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Properties.kt index bc15f01f..d6ec5697 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Properties.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Properties.kt @@ -2,7 +2,7 @@ package com.imagekit.api.core -import java.util.Properties +import com.imagekit.api.client.ImageKitClient fun getOsArch(): String { val osArch = System.getProperty("os.arch") @@ -16,7 +16,7 @@ fun getOsArch(): String { "x86_64" -> "x64" "arm" -> "arm" "aarch64" -> "arm64" - else -> "other:${osArch}" + else -> "other:$osArch" } } @@ -30,13 +30,13 @@ fun getOsName(): String { osName.startsWith("Linux") -> "Linux" osName.startsWith("Mac OS") -> "MacOS" osName.startsWith("Windows") -> "Windows" - else -> "Other:${osName}" + else -> "Other:$osName" } } fun getOsVersion(): String = System.getProperty("os.version", "unknown") fun getPackageVersion(): String = - Properties::class.java.`package`.implementationVersion ?: "unknown" + ImageKitClient::class.java.`package`.implementationVersion ?: "unknown" fun getJavaVersion(): String = System.getProperty("java.version", "unknown") From 814caf9f6454c4b32af76f3a5b68d6af54d631b3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 19 Sep 2025 03:07:00 +0000 Subject: [PATCH 027/142] chore(internal): codegen related update --- .../async/accounts/OriginServiceAsync.kt | 28 +++++++++++++++++ .../async/accounts/UrlEndpointServiceAsync.kt | 31 +++++++++++++++++++ .../blocking/accounts/OriginService.kt | 28 +++++++++++++++++ .../blocking/accounts/UrlEndpointService.kt | 31 +++++++++++++++++++ .../async/accounts/OriginServiceAsyncTest.kt | 25 +++++++-------- .../accounts/UrlEndpointServiceAsyncTest.kt | 19 +++++------- .../blocking/accounts/OriginServiceTest.kt | 25 +++++++-------- .../accounts/UrlEndpointServiceTest.kt | 19 +++++------- 8 files changed, 154 insertions(+), 52 deletions(-) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsync.kt index 0852af1b..f21f8782 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsync.kt @@ -10,6 +10,7 @@ import com.imagekit.api.models.accounts.origins.OriginCreateParams import com.imagekit.api.models.accounts.origins.OriginDeleteParams import com.imagekit.api.models.accounts.origins.OriginGetParams import com.imagekit.api.models.accounts.origins.OriginListParams +import com.imagekit.api.models.accounts.origins.OriginRequest import com.imagekit.api.models.accounts.origins.OriginResponse import com.imagekit.api.models.accounts.origins.OriginUpdateParams import java.util.concurrent.CompletableFuture @@ -41,6 +42,17 @@ interface OriginServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see create */ + fun create( + originRequest: OriginRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(OriginCreateParams.builder().originRequest(originRequest).build(), requestOptions) + + /** @see create */ + fun create(originRequest: OriginRequest): CompletableFuture = + create(originRequest, RequestOptions.none()) + /** * **Note:** This API is currently in beta. Updates the origin identified by `id` and returns * the updated origin object. @@ -176,6 +188,22 @@ interface OriginServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see create */ + fun create( + originRequest: OriginRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + OriginCreateParams.builder().originRequest(originRequest).build(), + requestOptions, + ) + + /** @see create */ + fun create( + originRequest: OriginRequest + ): CompletableFuture> = + create(originRequest, RequestOptions.none()) + /** * Returns a raw HTTP response for `put /v1/accounts/origins/{id}`, but is otherwise the * same as [OriginServiceAsync.update]. diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsync.kt index 334612e2..51897d33 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsync.kt @@ -10,6 +10,7 @@ import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams import java.util.concurrent.CompletableFuture @@ -42,6 +43,20 @@ interface UrlEndpointServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see create */ + fun create( + urlEndpointRequest: UrlEndpointRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + UrlEndpointCreateParams.builder().urlEndpointRequest(urlEndpointRequest).build(), + requestOptions, + ) + + /** @see create */ + fun create(urlEndpointRequest: UrlEndpointRequest): CompletableFuture = + create(urlEndpointRequest, RequestOptions.none()) + /** * **Note:** This API is currently in beta. Updates the URL‑endpoint identified by `id` and * returns the updated object. @@ -185,6 +200,22 @@ interface UrlEndpointServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see create */ + fun create( + urlEndpointRequest: UrlEndpointRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + UrlEndpointCreateParams.builder().urlEndpointRequest(urlEndpointRequest).build(), + requestOptions, + ) + + /** @see create */ + fun create( + urlEndpointRequest: UrlEndpointRequest + ): CompletableFuture> = + create(urlEndpointRequest, RequestOptions.none()) + /** * Returns a raw HTTP response for `put /v1/accounts/url-endpoints/{id}`, but is otherwise * the same as [UrlEndpointServiceAsync.update]. diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginService.kt index 5d735334..2ccb9932 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginService.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginService.kt @@ -11,6 +11,7 @@ import com.imagekit.api.models.accounts.origins.OriginCreateParams import com.imagekit.api.models.accounts.origins.OriginDeleteParams import com.imagekit.api.models.accounts.origins.OriginGetParams import com.imagekit.api.models.accounts.origins.OriginListParams +import com.imagekit.api.models.accounts.origins.OriginRequest import com.imagekit.api.models.accounts.origins.OriginResponse import com.imagekit.api.models.accounts.origins.OriginUpdateParams import java.util.function.Consumer @@ -40,6 +41,17 @@ interface OriginService { requestOptions: RequestOptions = RequestOptions.none(), ): OriginResponse + /** @see create */ + fun create( + originRequest: OriginRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): OriginResponse = + create(OriginCreateParams.builder().originRequest(originRequest).build(), requestOptions) + + /** @see create */ + fun create(originRequest: OriginRequest): OriginResponse = + create(originRequest, RequestOptions.none()) + /** * **Note:** This API is currently in beta. Updates the origin identified by `id` and returns * the updated origin object. @@ -162,6 +174,22 @@ interface OriginService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see create */ + @MustBeClosed + fun create( + originRequest: OriginRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + OriginCreateParams.builder().originRequest(originRequest).build(), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create(originRequest: OriginRequest): HttpResponseFor = + create(originRequest, RequestOptions.none()) + /** * Returns a raw HTTP response for `put /v1/accounts/origins/{id}`, but is otherwise the * same as [OriginService.update]. diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointService.kt index bdd10fd3..567a037d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointService.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointService.kt @@ -11,6 +11,7 @@ import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams +import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams import java.util.function.Consumer @@ -42,6 +43,20 @@ interface UrlEndpointService { requestOptions: RequestOptions = RequestOptions.none(), ): UrlEndpointResponse + /** @see create */ + fun create( + urlEndpointRequest: UrlEndpointRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): UrlEndpointResponse = + create( + UrlEndpointCreateParams.builder().urlEndpointRequest(urlEndpointRequest).build(), + requestOptions, + ) + + /** @see create */ + fun create(urlEndpointRequest: UrlEndpointRequest): UrlEndpointResponse = + create(urlEndpointRequest, RequestOptions.none()) + /** * **Note:** This API is currently in beta. Updates the URL‑endpoint identified by `id` and * returns the updated object. @@ -175,6 +190,22 @@ interface UrlEndpointService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see create */ + @MustBeClosed + fun create( + urlEndpointRequest: UrlEndpointRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + UrlEndpointCreateParams.builder().urlEndpointRequest(urlEndpointRequest).build(), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create(urlEndpointRequest: UrlEndpointRequest): HttpResponseFor = + create(urlEndpointRequest, RequestOptions.none()) + /** * Returns a raw HTTP response for `put /v1/accounts/url-endpoints/{id}`, but is otherwise * the same as [UrlEndpointService.update]. diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt index fb62ce18..e2844773 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt @@ -4,7 +4,6 @@ package com.imagekit.api.services.async.accounts import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import com.imagekit.api.models.accounts.origins.OriginCreateParams import com.imagekit.api.models.accounts.origins.OriginRequest import com.imagekit.api.models.accounts.origins.OriginUpdateParams import org.junit.jupiter.api.Disabled @@ -27,19 +26,17 @@ internal class OriginServiceAsyncTest { val originResponseFuture = originServiceAsync.create( - OriginCreateParams.builder() - .originRequest( - OriginRequest.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("images") - .build() - ) - .build() + OriginRequest.ofS3( + OriginRequest.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) ) val originResponse = originResponseFuture.get() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt index e95e7e55..312d19f5 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt @@ -4,7 +4,6 @@ package com.imagekit.api.services.async.accounts import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams import org.junit.jupiter.api.Disabled @@ -27,17 +26,13 @@ internal class UrlEndpointServiceAsyncTest { val urlEndpointResponseFuture = urlEndpointServiceAsync.create( - UrlEndpointCreateParams.builder() - .urlEndpointRequest( - UrlEndpointRequest.builder() - .description("My custom URL endpoint") - .addOrigin("origin-id-1") - .urlPrefix("product-images") - .urlRewriter( - UrlEndpointRequest.UrlRewriter.Cloudinary.builder() - .preserveAssetDeliveryTypes(true) - .build() - ) + UrlEndpointRequest.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) .build() ) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt index 2e20139f..9888e845 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt @@ -4,7 +4,6 @@ package com.imagekit.api.services.blocking.accounts import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.models.accounts.origins.OriginCreateParams import com.imagekit.api.models.accounts.origins.OriginRequest import com.imagekit.api.models.accounts.origins.OriginUpdateParams import org.junit.jupiter.api.Disabled @@ -27,19 +26,17 @@ internal class OriginServiceTest { val originResponse = originService.create( - OriginCreateParams.builder() - .originRequest( - OriginRequest.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("images") - .build() - ) - .build() + OriginRequest.ofS3( + OriginRequest.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() + ) ) originResponse.validate() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt index cdd0f580..f88b7478 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt @@ -4,7 +4,6 @@ package com.imagekit.api.services.blocking.accounts import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams import org.junit.jupiter.api.Disabled @@ -27,17 +26,13 @@ internal class UrlEndpointServiceTest { val urlEndpointResponse = urlEndpointService.create( - UrlEndpointCreateParams.builder() - .urlEndpointRequest( - UrlEndpointRequest.builder() - .description("My custom URL endpoint") - .addOrigin("origin-id-1") - .urlPrefix("product-images") - .urlRewriter( - UrlEndpointRequest.UrlRewriter.Cloudinary.builder() - .preserveAssetDeliveryTypes(true) - .build() - ) + UrlEndpointRequest.builder() + .description("My custom URL endpoint") + .addOrigin("origin-id-1") + .urlPrefix("product-images") + .urlRewriter( + UrlEndpointRequest.UrlRewriter.Cloudinary.builder() + .preserveAssetDeliveryTypes(true) .build() ) .build() From 2d41187dea1edca9d0f941690244b4c50874d9cc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 19 Sep 2025 12:59:32 +0000 Subject: [PATCH 028/142] feat(api): manual updates --- .stats.yml | 6 +- .../api/models/files/FileUpdateParams.kt | 77 ++- ...DetailsRequest.kt => UpdateFileRequest.kt} | 475 ++---------------- .../api/services/async/FileServiceAsync.kt | 48 +- .../services/async/FileServiceAsyncImpl.kt | 2 +- .../api/services/blocking/FileService.kt | 42 +- .../api/services/blocking/FileServiceImpl.kt | 2 +- .../api/models/files/FileUpdateParamsTest.kt | 118 ++--- ...equestTest.kt => UpdateFileRequestTest.kt} | 96 +--- .../services/async/FileServiceAsyncTest.kt | 35 +- .../api/services/blocking/FileServiceTest.kt | 35 +- .../api/proguard/ProGuardCompatibilityTest.kt | 23 +- 12 files changed, 219 insertions(+), 740 deletions(-) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/{UpdateFileDetailsRequest.kt => UpdateFileRequest.kt} (83%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/{UpdateFileDetailsRequestTest.kt => UpdateFileRequestTest.kt} (56%) diff --git a/.stats.yml b/.stats.yml index b0086e96..bb4a090c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-bc7c0d27962b30c19c778656988e154b54696819389289f34420a5e5fdfbd3b8.yml -openapi_spec_hash: 1bfde02a63416c036e9545927f727459 -config_hash: b415c06a3b29485af4601beb94ae1aeb +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-dd864816d7f4316ae89f57394da2fd1926166d4704db5a0bb5d23461d2d75e49.yml +openapi_spec_hash: 7f7c416563a15bbaea98804ecdc1a8f9 +config_hash: 54c05a157f2cc730fac9e1df5dc3ca29 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt index 479191fb..da034a61 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt @@ -2,7 +2,9 @@ package com.imagekit.api.models.files +import com.imagekit.api.core.JsonValue import com.imagekit.api.core.Params +import com.imagekit.api.core.checkRequired import com.imagekit.api.core.http.Headers import com.imagekit.api.core.http.QueryParams import java.util.Objects @@ -17,15 +19,15 @@ import kotlin.jvm.optionals.getOrNull class FileUpdateParams private constructor( private val fileId: String?, - private val updateFileDetailsRequest: UpdateFileDetailsRequest?, + private val updateFileRequest: UpdateFileRequest, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun fileId(): Optional = Optional.ofNullable(fileId) - fun updateFileDetailsRequest(): Optional = - Optional.ofNullable(updateFileDetailsRequest) + /** Schema for update file update request. */ + fun updateFileRequest(): UpdateFileRequest = updateFileRequest /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -37,9 +39,14 @@ private constructor( companion object { - @JvmStatic fun none(): FileUpdateParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [FileUpdateParams]. */ + /** + * Returns a mutable builder for constructing an instance of [FileUpdateParams]. + * + * The following fields are required: + * ```java + * .updateFileRequest() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -47,14 +54,14 @@ private constructor( class Builder internal constructor() { private var fileId: String? = null - private var updateFileDetailsRequest: UpdateFileDetailsRequest? = null + private var updateFileRequest: UpdateFileRequest? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(fileUpdateParams: FileUpdateParams) = apply { fileId = fileUpdateParams.fileId - updateFileDetailsRequest = fileUpdateParams.updateFileDetailsRequest + updateFileRequest = fileUpdateParams.updateFileRequest additionalHeaders = fileUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = fileUpdateParams.additionalQueryParams.toBuilder() } @@ -64,38 +71,21 @@ private constructor( /** Alias for calling [Builder.fileId] with `fileId.orElse(null)`. */ fun fileId(fileId: Optional) = fileId(fileId.getOrNull()) - fun updateFileDetailsRequest(updateFileDetailsRequest: UpdateFileDetailsRequest?) = apply { - this.updateFileDetailsRequest = updateFileDetailsRequest + /** Schema for update file update request. */ + fun updateFileRequest(updateFileRequest: UpdateFileRequest) = apply { + this.updateFileRequest = updateFileRequest } - /** - * Alias for calling [Builder.updateFileDetailsRequest] with - * `updateFileDetailsRequest.orElse(null)`. - */ - fun updateFileDetailsRequest(updateFileDetailsRequest: Optional) = - updateFileDetailsRequest(updateFileDetailsRequest.getOrNull()) + /** Alias for calling [updateFileRequest] with `UpdateFileRequest.ofDetails(details)`. */ + fun updateFileRequest(details: UpdateFileRequest.UpdateFileDetails) = + updateFileRequest(UpdateFileRequest.ofDetails(details)) /** - * Alias for calling [updateFileDetailsRequest] with - * `UpdateFileDetailsRequest.ofUpdateFileDetails(updateFileDetails)`. + * Alias for calling [updateFileRequest] with + * `UpdateFileRequest.ofChangePublicationStatus(changePublicationStatus)`. */ - fun updateFileDetailsRequest( - updateFileDetails: UpdateFileDetailsRequest.UpdateFileDetails - ) = - updateFileDetailsRequest( - UpdateFileDetailsRequest.ofUpdateFileDetails(updateFileDetails) - ) - - /** - * Alias for calling [updateFileDetailsRequest] with - * `UpdateFileDetailsRequest.ofChangePublicationStatus(changePublicationStatus)`. - */ - fun updateFileDetailsRequest( - changePublicationStatus: UpdateFileDetailsRequest.ChangePublicationStatus - ) = - updateFileDetailsRequest( - UpdateFileDetailsRequest.ofChangePublicationStatus(changePublicationStatus) - ) + fun updateFileRequest(changePublicationStatus: JsonValue) = + updateFileRequest(UpdateFileRequest.ofChangePublicationStatus(changePublicationStatus)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -199,17 +189,24 @@ private constructor( * Returns an immutable instance of [FileUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .updateFileRequest() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): FileUpdateParams = FileUpdateParams( fileId, - updateFileDetailsRequest, + checkRequired("updateFileRequest", updateFileRequest), additionalHeaders.build(), additionalQueryParams.build(), ) } - fun _body(): Optional = Optional.ofNullable(updateFileDetailsRequest) + fun _body(): UpdateFileRequest = updateFileRequest fun _pathParam(index: Int): String = when (index) { @@ -228,14 +225,14 @@ private constructor( return other is FileUpdateParams && fileId == other.fileId && - updateFileDetailsRequest == other.updateFileDetailsRequest && + updateFileRequest == other.updateFileRequest && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(fileId, updateFileDetailsRequest, additionalHeaders, additionalQueryParams) + Objects.hash(fileId, updateFileRequest, additionalHeaders, additionalQueryParams) override fun toString() = - "FileUpdateParams{fileId=$fileId, updateFileDetailsRequest=$updateFileDetailsRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "FileUpdateParams{fileId=$fileId, updateFileRequest=$updateFileRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileDetailsRequest.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt similarity index 83% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileDetailsRequest.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt index 0fbdcd19..a07b1ecb 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileDetailsRequest.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt @@ -32,34 +32,35 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -@JsonDeserialize(using = UpdateFileDetailsRequest.Deserializer::class) -@JsonSerialize(using = UpdateFileDetailsRequest.Serializer::class) -class UpdateFileDetailsRequest +/** Schema for update file update request. */ +@JsonDeserialize(using = UpdateFileRequest.Deserializer::class) +@JsonSerialize(using = UpdateFileRequest.Serializer::class) +class UpdateFileRequest private constructor( - private val updateFileDetails: UpdateFileDetails? = null, - private val changePublicationStatus: ChangePublicationStatus? = null, + private val details: UpdateFileDetails? = null, + private val changePublicationStatus: JsonValue? = null, private val _json: JsonValue? = null, ) { - fun updateFileDetails(): Optional = Optional.ofNullable(updateFileDetails) + fun details(): Optional = Optional.ofNullable(details) - fun changePublicationStatus(): Optional = + fun changePublicationStatus(): Optional = Optional.ofNullable(changePublicationStatus) - fun isUpdateFileDetails(): Boolean = updateFileDetails != null + fun isDetails(): Boolean = details != null fun isChangePublicationStatus(): Boolean = changePublicationStatus != null - fun asUpdateFileDetails(): UpdateFileDetails = updateFileDetails.getOrThrow("updateFileDetails") + fun asDetails(): UpdateFileDetails = details.getOrThrow("details") - fun asChangePublicationStatus(): ChangePublicationStatus = + fun asChangePublicationStatus(): JsonValue = changePublicationStatus.getOrThrow("changePublicationStatus") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - updateFileDetails != null -> visitor.visitUpdateFileDetails(updateFileDetails) + details != null -> visitor.visitDetails(details) changePublicationStatus != null -> visitor.visitChangePublicationStatus(changePublicationStatus) else -> visitor.unknown(_json) @@ -67,22 +68,18 @@ private constructor( private var validated: Boolean = false - fun validate(): UpdateFileDetailsRequest = apply { + fun validate(): UpdateFileRequest = apply { if (validated) { return@apply } accept( object : Visitor { - override fun visitUpdateFileDetails(updateFileDetails: UpdateFileDetails) { - updateFileDetails.validate() + override fun visitDetails(details: UpdateFileDetails) { + details.validate() } - override fun visitChangePublicationStatus( - changePublicationStatus: ChangePublicationStatus - ) { - changePublicationStatus.validate() - } + override fun visitChangePublicationStatus(changePublicationStatus: JsonValue) {} } ) validated = true @@ -105,12 +102,9 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUpdateFileDetails(updateFileDetails: UpdateFileDetails) = - updateFileDetails.validity() + override fun visitDetails(details: UpdateFileDetails) = details.validity() - override fun visitChangePublicationStatus( - changePublicationStatus: ChangePublicationStatus - ) = changePublicationStatus.validity() + override fun visitChangePublicationStatus(changePublicationStatus: JsonValue) = 1 override fun unknown(json: JsonValue?) = 0 } @@ -121,72 +115,68 @@ private constructor( return true } - return other is UpdateFileDetailsRequest && - updateFileDetails == other.updateFileDetails && + return other is UpdateFileRequest && + details == other.details && changePublicationStatus == other.changePublicationStatus } - override fun hashCode(): Int = Objects.hash(updateFileDetails, changePublicationStatus) + override fun hashCode(): Int = Objects.hash(details, changePublicationStatus) override fun toString(): String = when { - updateFileDetails != null -> - "UpdateFileDetailsRequest{updateFileDetails=$updateFileDetails}" + details != null -> "UpdateFileRequest{details=$details}" changePublicationStatus != null -> - "UpdateFileDetailsRequest{changePublicationStatus=$changePublicationStatus}" - _json != null -> "UpdateFileDetailsRequest{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UpdateFileDetailsRequest") + "UpdateFileRequest{changePublicationStatus=$changePublicationStatus}" + _json != null -> "UpdateFileRequest{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UpdateFileRequest") } companion object { - @JvmStatic - fun ofUpdateFileDetails(updateFileDetails: UpdateFileDetails) = - UpdateFileDetailsRequest(updateFileDetails = updateFileDetails) + @JvmStatic fun ofDetails(details: UpdateFileDetails) = UpdateFileRequest(details = details) @JvmStatic - fun ofChangePublicationStatus(changePublicationStatus: ChangePublicationStatus) = - UpdateFileDetailsRequest(changePublicationStatus = changePublicationStatus) + fun ofChangePublicationStatus(changePublicationStatus: JsonValue) = + UpdateFileRequest(changePublicationStatus = changePublicationStatus) } /** - * An interface that defines how to map each variant of [UpdateFileDetailsRequest] to a value of - * type [T]. + * An interface that defines how to map each variant of [UpdateFileRequest] to a value of type + * [T]. */ interface Visitor { - fun visitUpdateFileDetails(updateFileDetails: UpdateFileDetails): T + fun visitDetails(details: UpdateFileDetails): T - fun visitChangePublicationStatus(changePublicationStatus: ChangePublicationStatus): T + fun visitChangePublicationStatus(changePublicationStatus: JsonValue): T /** - * Maps an unknown variant of [UpdateFileDetailsRequest] to a value of type [T]. + * Maps an unknown variant of [UpdateFileRequest] to a value of type [T]. * - * An instance of [UpdateFileDetailsRequest] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK is - * on an older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * An instance of [UpdateFileRequest] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is unaware + * of. * * @throws ImageKitInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown UpdateFileDetailsRequest: $json") + throw ImageKitInvalidDataException("Unknown UpdateFileRequest: $json") } } - internal class Deserializer : - BaseDeserializer(UpdateFileDetailsRequest::class) { + internal class Deserializer : BaseDeserializer(UpdateFileRequest::class) { - override fun ObjectCodec.deserialize(node: JsonNode): UpdateFileDetailsRequest { + override fun ObjectCodec.deserialize(node: JsonNode): UpdateFileRequest { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UpdateFileDetailsRequest(updateFileDetails = it, _json = json) + UpdateFileRequest(details = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - UpdateFileDetailsRequest(changePublicationStatus = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + UpdateFileRequest(changePublicationStatus = it, _json = json) }, ) .filterNotNull() @@ -194,8 +184,8 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with all - // the possible variants (e.g. deserializing from boolean). - 0 -> UpdateFileDetailsRequest(_json = json) + // the possible variants. + 0 -> UpdateFileRequest(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first // completely valid match, or simply the first match if none are completely valid. @@ -204,20 +194,19 @@ private constructor( } } - internal class Serializer : - BaseSerializer(UpdateFileDetailsRequest::class) { + internal class Serializer : BaseSerializer(UpdateFileRequest::class) { override fun serialize( - value: UpdateFileDetailsRequest, + value: UpdateFileRequest, generator: JsonGenerator, provider: SerializerProvider, ) { when { - value.updateFileDetails != null -> generator.writeObject(value.updateFileDetails) + value.details != null -> generator.writeObject(value.details) value.changePublicationStatus != null -> generator.writeObject(value.changePublicationStatus) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UpdateFileDetailsRequest") + else -> throw IllegalStateException("Invalid UpdateFileRequest") } } } @@ -2167,370 +2156,4 @@ private constructor( override fun toString() = "UpdateFileDetails{customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, extensions=$extensions, removeAiTags=$removeAiTags, tags=$tags, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" } - - class ChangePublicationStatus - private constructor( - private val publish: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("publish") @ExcludeMissing publish: JsonField = JsonMissing.of() - ) : this(publish, mutableMapOf()) - - /** - * Configure the publication status of a file and its versions. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun publish(): Optional = publish.getOptional("publish") - - /** - * Returns the raw JSON value of [publish]. - * - * Unlike [publish], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("publish") @ExcludeMissing fun _publish(): JsonField = publish - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ChangePublicationStatus]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ChangePublicationStatus]. */ - class Builder internal constructor() { - - private var publish: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(changePublicationStatus: ChangePublicationStatus) = apply { - publish = changePublicationStatus.publish - additionalProperties = changePublicationStatus.additionalProperties.toMutableMap() - } - - /** Configure the publication status of a file and its versions. */ - fun publish(publish: Publish) = publish(JsonField.of(publish)) - - /** - * Sets [Builder.publish] to an arbitrary JSON value. - * - * You should usually call [Builder.publish] with a well-typed [Publish] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun publish(publish: JsonField) = apply { this.publish = publish } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ChangePublicationStatus]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): ChangePublicationStatus = - ChangePublicationStatus(publish, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): ChangePublicationStatus = apply { - if (validated) { - return@apply - } - - publish().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (publish.asKnown().getOrNull()?.validity() ?: 0) - - /** Configure the publication status of a file and its versions. */ - class Publish - private constructor( - private val isPublished: JsonField, - private val includeFileVersions: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("isPublished") - @ExcludeMissing - isPublished: JsonField = JsonMissing.of(), - @JsonProperty("includeFileVersions") - @ExcludeMissing - includeFileVersions: JsonField = JsonMissing.of(), - ) : this(isPublished, includeFileVersions, mutableMapOf()) - - /** - * Set to `true` to publish the file. Set to `false` to unpublish the file. - * - * @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 isPublished(): Boolean = isPublished.getRequired("isPublished") - - /** - * Set to `true` to publish/unpublish all versions of the file. Set to `false` to - * publish/unpublish only the current version of the file. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun includeFileVersions(): Optional = - includeFileVersions.getOptional("includeFileVersions") - - /** - * Returns the raw JSON value of [isPublished]. - * - * Unlike [isPublished], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("isPublished") - @ExcludeMissing - fun _isPublished(): JsonField = isPublished - - /** - * Returns the raw JSON value of [includeFileVersions]. - * - * Unlike [includeFileVersions], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("includeFileVersions") - @ExcludeMissing - fun _includeFileVersions(): JsonField = includeFileVersions - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Publish]. - * - * The following fields are required: - * ```java - * .isPublished() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Publish]. */ - class Builder internal constructor() { - - private var isPublished: JsonField? = null - private var includeFileVersions: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(publish: Publish) = apply { - isPublished = publish.isPublished - includeFileVersions = publish.includeFileVersions - additionalProperties = publish.additionalProperties.toMutableMap() - } - - /** Set to `true` to publish the file. Set to `false` to unpublish the file. */ - fun isPublished(isPublished: Boolean) = isPublished(JsonField.of(isPublished)) - - /** - * Sets [Builder.isPublished] to an arbitrary JSON value. - * - * You should usually call [Builder.isPublished] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun isPublished(isPublished: JsonField) = apply { - this.isPublished = isPublished - } - - /** - * Set to `true` to publish/unpublish all versions of the file. Set to `false` to - * publish/unpublish only the current version of the file. - */ - fun includeFileVersions(includeFileVersions: Boolean) = - includeFileVersions(JsonField.of(includeFileVersions)) - - /** - * Sets [Builder.includeFileVersions] to an arbitrary JSON value. - * - * You should usually call [Builder.includeFileVersions] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun includeFileVersions(includeFileVersions: JsonField) = apply { - this.includeFileVersions = includeFileVersions - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Publish]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .isPublished() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Publish = - Publish( - checkRequired("isPublished", isPublished), - includeFileVersions, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Publish = apply { - if (validated) { - return@apply - } - - isPublished() - includeFileVersions() - 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 (isPublished.asKnown().isPresent) 1 else 0) + - (if (includeFileVersions.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Publish && - isPublished == other.isPublished && - includeFileVersions == other.includeFileVersions && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(isPublished, includeFileVersions, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Publish{isPublished=$isPublished, includeFileVersions=$includeFileVersions, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ChangePublicationStatus && - publish == other.publish && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(publish, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ChangePublicationStatus{publish=$publish, additionalProperties=$additionalProperties}" - } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt index f5db6fe3..d608c612 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt @@ -50,22 +50,20 @@ interface FileServiceAsync { * `tags`, `customCoordinates`, `customMetadata`, publication status, remove existing `AITags` * and apply extensions using this API. */ - fun update(fileId: String): CompletableFuture = - update(fileId, FileUpdateParams.none()) + fun update(fileId: String, params: FileUpdateParams): CompletableFuture = + update(fileId, params, RequestOptions.none()) /** @see update */ fun update( fileId: String, - params: FileUpdateParams = FileUpdateParams.none(), + params: FileUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture = update(params.toBuilder().fileId(fileId).build(), requestOptions) /** @see update */ - fun update( - fileId: String, - params: FileUpdateParams = FileUpdateParams.none(), - ): CompletableFuture = update(fileId, params, RequestOptions.none()) + fun update(params: FileUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) /** @see update */ fun update( @@ -73,17 +71,6 @@ interface FileServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see update */ - fun update(params: FileUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - fileId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - update(fileId, FileUpdateParams.none(), requestOptions) - /** * This API deletes the file and all its file versions permanently. * @@ -249,29 +236,19 @@ interface FileServiceAsync { * Returns a raw HTTP response for `patch /v1/files/{fileId}/details`, but is otherwise the * same as [FileServiceAsync.update]. */ - fun update(fileId: String): CompletableFuture> = - update(fileId, FileUpdateParams.none()) - - /** @see update */ - fun update( - fileId: String, - params: FileUpdateParams = FileUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - update(params.toBuilder().fileId(fileId).build(), requestOptions) - - /** @see update */ fun update( fileId: String, - params: FileUpdateParams = FileUpdateParams.none(), + params: FileUpdateParams, ): CompletableFuture> = update(fileId, params, RequestOptions.none()) /** @see update */ fun update( + fileId: String, params: FileUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> = + update(params.toBuilder().fileId(fileId).build(), requestOptions) /** @see update */ fun update( @@ -281,10 +258,9 @@ interface FileServiceAsync { /** @see update */ fun update( - fileId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - update(fileId, FileUpdateParams.none(), requestOptions) + params: FileUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> /** * Returns a raw HTTP response for `delete /v1/files/{fileId}`, but is otherwise the same as diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt index bafc4724..f50f873a 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt @@ -160,7 +160,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien .method(HttpMethod.PATCH) .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "files", params._pathParam(0), "details") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt index 8f4e8f80..c2b3b7fa 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt @@ -50,20 +50,18 @@ interface FileService { * `tags`, `customCoordinates`, `customMetadata`, publication status, remove existing `AITags` * and apply extensions using this API. */ - fun update(fileId: String): FileUpdateResponse = update(fileId, FileUpdateParams.none()) + fun update(fileId: String, params: FileUpdateParams): FileUpdateResponse = + update(fileId, params, RequestOptions.none()) /** @see update */ fun update( fileId: String, - params: FileUpdateParams = FileUpdateParams.none(), + params: FileUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): FileUpdateResponse = update(params.toBuilder().fileId(fileId).build(), requestOptions) /** @see update */ - fun update( - fileId: String, - params: FileUpdateParams = FileUpdateParams.none(), - ): FileUpdateResponse = update(fileId, params, RequestOptions.none()) + fun update(params: FileUpdateParams): FileUpdateResponse = update(params, RequestOptions.none()) /** @see update */ fun update( @@ -71,13 +69,6 @@ interface FileService { requestOptions: RequestOptions = RequestOptions.none(), ): FileUpdateResponse - /** @see update */ - fun update(params: FileUpdateParams): FileUpdateResponse = update(params, RequestOptions.none()) - - /** @see update */ - fun update(fileId: String, requestOptions: RequestOptions): FileUpdateResponse = - update(fileId, FileUpdateParams.none(), requestOptions) - /** * This API deletes the file and all its file versions permanently. * @@ -231,24 +222,22 @@ interface FileService { * same as [FileService.update]. */ @MustBeClosed - fun update(fileId: String): HttpResponseFor = - update(fileId, FileUpdateParams.none()) + fun update(fileId: String, params: FileUpdateParams): HttpResponseFor = + update(fileId, params, RequestOptions.none()) /** @see update */ @MustBeClosed fun update( fileId: String, - params: FileUpdateParams = FileUpdateParams.none(), + params: FileUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor = update(params.toBuilder().fileId(fileId).build(), requestOptions) /** @see update */ @MustBeClosed - fun update( - fileId: String, - params: FileUpdateParams = FileUpdateParams.none(), - ): HttpResponseFor = update(fileId, params, RequestOptions.none()) + fun update(params: FileUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) /** @see update */ @MustBeClosed @@ -257,19 +246,6 @@ interface FileService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see update */ - @MustBeClosed - fun update(params: FileUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - fileId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - update(fileId, FileUpdateParams.none(), requestOptions) - /** * Returns a raw HTTP response for `delete /v1/files/{fileId}`, but is otherwise the same as * [FileService.delete]. diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt index 6448f2b3..790f4b66 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt @@ -147,7 +147,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti .method(HttpMethod.PATCH) .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "files", params._pathParam(0), "details") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt index 8687562a..ca26f701 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt @@ -4,7 +4,6 @@ package com.imagekit.api.models.files import com.imagekit.api.core.JsonValue import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 -import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,13 +13,12 @@ internal class FileUpdateParamsTest { fun create() { FileUpdateParams.builder() .fileId("fileId") - .updateFileDetailsRequest( - UpdateFileDetailsRequest.UpdateFileDetails.builder() - .customCoordinates("10,10,100,100") + .updateFileRequest( + UpdateFileRequest.UpdateFileDetails.builder() + .customCoordinates("customCoordinates") .customMetadata( - UpdateFileDetailsRequest.UpdateFileDetails.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) + UpdateFileRequest.UpdateFileDetails.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") @@ -40,31 +38,20 @@ internal class FileUpdateParamsTest { ), UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() - .maxTags(10L) - .minConfidence(80L) + .maxTags(5L) + .minConfidence(95L) .name( UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() - .maxTags(10L) - .minConfidence(80L) - .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name - .AWS_AUTO_TAGGING - ) - .build() - ), UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) - .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) - .addTag("tag1") - .addTag("tag2") - .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") + .removeAiTagsOfStrings(listOf("string")) + .tags(listOf("car", "vehicle", "motorsports")) + .webhookUrl("https://example.com") .build() ) .build() @@ -72,7 +59,11 @@ internal class FileUpdateParamsTest { @Test fun pathParams() { - val params = FileUpdateParams.builder().fileId("fileId").build() + val params = + FileUpdateParams.builder() + .fileId("fileId") + .updateFileRequest(UpdateFileRequest.UpdateFileDetails.builder().build()) + .build() assertThat(params._pathParam(0)).isEqualTo("fileId") // out-of-bound path param @@ -84,13 +75,12 @@ internal class FileUpdateParamsTest { val params = FileUpdateParams.builder() .fileId("fileId") - .updateFileDetailsRequest( - UpdateFileDetailsRequest.UpdateFileDetails.builder() - .customCoordinates("10,10,100,100") + .updateFileRequest( + UpdateFileRequest.UpdateFileDetails.builder() + .customCoordinates("customCoordinates") .customMetadata( - UpdateFileDetailsRequest.UpdateFileDetails.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) + UpdateFileRequest.UpdateFileDetails.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") @@ -110,46 +100,34 @@ internal class FileUpdateParamsTest { ), UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() - .maxTags(10L) - .minConfidence(80L) + .maxTags(5L) + .minConfidence(95L) .name( UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() - .maxTags(10L) - .minConfidence(80L) - .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name - .AWS_AUTO_TAGGING - ) - .build() - ), UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) - .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) - .addTag("tag1") - .addTag("tag2") - .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") + .removeAiTagsOfStrings(listOf("string")) + .tags(listOf("car", "vehicle", "motorsports")) + .webhookUrl("https://example.com") .build() ) .build() - val body = params._body().getOrNull() + val body = params._body() assertThat(body) .isEqualTo( - UpdateFileDetailsRequest.ofUpdateFileDetails( - UpdateFileDetailsRequest.UpdateFileDetails.builder() - .customCoordinates("10,10,100,100") + UpdateFileRequest.ofDetails( + UpdateFileRequest.UpdateFileDetails.builder() + .customCoordinates("customCoordinates") .customMetadata( - UpdateFileDetailsRequest.UpdateFileDetails.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) + UpdateFileRequest.UpdateFileDetails.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") @@ -169,31 +147,20 @@ internal class FileUpdateParamsTest { ), UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() - .maxTags(10L) - .minConfidence(80L) + .maxTags(5L) + .minConfidence(95L) .name( UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() - .maxTags(10L) - .minConfidence(80L) - .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name - .AWS_AUTO_TAGGING - ) - .build() - ), UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) - .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) - .addTag("tag1") - .addTag("tag2") - .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") + .removeAiTagsOfStrings(listOf("string")) + .tags(listOf("car", "vehicle", "motorsports")) + .webhookUrl("https://example.com") .build() ) ) @@ -201,8 +168,17 @@ internal class FileUpdateParamsTest { @Test fun bodyWithoutOptionalFields() { - val params = FileUpdateParams.builder().fileId("fileId").build() + val params = + FileUpdateParams.builder() + .fileId("fileId") + .updateFileRequest(UpdateFileRequest.UpdateFileDetails.builder().build()) + .build() - val body = params._body().getOrNull() + val body = params._body() + + assertThat(body) + .isEqualTo( + UpdateFileRequest.ofDetails(UpdateFileRequest.UpdateFileDetails.builder().build()) + ) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileDetailsRequestTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt similarity index 56% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileDetailsRequestTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt index f11323f1..bc3363db 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileDetailsRequestTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt @@ -5,23 +5,19 @@ package com.imagekit.api.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper -import com.imagekit.api.errors.ImageKitInvalidDataException import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows -import org.junit.jupiter.params.ParameterizedTest -import org.junit.jupiter.params.provider.EnumSource -internal class UpdateFileDetailsRequestTest { +internal class UpdateFileRequestTest { @Test - fun ofUpdateFileDetails() { - val updateFileDetails = - UpdateFileDetailsRequest.UpdateFileDetails.builder() + fun ofDetails() { + val details = + UpdateFileRequest.UpdateFileDetails.builder() .customCoordinates("customCoordinates") .customMetadata( - UpdateFileDetailsRequest.UpdateFileDetails.CustomMetadata.builder() + UpdateFileRequest.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -59,22 +55,21 @@ internal class UpdateFileDetailsRequestTest { .webhookUrl("https://example.com") .build() - val updateFileDetailsRequest = - UpdateFileDetailsRequest.ofUpdateFileDetails(updateFileDetails) + val updateFileRequest = UpdateFileRequest.ofDetails(details) - assertThat(updateFileDetailsRequest.updateFileDetails()).contains(updateFileDetails) - assertThat(updateFileDetailsRequest.changePublicationStatus()).isEmpty + assertThat(updateFileRequest.details()).contains(details) + assertThat(updateFileRequest.changePublicationStatus()).isEmpty } @Test - fun ofUpdateFileDetailsRoundtrip() { + fun ofDetailsRoundtrip() { val jsonMapper = jsonMapper() - val updateFileDetailsRequest = - UpdateFileDetailsRequest.ofUpdateFileDetails( - UpdateFileDetailsRequest.UpdateFileDetails.builder() + val updateFileRequest = + UpdateFileRequest.ofDetails( + UpdateFileRequest.UpdateFileDetails.builder() .customCoordinates("customCoordinates") .customMetadata( - UpdateFileDetailsRequest.UpdateFileDetails.CustomMetadata.builder() + UpdateFileRequest.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -113,74 +108,37 @@ internal class UpdateFileDetailsRequestTest { .build() ) - val roundtrippedUpdateFileDetailsRequest = + val roundtrippedUpdateFileRequest = jsonMapper.readValue( - jsonMapper.writeValueAsString(updateFileDetailsRequest), - jacksonTypeRef(), + jsonMapper.writeValueAsString(updateFileRequest), + jacksonTypeRef(), ) - assertThat(roundtrippedUpdateFileDetailsRequest).isEqualTo(updateFileDetailsRequest) + assertThat(roundtrippedUpdateFileRequest).isEqualTo(updateFileRequest) } @Test fun ofChangePublicationStatus() { - val changePublicationStatus = - UpdateFileDetailsRequest.ChangePublicationStatus.builder() - .publish( - UpdateFileDetailsRequest.ChangePublicationStatus.Publish.builder() - .isPublished(true) - .includeFileVersions(true) - .build() - ) - .build() + val changePublicationStatus = JsonValue.from(mapOf()) - val updateFileDetailsRequest = - UpdateFileDetailsRequest.ofChangePublicationStatus(changePublicationStatus) + val updateFileRequest = UpdateFileRequest.ofChangePublicationStatus(changePublicationStatus) - assertThat(updateFileDetailsRequest.updateFileDetails()).isEmpty - assertThat(updateFileDetailsRequest.changePublicationStatus()) - .contains(changePublicationStatus) + assertThat(updateFileRequest.details()).isEmpty + assertThat(updateFileRequest.changePublicationStatus()).contains(changePublicationStatus) } @Test fun ofChangePublicationStatusRoundtrip() { val jsonMapper = jsonMapper() - val updateFileDetailsRequest = - UpdateFileDetailsRequest.ofChangePublicationStatus( - UpdateFileDetailsRequest.ChangePublicationStatus.builder() - .publish( - UpdateFileDetailsRequest.ChangePublicationStatus.Publish.builder() - .isPublished(true) - .includeFileVersions(true) - .build() - ) - .build() - ) + val updateFileRequest = + UpdateFileRequest.ofChangePublicationStatus(JsonValue.from(mapOf())) - val roundtrippedUpdateFileDetailsRequest = + val roundtrippedUpdateFileRequest = jsonMapper.readValue( - jsonMapper.writeValueAsString(updateFileDetailsRequest), - jacksonTypeRef(), + jsonMapper.writeValueAsString(updateFileRequest), + jacksonTypeRef(), ) - assertThat(roundtrippedUpdateFileDetailsRequest).isEqualTo(updateFileDetailsRequest) - } - - enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { - BOOLEAN(JsonValue.from(false)), - STRING(JsonValue.from("invalid")), - INTEGER(JsonValue.from(-1)), - FLOAT(JsonValue.from(3.14)), - ARRAY(JsonValue.from(listOf("invalid", "array"))), - } - - @ParameterizedTest - @EnumSource - fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { - val updateFileDetailsRequest = - jsonMapper().convertValue(testCase.value, jacksonTypeRef()) - - val e = assertThrows { updateFileDetailsRequest.validate() } - assertThat(e).hasMessageStartingWith("Unknown ") + assertThat(roundtrippedUpdateFileRequest).isEqualTo(updateFileRequest) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index 80dc9fc6..1242509c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -11,7 +11,7 @@ import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileRenameParams import com.imagekit.api.models.files.FileUpdateParams import com.imagekit.api.models.files.FileUploadParams -import com.imagekit.api.models.files.UpdateFileDetailsRequest +import com.imagekit.api.models.files.UpdateFileRequest import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -34,13 +34,12 @@ internal class FileServiceAsyncTest { fileServiceAsync.update( FileUpdateParams.builder() .fileId("fileId") - .updateFileDetailsRequest( - UpdateFileDetailsRequest.UpdateFileDetails.builder() - .customCoordinates("10,10,100,100") + .updateFileRequest( + UpdateFileRequest.UpdateFileDetails.builder() + .customCoordinates("customCoordinates") .customMetadata( - UpdateFileDetailsRequest.UpdateFileDetails.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) + UpdateFileRequest.UpdateFileDetails.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") @@ -61,8 +60,8 @@ internal class FileServiceAsyncTest { ), UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() - .maxTags(10L) - .minConfidence(80L) + .maxTags(5L) + .minConfidence(95L) .name( UnnamedSchemaWithArrayParent1.AutoTaggingExtension .Name @@ -70,24 +69,12 @@ internal class FileServiceAsyncTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() - .maxTags(10L) - .minConfidence(80L) - .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension - .Name - .AWS_AUTO_TAGGING - ) - .build() - ), UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) - .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) - .addTag("tag1") - .addTag("tag2") - .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") + .removeAiTagsOfStrings(listOf("string")) + .tags(listOf("car", "vehicle", "motorsports")) + .webhookUrl("https://example.com") .build() ) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index 67c03035..b5a8fed5 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -11,7 +11,7 @@ import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileRenameParams import com.imagekit.api.models.files.FileUpdateParams import com.imagekit.api.models.files.FileUploadParams -import com.imagekit.api.models.files.UpdateFileDetailsRequest +import com.imagekit.api.models.files.UpdateFileRequest import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -34,13 +34,12 @@ internal class FileServiceTest { fileService.update( FileUpdateParams.builder() .fileId("fileId") - .updateFileDetailsRequest( - UpdateFileDetailsRequest.UpdateFileDetails.builder() - .customCoordinates("10,10,100,100") + .updateFileRequest( + UpdateFileRequest.UpdateFileDetails.builder() + .customCoordinates("customCoordinates") .customMetadata( - UpdateFileDetailsRequest.UpdateFileDetails.CustomMetadata.builder() - .putAdditionalProperty("brand", JsonValue.from("bar")) - .putAdditionalProperty("color", JsonValue.from("bar")) + UpdateFileRequest.UpdateFileDetails.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") @@ -61,8 +60,8 @@ internal class FileServiceTest { ), UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() - .maxTags(10L) - .minConfidence(80L) + .maxTags(5L) + .minConfidence(95L) .name( UnnamedSchemaWithArrayParent1.AutoTaggingExtension .Name @@ -70,24 +69,12 @@ internal class FileServiceTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() - .maxTags(10L) - .minConfidence(80L) - .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension - .Name - .AWS_AUTO_TAGGING - ) - .build() - ), UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) - .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) - .addTag("tag1") - .addTag("tag2") - .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") + .removeAiTagsOfStrings(listOf("string")) + .tags(listOf("car", "vehicle", "motorsports")) + .webhookUrl("https://example.com") .build() ) .build() diff --git a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt index 00e09e47..39efc720 100644 --- a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt +++ b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt @@ -9,7 +9,7 @@ import com.imagekit.api.core.jsonMapper import com.imagekit.api.models.StreamingResolution import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 import com.imagekit.api.models.files.File -import com.imagekit.api.models.files.UpdateFileDetailsRequest +import com.imagekit.api.models.files.UpdateFileRequest import java.time.OffsetDateTime import kotlin.reflect.full.memberFunctions import kotlin.reflect.jvm.javaMethod @@ -108,14 +108,14 @@ internal class ProGuardCompatibilityTest { } @Test - fun updateFileDetailsRequestRoundtrip() { + fun updateFileRequestRoundtrip() { val jsonMapper = jsonMapper() - val updateFileDetailsRequest = - UpdateFileDetailsRequest.ofUpdateFileDetails( - UpdateFileDetailsRequest.UpdateFileDetails.builder() + val updateFileRequest = + UpdateFileRequest.ofDetails( + UpdateFileRequest.UpdateFileDetails.builder() .customCoordinates("customCoordinates") .customMetadata( - UpdateFileDetailsRequest.UpdateFileDetails.CustomMetadata.builder() + UpdateFileRequest.UpdateFileDetails.CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -148,19 +148,18 @@ internal class ProGuardCompatibilityTest { ) ) .removeAiTagsOfStrings(listOf("string")) - .addTag("tag1") - .addTag("tag2") + .tags(listOf("car", "vehicle", "motorsports")) .webhookUrl("https://example.com") .build() ) - val roundtrippedUpdateFileDetailsRequest = + val roundtrippedUpdateFileRequest = jsonMapper.readValue( - jsonMapper.writeValueAsString(updateFileDetailsRequest), - jacksonTypeRef(), + jsonMapper.writeValueAsString(updateFileRequest), + jacksonTypeRef(), ) - assertThat(roundtrippedUpdateFileDetailsRequest).isEqualTo(updateFileDetailsRequest) + assertThat(roundtrippedUpdateFileRequest).isEqualTo(updateFileRequest) } @Test From e01a75a9df1f6f49754095c9b61159236b5658b5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 19 Sep 2025 13:04:07 +0000 Subject: [PATCH 029/142] feat(api): manual updates --- .stats.yml | 4 +- .../api/models/files/FileUpdateParams.kt | 3 +- .../api/models/files/UpdateFileRequest.kt | 390 +++++++++++++++++- .../api/models/files/FileUpdateParamsTest.kt | 78 +++- .../api/models/files/UpdateFileRequestTest.kt | 43 +- .../services/async/FileServiceAsyncTest.kt | 27 +- .../api/services/blocking/FileServiceTest.kt | 27 +- .../api/proguard/ProGuardCompatibilityTest.kt | 26 +- 8 files changed, 541 insertions(+), 57 deletions(-) diff --git a/.stats.yml b/.stats.yml index bb4a090c..c9c84db9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-dd864816d7f4316ae89f57394da2fd1926166d4704db5a0bb5d23461d2d75e49.yml -openapi_spec_hash: 7f7c416563a15bbaea98804ecdc1a8f9 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml +openapi_spec_hash: 1d382866fce3284f26d341f112988d9d config_hash: 54c05a157f2cc730fac9e1df5dc3ca29 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt index da034a61..43ac63f9 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt @@ -2,7 +2,6 @@ package com.imagekit.api.models.files -import com.imagekit.api.core.JsonValue import com.imagekit.api.core.Params import com.imagekit.api.core.checkRequired import com.imagekit.api.core.http.Headers @@ -84,7 +83,7 @@ private constructor( * Alias for calling [updateFileRequest] with * `UpdateFileRequest.ofChangePublicationStatus(changePublicationStatus)`. */ - fun updateFileRequest(changePublicationStatus: JsonValue) = + fun updateFileRequest(changePublicationStatus: UpdateFileRequest.ChangePublicationStatus) = updateFileRequest(UpdateFileRequest.ofChangePublicationStatus(changePublicationStatus)) fun additionalHeaders(additionalHeaders: Headers) = apply { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt index a07b1ecb..477e67cb 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt @@ -38,13 +38,13 @@ import kotlin.jvm.optionals.getOrNull class UpdateFileRequest private constructor( private val details: UpdateFileDetails? = null, - private val changePublicationStatus: JsonValue? = null, + private val changePublicationStatus: ChangePublicationStatus? = null, private val _json: JsonValue? = null, ) { fun details(): Optional = Optional.ofNullable(details) - fun changePublicationStatus(): Optional = + fun changePublicationStatus(): Optional = Optional.ofNullable(changePublicationStatus) fun isDetails(): Boolean = details != null @@ -53,7 +53,7 @@ private constructor( fun asDetails(): UpdateFileDetails = details.getOrThrow("details") - fun asChangePublicationStatus(): JsonValue = + fun asChangePublicationStatus(): ChangePublicationStatus = changePublicationStatus.getOrThrow("changePublicationStatus") fun _json(): Optional = Optional.ofNullable(_json) @@ -79,7 +79,11 @@ private constructor( details.validate() } - override fun visitChangePublicationStatus(changePublicationStatus: JsonValue) {} + override fun visitChangePublicationStatus( + changePublicationStatus: ChangePublicationStatus + ) { + changePublicationStatus.validate() + } } ) validated = true @@ -104,7 +108,9 @@ private constructor( object : Visitor { override fun visitDetails(details: UpdateFileDetails) = details.validity() - override fun visitChangePublicationStatus(changePublicationStatus: JsonValue) = 1 + override fun visitChangePublicationStatus( + changePublicationStatus: ChangePublicationStatus + ) = changePublicationStatus.validity() override fun unknown(json: JsonValue?) = 0 } @@ -136,7 +142,7 @@ private constructor( @JvmStatic fun ofDetails(details: UpdateFileDetails) = UpdateFileRequest(details = details) @JvmStatic - fun ofChangePublicationStatus(changePublicationStatus: JsonValue) = + fun ofChangePublicationStatus(changePublicationStatus: ChangePublicationStatus) = UpdateFileRequest(changePublicationStatus = changePublicationStatus) } @@ -148,7 +154,7 @@ private constructor( fun visitDetails(details: UpdateFileDetails): T - fun visitChangePublicationStatus(changePublicationStatus: JsonValue): T + fun visitChangePublicationStatus(changePublicationStatus: ChangePublicationStatus): T /** * Maps an unknown variant of [UpdateFileRequest] to a value of type [T]. @@ -175,7 +181,7 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { UpdateFileRequest(details = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { + tryDeserialize(node, jacksonTypeRef())?.let { UpdateFileRequest(changePublicationStatus = it, _json = json) }, ) @@ -184,7 +190,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with all - // the possible variants. + // the possible variants (e.g. deserializing from boolean). 0 -> UpdateFileRequest(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -2156,4 +2162,370 @@ private constructor( override fun toString() = "UpdateFileDetails{customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, extensions=$extensions, removeAiTags=$removeAiTags, tags=$tags, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" } + + class ChangePublicationStatus + private constructor( + private val publish: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("publish") @ExcludeMissing publish: JsonField = JsonMissing.of() + ) : this(publish, mutableMapOf()) + + /** + * Configure the publication status of a file and its versions. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun publish(): Optional = publish.getOptional("publish") + + /** + * Returns the raw JSON value of [publish]. + * + * Unlike [publish], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("publish") @ExcludeMissing fun _publish(): JsonField = publish + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChangePublicationStatus]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChangePublicationStatus]. */ + class Builder internal constructor() { + + private var publish: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(changePublicationStatus: ChangePublicationStatus) = apply { + publish = changePublicationStatus.publish + additionalProperties = changePublicationStatus.additionalProperties.toMutableMap() + } + + /** Configure the publication status of a file and its versions. */ + fun publish(publish: Publish) = publish(JsonField.of(publish)) + + /** + * Sets [Builder.publish] to an arbitrary JSON value. + * + * You should usually call [Builder.publish] with a well-typed [Publish] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun publish(publish: JsonField) = apply { this.publish = publish } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChangePublicationStatus]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ChangePublicationStatus = + ChangePublicationStatus(publish, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ChangePublicationStatus = apply { + if (validated) { + return@apply + } + + publish().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (publish.asKnown().getOrNull()?.validity() ?: 0) + + /** Configure the publication status of a file and its versions. */ + class Publish + private constructor( + private val isPublished: JsonField, + private val includeFileVersions: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("isPublished") + @ExcludeMissing + isPublished: JsonField = JsonMissing.of(), + @JsonProperty("includeFileVersions") + @ExcludeMissing + includeFileVersions: JsonField = JsonMissing.of(), + ) : this(isPublished, includeFileVersions, mutableMapOf()) + + /** + * Set to `true` to publish the file. Set to `false` to unpublish the file. + * + * @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 isPublished(): Boolean = isPublished.getRequired("isPublished") + + /** + * Set to `true` to publish/unpublish all versions of the file. Set to `false` to + * publish/unpublish only the current version of the file. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun includeFileVersions(): Optional = + includeFileVersions.getOptional("includeFileVersions") + + /** + * Returns the raw JSON value of [isPublished]. + * + * Unlike [isPublished], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("isPublished") + @ExcludeMissing + fun _isPublished(): JsonField = isPublished + + /** + * Returns the raw JSON value of [includeFileVersions]. + * + * Unlike [includeFileVersions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("includeFileVersions") + @ExcludeMissing + fun _includeFileVersions(): JsonField = includeFileVersions + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Publish]. + * + * The following fields are required: + * ```java + * .isPublished() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Publish]. */ + class Builder internal constructor() { + + private var isPublished: JsonField? = null + private var includeFileVersions: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(publish: Publish) = apply { + isPublished = publish.isPublished + includeFileVersions = publish.includeFileVersions + additionalProperties = publish.additionalProperties.toMutableMap() + } + + /** Set to `true` to publish the file. Set to `false` to unpublish the file. */ + fun isPublished(isPublished: Boolean) = isPublished(JsonField.of(isPublished)) + + /** + * Sets [Builder.isPublished] to an arbitrary JSON value. + * + * You should usually call [Builder.isPublished] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun isPublished(isPublished: JsonField) = apply { + this.isPublished = isPublished + } + + /** + * Set to `true` to publish/unpublish all versions of the file. Set to `false` to + * publish/unpublish only the current version of the file. + */ + fun includeFileVersions(includeFileVersions: Boolean) = + includeFileVersions(JsonField.of(includeFileVersions)) + + /** + * Sets [Builder.includeFileVersions] to an arbitrary JSON value. + * + * You should usually call [Builder.includeFileVersions] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun includeFileVersions(includeFileVersions: JsonField) = apply { + this.includeFileVersions = includeFileVersions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Publish]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .isPublished() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Publish = + Publish( + checkRequired("isPublished", isPublished), + includeFileVersions, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Publish = apply { + if (validated) { + return@apply + } + + isPublished() + includeFileVersions() + 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 (isPublished.asKnown().isPresent) 1 else 0) + + (if (includeFileVersions.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Publish && + isPublished == other.isPublished && + includeFileVersions == other.includeFileVersions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(isPublished, includeFileVersions, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Publish{isPublished=$isPublished, includeFileVersions=$includeFileVersions, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChangePublicationStatus && + publish == other.publish && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(publish, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChangePublicationStatus{publish=$publish, additionalProperties=$additionalProperties}" + } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt index ca26f701..3ca3df31 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt @@ -15,10 +15,11 @@ internal class FileUpdateParamsTest { .fileId("fileId") .updateFileRequest( UpdateFileRequest.UpdateFileDetails.builder() - .customCoordinates("customCoordinates") + .customCoordinates("10,10,100,100") .customMetadata( UpdateFileRequest.UpdateFileDetails.CustomMetadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) .description("description") @@ -38,20 +39,31 @@ internal class FileUpdateParamsTest { ), UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) + .maxTags(10L) + .minConfidence(80L) .name( UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + .maxTags(10L) + .minConfidence(80L) + .name( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + .AWS_AUTO_TAGGING + ) + .build() + ), UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) - .removeAiTagsOfStrings(listOf("string")) - .tags(listOf("car", "vehicle", "motorsports")) - .webhookUrl("https://example.com") + .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) + .addTag("tag1") + .addTag("tag2") + .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") .build() ) .build() @@ -77,10 +89,11 @@ internal class FileUpdateParamsTest { .fileId("fileId") .updateFileRequest( UpdateFileRequest.UpdateFileDetails.builder() - .customCoordinates("customCoordinates") + .customCoordinates("10,10,100,100") .customMetadata( UpdateFileRequest.UpdateFileDetails.CustomMetadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) .description("description") @@ -100,20 +113,31 @@ internal class FileUpdateParamsTest { ), UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) + .maxTags(10L) + .minConfidence(80L) .name( UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + .maxTags(10L) + .minConfidence(80L) + .name( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + .AWS_AUTO_TAGGING + ) + .build() + ), UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) - .removeAiTagsOfStrings(listOf("string")) - .tags(listOf("car", "vehicle", "motorsports")) - .webhookUrl("https://example.com") + .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) + .addTag("tag1") + .addTag("tag2") + .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") .build() ) .build() @@ -124,10 +148,11 @@ internal class FileUpdateParamsTest { .isEqualTo( UpdateFileRequest.ofDetails( UpdateFileRequest.UpdateFileDetails.builder() - .customCoordinates("customCoordinates") + .customCoordinates("10,10,100,100") .customMetadata( UpdateFileRequest.UpdateFileDetails.CustomMetadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) .description("description") @@ -147,20 +172,31 @@ internal class FileUpdateParamsTest { ), UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) + .maxTags(10L) + .minConfidence(80L) .name( UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + .maxTags(10L) + .minConfidence(80L) + .name( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + .AWS_AUTO_TAGGING + ) + .build() + ), UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) - .removeAiTagsOfStrings(listOf("string")) - .tags(listOf("car", "vehicle", "motorsports")) - .webhookUrl("https://example.com") + .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) + .addTag("tag1") + .addTag("tag2") + .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") .build() ) ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt index bc3363db..2caf9099 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt @@ -5,9 +5,13 @@ package com.imagekit.api.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper +import com.imagekit.api.errors.ImageKitInvalidDataException import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource internal class UpdateFileRequestTest { @@ -119,7 +123,15 @@ internal class UpdateFileRequestTest { @Test fun ofChangePublicationStatus() { - val changePublicationStatus = JsonValue.from(mapOf()) + val changePublicationStatus = + UpdateFileRequest.ChangePublicationStatus.builder() + .publish( + UpdateFileRequest.ChangePublicationStatus.Publish.builder() + .isPublished(true) + .includeFileVersions(true) + .build() + ) + .build() val updateFileRequest = UpdateFileRequest.ofChangePublicationStatus(changePublicationStatus) @@ -131,7 +143,16 @@ internal class UpdateFileRequestTest { fun ofChangePublicationStatusRoundtrip() { val jsonMapper = jsonMapper() val updateFileRequest = - UpdateFileRequest.ofChangePublicationStatus(JsonValue.from(mapOf())) + UpdateFileRequest.ofChangePublicationStatus( + UpdateFileRequest.ChangePublicationStatus.builder() + .publish( + UpdateFileRequest.ChangePublicationStatus.Publish.builder() + .isPublished(true) + .includeFileVersions(true) + .build() + ) + .build() + ) val roundtrippedUpdateFileRequest = jsonMapper.readValue( @@ -141,4 +162,22 @@ internal class UpdateFileRequestTest { assertThat(roundtrippedUpdateFileRequest).isEqualTo(updateFileRequest) } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val updateFileRequest = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { updateFileRequest.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index 1242509c..68e39d7a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -36,10 +36,11 @@ internal class FileServiceAsyncTest { .fileId("fileId") .updateFileRequest( UpdateFileRequest.UpdateFileDetails.builder() - .customCoordinates("customCoordinates") + .customCoordinates("10,10,100,100") .customMetadata( UpdateFileRequest.UpdateFileDetails.CustomMetadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) .description("description") @@ -60,8 +61,8 @@ internal class FileServiceAsyncTest { ), UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) + .maxTags(10L) + .minConfidence(80L) .name( UnnamedSchemaWithArrayParent1.AutoTaggingExtension .Name @@ -69,12 +70,24 @@ internal class FileServiceAsyncTest { ) .build() ), + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + .maxTags(10L) + .minConfidence(80L) + .name( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) + .build() + ), UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) - .removeAiTagsOfStrings(listOf("string")) - .tags(listOf("car", "vehicle", "motorsports")) - .webhookUrl("https://example.com") + .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) + .addTag("tag1") + .addTag("tag2") + .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") .build() ) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index b5a8fed5..fa5f9f08 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -36,10 +36,11 @@ internal class FileServiceTest { .fileId("fileId") .updateFileRequest( UpdateFileRequest.UpdateFileDetails.builder() - .customCoordinates("customCoordinates") + .customCoordinates("10,10,100,100") .customMetadata( UpdateFileRequest.UpdateFileDetails.CustomMetadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) .description("description") @@ -60,8 +61,8 @@ internal class FileServiceTest { ), UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) + .maxTags(10L) + .minConfidence(80L) .name( UnnamedSchemaWithArrayParent1.AutoTaggingExtension .Name @@ -69,12 +70,24 @@ internal class FileServiceTest { ) .build() ), + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + .maxTags(10L) + .minConfidence(80L) + .name( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension + .Name + .AWS_AUTO_TAGGING + ) + .build() + ), UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) - .removeAiTagsOfStrings(listOf("string")) - .tags(listOf("car", "vehicle", "motorsports")) - .webhookUrl("https://example.com") + .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) + .addTag("tag1") + .addTag("tag2") + .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") .build() ) .build() diff --git a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt index 39efc720..4ee1e3e0 100644 --- a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt +++ b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt @@ -113,10 +113,11 @@ internal class ProGuardCompatibilityTest { val updateFileRequest = UpdateFileRequest.ofDetails( UpdateFileRequest.UpdateFileDetails.builder() - .customCoordinates("customCoordinates") + .customCoordinates("10,10,100,100") .customMetadata( UpdateFileRequest.UpdateFileDetails.CustomMetadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("brand", JsonValue.from("bar")) + .putAdditionalProperty("color", JsonValue.from("bar")) .build() ) .description("description") @@ -136,20 +137,31 @@ internal class ProGuardCompatibilityTest { ), UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() - .maxTags(5L) - .minConfidence(95L) + .maxTags(10L) + .minConfidence(80L) .name( UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), + UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + .maxTags(10L) + .minConfidence(80L) + .name( + UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + .AWS_AUTO_TAGGING + ) + .build() + ), UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), ) ) - .removeAiTagsOfStrings(listOf("string")) - .tags(listOf("car", "vehicle", "motorsports")) - .webhookUrl("https://example.com") + .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) + .addTag("tag1") + .addTag("tag2") + .webhookUrl("https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a") .build() ) From 09a68d6fb594866ed049c11cba27d797ef553908 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 19 Sep 2025 13:40:08 +0000 Subject: [PATCH 030/142] feat(api): manual updates --- .stats.yml | 2 +- README.md | 6 ++-- .../api/client/okhttp/ImageKitOkHttpClient.kt | 7 ++--- .../okhttp/ImageKitOkHttpClientAsync.kt | 7 ++--- .../com/imagekit/api/core/ClientOptions.kt | 28 +++++++++---------- .../imagekit/api/core/ClientOptionsTest.kt | 2 +- .../api/services/ErrorHandlingTest.kt | 2 +- .../api/services/ServiceParamsTest.kt | 2 +- .../services/async/AssetServiceAsyncTest.kt | 2 +- .../CustomMetadataFieldServiceAsyncTest.kt | 8 +++--- .../services/async/FileServiceAsyncTest.kt | 14 +++++----- .../services/async/FolderServiceAsyncTest.kt | 10 +++---- .../async/accounts/OriginServiceAsyncTest.kt | 10 +++---- .../accounts/UrlEndpointServiceAsyncTest.kt | 10 +++---- .../async/accounts/UsageServiceAsyncTest.kt | 2 +- .../async/beta/v2/FileServiceAsyncTest.kt | 2 +- .../cache/InvalidationServiceAsyncTest.kt | 4 +-- .../async/files/BulkServiceAsyncTest.kt | 8 +++--- .../async/files/MetadataServiceAsyncTest.kt | 4 +-- .../async/files/VersionServiceAsyncTest.kt | 8 +++--- .../async/folders/JobServiceAsyncTest.kt | 2 +- .../api/services/blocking/AssetServiceTest.kt | 2 +- .../CustomMetadataFieldServiceTest.kt | 8 +++--- .../api/services/blocking/FileServiceTest.kt | 14 +++++----- .../services/blocking/FolderServiceTest.kt | 10 +++---- .../blocking/accounts/OriginServiceTest.kt | 10 +++---- .../accounts/UrlEndpointServiceTest.kt | 10 +++---- .../blocking/accounts/UsageServiceTest.kt | 2 +- .../blocking/beta/v2/FileServiceTest.kt | 2 +- .../blocking/cache/InvalidationServiceTest.kt | 4 +-- .../blocking/files/BulkServiceTest.kt | 8 +++--- .../blocking/files/MetadataServiceTest.kt | 4 +-- .../blocking/files/VersionServiceTest.kt | 8 +++--- .../blocking/folders/JobServiceTest.kt | 2 +- .../api/proguard/ProGuardCompatibilityTest.kt | 2 +- 35 files changed, 109 insertions(+), 117 deletions(-) diff --git a/.stats.yml b/.stats.yml index c9c84db9..00fd95da 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml openapi_spec_hash: 1d382866fce3284f26d341f112988d9d -config_hash: 54c05a157f2cc730fac9e1df5dc3ca29 +config_hash: 29a2351fe2be89392b15719be8bc964f diff --git a/README.md b/README.md index 4e268347..27e9ee4f 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; ImageKitClient client = ImageKitOkHttpClient.builder() - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build(); ``` @@ -98,7 +98,7 @@ ImageKitClient client = ImageKitOkHttpClient.builder() // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables .fromEnv() - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .build(); ``` @@ -106,7 +106,7 @@ See this table for the available options: | Setter | System property | Environment variable | Required | Default value | | --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- | -| `privateApiKey` | `imagekit.imagekitPrivateApiKey` | `IMAGEKIT_PRIVATE_API_KEY` | true | - | +| `privateKey` | `imagekit.imagekitPrivateApiKey` | `IMAGEKIT_PRIVATE_API_KEY` | true | - | | `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` | | `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - | | `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` | diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt index 2da16e75..4d354fbb 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt @@ -187,13 +187,10 @@ class ImageKitOkHttpClient private constructor() { * Your ImageKit private API key (it starts with `private_`). You can view and manage API * keys in the [dashboard](https://imagekit.io/dashboard/developer/api-keys). */ - fun privateApiKey(privateApiKey: String) = apply { - clientOptions.privateApiKey(privateApiKey) - } + fun privateKey(privateKey: String) = apply { clientOptions.privateKey(privateKey) } /** - * ImageKit Basic Auth only uses the username field and ignores the password. This field is - * unused. + * ImageKit Basic Auth only uses the `private_key` as username and ignores the password. * * Defaults to `"do_not_set"`. */ diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt index d998ad81..f865a58c 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt @@ -187,13 +187,10 @@ class ImageKitOkHttpClientAsync private constructor() { * Your ImageKit private API key (it starts with `private_`). You can view and manage API * keys in the [dashboard](https://imagekit.io/dashboard/developer/api-keys). */ - fun privateApiKey(privateApiKey: String) = apply { - clientOptions.privateApiKey(privateApiKey) - } + fun privateKey(privateKey: String) = apply { clientOptions.privateKey(privateKey) } /** - * ImageKit Basic Auth only uses the username field and ignores the password. This field is - * unused. + * ImageKit Basic Auth only uses the `private_key` as username and ignores the password. * * Defaults to `"do_not_set"`. */ diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt index 7b379cd1..61f3dc40 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt @@ -88,7 +88,7 @@ private constructor( * Your ImageKit private API key (it starts with `private_`). You can view and manage API keys * in the [dashboard](https://imagekit.io/dashboard/developer/api-keys). */ - @get:JvmName("privateApiKey") val privateApiKey: String, + @get:JvmName("privateKey") val privateKey: String, private val password: String?, private val webhookSecret: String?, ) { @@ -109,8 +109,7 @@ private constructor( fun baseUrlOverridden(): Boolean = baseUrl != null /** - * ImageKit Basic Auth only uses the username field and ignores the password. This field is - * unused. + * ImageKit Basic Auth only uses the `private_key` as username and ignores the password. * * Defaults to `"do_not_set"`. */ @@ -137,7 +136,7 @@ private constructor( * The following fields are required: * ```java * .httpClient() - * .privateApiKey() + * .privateKey() * ``` */ @JvmStatic fun builder() = Builder() @@ -163,7 +162,7 @@ private constructor( private var responseValidation: Boolean = false private var timeout: Timeout = Timeout.default() private var maxRetries: Int = 2 - private var privateApiKey: String? = null + private var privateKey: String? = null private var password: String? = "do_not_set" private var webhookSecret: String? = null @@ -179,7 +178,7 @@ private constructor( responseValidation = clientOptions.responseValidation timeout = clientOptions.timeout maxRetries = clientOptions.maxRetries - privateApiKey = clientOptions.privateApiKey + privateKey = clientOptions.privateKey password = clientOptions.password webhookSecret = clientOptions.webhookSecret } @@ -281,11 +280,10 @@ private constructor( * Your ImageKit private API key (it starts with `private_`). You can view and manage API * keys in the [dashboard](https://imagekit.io/dashboard/developer/api-keys). */ - fun privateApiKey(privateApiKey: String) = apply { this.privateApiKey = privateApiKey } + fun privateKey(privateKey: String) = apply { this.privateKey = privateKey } /** - * ImageKit Basic Auth only uses the username field and ignores the password. This field is - * unused. + * ImageKit Basic Auth only uses the `private_key` as username and ignores the password. * * Defaults to `"do_not_set"`. */ @@ -396,7 +394,7 @@ private constructor( * * |Setter |System property |Environment variable |Required|Default value | * |---------------|--------------------------------------|--------------------------------|--------|---------------------------| - * |`privateApiKey`|`imagekit.imagekitPrivateApiKey` |`IMAGEKIT_PRIVATE_API_KEY` |true |- | + * |`privateKey` |`imagekit.imagekitPrivateApiKey` |`IMAGEKIT_PRIVATE_API_KEY` |true |- | * |`password` |`imagekit.optionalImagekitIgnoresThis`|`OPTIONAL_IMAGEKIT_IGNORES_THIS`|false |`"do_not_set"` | * |`webhookSecret`|`imagekit.imagekitWebhookSecret` |`IMAGEKIT_WEBHOOK_SECRET` |false |- | * |`baseUrl` |`imagekit.baseUrl` |`IMAGE_KIT_BASE_URL` |true |`"https://api.imagekit.io"`| @@ -409,7 +407,7 @@ private constructor( } (System.getProperty("imagekit.imagekitPrivateApiKey") ?: System.getenv("IMAGEKIT_PRIVATE_API_KEY")) - ?.let { privateApiKey(it) } + ?.let { privateKey(it) } (System.getProperty("imagekit.optionalImagekitIgnoresThis") ?: System.getenv("OPTIONAL_IMAGEKIT_IGNORES_THIS")) ?.let { password(it) } @@ -426,14 +424,14 @@ private constructor( * The following fields are required: * ```java * .httpClient() - * .privateApiKey() + * .privateKey() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): ClientOptions { val httpClient = checkRequired("httpClient", httpClient) - val privateApiKey = checkRequired("privateApiKey", privateApiKey) + val privateKey = checkRequired("privateKey", privateKey) val headers = Headers.builder() val queryParams = QueryParams.builder() @@ -444,7 +442,7 @@ private constructor( headers.put("X-Stainless-Package-Version", getPackageVersion()) headers.put("X-Stainless-Runtime", "JRE") headers.put("X-Stainless-Runtime-Version", getJavaVersion()) - privateApiKey.let { username -> + privateKey.let { username -> password?.let { password -> if (!username.isEmpty() && !password.isEmpty()) { headers.put( @@ -473,7 +471,7 @@ private constructor( responseValidation, timeout, maxRetries, - privateApiKey, + privateKey, password, webhookSecret, ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt index 4ce82f36..3d1af46c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt @@ -21,7 +21,7 @@ internal class ClientOptionsTest { var clientOptions = ClientOptions.builder() .httpClient(httpClient) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() verify(httpClient, never()).close() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt index 3989b7eb..4978c043 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt @@ -55,7 +55,7 @@ internal class ErrorHandlingTest { client = ImageKitOkHttpClient.builder() .baseUrl(wmRuntimeInfo.httpBaseUrl) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt index 9c978aeb..59e7191c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt @@ -33,7 +33,7 @@ internal class ServiceParamsTest { client = ImageKitOkHttpClient.builder() .baseUrl(wmRuntimeInfo.httpBaseUrl) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt index 322f6ced..7dbc2604 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt @@ -18,7 +18,7 @@ internal class AssetServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val assetServiceAsync = client.assets() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt index bb8af989..1d361052 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt @@ -20,7 +20,7 @@ internal class CustomMetadataFieldServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val customMetadataFieldServiceAsync = client.customMetadataFields() @@ -74,7 +74,7 @@ internal class CustomMetadataFieldServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val customMetadataFieldServiceAsync = client.customMetadataFields() @@ -127,7 +127,7 @@ internal class CustomMetadataFieldServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val customMetadataFieldServiceAsync = client.customMetadataFields() @@ -147,7 +147,7 @@ internal class CustomMetadataFieldServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val customMetadataFieldServiceAsync = client.customMetadataFields() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index 68e39d7a..f6a815c2 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -25,7 +25,7 @@ internal class FileServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val fileServiceAsync = client.files() @@ -103,7 +103,7 @@ internal class FileServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val fileServiceAsync = client.files() @@ -119,7 +119,7 @@ internal class FileServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val fileServiceAsync = client.files() @@ -143,7 +143,7 @@ internal class FileServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val fileServiceAsync = client.files() @@ -160,7 +160,7 @@ internal class FileServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val fileServiceAsync = client.files() @@ -183,7 +183,7 @@ internal class FileServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val fileServiceAsync = client.files() @@ -207,7 +207,7 @@ internal class FileServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val fileServiceAsync = client.files() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt index 175c051b..3d3bd3de 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt @@ -22,7 +22,7 @@ internal class FolderServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val folderServiceAsync = client.folders() @@ -45,7 +45,7 @@ internal class FolderServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val folderServiceAsync = client.folders() @@ -65,7 +65,7 @@ internal class FolderServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val folderServiceAsync = client.folders() @@ -89,7 +89,7 @@ internal class FolderServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val folderServiceAsync = client.folders() @@ -112,7 +112,7 @@ internal class FolderServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val folderServiceAsync = client.folders() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt index e2844773..0175764c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt @@ -19,7 +19,7 @@ internal class OriginServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val originServiceAsync = client.accounts().origins() @@ -49,7 +49,7 @@ internal class OriginServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val originServiceAsync = client.accounts().origins() @@ -82,7 +82,7 @@ internal class OriginServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val originServiceAsync = client.accounts().origins() @@ -99,7 +99,7 @@ internal class OriginServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val originServiceAsync = client.accounts().origins() @@ -115,7 +115,7 @@ internal class OriginServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val originServiceAsync = client.accounts().origins() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt index 312d19f5..ebe07b02 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt @@ -19,7 +19,7 @@ internal class UrlEndpointServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val urlEndpointServiceAsync = client.accounts().urlEndpoints() @@ -48,7 +48,7 @@ internal class UrlEndpointServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val urlEndpointServiceAsync = client.accounts().urlEndpoints() @@ -82,7 +82,7 @@ internal class UrlEndpointServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val urlEndpointServiceAsync = client.accounts().urlEndpoints() @@ -99,7 +99,7 @@ internal class UrlEndpointServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val urlEndpointServiceAsync = client.accounts().urlEndpoints() @@ -115,7 +115,7 @@ internal class UrlEndpointServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val urlEndpointServiceAsync = client.accounts().urlEndpoints() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt index 08dd5a9e..5de37787 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt @@ -19,7 +19,7 @@ internal class UsageServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val usageServiceAsync = client.accounts().usage() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt index 868c4122..6973ea50 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt @@ -20,7 +20,7 @@ internal class FileServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val fileServiceAsync = client.beta().v2().files() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt index 547c8cab..9ad34dff 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt @@ -18,7 +18,7 @@ internal class InvalidationServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val invalidationServiceAsync = client.cache().invalidation() @@ -40,7 +40,7 @@ internal class InvalidationServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val invalidationServiceAsync = client.cache().invalidation() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt index fd95a1e5..e5d5b31d 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt @@ -21,7 +21,7 @@ internal class BulkServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val bulkServiceAsync = client.files().bulk() @@ -44,7 +44,7 @@ internal class BulkServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val bulkServiceAsync = client.files().bulk() @@ -68,7 +68,7 @@ internal class BulkServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val bulkServiceAsync = client.files().bulk() @@ -92,7 +92,7 @@ internal class BulkServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val bulkServiceAsync = client.files().bulk() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt index 827832b6..27b2dbd5 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt @@ -18,7 +18,7 @@ internal class MetadataServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val metadataServiceAsync = client.files().metadata() @@ -35,7 +35,7 @@ internal class MetadataServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val metadataServiceAsync = client.files().metadata() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt index afbefeb0..133c1ea0 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt @@ -20,7 +20,7 @@ internal class VersionServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val versionServiceAsync = client.files().versions() @@ -37,7 +37,7 @@ internal class VersionServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val versionServiceAsync = client.files().versions() @@ -57,7 +57,7 @@ internal class VersionServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val versionServiceAsync = client.files().versions() @@ -77,7 +77,7 @@ internal class VersionServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val versionServiceAsync = client.files().versions() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt index db5b2d61..1297b395 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt @@ -17,7 +17,7 @@ internal class JobServiceAsyncTest { val client = ImageKitOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val jobServiceAsync = client.folders().job() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt index 50fc335a..41c8d85e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt @@ -18,7 +18,7 @@ internal class AssetServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val assetService = client.assets() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt index be0a158b..5a39a789 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt @@ -20,7 +20,7 @@ internal class CustomMetadataFieldServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val customMetadataFieldService = client.customMetadataFields() @@ -73,7 +73,7 @@ internal class CustomMetadataFieldServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val customMetadataFieldService = client.customMetadataFields() @@ -125,7 +125,7 @@ internal class CustomMetadataFieldServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val customMetadataFieldService = client.customMetadataFields() @@ -144,7 +144,7 @@ internal class CustomMetadataFieldServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val customMetadataFieldService = client.customMetadataFields() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index fa5f9f08..d3e8e8c0 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -25,7 +25,7 @@ internal class FileServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val fileService = client.files() @@ -102,7 +102,7 @@ internal class FileServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val fileService = client.files() @@ -116,7 +116,7 @@ internal class FileServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val fileService = client.files() @@ -139,7 +139,7 @@ internal class FileServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val fileService = client.files() @@ -155,7 +155,7 @@ internal class FileServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val fileService = client.files() @@ -177,7 +177,7 @@ internal class FileServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val fileService = client.files() @@ -200,7 +200,7 @@ internal class FileServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val fileService = client.files() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt index 13026e90..0acddac1 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt @@ -22,7 +22,7 @@ internal class FolderServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val folderService = client.folders() @@ -44,7 +44,7 @@ internal class FolderServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val folderService = client.folders() @@ -63,7 +63,7 @@ internal class FolderServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val folderService = client.folders() @@ -86,7 +86,7 @@ internal class FolderServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val folderService = client.folders() @@ -108,7 +108,7 @@ internal class FolderServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val folderService = client.folders() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt index 9888e845..14b8b7a4 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt @@ -19,7 +19,7 @@ internal class OriginServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val originService = client.accounts().origins() @@ -48,7 +48,7 @@ internal class OriginServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val originService = client.accounts().origins() @@ -80,7 +80,7 @@ internal class OriginServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val originService = client.accounts().origins() @@ -96,7 +96,7 @@ internal class OriginServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val originService = client.accounts().origins() @@ -110,7 +110,7 @@ internal class OriginServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val originService = client.accounts().origins() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt index f88b7478..e9773bf0 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt @@ -19,7 +19,7 @@ internal class UrlEndpointServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val urlEndpointService = client.accounts().urlEndpoints() @@ -47,7 +47,7 @@ internal class UrlEndpointServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val urlEndpointService = client.accounts().urlEndpoints() @@ -80,7 +80,7 @@ internal class UrlEndpointServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val urlEndpointService = client.accounts().urlEndpoints() @@ -96,7 +96,7 @@ internal class UrlEndpointServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val urlEndpointService = client.accounts().urlEndpoints() @@ -110,7 +110,7 @@ internal class UrlEndpointServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val urlEndpointService = client.accounts().urlEndpoints() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt index b579bdf8..3899e0d7 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt @@ -19,7 +19,7 @@ internal class UsageServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val usageService = client.accounts().usage() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt index 31f1bce6..b0050868 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt @@ -20,7 +20,7 @@ internal class FileServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val fileService = client.beta().v2().files() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt index 819af016..b1148d83 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt @@ -18,7 +18,7 @@ internal class InvalidationServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val invalidationService = client.cache().invalidation() @@ -39,7 +39,7 @@ internal class InvalidationServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val invalidationService = client.cache().invalidation() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt index 55230523..90b69e4a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt @@ -21,7 +21,7 @@ internal class BulkServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val bulkService = client.files().bulk() @@ -43,7 +43,7 @@ internal class BulkServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val bulkService = client.files().bulk() @@ -66,7 +66,7 @@ internal class BulkServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val bulkService = client.files().bulk() @@ -89,7 +89,7 @@ internal class BulkServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val bulkService = client.files().bulk() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt index fcdef81c..d0ca7732 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt @@ -18,7 +18,7 @@ internal class MetadataServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val metadataService = client.files().metadata() @@ -34,7 +34,7 @@ internal class MetadataServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val metadataService = client.files().metadata() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt index a8d311ca..fce39206 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt @@ -20,7 +20,7 @@ internal class VersionServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val versionService = client.files().versions() @@ -36,7 +36,7 @@ internal class VersionServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val versionService = client.files().versions() @@ -55,7 +55,7 @@ internal class VersionServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val versionService = client.files().versions() @@ -74,7 +74,7 @@ internal class VersionServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val versionService = client.files().versions() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt index 63455dd0..4c515532 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt @@ -17,7 +17,7 @@ internal class JobServiceTest { val client = ImageKitOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() val jobService = client.folders().job() diff --git a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt index 4ee1e3e0..4ad5e27d 100644 --- a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt +++ b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt @@ -51,7 +51,7 @@ internal class ProGuardCompatibilityTest { fun client() { val client = ImageKitOkHttpClient.builder() - .privateApiKey("My Private API Key") + .privateKey("My Private Key") .password("My Password") .build() From e474ef2004c784def6eba33158337511c073d178 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 19 Sep 2025 13:47:28 +0000 Subject: [PATCH 031/142] feat(api): manual updates --- .stats.yml | 2 +- .../api/client/okhttp/ImageKitOkHttpClient.kt | 20 ++++++---- .../okhttp/ImageKitOkHttpClientAsync.kt | 20 ++++++---- .../com/imagekit/api/core/ClientOptions.kt | 40 ++++++++++++------- 4 files changed, 53 insertions(+), 29 deletions(-) diff --git a/.stats.yml b/.stats.yml index 00fd95da..d3fcabb4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml openapi_spec_hash: 1d382866fce3284f26d341f112988d9d -config_hash: 29a2351fe2be89392b15719be8bc964f +config_hash: c9c7bed2a4341f915a2dc85958ce7f0e diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt index 4d354fbb..ef875853 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt @@ -184,13 +184,15 @@ class ImageKitOkHttpClient private constructor() { fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } /** - * Your ImageKit private API key (it starts with `private_`). You can view and manage API - * keys in the [dashboard](https://imagekit.io/dashboard/developer/api-keys). + * Your ImageKit private API key (starts with `private_`). You can find this in the + * [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). */ fun privateKey(privateKey: String) = apply { clientOptions.privateKey(privateKey) } /** - * ImageKit Basic Auth only uses the `private_key` as username and ignores the password. + * Leave this field unset. ImageKit uses Basic Authentication scheme that requires the + * `private_key` as the username and empty string as the password. The password field is + * automatically managed by the SDK and should not be set. * * Defaults to `"do_not_set"`. */ @@ -200,10 +202,14 @@ class ImageKitOkHttpClient private constructor() { fun password(password: Optional) = password(password.getOrNull()) /** - * Your ImageKit webhook secret. This is used by the SDK to verify webhook signatures. It - * starts with a `whsec_` prefix. You can view and manage your webhook secret in the - * [dashboard](https://imagekit.io/dashboard/developer/webhooks). Treat the secret like a - * password, keep it private and do not expose it publicly. Learn more about + * Your ImageKit webhook secret used by the SDK to verify webhook signatures for security. + * This secret starts with a `whsec_` prefix and is essential for webhook verification. You + * can view and manage your webhook secret in the + * [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). + * + * **Security Note**: Treat this secret like a password - keep it private and never expose + * it publicly. This field is optional and only required if you plan to use webhook + * signature verification. Learn more about * [webhook verification](https://imagekit.io/docs/webhooks#verify-webhook-signature). */ fun webhookSecret(webhookSecret: String?) = apply { diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt index f865a58c..1957a6e9 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt @@ -184,13 +184,15 @@ class ImageKitOkHttpClientAsync private constructor() { fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } /** - * Your ImageKit private API key (it starts with `private_`). You can view and manage API - * keys in the [dashboard](https://imagekit.io/dashboard/developer/api-keys). + * Your ImageKit private API key (starts with `private_`). You can find this in the + * [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). */ fun privateKey(privateKey: String) = apply { clientOptions.privateKey(privateKey) } /** - * ImageKit Basic Auth only uses the `private_key` as username and ignores the password. + * Leave this field unset. ImageKit uses Basic Authentication scheme that requires the + * `private_key` as the username and empty string as the password. The password field is + * automatically managed by the SDK and should not be set. * * Defaults to `"do_not_set"`. */ @@ -200,10 +202,14 @@ class ImageKitOkHttpClientAsync private constructor() { fun password(password: Optional) = password(password.getOrNull()) /** - * Your ImageKit webhook secret. This is used by the SDK to verify webhook signatures. It - * starts with a `whsec_` prefix. You can view and manage your webhook secret in the - * [dashboard](https://imagekit.io/dashboard/developer/webhooks). Treat the secret like a - * password, keep it private and do not expose it publicly. Learn more about + * Your ImageKit webhook secret used by the SDK to verify webhook signatures for security. + * This secret starts with a `whsec_` prefix and is essential for webhook verification. You + * can view and manage your webhook secret in the + * [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). + * + * **Security Note**: Treat this secret like a password - keep it private and never expose + * it publicly. This field is optional and only required if you plan to use webhook + * signature verification. Learn more about * [webhook verification](https://imagekit.io/docs/webhooks#verify-webhook-signature). */ fun webhookSecret(webhookSecret: String?) = apply { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt index 61f3dc40..e46e0799 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt @@ -85,8 +85,8 @@ private constructor( */ @get:JvmName("maxRetries") val maxRetries: Int, /** - * Your ImageKit private API key (it starts with `private_`). You can view and manage API keys - * in the [dashboard](https://imagekit.io/dashboard/developer/api-keys). + * Your ImageKit private API key (starts with `private_`). You can find this in the + * [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). */ @get:JvmName("privateKey") val privateKey: String, private val password: String?, @@ -109,17 +109,23 @@ private constructor( fun baseUrlOverridden(): Boolean = baseUrl != null /** - * ImageKit Basic Auth only uses the `private_key` as username and ignores the password. + * Leave this field unset. ImageKit uses Basic Authentication scheme that requires the + * `private_key` as the username and empty string as the password. The password field is + * automatically managed by the SDK and should not be set. * * Defaults to `"do_not_set"`. */ fun password(): Optional = Optional.ofNullable(password) /** - * Your ImageKit webhook secret. This is used by the SDK to verify webhook signatures. It starts - * with a `whsec_` prefix. You can view and manage your webhook secret in the - * [dashboard](https://imagekit.io/dashboard/developer/webhooks). Treat the secret like a - * password, keep it private and do not expose it publicly. Learn more about + * Your ImageKit webhook secret used by the SDK to verify webhook signatures for security. This + * secret starts with a `whsec_` prefix and is essential for webhook verification. You can view + * and manage your webhook secret in the + * [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). + * + * **Security Note**: Treat this secret like a password - keep it private and never expose it + * publicly. This field is optional and only required if you plan to use webhook signature + * verification. Learn more about * [webhook verification](https://imagekit.io/docs/webhooks#verify-webhook-signature). */ fun webhookSecret(): Optional = Optional.ofNullable(webhookSecret) @@ -277,13 +283,15 @@ private constructor( fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } /** - * Your ImageKit private API key (it starts with `private_`). You can view and manage API - * keys in the [dashboard](https://imagekit.io/dashboard/developer/api-keys). + * Your ImageKit private API key (starts with `private_`). You can find this in the + * [ImageKit dashboard](https://imagekit.io/dashboard/developer/api-keys). */ fun privateKey(privateKey: String) = apply { this.privateKey = privateKey } /** - * ImageKit Basic Auth only uses the `private_key` as username and ignores the password. + * Leave this field unset. ImageKit uses Basic Authentication scheme that requires the + * `private_key` as the username and empty string as the password. The password field is + * automatically managed by the SDK and should not be set. * * Defaults to `"do_not_set"`. */ @@ -293,10 +301,14 @@ private constructor( fun password(password: Optional) = password(password.getOrNull()) /** - * Your ImageKit webhook secret. This is used by the SDK to verify webhook signatures. It - * starts with a `whsec_` prefix. You can view and manage your webhook secret in the - * [dashboard](https://imagekit.io/dashboard/developer/webhooks). Treat the secret like a - * password, keep it private and do not expose it publicly. Learn more about + * Your ImageKit webhook secret used by the SDK to verify webhook signatures for security. + * This secret starts with a `whsec_` prefix and is essential for webhook verification. You + * can view and manage your webhook secret in the + * [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). + * + * **Security Note**: Treat this secret like a password - keep it private and never expose + * it publicly. This field is optional and only required if you plan to use webhook + * signature verification. Learn more about * [webhook verification](https://imagekit.io/docs/webhooks#verify-webhook-signature). */ fun webhookSecret(webhookSecret: String?) = apply { this.webhookSecret = webhookSecret } From f5206beb4c997de9c2ff47a70d36795557fae7c5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 19 Sep 2025 13:53:57 +0000 Subject: [PATCH 032/142] feat(api): manual updates --- .stats.yml | 2 +- .../api/client/okhttp/ImageKitOkHttpClient.kt | 18 ++++------ .../okhttp/ImageKitOkHttpClientAsync.kt | 18 ++++------ .../com/imagekit/api/core/ClientOptions.kt | 35 ++++++------------- 4 files changed, 24 insertions(+), 49 deletions(-) diff --git a/.stats.yml b/.stats.yml index d3fcabb4..ee45f3d5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml openapi_spec_hash: 1d382866fce3284f26d341f112988d9d -config_hash: c9c7bed2a4341f915a2dc85958ce7f0e +config_hash: 51a9632be24fc533ad69a5bd56934651 diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt index ef875853..4600cfad 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt @@ -190,9 +190,8 @@ class ImageKitOkHttpClient private constructor() { fun privateKey(privateKey: String) = apply { clientOptions.privateKey(privateKey) } /** - * Leave this field unset. ImageKit uses Basic Authentication scheme that requires the - * `private_key` as the username and empty string as the password. The password field is - * automatically managed by the SDK and should not be set. + * ImageKit uses your API key as username and ignores the password. The SDK sets a dummy + * value. You can ignore this field. * * Defaults to `"do_not_set"`. */ @@ -202,15 +201,10 @@ class ImageKitOkHttpClient private constructor() { fun password(password: Optional) = password(password.getOrNull()) /** - * Your ImageKit webhook secret used by the SDK to verify webhook signatures for security. - * This secret starts with a `whsec_` prefix and is essential for webhook verification. You - * can view and manage your webhook secret in the - * [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). - * - * **Security Note**: Treat this secret like a password - keep it private and never expose - * it publicly. This field is optional and only required if you plan to use webhook - * signature verification. Learn more about - * [webhook verification](https://imagekit.io/docs/webhooks#verify-webhook-signature). + * Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`). You + * can find this in the + * [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). Only required if + * you're using webhooks. */ fun webhookSecret(webhookSecret: String?) = apply { clientOptions.webhookSecret(webhookSecret) diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt index 1957a6e9..458d5d20 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt @@ -190,9 +190,8 @@ class ImageKitOkHttpClientAsync private constructor() { fun privateKey(privateKey: String) = apply { clientOptions.privateKey(privateKey) } /** - * Leave this field unset. ImageKit uses Basic Authentication scheme that requires the - * `private_key` as the username and empty string as the password. The password field is - * automatically managed by the SDK and should not be set. + * ImageKit uses your API key as username and ignores the password. The SDK sets a dummy + * value. You can ignore this field. * * Defaults to `"do_not_set"`. */ @@ -202,15 +201,10 @@ class ImageKitOkHttpClientAsync private constructor() { fun password(password: Optional) = password(password.getOrNull()) /** - * Your ImageKit webhook secret used by the SDK to verify webhook signatures for security. - * This secret starts with a `whsec_` prefix and is essential for webhook verification. You - * can view and manage your webhook secret in the - * [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). - * - * **Security Note**: Treat this secret like a password - keep it private and never expose - * it publicly. This field is optional and only required if you plan to use webhook - * signature verification. Learn more about - * [webhook verification](https://imagekit.io/docs/webhooks#verify-webhook-signature). + * Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`). You + * can find this in the + * [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). Only required if + * you're using webhooks. */ fun webhookSecret(webhookSecret: String?) = apply { clientOptions.webhookSecret(webhookSecret) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt index e46e0799..c599f355 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt @@ -109,24 +109,17 @@ private constructor( fun baseUrlOverridden(): Boolean = baseUrl != null /** - * Leave this field unset. ImageKit uses Basic Authentication scheme that requires the - * `private_key` as the username and empty string as the password. The password field is - * automatically managed by the SDK and should not be set. + * ImageKit uses your API key as username and ignores the password. The SDK sets a dummy value. + * You can ignore this field. * * Defaults to `"do_not_set"`. */ fun password(): Optional = Optional.ofNullable(password) /** - * Your ImageKit webhook secret used by the SDK to verify webhook signatures for security. This - * secret starts with a `whsec_` prefix and is essential for webhook verification. You can view - * and manage your webhook secret in the - * [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). - * - * **Security Note**: Treat this secret like a password - keep it private and never expose it - * publicly. This field is optional and only required if you plan to use webhook signature - * verification. Learn more about - * [webhook verification](https://imagekit.io/docs/webhooks#verify-webhook-signature). + * Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`). You can + * find this in the [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). Only + * required if you're using webhooks. */ fun webhookSecret(): Optional = Optional.ofNullable(webhookSecret) @@ -289,9 +282,8 @@ private constructor( fun privateKey(privateKey: String) = apply { this.privateKey = privateKey } /** - * Leave this field unset. ImageKit uses Basic Authentication scheme that requires the - * `private_key` as the username and empty string as the password. The password field is - * automatically managed by the SDK and should not be set. + * ImageKit uses your API key as username and ignores the password. The SDK sets a dummy + * value. You can ignore this field. * * Defaults to `"do_not_set"`. */ @@ -301,15 +293,10 @@ private constructor( fun password(password: Optional) = password(password.getOrNull()) /** - * Your ImageKit webhook secret used by the SDK to verify webhook signatures for security. - * This secret starts with a `whsec_` prefix and is essential for webhook verification. You - * can view and manage your webhook secret in the - * [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). - * - * **Security Note**: Treat this secret like a password - keep it private and never expose - * it publicly. This field is optional and only required if you plan to use webhook - * signature verification. Learn more about - * [webhook verification](https://imagekit.io/docs/webhooks#verify-webhook-signature). + * Your ImageKit webhook secret for verifying webhook signatures (starts with `whsec_`). You + * can find this in the + * [ImageKit dashboard](https://imagekit.io/dashboard/developer/webhooks). Only required if + * you're using webhooks. */ fun webhookSecret(webhookSecret: String?) = apply { this.webhookSecret = webhookSecret } From da0222197fca08583b2096effa2bd18a9f9f615b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 20 Sep 2025 02:49:01 +0000 Subject: [PATCH 033/142] chore(internal): codegen related update --- .../api/client/okhttp/ImageKitOkHttpClient.kt | 12 ++++++ .../okhttp/ImageKitOkHttpClientAsync.kt | 12 ++++++ .../com/imagekit/api/core/ClientOptions.kt | 27 ++++++++++++ .../com/imagekit/api/core/DefaultSleeper.kt | 28 +++++++++++++ .../api/core/PhantomReachableSleeper.kt | 23 +++++++++++ .../kotlin/com/imagekit/api/core/Sleeper.kt | 21 ++++++++++ .../api/core/http/RetryingHttpClient.kt | 41 ++++--------------- .../api/core/http/RetryingHttpClientTest.kt | 9 +++- 8 files changed, 139 insertions(+), 34 deletions(-) create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/DefaultSleeper.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachableSleeper.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Sleeper.kt diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt index 4600cfad..dc4d4961 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.json.JsonMapper import com.imagekit.api.client.ImageKitClient import com.imagekit.api.client.ImageKitClientImpl import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.Sleeper import com.imagekit.api.core.Timeout import com.imagekit.api.core.http.Headers import com.imagekit.api.core.http.HttpClient @@ -120,6 +121,17 @@ class ImageKitOkHttpClient private constructor() { */ fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + fun sleeper(sleeper: Sleeper) = apply { clientOptions.sleeper(sleeper) } + /** * The clock to use for operations that require timing, like retries. * diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt index 458d5d20..305798c8 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.json.JsonMapper import com.imagekit.api.client.ImageKitClientAsync import com.imagekit.api.client.ImageKitClientAsyncImpl import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.Sleeper import com.imagekit.api.core.Timeout import com.imagekit.api.core.http.Headers import com.imagekit.api.core.http.HttpClient @@ -120,6 +121,17 @@ class ImageKitOkHttpClientAsync private constructor() { */ fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + fun sleeper(sleeper: Sleeper) = apply { clientOptions.sleeper(sleeper) } + /** * The clock to use for operations that require timing, like retries. * diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt index c599f355..3f0c04e3 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt @@ -41,6 +41,16 @@ private constructor( * needs to be overridden. */ @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + @get:JvmName("sleeper") val sleeper: Sleeper, /** * The clock to use for operations that require timing, like retries. * @@ -154,6 +164,7 @@ private constructor( private var httpClient: HttpClient? = null private var checkJacksonVersionCompatibility: Boolean = true private var jsonMapper: JsonMapper = jsonMapper() + private var sleeper: Sleeper? = null private var clock: Clock = Clock.systemUTC() private var baseUrl: String? = null private var headers: Headers.Builder = Headers.builder() @@ -170,6 +181,7 @@ private constructor( httpClient = clientOptions.originalHttpClient checkJacksonVersionCompatibility = clientOptions.checkJacksonVersionCompatibility jsonMapper = clientOptions.jsonMapper + sleeper = clientOptions.sleeper clock = clientOptions.clock baseUrl = clientOptions.baseUrl headers = clientOptions.headers.toBuilder() @@ -212,6 +224,17 @@ private constructor( */ fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + fun sleeper(sleeper: Sleeper) = apply { this.sleeper = PhantomReachableSleeper(sleeper) } + /** * The clock to use for operations that require timing, like retries. * @@ -430,6 +453,7 @@ private constructor( */ fun build(): ClientOptions { val httpClient = checkRequired("httpClient", httpClient) + val sleeper = sleeper ?: PhantomReachableSleeper(DefaultSleeper()) val privateKey = checkRequired("privateKey", privateKey) val headers = Headers.builder() @@ -458,11 +482,13 @@ private constructor( httpClient, RetryingHttpClient.builder() .httpClient(httpClient) + .sleeper(sleeper) .clock(clock) .maxRetries(maxRetries) .build(), checkJacksonVersionCompatibility, jsonMapper, + sleeper, clock, baseUrl, headers.build(), @@ -489,5 +515,6 @@ private constructor( */ fun close() { httpClient.close() + sleeper.close() } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/DefaultSleeper.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/DefaultSleeper.kt new file mode 100644 index 00000000..457f5920 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/DefaultSleeper.kt @@ -0,0 +1,28 @@ +package com.imagekit.api.core + +import java.time.Duration +import java.util.Timer +import java.util.TimerTask +import java.util.concurrent.CompletableFuture + +class DefaultSleeper : Sleeper { + + private val timer = Timer("DefaultSleeper", true) + + override fun sleep(duration: Duration) = Thread.sleep(duration.toMillis()) + + override fun sleepAsync(duration: Duration): CompletableFuture { + val future = CompletableFuture() + timer.schedule( + object : TimerTask() { + override fun run() { + future.complete(null) + } + }, + duration.toMillis(), + ) + return future + } + + override fun close() = timer.cancel() +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachableSleeper.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachableSleeper.kt new file mode 100644 index 00000000..4b69d4d8 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachableSleeper.kt @@ -0,0 +1,23 @@ +package com.imagekit.api.core + +import java.time.Duration +import java.util.concurrent.CompletableFuture + +/** + * A delegating wrapper around a [Sleeper] that closes it once it's only phantom reachable. + * + * This class ensures the [Sleeper] is closed even if the user forgets to do it. + */ +internal class PhantomReachableSleeper(private val sleeper: Sleeper) : Sleeper { + + init { + closeWhenPhantomReachable(this, sleeper) + } + + override fun sleep(duration: Duration) = sleeper.sleep(duration) + + override fun sleepAsync(duration: Duration): CompletableFuture = + sleeper.sleepAsync(duration) + + override fun close() = sleeper.close() +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Sleeper.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Sleeper.kt new file mode 100644 index 00000000..00564e44 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Sleeper.kt @@ -0,0 +1,21 @@ +package com.imagekit.api.core + +import java.time.Duration +import java.util.concurrent.CompletableFuture + +/** + * An interface for delaying execution for a specified amount of time. + * + * Useful for testing and cleaning up resources. + */ +interface Sleeper : AutoCloseable { + + /** Synchronously pauses execution for the given [duration]. */ + fun sleep(duration: Duration) + + /** Asynchronously pauses execution for the given [duration]. */ + fun sleepAsync(duration: Duration): CompletableFuture + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt index e8e45bee..0e3fcde5 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt @@ -1,6 +1,8 @@ package com.imagekit.api.core.http +import com.imagekit.api.core.DefaultSleeper import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.Sleeper import com.imagekit.api.core.checkRequired import com.imagekit.api.errors.ImageKitIoException import com.imagekit.api.errors.ImageKitRetryableException @@ -11,8 +13,6 @@ import java.time.OffsetDateTime import java.time.format.DateTimeFormatter import java.time.format.DateTimeParseException import java.time.temporal.ChronoUnit -import java.util.Timer -import java.util.TimerTask import java.util.UUID import java.util.concurrent.CompletableFuture import java.util.concurrent.ThreadLocalRandom @@ -130,7 +130,10 @@ private constructor( return executeWithRetries(modifiedRequest, requestOptions) } - override fun close() = httpClient.close() + override fun close() { + httpClient.close() + sleeper.close() + } private fun isRetryable(request: HttpRequest): Boolean = // Some requests, such as when a request body is being streamed, cannot be retried because @@ -235,33 +238,14 @@ private constructor( class Builder internal constructor() { private var httpClient: HttpClient? = null - private var sleeper: Sleeper = - object : Sleeper { - - private val timer = Timer("RetryingHttpClient", true) - - override fun sleep(duration: Duration) = Thread.sleep(duration.toMillis()) - - override fun sleepAsync(duration: Duration): CompletableFuture { - val future = CompletableFuture() - timer.schedule( - object : TimerTask() { - override fun run() { - future.complete(null) - } - }, - duration.toMillis(), - ) - return future - } - } + private var sleeper: Sleeper? = null private var clock: Clock = Clock.systemUTC() private var maxRetries: Int = 2 private var idempotencyHeader: String? = null fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } - @JvmSynthetic internal fun sleeper(sleeper: Sleeper) = apply { this.sleeper = sleeper } + fun sleeper(sleeper: Sleeper) = apply { this.sleeper = sleeper } fun clock(clock: Clock) = apply { this.clock = clock } @@ -272,17 +256,10 @@ private constructor( fun build(): HttpClient = RetryingHttpClient( checkRequired("httpClient", httpClient), - sleeper, + sleeper ?: DefaultSleeper(), clock, maxRetries, idempotencyHeader, ) } - - internal interface Sleeper { - - fun sleep(duration: Duration) - - fun sleepAsync(duration: Duration): CompletableFuture - } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt index 732cc289..d2f9ff61 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt @@ -6,6 +6,7 @@ import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.github.tomakehurst.wiremock.stubbing.Scenario import com.imagekit.api.client.okhttp.OkHttpClient import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.Sleeper import com.imagekit.api.errors.ImageKitRetryableException import java.io.InputStream import java.time.Duration @@ -294,12 +295,14 @@ internal class RetryingHttpClientTest { .httpClient(failingHttpClient) .maxRetries(2) .sleeper( - object : RetryingHttpClient.Sleeper { + object : Sleeper { override fun sleep(duration: Duration) {} override fun sleepAsync(duration: Duration): CompletableFuture = CompletableFuture.completedFuture(null) + + override fun close() {} } ) .build() @@ -333,12 +336,14 @@ internal class RetryingHttpClientTest { .httpClient(httpClient) // Use a no-op `Sleeper` to make the test fast. .sleeper( - object : RetryingHttpClient.Sleeper { + object : Sleeper { override fun sleep(duration: Duration) {} override fun sleepAsync(duration: Duration): CompletableFuture = CompletableFuture.completedFuture(null) + + override fun close() {} } ) From daaa7f33c20310093952bd4396d305bef42c81b8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 20 Sep 2025 03:12:40 +0000 Subject: [PATCH 034/142] chore: improve formatter performance --- scripts/fast-format | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/fast-format b/scripts/fast-format index e16bfc56..1b3bc473 100755 --- a/scripts/fast-format +++ b/scripts/fast-format @@ -2,7 +2,12 @@ set -euo pipefail +echo "Script started with $# arguments" +echo "Arguments: $*" +echo "Script location: $(dirname "$0")" + cd "$(dirname "$0")/.." +echo "Changed to directory: $(pwd)" if [ $# -eq 0 ]; then echo "Usage: $0 [additional-formatter-args...]" @@ -12,6 +17,8 @@ fi FILE_LIST="$1" +echo "Looking for file: $FILE_LIST" + if [ ! -f "$FILE_LIST" ]; then echo "Error: File '$FILE_LIST' not found" exit 1 @@ -23,9 +30,9 @@ if ! command -v ktfmt-fast-format &> /dev/null; then fi # Process Kotlin files -kt_files=$(grep -E '\.kt$' "$FILE_LIST" | grep -v './buildSrc/build/') -kt_files=$(grep -E '\.kt$' "$FILE_LIST" | grep -v './buildSrc/build/') -echo "==> Found $(echo "$kt_files" | wc -l) Kotlin files:" +echo "==> Looking for Kotlin files" +kt_files=$(grep -E '\.kt$' "$FILE_LIST" | grep -v './buildSrc/build/' || true) +echo "==> Done looking for Kotlin files" if [[ -n "$kt_files" ]]; then echo "==> will format Kotlin files" From 1b520d13de7c42693d3acc4a364fdec55eb341ce Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 20 Sep 2025 08:07:02 +0000 Subject: [PATCH 035/142] feat(api): Update env var name --- .stats.yml | 2 +- README.md | 22 +++++++++---------- .../com/imagekit/api/core/ClientOptions.kt | 6 ++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.stats.yml b/.stats.yml index ee45f3d5..0f9a4aa3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml openapi_spec_hash: 1d382866fce3284f26d341f112988d9d -config_hash: 51a9632be24fc533ad69a5bd56934651 +config_hash: f1fafe5e607e996b58b67fd1dd3e74fa diff --git a/README.md b/README.md index 27e9ee4f..4dee61d5 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,8 @@ import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; import java.io.ByteArrayInputStream; -// Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables +// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() @@ -71,8 +71,8 @@ Configure the client using system properties or environment variables: import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; -// Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables +// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); ``` @@ -95,8 +95,8 @@ import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; ImageKitClient client = ImageKitOkHttpClient.builder() - // Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties - // Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables + // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties + // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables .fromEnv() .privateKey("My Private Key") .build(); @@ -106,7 +106,7 @@ See this table for the available options: | Setter | System property | Environment variable | Required | Default value | | --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- | -| `privateKey` | `imagekit.imagekitPrivateApiKey` | `IMAGEKIT_PRIVATE_API_KEY` | true | - | +| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - | | `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` | | `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - | | `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` | @@ -158,8 +158,8 @@ import com.imagekit.api.models.files.FileUploadResponse; import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; -// Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables +// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() @@ -179,8 +179,8 @@ import com.imagekit.api.models.files.FileUploadResponse; import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; -// Configures using the `imagekit.imagekitPrivateApiKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_API_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables +// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv(); FileUploadParams params = FileUploadParams.builder() diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt index 3f0c04e3..bce756cf 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt @@ -416,7 +416,7 @@ private constructor( * * |Setter |System property |Environment variable |Required|Default value | * |---------------|--------------------------------------|--------------------------------|--------|---------------------------| - * |`privateKey` |`imagekit.imagekitPrivateApiKey` |`IMAGEKIT_PRIVATE_API_KEY` |true |- | + * |`privateKey` |`imagekit.imagekitPrivateKey` |`IMAGEKIT_PRIVATE_KEY` |true |- | * |`password` |`imagekit.optionalImagekitIgnoresThis`|`OPTIONAL_IMAGEKIT_IGNORES_THIS`|false |`"do_not_set"` | * |`webhookSecret`|`imagekit.imagekitWebhookSecret` |`IMAGEKIT_WEBHOOK_SECRET` |false |- | * |`baseUrl` |`imagekit.baseUrl` |`IMAGE_KIT_BASE_URL` |true |`"https://api.imagekit.io"`| @@ -427,8 +427,8 @@ private constructor( (System.getProperty("imagekit.baseUrl") ?: System.getenv("IMAGE_KIT_BASE_URL"))?.let { baseUrl(it) } - (System.getProperty("imagekit.imagekitPrivateApiKey") - ?: System.getenv("IMAGEKIT_PRIVATE_API_KEY")) + (System.getProperty("imagekit.imagekitPrivateKey") + ?: System.getenv("IMAGEKIT_PRIVATE_KEY")) ?.let { privateKey(it) } (System.getProperty("imagekit.optionalImagekitIgnoresThis") ?: System.getenv("OPTIONAL_IMAGEKIT_IGNORES_THIS")) From 0b273a981219fbf9083fcb2559d81f3e472ca9e1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 20 Sep 2025 09:25:44 +0000 Subject: [PATCH 036/142] feat(api): update api docs link --- .stats.yml | 2 +- README.md | 4 ++-- buildSrc/src/main/kotlin/image-kit.publish.gradle.kts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.stats.yml b/.stats.yml index 0f9a4aa3..7dfc3c2a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml openapi_spec_hash: 1d382866fce3284f26d341f112988d9d -config_hash: f1fafe5e607e996b58b67fd1dd3e74fa +config_hash: 5f7498f5ea66e8a544c6c37b10f77467 diff --git a/README.md b/README.md index 4dee61d5..44183a1d 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,13 @@ -The Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs) from applications written in Java. +The Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java. It is generated with [Stainless](https://www.stainless.com/). -The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1). +The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1). diff --git a/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts b/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts index 8d987816..a3b59471 100644 --- a/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts @@ -11,7 +11,7 @@ configure { pom { name.set("ImageKit API") description.set("Checkout [API overview](/docs/api-overview) to learn about ImageKit's APIs,\nauthentication, rate limits, and error codes etc.") - url.set("https://imagekit.io/docs") + url.set("https://imagekit.io/docs/api-reference") licenses { license { From 065125f9c510b69c6ec41ddb811f9cebcdd37c1b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 20 Sep 2025 09:28:02 +0000 Subject: [PATCH 037/142] feat(api): remove Stainless attribution from readme --- .stats.yml | 2 +- README.md | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 7dfc3c2a..e1604c7a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml openapi_spec_hash: 1d382866fce3284f26d341f112988d9d -config_hash: 5f7498f5ea66e8a544c6c37b10f77467 +config_hash: ff23f46fe08ef3f43c57c8cf13eff3a1 diff --git a/README.md b/README.md index 44183a1d..176c2df2 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,6 @@ The Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java. -It is generated with [Stainless](https://www.stainless.com/). - The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1). From ffd7bc0814f55df244b2f075961dc62522993d74 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 21 Sep 2025 03:11:35 +0000 Subject: [PATCH 038/142] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index e1604c7a..031fed99 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml openapi_spec_hash: 1d382866fce3284f26d341f112988d9d -config_hash: ff23f46fe08ef3f43c57c8cf13eff3a1 +config_hash: d57f3c7c581048428b41398f30da8b9b From 646022de6d3820653968a99867c60b3df998f9d3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 22 Sep 2025 12:35:58 +0000 Subject: [PATCH 039/142] feat(api): manual updates --- .github/workflows/publish-sonatype.yml | 41 ------------ .github/workflows/release-doctor.yml | 24 ------- .release-please-manifest.json | 3 - .stats.yml | 2 +- README.md | 14 +--- bin/check-release-environment | 33 --------- build.gradle.kts | 2 +- .../main/kotlin/image-kit.publish.gradle.kts | 6 +- .../kotlin/com/imagekit/api/core/Check.kt | 2 +- release-please-config.json | 67 ------------------- 10 files changed, 7 insertions(+), 187 deletions(-) delete mode 100644 .github/workflows/publish-sonatype.yml delete mode 100644 .github/workflows/release-doctor.yml delete mode 100644 .release-please-manifest.json delete mode 100644 bin/check-release-environment delete mode 100644 release-please-config.json diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml deleted file mode 100644 index 9207f7f8..00000000 --- a/.github/workflows/publish-sonatype.yml +++ /dev/null @@ -1,41 +0,0 @@ -# This workflow is triggered when a GitHub release is created. -# It can also be run manually to re-publish to Sonatype in case it failed for some reason. -# You can run this workflow by navigating to https://www.github.com/imagekit-developer/imagekit-java/actions/workflows/publish-sonatype.yml -name: Publish Sonatype -on: - workflow_dispatch: - - release: - types: [published] - -jobs: - publish: - name: publish - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Set up Java - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: | - 8 - 21 - cache: gradle - - - name: Set up Gradle - uses: gradle/gradle-build-action@v2 - - - name: Publish to Sonatype - run: |- - export -- GPG_SIGNING_KEY_ID - printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD" - GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')" - ./gradlew publish --no-configuration-cache - env: - SONATYPE_USERNAME: ${{ secrets.IMAGE_KIT_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.IMAGE_KIT_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} - GPG_SIGNING_KEY: ${{ secrets.IMAGE_KIT_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} - GPG_SIGNING_PASSWORD: ${{ secrets.IMAGE_KIT_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }} \ No newline at end of file diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml deleted file mode 100644 index 4b394d27..00000000 --- a/.github/workflows/release-doctor.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Release Doctor -on: - pull_request: - branches: - - master - workflow_dispatch: - -jobs: - release_doctor: - name: release doctor - runs-on: ubuntu-latest - if: github.repository == 'imagekit-developer/imagekit-java' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') - - steps: - - uses: actions/checkout@v4 - - - name: Check release environment - run: | - bash ./bin/check-release-environment - env: - SONATYPE_USERNAME: ${{ secrets.IMAGE_KIT_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.IMAGE_KIT_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} - GPG_SIGNING_KEY: ${{ secrets.IMAGE_KIT_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} - GPG_SIGNING_PASSWORD: ${{ secrets.IMAGE_KIT_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json deleted file mode 100644 index 1332969b..00000000 --- a/.release-please-manifest.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - ".": "0.0.1" -} \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 031fed99..7c3aae1c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml openapi_spec_hash: 1d382866fce3284f26d341f112988d9d -config_hash: d57f3c7c581048428b41398f30da8b9b +config_hash: e42d7fc3a8c92c35099cc283f9a4467a diff --git a/README.md b/README.md index 176c2df2..28acd4e2 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,14 @@ # Image Kit Java API Library - - [![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-java)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-java/0.0.1) [![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1) - - The Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java. - - The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1). - - ## Installation - - ### Gradle ```kotlin @@ -35,8 +25,6 @@ implementation("com.imagekit.api:image-kit-java:0.0.1") ``` - - ## Requirements This library requires Java 8 or later. @@ -705,4 +693,4 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. -We are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions. +We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-java/issues) with questions, bugs, or suggestions. diff --git a/bin/check-release-environment b/bin/check-release-environment deleted file mode 100644 index 3a6a7b4a..00000000 --- a/bin/check-release-environment +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash - -errors=() - -if [ -z "${SONATYPE_USERNAME}" ]; then - errors+=("The SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets") -fi - -if [ -z "${SONATYPE_PASSWORD}" ]; then - errors+=("The SONATYPE_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") -fi - -if [ -z "${GPG_SIGNING_KEY}" ]; then - errors+=("The GPG_SIGNING_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets") -fi - -if [ -z "${GPG_SIGNING_PASSWORD}" ]; then - errors+=("The GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") -fi - -lenErrors=${#errors[@]} - -if [[ lenErrors -gt 0 ]]; then - echo -e "Found the following errors in the release environment:\n" - - for error in "${errors[@]}"; do - echo -e "- $error\n" - done - - exit 1 -fi - -echo "The environment is ready to push releases!" diff --git a/build.gradle.kts b/build.gradle.kts index ce9ad14f..7712ede0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ repositories { allprojects { group = "com.imagekit.api" - version = "0.0.1" // x-release-please-version + version = "0.0.1" } subprojects { diff --git a/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts b/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts index a3b59471..3b7ce2e2 100644 --- a/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts @@ -27,9 +27,9 @@ configure { } scm { - connection.set("scm:git:git://github.com/imagekit-developer/imagekit-java.git") - developerConnection.set("scm:git:git://github.com/imagekit-developer/imagekit-java.git") - url.set("https://github.com/imagekit-developer/imagekit-java") + connection.set("scm:git:git://github.com/stainless-sdks/imagekit-java.git") + developerConnection.set("scm:git:git://github.com/stainless-sdks/imagekit-java.git") + url.set("https://github.com/stainless-sdks/imagekit-java") } versionMapping { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Check.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Check.kt index f587fcc9..93bcc538 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Check.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Check.kt @@ -77,7 +77,7 @@ This can happen if you are either: Double-check that you are depending on compatible Jackson versions. -See https://www.github.com/imagekit-developer/imagekit-java#jackson for more information. +See https://www.github.com/stainless-sdks/imagekit-java#jackson for more information. """ .trimIndent() } diff --git a/release-please-config.json b/release-please-config.json deleted file mode 100644 index 8f987198..00000000 --- a/release-please-config.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "packages": { - ".": {} - }, - "$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json", - "include-v-in-tag": true, - "include-component-in-tag": false, - "versioning": "prerelease", - "prerelease": true, - "bump-minor-pre-major": true, - "bump-patch-for-minor-pre-major": false, - "pull-request-header": "Automated Release PR", - "pull-request-title-pattern": "release: ${version}", - "changelog-sections": [ - { - "type": "feat", - "section": "Features" - }, - { - "type": "fix", - "section": "Bug Fixes" - }, - { - "type": "perf", - "section": "Performance Improvements" - }, - { - "type": "revert", - "section": "Reverts" - }, - { - "type": "chore", - "section": "Chores" - }, - { - "type": "docs", - "section": "Documentation" - }, - { - "type": "style", - "section": "Styles" - }, - { - "type": "refactor", - "section": "Refactors" - }, - { - "type": "test", - "section": "Tests", - "hidden": true - }, - { - "type": "build", - "section": "Build System" - }, - { - "type": "ci", - "section": "Continuous Integration", - "hidden": true - } - ], - "release-type": "simple", - "extra-files": [ - "README.md", - "build.gradle.kts" - ] -} \ No newline at end of file From 998d126b14aebc0a454a15d9169049888395ec35 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 23 Sep 2025 03:21:35 +0000 Subject: [PATCH 040/142] chore(internal): improve examples --- .../imagekit/api/models/ImageOverlayTest.kt | 280 ++++++++++++- .../com/imagekit/api/models/OverlayTest.kt | 384 +++++++++++++++++- .../com/imagekit/api/models/SrcOptionsTest.kt | 111 +++++ .../imagekit/api/models/TransformationTest.kt | 96 +++++ .../imagekit/api/models/VideoOverlayTest.kt | 280 ++++++++++++- 5 files changed, 1141 insertions(+), 10 deletions(-) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt index 934ff3f0..fbcfd99f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt @@ -24,7 +24,100 @@ internal class ImageOverlayTest { .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .input("input") .encoding(ImageOverlay.Encoding.AUTO) - .transformation(listOf()) + .addTransformation( + Transformation.builder() + .aiChangeBackground("aiChangeBackground") + .aiDropShadowTrue() + .aiEdit("aiEdit") + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) + .aiRetouch(Transformation.AiRetouch.TRUE) + .aiUpscale(Transformation.AiUpscale.TRUE) + .aiVariation(Transformation.AiVariation.TRUE) + .aspectRatio("4:3") + .audioCodec(Transformation.AudioCodec.AAC) + .background("red") + .blur(10.0) + .border("5_FF0000") + .colorProfile(true) + .contrastStretch(Transformation.ContrastStretch.TRUE) + .crop(Transformation.Crop.FORCE) + .cropMode(Transformation.CropMode.PAD_RESIZE) + .defaultImage("defaultImage") + .dpr(2.0) + .duration(0.0) + .endOffset(0.0) + .flip(Transformation.Flip.H) + .focus("center") + .format(Transformation.Format.AUTO) + .gradientTrue() + .grayscale(Transformation.Grayscale.TRUE) + .height(200.0) + .lossless(true) + .metadata(true) + .named("named") + .opacity(0.0) + .original(true) + .overlay( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing( + OverlayTiming.builder() + .duration(0.0) + .end(0.0) + .start(0.0) + .build() + ) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment( + TextOverlayTransformation.InnerAlignment.LEFT + ) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + ) + .page(0.0) + .progressive(true) + .quality(80.0) + .radius(20.0) + .raw("raw") + .rotation(90.0) + .shadowTrue() + .sharpenTrue() + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trimTrue() + .unsharpMaskTrue() + .videoCodec(Transformation.VideoCodec.H264) + .width(300.0) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .zoom(0.0) + .build() + ) .build() assertThat(imageOverlay.position()) @@ -35,7 +128,95 @@ internal class ImageOverlayTest { .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) assertThat(imageOverlay.input()).isEqualTo("input") assertThat(imageOverlay.encoding()).contains(ImageOverlay.Encoding.AUTO) - assertThat(imageOverlay.transformation().getOrNull()).containsExactly() + assertThat(imageOverlay.transformation().getOrNull()) + .containsExactly( + Transformation.builder() + .aiChangeBackground("aiChangeBackground") + .aiDropShadowTrue() + .aiEdit("aiEdit") + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) + .aiRetouch(Transformation.AiRetouch.TRUE) + .aiUpscale(Transformation.AiUpscale.TRUE) + .aiVariation(Transformation.AiVariation.TRUE) + .aspectRatio("4:3") + .audioCodec(Transformation.AudioCodec.AAC) + .background("red") + .blur(10.0) + .border("5_FF0000") + .colorProfile(true) + .contrastStretch(Transformation.ContrastStretch.TRUE) + .crop(Transformation.Crop.FORCE) + .cropMode(Transformation.CropMode.PAD_RESIZE) + .defaultImage("defaultImage") + .dpr(2.0) + .duration(0.0) + .endOffset(0.0) + .flip(Transformation.Flip.H) + .focus("center") + .format(Transformation.Format.AUTO) + .gradientTrue() + .grayscale(Transformation.Grayscale.TRUE) + .height(200.0) + .lossless(true) + .metadata(true) + .named("named") + .opacity(0.0) + .original(true) + .overlay( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing( + OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build() + ) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + ) + .page(0.0) + .progressive(true) + .quality(80.0) + .radius(20.0) + .raw("raw") + .rotation(90.0) + .shadowTrue() + .sharpenTrue() + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trimTrue() + .unsharpMaskTrue() + .videoCodec(Transformation.VideoCodec.H264) + .width(300.0) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .zoom(0.0) + .build() + ) } @Test @@ -53,7 +234,100 @@ internal class ImageOverlayTest { .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .input("input") .encoding(ImageOverlay.Encoding.AUTO) - .transformation(listOf()) + .addTransformation( + Transformation.builder() + .aiChangeBackground("aiChangeBackground") + .aiDropShadowTrue() + .aiEdit("aiEdit") + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) + .aiRetouch(Transformation.AiRetouch.TRUE) + .aiUpscale(Transformation.AiUpscale.TRUE) + .aiVariation(Transformation.AiVariation.TRUE) + .aspectRatio("4:3") + .audioCodec(Transformation.AudioCodec.AAC) + .background("red") + .blur(10.0) + .border("5_FF0000") + .colorProfile(true) + .contrastStretch(Transformation.ContrastStretch.TRUE) + .crop(Transformation.Crop.FORCE) + .cropMode(Transformation.CropMode.PAD_RESIZE) + .defaultImage("defaultImage") + .dpr(2.0) + .duration(0.0) + .endOffset(0.0) + .flip(Transformation.Flip.H) + .focus("center") + .format(Transformation.Format.AUTO) + .gradientTrue() + .grayscale(Transformation.Grayscale.TRUE) + .height(200.0) + .lossless(true) + .metadata(true) + .named("named") + .opacity(0.0) + .original(true) + .overlay( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing( + OverlayTiming.builder() + .duration(0.0) + .end(0.0) + .start(0.0) + .build() + ) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment( + TextOverlayTransformation.InnerAlignment.LEFT + ) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + ) + .page(0.0) + .progressive(true) + .quality(80.0) + .radius(20.0) + .raw("raw") + .rotation(90.0) + .shadowTrue() + .sharpenTrue() + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trimTrue() + .unsharpMaskTrue() + .videoCodec(Transformation.VideoCodec.H264) + .width(300.0) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .zoom(0.0) + .build() + ) .build() val roundtrippedImageOverlay = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt index c55bfc42..12352e41 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt @@ -112,7 +112,100 @@ internal class OverlayTest { .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .input("input") .encoding(ImageOverlay.Encoding.AUTO) - .transformation(listOf()) + .addTransformation( + Transformation.builder() + .aiChangeBackground("aiChangeBackground") + .aiDropShadowTrue() + .aiEdit("aiEdit") + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) + .aiRetouch(Transformation.AiRetouch.TRUE) + .aiUpscale(Transformation.AiUpscale.TRUE) + .aiVariation(Transformation.AiVariation.TRUE) + .aspectRatio("4:3") + .audioCodec(Transformation.AudioCodec.AAC) + .background("red") + .blur(10.0) + .border("5_FF0000") + .colorProfile(true) + .contrastStretch(Transformation.ContrastStretch.TRUE) + .crop(Transformation.Crop.FORCE) + .cropMode(Transformation.CropMode.PAD_RESIZE) + .defaultImage("defaultImage") + .dpr(2.0) + .duration(0.0) + .endOffset(0.0) + .flip(Transformation.Flip.H) + .focus("center") + .format(Transformation.Format.AUTO) + .gradientTrue() + .grayscale(Transformation.Grayscale.TRUE) + .height(200.0) + .lossless(true) + .metadata(true) + .named("named") + .opacity(0.0) + .original(true) + .overlay( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing( + OverlayTiming.builder() + .duration(0.0) + .end(0.0) + .start(0.0) + .build() + ) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment( + TextOverlayTransformation.InnerAlignment.LEFT + ) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + ) + .page(0.0) + .progressive(true) + .quality(80.0) + .radius(20.0) + .raw("raw") + .rotation(90.0) + .shadowTrue() + .sharpenTrue() + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trimTrue() + .unsharpMaskTrue() + .videoCodec(Transformation.VideoCodec.H264) + .width(300.0) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .zoom(0.0) + .build() + ) .build() val overlay = Overlay.ofImage(image) @@ -140,7 +233,102 @@ internal class OverlayTest { .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .input("input") .encoding(ImageOverlay.Encoding.AUTO) - .transformation(listOf()) + .addTransformation( + Transformation.builder() + .aiChangeBackground("aiChangeBackground") + .aiDropShadowTrue() + .aiEdit("aiEdit") + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .aiRemoveBackgroundExternal( + Transformation.AiRemoveBackgroundExternal.TRUE + ) + .aiRetouch(Transformation.AiRetouch.TRUE) + .aiUpscale(Transformation.AiUpscale.TRUE) + .aiVariation(Transformation.AiVariation.TRUE) + .aspectRatio("4:3") + .audioCodec(Transformation.AudioCodec.AAC) + .background("red") + .blur(10.0) + .border("5_FF0000") + .colorProfile(true) + .contrastStretch(Transformation.ContrastStretch.TRUE) + .crop(Transformation.Crop.FORCE) + .cropMode(Transformation.CropMode.PAD_RESIZE) + .defaultImage("defaultImage") + .dpr(2.0) + .duration(0.0) + .endOffset(0.0) + .flip(Transformation.Flip.H) + .focus("center") + .format(Transformation.Format.AUTO) + .gradientTrue() + .grayscale(Transformation.Grayscale.TRUE) + .height(200.0) + .lossless(true) + .metadata(true) + .named("named") + .opacity(0.0) + .original(true) + .overlay( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing( + OverlayTiming.builder() + .duration(0.0) + .end(0.0) + .start(0.0) + .build() + ) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment( + TextOverlayTransformation.InnerAlignment.LEFT + ) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + ) + .page(0.0) + .progressive(true) + .quality(80.0) + .radius(20.0) + .raw("raw") + .rotation(90.0) + .shadowTrue() + .sharpenTrue() + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trimTrue() + .unsharpMaskTrue() + .videoCodec(Transformation.VideoCodec.H264) + .width(300.0) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .zoom(0.0) + .build() + ) .build() ) @@ -164,7 +352,100 @@ internal class OverlayTest { .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .input("input") .encoding(VideoOverlay.Encoding.AUTO) - .transformation(listOf()) + .addTransformation( + Transformation.builder() + .aiChangeBackground("aiChangeBackground") + .aiDropShadowTrue() + .aiEdit("aiEdit") + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) + .aiRetouch(Transformation.AiRetouch.TRUE) + .aiUpscale(Transformation.AiUpscale.TRUE) + .aiVariation(Transformation.AiVariation.TRUE) + .aspectRatio("4:3") + .audioCodec(Transformation.AudioCodec.AAC) + .background("red") + .blur(10.0) + .border("5_FF0000") + .colorProfile(true) + .contrastStretch(Transformation.ContrastStretch.TRUE) + .crop(Transformation.Crop.FORCE) + .cropMode(Transformation.CropMode.PAD_RESIZE) + .defaultImage("defaultImage") + .dpr(2.0) + .duration(0.0) + .endOffset(0.0) + .flip(Transformation.Flip.H) + .focus("center") + .format(Transformation.Format.AUTO) + .gradientTrue() + .grayscale(Transformation.Grayscale.TRUE) + .height(200.0) + .lossless(true) + .metadata(true) + .named("named") + .opacity(0.0) + .original(true) + .overlay( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing( + OverlayTiming.builder() + .duration(0.0) + .end(0.0) + .start(0.0) + .build() + ) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment( + TextOverlayTransformation.InnerAlignment.LEFT + ) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + ) + .page(0.0) + .progressive(true) + .quality(80.0) + .radius(20.0) + .raw("raw") + .rotation(90.0) + .shadowTrue() + .sharpenTrue() + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trimTrue() + .unsharpMaskTrue() + .videoCodec(Transformation.VideoCodec.H264) + .width(300.0) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .zoom(0.0) + .build() + ) .build() val overlay = Overlay.ofVideo(video) @@ -192,7 +473,102 @@ internal class OverlayTest { .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .input("input") .encoding(VideoOverlay.Encoding.AUTO) - .transformation(listOf()) + .addTransformation( + Transformation.builder() + .aiChangeBackground("aiChangeBackground") + .aiDropShadowTrue() + .aiEdit("aiEdit") + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .aiRemoveBackgroundExternal( + Transformation.AiRemoveBackgroundExternal.TRUE + ) + .aiRetouch(Transformation.AiRetouch.TRUE) + .aiUpscale(Transformation.AiUpscale.TRUE) + .aiVariation(Transformation.AiVariation.TRUE) + .aspectRatio("4:3") + .audioCodec(Transformation.AudioCodec.AAC) + .background("red") + .blur(10.0) + .border("5_FF0000") + .colorProfile(true) + .contrastStretch(Transformation.ContrastStretch.TRUE) + .crop(Transformation.Crop.FORCE) + .cropMode(Transformation.CropMode.PAD_RESIZE) + .defaultImage("defaultImage") + .dpr(2.0) + .duration(0.0) + .endOffset(0.0) + .flip(Transformation.Flip.H) + .focus("center") + .format(Transformation.Format.AUTO) + .gradientTrue() + .grayscale(Transformation.Grayscale.TRUE) + .height(200.0) + .lossless(true) + .metadata(true) + .named("named") + .opacity(0.0) + .original(true) + .overlay( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing( + OverlayTiming.builder() + .duration(0.0) + .end(0.0) + .start(0.0) + .build() + ) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment( + TextOverlayTransformation.InnerAlignment.LEFT + ) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + ) + .page(0.0) + .progressive(true) + .quality(80.0) + .radius(20.0) + .raw("raw") + .rotation(90.0) + .shadowTrue() + .sharpenTrue() + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trimTrue() + .unsharpMaskTrue() + .videoCodec(Transformation.VideoCodec.H264) + .width(300.0) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .zoom(0.0) + .build() + ) .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt index a475e8e1..c5b2b7db 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt @@ -58,6 +58,45 @@ internal class SrcOptionsTest { .named("named") .opacity(0.0) .original(true) + .overlay( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing( + OverlayTiming.builder() + .duration(0.0) + .end(0.0) + .start(0.0) + .build() + ) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment( + TextOverlayTransformation.InnerAlignment.LEFT + ) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + ) .page(0.0) .progressive(true) .quality(80.0) @@ -127,6 +166,39 @@ internal class SrcOptionsTest { .named("named") .opacity(0.0) .original(true) + .overlay( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing( + OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build() + ) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + ) .page(0.0) .progressive(true) .quality(80.0) @@ -199,6 +271,45 @@ internal class SrcOptionsTest { .named("named") .opacity(0.0) .original(true) + .overlay( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing( + OverlayTiming.builder() + .duration(0.0) + .end(0.0) + .start(0.0) + .build() + ) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment( + TextOverlayTransformation.InnerAlignment.LEFT + ) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + ) .page(0.0) .progressive(true) .quality(80.0) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt index 3dee6fd4..e90e156b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt @@ -46,6 +46,37 @@ internal class TransformationTest { .named("named") .opacity(0.0) .original(true) + .overlay( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + ) .page(0.0) .progressive(true) .quality(80.0) @@ -102,6 +133,40 @@ internal class TransformationTest { assertThat(transformation.named()).contains("named") assertThat(transformation.opacity()).contains(0.0) assertThat(transformation.original()).contains(true) + assertThat(transformation.overlay()) + .contains( + Overlay.ofText( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + ) + ) assertThat(transformation.page()).contains(Transformation.Page.ofNumber(0.0)) assertThat(transformation.progressive()).contains(true) assertThat(transformation.quality()).contains(80.0) @@ -161,6 +226,37 @@ internal class TransformationTest { .named("named") .opacity(0.0) .original(true) + .overlay( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + ) .page(0.0) .progressive(true) .quality(80.0) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt index caca3a99..2f25fe21 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt @@ -24,7 +24,100 @@ internal class VideoOverlayTest { .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .input("input") .encoding(VideoOverlay.Encoding.AUTO) - .transformation(listOf()) + .addTransformation( + Transformation.builder() + .aiChangeBackground("aiChangeBackground") + .aiDropShadowTrue() + .aiEdit("aiEdit") + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) + .aiRetouch(Transformation.AiRetouch.TRUE) + .aiUpscale(Transformation.AiUpscale.TRUE) + .aiVariation(Transformation.AiVariation.TRUE) + .aspectRatio("4:3") + .audioCodec(Transformation.AudioCodec.AAC) + .background("red") + .blur(10.0) + .border("5_FF0000") + .colorProfile(true) + .contrastStretch(Transformation.ContrastStretch.TRUE) + .crop(Transformation.Crop.FORCE) + .cropMode(Transformation.CropMode.PAD_RESIZE) + .defaultImage("defaultImage") + .dpr(2.0) + .duration(0.0) + .endOffset(0.0) + .flip(Transformation.Flip.H) + .focus("center") + .format(Transformation.Format.AUTO) + .gradientTrue() + .grayscale(Transformation.Grayscale.TRUE) + .height(200.0) + .lossless(true) + .metadata(true) + .named("named") + .opacity(0.0) + .original(true) + .overlay( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing( + OverlayTiming.builder() + .duration(0.0) + .end(0.0) + .start(0.0) + .build() + ) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment( + TextOverlayTransformation.InnerAlignment.LEFT + ) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + ) + .page(0.0) + .progressive(true) + .quality(80.0) + .radius(20.0) + .raw("raw") + .rotation(90.0) + .shadowTrue() + .sharpenTrue() + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trimTrue() + .unsharpMaskTrue() + .videoCodec(Transformation.VideoCodec.H264) + .width(300.0) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .zoom(0.0) + .build() + ) .build() assertThat(videoOverlay.position()) @@ -35,7 +128,95 @@ internal class VideoOverlayTest { .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) assertThat(videoOverlay.input()).isEqualTo("input") assertThat(videoOverlay.encoding()).contains(VideoOverlay.Encoding.AUTO) - assertThat(videoOverlay.transformation().getOrNull()).containsExactly() + assertThat(videoOverlay.transformation().getOrNull()) + .containsExactly( + Transformation.builder() + .aiChangeBackground("aiChangeBackground") + .aiDropShadowTrue() + .aiEdit("aiEdit") + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) + .aiRetouch(Transformation.AiRetouch.TRUE) + .aiUpscale(Transformation.AiUpscale.TRUE) + .aiVariation(Transformation.AiVariation.TRUE) + .aspectRatio("4:3") + .audioCodec(Transformation.AudioCodec.AAC) + .background("red") + .blur(10.0) + .border("5_FF0000") + .colorProfile(true) + .contrastStretch(Transformation.ContrastStretch.TRUE) + .crop(Transformation.Crop.FORCE) + .cropMode(Transformation.CropMode.PAD_RESIZE) + .defaultImage("defaultImage") + .dpr(2.0) + .duration(0.0) + .endOffset(0.0) + .flip(Transformation.Flip.H) + .focus("center") + .format(Transformation.Format.AUTO) + .gradientTrue() + .grayscale(Transformation.Grayscale.TRUE) + .height(200.0) + .lossless(true) + .metadata(true) + .named("named") + .opacity(0.0) + .original(true) + .overlay( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing( + OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build() + ) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + ) + .page(0.0) + .progressive(true) + .quality(80.0) + .radius(20.0) + .raw("raw") + .rotation(90.0) + .shadowTrue() + .sharpenTrue() + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trimTrue() + .unsharpMaskTrue() + .videoCodec(Transformation.VideoCodec.H264) + .width(300.0) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .zoom(0.0) + .build() + ) } @Test @@ -53,7 +234,100 @@ internal class VideoOverlayTest { .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .input("input") .encoding(VideoOverlay.Encoding.AUTO) - .transformation(listOf()) + .addTransformation( + Transformation.builder() + .aiChangeBackground("aiChangeBackground") + .aiDropShadowTrue() + .aiEdit("aiEdit") + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) + .aiRetouch(Transformation.AiRetouch.TRUE) + .aiUpscale(Transformation.AiUpscale.TRUE) + .aiVariation(Transformation.AiVariation.TRUE) + .aspectRatio("4:3") + .audioCodec(Transformation.AudioCodec.AAC) + .background("red") + .blur(10.0) + .border("5_FF0000") + .colorProfile(true) + .contrastStretch(Transformation.ContrastStretch.TRUE) + .crop(Transformation.Crop.FORCE) + .cropMode(Transformation.CropMode.PAD_RESIZE) + .defaultImage("defaultImage") + .dpr(2.0) + .duration(0.0) + .endOffset(0.0) + .flip(Transformation.Flip.H) + .focus("center") + .format(Transformation.Format.AUTO) + .gradientTrue() + .grayscale(Transformation.Grayscale.TRUE) + .height(200.0) + .lossless(true) + .metadata(true) + .named("named") + .opacity(0.0) + .original(true) + .overlay( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing( + OverlayTiming.builder() + .duration(0.0) + .end(0.0) + .start(0.0) + .build() + ) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment( + TextOverlayTransformation.InnerAlignment.LEFT + ) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + ) + .page(0.0) + .progressive(true) + .quality(80.0) + .radius(20.0) + .raw("raw") + .rotation(90.0) + .shadowTrue() + .sharpenTrue() + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trimTrue() + .unsharpMaskTrue() + .videoCodec(Transformation.VideoCodec.H264) + .width(300.0) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .zoom(0.0) + .build() + ) .build() val roundtrippedVideoOverlay = From 86ca3d7d9676b6a07f1930195a8dd5dacf12714a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 24 Sep 2025 04:46:50 +0000 Subject: [PATCH 041/142] chore(internal): change some comment formatting --- .../com/imagekit/api/models/beta/v2/files/FileUploadParams.kt | 4 ++-- .../kotlin/com/imagekit/api/models/files/FileUploadParams.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt index dfca90aa..3391b120 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt @@ -3461,7 +3461,7 @@ private constructor( ) { /** - * List of transformations to apply _after_ the file is uploaded. Each item must match one + * List of transformations to apply *after* the file is uploaded. Each item must match one * of the following types: `transformation`, `gif-to-video`, `thumbnail`, `abs`. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -3525,7 +3525,7 @@ private constructor( } /** - * List of transformations to apply _after_ the file is uploaded. Each item must match + * List of transformations to apply *after* the file is uploaded. Each item must match * one of the following types: `transformation`, `gif-to-video`, `thumbnail`, `abs`. */ fun post(post: List) = post(MultipartField.of(post)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt index ad7c211a..59aec7a5 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -3727,7 +3727,7 @@ private constructor( ) { /** - * List of transformations to apply _after_ the file is uploaded. Each item must match one + * List of transformations to apply *after* the file is uploaded. Each item must match one * of the following types: `transformation`, `gif-to-video`, `thumbnail`, `abs`. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -3791,7 +3791,7 @@ private constructor( } /** - * List of transformations to apply _after_ the file is uploaded. Each item must match + * List of transformations to apply *after* the file is uploaded. Each item must match * one of the following types: `transformation`, `gif-to-video`, `thumbnail`, `abs`. */ fun post(post: List) = post(MultipartField.of(post)) From 8ccff9bc6b39dbd306eb5325a830bbadc0053585 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 26 Sep 2025 02:48:15 +0000 Subject: [PATCH 042/142] fix(client): deserialization of empty objects --- .../main/kotlin/com/imagekit/api/models/BaseOverlay.kt | 1 + .../main/kotlin/com/imagekit/api/models/ImageOverlay.kt | 1 + .../kotlin/com/imagekit/api/models/OverlayPosition.kt | 1 + .../main/kotlin/com/imagekit/api/models/OverlayTiming.kt | 1 + .../kotlin/com/imagekit/api/models/SolidColorOverlay.kt | 1 + .../api/models/SolidColorOverlayTransformation.kt | 1 + .../main/kotlin/com/imagekit/api/models/SrcOptions.kt | 1 + .../kotlin/com/imagekit/api/models/SubtitleOverlay.kt | 1 + .../imagekit/api/models/SubtitleOverlayTransformation.kt | 1 + .../main/kotlin/com/imagekit/api/models/TextOverlay.kt | 1 + .../com/imagekit/api/models/TextOverlayTransformation.kt | 1 + .../kotlin/com/imagekit/api/models/Transformation.kt | 1 + .../main/kotlin/com/imagekit/api/models/VideoOverlay.kt | 1 + .../api/models/accounts/origins/OriginRequest.kt | 8 ++++++++ .../api/models/accounts/origins/OriginResponse.kt | 8 ++++++++ .../models/accounts/urlendpoints/UrlEndpointRequest.kt | 2 ++ .../models/accounts/urlendpoints/UrlEndpointResponse.kt | 2 ++ .../api/models/accounts/usage/UsageGetResponse.kt | 1 + .../api/models/beta/v2/files/FileUploadResponse.kt | 4 ++++ .../cache/invalidation/InvalidationCreateParams.kt | 1 + .../cache/invalidation/InvalidationCreateResponse.kt | 1 + .../models/cache/invalidation/InvalidationGetResponse.kt | 1 + .../models/custommetadatafields/CustomMetadataField.kt | 2 ++ .../CustomMetadataFieldCreateParams.kt | 2 ++ .../CustomMetadataFieldDeleteResponse.kt | 1 + .../CustomMetadataFieldUpdateParams.kt | 2 ++ .../main/kotlin/com/imagekit/api/models/files/File.kt | 3 +++ .../com/imagekit/api/models/files/FileCopyParams.kt | 1 + .../com/imagekit/api/models/files/FileCopyResponse.kt | 1 + .../com/imagekit/api/models/files/FileMoveParams.kt | 1 + .../com/imagekit/api/models/files/FileMoveResponse.kt | 1 + .../com/imagekit/api/models/files/FileRenameParams.kt | 1 + .../com/imagekit/api/models/files/FileRenameResponse.kt | 1 + .../com/imagekit/api/models/files/FileUpdateResponse.kt | 2 ++ .../com/imagekit/api/models/files/FileUploadResponse.kt | 4 ++++ .../main/kotlin/com/imagekit/api/models/files/Folder.kt | 1 + .../kotlin/com/imagekit/api/models/files/Metadata.kt | 7 +++++++ .../com/imagekit/api/models/files/UpdateFileRequest.kt | 6 ++++++ .../imagekit/api/models/files/bulk/BulkAddTagsParams.kt | 1 + .../api/models/files/bulk/BulkAddTagsResponse.kt | 1 + .../imagekit/api/models/files/bulk/BulkDeleteParams.kt | 1 + .../imagekit/api/models/files/bulk/BulkDeleteResponse.kt | 1 + .../api/models/files/bulk/BulkRemoveAiTagsParams.kt | 1 + .../api/models/files/bulk/BulkRemoveAiTagsResponse.kt | 1 + .../api/models/files/bulk/BulkRemoveTagsParams.kt | 1 + .../api/models/files/bulk/BulkRemoveTagsResponse.kt | 1 + .../api/models/files/versions/VersionDeleteResponse.kt | 1 + .../com/imagekit/api/models/folders/FolderCopyParams.kt | 1 + .../imagekit/api/models/folders/FolderCopyResponse.kt | 1 + .../imagekit/api/models/folders/FolderCreateParams.kt | 1 + .../imagekit/api/models/folders/FolderCreateResponse.kt | 1 + .../imagekit/api/models/folders/FolderDeleteParams.kt | 1 + .../imagekit/api/models/folders/FolderDeleteResponse.kt | 1 + .../com/imagekit/api/models/folders/FolderMoveParams.kt | 1 + .../imagekit/api/models/folders/FolderMoveResponse.kt | 1 + .../imagekit/api/models/folders/FolderRenameParams.kt | 1 + .../imagekit/api/models/folders/FolderRenameResponse.kt | 1 + .../imagekit/api/models/folders/job/JobGetResponse.kt | 1 + .../com/imagekit/api/models/webhooks/BaseWebhookEvent.kt | 1 + .../api/models/webhooks/UploadPostTransformErrorEvent.kt | 6 ++++++ .../models/webhooks/UploadPostTransformSuccessEvent.kt | 4 ++++ .../api/models/webhooks/UploadPreTransformErrorEvent.kt | 5 +++++ .../models/webhooks/UploadPreTransformSuccessEvent.kt | 6 ++++++ .../models/webhooks/VideoTransformationAcceptedEvent.kt | 6 ++++++ .../api/models/webhooks/VideoTransformationErrorEvent.kt | 7 +++++++ .../api/models/webhooks/VideoTransformationReadyEvent.kt | 9 +++++++++ 66 files changed, 141 insertions(+) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/BaseOverlay.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/BaseOverlay.kt index 7030982b..20f7a1ac 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/BaseOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/BaseOverlay.kt @@ -17,6 +17,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class BaseOverlay +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val position: JsonField, private val timing: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ImageOverlay.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ImageOverlay.kt index 3c5b235f..eeb14140 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ImageOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ImageOverlay.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class ImageOverlay +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val position: JsonField, private val timing: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt index 42f5e18e..1ad0cf1d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt @@ -29,6 +29,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class OverlayPosition +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val focus: JsonField, private val x: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayTiming.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayTiming.kt index 4d94f499..27365d42 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayTiming.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayTiming.kt @@ -28,6 +28,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class OverlayTiming +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val duration: JsonField, private val end: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlay.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlay.kt index 882fbd6c..f9215069 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlay.kt @@ -20,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class SolidColorOverlay +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val position: JsonField, private val timing: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt index 8d69770f..b4db2465 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt @@ -28,6 +28,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class SolidColorOverlayTransformation +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val alpha: JsonField, private val background: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SrcOptions.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SrcOptions.kt index 24c50b25..ff3827ea 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SrcOptions.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SrcOptions.kt @@ -24,6 +24,7 @@ import kotlin.jvm.optionals.getOrNull * [Transformations guide](https://imagekit.io/docs/transformations). */ class SrcOptions +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val src: JsonField, private val urlEndpoint: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlay.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlay.kt index 6a0485c3..02463135 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlay.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class SubtitleOverlay +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val position: JsonField, private val timing: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlayTransformation.kt index 11c122df..d75c55bb 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlayTransformation.kt @@ -23,6 +23,7 @@ import kotlin.jvm.optionals.getOrNull * from the docs. */ class SubtitleOverlayTransformation +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val background: JsonField, private val color: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlay.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlay.kt index 6bd7dfef..679b0f68 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlay.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class TextOverlay +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val position: JsonField, private val timing: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt index c29f846b..cad7948e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt @@ -29,6 +29,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class TextOverlayTransformation +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val alpha: JsonField, private val background: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt index ee1ca86e..578ba09a 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt @@ -38,6 +38,7 @@ import kotlin.jvm.optionals.getOrNull * [Transformations documentation](https://imagekit.io/docs/transformations). */ class Transformation +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val aiChangeBackground: JsonField, private val aiDropShadow: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VideoOverlay.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VideoOverlay.kt index 2ca94d24..8721b3ae 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VideoOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VideoOverlay.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class VideoOverlay +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val position: JsonField, private val timing: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginRequest.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginRequest.kt index 56eb7949..ba4d09bc 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginRequest.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginRequest.kt @@ -364,6 +364,7 @@ private constructor( } class S3 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accessKey: JsonField, private val bucket: JsonField, @@ -821,6 +822,7 @@ private constructor( } class S3Compatible + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accessKey: JsonField, private val bucket: JsonField, @@ -1364,6 +1366,7 @@ private constructor( } class CloudinaryBackup + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accessKey: JsonField, private val bucket: JsonField, @@ -1821,6 +1824,7 @@ private constructor( } class WebFolder + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val baseUrl: JsonField, private val name: JsonField, @@ -2205,6 +2209,7 @@ private constructor( } class WebProxy + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, private val type: JsonValue, @@ -2498,6 +2503,7 @@ private constructor( } class Gcs + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val bucket: JsonField, private val clientEmail: JsonField, @@ -2949,6 +2955,7 @@ private constructor( } class AzureBlob + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountName: JsonField, private val container: JsonField, @@ -3400,6 +3407,7 @@ private constructor( } class AkeneoPim + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val baseUrl: JsonField, private val clientId: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginResponse.kt index 5f8eed29..4b04735c 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginResponse.kt @@ -365,6 +365,7 @@ private constructor( } class S3 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val bucket: JsonField, @@ -787,6 +788,7 @@ private constructor( } class S3Compatible + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val bucket: JsonField, @@ -1297,6 +1299,7 @@ private constructor( } class CloudinaryBackup + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val bucket: JsonField, @@ -1719,6 +1722,7 @@ private constructor( } class WebFolder + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val baseUrl: JsonField, @@ -2150,6 +2154,7 @@ private constructor( } class WebProxy + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val includeCanonicalHeader: JsonField, @@ -2487,6 +2492,7 @@ private constructor( } class Gcs + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val bucket: JsonField, @@ -2945,6 +2951,7 @@ private constructor( } class AzureBlob + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val accountName: JsonField, @@ -3405,6 +3412,7 @@ private constructor( } class AkeneoPim + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val baseUrl: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequest.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequest.kt index 40f3d600..cfb1f51f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequest.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequest.kt @@ -31,6 +31,7 @@ import kotlin.jvm.optionals.getOrNull /** Schema for URL endpoint resource. */ class UrlEndpointRequest +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val description: JsonField, private val origins: JsonField>, @@ -529,6 +530,7 @@ private constructor( } class Cloudinary + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val type: JsonValue, private val preserveAssetDeliveryTypes: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponse.kt index e6bbbd71..90b2b7ad 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponse.kt @@ -31,6 +31,7 @@ import kotlin.jvm.optionals.getOrNull /** URL‑endpoint object as returned by the API. */ class UrlEndpointResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val description: JsonField, @@ -587,6 +588,7 @@ private constructor( } class Cloudinary + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val preserveAssetDeliveryTypes: JsonField, private val type: JsonValue, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponse.kt index 3239c0ed..f8065d3d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponse.kt @@ -16,6 +16,7 @@ import java.util.Objects import java.util.Optional class UsageGetResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val bandwidthBytes: JsonField, private val extensionUnitsCount: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt index 2b6fd59d..7214d2ba 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt @@ -22,6 +22,7 @@ import kotlin.jvm.optionals.getOrNull /** Object containing details of a successful upload. */ class FileUploadResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val aiTags: JsonField>, private val audioCodec: JsonField, @@ -1106,6 +1107,7 @@ private constructor( (if (width.asKnown().isPresent) 1 else 0) class AiTag + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val confidence: JsonField, private val name: JsonField, @@ -1547,6 +1549,7 @@ private constructor( * If no extension was requested, then this parameter is not returned. */ class ExtensionStatus + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val aiAutoDescription: JsonField, private val awsAutoTagging: JsonField, @@ -2376,6 +2379,7 @@ private constructor( /** An object containing the file or file version's `id` (versionId) and `name`. */ class VersionInfo + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val name: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParams.kt index 1fe6f16e..3f4985aa 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParams.kt @@ -245,6 +245,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val url: JsonField, private val additionalProperties: MutableMap, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponse.kt index 51e74c57..beddefa3 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponse.kt @@ -16,6 +16,7 @@ import java.util.Objects import java.util.Optional class InvalidationCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val requestId: JsonField, private val additionalProperties: MutableMap, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponse.kt index 74befb58..eb953ad6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponse.kt @@ -18,6 +18,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class InvalidationGetResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val status: JsonField, private val additionalProperties: MutableMap, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt index f69779fe..1d5dff3f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt @@ -33,6 +33,7 @@ import kotlin.jvm.optionals.getOrNull /** Object containing details of a custom metadata field. */ class CustomMetadataField +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val label: JsonField, @@ -287,6 +288,7 @@ private constructor( /** An object that describes the rules for the custom metadata field value. */ class Schema + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val type: JsonField, private val defaultValue: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt index 254e574f..c3f218b0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt @@ -331,6 +331,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val label: JsonField, private val name: JsonField, @@ -574,6 +575,7 @@ private constructor( } class Schema + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val type: JsonField, private val defaultValue: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt index 7ec2f007..ddfd5eaa 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class CustomMetadataFieldDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt index b866dd92..a76a1adf 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt @@ -307,6 +307,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val label: JsonField, private val schema: JsonField, @@ -503,6 +504,7 @@ private constructor( * `schema`. The schema will be validated as per the existing `type`. */ class Schema + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val defaultValue: JsonField, private val isValueRequired: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt index f0b39c85..197be28a 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt @@ -22,6 +22,7 @@ import kotlin.jvm.optionals.getOrNull /** Object containing details of a file or file version. */ class File +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val aiTags: JsonField>, private val createdAt: JsonField, @@ -970,6 +971,7 @@ private constructor( (if (width.asKnown().isPresent) 1 else 0) class AiTag + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val confidence: JsonField, private val name: JsonField, @@ -1418,6 +1420,7 @@ private constructor( /** An object with details of the file version. */ class VersionInfo + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val name: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyParams.kt index 7fb1d9df..1256c678 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyParams.kt @@ -320,6 +320,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val destinationPath: JsonField, private val sourceFilePath: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyResponse.kt index b3b4affb..ae3f5bf1 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class FileCopyResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveParams.kt index f4e3c64a..e8a9761e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveParams.kt @@ -280,6 +280,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val destinationPath: JsonField, private val sourceFilePath: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveResponse.kt index 726f9e26..7f946c51 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class FileMoveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameParams.kt index 2b7b4b57..0fe5f024 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameParams.kt @@ -344,6 +344,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val filePath: JsonField, private val newFileName: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameResponse.kt index 3f9dc4c5..e8707efe 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameResponse.kt @@ -16,6 +16,7 @@ import java.util.Objects import java.util.Optional class FileRenameResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val purgeRequestId: JsonField, private val additionalProperties: MutableMap, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt index d8ecc3ec..79bbe2bd 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt @@ -22,6 +22,7 @@ import kotlin.jvm.optionals.getOrNull /** Object containing details of a file or file version. */ class FileUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val aiTags: JsonField>, private val createdAt: JsonField, @@ -1039,6 +1040,7 @@ private constructor( (extensionStatus.asKnown().getOrNull()?.validity() ?: 0) class ExtensionStatus + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val aiAutoDescription: JsonField, private val awsAutoTagging: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt index 3323941e..fe96fb9a 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt @@ -21,6 +21,7 @@ import kotlin.jvm.optionals.getOrNull /** Object containing details of a successful upload. */ class FileUploadResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val aiTags: JsonField>, private val audioCodec: JsonField, @@ -1105,6 +1106,7 @@ private constructor( (if (width.asKnown().isPresent) 1 else 0) class AiTag + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val confidence: JsonField, private val name: JsonField, @@ -1546,6 +1548,7 @@ private constructor( * If no extension was requested, then this parameter is not returned. */ class ExtensionStatus + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val aiAutoDescription: JsonField, private val awsAutoTagging: JsonField, @@ -2375,6 +2378,7 @@ private constructor( /** An object containing the file or file version's `id` (versionId) and `name`. */ class VersionInfo + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val name: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Folder.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Folder.kt index 3e7c9a34..0a3a88f7 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Folder.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Folder.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class Folder +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val createdAt: JsonField, private val folderId: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Metadata.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Metadata.kt index 69891ec1..ea625eaa 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Metadata.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Metadata.kt @@ -20,6 +20,7 @@ import kotlin.jvm.optionals.getOrNull /** JSON object containing metadata. */ class Metadata +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val audioCodec: JsonField, private val bitRate: JsonField, @@ -610,6 +611,7 @@ private constructor( (if (width.asKnown().isPresent) 1 else 0) class Exif + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val exif: JsonField, private val gps: JsonField, @@ -923,6 +925,7 @@ private constructor( /** Object containing Exif details. */ class InnerExif + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val apertureValue: JsonField, private val colorSpace: JsonField, @@ -2109,6 +2112,7 @@ private constructor( /** Object containing GPS information. */ class Gps + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val gpsVersionId: JsonField>, private val additionalProperties: MutableMap, @@ -2275,6 +2279,7 @@ private constructor( /** Object containing EXIF image information. */ class Image + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val exifOffset: JsonField, private val gpsInfo: JsonField, @@ -2825,6 +2830,7 @@ private constructor( /** JSON object. */ class Interoperability + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val interopIndex: JsonField, private val interopVersion: JsonField, @@ -3123,6 +3129,7 @@ private constructor( /** Object containing Thumbnail information. */ class Thumbnail + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val compression: JsonField, private val resolutionUnit: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt index 477e67cb..ca32f900 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt @@ -218,6 +218,7 @@ private constructor( } class UpdateFileDetails + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val customCoordinates: JsonField, private val customMetadata: JsonField, @@ -1052,6 +1053,7 @@ private constructor( } class RemoveBg + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonValue, private val options: JsonField, @@ -1219,6 +1221,7 @@ private constructor( (options.asKnown().getOrNull()?.validity() ?: 0) class Options + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val addShadow: JsonField, private val bgColor: JsonField, @@ -1549,6 +1552,7 @@ private constructor( } class AutoTaggingExtension + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val maxTags: JsonField, private val minConfidence: JsonField, @@ -2164,6 +2168,7 @@ private constructor( } class ChangePublicationStatus + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val publish: JsonField, private val additionalProperties: MutableMap, @@ -2291,6 +2296,7 @@ private constructor( /** Configure the publication status of a file and its versions. */ class Publish + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val isPublished: JsonField, private val includeFileVersions: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParams.kt index c59c5207..8bbc2da9 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParams.kt @@ -292,6 +292,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val fileIds: JsonField>, private val tags: JsonField>, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponse.kt index 2cfbf744..b46409d9 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponse.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class BulkAddTagsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val successfullyUpdatedFileIds: JsonField>, private val additionalProperties: MutableMap, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParams.kt index e27e8f49..e2da50c4 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParams.kt @@ -256,6 +256,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val fileIds: JsonField>, private val additionalProperties: MutableMap, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponse.kt index 10b9af28..8f302126 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponse.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class BulkDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val successfullyDeletedFileIds: JsonField>, private val additionalProperties: MutableMap, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParams.kt index f22a019e..ccfe5368 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParams.kt @@ -293,6 +293,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val aiTags: JsonField>, private val fileIds: JsonField>, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponse.kt index 9d467351..fe19c147 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponse.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class BulkRemoveAiTagsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val successfullyUpdatedFileIds: JsonField>, private val additionalProperties: MutableMap, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParams.kt index f72a4520..38006117 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParams.kt @@ -293,6 +293,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val fileIds: JsonField>, private val tags: JsonField>, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponse.kt index 0a23ecda..b4293490 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponse.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class BulkRemoveTagsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val successfullyUpdatedFileIds: JsonField>, private val additionalProperties: MutableMap, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionDeleteResponse.kt index 1b41f618..0cb9389e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionDeleteResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class VersionDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyParams.kt index 92cb7933..66ce29e5 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyParams.kt @@ -322,6 +322,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val destinationPath: JsonField, private val sourceFolderPath: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyResponse.kt index 3373e268..b9bec4d9 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyResponse.kt @@ -17,6 +17,7 @@ import java.util.Objects /** Job submitted successfully. A `jobId` will be returned. */ class FolderCopyResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val jobId: JsonField, private val additionalProperties: MutableMap, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateParams.kt index 3976d1ed..8260f507 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateParams.kt @@ -301,6 +301,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val folderName: JsonField, private val parentFolderPath: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateResponse.kt index ca1aebd1..d82d3171 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class FolderCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteParams.kt index 0cdc8516..5cc97b7c 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteParams.kt @@ -245,6 +245,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val folderPath: JsonField, private val additionalProperties: MutableMap, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteResponse.kt index b9d17cd6..cd0cd73f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class FolderDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveParams.kt index 26539737..948dea58 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveParams.kt @@ -283,6 +283,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val destinationPath: JsonField, private val sourceFolderPath: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveResponse.kt index 7df902cc..d948d7ce 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveResponse.kt @@ -17,6 +17,7 @@ import java.util.Objects /** Job submitted successfully. A `jobId` will be returned. */ class FolderMoveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val jobId: JsonField, private val additionalProperties: MutableMap, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameParams.kt index c6564c80..3dd2d495 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameParams.kt @@ -343,6 +343,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val folderPath: JsonField, private val newFolderName: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameResponse.kt index 96bd156a..1210c3d6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameResponse.kt @@ -17,6 +17,7 @@ import java.util.Objects /** Job submitted successfully. A `jobId` will be returned. */ class FolderRenameResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val jobId: JsonField, private val additionalProperties: MutableMap, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetResponse.kt index b6ed81c2..e563ae4b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetResponse.kt @@ -18,6 +18,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class JobGetResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val jobId: JsonField, private val purgeRequestId: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/BaseWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/BaseWebhookEvent.kt index 5b0e7ede..9446ec87 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/BaseWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/BaseWebhookEvent.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class BaseWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val type: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt index d5ec74e4..9ec85370 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt @@ -24,6 +24,7 @@ import kotlin.jvm.optionals.getOrNull * requested transformation could not be generated. */ class UploadPostTransformErrorEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val type: JsonField, @@ -307,6 +308,7 @@ private constructor( (request.asKnown().getOrNull()?.validity() ?: 0) class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val fileId: JsonField, private val name: JsonField, @@ -598,6 +600,7 @@ private constructor( (if (url.asKnown().isPresent) 1 else 0) class Transformation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val error: JsonField, private val additionalProperties: MutableMap, @@ -740,6 +743,7 @@ private constructor( internal fun validity(): Int = (error.asKnown().getOrNull()?.validity() ?: 0) class Error + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val reason: JsonField, private val additionalProperties: MutableMap, @@ -945,6 +949,7 @@ private constructor( } class Request + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val transformation: JsonField, private val xRequestId: JsonField, @@ -1132,6 +1137,7 @@ private constructor( (if (xRequestId.asKnown().isPresent) 1 else 0) class Transformation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val type: JsonField, private val protocol: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt index 78cc1df5..cf6e340c 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt @@ -25,6 +25,7 @@ import kotlin.jvm.optionals.getOrNull * generates a separate webhook event. */ class UploadPostTransformSuccessEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val type: JsonField, @@ -310,6 +311,7 @@ private constructor( (request.asKnown().getOrNull()?.validity() ?: 0) class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val fileId: JsonField, private val name: JsonField, @@ -544,6 +546,7 @@ private constructor( } class Request + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val transformation: JsonField, private val xRequestId: JsonField, @@ -731,6 +734,7 @@ private constructor( (if (xRequestId.asKnown().isPresent) 1 else 0) class Transformation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val type: JsonField, private val protocol: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt index 50655f34..e346a9ca 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt @@ -22,6 +22,7 @@ import kotlin.jvm.optionals.getOrNull * requested transformation could not be applied. */ class UploadPreTransformErrorEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val type: JsonField, @@ -304,6 +305,7 @@ private constructor( (request.asKnown().getOrNull()?.validity() ?: 0) class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, private val path: JsonField, @@ -523,6 +525,7 @@ private constructor( (transformation.asKnown().getOrNull()?.validity() ?: 0) class Transformation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val error: JsonField, private val additionalProperties: MutableMap, @@ -665,6 +668,7 @@ private constructor( internal fun validity(): Int = (error.asKnown().getOrNull()?.validity() ?: 0) class Error + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val reason: JsonField, private val additionalProperties: MutableMap, @@ -868,6 +872,7 @@ private constructor( } class Request + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val transformation: JsonField, private val xRequestId: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt index 9c71f74b..f6bf26cb 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt @@ -27,6 +27,7 @@ import kotlin.jvm.optionals.getOrNull * requested transformation and is now available in the Media Library. */ class UploadPreTransformSuccessEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val type: JsonField, @@ -315,6 +316,7 @@ private constructor( /** Object containing details of a successful upload. */ class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val aiTags: JsonField>, private val audioCodec: JsonField, @@ -1440,6 +1442,7 @@ private constructor( (if (width.asKnown().isPresent) 1 else 0) class AiTag + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val confidence: JsonField, private val name: JsonField, @@ -1896,6 +1899,7 @@ private constructor( * If no extension was requested, then this parameter is not returned. */ class ExtensionStatus + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val aiAutoDescription: JsonField, private val awsAutoTagging: JsonField, @@ -2738,6 +2742,7 @@ private constructor( /** An object containing the file or file version's `id` (versionId) and `name`. */ class VersionInfo + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val name: JsonField, @@ -2986,6 +2991,7 @@ private constructor( } class Request + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val transformation: JsonField, private val xRequestId: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt index 61dbf8ac..38e493b3 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt @@ -27,6 +27,7 @@ import kotlin.jvm.optionals.getOrNull * tracking transformation lifecycle. */ class VideoTransformationAcceptedEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val type: JsonField, @@ -315,6 +316,7 @@ private constructor( (request.asKnown().getOrNull()?.validity() ?: 0) class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val asset: JsonField, private val transformation: JsonField, @@ -502,6 +504,7 @@ private constructor( /** Information about the source video asset being transformed. */ class Asset + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val url: JsonField, private val additionalProperties: MutableMap, @@ -661,6 +664,7 @@ private constructor( /** Base information about a video transformation request. */ class Transformation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val type: JsonField, private val options: JsonField, @@ -995,6 +999,7 @@ private constructor( /** Configuration options for video transformations. */ class Options + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val audioCodec: JsonField, private val autoRotate: JsonField, @@ -2041,6 +2046,7 @@ private constructor( /** Information about the original request that triggered the video transformation. */ class Request + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val url: JsonField, private val xRequestId: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt index 176f4000..e61c14b3 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt @@ -27,6 +27,7 @@ import kotlin.jvm.optionals.getOrNull * download failure. For other errors, contact ImageKit support. */ class VideoTransformationErrorEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val type: JsonField, @@ -313,6 +314,7 @@ private constructor( (request.asKnown().getOrNull()?.validity() ?: 0) class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val asset: JsonField, private val transformation: JsonField, @@ -497,6 +499,7 @@ private constructor( /** Information about the source video asset being transformed. */ class Asset + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val url: JsonField, private val additionalProperties: MutableMap, @@ -655,6 +658,7 @@ private constructor( } class Transformation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val type: JsonField, private val error: JsonField, @@ -1023,6 +1027,7 @@ private constructor( /** Details about the transformation error. */ class Error + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val reason: JsonField, private val additionalProperties: MutableMap, @@ -1341,6 +1346,7 @@ private constructor( /** Configuration options for video transformations. */ class Options + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val audioCodec: JsonField, private val autoRotate: JsonField, @@ -2390,6 +2396,7 @@ private constructor( /** Information about the original request that triggered the video transformation. */ class Request + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val url: JsonField, private val xRequestId: JsonField, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt index 005fceac..d16c228d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt @@ -27,6 +27,7 @@ import kotlin.jvm.optionals.getOrNull * your application can start showing the transformed video to users. */ class VideoTransformationReadyEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val type: JsonField, @@ -346,6 +347,7 @@ private constructor( (timings.asKnown().getOrNull()?.validity() ?: 0) class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val asset: JsonField, private val transformation: JsonField, @@ -530,6 +532,7 @@ private constructor( /** Information about the source video asset being transformed. */ class Asset + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val url: JsonField, private val additionalProperties: MutableMap, @@ -688,6 +691,7 @@ private constructor( } class Transformation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val type: JsonField, private val options: JsonField, @@ -1056,6 +1060,7 @@ private constructor( /** Configuration options for video transformations. */ class Options + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val audioCodec: JsonField, private val autoRotate: JsonField, @@ -2062,6 +2067,7 @@ private constructor( /** Information about the transformed output video. */ class Output + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val url: JsonField, private val videoMetadata: JsonField, @@ -2252,6 +2258,7 @@ private constructor( /** Metadata of the output video file. */ class VideoMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val bitrate: JsonField, private val duration: JsonField, @@ -2617,6 +2624,7 @@ private constructor( /** Information about the original request that triggered the video transformation. */ class Request + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val url: JsonField, private val xRequestId: JsonField, @@ -2858,6 +2866,7 @@ private constructor( /** Performance metrics for the transformation process. */ class Timings + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val downloadDuration: JsonField, private val encodingDuration: JsonField, From 6e2eac363b8f707a58009f6812350f45d4856da2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 30 Sep 2025 07:21:33 +0000 Subject: [PATCH 043/142] feat(api): add path policy related non-breaking changes --- .stats.yml | 4 +-- .../models/beta/v2/files/FileUploadParams.kt | 6 ++++ .../CustomMetadataFieldListParams.kt | 31 +++++++++++++++++-- .../api/models/files/FileUploadParams.kt | 6 ++++ .../async/CustomMetadataFieldServiceAsync.kt | 4 +++ .../blocking/CustomMetadataFieldService.kt | 4 +++ .../CustomMetadataFieldListParamsTest.kt | 18 +++++++++-- .../CustomMetadataFieldServiceAsyncTest.kt | 5 ++- .../CustomMetadataFieldServiceTest.kt | 5 ++- 9 files changed, 74 insertions(+), 9 deletions(-) diff --git a/.stats.yml b/.stats.yml index 7c3aae1c..da19a2b5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d1a3e6dfc45ae832b6b14a0aef25878985c679fa9f48c1470df188b1578ba648.yml -openapi_spec_hash: 1d382866fce3284f26d341f112988d9d +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-1499148ce5fc81b4d8c8b3eaadf7adfaf54df5fa0b3a0452c3f5ef0dfe884a95.yml +openapi_spec_hash: e91526b143d3e696bef2b4d0ea3aa2b4 config_hash: e42d7fc3a8c92c35099cc283f9a4467a diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt index 3391b120..004e5b27 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt @@ -3312,6 +3312,8 @@ private constructor( @JvmField val METADATA = of("metadata") + @JvmField val SELECTED_FIELDS_SCHEMA = of("selectedFieldsSchema") + @JvmStatic fun of(value: String) = ResponseField(JsonField.of(value)) } @@ -3324,6 +3326,7 @@ private constructor( IS_PUBLISHED, CUSTOM_METADATA, METADATA, + SELECTED_FIELDS_SCHEMA, } /** @@ -3343,6 +3346,7 @@ private constructor( IS_PUBLISHED, CUSTOM_METADATA, METADATA, + SELECTED_FIELDS_SCHEMA, /** * An enum member indicating that [ResponseField] was instantiated with an unknown * value. @@ -3366,6 +3370,7 @@ private constructor( IS_PUBLISHED -> Value.IS_PUBLISHED CUSTOM_METADATA -> Value.CUSTOM_METADATA METADATA -> Value.METADATA + SELECTED_FIELDS_SCHEMA -> Value.SELECTED_FIELDS_SCHEMA else -> Value._UNKNOWN } @@ -3387,6 +3392,7 @@ private constructor( IS_PUBLISHED -> Known.IS_PUBLISHED CUSTOM_METADATA -> Known.CUSTOM_METADATA METADATA -> Known.METADATA + SELECTED_FIELDS_SCHEMA -> Known.SELECTED_FIELDS_SCHEMA else -> throw ImageKitInvalidDataException("Unknown ResponseField: $value") } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParams.kt index 8ae404f5..caaf35ac 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParams.kt @@ -12,14 +12,26 @@ import kotlin.jvm.optionals.getOrNull /** * This API returns the array of created custom metadata field objects. By default the API returns * only non deleted field objects, but you can include deleted fields in the API response. + * + * You can also filter results by a specific folder path to retrieve custom metadata fields + * applicable at that location. This path-specific filtering is useful when using the **Path + * policy** feature to determine which custom metadata fields are selected for a given path. */ class CustomMetadataFieldListParams private constructor( + private val folderPath: String?, private val includeDeleted: Boolean?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { + /** + * The folder path (e.g., `/path/to/folder`) for which to retrieve applicable custom metadata + * fields. Useful for determining path-specific field selections when the + * [Path policy](https://imagekit.io/docs/dam/path-policy) feature is in use. + */ + fun folderPath(): Optional = Optional.ofNullable(folderPath) + /** Set it to `true` to include deleted field objects in the API response. */ fun includeDeleted(): Optional = Optional.ofNullable(includeDeleted) @@ -45,17 +57,29 @@ private constructor( /** A builder for [CustomMetadataFieldListParams]. */ class Builder internal constructor() { + private var folderPath: String? = null private var includeDeleted: Boolean? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(customMetadataFieldListParams: CustomMetadataFieldListParams) = apply { + folderPath = customMetadataFieldListParams.folderPath includeDeleted = customMetadataFieldListParams.includeDeleted additionalHeaders = customMetadataFieldListParams.additionalHeaders.toBuilder() additionalQueryParams = customMetadataFieldListParams.additionalQueryParams.toBuilder() } + /** + * The folder path (e.g., `/path/to/folder`) for which to retrieve applicable custom + * metadata fields. Useful for determining path-specific field selections when the + * [Path policy](https://imagekit.io/docs/dam/path-policy) feature is in use. + */ + fun folderPath(folderPath: String?) = apply { this.folderPath = folderPath } + + /** Alias for calling [Builder.folderPath] with `folderPath.orElse(null)`. */ + fun folderPath(folderPath: Optional) = folderPath(folderPath.getOrNull()) + /** Set it to `true` to include deleted field objects in the API response. */ fun includeDeleted(includeDeleted: Boolean?) = apply { this.includeDeleted = includeDeleted @@ -177,6 +201,7 @@ private constructor( */ fun build(): CustomMetadataFieldListParams = CustomMetadataFieldListParams( + folderPath, includeDeleted, additionalHeaders.build(), additionalQueryParams.build(), @@ -188,6 +213,7 @@ private constructor( override fun _queryParams(): QueryParams = QueryParams.builder() .apply { + folderPath?.let { put("folderPath", it) } includeDeleted?.let { put("includeDeleted", it.toString()) } putAll(additionalQueryParams) } @@ -199,14 +225,15 @@ private constructor( } return other is CustomMetadataFieldListParams && + folderPath == other.folderPath && includeDeleted == other.includeDeleted && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(includeDeleted, additionalHeaders, additionalQueryParams) + Objects.hash(folderPath, includeDeleted, additionalHeaders, additionalQueryParams) override fun toString() = - "CustomMetadataFieldListParams{includeDeleted=$includeDeleted, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "CustomMetadataFieldListParams{folderPath=$folderPath, includeDeleted=$includeDeleted, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt index 59aec7a5..e5b9c421 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -3578,6 +3578,8 @@ private constructor( @JvmField val METADATA = of("metadata") + @JvmField val SELECTED_FIELDS_SCHEMA = of("selectedFieldsSchema") + @JvmStatic fun of(value: String) = ResponseField(JsonField.of(value)) } @@ -3590,6 +3592,7 @@ private constructor( IS_PUBLISHED, CUSTOM_METADATA, METADATA, + SELECTED_FIELDS_SCHEMA, } /** @@ -3609,6 +3612,7 @@ private constructor( IS_PUBLISHED, CUSTOM_METADATA, METADATA, + SELECTED_FIELDS_SCHEMA, /** * An enum member indicating that [ResponseField] was instantiated with an unknown * value. @@ -3632,6 +3636,7 @@ private constructor( IS_PUBLISHED -> Value.IS_PUBLISHED CUSTOM_METADATA -> Value.CUSTOM_METADATA METADATA -> Value.METADATA + SELECTED_FIELDS_SCHEMA -> Value.SELECTED_FIELDS_SCHEMA else -> Value._UNKNOWN } @@ -3653,6 +3658,7 @@ private constructor( IS_PUBLISHED -> Known.IS_PUBLISHED CUSTOM_METADATA -> Known.CUSTOM_METADATA METADATA -> Known.METADATA + SELECTED_FIELDS_SCHEMA -> Known.SELECTED_FIELDS_SCHEMA else -> throw ImageKitInvalidDataException("Unknown ResponseField: $value") } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsync.kt index 6d7d7c13..77621817 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsync.kt @@ -79,6 +79,10 @@ interface CustomMetadataFieldServiceAsync { * This API returns the array of created custom metadata field objects. By default the API * returns only non deleted field objects, but you can include deleted fields in the API * response. + * + * You can also filter results by a specific folder path to retrieve custom metadata fields + * applicable at that location. This path-specific filtering is useful when using the **Path + * policy** feature to determine which custom metadata fields are selected for a given path. */ fun list(): CompletableFuture> = list(CustomMetadataFieldListParams.none()) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldService.kt index bd644eeb..e9751f5a 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldService.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldService.kt @@ -77,6 +77,10 @@ interface CustomMetadataFieldService { * This API returns the array of created custom metadata field objects. By default the API * returns only non deleted field objects, but you can include deleted fields in the API * response. + * + * You can also filter results by a specific folder path to retrieve custom metadata fields + * applicable at that location. This path-specific filtering is useful when using the **Path + * policy** feature to determine which custom metadata fields are selected for a given path. */ fun list(): List = list(CustomMetadataFieldListParams.none()) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt index df9806ae..395d54c2 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt @@ -10,17 +10,29 @@ internal class CustomMetadataFieldListParamsTest { @Test fun create() { - CustomMetadataFieldListParams.builder().includeDeleted(true).build() + CustomMetadataFieldListParams.builder() + .folderPath("folderPath") + .includeDeleted(true) + .build() } @Test fun queryParams() { - val params = CustomMetadataFieldListParams.builder().includeDeleted(true).build() + val params = + CustomMetadataFieldListParams.builder() + .folderPath("folderPath") + .includeDeleted(true) + .build() val queryParams = params._queryParams() assertThat(queryParams) - .isEqualTo(QueryParams.builder().put("includeDeleted", "true").build()) + .isEqualTo( + QueryParams.builder() + .put("folderPath", "folderPath") + .put("includeDeleted", "true") + .build() + ) } @Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt index 1d361052..99e2bc5a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt @@ -134,7 +134,10 @@ internal class CustomMetadataFieldServiceAsyncTest { val customMetadataFieldsFuture = customMetadataFieldServiceAsync.list( - CustomMetadataFieldListParams.builder().includeDeleted(true).build() + CustomMetadataFieldListParams.builder() + .folderPath("folderPath") + .includeDeleted(true) + .build() ) val customMetadataFields = customMetadataFieldsFuture.get() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt index 5a39a789..d7cf6630 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt @@ -132,7 +132,10 @@ internal class CustomMetadataFieldServiceTest { val customMetadataFields = customMetadataFieldService.list( - CustomMetadataFieldListParams.builder().includeDeleted(true).build() + CustomMetadataFieldListParams.builder() + .folderPath("folderPath") + .includeDeleted(true) + .build() ) customMetadataFields.forEach { it.validate() } From bff74feabf748f922f897e3ca0a62e5cbe0fde0f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 30 Sep 2025 07:24:38 +0000 Subject: [PATCH 044/142] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index da19a2b5..6b1c558b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-1499148ce5fc81b4d8c8b3eaadf7adfaf54df5fa0b3a0452c3f5ef0dfe884a95.yml -openapi_spec_hash: e91526b143d3e696bef2b4d0ea3aa2b4 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-8d944c932f09191791cc09e90ebf8142e523c0a6dd82ae9d1dbd7ff884acfc4b.yml +openapi_spec_hash: 179e38a7a472a5f98d17aed41099cbfd config_hash: e42d7fc3a8c92c35099cc283f9a4467a From 34289ae2c42a258e56ad87133c9eff209b248163 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 30 Sep 2025 07:29:04 +0000 Subject: [PATCH 045/142] feat(api): add selectedFieldsSchema in upload and list API response --- .stats.yml | 4 +- .../models/beta/v2/files/FileUploadParams.kt | 206 +++++++++- .../com/imagekit/api/models/files/File.kt | 172 +++++++- .../api/models/files/FileUpdateResponse.kt | 64 ++- .../api/models/files/FileUploadParams.kt | 206 +++++++++- .../models/assets/AssetListResponseTest.kt | 44 +++ .../beta/v2/files/FileUploadParamsTest.kt | 73 ++++ .../com/imagekit/api/models/files/FileTest.kt | 66 ++++ .../models/files/FileUpdateResponseTest.kt | 66 ++++ .../api/models/files/FileUploadParamsTest.kt | 73 ++++ .../api/services/ErrorHandlingTest.kt | 374 ++++++++++++++++++ .../api/services/ServiceParamsTest.kt | 22 ++ .../services/async/FileServiceAsyncTest.kt | 22 ++ .../async/beta/v2/FileServiceAsyncTest.kt | 22 ++ .../api/services/blocking/FileServiceTest.kt | 22 ++ .../blocking/beta/v2/FileServiceTest.kt | 22 ++ .../api/proguard/ProGuardCompatibilityTest.kt | 22 ++ 17 files changed, 1474 insertions(+), 6 deletions(-) diff --git a/.stats.yml b/.stats.yml index 6b1c558b..bceb847c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-8d944c932f09191791cc09e90ebf8142e523c0a6dd82ae9d1dbd7ff884acfc4b.yml -openapi_spec_hash: 179e38a7a472a5f98d17aed41099cbfd +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-7a42233daaf82345cc6d92cc49d4885126176b014c05ea0618c035869319fe53.yml +openapi_spec_hash: c41b1b6062b7c2ea548b16e0462aa358 config_hash: e42d7fc3a8c92c35099cc283f9a4467a diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt index 004e5b27..118516e6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt @@ -228,6 +228,20 @@ private constructor( */ fun responseFields(): Optional> = body.responseFields() + /** + * This field is included in the response only if the Path policy feature is available in the + * plan. It contains schema definitions for the custom metadata fields selected for the + * specified file path. Field selection can only be done when the Path policy feature is + * enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the + * custom metadata schema. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun selectedFieldsSchema(): Optional = body.selectedFieldsSchema() + /** * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the `%` @@ -400,6 +414,14 @@ private constructor( */ fun _responseFields(): MultipartField> = body._responseFields() + /** + * Returns the raw multipart value of [selectedFieldsSchema]. + * + * Unlike [selectedFieldsSchema], this method doesn't throw if the multipart field has an + * unexpected type. + */ + fun _selectedFieldsSchema(): MultipartField = body._selectedFieldsSchema() + /** * Returns the raw multipart value of [tags]. * @@ -832,6 +854,31 @@ private constructor( body.addResponseField(responseField) } + /** + * This field is included in the response only if the Path policy feature is available in + * the plan. It contains schema definitions for the custom metadata fields selected for the + * specified file path. Field selection can only be done when the Path policy feature is + * enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the + * custom metadata schema. + */ + fun selectedFieldsSchema(selectedFieldsSchema: SelectedFieldsSchema) = apply { + body.selectedFieldsSchema(selectedFieldsSchema) + } + + /** + * Sets [Builder.selectedFieldsSchema] to an arbitrary multipart value. + * + * You should usually call [Builder.selectedFieldsSchema] with a well-typed + * [SelectedFieldsSchema] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun selectedFieldsSchema(selectedFieldsSchema: MultipartField) = + apply { + body.selectedFieldsSchema(selectedFieldsSchema) + } + /** * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the @@ -1074,6 +1121,7 @@ private constructor( "overwriteFile" to _overwriteFile(), "overwriteTags" to _overwriteTags(), "responseFields" to _responseFields(), + "selectedFieldsSchema" to _selectedFieldsSchema(), "tags" to _tags(), "transformation" to _transformation(), "useUniqueFileName" to _useUniqueFileName(), @@ -1103,6 +1151,7 @@ private constructor( private val overwriteFile: MultipartField, private val overwriteTags: MultipartField, private val responseFields: MultipartField>, + private val selectedFieldsSchema: MultipartField, private val tags: MultipartField>, private val transformation: MultipartField, private val useUniqueFileName: MultipartField, @@ -1283,6 +1332,21 @@ private constructor( fun responseFields(): Optional> = responseFields.value.getOptional("responseFields") + /** + * This field is included in the response only if the Path policy feature is available in + * the plan. It contains schema definitions for the custom metadata fields selected for the + * specified file path. Field selection can only be done when the Path policy feature is + * enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the + * custom metadata schema. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun selectedFieldsSchema(): Optional = + selectedFieldsSchema.value.getOptional("selectedFieldsSchema") + /** * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the @@ -1482,6 +1546,16 @@ private constructor( @ExcludeMissing fun _responseFields(): MultipartField> = responseFields + /** + * Returns the raw multipart value of [selectedFieldsSchema]. + * + * Unlike [selectedFieldsSchema], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("selectedFieldsSchema") + @ExcludeMissing + fun _selectedFieldsSchema(): MultipartField = selectedFieldsSchema + /** * Returns the raw multipart value of [tags]. * @@ -1565,6 +1639,8 @@ private constructor( private var overwriteFile: MultipartField = MultipartField.of(null) private var overwriteTags: MultipartField = MultipartField.of(null) private var responseFields: MultipartField>? = null + private var selectedFieldsSchema: MultipartField = + MultipartField.of(null) private var tags: MultipartField>? = null private var transformation: MultipartField = MultipartField.of(null) private var useUniqueFileName: MultipartField = MultipartField.of(null) @@ -1589,6 +1665,7 @@ private constructor( overwriteFile = body.overwriteFile overwriteTags = body.overwriteTags responseFields = body.responseFields.map { it.toMutableList() } + selectedFieldsSchema = body.selectedFieldsSchema tags = body.tags.map { it.toMutableList() } transformation = body.transformation useUniqueFileName = body.useUniqueFileName @@ -1965,6 +2042,30 @@ private constructor( } } + /** + * This field is included in the response only if the Path policy feature is available + * in the plan. It contains schema definitions for the custom metadata fields selected + * for the specified file path. Field selection can only be done when the Path policy + * feature is enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about + * the custom metadata schema. + */ + fun selectedFieldsSchema(selectedFieldsSchema: SelectedFieldsSchema) = + selectedFieldsSchema(MultipartField.of(selectedFieldsSchema)) + + /** + * Sets [Builder.selectedFieldsSchema] to an arbitrary multipart value. + * + * You should usually call [Builder.selectedFieldsSchema] with a well-typed + * [SelectedFieldsSchema] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun selectedFieldsSchema(selectedFieldsSchema: MultipartField) = + apply { + this.selectedFieldsSchema = selectedFieldsSchema + } + /** * Set the tags while uploading the file. Provide an array of tag strings (e.g. * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not @@ -2113,6 +2214,7 @@ private constructor( overwriteFile, overwriteTags, (responseFields ?: MultipartField.of(null)).map { it.toImmutable() }, + selectedFieldsSchema, (tags ?: MultipartField.of(null)).map { it.toImmutable() }, transformation, useUniqueFileName, @@ -2144,6 +2246,7 @@ private constructor( overwriteFile() overwriteTags() responseFields().ifPresent { it.forEach { it.validate() } } + selectedFieldsSchema().ifPresent { it.validate() } tags() transformation().ifPresent { it.validate() } useUniqueFileName() @@ -2181,6 +2284,7 @@ private constructor( overwriteFile == other.overwriteFile && overwriteTags == other.overwriteTags && responseFields == other.responseFields && + selectedFieldsSchema == other.selectedFieldsSchema && tags == other.tags && transformation == other.transformation && useUniqueFileName == other.useUniqueFileName && @@ -2206,6 +2310,7 @@ private constructor( overwriteFile, overwriteTags, responseFields, + selectedFieldsSchema, tags, transformation, useUniqueFileName, @@ -2217,7 +2322,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, responseFields=$responseFields, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + "Body{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, responseFields=$responseFields, selectedFieldsSchema=$selectedFieldsSchema, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" } /** @@ -3450,6 +3555,105 @@ private constructor( override fun toString() = value.toString() } + /** + * This field is included in the response only if the Path policy feature is available in the + * plan. It contains schema definitions for the custom metadata fields selected for the + * specified file path. Field selection can only be done when the Path policy feature is + * enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the + * custom metadata schema. + */ + class SelectedFieldsSchema + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [SelectedFieldsSchema]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SelectedFieldsSchema]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(selectedFieldsSchema: SelectedFieldsSchema) = apply { + additionalProperties = selectedFieldsSchema.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SelectedFieldsSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SelectedFieldsSchema = + SelectedFieldsSchema(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): SelectedFieldsSchema = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SelectedFieldsSchema && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "SelectedFieldsSchema{additionalProperties=$additionalProperties}" + } + /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing file diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt index 197be28a..3c7ce9e1 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt @@ -38,6 +38,7 @@ private constructor( private val isPublished: JsonField, private val mime: JsonField, private val name: JsonField, + private val selectedFieldsSchema: JsonField, private val size: JsonField, private val tags: JsonField>, private val thumbnail: JsonField, @@ -77,6 +78,9 @@ private constructor( isPublished: JsonField = JsonMissing.of(), @JsonProperty("mime") @ExcludeMissing mime: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("selectedFieldsSchema") + @ExcludeMissing + selectedFieldsSchema: JsonField = JsonMissing.of(), @JsonProperty("size") @ExcludeMissing size: JsonField = JsonMissing.of(), @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), @JsonProperty("thumbnail") @ExcludeMissing thumbnail: JsonField = JsonMissing.of(), @@ -104,6 +108,7 @@ private constructor( isPublished, mime, name, + selectedFieldsSchema, size, tags, thumbnail, @@ -230,6 +235,21 @@ private constructor( */ fun name(): Optional = name.getOptional("name") + /** + * This field is included in the response only if the Path policy feature is available in the + * plan. It contains schema definitions for the custom metadata fields selected for the + * specified file path. Field selection can only be done when the Path policy feature is + * enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the + * custom metadata schema. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun selectedFieldsSchema(): Optional = + selectedFieldsSchema.getOptional("selectedFieldsSchema") + /** * Size of the file in bytes. * @@ -404,6 +424,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [selectedFieldsSchema]. + * + * Unlike [selectedFieldsSchema], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("selectedFieldsSchema") + @ExcludeMissing + fun _selectedFieldsSchema(): JsonField = selectedFieldsSchema + /** * Returns the raw JSON value of [size]. * @@ -499,6 +529,7 @@ private constructor( private var isPublished: JsonField = JsonMissing.of() private var mime: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() + private var selectedFieldsSchema: JsonField = JsonMissing.of() private var size: JsonField = JsonMissing.of() private var tags: JsonField>? = null private var thumbnail: JsonField = JsonMissing.of() @@ -525,6 +556,7 @@ private constructor( isPublished = file.isPublished mime = file.mime name = file.name + selectedFieldsSchema = file.selectedFieldsSchema size = file.size tags = file.tags.map { it.toMutableList() } thumbnail = file.thumbnail @@ -734,6 +766,29 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** + * This field is included in the response only if the Path policy feature is available in + * the plan. It contains schema definitions for the custom metadata fields selected for the + * specified file path. Field selection can only be done when the Path policy feature is + * enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the + * custom metadata schema. + */ + fun selectedFieldsSchema(selectedFieldsSchema: SelectedFieldsSchema) = + selectedFieldsSchema(JsonField.of(selectedFieldsSchema)) + + /** + * Sets [Builder.selectedFieldsSchema] to an arbitrary JSON value. + * + * You should usually call [Builder.selectedFieldsSchema] with a well-typed + * [SelectedFieldsSchema] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun selectedFieldsSchema(selectedFieldsSchema: JsonField) = apply { + this.selectedFieldsSchema = selectedFieldsSchema + } + /** Size of the file in bytes. */ fun size(size: Double) = size(JsonField.of(size)) @@ -888,6 +943,7 @@ private constructor( isPublished, mime, name, + selectedFieldsSchema, size, (tags ?: JsonMissing.of()).map { it.toImmutable() }, thumbnail, @@ -921,6 +977,7 @@ private constructor( isPublished() mime() name() + selectedFieldsSchema().ifPresent { it.validate() } size() tags() thumbnail() @@ -961,6 +1018,7 @@ private constructor( (if (isPublished.asKnown().isPresent) 1 else 0) + (if (mime.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + + (selectedFieldsSchema.asKnown().getOrNull()?.validity() ?: 0) + (if (size.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) + (if (thumbnail.asKnown().isPresent) 1 else 0) + @@ -1290,6 +1348,116 @@ private constructor( override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" } + /** + * This field is included in the response only if the Path policy feature is available in the + * plan. It contains schema definitions for the custom metadata fields selected for the + * specified file path. Field selection can only be done when the Path policy feature is + * enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the + * custom metadata schema. + */ + class SelectedFieldsSchema + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [SelectedFieldsSchema]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SelectedFieldsSchema]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(selectedFieldsSchema: SelectedFieldsSchema) = apply { + additionalProperties = selectedFieldsSchema.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SelectedFieldsSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SelectedFieldsSchema = + SelectedFieldsSchema(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): SelectedFieldsSchema = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SelectedFieldsSchema && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "SelectedFieldsSchema{additionalProperties=$additionalProperties}" + } + /** Type of the asset. */ class Type @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1615,6 +1783,7 @@ private constructor( isPublished == other.isPublished && mime == other.mime && name == other.name && + selectedFieldsSchema == other.selectedFieldsSchema && size == other.size && tags == other.tags && thumbnail == other.thumbnail && @@ -1642,6 +1811,7 @@ private constructor( isPublished, mime, name, + selectedFieldsSchema, size, tags, thumbnail, @@ -1657,5 +1827,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "File{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, fileId=$fileId, filePath=$filePath, fileType=$fileType, hasAlpha=$hasAlpha, height=$height, isPrivateFile=$isPrivateFile, isPublished=$isPublished, mime=$mime, name=$name, size=$size, tags=$tags, thumbnail=$thumbnail, type=$type, updatedAt=$updatedAt, url=$url, versionInfo=$versionInfo, width=$width, additionalProperties=$additionalProperties}" + "File{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, fileId=$fileId, filePath=$filePath, fileType=$fileType, hasAlpha=$hasAlpha, height=$height, isPrivateFile=$isPrivateFile, isPublished=$isPublished, mime=$mime, name=$name, selectedFieldsSchema=$selectedFieldsSchema, size=$size, tags=$tags, thumbnail=$thumbnail, type=$type, updatedAt=$updatedAt, url=$url, versionInfo=$versionInfo, width=$width, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt index 79bbe2bd..182020c9 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt @@ -38,6 +38,7 @@ private constructor( private val isPublished: JsonField, private val mime: JsonField, private val name: JsonField, + private val selectedFieldsSchema: JsonField, private val size: JsonField, private val tags: JsonField>, private val thumbnail: JsonField, @@ -80,6 +81,9 @@ private constructor( isPublished: JsonField = JsonMissing.of(), @JsonProperty("mime") @ExcludeMissing mime: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("selectedFieldsSchema") + @ExcludeMissing + selectedFieldsSchema: JsonField = JsonMissing.of(), @JsonProperty("size") @ExcludeMissing size: JsonField = JsonMissing.of(), @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), @JsonProperty("thumbnail") @ExcludeMissing thumbnail: JsonField = JsonMissing.of(), @@ -110,6 +114,7 @@ private constructor( isPublished, mime, name, + selectedFieldsSchema, size, tags, thumbnail, @@ -138,6 +143,7 @@ private constructor( .isPublished(isPublished) .mime(mime) .name(name) + .selectedFieldsSchema(selectedFieldsSchema) .size(size) .tags(tags) .thumbnail(thumbnail) @@ -264,6 +270,21 @@ private constructor( */ fun name(): Optional = name.getOptional("name") + /** + * This field is included in the response only if the Path policy feature is available in the + * plan. It contains schema definitions for the custom metadata fields selected for the + * specified file path. Field selection can only be done when the Path policy feature is + * enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the + * custom metadata schema. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun selectedFieldsSchema(): Optional = + selectedFieldsSchema.getOptional("selectedFieldsSchema") + /** * Size of the file in bytes. * @@ -445,6 +466,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [selectedFieldsSchema]. + * + * Unlike [selectedFieldsSchema], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("selectedFieldsSchema") + @ExcludeMissing + fun _selectedFieldsSchema(): JsonField = selectedFieldsSchema + /** * Returns the raw JSON value of [size]. * @@ -549,6 +580,7 @@ private constructor( private var isPublished: JsonField = JsonMissing.of() private var mime: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() + private var selectedFieldsSchema: JsonField = JsonMissing.of() private var size: JsonField = JsonMissing.of() private var tags: JsonField>? = null private var thumbnail: JsonField = JsonMissing.of() @@ -576,6 +608,7 @@ private constructor( isPublished = fileUpdateResponse.isPublished mime = fileUpdateResponse.mime name = fileUpdateResponse.name + selectedFieldsSchema = fileUpdateResponse.selectedFieldsSchema size = fileUpdateResponse.size tags = fileUpdateResponse.tags.map { it.toMutableList() } thumbnail = fileUpdateResponse.thumbnail @@ -786,6 +819,30 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** + * This field is included in the response only if the Path policy feature is available in + * the plan. It contains schema definitions for the custom metadata fields selected for the + * specified file path. Field selection can only be done when the Path policy feature is + * enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the + * custom metadata schema. + */ + fun selectedFieldsSchema(selectedFieldsSchema: File.SelectedFieldsSchema) = + selectedFieldsSchema(JsonField.of(selectedFieldsSchema)) + + /** + * Sets [Builder.selectedFieldsSchema] to an arbitrary JSON value. + * + * You should usually call [Builder.selectedFieldsSchema] with a well-typed + * [File.SelectedFieldsSchema] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun selectedFieldsSchema(selectedFieldsSchema: JsonField) = + apply { + this.selectedFieldsSchema = selectedFieldsSchema + } + /** Size of the file in bytes. */ fun size(size: Double) = size(JsonField.of(size)) @@ -954,6 +1011,7 @@ private constructor( isPublished, mime, name, + selectedFieldsSchema, size, (tags ?: JsonMissing.of()).map { it.toImmutable() }, thumbnail, @@ -988,6 +1046,7 @@ private constructor( isPublished() mime() name() + selectedFieldsSchema().ifPresent { it.validate() } size() tags() thumbnail() @@ -1029,6 +1088,7 @@ private constructor( (if (isPublished.asKnown().isPresent) 1 else 0) + (if (mime.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + + (selectedFieldsSchema.asKnown().getOrNull()?.validity() ?: 0) + (if (size.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) + (if (thumbnail.asKnown().isPresent) 1 else 0) + @@ -1888,6 +1948,7 @@ private constructor( isPublished == other.isPublished && mime == other.mime && name == other.name && + selectedFieldsSchema == other.selectedFieldsSchema && size == other.size && tags == other.tags && thumbnail == other.thumbnail && @@ -1916,6 +1977,7 @@ private constructor( isPublished, mime, name, + selectedFieldsSchema, size, tags, thumbnail, @@ -1932,5 +1994,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FileUpdateResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, fileId=$fileId, filePath=$filePath, fileType=$fileType, hasAlpha=$hasAlpha, height=$height, isPrivateFile=$isPrivateFile, isPublished=$isPublished, mime=$mime, name=$name, size=$size, tags=$tags, thumbnail=$thumbnail, type=$type, updatedAt=$updatedAt, url=$url, versionInfo=$versionInfo, width=$width, extensionStatus=$extensionStatus, additionalProperties=$additionalProperties}" + "FileUpdateResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, fileId=$fileId, filePath=$filePath, fileType=$fileType, hasAlpha=$hasAlpha, height=$height, isPrivateFile=$isPrivateFile, isPublished=$isPublished, mime=$mime, name=$name, selectedFieldsSchema=$selectedFieldsSchema, size=$size, tags=$tags, thumbnail=$thumbnail, type=$type, updatedAt=$updatedAt, url=$url, versionInfo=$versionInfo, width=$width, extensionStatus=$extensionStatus, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt index e5b9c421..c6a13ec3 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -256,6 +256,20 @@ private constructor( */ fun responseFields(): Optional> = body.responseFields() + /** + * This field is included in the response only if the Path policy feature is available in the + * plan. It contains schema definitions for the custom metadata fields selected for the + * specified file path. Field selection can only be done when the Path policy feature is + * enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the + * custom metadata schema. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun selectedFieldsSchema(): Optional = body.selectedFieldsSchema() + /** * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. Learn * how to create a signature on the page below. This should be in lowercase. @@ -454,6 +468,14 @@ private constructor( */ fun _responseFields(): MultipartField> = body._responseFields() + /** + * Returns the raw multipart value of [selectedFieldsSchema]. + * + * Unlike [selectedFieldsSchema], this method doesn't throw if the multipart field has an + * unexpected type. + */ + fun _selectedFieldsSchema(): MultipartField = body._selectedFieldsSchema() + /** * Returns the raw multipart value of [signature]. * @@ -933,6 +955,31 @@ private constructor( body.addResponseField(responseField) } + /** + * This field is included in the response only if the Path policy feature is available in + * the plan. It contains schema definitions for the custom metadata fields selected for the + * specified file path. Field selection can only be done when the Path policy feature is + * enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the + * custom metadata schema. + */ + fun selectedFieldsSchema(selectedFieldsSchema: SelectedFieldsSchema) = apply { + body.selectedFieldsSchema(selectedFieldsSchema) + } + + /** + * Sets [Builder.selectedFieldsSchema] to an arbitrary multipart value. + * + * You should usually call [Builder.selectedFieldsSchema] with a well-typed + * [SelectedFieldsSchema] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun selectedFieldsSchema(selectedFieldsSchema: MultipartField) = + apply { + body.selectedFieldsSchema(selectedFieldsSchema) + } + /** * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. * Learn how to create a signature on the page below. This should be in lowercase. @@ -1195,6 +1242,7 @@ private constructor( "overwriteTags" to _overwriteTags(), "publicKey" to _publicKey(), "responseFields" to _responseFields(), + "selectedFieldsSchema" to _selectedFieldsSchema(), "signature" to _signature(), "tags" to _tags(), "transformation" to _transformation(), @@ -1227,6 +1275,7 @@ private constructor( private val overwriteTags: MultipartField, private val publicKey: MultipartField, private val responseFields: MultipartField>, + private val selectedFieldsSchema: MultipartField, private val signature: MultipartField, private val tags: MultipartField>, private val transformation: MultipartField, @@ -1435,6 +1484,21 @@ private constructor( fun responseFields(): Optional> = responseFields.value.getOptional("responseFields") + /** + * This field is included in the response only if the Path policy feature is available in + * the plan. It contains schema definitions for the custom metadata fields selected for the + * specified file path. Field selection can only be done when the Path policy feature is + * enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the + * custom metadata schema. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun selectedFieldsSchema(): Optional = + selectedFieldsSchema.value.getOptional("selectedFieldsSchema") + /** * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. * Learn how to create a signature on the page below. This should be in lowercase. @@ -1663,6 +1727,16 @@ private constructor( @ExcludeMissing fun _responseFields(): MultipartField> = responseFields + /** + * Returns the raw multipart value of [selectedFieldsSchema]. + * + * Unlike [selectedFieldsSchema], this method doesn't throw if the multipart field has an + * unexpected type. + */ + @JsonProperty("selectedFieldsSchema") + @ExcludeMissing + fun _selectedFieldsSchema(): MultipartField = selectedFieldsSchema + /** * Returns the raw multipart value of [signature]. * @@ -1758,6 +1832,8 @@ private constructor( private var overwriteTags: MultipartField = MultipartField.of(null) private var publicKey: MultipartField = MultipartField.of(null) private var responseFields: MultipartField>? = null + private var selectedFieldsSchema: MultipartField = + MultipartField.of(null) private var signature: MultipartField = MultipartField.of(null) private var tags: MultipartField>? = null private var transformation: MultipartField = MultipartField.of(null) @@ -1785,6 +1861,7 @@ private constructor( overwriteTags = body.overwriteTags publicKey = body.publicKey responseFields = body.responseFields.map { it.toMutableList() } + selectedFieldsSchema = body.selectedFieldsSchema signature = body.signature tags = body.tags.map { it.toMutableList() } transformation = body.transformation @@ -2201,6 +2278,30 @@ private constructor( } } + /** + * This field is included in the response only if the Path policy feature is available + * in the plan. It contains schema definitions for the custom metadata fields selected + * for the specified file path. Field selection can only be done when the Path policy + * feature is enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about + * the custom metadata schema. + */ + fun selectedFieldsSchema(selectedFieldsSchema: SelectedFieldsSchema) = + selectedFieldsSchema(MultipartField.of(selectedFieldsSchema)) + + /** + * Sets [Builder.selectedFieldsSchema] to an arbitrary multipart value. + * + * You should usually call [Builder.selectedFieldsSchema] with a well-typed + * [SelectedFieldsSchema] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun selectedFieldsSchema(selectedFieldsSchema: MultipartField) = + apply { + this.selectedFieldsSchema = selectedFieldsSchema + } + /** * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. * Learn how to create a signature on the page below. This should be in lowercase. @@ -2369,6 +2470,7 @@ private constructor( overwriteTags, publicKey, (responseFields ?: MultipartField.of(null)).map { it.toImmutable() }, + selectedFieldsSchema, signature, (tags ?: MultipartField.of(null)).map { it.toImmutable() }, transformation, @@ -2403,6 +2505,7 @@ private constructor( overwriteTags() publicKey() responseFields().ifPresent { it.forEach { it.validate() } } + selectedFieldsSchema().ifPresent { it.validate() } signature() tags() transformation().ifPresent { it.validate() } @@ -2443,6 +2546,7 @@ private constructor( overwriteTags == other.overwriteTags && publicKey == other.publicKey && responseFields == other.responseFields && + selectedFieldsSchema == other.selectedFieldsSchema && signature == other.signature && tags == other.tags && transformation == other.transformation && @@ -2471,6 +2575,7 @@ private constructor( overwriteTags, publicKey, responseFields, + selectedFieldsSchema, signature, tags, transformation, @@ -2483,7 +2588,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, expire=$expire, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, publicKey=$publicKey, responseFields=$responseFields, signature=$signature, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + "Body{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, expire=$expire, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, publicKey=$publicKey, responseFields=$responseFields, selectedFieldsSchema=$selectedFieldsSchema, signature=$signature, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" } /** @@ -3716,6 +3821,105 @@ private constructor( override fun toString() = value.toString() } + /** + * This field is included in the response only if the Path policy feature is available in the + * plan. It contains schema definitions for the custom metadata fields selected for the + * specified file path. Field selection can only be done when the Path policy feature is + * enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the + * custom metadata schema. + */ + class SelectedFieldsSchema + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [SelectedFieldsSchema]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SelectedFieldsSchema]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(selectedFieldsSchema: SelectedFieldsSchema) = apply { + additionalProperties = selectedFieldsSchema.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SelectedFieldsSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SelectedFieldsSchema = + SelectedFieldsSchema(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): SelectedFieldsSchema = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SelectedFieldsSchema && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "SelectedFieldsSchema{additionalProperties=$additionalProperties}" + } + /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing file diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt index 70896711..6cbde398 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt @@ -41,6 +41,28 @@ internal class AssetListResponseTest { .isPublished(true) .mime("mime") .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .size(0.0) .addTag("string") .thumbnail("https://example.com") @@ -83,6 +105,28 @@ internal class AssetListResponseTest { .isPublished(true) .mime("mime") .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .size(0.0) .addTag("string") .thumbnail("https://example.com") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt index e4adb865..5ce7a267 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt @@ -67,6 +67,27 @@ internal class FileUploadParamsTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .tags(listOf("t-shirt", "round-neck", "men")) .transformation( FileUploadParams.Transformation.builder() @@ -146,6 +167,28 @@ internal class FileUploadParamsTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .tags(listOf("t-shirt", "round-neck", "men")) .transformation( FileUploadParams.Transformation.builder() @@ -237,6 +280,36 @@ internal class FileUploadParamsTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ), + "selectedFieldsSchema" to + MultipartField.of( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf( + "small", + "medium", + "large", + 30, + 40, + true, + ), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ), "tags" to MultipartField.of(listOf("t-shirt", "round-neck", "men")), "transformation" to MultipartField.of( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt index 78282e94..daf4fec8 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt @@ -36,6 +36,28 @@ internal class FileTest { .isPublished(true) .mime("mime") .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .size(0.0) .addTag("string") .thumbnail("https://example.com") @@ -68,6 +90,28 @@ internal class FileTest { assertThat(file.isPublished()).contains(true) assertThat(file.mime()).contains("mime") assertThat(file.name()).contains("name") + assertThat(file.selectedFieldsSchema()) + .contains( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) assertThat(file.size()).contains(0.0) assertThat(file.tags().getOrNull()).containsExactly("string") assertThat(file.thumbnail()).contains("https://example.com") @@ -104,6 +148,28 @@ internal class FileTest { .isPublished(true) .mime("mime") .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .size(0.0) .addTag("string") .thumbnail("https://example.com") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt index de6e3a66..f9202b81 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt @@ -36,6 +36,28 @@ internal class FileUpdateResponseTest { .isPublished(true) .mime("mime") .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .size(0.0) .addTag("string") .thumbnail("https://example.com") @@ -81,6 +103,28 @@ internal class FileUpdateResponseTest { assertThat(fileUpdateResponse.isPublished()).contains(true) assertThat(fileUpdateResponse.mime()).contains("mime") assertThat(fileUpdateResponse.name()).contains("name") + assertThat(fileUpdateResponse.selectedFieldsSchema()) + .contains( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) assertThat(fileUpdateResponse.size()).contains(0.0) assertThat(fileUpdateResponse.tags().getOrNull()).containsExactly("string") assertThat(fileUpdateResponse.thumbnail()).contains("https://example.com") @@ -127,6 +171,28 @@ internal class FileUpdateResponseTest { .isPublished(true) .mime("mime") .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .size(0.0) .addTag("string") .thumbnail("https://example.com") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt index fbea5ec8..3af58927 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt @@ -69,6 +69,27 @@ internal class FileUploadParamsTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -151,6 +172,28 @@ internal class FileUploadParamsTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -245,6 +288,36 @@ internal class FileUploadParamsTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ), + "selectedFieldsSchema" to + MultipartField.of( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf( + "small", + "medium", + "large", + 30, + 40, + true, + ), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ), "signature" to MultipartField.of("signature"), "tags" to MultipartField.of(listOf("t-shirt", "round-neck", "men")), "transformation" to diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt index 4978c043..38cc24d1 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt @@ -129,6 +129,28 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -229,6 +251,28 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -329,6 +373,28 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -429,6 +495,28 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -529,6 +617,28 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -629,6 +739,28 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -729,6 +861,28 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -829,6 +983,28 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -929,6 +1105,28 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -1029,6 +1227,28 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -1129,6 +1349,28 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -1229,6 +1471,28 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -1329,6 +1593,28 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -1429,6 +1715,28 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -1529,6 +1837,28 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -1629,6 +1959,28 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -1727,6 +2079,28 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt index 59e7191c..cd9400c0 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt @@ -101,6 +101,28 @@ internal class ServiceParamsTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index f6a815c2..06f7f729 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -270,6 +270,28 @@ internal class FileServiceAsyncTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt index 6973ea50..fa6659a6 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt @@ -81,6 +81,28 @@ internal class FileServiceAsyncTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .tags(listOf("t-shirt", "round-neck", "men")) .transformation( FileUploadParams.Transformation.builder() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index d3e8e8c0..63e26e05 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -263,6 +263,28 @@ internal class FileServiceTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt index b0050868..e68555dc 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt @@ -81,6 +81,28 @@ internal class FileServiceTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) + .selectedFieldsSchema( + FileUploadParams.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .tags(listOf("t-shirt", "round-neck", "men")) .transformation( FileUploadParams.Transformation.builder() diff --git a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt index 4ad5e27d..41078fe2 100644 --- a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt +++ b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt @@ -91,6 +91,28 @@ internal class ProGuardCompatibilityTest { .isPublished(true) .mime("mime") .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .size(0.0) .addTag("string") .thumbnail("https://example.com") From fc00907646fa9bfb333ac303783d58956cc262c2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 30 Sep 2025 07:38:40 +0000 Subject: [PATCH 046/142] docs: correct typo in default value description for custom metadata field --- .stats.yml | 4 ++-- .../api/models/custommetadatafields/CustomMetadataField.kt | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.stats.yml b/.stats.yml index bceb847c..56e1384b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-7a42233daaf82345cc6d92cc49d4885126176b014c05ea0618c035869319fe53.yml -openapi_spec_hash: c41b1b6062b7c2ea548b16e0462aa358 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-aa4c8e857ae03b12dabf168c83c62f759e2706d69fa4eb77d11519d45a5dada2.yml +openapi_spec_hash: 6ea00242c4685fb6422328f0dd53f9b1 config_hash: e42d7fc3a8c92c35099cc283f9a4467a diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt index 1d5dff3f..faf75e58 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt @@ -346,7 +346,7 @@ private constructor( fun type(): Type = type.getRequired("type") /** - * The default value for this custom metadata field. Date type of default value depends on + * The default value for this custom metadata field. Data type of default value depends on * the field type. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -536,7 +536,7 @@ private constructor( fun type(type: JsonField) = apply { this.type = type } /** - * The default value for this custom metadata field. Date type of default value depends + * The default value for this custom metadata field. Data type of default value depends * on the field type. */ fun defaultValue(defaultValue: DefaultValue) = defaultValue(JsonField.of(defaultValue)) @@ -931,7 +931,7 @@ private constructor( } /** - * The default value for this custom metadata field. Date type of default value depends on + * The default value for this custom metadata field. Data type of default value depends on * the field type. */ @JsonDeserialize(using = DefaultValue.Deserializer::class) From 7abe23093ccf53fcf4b0829cc7d4b792cf8c4406 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 30 Sep 2025 07:48:58 +0000 Subject: [PATCH 047/142] feat(api): fix upload API request params --- .stats.yml | 4 +- .../models/beta/v2/files/FileUploadParams.kt | 206 +--------- .../beta/v2/files/FileUploadResponse.kt | 172 +++++++- .../api/models/files/FileUploadParams.kt | 206 +--------- .../api/models/files/FileUploadResponse.kt | 172 +++++++- .../UploadPreTransformSuccessEvent.kt | 179 ++++++++- .../beta/v2/files/FileUploadParamsTest.kt | 73 ---- .../beta/v2/files/FileUploadResponseTest.kt | 66 ++++ .../api/models/files/FileUploadParamsTest.kt | 73 ---- .../models/files/FileUploadResponseTest.kt | 66 ++++ .../webhooks/UnsafeUnwrapWebhookEventTest.kt | 51 +++ .../models/webhooks/UnwrapWebhookEventTest.kt | 51 +++ .../UploadPreTransformSuccessEventTest.kt | 66 ++++ .../api/services/ErrorHandlingTest.kt | 374 ------------------ .../api/services/ServiceParamsTest.kt | 22 -- .../services/async/FileServiceAsyncTest.kt | 22 -- .../async/beta/v2/FileServiceAsyncTest.kt | 22 -- .../api/services/blocking/FileServiceTest.kt | 22 -- .../blocking/beta/v2/FileServiceTest.kt | 22 -- 19 files changed, 824 insertions(+), 1045 deletions(-) diff --git a/.stats.yml b/.stats.yml index 56e1384b..0c9c486c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-aa4c8e857ae03b12dabf168c83c62f759e2706d69fa4eb77d11519d45a5dada2.yml -openapi_spec_hash: 6ea00242c4685fb6422328f0dd53f9b1 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-01aef94bd928f40b7209dc21df71e2312d4bee430119b30ee05d75cf5e1b4801.yml +openapi_spec_hash: 054c332db88b23d362f72583dd24b2aa config_hash: e42d7fc3a8c92c35099cc283f9a4467a diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt index 118516e6..004e5b27 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt @@ -228,20 +228,6 @@ private constructor( */ fun responseFields(): Optional> = body.responseFields() - /** - * This field is included in the response only if the Path policy feature is available in the - * plan. It contains schema definitions for the custom metadata fields selected for the - * specified file path. Field selection can only be done when the Path policy feature is - * enabled. - * - * Keys are the names of the custom metadata fields; the value object has details about the - * custom metadata schema. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun selectedFieldsSchema(): Optional = body.selectedFieldsSchema() - /** * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the `%` @@ -414,14 +400,6 @@ private constructor( */ fun _responseFields(): MultipartField> = body._responseFields() - /** - * Returns the raw multipart value of [selectedFieldsSchema]. - * - * Unlike [selectedFieldsSchema], this method doesn't throw if the multipart field has an - * unexpected type. - */ - fun _selectedFieldsSchema(): MultipartField = body._selectedFieldsSchema() - /** * Returns the raw multipart value of [tags]. * @@ -854,31 +832,6 @@ private constructor( body.addResponseField(responseField) } - /** - * This field is included in the response only if the Path policy feature is available in - * the plan. It contains schema definitions for the custom metadata fields selected for the - * specified file path. Field selection can only be done when the Path policy feature is - * enabled. - * - * Keys are the names of the custom metadata fields; the value object has details about the - * custom metadata schema. - */ - fun selectedFieldsSchema(selectedFieldsSchema: SelectedFieldsSchema) = apply { - body.selectedFieldsSchema(selectedFieldsSchema) - } - - /** - * Sets [Builder.selectedFieldsSchema] to an arbitrary multipart value. - * - * You should usually call [Builder.selectedFieldsSchema] with a well-typed - * [SelectedFieldsSchema] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun selectedFieldsSchema(selectedFieldsSchema: MultipartField) = - apply { - body.selectedFieldsSchema(selectedFieldsSchema) - } - /** * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the @@ -1121,7 +1074,6 @@ private constructor( "overwriteFile" to _overwriteFile(), "overwriteTags" to _overwriteTags(), "responseFields" to _responseFields(), - "selectedFieldsSchema" to _selectedFieldsSchema(), "tags" to _tags(), "transformation" to _transformation(), "useUniqueFileName" to _useUniqueFileName(), @@ -1151,7 +1103,6 @@ private constructor( private val overwriteFile: MultipartField, private val overwriteTags: MultipartField, private val responseFields: MultipartField>, - private val selectedFieldsSchema: MultipartField, private val tags: MultipartField>, private val transformation: MultipartField, private val useUniqueFileName: MultipartField, @@ -1332,21 +1283,6 @@ private constructor( fun responseFields(): Optional> = responseFields.value.getOptional("responseFields") - /** - * This field is included in the response only if the Path policy feature is available in - * the plan. It contains schema definitions for the custom metadata fields selected for the - * specified file path. Field selection can only be done when the Path policy feature is - * enabled. - * - * Keys are the names of the custom metadata fields; the value object has details about the - * custom metadata schema. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun selectedFieldsSchema(): Optional = - selectedFieldsSchema.value.getOptional("selectedFieldsSchema") - /** * Set the tags while uploading the file. Provide an array of tag strings (e.g. `["tag1", * "tag2", "tag3"]`). The combined length of all tag characters must not exceed 500, and the @@ -1546,16 +1482,6 @@ private constructor( @ExcludeMissing fun _responseFields(): MultipartField> = responseFields - /** - * Returns the raw multipart value of [selectedFieldsSchema]. - * - * Unlike [selectedFieldsSchema], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("selectedFieldsSchema") - @ExcludeMissing - fun _selectedFieldsSchema(): MultipartField = selectedFieldsSchema - /** * Returns the raw multipart value of [tags]. * @@ -1639,8 +1565,6 @@ private constructor( private var overwriteFile: MultipartField = MultipartField.of(null) private var overwriteTags: MultipartField = MultipartField.of(null) private var responseFields: MultipartField>? = null - private var selectedFieldsSchema: MultipartField = - MultipartField.of(null) private var tags: MultipartField>? = null private var transformation: MultipartField = MultipartField.of(null) private var useUniqueFileName: MultipartField = MultipartField.of(null) @@ -1665,7 +1589,6 @@ private constructor( overwriteFile = body.overwriteFile overwriteTags = body.overwriteTags responseFields = body.responseFields.map { it.toMutableList() } - selectedFieldsSchema = body.selectedFieldsSchema tags = body.tags.map { it.toMutableList() } transformation = body.transformation useUniqueFileName = body.useUniqueFileName @@ -2042,30 +1965,6 @@ private constructor( } } - /** - * This field is included in the response only if the Path policy feature is available - * in the plan. It contains schema definitions for the custom metadata fields selected - * for the specified file path. Field selection can only be done when the Path policy - * feature is enabled. - * - * Keys are the names of the custom metadata fields; the value object has details about - * the custom metadata schema. - */ - fun selectedFieldsSchema(selectedFieldsSchema: SelectedFieldsSchema) = - selectedFieldsSchema(MultipartField.of(selectedFieldsSchema)) - - /** - * Sets [Builder.selectedFieldsSchema] to an arbitrary multipart value. - * - * You should usually call [Builder.selectedFieldsSchema] with a well-typed - * [SelectedFieldsSchema] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun selectedFieldsSchema(selectedFieldsSchema: MultipartField) = - apply { - this.selectedFieldsSchema = selectedFieldsSchema - } - /** * Set the tags while uploading the file. Provide an array of tag strings (e.g. * `["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not @@ -2214,7 +2113,6 @@ private constructor( overwriteFile, overwriteTags, (responseFields ?: MultipartField.of(null)).map { it.toImmutable() }, - selectedFieldsSchema, (tags ?: MultipartField.of(null)).map { it.toImmutable() }, transformation, useUniqueFileName, @@ -2246,7 +2144,6 @@ private constructor( overwriteFile() overwriteTags() responseFields().ifPresent { it.forEach { it.validate() } } - selectedFieldsSchema().ifPresent { it.validate() } tags() transformation().ifPresent { it.validate() } useUniqueFileName() @@ -2284,7 +2181,6 @@ private constructor( overwriteFile == other.overwriteFile && overwriteTags == other.overwriteTags && responseFields == other.responseFields && - selectedFieldsSchema == other.selectedFieldsSchema && tags == other.tags && transformation == other.transformation && useUniqueFileName == other.useUniqueFileName && @@ -2310,7 +2206,6 @@ private constructor( overwriteFile, overwriteTags, responseFields, - selectedFieldsSchema, tags, transformation, useUniqueFileName, @@ -2322,7 +2217,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, responseFields=$responseFields, selectedFieldsSchema=$selectedFieldsSchema, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + "Body{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, responseFields=$responseFields, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" } /** @@ -3555,105 +3450,6 @@ private constructor( override fun toString() = value.toString() } - /** - * This field is included in the response only if the Path policy feature is available in the - * plan. It contains schema definitions for the custom metadata fields selected for the - * specified file path. Field selection can only be done when the Path policy feature is - * enabled. - * - * Keys are the names of the custom metadata fields; the value object has details about the - * custom metadata schema. - */ - class SelectedFieldsSchema - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [SelectedFieldsSchema]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SelectedFieldsSchema]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(selectedFieldsSchema: SelectedFieldsSchema) = apply { - additionalProperties = selectedFieldsSchema.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SelectedFieldsSchema]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): SelectedFieldsSchema = - SelectedFieldsSchema(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): SelectedFieldsSchema = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SelectedFieldsSchema && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "SelectedFieldsSchema{additionalProperties=$additionalProperties}" - } - /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing file diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt index 7214d2ba..f4dbf49e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt @@ -41,6 +41,7 @@ private constructor( private val isPublished: JsonField, private val metadata: JsonField, private val name: JsonField, + private val selectedFieldsSchema: JsonField, private val size: JsonField, private val tags: JsonField>, private val thumbnailUrl: JsonField, @@ -86,6 +87,9 @@ private constructor( isPublished: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("selectedFieldsSchema") + @ExcludeMissing + selectedFieldsSchema: JsonField = JsonMissing.of(), @JsonProperty("size") @ExcludeMissing size: JsonField = JsonMissing.of(), @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), @JsonProperty("thumbnailUrl") @@ -117,6 +121,7 @@ private constructor( isPublished, metadata, name, + selectedFieldsSchema, size, tags, thumbnailUrl, @@ -284,6 +289,21 @@ private constructor( */ fun name(): Optional = name.getOptional("name") + /** + * This field is included in the response only if the Path policy feature is available in the + * plan. It contains schema definitions for the custom metadata fields selected for the + * specified file path. Field selection can only be done when the Path policy feature is + * enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the + * custom metadata schema. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun selectedFieldsSchema(): Optional = + selectedFieldsSchema.getOptional("selectedFieldsSchema") + /** * Size of the image file in Bytes. * @@ -474,6 +494,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [selectedFieldsSchema]. + * + * Unlike [selectedFieldsSchema], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("selectedFieldsSchema") + @ExcludeMissing + fun _selectedFieldsSchema(): JsonField = selectedFieldsSchema + /** * Returns the raw JSON value of [size]. * @@ -565,6 +595,7 @@ private constructor( private var isPublished: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() + private var selectedFieldsSchema: JsonField = JsonMissing.of() private var size: JsonField = JsonMissing.of() private var tags: JsonField>? = null private var thumbnailUrl: JsonField = JsonMissing.of() @@ -593,6 +624,7 @@ private constructor( isPublished = fileUploadResponse.isPublished metadata = fileUploadResponse.metadata name = fileUploadResponse.name + selectedFieldsSchema = fileUploadResponse.selectedFieldsSchema size = fileUploadResponse.size tags = fileUploadResponse.tags.map { it.toMutableList() } thumbnailUrl = fileUploadResponse.thumbnailUrl @@ -876,6 +908,29 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** + * This field is included in the response only if the Path policy feature is available in + * the plan. It contains schema definitions for the custom metadata fields selected for the + * specified file path. Field selection can only be done when the Path policy feature is + * enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the + * custom metadata schema. + */ + fun selectedFieldsSchema(selectedFieldsSchema: SelectedFieldsSchema) = + selectedFieldsSchema(JsonField.of(selectedFieldsSchema)) + + /** + * Sets [Builder.selectedFieldsSchema] to an arbitrary JSON value. + * + * You should usually call [Builder.selectedFieldsSchema] with a well-typed + * [SelectedFieldsSchema] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun selectedFieldsSchema(selectedFieldsSchema: JsonField) = apply { + this.selectedFieldsSchema = selectedFieldsSchema + } + /** Size of the image file in Bytes. */ fun size(size: Double) = size(JsonField.of(size)) @@ -1021,6 +1076,7 @@ private constructor( isPublished, metadata, name, + selectedFieldsSchema, size, (tags ?: JsonMissing.of()).map { it.toImmutable() }, thumbnailUrl, @@ -1056,6 +1112,7 @@ private constructor( isPublished() metadata().ifPresent { it.validate() } name() + selectedFieldsSchema().ifPresent { it.validate() } size() tags() thumbnailUrl() @@ -1098,6 +1155,7 @@ private constructor( (if (isPublished.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + + (selectedFieldsSchema.asKnown().getOrNull()?.validity() ?: 0) + (if (size.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) + (if (thumbnailUrl.asKnown().isPresent) 1 else 0) + @@ -2377,6 +2435,116 @@ private constructor( "ExtensionStatus{aiAutoDescription=$aiAutoDescription, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" } + /** + * This field is included in the response only if the Path policy feature is available in the + * plan. It contains schema definitions for the custom metadata fields selected for the + * specified file path. Field selection can only be done when the Path policy feature is + * enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the + * custom metadata schema. + */ + class SelectedFieldsSchema + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [SelectedFieldsSchema]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SelectedFieldsSchema]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(selectedFieldsSchema: SelectedFieldsSchema) = apply { + additionalProperties = selectedFieldsSchema.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SelectedFieldsSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SelectedFieldsSchema = + SelectedFieldsSchema(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): SelectedFieldsSchema = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SelectedFieldsSchema && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "SelectedFieldsSchema{additionalProperties=$additionalProperties}" + } + /** An object containing the file or file version's `id` (versionId) and `name`. */ class VersionInfo @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -2577,6 +2745,7 @@ private constructor( isPublished == other.isPublished && metadata == other.metadata && name == other.name && + selectedFieldsSchema == other.selectedFieldsSchema && size == other.size && tags == other.tags && thumbnailUrl == other.thumbnailUrl && @@ -2606,6 +2775,7 @@ private constructor( isPublished, metadata, name, + selectedFieldsSchema, size, tags, thumbnailUrl, @@ -2620,5 +2790,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FileUploadResponse{aiTags=$aiTags, audioCodec=$audioCodec, bitRate=$bitRate, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, duration=$duration, embeddedMetadata=$embeddedMetadata, extensionStatus=$extensionStatus, fileId=$fileId, filePath=$filePath, fileType=$fileType, height=$height, isPrivateFile=$isPrivateFile, isPublished=$isPublished, metadata=$metadata, name=$name, size=$size, tags=$tags, thumbnailUrl=$thumbnailUrl, url=$url, versionInfo=$versionInfo, videoCodec=$videoCodec, width=$width, additionalProperties=$additionalProperties}" + "FileUploadResponse{aiTags=$aiTags, audioCodec=$audioCodec, bitRate=$bitRate, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, duration=$duration, embeddedMetadata=$embeddedMetadata, extensionStatus=$extensionStatus, fileId=$fileId, filePath=$filePath, fileType=$fileType, height=$height, isPrivateFile=$isPrivateFile, isPublished=$isPublished, metadata=$metadata, name=$name, selectedFieldsSchema=$selectedFieldsSchema, size=$size, tags=$tags, thumbnailUrl=$thumbnailUrl, url=$url, versionInfo=$versionInfo, videoCodec=$videoCodec, width=$width, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt index c6a13ec3..e5b9c421 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -256,20 +256,6 @@ private constructor( */ fun responseFields(): Optional> = body.responseFields() - /** - * This field is included in the response only if the Path policy feature is available in the - * plan. It contains schema definitions for the custom metadata fields selected for the - * specified file path. Field selection can only be done when the Path policy feature is - * enabled. - * - * Keys are the names of the custom metadata fields; the value object has details about the - * custom metadata schema. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun selectedFieldsSchema(): Optional = body.selectedFieldsSchema() - /** * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. Learn * how to create a signature on the page below. This should be in lowercase. @@ -468,14 +454,6 @@ private constructor( */ fun _responseFields(): MultipartField> = body._responseFields() - /** - * Returns the raw multipart value of [selectedFieldsSchema]. - * - * Unlike [selectedFieldsSchema], this method doesn't throw if the multipart field has an - * unexpected type. - */ - fun _selectedFieldsSchema(): MultipartField = body._selectedFieldsSchema() - /** * Returns the raw multipart value of [signature]. * @@ -955,31 +933,6 @@ private constructor( body.addResponseField(responseField) } - /** - * This field is included in the response only if the Path policy feature is available in - * the plan. It contains schema definitions for the custom metadata fields selected for the - * specified file path. Field selection can only be done when the Path policy feature is - * enabled. - * - * Keys are the names of the custom metadata fields; the value object has details about the - * custom metadata schema. - */ - fun selectedFieldsSchema(selectedFieldsSchema: SelectedFieldsSchema) = apply { - body.selectedFieldsSchema(selectedFieldsSchema) - } - - /** - * Sets [Builder.selectedFieldsSchema] to an arbitrary multipart value. - * - * You should usually call [Builder.selectedFieldsSchema] with a well-typed - * [SelectedFieldsSchema] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun selectedFieldsSchema(selectedFieldsSchema: MultipartField) = - apply { - body.selectedFieldsSchema(selectedFieldsSchema) - } - /** * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. * Learn how to create a signature on the page below. This should be in lowercase. @@ -1242,7 +1195,6 @@ private constructor( "overwriteTags" to _overwriteTags(), "publicKey" to _publicKey(), "responseFields" to _responseFields(), - "selectedFieldsSchema" to _selectedFieldsSchema(), "signature" to _signature(), "tags" to _tags(), "transformation" to _transformation(), @@ -1275,7 +1227,6 @@ private constructor( private val overwriteTags: MultipartField, private val publicKey: MultipartField, private val responseFields: MultipartField>, - private val selectedFieldsSchema: MultipartField, private val signature: MultipartField, private val tags: MultipartField>, private val transformation: MultipartField, @@ -1484,21 +1435,6 @@ private constructor( fun responseFields(): Optional> = responseFields.value.getOptional("responseFields") - /** - * This field is included in the response only if the Path policy feature is available in - * the plan. It contains schema definitions for the custom metadata fields selected for the - * specified file path. Field selection can only be done when the Path policy feature is - * enabled. - * - * Keys are the names of the custom metadata fields; the value object has details about the - * custom metadata schema. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun selectedFieldsSchema(): Optional = - selectedFieldsSchema.value.getOptional("selectedFieldsSchema") - /** * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. * Learn how to create a signature on the page below. This should be in lowercase. @@ -1727,16 +1663,6 @@ private constructor( @ExcludeMissing fun _responseFields(): MultipartField> = responseFields - /** - * Returns the raw multipart value of [selectedFieldsSchema]. - * - * Unlike [selectedFieldsSchema], this method doesn't throw if the multipart field has an - * unexpected type. - */ - @JsonProperty("selectedFieldsSchema") - @ExcludeMissing - fun _selectedFieldsSchema(): MultipartField = selectedFieldsSchema - /** * Returns the raw multipart value of [signature]. * @@ -1832,8 +1758,6 @@ private constructor( private var overwriteTags: MultipartField = MultipartField.of(null) private var publicKey: MultipartField = MultipartField.of(null) private var responseFields: MultipartField>? = null - private var selectedFieldsSchema: MultipartField = - MultipartField.of(null) private var signature: MultipartField = MultipartField.of(null) private var tags: MultipartField>? = null private var transformation: MultipartField = MultipartField.of(null) @@ -1861,7 +1785,6 @@ private constructor( overwriteTags = body.overwriteTags publicKey = body.publicKey responseFields = body.responseFields.map { it.toMutableList() } - selectedFieldsSchema = body.selectedFieldsSchema signature = body.signature tags = body.tags.map { it.toMutableList() } transformation = body.transformation @@ -2278,30 +2201,6 @@ private constructor( } } - /** - * This field is included in the response only if the Path policy feature is available - * in the plan. It contains schema definitions for the custom metadata fields selected - * for the specified file path. Field selection can only be done when the Path policy - * feature is enabled. - * - * Keys are the names of the custom metadata fields; the value object has details about - * the custom metadata schema. - */ - fun selectedFieldsSchema(selectedFieldsSchema: SelectedFieldsSchema) = - selectedFieldsSchema(MultipartField.of(selectedFieldsSchema)) - - /** - * Sets [Builder.selectedFieldsSchema] to an arbitrary multipart value. - * - * You should usually call [Builder.selectedFieldsSchema] with a well-typed - * [SelectedFieldsSchema] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun selectedFieldsSchema(selectedFieldsSchema: MultipartField) = - apply { - this.selectedFieldsSchema = selectedFieldsSchema - } - /** * HMAC-SHA1 digest of the token+expire using your ImageKit.io private API key as a key. * Learn how to create a signature on the page below. This should be in lowercase. @@ -2470,7 +2369,6 @@ private constructor( overwriteTags, publicKey, (responseFields ?: MultipartField.of(null)).map { it.toImmutable() }, - selectedFieldsSchema, signature, (tags ?: MultipartField.of(null)).map { it.toImmutable() }, transformation, @@ -2505,7 +2403,6 @@ private constructor( overwriteTags() publicKey() responseFields().ifPresent { it.forEach { it.validate() } } - selectedFieldsSchema().ifPresent { it.validate() } signature() tags() transformation().ifPresent { it.validate() } @@ -2546,7 +2443,6 @@ private constructor( overwriteTags == other.overwriteTags && publicKey == other.publicKey && responseFields == other.responseFields && - selectedFieldsSchema == other.selectedFieldsSchema && signature == other.signature && tags == other.tags && transformation == other.transformation && @@ -2575,7 +2471,6 @@ private constructor( overwriteTags, publicKey, responseFields, - selectedFieldsSchema, signature, tags, transformation, @@ -2588,7 +2483,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, expire=$expire, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, publicKey=$publicKey, responseFields=$responseFields, selectedFieldsSchema=$selectedFieldsSchema, signature=$signature, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + "Body{file=$file, fileName=$fileName, token=$token, checks=$checks, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, expire=$expire, extensions=$extensions, folder=$folder, isPrivateFile=$isPrivateFile, isPublished=$isPublished, overwriteAiTags=$overwriteAiTags, overwriteCustomMetadata=$overwriteCustomMetadata, overwriteFile=$overwriteFile, overwriteTags=$overwriteTags, publicKey=$publicKey, responseFields=$responseFields, signature=$signature, tags=$tags, transformation=$transformation, useUniqueFileName=$useUniqueFileName, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" } /** @@ -3821,105 +3716,6 @@ private constructor( override fun toString() = value.toString() } - /** - * This field is included in the response only if the Path policy feature is available in the - * plan. It contains schema definitions for the custom metadata fields selected for the - * specified file path. Field selection can only be done when the Path policy feature is - * enabled. - * - * Keys are the names of the custom metadata fields; the value object has details about the - * custom metadata schema. - */ - class SelectedFieldsSchema - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [SelectedFieldsSchema]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SelectedFieldsSchema]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(selectedFieldsSchema: SelectedFieldsSchema) = apply { - additionalProperties = selectedFieldsSchema.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SelectedFieldsSchema]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): SelectedFieldsSchema = - SelectedFieldsSchema(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): SelectedFieldsSchema = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SelectedFieldsSchema && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "SelectedFieldsSchema{additionalProperties=$additionalProperties}" - } - /** * Configure pre-processing (`pre`) and post-processing (`post`) transformations. * - `pre` — applied before the file is uploaded to the Media Library. Useful for reducing file diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt index fe96fb9a..9b414c10 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt @@ -40,6 +40,7 @@ private constructor( private val isPublished: JsonField, private val metadata: JsonField, private val name: JsonField, + private val selectedFieldsSchema: JsonField, private val size: JsonField, private val tags: JsonField>, private val thumbnailUrl: JsonField, @@ -85,6 +86,9 @@ private constructor( isPublished: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("selectedFieldsSchema") + @ExcludeMissing + selectedFieldsSchema: JsonField = JsonMissing.of(), @JsonProperty("size") @ExcludeMissing size: JsonField = JsonMissing.of(), @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), @JsonProperty("thumbnailUrl") @@ -116,6 +120,7 @@ private constructor( isPublished, metadata, name, + selectedFieldsSchema, size, tags, thumbnailUrl, @@ -283,6 +288,21 @@ private constructor( */ fun name(): Optional = name.getOptional("name") + /** + * This field is included in the response only if the Path policy feature is available in the + * plan. It contains schema definitions for the custom metadata fields selected for the + * specified file path. Field selection can only be done when the Path policy feature is + * enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the + * custom metadata schema. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun selectedFieldsSchema(): Optional = + selectedFieldsSchema.getOptional("selectedFieldsSchema") + /** * Size of the image file in Bytes. * @@ -473,6 +493,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [selectedFieldsSchema]. + * + * Unlike [selectedFieldsSchema], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("selectedFieldsSchema") + @ExcludeMissing + fun _selectedFieldsSchema(): JsonField = selectedFieldsSchema + /** * Returns the raw JSON value of [size]. * @@ -564,6 +594,7 @@ private constructor( private var isPublished: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() + private var selectedFieldsSchema: JsonField = JsonMissing.of() private var size: JsonField = JsonMissing.of() private var tags: JsonField>? = null private var thumbnailUrl: JsonField = JsonMissing.of() @@ -592,6 +623,7 @@ private constructor( isPublished = fileUploadResponse.isPublished metadata = fileUploadResponse.metadata name = fileUploadResponse.name + selectedFieldsSchema = fileUploadResponse.selectedFieldsSchema size = fileUploadResponse.size tags = fileUploadResponse.tags.map { it.toMutableList() } thumbnailUrl = fileUploadResponse.thumbnailUrl @@ -875,6 +907,29 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** + * This field is included in the response only if the Path policy feature is available in + * the plan. It contains schema definitions for the custom metadata fields selected for the + * specified file path. Field selection can only be done when the Path policy feature is + * enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the + * custom metadata schema. + */ + fun selectedFieldsSchema(selectedFieldsSchema: SelectedFieldsSchema) = + selectedFieldsSchema(JsonField.of(selectedFieldsSchema)) + + /** + * Sets [Builder.selectedFieldsSchema] to an arbitrary JSON value. + * + * You should usually call [Builder.selectedFieldsSchema] with a well-typed + * [SelectedFieldsSchema] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun selectedFieldsSchema(selectedFieldsSchema: JsonField) = apply { + this.selectedFieldsSchema = selectedFieldsSchema + } + /** Size of the image file in Bytes. */ fun size(size: Double) = size(JsonField.of(size)) @@ -1020,6 +1075,7 @@ private constructor( isPublished, metadata, name, + selectedFieldsSchema, size, (tags ?: JsonMissing.of()).map { it.toImmutable() }, thumbnailUrl, @@ -1055,6 +1111,7 @@ private constructor( isPublished() metadata().ifPresent { it.validate() } name() + selectedFieldsSchema().ifPresent { it.validate() } size() tags() thumbnailUrl() @@ -1097,6 +1154,7 @@ private constructor( (if (isPublished.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + + (selectedFieldsSchema.asKnown().getOrNull()?.validity() ?: 0) + (if (size.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) + (if (thumbnailUrl.asKnown().isPresent) 1 else 0) + @@ -2376,6 +2434,116 @@ private constructor( "ExtensionStatus{aiAutoDescription=$aiAutoDescription, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" } + /** + * This field is included in the response only if the Path policy feature is available in the + * plan. It contains schema definitions for the custom metadata fields selected for the + * specified file path. Field selection can only be done when the Path policy feature is + * enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the + * custom metadata schema. + */ + class SelectedFieldsSchema + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [SelectedFieldsSchema]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SelectedFieldsSchema]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(selectedFieldsSchema: SelectedFieldsSchema) = apply { + additionalProperties = selectedFieldsSchema.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SelectedFieldsSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SelectedFieldsSchema = + SelectedFieldsSchema(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): SelectedFieldsSchema = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SelectedFieldsSchema && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "SelectedFieldsSchema{additionalProperties=$additionalProperties}" + } + /** An object containing the file or file version's `id` (versionId) and `name`. */ class VersionInfo @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -2576,6 +2744,7 @@ private constructor( isPublished == other.isPublished && metadata == other.metadata && name == other.name && + selectedFieldsSchema == other.selectedFieldsSchema && size == other.size && tags == other.tags && thumbnailUrl == other.thumbnailUrl && @@ -2605,6 +2774,7 @@ private constructor( isPublished, metadata, name, + selectedFieldsSchema, size, tags, thumbnailUrl, @@ -2619,5 +2789,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FileUploadResponse{aiTags=$aiTags, audioCodec=$audioCodec, bitRate=$bitRate, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, duration=$duration, embeddedMetadata=$embeddedMetadata, extensionStatus=$extensionStatus, fileId=$fileId, filePath=$filePath, fileType=$fileType, height=$height, isPrivateFile=$isPrivateFile, isPublished=$isPublished, metadata=$metadata, name=$name, size=$size, tags=$tags, thumbnailUrl=$thumbnailUrl, url=$url, versionInfo=$versionInfo, videoCodec=$videoCodec, width=$width, additionalProperties=$additionalProperties}" + "FileUploadResponse{aiTags=$aiTags, audioCodec=$audioCodec, bitRate=$bitRate, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, duration=$duration, embeddedMetadata=$embeddedMetadata, extensionStatus=$extensionStatus, fileId=$fileId, filePath=$filePath, fileType=$fileType, height=$height, isPrivateFile=$isPrivateFile, isPublished=$isPublished, metadata=$metadata, name=$name, selectedFieldsSchema=$selectedFieldsSchema, size=$size, tags=$tags, thumbnailUrl=$thumbnailUrl, url=$url, versionInfo=$versionInfo, videoCodec=$videoCodec, width=$width, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt index f6bf26cb..1e48aded 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt @@ -335,6 +335,7 @@ private constructor( private val isPublished: JsonField, private val metadata: JsonField, private val name: JsonField, + private val selectedFieldsSchema: JsonField, private val size: JsonField, private val tags: JsonField>, private val thumbnailUrl: JsonField, @@ -388,6 +389,9 @@ private constructor( @ExcludeMissing metadata: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("selectedFieldsSchema") + @ExcludeMissing + selectedFieldsSchema: JsonField = JsonMissing.of(), @JsonProperty("size") @ExcludeMissing size: JsonField = JsonMissing.of(), @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), @JsonProperty("thumbnailUrl") @@ -419,6 +423,7 @@ private constructor( isPublished, metadata, name, + selectedFieldsSchema, size, tags, thumbnailUrl, @@ -590,6 +595,21 @@ private constructor( */ fun name(): Optional = name.getOptional("name") + /** + * This field is included in the response only if the Path policy feature is available in + * the plan. It contains schema definitions for the custom metadata fields selected for the + * specified file path. Field selection can only be done when the Path policy feature is + * enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the + * custom metadata schema. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun selectedFieldsSchema(): Optional = + selectedFieldsSchema.getOptional("selectedFieldsSchema") + /** * Size of the image file in Bytes. * @@ -787,6 +807,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [selectedFieldsSchema]. + * + * Unlike [selectedFieldsSchema], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("selectedFieldsSchema") + @ExcludeMissing + fun _selectedFieldsSchema(): JsonField = selectedFieldsSchema + /** * Returns the raw JSON value of [size]. * @@ -881,6 +911,7 @@ private constructor( private var isPublished: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() + private var selectedFieldsSchema: JsonField = JsonMissing.of() private var size: JsonField = JsonMissing.of() private var tags: JsonField>? = null private var thumbnailUrl: JsonField = JsonMissing.of() @@ -909,6 +940,7 @@ private constructor( isPublished = data.isPublished metadata = data.metadata name = data.name + selectedFieldsSchema = data.selectedFieldsSchema size = data.size tags = data.tags.map { it.toMutableList() } thumbnailUrl = data.thumbnailUrl @@ -1206,6 +1238,30 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** + * This field is included in the response only if the Path policy feature is available + * in the plan. It contains schema definitions for the custom metadata fields selected + * for the specified file path. Field selection can only be done when the Path policy + * feature is enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about + * the custom metadata schema. + */ + fun selectedFieldsSchema(selectedFieldsSchema: SelectedFieldsSchema) = + selectedFieldsSchema(JsonField.of(selectedFieldsSchema)) + + /** + * Sets [Builder.selectedFieldsSchema] to an arbitrary JSON value. + * + * You should usually call [Builder.selectedFieldsSchema] with a well-typed + * [SelectedFieldsSchema] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun selectedFieldsSchema(selectedFieldsSchema: JsonField) = + apply { + this.selectedFieldsSchema = selectedFieldsSchema + } + /** Size of the image file in Bytes. */ fun size(size: Double) = size(JsonField.of(size)) @@ -1355,6 +1411,7 @@ private constructor( isPublished, metadata, name, + selectedFieldsSchema, size, (tags ?: JsonMissing.of()).map { it.toImmutable() }, thumbnailUrl, @@ -1390,6 +1447,7 @@ private constructor( isPublished() metadata().ifPresent { it.validate() } name() + selectedFieldsSchema().ifPresent { it.validate() } size() tags() thumbnailUrl() @@ -1433,6 +1491,7 @@ private constructor( (if (isPublished.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + + (selectedFieldsSchema.asKnown().getOrNull()?.validity() ?: 0) + (if (size.asKnown().isPresent) 1 else 0) + (tags.asKnown().getOrNull()?.size ?: 0) + (if (thumbnailUrl.asKnown().isPresent) 1 else 0) + @@ -2740,6 +2799,122 @@ private constructor( "ExtensionStatus{aiAutoDescription=$aiAutoDescription, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" } + /** + * This field is included in the response only if the Path policy feature is available in + * the plan. It contains schema definitions for the custom metadata fields selected for the + * specified file path. Field selection can only be done when the Path policy feature is + * enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the + * custom metadata schema. + */ + class SelectedFieldsSchema + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SelectedFieldsSchema]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SelectedFieldsSchema]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(selectedFieldsSchema: SelectedFieldsSchema) = apply { + additionalProperties = selectedFieldsSchema.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SelectedFieldsSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SelectedFieldsSchema = + SelectedFieldsSchema(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): SelectedFieldsSchema = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SelectedFieldsSchema && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SelectedFieldsSchema{additionalProperties=$additionalProperties}" + } + /** An object containing the file or file version's `id` (versionId) and `name`. */ class VersionInfo @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -2944,6 +3119,7 @@ private constructor( isPublished == other.isPublished && metadata == other.metadata && name == other.name && + selectedFieldsSchema == other.selectedFieldsSchema && size == other.size && tags == other.tags && thumbnailUrl == other.thumbnailUrl && @@ -2973,6 +3149,7 @@ private constructor( isPublished, metadata, name, + selectedFieldsSchema, size, tags, thumbnailUrl, @@ -2987,7 +3164,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Data{aiTags=$aiTags, audioCodec=$audioCodec, bitRate=$bitRate, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, duration=$duration, embeddedMetadata=$embeddedMetadata, extensionStatus=$extensionStatus, fileId=$fileId, filePath=$filePath, fileType=$fileType, height=$height, isPrivateFile=$isPrivateFile, isPublished=$isPublished, metadata=$metadata, name=$name, size=$size, tags=$tags, thumbnailUrl=$thumbnailUrl, url=$url, versionInfo=$versionInfo, videoCodec=$videoCodec, width=$width, additionalProperties=$additionalProperties}" + "Data{aiTags=$aiTags, audioCodec=$audioCodec, bitRate=$bitRate, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, duration=$duration, embeddedMetadata=$embeddedMetadata, extensionStatus=$extensionStatus, fileId=$fileId, filePath=$filePath, fileType=$fileType, height=$height, isPrivateFile=$isPrivateFile, isPublished=$isPublished, metadata=$metadata, name=$name, selectedFieldsSchema=$selectedFieldsSchema, size=$size, tags=$tags, thumbnailUrl=$thumbnailUrl, url=$url, versionInfo=$versionInfo, videoCodec=$videoCodec, width=$width, additionalProperties=$additionalProperties}" } class Request diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt index 5ce7a267..e4adb865 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt @@ -67,27 +67,6 @@ internal class FileUploadParamsTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .tags(listOf("t-shirt", "round-neck", "men")) .transformation( FileUploadParams.Transformation.builder() @@ -167,28 +146,6 @@ internal class FileUploadParamsTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .tags(listOf("t-shirt", "round-neck", "men")) .transformation( FileUploadParams.Transformation.builder() @@ -280,36 +237,6 @@ internal class FileUploadParamsTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ), - "selectedFieldsSchema" to - MultipartField.of( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf( - "small", - "medium", - "large", - 30, - 40, - true, - ), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ), "tags" to MultipartField.of(listOf("t-shirt", "round-neck", "men")), "transformation" to MultipartField.of( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt index 9c5cab4e..8793dc70 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt @@ -145,6 +145,28 @@ internal class FileUploadResponseTest { .build() ) .name("name") + .selectedFieldsSchema( + FileUploadResponse.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .size(0.0) .addTag("string") .thumbnailUrl("thumbnailUrl") @@ -284,6 +306,28 @@ internal class FileUploadResponseTest { .build() ) assertThat(fileUploadResponse.name()).contains("name") + assertThat(fileUploadResponse.selectedFieldsSchema()) + .contains( + FileUploadResponse.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) assertThat(fileUploadResponse.size()).contains(0.0) assertThat(fileUploadResponse.tags().getOrNull()).containsExactly("string") assertThat(fileUploadResponse.thumbnailUrl()).contains("thumbnailUrl") @@ -428,6 +472,28 @@ internal class FileUploadResponseTest { .build() ) .name("name") + .selectedFieldsSchema( + FileUploadResponse.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .size(0.0) .addTag("string") .thumbnailUrl("thumbnailUrl") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt index 3af58927..fbea5ec8 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt @@ -69,27 +69,6 @@ internal class FileUploadParamsTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -172,28 +151,6 @@ internal class FileUploadParamsTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -288,36 +245,6 @@ internal class FileUploadParamsTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ), - "selectedFieldsSchema" to - MultipartField.of( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf( - "small", - "medium", - "large", - 30, - 40, - true, - ), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ), "signature" to MultipartField.of("signature"), "tags" to MultipartField.of(listOf("t-shirt", "round-neck", "men")), "transformation" to diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt index 48c228e3..17484f6b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt @@ -144,6 +144,28 @@ internal class FileUploadResponseTest { .build() ) .name("name") + .selectedFieldsSchema( + FileUploadResponse.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .size(0.0) .addTag("string") .thumbnailUrl("thumbnailUrl") @@ -283,6 +305,28 @@ internal class FileUploadResponseTest { .build() ) assertThat(fileUploadResponse.name()).contains("name") + assertThat(fileUploadResponse.selectedFieldsSchema()) + .contains( + FileUploadResponse.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) assertThat(fileUploadResponse.size()).contains(0.0) assertThat(fileUploadResponse.tags().getOrNull()).containsExactly("string") assertThat(fileUploadResponse.thumbnailUrl()).contains("thumbnailUrl") @@ -427,6 +471,28 @@ internal class FileUploadResponseTest { .build() ) .name("name") + .selectedFieldsSchema( + FileUploadResponse.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .size(0.0) .addTag("string") .thumbnailUrl("thumbnailUrl") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt index b319bfe9..fffd15cd 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt @@ -698,6 +698,28 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .name("name") + .selectedFieldsSchema( + UploadPreTransformSuccessEvent.Data.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .size(0.0) .addTag("string") .thumbnailUrl("thumbnailUrl") @@ -891,6 +913,35 @@ internal class UnsafeUnwrapWebhookEventTest { .build() ) .name("name") + .selectedFieldsSchema( + UploadPreTransformSuccessEvent.Data.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf( + "small", + "medium", + "large", + 30, + 40, + true, + ), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .size(0.0) .addTag("string") .thumbnailUrl("thumbnailUrl") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt index 3addab08..24dfa675 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt @@ -696,6 +696,28 @@ internal class UnwrapWebhookEventTest { .build() ) .name("name") + .selectedFieldsSchema( + UploadPreTransformSuccessEvent.Data.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .size(0.0) .addTag("string") .thumbnailUrl("thumbnailUrl") @@ -889,6 +911,35 @@ internal class UnwrapWebhookEventTest { .build() ) .name("name") + .selectedFieldsSchema( + UploadPreTransformSuccessEvent.Data.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf( + "small", + "medium", + "large", + 30, + 40, + true, + ), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .size(0.0) .addTag("string") .thumbnailUrl("thumbnailUrl") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt index 241d7acf..c0975186 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt @@ -163,6 +163,28 @@ internal class UploadPreTransformSuccessEventTest { .build() ) .name("name") + .selectedFieldsSchema( + UploadPreTransformSuccessEvent.Data.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .size(0.0) .addTag("string") .thumbnailUrl("thumbnailUrl") @@ -330,6 +352,28 @@ internal class UploadPreTransformSuccessEventTest { .build() ) .name("name") + .selectedFieldsSchema( + UploadPreTransformSuccessEvent.Data.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .size(0.0) .addTag("string") .thumbnailUrl("thumbnailUrl") @@ -505,6 +549,28 @@ internal class UploadPreTransformSuccessEventTest { .build() ) .name("name") + .selectedFieldsSchema( + UploadPreTransformSuccessEvent.Data.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) .size(0.0) .addTag("string") .thumbnailUrl("thumbnailUrl") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt index 38cc24d1..4978c043 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt @@ -129,28 +129,6 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -251,28 +229,6 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -373,28 +329,6 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -495,28 +429,6 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -617,28 +529,6 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -739,28 +629,6 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -861,28 +729,6 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -983,28 +829,6 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -1105,28 +929,6 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -1227,28 +1029,6 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -1349,28 +1129,6 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -1471,28 +1229,6 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -1593,28 +1329,6 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -1715,28 +1429,6 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -1837,28 +1529,6 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -1959,28 +1629,6 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( @@ -2079,28 +1727,6 @@ internal class ErrorHandlingTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt index cd9400c0..59e7191c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt @@ -101,28 +101,6 @@ internal class ServiceParamsTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index 06f7f729..f6a815c2 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -270,28 +270,6 @@ internal class FileServiceAsyncTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt index fa6659a6..6973ea50 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt @@ -81,28 +81,6 @@ internal class FileServiceAsyncTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .tags(listOf("t-shirt", "round-neck", "men")) .transformation( FileUploadParams.Transformation.builder() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index 63e26e05..d3e8e8c0 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -263,28 +263,6 @@ internal class FileServiceTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt index e68555dc..b0050868 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt @@ -81,28 +81,6 @@ internal class FileServiceTest { FileUploadParams.ResponseField.IS_PRIVATE_FILE, ) ) - .selectedFieldsSchema( - FileUploadParams.SelectedFieldsSchema.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "type" to "Text", - "defaultValue" to "string", - "isValueRequired" to true, - "maxLength" to 0, - "maxValue" to "string", - "minLength" to 0, - "minValue" to "string", - "readOnly" to true, - "selectOptions" to - listOf("small", "medium", "large", 30, 40, true), - "selectOptionsTruncated" to true, - ) - ), - ) - .build() - ) .tags(listOf("t-shirt", "round-neck", "men")) .transformation( FileUploadParams.Transformation.builder() From d8b166477c4a975905ca122dbc8b92bf92152d15 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Oct 2025 07:36:06 +0000 Subject: [PATCH 048/142] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 0c9c486c..90e53979 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-01aef94bd928f40b7209dc21df71e2312d4bee430119b30ee05d75cf5e1b4801.yml openapi_spec_hash: 054c332db88b23d362f72583dd24b2aa -config_hash: e42d7fc3a8c92c35099cc283f9a4467a +config_hash: 371b1694848e02828dd8db3265557ddf From ff67a4bf5590d1b0233568425a8f9d6540d703f5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Oct 2025 07:36:16 +0000 Subject: [PATCH 049/142] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 90e53979..bb92027a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-01aef94bd928f40b7209dc21df71e2312d4bee430119b30ee05d75cf5e1b4801.yml openapi_spec_hash: 054c332db88b23d362f72583dd24b2aa -config_hash: 371b1694848e02828dd8db3265557ddf +config_hash: 719e92ff078b4a030a1480b546be0b7a From 283eebf0735a8becac2e0a17abe1785ff5a8b30e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Oct 2025 07:47:59 +0000 Subject: [PATCH 050/142] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index bb92027a..88337313 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-01aef94bd928f40b7209dc21df71e2312d4bee430119b30ee05d75cf5e1b4801.yml openapi_spec_hash: 054c332db88b23d362f72583dd24b2aa -config_hash: 719e92ff078b4a030a1480b546be0b7a +config_hash: cb0b86a64fed7f839bb0ef6568a8ba37 From d32862ef56ea8e1ce14912508ac1ec96ccb66c46 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Oct 2025 07:50:19 +0000 Subject: [PATCH 051/142] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 88337313..b346bb7b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-01aef94bd928f40b7209dc21df71e2312d4bee430119b30ee05d75cf5e1b4801.yml openapi_spec_hash: 054c332db88b23d362f72583dd24b2aa -config_hash: cb0b86a64fed7f839bb0ef6568a8ba37 +config_hash: f351b784e512ad36eafbc0641ad61183 From 2ba84116c268a36768608a4c09656725cdf18242 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Oct 2025 09:20:53 +0000 Subject: [PATCH 052/142] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index b346bb7b..3d1832c1 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-01aef94bd928f40b7209dc21df71e2312d4bee430119b30ee05d75cf5e1b4801.yml openapi_spec_hash: 054c332db88b23d362f72583dd24b2aa -config_hash: f351b784e512ad36eafbc0641ad61183 +config_hash: 8d97605bd07a42f98d8142059b56522c From 780f9411a217501e63541e9184ae2ed646acf5e6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Oct 2025 10:02:11 +0000 Subject: [PATCH 053/142] codegen metadata --- .stats.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3d1832c1..ad4cfbf9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-01aef94bd928f40b7209dc21df71e2312d4bee430119b30ee05d75cf5e1b4801.yml -openapi_spec_hash: 054c332db88b23d362f72583dd24b2aa -config_hash: 8d97605bd07a42f98d8142059b56522c +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7ad6f552b38f2145781847f8b390fa1ec43068d64e45a33012a97a9299edc10.yml +openapi_spec_hash: 50f281e91210ad5018ac7e4eee216f56 +config_hash: 6d15773e29070b9c1d4820e4897f17a5 From 73b45cc54ec6f70ea00fea7b5b0d605c5684bc3c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 5 Oct 2025 13:50:08 +0000 Subject: [PATCH 054/142] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index ad4cfbf9..f035d349 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7ad6f552b38f2145781847f8b390fa1ec43068d64e45a33012a97a9299edc10.yml openapi_spec_hash: 50f281e91210ad5018ac7e4eee216f56 -config_hash: 6d15773e29070b9c1d4820e4897f17a5 +config_hash: 74a8263b80c732a2b016177e7d56bb9c From 70d2551ec48038eb1deb0459a0b4dc2b6506c837 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 Oct 2025 09:46:03 +0000 Subject: [PATCH 055/142] feat(api): add GetImageAttributesOptions and ResponsiveImageAttributes schemas; update resource references in main.yaml; remove dummy endpoint --- .stats.yml | 6 +- .../api/models/GetImageAttributesOptions.kt | 761 ++++++++++++++++++ .../api/models/ResponsiveImageAttributes.kt | 290 +++++++ .../models/GetImageAttributesOptionsTest.kt | 364 +++++++++ .../models/ResponsiveImageAttributesTest.kt | 55 ++ 5 files changed, 1473 insertions(+), 3 deletions(-) create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/GetImageAttributesOptions.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ResponsiveImageAttributes.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ResponsiveImageAttributesTest.kt diff --git a/.stats.yml b/.stats.yml index f035d349..27ad9e7e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7ad6f552b38f2145781847f8b390fa1ec43068d64e45a33012a97a9299edc10.yml -openapi_spec_hash: 50f281e91210ad5018ac7e4eee216f56 -config_hash: 74a8263b80c732a2b016177e7d56bb9c +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-0e4fa3c1f9d8cafecb9671fa76c0ff9156c643e05837804679e5e336bad8f4c1.yml +openapi_spec_hash: 4544b950730b721c252eb519358b8609 +config_hash: 3d7a0bc2844e9fb4797149b233e85770 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/GetImageAttributesOptions.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/GetImageAttributesOptions.kt new file mode 100644 index 00000000..96f3a01c --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/GetImageAttributesOptions.kt @@ -0,0 +1,761 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Options for generating responsive image attributes including `src`, `srcSet`, and `sizes` for + * HTML `` elements. This schema extends `SrcOptions` to add support for responsive image + * generation with breakpoints. + */ +class GetImageAttributesOptions +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val src: JsonField, + private val urlEndpoint: JsonField, + private val expiresIn: JsonField, + private val queryParameters: JsonField, + private val signed: JsonField, + private val transformation: JsonField>, + private val transformationPosition: JsonField, + private val deviceBreakpoints: JsonField>, + private val imageBreakpoints: JsonField>, + private val sizes: JsonField, + private val width: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("src") @ExcludeMissing src: JsonField = JsonMissing.of(), + @JsonProperty("urlEndpoint") + @ExcludeMissing + urlEndpoint: JsonField = JsonMissing.of(), + @JsonProperty("expiresIn") @ExcludeMissing expiresIn: JsonField = JsonMissing.of(), + @JsonProperty("queryParameters") + @ExcludeMissing + queryParameters: JsonField = JsonMissing.of(), + @JsonProperty("signed") @ExcludeMissing signed: JsonField = JsonMissing.of(), + @JsonProperty("transformation") + @ExcludeMissing + transformation: JsonField> = JsonMissing.of(), + @JsonProperty("transformationPosition") + @ExcludeMissing + transformationPosition: JsonField = JsonMissing.of(), + @JsonProperty("deviceBreakpoints") + @ExcludeMissing + deviceBreakpoints: JsonField> = JsonMissing.of(), + @JsonProperty("imageBreakpoints") + @ExcludeMissing + imageBreakpoints: JsonField> = JsonMissing.of(), + @JsonProperty("sizes") @ExcludeMissing sizes: JsonField = JsonMissing.of(), + @JsonProperty("width") @ExcludeMissing width: JsonField = JsonMissing.of(), + ) : this( + src, + urlEndpoint, + expiresIn, + queryParameters, + signed, + transformation, + transformationPosition, + deviceBreakpoints, + imageBreakpoints, + sizes, + width, + mutableMapOf(), + ) + + fun toSrcOptions(): SrcOptions = + SrcOptions.builder() + .src(src) + .urlEndpoint(urlEndpoint) + .expiresIn(expiresIn) + .queryParameters(queryParameters) + .signed(signed) + .transformation(transformation) + .transformationPosition(transformationPosition) + .build() + + /** + * Accepts a relative or absolute path of the resource. If a relative path is provided, it is + * appended to the `urlEndpoint`. If an absolute path is provided, `urlEndpoint` is ignored. + * + * @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 src(): String = src.getRequired("src") + + /** + * Get your urlEndpoint from the + * [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints). + * + * @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 urlEndpoint(): String = urlEndpoint.getRequired("urlEndpoint") + + /** + * When you want the signed URL to expire, specified in seconds. If `expiresIn` is anything + * above 0, the URL will always be signed even if `signed` is set to false. If not specified and + * `signed` is `true`, the signed URL will not expire (valid indefinitely). + * + * Example: Setting `expiresIn: 3600` will make the URL expire 1 hour from generation time. + * After the expiry time, the signed URL will no longer be valid and ImageKit will return a 401 + * Unauthorized status code. + * + * [Learn + * more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiresIn(): Optional = expiresIn.getOptional("expiresIn") + + /** + * These are additional query parameters that you want to add to the final URL. They can be any + * query parameters and not necessarily related to ImageKit. This is especially useful if you + * want to add a versioning parameter to your URLs. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun queryParameters(): Optional = + queryParameters.getOptional("queryParameters") + + /** + * Whether to sign the URL or not. Set this to `true` if you want to generate a signed URL. If + * `signed` is `true` and `expiresIn` is not specified, the signed URL will not expire (valid + * indefinitely). Note: If `expiresIn` is set to any value above 0, the URL will always be + * signed regardless of this setting. + * [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun signed(): Optional = signed.getOptional("signed") + + /** + * An array of objects specifying the transformations to be applied in the URL. If more than one + * transformation is specified, they are applied in the order they are specified as chained + * transformations. See + * [Chained transformations](https://imagekit.io/docs/transformations#chained-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") + + /** + * By default, the transformation string is added as a query parameter in the URL, e.g., + * `?tr=w-100,h-100`. If you want to add the transformation string in the path of the URL, set + * this to `path`. Learn more in the + * [Transformations guide](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 transformationPosition(): Optional = + transformationPosition.getOptional("transformationPosition") + + /** + * Custom list of **device-width breakpoints** in pixels. These define common screen widths for + * responsive image generation. + * + * Defaults to `[640, 750, 828, 1080, 1200, 1920, 2048, 3840]`. Sorted automatically. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun deviceBreakpoints(): Optional> = + deviceBreakpoints.getOptional("deviceBreakpoints") + + /** + * Custom list of **image-specific breakpoints** in pixels. Useful for generating small variants + * (e.g., placeholders or thumbnails). + * + * Merged with `deviceBreakpoints` before calculating `srcSet`. Defaults to `[16, 32, 48, 64, + * 96, 128, 256, 384]`. Sorted automatically. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun imageBreakpoints(): Optional> = + imageBreakpoints.getOptional("imageBreakpoints") + + /** + * The value for the HTML `sizes` attribute (e.g., `"100vw"` or `"(min-width:768px) 50vw, + * 100vw"`). + * - If it includes one or more `vw` units, breakpoints smaller than the corresponding + * percentage of the smallest device width are excluded. + * - If it contains no `vw` units, the full breakpoint list is used. + * + * Enables a width-based strategy and generates `w` descriptors in `srcSet`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sizes(): Optional = sizes.getOptional("sizes") + + /** + * The intended display width of the image in pixels, used **only when the `sizes` attribute is + * not provided**. + * + * Triggers a DPR-based strategy (1x and 2x variants) and generates `x` descriptors in `srcSet`. + * + * Ignored if `sizes` is present. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun width(): Optional = width.getOptional("width") + + /** + * Returns the raw JSON value of [src]. + * + * Unlike [src], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("src") @ExcludeMissing fun _src(): JsonField = src + + /** + * Returns the raw JSON value of [urlEndpoint]. + * + * Unlike [urlEndpoint], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("urlEndpoint") @ExcludeMissing fun _urlEndpoint(): JsonField = urlEndpoint + + /** + * Returns the raw JSON value of [expiresIn]. + * + * Unlike [expiresIn], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expiresIn") @ExcludeMissing fun _expiresIn(): JsonField = expiresIn + + /** + * Returns the raw JSON value of [queryParameters]. + * + * Unlike [queryParameters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("queryParameters") + @ExcludeMissing + fun _queryParameters(): JsonField = queryParameters + + /** + * Returns the raw JSON value of [signed]. + * + * Unlike [signed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("signed") @ExcludeMissing fun _signed(): JsonField = signed + + /** + * 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 [transformationPosition]. + * + * Unlike [transformationPosition], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("transformationPosition") + @ExcludeMissing + fun _transformationPosition(): JsonField = transformationPosition + + /** + * Returns the raw JSON value of [deviceBreakpoints]. + * + * Unlike [deviceBreakpoints], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("deviceBreakpoints") + @ExcludeMissing + fun _deviceBreakpoints(): JsonField> = deviceBreakpoints + + /** + * Returns the raw JSON value of [imageBreakpoints]. + * + * Unlike [imageBreakpoints], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("imageBreakpoints") + @ExcludeMissing + fun _imageBreakpoints(): JsonField> = imageBreakpoints + + /** + * Returns the raw JSON value of [sizes]. + * + * Unlike [sizes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sizes") @ExcludeMissing fun _sizes(): JsonField = sizes + + /** + * Returns the raw JSON value of [width]. + * + * Unlike [width], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("width") @ExcludeMissing fun _width(): JsonField = width + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [GetImageAttributesOptions]. + * + * The following fields are required: + * ```java + * .src() + * .urlEndpoint() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GetImageAttributesOptions]. */ + class Builder internal constructor() { + + private var src: JsonField? = null + private var urlEndpoint: JsonField? = null + private var expiresIn: JsonField = JsonMissing.of() + private var queryParameters: JsonField = JsonMissing.of() + private var signed: JsonField = JsonMissing.of() + private var transformation: JsonField>? = null + private var transformationPosition: JsonField = JsonMissing.of() + private var deviceBreakpoints: JsonField>? = null + private var imageBreakpoints: JsonField>? = null + private var sizes: JsonField = JsonMissing.of() + private var width: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(getImageAttributesOptions: GetImageAttributesOptions) = apply { + src = getImageAttributesOptions.src + urlEndpoint = getImageAttributesOptions.urlEndpoint + expiresIn = getImageAttributesOptions.expiresIn + queryParameters = getImageAttributesOptions.queryParameters + signed = getImageAttributesOptions.signed + transformation = getImageAttributesOptions.transformation.map { it.toMutableList() } + transformationPosition = getImageAttributesOptions.transformationPosition + deviceBreakpoints = + getImageAttributesOptions.deviceBreakpoints.map { it.toMutableList() } + imageBreakpoints = getImageAttributesOptions.imageBreakpoints.map { it.toMutableList() } + sizes = getImageAttributesOptions.sizes + width = getImageAttributesOptions.width + additionalProperties = getImageAttributesOptions.additionalProperties.toMutableMap() + } + + /** + * Accepts a relative or absolute path of the resource. If a relative path is provided, it + * is appended to the `urlEndpoint`. If an absolute path is provided, `urlEndpoint` is + * ignored. + */ + fun src(src: String) = src(JsonField.of(src)) + + /** + * Sets [Builder.src] to an arbitrary JSON value. + * + * You should usually call [Builder.src] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun src(src: JsonField) = apply { this.src = src } + + /** + * Get your urlEndpoint from the + * [ImageKit dashboard](https://imagekit.io/dashboard/url-endpoints). + */ + fun urlEndpoint(urlEndpoint: String) = urlEndpoint(JsonField.of(urlEndpoint)) + + /** + * Sets [Builder.urlEndpoint] to an arbitrary JSON value. + * + * You should usually call [Builder.urlEndpoint] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun urlEndpoint(urlEndpoint: JsonField) = apply { this.urlEndpoint = urlEndpoint } + + /** + * When you want the signed URL to expire, specified in seconds. If `expiresIn` is anything + * above 0, the URL will always be signed even if `signed` is set to false. If not specified + * and `signed` is `true`, the signed URL will not expire (valid indefinitely). + * + * Example: Setting `expiresIn: 3600` will make the URL expire 1 hour from generation time. + * After the expiry time, the signed URL will no longer be valid and ImageKit will return a + * 401 Unauthorized status code. + * + * [Learn + * more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + */ + fun expiresIn(expiresIn: Double) = expiresIn(JsonField.of(expiresIn)) + + /** + * Sets [Builder.expiresIn] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresIn] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun expiresIn(expiresIn: JsonField) = apply { this.expiresIn = expiresIn } + + /** + * These are additional query parameters that you want to add to the final URL. They can be + * any query parameters and not necessarily related to ImageKit. This is especially useful + * if you want to add a versioning parameter to your URLs. + */ + fun queryParameters(queryParameters: SrcOptions.QueryParameters) = + queryParameters(JsonField.of(queryParameters)) + + /** + * Sets [Builder.queryParameters] to an arbitrary JSON value. + * + * You should usually call [Builder.queryParameters] with a well-typed + * [SrcOptions.QueryParameters] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun queryParameters(queryParameters: JsonField) = apply { + this.queryParameters = queryParameters + } + + /** + * Whether to sign the URL or not. Set this to `true` if you want to generate a signed URL. + * If `signed` is `true` and `expiresIn` is not specified, the signed URL will not expire + * (valid indefinitely). Note: If `expiresIn` is set to any value above 0, the URL will + * always be signed regardless of this setting. + * [Learn more](https://imagekit.io/docs/media-delivery-basic-security#how-to-generate-signed-urls). + */ + fun signed(signed: Boolean) = signed(JsonField.of(signed)) + + /** + * Sets [Builder.signed] to an arbitrary JSON value. + * + * You should usually call [Builder.signed] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun signed(signed: JsonField) = apply { this.signed = signed } + + /** + * An array of objects specifying the transformations to be applied in the URL. If more than + * one transformation is specified, they are applied in the order they are specified as + * chained transformations. See + * [Chained transformations](https://imagekit.io/docs/transformations#chained-transformations). + */ + fun transformation(transformation: List) = + transformation(JsonField.of(transformation)) + + /** + * Sets [Builder.transformation] to an arbitrary JSON value. + * + * You should usually call [Builder.transformation] with a well-typed `List` + * 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.map { it.toMutableList() } + } + + /** + * Adds a single [Transformation] to [Builder.transformation]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTransformation(transformation: Transformation) = apply { + this.transformation = + (this.transformation ?: JsonField.of(mutableListOf())).also { + checkKnown("transformation", it).add(transformation) + } + } + + /** + * By default, the transformation string is added as a query parameter in the URL, e.g., + * `?tr=w-100,h-100`. If you want to add the transformation string in the path of the URL, + * set this to `path`. Learn more in the + * [Transformations guide](https://imagekit.io/docs/transformations). + */ + fun transformationPosition(transformationPosition: TransformationPosition) = + transformationPosition(JsonField.of(transformationPosition)) + + /** + * Sets [Builder.transformationPosition] to an arbitrary JSON value. + * + * You should usually call [Builder.transformationPosition] with a well-typed + * [TransformationPosition] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun transformationPosition(transformationPosition: JsonField) = + apply { + this.transformationPosition = transformationPosition + } + + /** + * Custom list of **device-width breakpoints** in pixels. These define common screen widths + * for responsive image generation. + * + * Defaults to `[640, 750, 828, 1080, 1200, 1920, 2048, 3840]`. Sorted automatically. + */ + fun deviceBreakpoints(deviceBreakpoints: List) = + deviceBreakpoints(JsonField.of(deviceBreakpoints)) + + /** + * Sets [Builder.deviceBreakpoints] to an arbitrary JSON value. + * + * You should usually call [Builder.deviceBreakpoints] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun deviceBreakpoints(deviceBreakpoints: JsonField>) = apply { + this.deviceBreakpoints = deviceBreakpoints.map { it.toMutableList() } + } + + /** + * Adds a single [Double] to [deviceBreakpoints]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDeviceBreakpoint(deviceBreakpoint: Double) = apply { + deviceBreakpoints = + (deviceBreakpoints ?: JsonField.of(mutableListOf())).also { + checkKnown("deviceBreakpoints", it).add(deviceBreakpoint) + } + } + + /** + * Custom list of **image-specific breakpoints** in pixels. Useful for generating small + * variants (e.g., placeholders or thumbnails). + * + * Merged with `deviceBreakpoints` before calculating `srcSet`. Defaults to `[16, 32, 48, + * 64, 96, 128, 256, 384]`. Sorted automatically. + */ + fun imageBreakpoints(imageBreakpoints: List) = + imageBreakpoints(JsonField.of(imageBreakpoints)) + + /** + * Sets [Builder.imageBreakpoints] to an arbitrary JSON value. + * + * You should usually call [Builder.imageBreakpoints] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun imageBreakpoints(imageBreakpoints: JsonField>) = apply { + this.imageBreakpoints = imageBreakpoints.map { it.toMutableList() } + } + + /** + * Adds a single [Double] to [imageBreakpoints]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addImageBreakpoint(imageBreakpoint: Double) = apply { + imageBreakpoints = + (imageBreakpoints ?: JsonField.of(mutableListOf())).also { + checkKnown("imageBreakpoints", it).add(imageBreakpoint) + } + } + + /** + * The value for the HTML `sizes` attribute (e.g., `"100vw"` or `"(min-width:768px) 50vw, + * 100vw"`). + * - If it includes one or more `vw` units, breakpoints smaller than the corresponding + * percentage of the smallest device width are excluded. + * - If it contains no `vw` units, the full breakpoint list is used. + * + * Enables a width-based strategy and generates `w` descriptors in `srcSet`. + */ + fun sizes(sizes: String) = sizes(JsonField.of(sizes)) + + /** + * Sets [Builder.sizes] to an arbitrary JSON value. + * + * You should usually call [Builder.sizes] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun sizes(sizes: JsonField) = apply { this.sizes = sizes } + + /** + * The intended display width of the image in pixels, used **only when the `sizes` attribute + * is not provided**. + * + * Triggers a DPR-based strategy (1x and 2x variants) and generates `x` descriptors in + * `srcSet`. + * + * Ignored if `sizes` is present. + */ + fun width(width: Double) = width(JsonField.of(width)) + + /** + * Sets [Builder.width] to an arbitrary JSON value. + * + * You should usually call [Builder.width] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun width(width: JsonField) = apply { this.width = width } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GetImageAttributesOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .src() + * .urlEndpoint() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GetImageAttributesOptions = + GetImageAttributesOptions( + checkRequired("src", src), + checkRequired("urlEndpoint", urlEndpoint), + expiresIn, + queryParameters, + signed, + (transformation ?: JsonMissing.of()).map { it.toImmutable() }, + transformationPosition, + (deviceBreakpoints ?: JsonMissing.of()).map { it.toImmutable() }, + (imageBreakpoints ?: JsonMissing.of()).map { it.toImmutable() }, + sizes, + width, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GetImageAttributesOptions = apply { + if (validated) { + return@apply + } + + src() + urlEndpoint() + expiresIn() + queryParameters().ifPresent { it.validate() } + signed() + transformation().ifPresent { it.forEach { it.validate() } } + transformationPosition().ifPresent { it.validate() } + deviceBreakpoints() + imageBreakpoints() + sizes() + width() + 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 (src.asKnown().isPresent) 1 else 0) + + (if (urlEndpoint.asKnown().isPresent) 1 else 0) + + (if (expiresIn.asKnown().isPresent) 1 else 0) + + (queryParameters.asKnown().getOrNull()?.validity() ?: 0) + + (if (signed.asKnown().isPresent) 1 else 0) + + (transformation.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (transformationPosition.asKnown().getOrNull()?.validity() ?: 0) + + (deviceBreakpoints.asKnown().getOrNull()?.size ?: 0) + + (imageBreakpoints.asKnown().getOrNull()?.size ?: 0) + + (if (sizes.asKnown().isPresent) 1 else 0) + + (if (width.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GetImageAttributesOptions && + src == other.src && + urlEndpoint == other.urlEndpoint && + expiresIn == other.expiresIn && + queryParameters == other.queryParameters && + signed == other.signed && + transformation == other.transformation && + transformationPosition == other.transformationPosition && + deviceBreakpoints == other.deviceBreakpoints && + imageBreakpoints == other.imageBreakpoints && + sizes == other.sizes && + width == other.width && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + src, + urlEndpoint, + expiresIn, + queryParameters, + signed, + transformation, + transformationPosition, + deviceBreakpoints, + imageBreakpoints, + sizes, + width, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GetImageAttributesOptions{src=$src, urlEndpoint=$urlEndpoint, expiresIn=$expiresIn, queryParameters=$queryParameters, signed=$signed, transformation=$transformation, transformationPosition=$transformationPosition, deviceBreakpoints=$deviceBreakpoints, imageBreakpoints=$imageBreakpoints, sizes=$sizes, width=$width, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ResponsiveImageAttributes.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ResponsiveImageAttributes.kt new file mode 100644 index 00000000..c079f6a4 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ResponsiveImageAttributes.kt @@ -0,0 +1,290 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * Resulting set of attributes suitable for an HTML `` element. Useful for enabling responsive + * image loading with `srcSet` and `sizes`. + */ +class ResponsiveImageAttributes +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val src: JsonField, + private val sizes: JsonField, + private val srcSet: JsonField, + private val width: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("src") @ExcludeMissing src: JsonField = JsonMissing.of(), + @JsonProperty("sizes") @ExcludeMissing sizes: JsonField = JsonMissing.of(), + @JsonProperty("srcSet") @ExcludeMissing srcSet: JsonField = JsonMissing.of(), + @JsonProperty("width") @ExcludeMissing width: JsonField = JsonMissing.of(), + ) : this(src, sizes, srcSet, width, mutableMapOf()) + + /** + * URL for the *largest* candidate (assigned to plain `src`). + * + * @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 src(): String = src.getRequired("src") + + /** + * `sizes` returned (or synthesised as `100vw`). The value for the HTML `sizes` attribute. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sizes(): Optional = sizes.getOptional("sizes") + + /** + * Candidate set with `w` or `x` descriptors. Multiple image URLs separated by commas, each with + * a descriptor. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun srcSet(): Optional = srcSet.getOptional("srcSet") + + /** + * Width as a number (if `width` was provided in the input options). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun width(): Optional = width.getOptional("width") + + /** + * Returns the raw JSON value of [src]. + * + * Unlike [src], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("src") @ExcludeMissing fun _src(): JsonField = src + + /** + * Returns the raw JSON value of [sizes]. + * + * Unlike [sizes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sizes") @ExcludeMissing fun _sizes(): JsonField = sizes + + /** + * Returns the raw JSON value of [srcSet]. + * + * Unlike [srcSet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("srcSet") @ExcludeMissing fun _srcSet(): JsonField = srcSet + + /** + * Returns the raw JSON value of [width]. + * + * Unlike [width], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("width") @ExcludeMissing fun _width(): JsonField = width + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ResponsiveImageAttributes]. + * + * The following fields are required: + * ```java + * .src() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ResponsiveImageAttributes]. */ + class Builder internal constructor() { + + private var src: JsonField? = null + private var sizes: JsonField = JsonMissing.of() + private var srcSet: JsonField = JsonMissing.of() + private var width: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(responsiveImageAttributes: ResponsiveImageAttributes) = apply { + src = responsiveImageAttributes.src + sizes = responsiveImageAttributes.sizes + srcSet = responsiveImageAttributes.srcSet + width = responsiveImageAttributes.width + additionalProperties = responsiveImageAttributes.additionalProperties.toMutableMap() + } + + /** URL for the *largest* candidate (assigned to plain `src`). */ + fun src(src: String) = src(JsonField.of(src)) + + /** + * Sets [Builder.src] to an arbitrary JSON value. + * + * You should usually call [Builder.src] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun src(src: JsonField) = apply { this.src = src } + + /** + * `sizes` returned (or synthesised as `100vw`). The value for the HTML `sizes` attribute. + */ + fun sizes(sizes: String) = sizes(JsonField.of(sizes)) + + /** + * Sets [Builder.sizes] to an arbitrary JSON value. + * + * You should usually call [Builder.sizes] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun sizes(sizes: JsonField) = apply { this.sizes = sizes } + + /** + * Candidate set with `w` or `x` descriptors. Multiple image URLs separated by commas, each + * with a descriptor. + */ + fun srcSet(srcSet: String) = srcSet(JsonField.of(srcSet)) + + /** + * Sets [Builder.srcSet] to an arbitrary JSON value. + * + * You should usually call [Builder.srcSet] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun srcSet(srcSet: JsonField) = apply { this.srcSet = srcSet } + + /** Width as a number (if `width` was provided in the input options). */ + fun width(width: Double) = width(JsonField.of(width)) + + /** + * Sets [Builder.width] to an arbitrary JSON value. + * + * You should usually call [Builder.width] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun width(width: JsonField) = apply { this.width = width } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ResponsiveImageAttributes]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .src() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ResponsiveImageAttributes = + ResponsiveImageAttributes( + checkRequired("src", src), + sizes, + srcSet, + width, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ResponsiveImageAttributes = apply { + if (validated) { + return@apply + } + + src() + sizes() + srcSet() + width() + 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 (src.asKnown().isPresent) 1 else 0) + + (if (sizes.asKnown().isPresent) 1 else 0) + + (if (srcSet.asKnown().isPresent) 1 else 0) + + (if (width.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResponsiveImageAttributes && + src == other.src && + sizes == other.sizes && + srcSet == other.srcSet && + width == other.width && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(src, sizes, srcSet, width, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ResponsiveImageAttributes{src=$src, sizes=$sizes, srcSet=$srcSet, width=$width, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt new file mode 100644 index 00000000..cbf1479c --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt @@ -0,0 +1,364 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class GetImageAttributesOptionsTest { + + @Test + fun create() { + val getImageAttributesOptions = + GetImageAttributesOptions.builder() + .src("/my-image.jpg") + .urlEndpoint("https://ik.imagekit.io/demo") + .expiresIn(0.0) + .queryParameters( + SrcOptions.QueryParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .signed(true) + .addTransformation( + Transformation.builder() + .aiChangeBackground("aiChangeBackground") + .aiDropShadowTrue() + .aiEdit("aiEdit") + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) + .aiRetouch(Transformation.AiRetouch.TRUE) + .aiUpscale(Transformation.AiUpscale.TRUE) + .aiVariation(Transformation.AiVariation.TRUE) + .aspectRatio("4:3") + .audioCodec(Transformation.AudioCodec.AAC) + .background("red") + .blur(10.0) + .border("5_FF0000") + .colorProfile(true) + .contrastStretch(Transformation.ContrastStretch.TRUE) + .crop(Transformation.Crop.FORCE) + .cropMode(Transformation.CropMode.PAD_RESIZE) + .defaultImage("defaultImage") + .dpr(2.0) + .duration(0.0) + .endOffset(0.0) + .flip(Transformation.Flip.H) + .focus("center") + .format(Transformation.Format.AUTO) + .gradientTrue() + .grayscale(Transformation.Grayscale.TRUE) + .height(200.0) + .lossless(true) + .metadata(true) + .named("named") + .opacity(0.0) + .original(true) + .overlay( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing( + OverlayTiming.builder() + .duration(0.0) + .end(0.0) + .start(0.0) + .build() + ) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment( + TextOverlayTransformation.InnerAlignment.LEFT + ) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + ) + .page(0.0) + .progressive(true) + .quality(80.0) + .radius(20.0) + .raw("raw") + .rotation(90.0) + .shadowTrue() + .sharpenTrue() + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trimTrue() + .unsharpMaskTrue() + .videoCodec(Transformation.VideoCodec.H264) + .width(300.0) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .zoom(0.0) + .build() + ) + .transformationPosition(TransformationPosition.PATH) + .deviceBreakpoints( + listOf(640.0, 750.0, 828.0, 1080.0, 1200.0, 1920.0, 2048.0, 3840.0) + ) + .imageBreakpoints(listOf(16.0, 32.0, 48.0, 64.0, 96.0, 128.0, 256.0, 384.0)) + .sizes("(min-width: 768px) 50vw, 100vw") + .width(400.0) + .build() + + assertThat(getImageAttributesOptions.src()).isEqualTo("/my-image.jpg") + assertThat(getImageAttributesOptions.urlEndpoint()).isEqualTo("https://ik.imagekit.io/demo") + assertThat(getImageAttributesOptions.expiresIn()).contains(0.0) + assertThat(getImageAttributesOptions.queryParameters()) + .contains( + SrcOptions.QueryParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(getImageAttributesOptions.signed()).contains(true) + assertThat(getImageAttributesOptions.transformation().getOrNull()) + .containsExactly( + Transformation.builder() + .aiChangeBackground("aiChangeBackground") + .aiDropShadowTrue() + .aiEdit("aiEdit") + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) + .aiRetouch(Transformation.AiRetouch.TRUE) + .aiUpscale(Transformation.AiUpscale.TRUE) + .aiVariation(Transformation.AiVariation.TRUE) + .aspectRatio("4:3") + .audioCodec(Transformation.AudioCodec.AAC) + .background("red") + .blur(10.0) + .border("5_FF0000") + .colorProfile(true) + .contrastStretch(Transformation.ContrastStretch.TRUE) + .crop(Transformation.Crop.FORCE) + .cropMode(Transformation.CropMode.PAD_RESIZE) + .defaultImage("defaultImage") + .dpr(2.0) + .duration(0.0) + .endOffset(0.0) + .flip(Transformation.Flip.H) + .focus("center") + .format(Transformation.Format.AUTO) + .gradientTrue() + .grayscale(Transformation.Grayscale.TRUE) + .height(200.0) + .lossless(true) + .metadata(true) + .named("named") + .opacity(0.0) + .original(true) + .overlay( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing( + OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build() + ) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + ) + .page(0.0) + .progressive(true) + .quality(80.0) + .radius(20.0) + .raw("raw") + .rotation(90.0) + .shadowTrue() + .sharpenTrue() + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trimTrue() + .unsharpMaskTrue() + .videoCodec(Transformation.VideoCodec.H264) + .width(300.0) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .zoom(0.0) + .build() + ) + assertThat(getImageAttributesOptions.transformationPosition()) + .contains(TransformationPosition.PATH) + assertThat(getImageAttributesOptions.deviceBreakpoints().getOrNull()) + .containsExactly(640.0, 750.0, 828.0, 1080.0, 1200.0, 1920.0, 2048.0, 3840.0) + assertThat(getImageAttributesOptions.imageBreakpoints().getOrNull()) + .containsExactly(16.0, 32.0, 48.0, 64.0, 96.0, 128.0, 256.0, 384.0) + assertThat(getImageAttributesOptions.sizes()).contains("(min-width: 768px) 50vw, 100vw") + assertThat(getImageAttributesOptions.width()).contains(400.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val getImageAttributesOptions = + GetImageAttributesOptions.builder() + .src("/my-image.jpg") + .urlEndpoint("https://ik.imagekit.io/demo") + .expiresIn(0.0) + .queryParameters( + SrcOptions.QueryParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .signed(true) + .addTransformation( + Transformation.builder() + .aiChangeBackground("aiChangeBackground") + .aiDropShadowTrue() + .aiEdit("aiEdit") + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) + .aiRetouch(Transformation.AiRetouch.TRUE) + .aiUpscale(Transformation.AiUpscale.TRUE) + .aiVariation(Transformation.AiVariation.TRUE) + .aspectRatio("4:3") + .audioCodec(Transformation.AudioCodec.AAC) + .background("red") + .blur(10.0) + .border("5_FF0000") + .colorProfile(true) + .contrastStretch(Transformation.ContrastStretch.TRUE) + .crop(Transformation.Crop.FORCE) + .cropMode(Transformation.CropMode.PAD_RESIZE) + .defaultImage("defaultImage") + .dpr(2.0) + .duration(0.0) + .endOffset(0.0) + .flip(Transformation.Flip.H) + .focus("center") + .format(Transformation.Format.AUTO) + .gradientTrue() + .grayscale(Transformation.Grayscale.TRUE) + .height(200.0) + .lossless(true) + .metadata(true) + .named("named") + .opacity(0.0) + .original(true) + .overlay( + TextOverlay.builder() + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .y(0.0) + .build() + ) + .timing( + OverlayTiming.builder() + .duration(0.0) + .end(0.0) + .start(0.0) + .build() + ) + .text("text") + .encoding(TextOverlay.Encoding.AUTO) + .addTransformation( + TextOverlayTransformation.builder() + .alpha(1.0) + .background("background") + .flip(TextOverlayTransformation.Flip.H) + .fontColor("fontColor") + .fontFamily("fontFamily") + .fontSize(0.0) + .innerAlignment( + TextOverlayTransformation.InnerAlignment.LEFT + ) + .lineHeight(0.0) + .padding(0.0) + .radius(0.0) + .rotation(0.0) + .typography("typography") + .width(0.0) + .build() + ) + .build() + ) + .page(0.0) + .progressive(true) + .quality(80.0) + .radius(20.0) + .raw("raw") + .rotation(90.0) + .shadowTrue() + .sharpenTrue() + .startOffset(0.0) + .addStreamingResolution(StreamingResolution._240) + .trimTrue() + .unsharpMaskTrue() + .videoCodec(Transformation.VideoCodec.H264) + .width(300.0) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .zoom(0.0) + .build() + ) + .transformationPosition(TransformationPosition.PATH) + .deviceBreakpoints( + listOf(640.0, 750.0, 828.0, 1080.0, 1200.0, 1920.0, 2048.0, 3840.0) + ) + .imageBreakpoints(listOf(16.0, 32.0, 48.0, 64.0, 96.0, 128.0, 256.0, 384.0)) + .sizes("(min-width: 768px) 50vw, 100vw") + .width(400.0) + .build() + + val roundtrippedGetImageAttributesOptions = + jsonMapper.readValue( + jsonMapper.writeValueAsString(getImageAttributesOptions), + jacksonTypeRef(), + ) + + assertThat(roundtrippedGetImageAttributesOptions).isEqualTo(getImageAttributesOptions) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ResponsiveImageAttributesTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ResponsiveImageAttributesTest.kt new file mode 100644 index 00000000..e6429aae --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ResponsiveImageAttributesTest.kt @@ -0,0 +1,55 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ResponsiveImageAttributesTest { + + @Test + fun create() { + val responsiveImageAttributes = + ResponsiveImageAttributes.builder() + .src("https://ik.imagekit.io/demo/image.jpg?tr=w-3840") + .sizes("100vw") + .srcSet( + "https://ik.imagekit.io/demo/image.jpg?tr=w-640 640w, https://ik.imagekit.io/demo/image.jpg?tr=w-1080 1080w, https://ik.imagekit.io/demo/image.jpg?tr=w-1920 1920w" + ) + .width(400.0) + .build() + + assertThat(responsiveImageAttributes.src()) + .isEqualTo("https://ik.imagekit.io/demo/image.jpg?tr=w-3840") + assertThat(responsiveImageAttributes.sizes()).contains("100vw") + assertThat(responsiveImageAttributes.srcSet()) + .contains( + "https://ik.imagekit.io/demo/image.jpg?tr=w-640 640w, https://ik.imagekit.io/demo/image.jpg?tr=w-1080 1080w, https://ik.imagekit.io/demo/image.jpg?tr=w-1920 1920w" + ) + assertThat(responsiveImageAttributes.width()).contains(400.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val responsiveImageAttributes = + ResponsiveImageAttributes.builder() + .src("https://ik.imagekit.io/demo/image.jpg?tr=w-3840") + .sizes("100vw") + .srcSet( + "https://ik.imagekit.io/demo/image.jpg?tr=w-640 640w, https://ik.imagekit.io/demo/image.jpg?tr=w-1080 1080w, https://ik.imagekit.io/demo/image.jpg?tr=w-1920 1920w" + ) + .width(400.0) + .build() + + val roundtrippedResponsiveImageAttributes = + jsonMapper.readValue( + jsonMapper.writeValueAsString(responsiveImageAttributes), + jacksonTypeRef(), + ) + + assertThat(roundtrippedResponsiveImageAttributes).isEqualTo(responsiveImageAttributes) + } +} From 4d5f93f324354b639cc57e105ddfc0c13fd087c5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 Oct 2025 10:14:09 +0000 Subject: [PATCH 056/142] codegen metadata --- .stats.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 27ad9e7e..e27f9d4f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-0e4fa3c1f9d8cafecb9671fa76c0ff9156c643e05837804679e5e336bad8f4c1.yml -openapi_spec_hash: 4544b950730b721c252eb519358b8609 -config_hash: 3d7a0bc2844e9fb4797149b233e85770 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-9d184cb502ab32a85db2889c796cdfebe812f2a55a604df79c85dd4b5e7e2add.yml +openapi_spec_hash: a9aa620376fce66532c84f9364209b0b +config_hash: bb7229ef61cee50cd6c1ac02a5a74e81 From 15118a9b5d1cb2c7bd15baa8fdf86676a11effc1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Oct 2025 05:31:52 +0000 Subject: [PATCH 057/142] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index e27f9d4f..df4337df 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-9d184cb502ab32a85db2889c796cdfebe812f2a55a604df79c85dd4b5e7e2add.yml openapi_spec_hash: a9aa620376fce66532c84f9364209b0b -config_hash: bb7229ef61cee50cd6c1ac02a5a74e81 +config_hash: d7961ccc7e3cafdf8f56d6c89c3c7d62 From 6b94acda1b23842639ff029d374d5e55357b9059 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Oct 2025 05:32:47 +0000 Subject: [PATCH 058/142] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index df4337df..43d92ddb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-9d184cb502ab32a85db2889c796cdfebe812f2a55a604df79c85dd4b5e7e2add.yml openapi_spec_hash: a9aa620376fce66532c84f9364209b0b -config_hash: d7961ccc7e3cafdf8f56d6c89c3c7d62 +config_hash: c2c1c0a5c85d678e5aa8996f3637b616 From 52a222e58f609ee9a941a699264a9e024881c097 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Oct 2025 05:45:23 +0000 Subject: [PATCH 059/142] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 43d92ddb..ae3aead6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-9d184cb502ab32a85db2889c796cdfebe812f2a55a604df79c85dd4b5e7e2add.yml openapi_spec_hash: a9aa620376fce66532c84f9364209b0b -config_hash: c2c1c0a5c85d678e5aa8996f3637b616 +config_hash: eb4cf65a4c6b26a2901076eff5810d5d From ccb0ffb22b5a6ce7789110fa3d83e42a279fcb22 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 13 Nov 2025 06:46:52 +0000 Subject: [PATCH 060/142] fix(client): multi-value header serialization --- .../kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt index f86881b5..398d0745 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt @@ -109,19 +109,19 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC val builder = Request.Builder().url(toUrl()).method(method.name, body) headers.names().forEach { name -> - headers.values(name).forEach { builder.header(name, it) } + headers.values(name).forEach { builder.addHeader(name, it) } } if ( !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 ) { - builder.header( + builder.addHeader( "X-Stainless-Read-Timeout", Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), ) } if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { - builder.header( + builder.addHeader( "X-Stainless-Timeout", Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), ) From d4b8c848066b410e35a95c555bc238f8e5228b83 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 26 Nov 2025 19:59:05 +0000 Subject: [PATCH 061/142] fix(client): cancel okhttp call when future cancelled --- image-kit-java-client-okhttp/build.gradle.kts | 1 + .../api/client/okhttp/OkHttpClient.kt | 34 ++++++++------ .../api/client/okhttp/OkHttpClientTest.kt | 44 +++++++++++++++++++ 3 files changed, 65 insertions(+), 14 deletions(-) create mode 100644 image-kit-java-client-okhttp/src/test/kotlin/com/imagekit/api/client/okhttp/OkHttpClientTest.kt diff --git a/image-kit-java-client-okhttp/build.gradle.kts b/image-kit-java-client-okhttp/build.gradle.kts index cd001ec2..fae6d579 100644 --- a/image-kit-java-client-okhttp/build.gradle.kts +++ b/image-kit-java-client-okhttp/build.gradle.kts @@ -11,4 +11,5 @@ dependencies { testImplementation(kotlin("test")) testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") } diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt index 398d0745..91366fec 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt @@ -13,6 +13,7 @@ import java.io.IOException import java.io.InputStream import java.net.Proxy import java.time.Duration +import java.util.concurrent.CancellationException import java.util.concurrent.CompletableFuture import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory @@ -29,8 +30,8 @@ import okhttp3.Response import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink -class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient) : - HttpClient { +class OkHttpClient +private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient { override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { val call = newCall(request, requestOptions) @@ -50,20 +51,25 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC ): CompletableFuture { val future = CompletableFuture() - request.body?.run { future.whenComplete { _, _ -> close() } } - - newCall(request, requestOptions) - .enqueue( - object : Callback { - override fun onResponse(call: Call, response: Response) { - future.complete(response.toResponse()) - } + val call = newCall(request, requestOptions) + call.enqueue( + object : Callback { + override fun onResponse(call: Call, response: Response) { + future.complete(response.toResponse()) + } - override fun onFailure(call: Call, e: IOException) { - future.completeExceptionally(ImageKitIoException("Request failed", e)) - } + override fun onFailure(call: Call, e: IOException) { + future.completeExceptionally(ImageKitIoException("Request failed", e)) } - ) + } + ) + + future.whenComplete { _, e -> + if (e is CancellationException) { + call.cancel() + } + request.body?.close() + } return future } diff --git a/image-kit-java-client-okhttp/src/test/kotlin/com/imagekit/api/client/okhttp/OkHttpClientTest.kt b/image-kit-java-client-okhttp/src/test/kotlin/com/imagekit/api/client/okhttp/OkHttpClientTest.kt new file mode 100644 index 00000000..d99380df --- /dev/null +++ b/image-kit-java-client-okhttp/src/test/kotlin/com/imagekit/api/client/okhttp/OkHttpClientTest.kt @@ -0,0 +1,44 @@ +package com.imagekit.api.client.okhttp + +import com.github.tomakehurst.wiremock.client.WireMock.* +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class OkHttpClientTest { + + private lateinit var baseUrl: String + private lateinit var httpClient: OkHttpClient + + @BeforeEach + fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { + baseUrl = wmRuntimeInfo.httpBaseUrl + httpClient = OkHttpClient.builder().build() + } + + @Test + fun executeAsync_whenFutureCancelled_cancelsUnderlyingCall() { + stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) + val responseFuture = + httpClient.executeAsync( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build() + ) + val call = httpClient.okHttpClient.dispatcher.runningCalls().single() + + responseFuture.cancel(false) + + // Should have cancelled the underlying call + assertThat(call.isCanceled()).isTrue() + } +} From 2273b04035285050a65b6703e523789905d71387 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Dec 2025 08:46:23 +0000 Subject: [PATCH 062/142] docs: remove `$` for better copy-pasteabality --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 28acd4e2..492accde 100644 --- a/README.md +++ b/README.md @@ -305,13 +305,13 @@ The SDK uses the standard [OkHttp logging interceptor](https://github.com/square Enable logging by setting the `IMAGE_KIT_LOG` environment variable to `info`: ```sh -$ export IMAGE_KIT_LOG=info +export IMAGE_KIT_LOG=info ``` Or to `debug` for more verbose logging: ```sh -$ export IMAGE_KIT_LOG=debug +export IMAGE_KIT_LOG=debug ``` ## ProGuard and R8 From ef2d36ed1208d88cbd754c33f79b1ba7cc988d9a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 8 Dec 2025 09:57:57 +0000 Subject: [PATCH 063/142] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index ae3aead6..8577a4cc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-9d184cb502ab32a85db2889c796cdfebe812f2a55a604df79c85dd4b5e7e2add.yml openapi_spec_hash: a9aa620376fce66532c84f9364209b0b -config_hash: eb4cf65a4c6b26a2901076eff5810d5d +config_hash: 10b48f323ed534664483af1952174d52 From 2ac6ea4c59f1ed5031af541af36b909e91df2b5c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 8 Dec 2025 12:31:29 +0000 Subject: [PATCH 064/142] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 8577a4cc..6dfdc12a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-9d184cb502ab32a85db2889c796cdfebe812f2a55a604df79c85dd4b5e7e2add.yml openapi_spec_hash: a9aa620376fce66532c84f9364209b0b -config_hash: 10b48f323ed534664483af1952174d52 +config_hash: fd112bd17c0c8e9f81a50d0e15ea70d6 From 24ea2421955f30ca55fcb9383426a7be14bc02fd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 12 Dec 2025 11:53:45 +0000 Subject: [PATCH 065/142] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 6dfdc12a..2e7957ed 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-9d184cb502ab32a85db2889c796cdfebe812f2a55a604df79c85dd4b5e7e2add.yml openapi_spec_hash: a9aa620376fce66532c84f9364209b0b -config_hash: fd112bd17c0c8e9f81a50d0e15ea70d6 +config_hash: 2a4d7992f6d3a0db0e9a430d513d94e6 From 1b2ada9f5f9400b0db81452da306e3957d03a09c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 12 Dec 2025 11:54:39 +0000 Subject: [PATCH 066/142] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 2e7957ed..f03cc097 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-9d184cb502ab32a85db2889c796cdfebe812f2a55a604df79c85dd4b5e7e2add.yml openapi_spec_hash: a9aa620376fce66532c84f9364209b0b -config_hash: 2a4d7992f6d3a0db0e9a430d513d94e6 +config_hash: b4f610d4f53fe5bb17b35cf77a7521ea From 6c7f656f9aa9b591315c20022e7c5851d548bece Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 12 Dec 2025 12:00:41 +0000 Subject: [PATCH 067/142] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index f03cc097..e75a1bc7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 42 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-9d184cb502ab32a85db2889c796cdfebe812f2a55a604df79c85dd4b5e7e2add.yml openapi_spec_hash: a9aa620376fce66532c84f9364209b0b -config_hash: b4f610d4f53fe5bb17b35cf77a7521ea +config_hash: 71cab8223bb5610c6c7ca6e9c4cc1f89 From fa1b9b7159b51b86831440ba956082f3d2619c37 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 5 Jan 2026 04:05:30 +0000 Subject: [PATCH 068/142] feat(client): add `HttpRequest#url()` method --- LICENSE | 2 +- .../com/imagekit/api/core/http/HttpRequest.kt | 30 +++++ .../imagekit/api/core/http/HttpRequestTest.kt | 110 ++++++++++++++++++ 3 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/HttpRequestTest.kt diff --git a/LICENSE b/LICENSE index e7a4d160..20278610 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2025 Image Kit + Copyright 2026 Image Kit Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequest.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequest.kt index 7cbf3855..9852b94d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequest.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequest.kt @@ -2,6 +2,7 @@ package com.imagekit.api.core.http import com.imagekit.api.core.checkRequired import com.imagekit.api.core.toImmutable +import java.net.URLEncoder class HttpRequest private constructor( @@ -13,6 +14,35 @@ private constructor( @get:JvmName("body") val body: HttpRequestBody?, ) { + fun url(): String = buildString { + append(baseUrl) + + pathSegments.forEach { segment -> + if (!endsWith("/")) { + append("/") + } + append(URLEncoder.encode(segment, "UTF-8")) + } + + if (queryParams.isEmpty()) { + return@buildString + } + + append("?") + var isFirst = true + queryParams.keys().forEach { key -> + queryParams.values(key).forEach { value -> + if (!isFirst) { + append("&") + } + append(URLEncoder.encode(key, "UTF-8")) + append("=") + append(URLEncoder.encode(value, "UTF-8")) + isFirst = false + } + } + } + fun toBuilder(): Builder = Builder().from(this) override fun toString(): String = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/HttpRequestTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/HttpRequestTest.kt new file mode 100644 index 00000000..dec0c7ad --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/HttpRequestTest.kt @@ -0,0 +1,110 @@ +package com.imagekit.api.core.http + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class HttpRequestTest { + + enum class UrlTestCase(val request: HttpRequest, val expectedUrl: String) { + BASE_URL_ONLY( + HttpRequest.builder().method(HttpMethod.GET).baseUrl("https://api.example.com").build(), + expectedUrl = "https://api.example.com", + ), + BASE_URL_WITH_TRAILING_SLASH( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com/") + .build(), + expectedUrl = "https://api.example.com/", + ), + SINGLE_PATH_SEGMENT( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("users") + .build(), + expectedUrl = "https://api.example.com/users", + ), + MULTIPLE_PATH_SEGMENTS( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegments("users", "123", "profile") + .build(), + expectedUrl = "https://api.example.com/users/123/profile", + ), + PATH_SEGMENT_WITH_SPECIAL_CHARS( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("user name") + .build(), + expectedUrl = "https://api.example.com/user+name", + ), + SINGLE_QUERY_PARAM( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("users") + .putQueryParam("limit", "10") + .build(), + expectedUrl = "https://api.example.com/users?limit=10", + ), + MULTIPLE_QUERY_PARAMS( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("users") + .putQueryParam("limit", "10") + .putQueryParam("offset", "20") + .build(), + expectedUrl = "https://api.example.com/users?limit=10&offset=20", + ), + QUERY_PARAM_WITH_SPECIAL_CHARS( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("search") + .putQueryParam("q", "hello world") + .build(), + expectedUrl = "https://api.example.com/search?q=hello+world", + ), + MULTIPLE_VALUES_SAME_PARAM( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("users") + .putQueryParams("tags", listOf("admin", "user")) + .build(), + expectedUrl = "https://api.example.com/users?tags=admin&tags=user", + ), + BASE_URL_WITH_TRAILING_SLASH_AND_PATH( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com/") + .addPathSegment("users") + .build(), + expectedUrl = "https://api.example.com/users", + ), + COMPLEX_URL( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl("https://api.example.com") + .addPathSegments("v1", "users", "123") + .putQueryParams("include", listOf("profile", "settings")) + .putQueryParam("format", "json") + .build(), + expectedUrl = + "https://api.example.com/v1/users/123?include=profile&include=settings&format=json", + ), + } + + @ParameterizedTest + @EnumSource + fun url(testCase: UrlTestCase) { + val actualUrl = testCase.request.url() + + assertThat(actualUrl).isEqualTo(testCase.expectedUrl) + } +} From 41bf7009b03948c41ffd933a80ee0ffea1a7a00b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 5 Jan 2026 20:49:12 +0000 Subject: [PATCH 069/142] docs: prominently feature MCP server setup in root SDK readmes --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 492accde..70c2d6f0 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,15 @@ The Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java. +## MCP Server + +Use the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application. + +[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl19) +[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%7D) + +> Note: You may need to set environment variables in your MCP client. + The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1). ## Installation From a7be5cec994774da7ba3c6129e63d13686d065c9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 9 Jan 2026 00:56:16 +0000 Subject: [PATCH 070/142] feat(client): allow configuring dispatcher executor service --- .../api/client/okhttp/ImageKitOkHttpClient.kt | 22 +++++++++++++++++++ .../okhttp/ImageKitOkHttpClientAsync.kt | 22 +++++++++++++++++++ .../api/client/okhttp/OkHttpClient.kt | 9 ++++++++ 3 files changed, 53 insertions(+) diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt index dc4d4961..8f719c14 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt @@ -16,6 +16,7 @@ import java.net.Proxy import java.time.Clock import java.time.Duration import java.util.Optional +import java.util.concurrent.ExecutorService import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager @@ -44,11 +45,31 @@ class ImageKitOkHttpClient private constructor() { class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() + private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null + /** + * The executor service to use for running HTTP requests. + * + * Defaults to OkHttp's + * [default executor service](https://github.com/square/okhttp/blob/ace792f443b2ffb17974f5c0d1cecdf589309f26/okhttp/src/commonJvmAndroid/kotlin/okhttp3/Dispatcher.kt#L98-L104). + * + * This class takes ownership of the executor service and shuts it down when closed. + */ + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { + this.dispatcherExecutorService = dispatcherExecutorService + } + + /** + * Alias for calling [Builder.dispatcherExecutorService] with + * `dispatcherExecutorService.orElse(null)`. + */ + fun dispatcherExecutorService(dispatcherExecutorService: Optional) = + dispatcherExecutorService(dispatcherExecutorService.getOrNull()) + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ @@ -325,6 +346,7 @@ class ImageKitOkHttpClient private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .dispatcherExecutorService(dispatcherExecutorService) .sslSocketFactory(sslSocketFactory) .trustManager(trustManager) .hostnameVerifier(hostnameVerifier) diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt index 305798c8..ec9c933f 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt @@ -16,6 +16,7 @@ import java.net.Proxy import java.time.Clock import java.time.Duration import java.util.Optional +import java.util.concurrent.ExecutorService import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager @@ -44,11 +45,31 @@ class ImageKitOkHttpClientAsync private constructor() { class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() + private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null + /** + * The executor service to use for running HTTP requests. + * + * Defaults to OkHttp's + * [default executor service](https://github.com/square/okhttp/blob/ace792f443b2ffb17974f5c0d1cecdf589309f26/okhttp/src/commonJvmAndroid/kotlin/okhttp3/Dispatcher.kt#L98-L104). + * + * This class takes ownership of the executor service and shuts it down when closed. + */ + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { + this.dispatcherExecutorService = dispatcherExecutorService + } + + /** + * Alias for calling [Builder.dispatcherExecutorService] with + * `dispatcherExecutorService.orElse(null)`. + */ + fun dispatcherExecutorService(dispatcherExecutorService: Optional) = + dispatcherExecutorService(dispatcherExecutorService.getOrNull()) + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ @@ -325,6 +346,7 @@ class ImageKitOkHttpClientAsync private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .dispatcherExecutorService(dispatcherExecutorService) .sslSocketFactory(sslSocketFactory) .trustManager(trustManager) .hostnameVerifier(hostnameVerifier) diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt index 91366fec..8f64b63d 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt @@ -15,11 +15,13 @@ import java.net.Proxy import java.time.Duration import java.util.concurrent.CancellationException import java.util.concurrent.CompletableFuture +import java.util.concurrent.ExecutorService import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager import okhttp3.Call import okhttp3.Callback +import okhttp3.Dispatcher import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType import okhttp3.MediaType.Companion.toMediaType @@ -198,6 +200,7 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null + private var dispatcherExecutorService: ExecutorService? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null @@ -208,6 +211,10 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { + this.dispatcherExecutorService = dispatcherExecutorService + } + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { this.sslSocketFactory = sslSocketFactory } @@ -229,6 +236,8 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien .callTimeout(timeout.request()) .proxy(proxy) .apply { + dispatcherExecutorService?.let { dispatcher(Dispatcher(it)) } + val sslSocketFactory = sslSocketFactory val trustManager = trustManager if (sslSocketFactory != null && trustManager != null) { From 83de2bfb62facd417c3cd626c0f3a7ed7e989165 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 12 Jan 2026 23:00:41 +0000 Subject: [PATCH 071/142] chore(internal): support uploading Maven repo artifacts to stainless package server --- .github/workflows/ci.yml | 18 ++++ .../main/kotlin/image-kit.publish.gradle.kts | 8 ++ scripts/upload-artifacts | 96 +++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100755 scripts/upload-artifacts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02410e79..89204503 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,9 @@ jobs: build: timeout-minutes: 15 name: build + permissions: + contents: read + id-token: write runs-on: ${{ github.repository == 'stainless-sdks/imagekit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork @@ -61,6 +64,21 @@ jobs: - name: Build SDK run: ./scripts/build + - name: Get GitHub OIDC Token + if: github.repository == 'stainless-sdks/imagekit-java' + id: github-oidc + uses: actions/github-script@v6 + with: + script: core.setOutput('github_token', await core.getIDToken()); + + - name: Build and upload Maven artifacts + if: github.repository == 'stainless-sdks/imagekit-java' + env: + URL: https://pkg.stainless.com/s + AUTH: ${{ steps.github-oidc.outputs.github_token }} + SHA: ${{ github.sha }} + PROJECT: imagekit-java + run: ./scripts/upload-artifacts test: timeout-minutes: 15 name: test diff --git a/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts b/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts index 3b7ce2e2..2ab3f74a 100644 --- a/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts @@ -40,6 +40,14 @@ configure { } } } + repositories { + if (project.hasProperty("publishLocal")) { + maven { + name = "LocalFileSystem" + url = uri("${rootProject.layout.buildDirectory.get()}/local-maven-repo") + } + } + } } signing { diff --git a/scripts/upload-artifacts b/scripts/upload-artifacts new file mode 100755 index 00000000..729e6f22 --- /dev/null +++ b/scripts/upload-artifacts @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# ANSI Color Codes +GREEN='\033[32m' +RED='\033[31m' +NC='\033[0m' # No Color + +log_error() { + local msg="$1" + local headers="$2" + local body="$3" + echo -e "${RED}${msg}${NC}" + [[ -f "$headers" ]] && echo -e "${RED}Headers:$(cat "$headers")${NC}" + echo -e "${RED}Body: ${body}${NC}" + exit 1 +} + +upload_file() { + local file_name="$1" + local tmp_headers + tmp_headers=$(mktemp) + + if [ -f "$file_name" ]; then + echo -e "${GREEN}Processing file: $file_name${NC}" + pkg_file_name="mvn${file_name#./build/local-maven-repo}" + + # Get signed URL for uploading artifact file + signed_url_response=$(curl -X POST -G "$URL" \ + -sS --retry 5 \ + -D "$tmp_headers" \ + --data-urlencode "filename=$pkg_file_name" \ + -H "Authorization: Bearer $AUTH" \ + -H "Content-Type: application/json") + + # Validate JSON and extract URL + if ! signed_url=$(echo "$signed_url_response" | jq -e -r '.url' 2>/dev/null) || [[ "$signed_url" == "null" ]]; then + log_error "Failed to get valid signed URL" "$tmp_headers" "$signed_url_response" + fi + + # Set content-type based on file extension + local extension="${file_name##*.}" + local content_type + case "$extension" in + jar) content_type="application/java-archive" ;; + md5|sha1|sha256|sha512) content_type="text/plain" ;; + module) content_type="application/json" ;; + pom|xml) content_type="application/xml" ;; + *) content_type="application/octet-stream" ;; + esac + + # Upload file + upload_response=$(curl -v -X PUT \ + --retry 5 \ + -D "$tmp_headers" \ + -H "Content-Type: $content_type" \ + --data-binary "@${file_name}" "$signed_url" 2>&1) + + if ! echo "$upload_response" | grep -q "HTTP/[0-9.]* 200"; then + log_error "Failed upload artifact file" "$tmp_headers" "$upload_response" + fi + + # Insert small throttle to reduce rate limiting risk + sleep 0.1 + fi +} + +walk_tree() { + local current_dir="$1" + + for entry in "$current_dir"/*; do + # Check that entry is valid + [ -e "$entry" ] || [ -h "$entry" ] || continue + + if [ -d "$entry" ]; then + walk_tree "$entry" + else + upload_file "$entry" + fi + done +} + +cd "$(dirname "$0")/.." + +echo "::group::Creating local Maven content" +./gradlew publishMavenPublicationToLocalFileSystemRepository -PpublishLocal +echo "::endgroup::" + +echo "::group::Uploading to pkg.stainless.com" +walk_tree "./build/local-maven-repo" +echo "::endgroup::" + +echo "::group::Generating instructions" +echo "Configure maven or gradle to use the repo located at 'https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn'" +echo "::endgroup::" From 1bca6144095239ef2892cd989f89136e4af1a953 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 15 Jan 2026 06:52:13 +0000 Subject: [PATCH 072/142] feat(api): Add saved extensions API and enhance transformation options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added complete CRUD API endpoints for saved extensions, allowing users to save complex extension configurations and reuse them across multiple assets Fixed metadata endpoint path: /v1/files/metadata → /v1/metadata Added and improved transformation options e.g. color replace, layer modes, distort effect, gradient background etc. --- .stats.yml | 8 +- .../com/imagekit/api/client/ImageKitClient.kt | 5 + .../api/client/ImageKitClientAsync.kt | 5 + .../api/client/ImageKitClientAsyncImpl.kt | 14 + .../imagekit/api/client/ImageKitClientImpl.kt | 14 + .../com/imagekit/api/models/BaseOverlay.kt | 254 +- .../imagekit/api/models/ExtensionConfig.kt | 6598 +++++++++++++++++ .../com/imagekit/api/models/ImageOverlay.kt | 119 +- .../com/imagekit/api/models/SavedExtension.kt | 383 + .../imagekit/api/models/SolidColorOverlay.kt | 98 +- .../models/SolidColorOverlayTransformation.kt | 63 +- .../imagekit/api/models/SubtitleOverlay.kt | 119 +- .../models/SubtitleOverlayTransformation.kt | 10 +- .../com/imagekit/api/models/TextOverlay.kt | 116 +- .../api/models/TextOverlayTransformation.kt | 87 +- .../com/imagekit/api/models/Transformation.kt | 181 +- .../com/imagekit/api/models/VideoOverlay.kt | 119 +- .../models/beta/v2/files/FileUploadParams.kt | 5101 ++++++++++++- .../CustomMetadataField.kt | 74 +- .../CustomMetadataFieldCreateParams.kt | 74 +- .../CustomMetadataFieldUpdateParams.kt | 74 +- .../api/models/files/FileUploadParams.kt | 5101 ++++++++++++- .../api/models/files/UpdateFileRequest.kt | 6254 +++++++++++++++- .../SavedExtensionCreateParams.kt | 637 ++ .../SavedExtensionDeleteParams.kt | 232 + .../SavedExtensionGetParams.kt | 189 + .../SavedExtensionListParams.kt | 174 + .../SavedExtensionUpdateParams.kt | 613 ++ .../async/SavedExtensionServiceAsync.kt | 335 + .../async/SavedExtensionServiceAsyncImpl.kt | 247 + .../async/files/MetadataServiceAsync.kt | 2 +- .../async/files/MetadataServiceAsyncImpl.kt | 4 +- .../blocking/SavedExtensionService.kt | 333 + .../blocking/SavedExtensionServiceImpl.kt | 227 + .../blocking/files/MetadataService.kt | 2 +- .../blocking/files/MetadataServiceImpl.kt | 4 +- .../imagekit/api/models/BaseOverlayTest.kt | 3 + .../api/models/ExtensionConfigTest.kt | 193 + .../models/GetImageAttributesOptionsTest.kt | 9 + .../imagekit/api/models/ImageOverlayTest.kt | 12 + .../com/imagekit/api/models/OverlayTest.kt | 22 + .../imagekit/api/models/SavedExtensionTest.kt | 93 + .../api/models/SolidColorOverlayTest.kt | 3 + .../com/imagekit/api/models/SrcOptionsTest.kt | 9 + .../api/models/SubtitleOverlayTest.kt | 3 + .../imagekit/api/models/TextOverlayTest.kt | 3 + .../imagekit/api/models/TransformationTest.kt | 9 + .../imagekit/api/models/VideoOverlayTest.kt | 12 + .../beta/v2/files/FileUploadParamsTest.kt | 392 +- .../api/models/files/FileUpdateParamsTest.kt | 122 +- .../api/models/files/FileUploadParamsTest.kt | 392 +- .../api/models/files/UpdateFileRequestTest.kt | 257 +- .../SavedExtensionCreateParamsTest.kt | 90 + .../SavedExtensionDeleteParamsTest.kt | 23 + .../SavedExtensionGetParamsTest.kt | 23 + .../SavedExtensionListParamsTest.kt | 13 + .../SavedExtensionUpdateParamsTest.kt | 89 + .../api/services/ErrorHandlingTest.kt | 2433 +++++- .../api/services/ServiceParamsTest.kt | 121 +- .../services/async/FileServiceAsyncTest.kt | 179 +- .../async/SavedExtensionServiceAsyncTest.kt | 139 + .../async/beta/v2/FileServiceAsyncTest.kt | 138 +- .../api/services/blocking/FileServiceTest.kt | 179 +- .../blocking/SavedExtensionServiceTest.kt | 133 + .../blocking/beta/v2/FileServiceTest.kt | 138 +- .../api/proguard/ProGuardCompatibilityTest.kt | 43 +- 66 files changed, 32510 insertions(+), 635 deletions(-) create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SavedExtension.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionCreateParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionDeleteParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionGetParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionListParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionUpdateParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsync.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncImpl.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/SavedExtensionService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceImpl.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExtensionConfigTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SavedExtensionTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionCreateParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionDeleteParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionGetParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionListParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionUpdateParamsTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt diff --git a/.stats.yml b/.stats.yml index e75a1bc7..fdbd8925 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 42 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-9d184cb502ab32a85db2889c796cdfebe812f2a55a604df79c85dd4b5e7e2add.yml -openapi_spec_hash: a9aa620376fce66532c84f9364209b0b -config_hash: 71cab8223bb5610c6c7ca6e9c4cc1f89 +configured_endpoints: 47 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-7a3257eb171467b637c8d72877f201c2e6038c71ed447a9453230b7309ce7416.yml +openapi_spec_hash: 87b000a9989ad5c9526f28d91b8a1749 +config_hash: aeb6eb949d73382270bbd8bbf2e4cf2a diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt index ff5e2276..6b222fca 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt @@ -10,6 +10,7 @@ import com.imagekit.api.services.blocking.CacheService import com.imagekit.api.services.blocking.CustomMetadataFieldService import com.imagekit.api.services.blocking.FileService import com.imagekit.api.services.blocking.FolderService +import com.imagekit.api.services.blocking.SavedExtensionService import com.imagekit.api.services.blocking.WebhookService import java.util.function.Consumer @@ -53,6 +54,8 @@ interface ImageKitClient { fun files(): FileService + fun savedExtensions(): SavedExtensionService + fun assets(): AssetService fun cache(): CacheService @@ -92,6 +95,8 @@ interface ImageKitClient { fun files(): FileService.WithRawResponse + fun savedExtensions(): SavedExtensionService.WithRawResponse + fun assets(): AssetService.WithRawResponse fun cache(): CacheService.WithRawResponse diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt index 22131527..b070668e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt @@ -10,6 +10,7 @@ import com.imagekit.api.services.async.CacheServiceAsync import com.imagekit.api.services.async.CustomMetadataFieldServiceAsync import com.imagekit.api.services.async.FileServiceAsync import com.imagekit.api.services.async.FolderServiceAsync +import com.imagekit.api.services.async.SavedExtensionServiceAsync import com.imagekit.api.services.async.WebhookServiceAsync import java.util.function.Consumer @@ -53,6 +54,8 @@ interface ImageKitClientAsync { fun files(): FileServiceAsync + fun savedExtensions(): SavedExtensionServiceAsync + fun assets(): AssetServiceAsync fun cache(): CacheServiceAsync @@ -96,6 +99,8 @@ interface ImageKitClientAsync { fun files(): FileServiceAsync.WithRawResponse + fun savedExtensions(): SavedExtensionServiceAsync.WithRawResponse + fun assets(): AssetServiceAsync.WithRawResponse fun cache(): CacheServiceAsync.WithRawResponse diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt index 4ddc0590..9fe9056f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt @@ -18,6 +18,8 @@ import com.imagekit.api.services.async.FileServiceAsync import com.imagekit.api.services.async.FileServiceAsyncImpl import com.imagekit.api.services.async.FolderServiceAsync import com.imagekit.api.services.async.FolderServiceAsyncImpl +import com.imagekit.api.services.async.SavedExtensionServiceAsync +import com.imagekit.api.services.async.SavedExtensionServiceAsyncImpl import com.imagekit.api.services.async.WebhookServiceAsync import com.imagekit.api.services.async.WebhookServiceAsyncImpl import java.util.function.Consumer @@ -45,6 +47,10 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK private val files: FileServiceAsync by lazy { FileServiceAsyncImpl(clientOptionsWithUserAgent) } + private val savedExtensions: SavedExtensionServiceAsync by lazy { + SavedExtensionServiceAsyncImpl(clientOptionsWithUserAgent) + } + private val assets: AssetServiceAsync by lazy { AssetServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -78,6 +84,8 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK override fun files(): FileServiceAsync = files + override fun savedExtensions(): SavedExtensionServiceAsync = savedExtensions + override fun assets(): AssetServiceAsync = assets override fun cache(): CacheServiceAsync = cache @@ -103,6 +111,10 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK FileServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val savedExtensions: SavedExtensionServiceAsync.WithRawResponse by lazy { + SavedExtensionServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + private val assets: AssetServiceAsync.WithRawResponse by lazy { AssetServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -139,6 +151,8 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK override fun files(): FileServiceAsync.WithRawResponse = files + override fun savedExtensions(): SavedExtensionServiceAsync.WithRawResponse = savedExtensions + override fun assets(): AssetServiceAsync.WithRawResponse = assets override fun cache(): CacheServiceAsync.WithRawResponse = cache diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt index 433b100c..a9b47abf 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt @@ -18,6 +18,8 @@ import com.imagekit.api.services.blocking.FileService import com.imagekit.api.services.blocking.FileServiceImpl import com.imagekit.api.services.blocking.FolderService import com.imagekit.api.services.blocking.FolderServiceImpl +import com.imagekit.api.services.blocking.SavedExtensionService +import com.imagekit.api.services.blocking.SavedExtensionServiceImpl import com.imagekit.api.services.blocking.WebhookService import com.imagekit.api.services.blocking.WebhookServiceImpl import java.util.function.Consumer @@ -45,6 +47,10 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli private val files: FileService by lazy { FileServiceImpl(clientOptionsWithUserAgent) } + private val savedExtensions: SavedExtensionService by lazy { + SavedExtensionServiceImpl(clientOptionsWithUserAgent) + } + private val assets: AssetService by lazy { AssetServiceImpl(clientOptionsWithUserAgent) } private val cache: CacheService by lazy { CacheServiceImpl(clientOptionsWithUserAgent) } @@ -68,6 +74,8 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli override fun files(): FileService = files + override fun savedExtensions(): SavedExtensionService = savedExtensions + override fun assets(): AssetService = assets override fun cache(): CacheService = cache @@ -93,6 +101,10 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli FileServiceImpl.WithRawResponseImpl(clientOptions) } + private val savedExtensions: SavedExtensionService.WithRawResponse by lazy { + SavedExtensionServiceImpl.WithRawResponseImpl(clientOptions) + } + private val assets: AssetService.WithRawResponse by lazy { AssetServiceImpl.WithRawResponseImpl(clientOptions) } @@ -129,6 +141,8 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli override fun files(): FileService.WithRawResponse = files + override fun savedExtensions(): SavedExtensionService.WithRawResponse = savedExtensions + override fun assets(): AssetService.WithRawResponse = assets override fun cache(): CacheService.WithRawResponse = cache diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/BaseOverlay.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/BaseOverlay.kt index 20f7a1ac..e9672404 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/BaseOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/BaseOverlay.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.Enum import com.imagekit.api.core.ExcludeMissing import com.imagekit.api.core.JsonField import com.imagekit.api.core.JsonMissing @@ -19,6 +20,7 @@ import kotlin.jvm.optionals.getOrNull class BaseOverlay @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val layerMode: JsonField, private val position: JsonField, private val timing: JsonField, private val additionalProperties: MutableMap, @@ -26,24 +28,62 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("layerMode") + @ExcludeMissing + layerMode: JsonField = JsonMissing.of(), @JsonProperty("position") @ExcludeMissing position: JsonField = JsonMissing.of(), @JsonProperty("timing") @ExcludeMissing timing: JsonField = JsonMissing.of(), - ) : this(position, timing, mutableMapOf()) + ) : this(layerMode, position, timing, mutableMapOf()) + + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in the + * URL. By default, layers completely cover the base image beneath them. Layer modes change this + * behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is + * always darker than the original images. This is ideal for applying shadows or color tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. The + * red channel controls horizontal displacement, and the green channel controls vertical + * displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image + * transparent, while transparent areas leave the base image unchanged. This mode functions + * like a hole-punch, effectively cutting the shape of the layer out of the underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside the + * opaque area of the layer are preserved. This mode functions like a cookie-cutter, trimming + * the base image to match the specific dimensions and shape of the layer. See + * [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun layerMode(): Optional = layerMode.getOptional("layerMode") /** + * Specifies the overlay's position relative to the parent asset. See + * [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun position(): Optional = position.getOptional("position") /** + * Specifies timing information for the overlay (only applicable if the base asset is a video). + * See [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun timing(): Optional = timing.getOptional("timing") + /** + * Returns the raw JSON value of [layerMode]. + * + * Unlike [layerMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("layerMode") @ExcludeMissing fun _layerMode(): JsonField = layerMode + /** * Returns the raw JSON value of [position]. * @@ -79,17 +119,53 @@ private constructor( /** A builder for [BaseOverlay]. */ class Builder internal constructor() { + private var layerMode: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() private var timing: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(baseOverlay: BaseOverlay) = apply { + layerMode = baseOverlay.layerMode position = baseOverlay.position timing = baseOverlay.timing additionalProperties = baseOverlay.additionalProperties.toMutableMap() } + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in + * the URL. By default, layers completely cover the base image beneath them. Layer modes + * change this behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is + * always darker than the original images. This is ideal for applying shadows or color + * tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. + * The red channel controls horizontal displacement, and the green channel controls + * vertical displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image + * transparent, while transparent areas leave the base image unchanged. This mode + * functions like a hole-punch, effectively cutting the shape of the layer out of the + * underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside + * the opaque area of the layer are preserved. This mode functions like a cookie-cutter, + * trimming the base image to match the specific dimensions and shape of the layer. See + * [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + */ + fun layerMode(layerMode: LayerMode) = layerMode(JsonField.of(layerMode)) + + /** + * Sets [Builder.layerMode] to an arbitrary JSON value. + * + * You should usually call [Builder.layerMode] with a well-typed [LayerMode] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun layerMode(layerMode: JsonField) = apply { this.layerMode = layerMode } + + /** + * Specifies the overlay's position relative to the parent asset. See + * [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + */ fun position(position: OverlayPosition) = position(JsonField.of(position)) /** @@ -101,6 +177,11 @@ private constructor( */ fun position(position: JsonField) = apply { this.position = position } + /** + * Specifies timing information for the overlay (only applicable if the base asset is a + * video). See + * [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + */ fun timing(timing: OverlayTiming) = timing(JsonField.of(timing)) /** @@ -137,7 +218,7 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): BaseOverlay = - BaseOverlay(position, timing, additionalProperties.toMutableMap()) + BaseOverlay(layerMode, position, timing, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -147,6 +228,7 @@ private constructor( return@apply } + layerMode().ifPresent { it.validate() } position().ifPresent { it.validate() } timing().ifPresent { it.validate() } validated = true @@ -167,24 +249,186 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (position.asKnown().getOrNull()?.validity() ?: 0) + + (layerMode.asKnown().getOrNull()?.validity() ?: 0) + + (position.asKnown().getOrNull()?.validity() ?: 0) + (timing.asKnown().getOrNull()?.validity() ?: 0) + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in the + * URL. By default, layers completely cover the base image beneath them. Layer modes change this + * behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is + * always darker than the original images. This is ideal for applying shadows or color tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. The + * red channel controls horizontal displacement, and the green channel controls vertical + * displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image + * transparent, while transparent areas leave the base image unchanged. This mode functions + * like a hole-punch, effectively cutting the shape of the layer out of the underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside the + * opaque area of the layer are preserved. This mode functions like a cookie-cutter, trimming + * the base image to match the specific dimensions and shape of the layer. See + * [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + */ + class LayerMode @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MULTIPLY = of("multiply") + + @JvmField val CUTTER = of("cutter") + + @JvmField val CUTOUT = of("cutout") + + @JvmField val DISPLACE = of("displace") + + @JvmStatic fun of(value: String) = LayerMode(JsonField.of(value)) + } + + /** An enum containing [LayerMode]'s known values. */ + enum class Known { + MULTIPLY, + CUTTER, + CUTOUT, + DISPLACE, + } + + /** + * An enum containing [LayerMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [LayerMode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MULTIPLY, + CUTTER, + CUTOUT, + DISPLACE, + /** + * An enum member indicating that [LayerMode] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MULTIPLY -> Value.MULTIPLY + CUTTER -> Value.CUTTER + CUTOUT -> Value.CUTOUT + DISPLACE -> Value.DISPLACE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MULTIPLY -> Known.MULTIPLY + CUTTER -> Known.CUTTER + CUTOUT -> Known.CUTOUT + DISPLACE -> Known.DISPLACE + else -> throw ImageKitInvalidDataException("Unknown LayerMode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): LayerMode = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LayerMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } return other is BaseOverlay && + layerMode == other.layerMode && position == other.position && timing == other.timing && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(position, timing, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(layerMode, position, timing, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "BaseOverlay{position=$position, timing=$timing, additionalProperties=$additionalProperties}" + "BaseOverlay{layerMode=$layerMode, position=$position, timing=$timing, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt new file mode 100644 index 00000000..12fba239 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt @@ -0,0 +1,6598 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.allMaxBy +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Configuration object for an extension (base extensions only, not saved extension references). */ +@JsonDeserialize(using = ExtensionConfig.Deserializer::class) +@JsonSerialize(using = ExtensionConfig.Serializer::class) +class ExtensionConfig +private constructor( + private val removeBg: RemoveBg? = null, + private val autoTaggingExtension: AutoTaggingExtension? = null, + private val aiAutoDescription: JsonValue? = null, + private val aiTasks: AiTasks? = null, + private val _json: JsonValue? = null, +) { + + fun removeBg(): Optional = Optional.ofNullable(removeBg) + + fun autoTaggingExtension(): Optional = + Optional.ofNullable(autoTaggingExtension) + + fun aiAutoDescription(): Optional = Optional.ofNullable(aiAutoDescription) + + fun aiTasks(): Optional = Optional.ofNullable(aiTasks) + + fun isRemoveBg(): Boolean = removeBg != null + + fun isAutoTaggingExtension(): Boolean = autoTaggingExtension != null + + fun isAiAutoDescription(): Boolean = aiAutoDescription != null + + fun isAiTasks(): Boolean = aiTasks != null + + fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") + + fun asAutoTaggingExtension(): AutoTaggingExtension = + autoTaggingExtension.getOrThrow("autoTaggingExtension") + + fun asAiAutoDescription(): JsonValue = aiAutoDescription.getOrThrow("aiAutoDescription") + + fun asAiTasks(): AiTasks = aiTasks.getOrThrow("aiTasks") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + removeBg != null -> visitor.visitRemoveBg(removeBg) + autoTaggingExtension != null -> visitor.visitAutoTaggingExtension(autoTaggingExtension) + aiAutoDescription != null -> visitor.visitAiAutoDescription(aiAutoDescription) + aiTasks != null -> visitor.visitAiTasks(aiTasks) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ExtensionConfig = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) { + removeBg.validate() + } + + override fun visitAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension) { + autoTaggingExtension.validate() + } + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { + aiAutoDescription.let { + if (it != JsonValue.from(mapOf("name" to "ai-auto-description"))) { + throw ImageKitInvalidDataException( + "'aiAutoDescription' is invalid, received $it" + ) + } + } + } + + override fun visitAiTasks(aiTasks: AiTasks) { + aiTasks.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() + + override fun visitAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension) = + autoTaggingExtension.validity() + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = + aiAutoDescription.let { + if (it == JsonValue.from(mapOf("name" to "ai-auto-description"))) 1 else 0 + } + + override fun visitAiTasks(aiTasks: AiTasks) = aiTasks.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExtensionConfig && + removeBg == other.removeBg && + autoTaggingExtension == other.autoTaggingExtension && + aiAutoDescription == other.aiAutoDescription && + aiTasks == other.aiTasks + } + + override fun hashCode(): Int = + Objects.hash(removeBg, autoTaggingExtension, aiAutoDescription, aiTasks) + + override fun toString(): String = + when { + removeBg != null -> "ExtensionConfig{removeBg=$removeBg}" + autoTaggingExtension != null -> + "ExtensionConfig{autoTaggingExtension=$autoTaggingExtension}" + aiAutoDescription != null -> "ExtensionConfig{aiAutoDescription=$aiAutoDescription}" + aiTasks != null -> "ExtensionConfig{aiTasks=$aiTasks}" + _json != null -> "ExtensionConfig{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ExtensionConfig") + } + + companion object { + + @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = ExtensionConfig(removeBg = removeBg) + + @JvmStatic + fun ofAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension) = + ExtensionConfig(autoTaggingExtension = autoTaggingExtension) + + @JvmStatic + fun ofAiAutoDescription() = + ExtensionConfig( + aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) + ) + + @JvmStatic fun ofAiTasks(aiTasks: AiTasks) = ExtensionConfig(aiTasks = aiTasks) + } + + /** + * An interface that defines how to map each variant of [ExtensionConfig] to a value of type + * [T]. + */ + interface Visitor { + + fun visitRemoveBg(removeBg: RemoveBg): T + + fun visitAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension): T + + fun visitAiAutoDescription(aiAutoDescription: JsonValue): T + + fun visitAiTasks(aiTasks: AiTasks): T + + /** + * Maps an unknown variant of [ExtensionConfig] to a value of type [T]. + * + * An instance of [ExtensionConfig] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is unaware + * of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown ExtensionConfig: $json") + } + } + + internal class Deserializer : BaseDeserializer(ExtensionConfig::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ExtensionConfig { + val json = JsonValue.fromJsonNode(node) + val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() + + when (name) { + "remove-bg" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + ExtensionConfig(removeBg = it, _json = json) + } ?: ExtensionConfig(_json = json) + } + "ai-auto-description" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { ExtensionConfig(aiAutoDescription = it, _json = json) } + ?.takeIf { it.isValid() } ?: ExtensionConfig(_json = json) + } + "ai-tasks" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + ExtensionConfig(aiTasks = it, _json = json) + } ?: ExtensionConfig(_json = json) + } + } + + return tryDeserialize(node, jacksonTypeRef())?.let { + ExtensionConfig(autoTaggingExtension = it, _json = json) + } ?: ExtensionConfig(_json = json) + } + } + + internal class Serializer : BaseSerializer(ExtensionConfig::class) { + + override fun serialize( + value: ExtensionConfig, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.removeBg != null -> generator.writeObject(value.removeBg) + value.autoTaggingExtension != null -> + generator.writeObject(value.autoTaggingExtension) + value.aiAutoDescription != null -> generator.writeObject(value.aiAutoDescription) + value.aiTasks != null -> generator.writeObject(value.aiTasks) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ExtensionConfig") + } + } + } + + class RemoveBg + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonValue, + private val options: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("options") @ExcludeMissing options: JsonField = JsonMissing.of(), + ) : this(name, options, mutableMapOf()) + + /** + * Specifies the background removal extension. + * + * Expected to always return the following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun options(): Optional = options.getOptional("options") + + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveBg]. */ + class Builder internal constructor() { + + private var name: JsonValue = JsonValue.from("remove-bg") + private var options: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removeBg: RemoveBg) = apply { + name = removeBg.name + options = removeBg.options + additionalProperties = removeBg.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + fun options(options: Options) = options(JsonField.of(options)) + + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [Options] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun options(options: JsonField) = apply { this.options = options } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemoveBg]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemoveBg = RemoveBg(name, options, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): RemoveBg = apply { + if (validated) { + return@apply + } + + _name().let { + if (it != JsonValue.from("remove-bg")) { + throw ImageKitInvalidDataException("'name' is invalid, received $it") + } + } + options().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + name.let { if (it == JsonValue.from("remove-bg")) 1 else 0 } + + (options.asKnown().getOrNull()?.validity() ?: 0) + + class Options + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val addShadow: JsonField, + private val bgColor: JsonField, + private val bgImageUrl: JsonField, + private val semitransparency: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("add_shadow") + @ExcludeMissing + addShadow: JsonField = JsonMissing.of(), + @JsonProperty("bg_color") + @ExcludeMissing + bgColor: JsonField = JsonMissing.of(), + @JsonProperty("bg_image_url") + @ExcludeMissing + bgImageUrl: JsonField = JsonMissing.of(), + @JsonProperty("semitransparency") + @ExcludeMissing + semitransparency: JsonField = JsonMissing.of(), + ) : this(addShadow, bgColor, bgImageUrl, semitransparency, mutableMapOf()) + + /** + * Whether to add an artificial shadow to the result. Default is false. Note: Adding + * shadows is currently only supported for car photos. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun addShadow(): Optional = addShadow.getOptional("add_shadow") + + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or color + * name (e.g., "green"). If this parameter is set, `bg_image_url` must be empty. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun bgColor(): Optional = bgColor.getOptional("bg_color") + + /** + * Sets a background image from a URL. If this parameter is set, `bg_color` must be + * empty. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun bgImageUrl(): Optional = bgImageUrl.getOptional("bg_image_url") + + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun semitransparency(): Optional = + semitransparency.getOptional("semitransparency") + + /** + * Returns the raw JSON value of [addShadow]. + * + * Unlike [addShadow], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("add_shadow") + @ExcludeMissing + fun _addShadow(): JsonField = addShadow + + /** + * Returns the raw JSON value of [bgColor]. + * + * Unlike [bgColor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bg_color") @ExcludeMissing fun _bgColor(): JsonField = bgColor + + /** + * Returns the raw JSON value of [bgImageUrl]. + * + * Unlike [bgImageUrl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("bg_image_url") + @ExcludeMissing + fun _bgImageUrl(): JsonField = bgImageUrl + + /** + * Returns the raw JSON value of [semitransparency]. + * + * Unlike [semitransparency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("semitransparency") + @ExcludeMissing + fun _semitransparency(): JsonField = semitransparency + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Options]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Options]. */ + class Builder internal constructor() { + + private var addShadow: JsonField = JsonMissing.of() + private var bgColor: JsonField = JsonMissing.of() + private var bgImageUrl: JsonField = JsonMissing.of() + private var semitransparency: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(options: Options) = apply { + addShadow = options.addShadow + bgColor = options.bgColor + bgImageUrl = options.bgImageUrl + semitransparency = options.semitransparency + additionalProperties = options.additionalProperties.toMutableMap() + } + + /** + * Whether to add an artificial shadow to the result. Default is false. Note: Adding + * shadows is currently only supported for car photos. + */ + fun addShadow(addShadow: Boolean) = addShadow(JsonField.of(addShadow)) + + /** + * Sets [Builder.addShadow] to an arbitrary JSON value. + * + * You should usually call [Builder.addShadow] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun addShadow(addShadow: JsonField) = apply { this.addShadow = addShadow } + + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or + * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be + * empty. + */ + fun bgColor(bgColor: String) = bgColor(JsonField.of(bgColor)) + + /** + * Sets [Builder.bgColor] to an arbitrary JSON value. + * + * You should usually call [Builder.bgColor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bgColor(bgColor: JsonField) = apply { this.bgColor = bgColor } + + /** + * Sets a background image from a URL. If this parameter is set, `bg_color` must be + * empty. + */ + fun bgImageUrl(bgImageUrl: String) = bgImageUrl(JsonField.of(bgImageUrl)) + + /** + * Sets [Builder.bgImageUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.bgImageUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bgImageUrl(bgImageUrl: JsonField) = apply { + this.bgImageUrl = bgImageUrl + } + + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + */ + fun semitransparency(semitransparency: Boolean) = + semitransparency(JsonField.of(semitransparency)) + + /** + * Sets [Builder.semitransparency] to an arbitrary JSON value. + * + * You should usually call [Builder.semitransparency] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun semitransparency(semitransparency: JsonField) = apply { + this.semitransparency = semitransparency + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Options]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Options = + Options( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Options = apply { + if (validated) { + return@apply + } + + addShadow() + bgColor() + bgImageUrl() + semitransparency() + 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 (addShadow.asKnown().isPresent) 1 else 0) + + (if (bgColor.asKnown().isPresent) 1 else 0) + + (if (bgImageUrl.asKnown().isPresent) 1 else 0) + + (if (semitransparency.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Options && + addShadow == other.addShadow && + bgColor == other.bgColor && + bgImageUrl == other.bgImageUrl && + semitransparency == other.semitransparency && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(addShadow, bgColor, bgImageUrl, semitransparency, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveBg && + name == other.name && + options == other.options && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, options, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" + } + + class AutoTaggingExtension + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val maxTags: JsonField, + private val minConfidence: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("maxTags") @ExcludeMissing maxTags: JsonField = JsonMissing.of(), + @JsonProperty("minConfidence") + @ExcludeMissing + minConfidence: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(maxTags, minConfidence, name, mutableMapOf()) + + /** + * Maximum number of tags to attach to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun maxTags(): Long = maxTags.getRequired("maxTags") + + /** + * Minimum confidence level for tags to be considered valid. + * + * @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 minConfidence(): Long = minConfidence.getRequired("minConfidence") + + /** + * Specifies the auto-tagging extension used. + * + * @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(): Name = name.getRequired("name") + + /** + * Returns the raw JSON value of [maxTags]. + * + * Unlike [maxTags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("maxTags") @ExcludeMissing fun _maxTags(): JsonField = maxTags + + /** + * Returns the raw JSON value of [minConfidence]. + * + * Unlike [minConfidence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minConfidence") + @ExcludeMissing + fun _minConfidence(): JsonField = minConfidence + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AutoTaggingExtension]. + * + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutoTaggingExtension]. */ + class Builder internal constructor() { + + private var maxTags: JsonField? = null + private var minConfidence: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { + maxTags = autoTaggingExtension.maxTags + minConfidence = autoTaggingExtension.minConfidence + name = autoTaggingExtension.name + additionalProperties = autoTaggingExtension.additionalProperties.toMutableMap() + } + + /** Maximum number of tags to attach to the asset. */ + fun maxTags(maxTags: Long) = maxTags(JsonField.of(maxTags)) + + /** + * Sets [Builder.maxTags] to an arbitrary JSON value. + * + * You should usually call [Builder.maxTags] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxTags(maxTags: JsonField) = apply { this.maxTags = maxTags } + + /** Minimum confidence level for tags to be considered valid. */ + fun minConfidence(minConfidence: Long) = minConfidence(JsonField.of(minConfidence)) + + /** + * Sets [Builder.minConfidence] to an arbitrary JSON value. + * + * You should usually call [Builder.minConfidence] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minConfidence(minConfidence: JsonField) = apply { + this.minConfidence = minConfidence + } + + /** Specifies the auto-tagging extension used. */ + fun name(name: Name) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [Name] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutoTaggingExtension]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutoTaggingExtension = + AutoTaggingExtension( + checkRequired("maxTags", maxTags), + checkRequired("minConfidence", minConfidence), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutoTaggingExtension = apply { + if (validated) { + return@apply + } + + maxTags() + minConfidence() + name().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (maxTags.asKnown().isPresent) 1 else 0) + + (if (minConfidence.asKnown().isPresent) 1 else 0) + + (name.asKnown().getOrNull()?.validity() ?: 0) + + /** Specifies the auto-tagging extension used. */ + class Name @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") + + @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + } + + /** + * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Name] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + /** An enum member indicating that [Name] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING + else -> throw ImageKitInvalidDataException("Unknown Name: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Name = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Name && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutoTaggingExtension && + maxTags == other.maxTags && + minConfidence == other.minConfidence && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(maxTags, minConfidence, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" + } + + class AiTasks + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonValue, + private val tasks: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("tasks") @ExcludeMissing tasks: JsonField> = JsonMissing.of(), + ) : this(name, tasks, mutableMapOf()) + + /** + * Specifies the AI tasks extension for automated image analysis using AI models. + * + * Expected to always return the following: + * ```java + * JsonValue.from("ai-tasks") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Array of task objects defining AI operations to perform on the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tasks(): List = tasks.getRequired("tasks") + + /** + * Returns the raw JSON value of [tasks]. + * + * Unlike [tasks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tasks") @ExcludeMissing fun _tasks(): JsonField> = tasks + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AiTasks]. + * + * The following fields are required: + * ```java + * .tasks() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AiTasks]. */ + class Builder internal constructor() { + + private var name: JsonValue = JsonValue.from("ai-tasks") + private var tasks: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(aiTasks: AiTasks) = apply { + name = aiTasks.name + tasks = aiTasks.tasks.map { it.toMutableList() } + additionalProperties = aiTasks.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("ai-tasks") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** Array of task objects defining AI operations to perform on the asset. */ + fun tasks(tasks: List) = tasks(JsonField.of(tasks)) + + /** + * Sets [Builder.tasks] to an arbitrary JSON value. + * + * You should usually call [Builder.tasks] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tasks(tasks: JsonField>) = apply { + this.tasks = tasks.map { it.toMutableList() } + } + + /** + * Adds a single [Task] to [tasks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTask(task: Task) = apply { + tasks = + (tasks ?: JsonField.of(mutableListOf())).also { + checkKnown("tasks", it).add(task) + } + } + + /** Alias for calling [addTask] with `Task.ofSelectTags(selectTags)`. */ + fun addTask(selectTags: Task.SelectTags) = addTask(Task.ofSelectTags(selectTags)) + + /** Alias for calling [addTask] with `Task.ofSelectMetadata(selectMetadata)`. */ + fun addTask(selectMetadata: Task.SelectMetadata) = + addTask(Task.ofSelectMetadata(selectMetadata)) + + /** Alias for calling [addTask] with `Task.ofYesNo(yesNo)`. */ + fun addTask(yesNo: Task.YesNo) = addTask(Task.ofYesNo(yesNo)) + + /** + * Alias for calling [addTask] with the following: + * ```java + * Task.YesNo.builder() + * .instruction(instruction) + * .build() + * ``` + */ + fun addYesNoTask(instruction: String) = + addTask(Task.YesNo.builder().instruction(instruction).build()) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AiTasks]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tasks() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AiTasks = + AiTasks( + name, + checkRequired("tasks", tasks).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AiTasks = apply { + if (validated) { + return@apply + } + + _name().let { + if (it != JsonValue.from("ai-tasks")) { + throw ImageKitInvalidDataException("'name' is invalid, received $it") + } + } + tasks().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + name.let { if (it == JsonValue.from("ai-tasks")) 1 else 0 } + + (tasks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + @JsonDeserialize(using = Task.Deserializer::class) + @JsonSerialize(using = Task.Serializer::class) + class Task + private constructor( + private val selectTags: SelectTags? = null, + private val selectMetadata: SelectMetadata? = null, + private val yesNo: YesNo? = null, + private val _json: JsonValue? = null, + ) { + + fun selectTags(): Optional = Optional.ofNullable(selectTags) + + fun selectMetadata(): Optional = Optional.ofNullable(selectMetadata) + + fun yesNo(): Optional = Optional.ofNullable(yesNo) + + fun isSelectTags(): Boolean = selectTags != null + + fun isSelectMetadata(): Boolean = selectMetadata != null + + fun isYesNo(): Boolean = yesNo != null + + fun asSelectTags(): SelectTags = selectTags.getOrThrow("selectTags") + + fun asSelectMetadata(): SelectMetadata = selectMetadata.getOrThrow("selectMetadata") + + fun asYesNo(): YesNo = yesNo.getOrThrow("yesNo") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + selectTags != null -> visitor.visitSelectTags(selectTags) + selectMetadata != null -> visitor.visitSelectMetadata(selectMetadata) + yesNo != null -> visitor.visitYesNo(yesNo) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Task = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitSelectTags(selectTags: SelectTags) { + selectTags.validate() + } + + override fun visitSelectMetadata(selectMetadata: SelectMetadata) { + selectMetadata.validate() + } + + override fun visitYesNo(yesNo: YesNo) { + yesNo.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitSelectTags(selectTags: SelectTags) = selectTags.validity() + + override fun visitSelectMetadata(selectMetadata: SelectMetadata) = + selectMetadata.validity() + + override fun visitYesNo(yesNo: YesNo) = yesNo.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Task && + selectTags == other.selectTags && + selectMetadata == other.selectMetadata && + yesNo == other.yesNo + } + + override fun hashCode(): Int = Objects.hash(selectTags, selectMetadata, yesNo) + + override fun toString(): String = + when { + selectTags != null -> "Task{selectTags=$selectTags}" + selectMetadata != null -> "Task{selectMetadata=$selectMetadata}" + yesNo != null -> "Task{yesNo=$yesNo}" + _json != null -> "Task{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Task") + } + + companion object { + + @JvmStatic fun ofSelectTags(selectTags: SelectTags) = Task(selectTags = selectTags) + + @JvmStatic + fun ofSelectMetadata(selectMetadata: SelectMetadata) = + Task(selectMetadata = selectMetadata) + + @JvmStatic fun ofYesNo(yesNo: YesNo) = Task(yesNo = yesNo) + } + + /** + * An interface that defines how to map each variant of [Task] to a value of type [T]. + */ + interface Visitor { + + fun visitSelectTags(selectTags: SelectTags): T + + fun visitSelectMetadata(selectMetadata: SelectMetadata): T + + fun visitYesNo(yesNo: YesNo): T + + /** + * Maps an unknown variant of [Task] to a value of type [T]. + * + * An instance of [Task] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Task: $json") + } + } + + internal class Deserializer : BaseDeserializer(Task::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Task { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "select_tags" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Task(selectTags = it, _json = json) + } ?: Task(_json = json) + } + "select_metadata" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Task(selectMetadata = it, _json = json) + } ?: Task(_json = json) + } + "yes_no" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Task(yesNo = it, _json = json) + } ?: Task(_json = json) + } + } + + return Task(_json = json) + } + } + + internal class Serializer : BaseSerializer(Task::class) { + + override fun serialize( + value: Task, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.selectTags != null -> generator.writeObject(value.selectTags) + value.selectMetadata != null -> generator.writeObject(value.selectMetadata) + value.yesNo != null -> generator.writeObject(value.yesNo) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Task") + } + } + } + + class SelectTags + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val instruction: JsonField, + private val type: JsonValue, + private val vocabulary: JsonField>, + private val maxSelections: JsonField, + private val minSelections: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("instruction") + @ExcludeMissing + instruction: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("vocabulary") + @ExcludeMissing + vocabulary: JsonField> = JsonMissing.of(), + @JsonProperty("max_selections") + @ExcludeMissing + maxSelections: JsonField = JsonMissing.of(), + @JsonProperty("min_selections") + @ExcludeMissing + minSelections: JsonField = JsonMissing.of(), + ) : this( + instruction, + type, + vocabulary, + maxSelections, + minSelections, + mutableMapOf(), + ) + + /** + * The question or instruction for the AI to analyze the image. + * + * @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 instruction(): String = instruction.getRequired("instruction") + + /** + * Task type that analyzes the image and adds matching tags from a vocabulary. + * + * Expected to always return the following: + * ```java + * JsonValue.from("select_tags") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Array of possible tag values. Combined length of all strings must not exceed 500 + * characters. Cannot contain the `%` character. + * + * @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 vocabulary(): List = vocabulary.getRequired("vocabulary") + + /** + * Maximum number of tags to select from the vocabulary. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun maxSelections(): Optional = maxSelections.getOptional("max_selections") + + /** + * Minimum number of tags to select from the vocabulary. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun minSelections(): Optional = minSelections.getOptional("min_selections") + + /** + * Returns the raw JSON value of [instruction]. + * + * Unlike [instruction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("instruction") + @ExcludeMissing + fun _instruction(): JsonField = instruction + + /** + * Returns the raw JSON value of [vocabulary]. + * + * Unlike [vocabulary], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("vocabulary") + @ExcludeMissing + fun _vocabulary(): JsonField> = vocabulary + + /** + * Returns the raw JSON value of [maxSelections]. + * + * Unlike [maxSelections], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("max_selections") + @ExcludeMissing + fun _maxSelections(): JsonField = maxSelections + + /** + * Returns the raw JSON value of [minSelections]. + * + * Unlike [minSelections], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("min_selections") + @ExcludeMissing + fun _minSelections(): JsonField = minSelections + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SelectTags]. + * + * The following fields are required: + * ```java + * .instruction() + * .vocabulary() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SelectTags]. */ + class Builder internal constructor() { + + private var instruction: JsonField? = null + private var type: JsonValue = JsonValue.from("select_tags") + private var vocabulary: JsonField>? = null + private var maxSelections: JsonField = JsonMissing.of() + private var minSelections: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(selectTags: SelectTags) = apply { + instruction = selectTags.instruction + type = selectTags.type + vocabulary = selectTags.vocabulary.map { it.toMutableList() } + maxSelections = selectTags.maxSelections + minSelections = selectTags.minSelections + additionalProperties = selectTags.additionalProperties.toMutableMap() + } + + /** The question or instruction for the AI to analyze the image. */ + fun instruction(instruction: String) = instruction(JsonField.of(instruction)) + + /** + * Sets [Builder.instruction] to an arbitrary JSON value. + * + * You should usually call [Builder.instruction] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun instruction(instruction: JsonField) = apply { + this.instruction = instruction + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("select_tags") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Array of possible tag values. Combined length of all strings must not exceed + * 500 characters. Cannot contain the `%` character. + */ + fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) + + /** + * Sets [Builder.vocabulary] to an arbitrary JSON value. + * + * You should usually call [Builder.vocabulary] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun vocabulary(vocabulary: JsonField>) = apply { + this.vocabulary = vocabulary.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.vocabulary]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVocabulary(vocabulary: String) = apply { + this.vocabulary = + (this.vocabulary ?: JsonField.of(mutableListOf())).also { + checkKnown("vocabulary", it).add(vocabulary) + } + } + + /** Maximum number of tags to select from the vocabulary. */ + fun maxSelections(maxSelections: Long) = + maxSelections(JsonField.of(maxSelections)) + + /** + * Sets [Builder.maxSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.maxSelections] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun maxSelections(maxSelections: JsonField) = apply { + this.maxSelections = maxSelections + } + + /** Minimum number of tags to select from the vocabulary. */ + fun minSelections(minSelections: Long) = + minSelections(JsonField.of(minSelections)) + + /** + * Sets [Builder.minSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.minSelections] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minSelections(minSelections: JsonField) = apply { + this.minSelections = minSelections + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SelectTags]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .instruction() + * .vocabulary() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SelectTags = + SelectTags( + checkRequired("instruction", instruction), + type, + checkRequired("vocabulary", vocabulary).map { it.toImmutable() }, + maxSelections, + minSelections, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SelectTags = apply { + if (validated) { + return@apply + } + + instruction() + _type().let { + if (it != JsonValue.from("select_tags")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + vocabulary() + maxSelections() + minSelections() + 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 (instruction.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("select_tags")) 1 else 0 } + + (vocabulary.asKnown().getOrNull()?.size ?: 0) + + (if (maxSelections.asKnown().isPresent) 1 else 0) + + (if (minSelections.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SelectTags && + instruction == other.instruction && + type == other.type && + vocabulary == other.vocabulary && + maxSelections == other.maxSelections && + minSelections == other.minSelections && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + instruction, + type, + vocabulary, + maxSelections, + minSelections, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SelectTags{instruction=$instruction, type=$type, vocabulary=$vocabulary, maxSelections=$maxSelections, minSelections=$minSelections, additionalProperties=$additionalProperties}" + } + + class SelectMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val instruction: JsonField, + private val type: JsonValue, + private val maxSelections: JsonField, + private val minSelections: JsonField, + private val vocabulary: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of(), + @JsonProperty("instruction") + @ExcludeMissing + instruction: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("max_selections") + @ExcludeMissing + maxSelections: JsonField = JsonMissing.of(), + @JsonProperty("min_selections") + @ExcludeMissing + minSelections: JsonField = JsonMissing.of(), + @JsonProperty("vocabulary") + @ExcludeMissing + vocabulary: JsonField> = JsonMissing.of(), + ) : this( + field, + instruction, + type, + maxSelections, + minSelections, + vocabulary, + mutableMapOf(), + ) + + /** + * Name of the custom metadata field to set. The field must exist in 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 field(): String = field.getRequired("field") + + /** + * The question or instruction for the AI to analyze the image. + * + * @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 instruction(): String = instruction.getRequired("instruction") + + /** + * Task type that analyzes the image and sets a custom metadata field value from a + * vocabulary. + * + * Expected to always return the following: + * ```java + * JsonValue.from("select_metadata") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Maximum number of values to select from the vocabulary. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun maxSelections(): Optional = maxSelections.getOptional("max_selections") + + /** + * Minimum number of values to select from the vocabulary. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun minSelections(): Optional = minSelections.getOptional("min_selections") + + /** + * Array of possible values matching the custom metadata field type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun vocabulary(): Optional> = vocabulary.getOptional("vocabulary") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [instruction]. + * + * Unlike [instruction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("instruction") + @ExcludeMissing + fun _instruction(): JsonField = instruction + + /** + * Returns the raw JSON value of [maxSelections]. + * + * Unlike [maxSelections], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("max_selections") + @ExcludeMissing + fun _maxSelections(): JsonField = maxSelections + + /** + * Returns the raw JSON value of [minSelections]. + * + * Unlike [minSelections], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("min_selections") + @ExcludeMissing + fun _minSelections(): JsonField = minSelections + + /** + * Returns the raw JSON value of [vocabulary]. + * + * Unlike [vocabulary], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("vocabulary") + @ExcludeMissing + fun _vocabulary(): JsonField> = vocabulary + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SelectMetadata]. + * + * The following fields are required: + * ```java + * .field() + * .instruction() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SelectMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var instruction: JsonField? = null + private var type: JsonValue = JsonValue.from("select_metadata") + private var maxSelections: JsonField = JsonMissing.of() + private var minSelections: JsonField = JsonMissing.of() + private var vocabulary: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(selectMetadata: SelectMetadata) = apply { + field = selectMetadata.field + instruction = selectMetadata.instruction + type = selectMetadata.type + maxSelections = selectMetadata.maxSelections + minSelections = selectMetadata.minSelections + vocabulary = selectMetadata.vocabulary.map { it.toMutableList() } + additionalProperties = selectMetadata.additionalProperties.toMutableMap() + } + + /** + * Name of the custom metadata field to set. The field must exist in your + * account. + */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** The question or instruction for the AI to analyze the image. */ + fun instruction(instruction: String) = instruction(JsonField.of(instruction)) + + /** + * Sets [Builder.instruction] to an arbitrary JSON value. + * + * You should usually call [Builder.instruction] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun instruction(instruction: JsonField) = apply { + this.instruction = instruction + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("select_metadata") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Maximum number of values to select from the vocabulary. */ + fun maxSelections(maxSelections: Long) = + maxSelections(JsonField.of(maxSelections)) + + /** + * Sets [Builder.maxSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.maxSelections] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun maxSelections(maxSelections: JsonField) = apply { + this.maxSelections = maxSelections + } + + /** Minimum number of values to select from the vocabulary. */ + fun minSelections(minSelections: Long) = + minSelections(JsonField.of(minSelections)) + + /** + * Sets [Builder.minSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.minSelections] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minSelections(minSelections: JsonField) = apply { + this.minSelections = minSelections + } + + /** Array of possible values matching the custom metadata field type. */ + fun vocabulary(vocabulary: List) = + vocabulary(JsonField.of(vocabulary)) + + /** + * Sets [Builder.vocabulary] to an arbitrary JSON value. + * + * You should usually call [Builder.vocabulary] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun vocabulary(vocabulary: JsonField>) = apply { + this.vocabulary = vocabulary.map { it.toMutableList() } + } + + /** + * Adds a single [Vocabulary] to [Builder.vocabulary]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVocabulary(vocabulary: Vocabulary) = apply { + this.vocabulary = + (this.vocabulary ?: JsonField.of(mutableListOf())).also { + checkKnown("vocabulary", it).add(vocabulary) + } + } + + /** Alias for calling [addVocabulary] with `Vocabulary.ofString(string)`. */ + fun addVocabulary(string: String) = addVocabulary(Vocabulary.ofString(string)) + + /** Alias for calling [addVocabulary] with `Vocabulary.ofNumber(number)`. */ + fun addVocabulary(number: Double) = addVocabulary(Vocabulary.ofNumber(number)) + + /** Alias for calling [addVocabulary] with `Vocabulary.ofBool(bool)`. */ + fun addVocabulary(bool: Boolean) = addVocabulary(Vocabulary.ofBool(bool)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SelectMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .field() + * .instruction() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SelectMetadata = + SelectMetadata( + checkRequired("field", field), + checkRequired("instruction", instruction), + type, + maxSelections, + minSelections, + (vocabulary ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SelectMetadata = apply { + if (validated) { + return@apply + } + + field() + instruction() + _type().let { + if (it != JsonValue.from("select_metadata")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + maxSelections() + minSelections() + vocabulary().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (field.asKnown().isPresent) 1 else 0) + + (if (instruction.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("select_metadata")) 1 else 0 } + + (if (maxSelections.asKnown().isPresent) 1 else 0) + + (if (minSelections.asKnown().isPresent) 1 else 0) + + (vocabulary.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + @JsonDeserialize(using = Vocabulary.Deserializer::class) + @JsonSerialize(using = Vocabulary.Serializer::class) + class Vocabulary + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Vocabulary = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Vocabulary && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> "Vocabulary{string=$string}" + number != null -> "Vocabulary{number=$number}" + bool != null -> "Vocabulary{bool=$bool}" + _json != null -> "Vocabulary{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Vocabulary") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Vocabulary(string = string) + + @JvmStatic fun ofNumber(number: Double) = Vocabulary(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Vocabulary(bool = bool) + } + + /** + * An interface that defines how to map each variant of [Vocabulary] to a value + * of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [Vocabulary] to a value of type [T]. + * + * An instance of [Vocabulary] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the API may respond + * with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Vocabulary: $json") + } + } + + internal class Deserializer : BaseDeserializer(Vocabulary::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Vocabulary { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Vocabulary(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Vocabulary(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Vocabulary(bool = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing + // from object). + 0 -> Vocabulary(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Vocabulary::class) { + + override fun serialize( + value: Vocabulary, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Vocabulary") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SelectMetadata && + field == other.field && + instruction == other.instruction && + type == other.type && + maxSelections == other.maxSelections && + minSelections == other.minSelections && + vocabulary == other.vocabulary && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + field, + instruction, + type, + maxSelections, + minSelections, + vocabulary, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SelectMetadata{field=$field, instruction=$instruction, type=$type, maxSelections=$maxSelections, minSelections=$minSelections, vocabulary=$vocabulary, additionalProperties=$additionalProperties}" + } + + class YesNo + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val instruction: JsonField, + private val type: JsonValue, + private val onNo: JsonField, + private val onUnknown: JsonField, + private val onYes: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("instruction") + @ExcludeMissing + instruction: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("on_no") @ExcludeMissing onNo: JsonField = JsonMissing.of(), + @JsonProperty("on_unknown") + @ExcludeMissing + onUnknown: JsonField = JsonMissing.of(), + @JsonProperty("on_yes") + @ExcludeMissing + onYes: JsonField = JsonMissing.of(), + ) : this(instruction, type, onNo, onUnknown, onYes, mutableMapOf()) + + /** + * The yes/no question for the AI to answer about the image. + * + * @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 instruction(): String = instruction.getRequired("instruction") + + /** + * Task type that asks a yes/no question and executes actions based on the answer. + * + * Expected to always return the following: + * ```java + * JsonValue.from("yes_no") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Actions to execute if the AI answers no. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun onNo(): Optional = onNo.getOptional("on_no") + + /** + * Actions to execute if the AI cannot determine the answer. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun onUnknown(): Optional = onUnknown.getOptional("on_unknown") + + /** + * Actions to execute if the AI answers yes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun onYes(): Optional = onYes.getOptional("on_yes") + + /** + * Returns the raw JSON value of [instruction]. + * + * Unlike [instruction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("instruction") + @ExcludeMissing + fun _instruction(): JsonField = instruction + + /** + * Returns the raw JSON value of [onNo]. + * + * Unlike [onNo], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("on_no") @ExcludeMissing fun _onNo(): JsonField = onNo + + /** + * Returns the raw JSON value of [onUnknown]. + * + * Unlike [onUnknown], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("on_unknown") + @ExcludeMissing + fun _onUnknown(): JsonField = onUnknown + + /** + * Returns the raw JSON value of [onYes]. + * + * Unlike [onYes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("on_yes") @ExcludeMissing fun _onYes(): JsonField = onYes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [YesNo]. + * + * The following fields are required: + * ```java + * .instruction() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [YesNo]. */ + class Builder internal constructor() { + + private var instruction: JsonField? = null + private var type: JsonValue = JsonValue.from("yes_no") + private var onNo: JsonField = JsonMissing.of() + private var onUnknown: JsonField = JsonMissing.of() + private var onYes: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(yesNo: YesNo) = apply { + instruction = yesNo.instruction + type = yesNo.type + onNo = yesNo.onNo + onUnknown = yesNo.onUnknown + onYes = yesNo.onYes + additionalProperties = yesNo.additionalProperties.toMutableMap() + } + + /** The yes/no question for the AI to answer about the image. */ + fun instruction(instruction: String) = instruction(JsonField.of(instruction)) + + /** + * Sets [Builder.instruction] to an arbitrary JSON value. + * + * You should usually call [Builder.instruction] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun instruction(instruction: JsonField) = apply { + this.instruction = instruction + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("yes_no") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Actions to execute if the AI answers no. */ + fun onNo(onNo: OnNo) = onNo(JsonField.of(onNo)) + + /** + * Sets [Builder.onNo] to an arbitrary JSON value. + * + * You should usually call [Builder.onNo] with a well-typed [OnNo] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun onNo(onNo: JsonField) = apply { this.onNo = onNo } + + /** Actions to execute if the AI cannot determine the answer. */ + fun onUnknown(onUnknown: OnUnknown) = onUnknown(JsonField.of(onUnknown)) + + /** + * Sets [Builder.onUnknown] to an arbitrary JSON value. + * + * You should usually call [Builder.onUnknown] with a well-typed [OnUnknown] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun onUnknown(onUnknown: JsonField) = apply { + this.onUnknown = onUnknown + } + + /** Actions to execute if the AI answers yes. */ + fun onYes(onYes: OnYes) = onYes(JsonField.of(onYes)) + + /** + * Sets [Builder.onYes] to an arbitrary JSON value. + * + * You should usually call [Builder.onYes] with a well-typed [OnYes] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun onYes(onYes: JsonField) = apply { this.onYes = onYes } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [YesNo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .instruction() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): YesNo = + YesNo( + checkRequired("instruction", instruction), + type, + onNo, + onUnknown, + onYes, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): YesNo = apply { + if (validated) { + return@apply + } + + instruction() + _type().let { + if (it != JsonValue.from("yes_no")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + onNo().ifPresent { it.validate() } + onUnknown().ifPresent { it.validate() } + onYes().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (instruction.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("yes_no")) 1 else 0 } + + (onNo.asKnown().getOrNull()?.validity() ?: 0) + + (onUnknown.asKnown().getOrNull()?.validity() ?: 0) + + (onYes.asKnown().getOrNull()?.validity() ?: 0) + + /** Actions to execute if the AI answers no. */ + class OnNo + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val addTags: JsonField>, + private val removeTags: JsonField>, + private val setMetadata: JsonField>, + private val unsetMetadata: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("add_tags") + @ExcludeMissing + addTags: JsonField> = JsonMissing.of(), + @JsonProperty("remove_tags") + @ExcludeMissing + removeTags: JsonField> = JsonMissing.of(), + @JsonProperty("set_metadata") + @ExcludeMissing + setMetadata: JsonField> = JsonMissing.of(), + @JsonProperty("unset_metadata") + @ExcludeMissing + unsetMetadata: JsonField> = JsonMissing.of(), + ) : this(addTags, removeTags, setMetadata, unsetMetadata, mutableMapOf()) + + /** + * Array of tag strings to add to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun addTags(): Optional> = addTags.getOptional("add_tags") + + /** + * Array of tag strings to remove from the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun removeTags(): Optional> = removeTags.getOptional("remove_tags") + + /** + * Array of custom metadata field updates. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun setMetadata(): Optional> = + setMetadata.getOptional("set_metadata") + + /** + * Array of custom metadata fields to remove. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun unsetMetadata(): Optional> = + unsetMetadata.getOptional("unset_metadata") + + /** + * Returns the raw JSON value of [addTags]. + * + * Unlike [addTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_tags") + @ExcludeMissing + fun _addTags(): JsonField> = addTags + + /** + * Returns the raw JSON value of [removeTags]. + * + * Unlike [removeTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("remove_tags") + @ExcludeMissing + fun _removeTags(): JsonField> = removeTags + + /** + * Returns the raw JSON value of [setMetadata]. + * + * Unlike [setMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("set_metadata") + @ExcludeMissing + fun _setMetadata(): JsonField> = setMetadata + + /** + * Returns the raw JSON value of [unsetMetadata]. + * + * Unlike [unsetMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unset_metadata") + @ExcludeMissing + fun _unsetMetadata(): JsonField> = unsetMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [OnNo]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OnNo]. */ + class Builder internal constructor() { + + private var addTags: JsonField>? = null + private var removeTags: JsonField>? = null + private var setMetadata: JsonField>? = null + private var unsetMetadata: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(onNo: OnNo) = apply { + addTags = onNo.addTags.map { it.toMutableList() } + removeTags = onNo.removeTags.map { it.toMutableList() } + setMetadata = onNo.setMetadata.map { it.toMutableList() } + unsetMetadata = onNo.unsetMetadata.map { it.toMutableList() } + additionalProperties = onNo.additionalProperties.toMutableMap() + } + + /** Array of tag strings to add to the asset. */ + fun addTags(addTags: List) = addTags(JsonField.of(addTags)) + + /** + * Sets [Builder.addTags] to an arbitrary JSON value. + * + * You should usually call [Builder.addTags] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun addTags(addTags: JsonField>) = apply { + this.addTags = addTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [addTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAddTag(addTag: String) = apply { + addTags = + (addTags ?: JsonField.of(mutableListOf())).also { + checkKnown("addTags", it).add(addTag) + } + } + + /** Array of tag strings to remove from the asset. */ + fun removeTags(removeTags: List) = + removeTags(JsonField.of(removeTags)) + + /** + * Sets [Builder.removeTags] to an arbitrary JSON value. + * + * You should usually call [Builder.removeTags] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun removeTags(removeTags: JsonField>) = apply { + this.removeTags = removeTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [removeTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addRemoveTag(removeTag: String) = apply { + removeTags = + (removeTags ?: JsonField.of(mutableListOf())).also { + checkKnown("removeTags", it).add(removeTag) + } + } + + /** Array of custom metadata field updates. */ + fun setMetadata(setMetadata: List) = + setMetadata(JsonField.of(setMetadata)) + + /** + * Sets [Builder.setMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.setMetadata] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun setMetadata(setMetadata: JsonField>) = apply { + this.setMetadata = setMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [SetMetadata] to [Builder.setMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addSetMetadata(setMetadata: SetMetadata) = apply { + this.setMetadata = + (this.setMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("setMetadata", it).add(setMetadata) + } + } + + /** Array of custom metadata fields to remove. */ + fun unsetMetadata(unsetMetadata: List) = + unsetMetadata(JsonField.of(unsetMetadata)) + + /** + * Sets [Builder.unsetMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.unsetMetadata] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unsetMetadata(unsetMetadata: JsonField>) = apply { + this.unsetMetadata = unsetMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { + this.unsetMetadata = + (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("unsetMetadata", it).add(unsetMetadata) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OnNo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OnNo = + OnNo( + (addTags ?: JsonMissing.of()).map { it.toImmutable() }, + (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, + (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + (unsetMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OnNo = apply { + if (validated) { + return@apply + } + + addTags() + removeTags() + setMetadata().ifPresent { it.forEach { it.validate() } } + unsetMetadata().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (addTags.asKnown().getOrNull()?.size ?: 0) + + (removeTags.asKnown().getOrNull()?.size ?: 0) + + (setMetadata.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (unsetMetadata.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + class SetMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this(field, value, mutableMapOf()) + + /** + * Name of the custom metadata field to set. + * + * @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 field(): String = field.getRequired("field") + + /** + * Value to set for the custom metadata field. The value type should match + * the custom metadata field type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun value(): Value = value.getRequired("value") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(setMetadata: SetMetadata) = apply { + field = setMetadata.field + value = setMetadata.value + additionalProperties = + setMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to set. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + */ + fun value(value: Value) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ + fun valueOfMixed(mixed: List) = + value(Value.ofMixed(mixed)) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SetMetadata = + SetMetadata( + checkRequired("field", field), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SetMetadata = apply { + if (validated) { + return@apply + } + + field() + value().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (field.asKnown().isPresent) 1 else 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Value to set for the custom metadata field. The value type should match + * the custom metadata field type. + */ + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val mixed: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun mixed(): Optional> = + Optional.ofNullable(mixed) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isMixed(): Boolean = mixed != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asMixed(): List = + mixed.getOrThrow("mixed") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + mixed != null -> visitor.visitMixed(mixed) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitMixed( + mixed: List + ) { + mixed.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitMixed( + mixed: List + ) = mixed.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + string == other.string && + number == other.number && + bool == other.bool && + mixed == other.mixed + } + + override fun hashCode(): Int = Objects.hash(string, number, bool, mixed) + + override fun toString(): String = + when { + string != null -> "Value{string=$string}" + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + mixed != null -> "Value{mixed=$mixed}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic + fun ofMixed(mixed: List) = + Value(mixed = mixed.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Value] to a + * value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitMixed(mixed: List): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the + * API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Value: $json") + } + } + + internal class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Value(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Value(number = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Value(bool = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef< + List + >(), + ) + ?.let { Value(mixed = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. + // deserializing from object). + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, + // then use the first completely valid match, or simply the + // first match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.mixed != null -> generator.writeObject(value.mixed) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + + @JsonDeserialize( + using = UnnamedSchemaWithArrayParent0.Deserializer::class + ) + @JsonSerialize(using = UnnamedSchemaWithArrayParent0.Serializer::class) + class UnnamedSchemaWithArrayParent0 + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent0 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent0 && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> + "UnnamedSchemaWithArrayParent0{string=$string}" + number != null -> + "UnnamedSchemaWithArrayParent0{number=$number}" + bool != null -> "UnnamedSchemaWithArrayParent0{bool=$bool}" + _json != null -> + "UnnamedSchemaWithArrayParent0{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent0" + ) + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent0(string = string) + + @JvmStatic + fun ofNumber(number: Double) = + UnnamedSchemaWithArrayParent0(number = number) + + @JvmStatic + fun ofBool(bool: Boolean) = + UnnamedSchemaWithArrayParent0(bool = bool) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent0] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent0] to + * a value of type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent0] can contain an + * unknown variant if it was deserialized from data that doesn't + * match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent0: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent0::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent0 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnnamedSchemaWithArrayParent0( + string = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnnamedSchemaWithArrayParent0( + number = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnnamedSchemaWithArrayParent0( + bool = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is + // completely incompatible with all the possible + // variants (e.g. deserializing from object). + 0 -> UnnamedSchemaWithArrayParent0(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest + // validity, then use the first completely valid match, + // or simply the first match if none are completely + // valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent0::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent0, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent0" + ) + } + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SetMetadata && + field == other.field && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" + } + + class UnsetMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of() + ) : this(field, mutableMapOf()) + + /** + * Name of the custom metadata field to remove. + * + * @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 field(): String = field.getRequired("field") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnsetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnsetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unsetMetadata: UnsetMetadata) = apply { + field = unsetMetadata.field + additionalProperties = + unsetMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to remove. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnsetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnsetMetadata = + UnsetMetadata( + checkRequired("field", field), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnsetMetadata = apply { + if (validated) { + return@apply + } + + field() + 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 (field.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnsetMetadata && + field == other.field && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OnNo && + addTags == other.addTags && + removeTags == other.removeTags && + setMetadata == other.setMetadata && + unsetMetadata == other.unsetMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addTags, + removeTags, + setMetadata, + unsetMetadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OnNo{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" + } + + /** Actions to execute if the AI cannot determine the answer. */ + class OnUnknown + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val addTags: JsonField>, + private val removeTags: JsonField>, + private val setMetadata: JsonField>, + private val unsetMetadata: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("add_tags") + @ExcludeMissing + addTags: JsonField> = JsonMissing.of(), + @JsonProperty("remove_tags") + @ExcludeMissing + removeTags: JsonField> = JsonMissing.of(), + @JsonProperty("set_metadata") + @ExcludeMissing + setMetadata: JsonField> = JsonMissing.of(), + @JsonProperty("unset_metadata") + @ExcludeMissing + unsetMetadata: JsonField> = JsonMissing.of(), + ) : this(addTags, removeTags, setMetadata, unsetMetadata, mutableMapOf()) + + /** + * Array of tag strings to add to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun addTags(): Optional> = addTags.getOptional("add_tags") + + /** + * Array of tag strings to remove from the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun removeTags(): Optional> = removeTags.getOptional("remove_tags") + + /** + * Array of custom metadata field updates. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun setMetadata(): Optional> = + setMetadata.getOptional("set_metadata") + + /** + * Array of custom metadata fields to remove. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun unsetMetadata(): Optional> = + unsetMetadata.getOptional("unset_metadata") + + /** + * Returns the raw JSON value of [addTags]. + * + * Unlike [addTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_tags") + @ExcludeMissing + fun _addTags(): JsonField> = addTags + + /** + * Returns the raw JSON value of [removeTags]. + * + * Unlike [removeTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("remove_tags") + @ExcludeMissing + fun _removeTags(): JsonField> = removeTags + + /** + * Returns the raw JSON value of [setMetadata]. + * + * Unlike [setMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("set_metadata") + @ExcludeMissing + fun _setMetadata(): JsonField> = setMetadata + + /** + * Returns the raw JSON value of [unsetMetadata]. + * + * Unlike [unsetMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unset_metadata") + @ExcludeMissing + fun _unsetMetadata(): JsonField> = unsetMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OnUnknown]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OnUnknown]. */ + class Builder internal constructor() { + + private var addTags: JsonField>? = null + private var removeTags: JsonField>? = null + private var setMetadata: JsonField>? = null + private var unsetMetadata: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(onUnknown: OnUnknown) = apply { + addTags = onUnknown.addTags.map { it.toMutableList() } + removeTags = onUnknown.removeTags.map { it.toMutableList() } + setMetadata = onUnknown.setMetadata.map { it.toMutableList() } + unsetMetadata = onUnknown.unsetMetadata.map { it.toMutableList() } + additionalProperties = onUnknown.additionalProperties.toMutableMap() + } + + /** Array of tag strings to add to the asset. */ + fun addTags(addTags: List) = addTags(JsonField.of(addTags)) + + /** + * Sets [Builder.addTags] to an arbitrary JSON value. + * + * You should usually call [Builder.addTags] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun addTags(addTags: JsonField>) = apply { + this.addTags = addTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [addTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAddTag(addTag: String) = apply { + addTags = + (addTags ?: JsonField.of(mutableListOf())).also { + checkKnown("addTags", it).add(addTag) + } + } + + /** Array of tag strings to remove from the asset. */ + fun removeTags(removeTags: List) = + removeTags(JsonField.of(removeTags)) + + /** + * Sets [Builder.removeTags] to an arbitrary JSON value. + * + * You should usually call [Builder.removeTags] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun removeTags(removeTags: JsonField>) = apply { + this.removeTags = removeTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [removeTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addRemoveTag(removeTag: String) = apply { + removeTags = + (removeTags ?: JsonField.of(mutableListOf())).also { + checkKnown("removeTags", it).add(removeTag) + } + } + + /** Array of custom metadata field updates. */ + fun setMetadata(setMetadata: List) = + setMetadata(JsonField.of(setMetadata)) + + /** + * Sets [Builder.setMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.setMetadata] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun setMetadata(setMetadata: JsonField>) = apply { + this.setMetadata = setMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [SetMetadata] to [Builder.setMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addSetMetadata(setMetadata: SetMetadata) = apply { + this.setMetadata = + (this.setMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("setMetadata", it).add(setMetadata) + } + } + + /** Array of custom metadata fields to remove. */ + fun unsetMetadata(unsetMetadata: List) = + unsetMetadata(JsonField.of(unsetMetadata)) + + /** + * Sets [Builder.unsetMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.unsetMetadata] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unsetMetadata(unsetMetadata: JsonField>) = apply { + this.unsetMetadata = unsetMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { + this.unsetMetadata = + (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("unsetMetadata", it).add(unsetMetadata) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OnUnknown]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OnUnknown = + OnUnknown( + (addTags ?: JsonMissing.of()).map { it.toImmutable() }, + (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, + (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + (unsetMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OnUnknown = apply { + if (validated) { + return@apply + } + + addTags() + removeTags() + setMetadata().ifPresent { it.forEach { it.validate() } } + unsetMetadata().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (addTags.asKnown().getOrNull()?.size ?: 0) + + (removeTags.asKnown().getOrNull()?.size ?: 0) + + (setMetadata.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (unsetMetadata.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + class SetMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this(field, value, mutableMapOf()) + + /** + * Name of the custom metadata field to set. + * + * @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 field(): String = field.getRequired("field") + + /** + * Value to set for the custom metadata field. The value type should match + * the custom metadata field type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun value(): Value = value.getRequired("value") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(setMetadata: SetMetadata) = apply { + field = setMetadata.field + value = setMetadata.value + additionalProperties = + setMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to set. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + */ + fun value(value: Value) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ + fun valueOfMixed(mixed: List) = + value(Value.ofMixed(mixed)) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SetMetadata = + SetMetadata( + checkRequired("field", field), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SetMetadata = apply { + if (validated) { + return@apply + } + + field() + value().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (field.asKnown().isPresent) 1 else 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Value to set for the custom metadata field. The value type should match + * the custom metadata field type. + */ + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val mixed: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun mixed(): Optional> = + Optional.ofNullable(mixed) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isMixed(): Boolean = mixed != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asMixed(): List = + mixed.getOrThrow("mixed") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + mixed != null -> visitor.visitMixed(mixed) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitMixed( + mixed: List + ) { + mixed.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitMixed( + mixed: List + ) = mixed.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + string == other.string && + number == other.number && + bool == other.bool && + mixed == other.mixed + } + + override fun hashCode(): Int = Objects.hash(string, number, bool, mixed) + + override fun toString(): String = + when { + string != null -> "Value{string=$string}" + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + mixed != null -> "Value{mixed=$mixed}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic + fun ofMixed(mixed: List) = + Value(mixed = mixed.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Value] to a + * value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitMixed(mixed: List): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the + * API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Value: $json") + } + } + + internal class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Value(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Value(number = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Value(bool = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef< + List + >(), + ) + ?.let { Value(mixed = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. + // deserializing from object). + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, + // then use the first completely valid match, or simply the + // first match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.mixed != null -> generator.writeObject(value.mixed) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + + @JsonDeserialize( + using = UnnamedSchemaWithArrayParent1.Deserializer::class + ) + @JsonSerialize(using = UnnamedSchemaWithArrayParent1.Serializer::class) + class UnnamedSchemaWithArrayParent1 + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent1 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent1 && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> + "UnnamedSchemaWithArrayParent1{string=$string}" + number != null -> + "UnnamedSchemaWithArrayParent1{number=$number}" + bool != null -> "UnnamedSchemaWithArrayParent1{bool=$bool}" + _json != null -> + "UnnamedSchemaWithArrayParent1{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent1" + ) + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent1(string = string) + + @JvmStatic + fun ofNumber(number: Double) = + UnnamedSchemaWithArrayParent1(number = number) + + @JvmStatic + fun ofBool(bool: Boolean) = + UnnamedSchemaWithArrayParent1(bool = bool) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent1] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent1] to + * a value of type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent1] can contain an + * unknown variant if it was deserialized from data that doesn't + * match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent1: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent1::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent1 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnnamedSchemaWithArrayParent1( + string = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnnamedSchemaWithArrayParent1( + number = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnnamedSchemaWithArrayParent1( + bool = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is + // completely incompatible with all the possible + // variants (e.g. deserializing from object). + 0 -> UnnamedSchemaWithArrayParent1(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest + // validity, then use the first completely valid match, + // or simply the first match if none are completely + // valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent1::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent1, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent1" + ) + } + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SetMetadata && + field == other.field && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" + } + + class UnsetMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of() + ) : this(field, mutableMapOf()) + + /** + * Name of the custom metadata field to remove. + * + * @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 field(): String = field.getRequired("field") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnsetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnsetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unsetMetadata: UnsetMetadata) = apply { + field = unsetMetadata.field + additionalProperties = + unsetMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to remove. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnsetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnsetMetadata = + UnsetMetadata( + checkRequired("field", field), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnsetMetadata = apply { + if (validated) { + return@apply + } + + field() + 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 (field.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnsetMetadata && + field == other.field && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OnUnknown && + addTags == other.addTags && + removeTags == other.removeTags && + setMetadata == other.setMetadata && + unsetMetadata == other.unsetMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addTags, + removeTags, + setMetadata, + unsetMetadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OnUnknown{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" + } + + /** Actions to execute if the AI answers yes. */ + class OnYes + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val addTags: JsonField>, + private val removeTags: JsonField>, + private val setMetadata: JsonField>, + private val unsetMetadata: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("add_tags") + @ExcludeMissing + addTags: JsonField> = JsonMissing.of(), + @JsonProperty("remove_tags") + @ExcludeMissing + removeTags: JsonField> = JsonMissing.of(), + @JsonProperty("set_metadata") + @ExcludeMissing + setMetadata: JsonField> = JsonMissing.of(), + @JsonProperty("unset_metadata") + @ExcludeMissing + unsetMetadata: JsonField> = JsonMissing.of(), + ) : this(addTags, removeTags, setMetadata, unsetMetadata, mutableMapOf()) + + /** + * Array of tag strings to add to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun addTags(): Optional> = addTags.getOptional("add_tags") + + /** + * Array of tag strings to remove from the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun removeTags(): Optional> = removeTags.getOptional("remove_tags") + + /** + * Array of custom metadata field updates. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun setMetadata(): Optional> = + setMetadata.getOptional("set_metadata") + + /** + * Array of custom metadata fields to remove. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun unsetMetadata(): Optional> = + unsetMetadata.getOptional("unset_metadata") + + /** + * Returns the raw JSON value of [addTags]. + * + * Unlike [addTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_tags") + @ExcludeMissing + fun _addTags(): JsonField> = addTags + + /** + * Returns the raw JSON value of [removeTags]. + * + * Unlike [removeTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("remove_tags") + @ExcludeMissing + fun _removeTags(): JsonField> = removeTags + + /** + * Returns the raw JSON value of [setMetadata]. + * + * Unlike [setMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("set_metadata") + @ExcludeMissing + fun _setMetadata(): JsonField> = setMetadata + + /** + * Returns the raw JSON value of [unsetMetadata]. + * + * Unlike [unsetMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unset_metadata") + @ExcludeMissing + fun _unsetMetadata(): JsonField> = unsetMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [OnYes]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OnYes]. */ + class Builder internal constructor() { + + private var addTags: JsonField>? = null + private var removeTags: JsonField>? = null + private var setMetadata: JsonField>? = null + private var unsetMetadata: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(onYes: OnYes) = apply { + addTags = onYes.addTags.map { it.toMutableList() } + removeTags = onYes.removeTags.map { it.toMutableList() } + setMetadata = onYes.setMetadata.map { it.toMutableList() } + unsetMetadata = onYes.unsetMetadata.map { it.toMutableList() } + additionalProperties = onYes.additionalProperties.toMutableMap() + } + + /** Array of tag strings to add to the asset. */ + fun addTags(addTags: List) = addTags(JsonField.of(addTags)) + + /** + * Sets [Builder.addTags] to an arbitrary JSON value. + * + * You should usually call [Builder.addTags] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun addTags(addTags: JsonField>) = apply { + this.addTags = addTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [addTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAddTag(addTag: String) = apply { + addTags = + (addTags ?: JsonField.of(mutableListOf())).also { + checkKnown("addTags", it).add(addTag) + } + } + + /** Array of tag strings to remove from the asset. */ + fun removeTags(removeTags: List) = + removeTags(JsonField.of(removeTags)) + + /** + * Sets [Builder.removeTags] to an arbitrary JSON value. + * + * You should usually call [Builder.removeTags] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun removeTags(removeTags: JsonField>) = apply { + this.removeTags = removeTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [removeTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addRemoveTag(removeTag: String) = apply { + removeTags = + (removeTags ?: JsonField.of(mutableListOf())).also { + checkKnown("removeTags", it).add(removeTag) + } + } + + /** Array of custom metadata field updates. */ + fun setMetadata(setMetadata: List) = + setMetadata(JsonField.of(setMetadata)) + + /** + * Sets [Builder.setMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.setMetadata] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun setMetadata(setMetadata: JsonField>) = apply { + this.setMetadata = setMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [SetMetadata] to [Builder.setMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addSetMetadata(setMetadata: SetMetadata) = apply { + this.setMetadata = + (this.setMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("setMetadata", it).add(setMetadata) + } + } + + /** Array of custom metadata fields to remove. */ + fun unsetMetadata(unsetMetadata: List) = + unsetMetadata(JsonField.of(unsetMetadata)) + + /** + * Sets [Builder.unsetMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.unsetMetadata] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unsetMetadata(unsetMetadata: JsonField>) = apply { + this.unsetMetadata = unsetMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { + this.unsetMetadata = + (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("unsetMetadata", it).add(unsetMetadata) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OnYes]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OnYes = + OnYes( + (addTags ?: JsonMissing.of()).map { it.toImmutable() }, + (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, + (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + (unsetMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OnYes = apply { + if (validated) { + return@apply + } + + addTags() + removeTags() + setMetadata().ifPresent { it.forEach { it.validate() } } + unsetMetadata().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (addTags.asKnown().getOrNull()?.size ?: 0) + + (removeTags.asKnown().getOrNull()?.size ?: 0) + + (setMetadata.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (unsetMetadata.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + class SetMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this(field, value, mutableMapOf()) + + /** + * Name of the custom metadata field to set. + * + * @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 field(): String = field.getRequired("field") + + /** + * Value to set for the custom metadata field. The value type should match + * the custom metadata field type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun value(): Value = value.getRequired("value") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(setMetadata: SetMetadata) = apply { + field = setMetadata.field + value = setMetadata.value + additionalProperties = + setMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to set. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + */ + fun value(value: Value) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ + fun valueOfMixed(mixed: List) = + value(Value.ofMixed(mixed)) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SetMetadata = + SetMetadata( + checkRequired("field", field), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SetMetadata = apply { + if (validated) { + return@apply + } + + field() + value().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (field.asKnown().isPresent) 1 else 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Value to set for the custom metadata field. The value type should match + * the custom metadata field type. + */ + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val mixed: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun mixed(): Optional> = + Optional.ofNullable(mixed) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isMixed(): Boolean = mixed != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asMixed(): List = + mixed.getOrThrow("mixed") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + mixed != null -> visitor.visitMixed(mixed) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitMixed( + mixed: List + ) { + mixed.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitMixed( + mixed: List + ) = mixed.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + string == other.string && + number == other.number && + bool == other.bool && + mixed == other.mixed + } + + override fun hashCode(): Int = Objects.hash(string, number, bool, mixed) + + override fun toString(): String = + when { + string != null -> "Value{string=$string}" + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + mixed != null -> "Value{mixed=$mixed}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic + fun ofMixed(mixed: List) = + Value(mixed = mixed.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Value] to a + * value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitMixed(mixed: List): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the + * API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Value: $json") + } + } + + internal class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Value(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Value(number = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Value(bool = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef< + List + >(), + ) + ?.let { Value(mixed = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. + // deserializing from object). + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, + // then use the first completely valid match, or simply the + // first match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.mixed != null -> generator.writeObject(value.mixed) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + + @JsonDeserialize( + using = UnnamedSchemaWithArrayParent2.Deserializer::class + ) + @JsonSerialize(using = UnnamedSchemaWithArrayParent2.Serializer::class) + class UnnamedSchemaWithArrayParent2 + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent2 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent2 && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> + "UnnamedSchemaWithArrayParent2{string=$string}" + number != null -> + "UnnamedSchemaWithArrayParent2{number=$number}" + bool != null -> "UnnamedSchemaWithArrayParent2{bool=$bool}" + _json != null -> + "UnnamedSchemaWithArrayParent2{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent2" + ) + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent2(string = string) + + @JvmStatic + fun ofNumber(number: Double) = + UnnamedSchemaWithArrayParent2(number = number) + + @JvmStatic + fun ofBool(bool: Boolean) = + UnnamedSchemaWithArrayParent2(bool = bool) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent2] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [UnnamedSchemaWithArrayParent2] to + * a value of type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent2] can contain an + * unknown variant if it was deserialized from data that doesn't + * match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent2: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent2::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent2 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnnamedSchemaWithArrayParent2( + string = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnnamedSchemaWithArrayParent2( + number = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnnamedSchemaWithArrayParent2( + bool = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is + // completely incompatible with all the possible + // variants (e.g. deserializing from object). + 0 -> UnnamedSchemaWithArrayParent2(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest + // validity, then use the first completely valid match, + // or simply the first match if none are completely + // valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent2::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent2, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent2" + ) + } + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SetMetadata && + field == other.field && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" + } + + class UnsetMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of() + ) : this(field, mutableMapOf()) + + /** + * Name of the custom metadata field to remove. + * + * @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 field(): String = field.getRequired("field") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnsetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnsetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unsetMetadata: UnsetMetadata) = apply { + field = unsetMetadata.field + additionalProperties = + unsetMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to remove. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnsetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnsetMetadata = + UnsetMetadata( + checkRequired("field", field), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnsetMetadata = apply { + if (validated) { + return@apply + } + + field() + 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 (field.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnsetMetadata && + field == other.field && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OnYes && + addTags == other.addTags && + removeTags == other.removeTags && + setMetadata == other.setMetadata && + unsetMetadata == other.unsetMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addTags, + removeTags, + setMetadata, + unsetMetadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OnYes{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is YesNo && + instruction == other.instruction && + type == other.type && + onNo == other.onNo && + onUnknown == other.onUnknown && + onYes == other.onYes && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(instruction, type, onNo, onUnknown, onYes, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "YesNo{instruction=$instruction, type=$type, onNo=$onNo, onUnknown=$onUnknown, onYes=$onYes, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiTasks && + name == other.name && + tasks == other.tasks && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, tasks, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AiTasks{name=$name, tasks=$tasks, additionalProperties=$additionalProperties}" + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ImageOverlay.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ImageOverlay.kt index eeb14140..c4c0d114 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ImageOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ImageOverlay.kt @@ -23,6 +23,7 @@ import kotlin.jvm.optionals.getOrNull class ImageOverlay @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val layerMode: JsonField, private val position: JsonField, private val timing: JsonField, private val input: JsonField, @@ -34,6 +35,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("layerMode") + @ExcludeMissing + layerMode: JsonField = JsonMissing.of(), @JsonProperty("position") @ExcludeMissing position: JsonField = JsonMissing.of(), @@ -44,18 +48,46 @@ private constructor( @JsonProperty("transformation") @ExcludeMissing transformation: JsonField> = JsonMissing.of(), - ) : this(position, timing, input, type, encoding, transformation, mutableMapOf()) + ) : this(layerMode, position, timing, input, type, encoding, transformation, mutableMapOf()) fun toBaseOverlay(): BaseOverlay = - BaseOverlay.builder().position(position).timing(timing).build() + BaseOverlay.builder().layerMode(layerMode).position(position).timing(timing).build() + + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in the + * URL. By default, layers completely cover the base image beneath them. Layer modes change this + * behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is + * always darker than the original images. This is ideal for applying shadows or color tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. The + * red channel controls horizontal displacement, and the green channel controls vertical + * displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image + * transparent, while transparent areas leave the base image unchanged. This mode functions + * like a hole-punch, effectively cutting the shape of the layer out of the underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside the + * opaque area of the layer are preserved. This mode functions like a cookie-cutter, trimming + * the base image to match the specific dimensions and shape of the layer. See + * [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun layerMode(): Optional = layerMode.getOptional("layerMode") /** + * Specifies the overlay's position relative to the parent asset. See + * [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun position(): Optional = position.getOptional("position") /** + * Specifies timing information for the overlay (only applicable if the base asset is a video). + * See [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -86,6 +118,10 @@ private constructor( * automatically. To always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. * To always use plain text (`i-{input}`), set it to `plain`. * + * Regardless of the encoding method: + * - Leading and trailing slashes are removed. + * - Remaining slashes within the path are replaced with `@@` when using plain text. + * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -104,6 +140,15 @@ private constructor( fun transformation(): Optional> = transformation.getOptional("transformation") + /** + * Returns the raw JSON value of [layerMode]. + * + * Unlike [layerMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("layerMode") + @ExcludeMissing + fun _layerMode(): JsonField = layerMode + /** * Returns the raw JSON value of [position]. * @@ -169,6 +214,7 @@ private constructor( /** A builder for [ImageOverlay]. */ class Builder internal constructor() { + private var layerMode: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() private var timing: JsonField = JsonMissing.of() private var input: JsonField? = null @@ -179,6 +225,7 @@ private constructor( @JvmSynthetic internal fun from(imageOverlay: ImageOverlay) = apply { + layerMode = imageOverlay.layerMode position = imageOverlay.position timing = imageOverlay.timing input = imageOverlay.input @@ -188,6 +235,42 @@ private constructor( additionalProperties = imageOverlay.additionalProperties.toMutableMap() } + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in + * the URL. By default, layers completely cover the base image beneath them. Layer modes + * change this behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is + * always darker than the original images. This is ideal for applying shadows or color + * tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. + * The red channel controls horizontal displacement, and the green channel controls + * vertical displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image + * transparent, while transparent areas leave the base image unchanged. This mode + * functions like a hole-punch, effectively cutting the shape of the layer out of the + * underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside + * the opaque area of the layer are preserved. This mode functions like a cookie-cutter, + * trimming the base image to match the specific dimensions and shape of the layer. See + * [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + */ + fun layerMode(layerMode: BaseOverlay.LayerMode) = layerMode(JsonField.of(layerMode)) + + /** + * Sets [Builder.layerMode] to an arbitrary JSON value. + * + * You should usually call [Builder.layerMode] with a well-typed [BaseOverlay.LayerMode] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun layerMode(layerMode: JsonField) = apply { + this.layerMode = layerMode + } + + /** + * Specifies the overlay's position relative to the parent asset. See + * [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + */ fun position(position: OverlayPosition) = position(JsonField.of(position)) /** @@ -199,6 +282,11 @@ private constructor( */ fun position(position: JsonField) = apply { this.position = position } + /** + * Specifies timing information for the overlay (only applicable if the base asset is a + * video). See + * [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + */ fun timing(timing: OverlayTiming) = timing(JsonField.of(timing)) /** @@ -240,6 +328,10 @@ private constructor( * `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate format * automatically. To always use base64 encoding (`ie-{base64}`), set this parameter to * `base64`. To always use plain text (`i-{input}`), set it to `plain`. + * + * Regardless of the encoding method: + * - Leading and trailing slashes are removed. + * - Remaining slashes within the path are replaced with `@@` when using plain text. */ fun encoding(encoding: Encoding) = encoding(JsonField.of(encoding)) @@ -318,6 +410,7 @@ private constructor( */ fun build(): ImageOverlay = ImageOverlay( + layerMode, position, timing, checkRequired("input", input), @@ -335,6 +428,7 @@ private constructor( return@apply } + layerMode().ifPresent { it.validate() } position().ifPresent { it.validate() } timing().ifPresent { it.validate() } input() @@ -363,7 +457,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (position.asKnown().getOrNull()?.validity() ?: 0) + + (layerMode.asKnown().getOrNull()?.validity() ?: 0) + + (position.asKnown().getOrNull()?.validity() ?: 0) + (timing.asKnown().getOrNull()?.validity() ?: 0) + (if (input.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("image")) 1 else 0 } + @@ -375,6 +470,10 @@ private constructor( * `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate format * automatically. To always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. * To always use plain text (`i-{input}`), set it to `plain`. + * + * Regardless of the encoding method: + * - Leading and trailing slashes are removed. + * - Remaining slashes within the path are replaced with `@@` when using plain text. */ class Encoding @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -515,6 +614,7 @@ private constructor( } return other is ImageOverlay && + layerMode == other.layerMode && position == other.position && timing == other.timing && input == other.input && @@ -525,11 +625,20 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(position, timing, input, type, encoding, transformation, additionalProperties) + Objects.hash( + layerMode, + position, + timing, + input, + type, + encoding, + transformation, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "ImageOverlay{position=$position, timing=$timing, input=$input, type=$type, encoding=$encoding, transformation=$transformation, additionalProperties=$additionalProperties}" + "ImageOverlay{layerMode=$layerMode, position=$position, timing=$timing, input=$input, type=$type, encoding=$encoding, transformation=$transformation, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SavedExtension.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SavedExtension.kt new file mode 100644 index 00000000..d3389ef3 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SavedExtension.kt @@ -0,0 +1,383 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Saved extension object containing extension configuration. */ +class SavedExtension +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val config: JsonField, + private val createdAt: JsonField, + private val description: JsonField, + private val name: JsonField, + private val updatedAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("config") + @ExcludeMissing + config: JsonField = JsonMissing.of(), + @JsonProperty("createdAt") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("updatedAt") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this(id, config, createdAt, description, name, updatedAt, mutableMapOf()) + + /** + * Unique identifier of the saved extension. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * Configuration object for an extension (base extensions only, not saved extension references). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun config(): Optional = config.getOptional("config") + + /** + * Timestamp when the saved extension was created. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun createdAt(): Optional = createdAt.getOptional("createdAt") + + /** + * Description of the saved extension. + * + * @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") + + /** + * Name of the saved extension. + * + * @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") + + /** + * Timestamp when the saved extension was last updated. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun updatedAt(): Optional = updatedAt.getOptional("updatedAt") + + /** + * 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 [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config + + /** + * 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 [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 [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 [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updatedAt") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [SavedExtension]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SavedExtension]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var config: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(savedExtension: SavedExtension) = apply { + id = savedExtension.id + config = savedExtension.config + createdAt = savedExtension.createdAt + description = savedExtension.description + name = savedExtension.name + updatedAt = savedExtension.updatedAt + additionalProperties = savedExtension.additionalProperties.toMutableMap() + } + + /** Unique identifier of the saved extension. */ + 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 } + + /** + * Configuration object for an extension (base extensions only, not saved extension + * references). + */ + fun config(config: ExtensionConfig) = config(JsonField.of(config)) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [ExtensionConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun config(config: JsonField) = apply { this.config = config } + + /** Alias for calling [config] with `ExtensionConfig.ofRemoveBg(removeBg)`. */ + fun config(removeBg: ExtensionConfig.RemoveBg) = + config(ExtensionConfig.ofRemoveBg(removeBg)) + + /** + * Alias for calling [config] with + * `ExtensionConfig.ofAutoTaggingExtension(autoTaggingExtension)`. + */ + fun config(autoTaggingExtension: ExtensionConfig.AutoTaggingExtension) = + config(ExtensionConfig.ofAutoTaggingExtension(autoTaggingExtension)) + + /** Alias for calling [config] with `ExtensionConfig.ofAiAutoDescription()`. */ + fun configAiAutoDescription() = config(ExtensionConfig.ofAiAutoDescription()) + + /** Alias for calling [config] with `ExtensionConfig.ofAiTasks(aiTasks)`. */ + fun config(aiTasks: ExtensionConfig.AiTasks) = config(ExtensionConfig.ofAiTasks(aiTasks)) + + /** + * Alias for calling [config] with the following: + * ```java + * ExtensionConfig.AiTasks.builder() + * .tasks(tasks) + * .build() + * ``` + */ + fun aiTasksConfig(tasks: List) = + config(ExtensionConfig.AiTasks.builder().tasks(tasks).build()) + + /** Timestamp when the saved extension 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 } + + /** Description of the saved extension. */ + 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 } + + /** Name of the saved extension. */ + 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 } + + /** Timestamp when the saved extension was last updated. */ + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SavedExtension]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SavedExtension = + SavedExtension( + id, + config, + createdAt, + description, + name, + updatedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SavedExtension = apply { + if (validated) { + return@apply + } + + id() + config().ifPresent { it.validate() } + createdAt() + description() + name() + updatedAt() + 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) + + (config.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SavedExtension && + id == other.id && + config == other.config && + createdAt == other.createdAt && + description == other.description && + name == other.name && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, config, createdAt, description, name, updatedAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SavedExtension{id=$id, config=$config, createdAt=$createdAt, description=$description, name=$name, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlay.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlay.kt index f9215069..d8dfb6e2 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlay.kt @@ -22,6 +22,7 @@ import kotlin.jvm.optionals.getOrNull class SolidColorOverlay @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val layerMode: JsonField, private val position: JsonField, private val timing: JsonField, private val color: JsonField, @@ -32,6 +33,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("layerMode") + @ExcludeMissing + layerMode: JsonField = JsonMissing.of(), @JsonProperty("position") @ExcludeMissing position: JsonField = JsonMissing.of(), @@ -41,18 +45,46 @@ private constructor( @JsonProperty("transformation") @ExcludeMissing transformation: JsonField> = JsonMissing.of(), - ) : this(position, timing, color, type, transformation, mutableMapOf()) + ) : this(layerMode, position, timing, color, type, transformation, mutableMapOf()) fun toBaseOverlay(): BaseOverlay = - BaseOverlay.builder().position(position).timing(timing).build() + BaseOverlay.builder().layerMode(layerMode).position(position).timing(timing).build() /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in the + * URL. By default, layers completely cover the base image beneath them. Layer modes change this + * behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is + * always darker than the original images. This is ideal for applying shadows or color tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. The + * red channel controls horizontal displacement, and the green channel controls vertical + * displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image + * transparent, while transparent areas leave the base image unchanged. This mode functions + * like a hole-punch, effectively cutting the shape of the layer out of the underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside the + * opaque area of the layer are preserved. This mode functions like a cookie-cutter, trimming + * the base image to match the specific dimensions and shape of the layer. See + * [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun layerMode(): Optional = layerMode.getOptional("layerMode") + + /** + * Specifies the overlay's position relative to the parent asset. See + * [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun position(): Optional = position.getOptional("position") /** + * Specifies timing information for the overlay (only applicable if the base asset is a video). + * See [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -92,6 +124,15 @@ private constructor( fun transformation(): Optional> = transformation.getOptional("transformation") + /** + * Returns the raw JSON value of [layerMode]. + * + * Unlike [layerMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("layerMode") + @ExcludeMissing + fun _layerMode(): JsonField = layerMode + /** * Returns the raw JSON value of [position]. * @@ -150,6 +191,7 @@ private constructor( /** A builder for [SolidColorOverlay]. */ class Builder internal constructor() { + private var layerMode: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() private var timing: JsonField = JsonMissing.of() private var color: JsonField? = null @@ -159,6 +201,7 @@ private constructor( @JvmSynthetic internal fun from(solidColorOverlay: SolidColorOverlay) = apply { + layerMode = solidColorOverlay.layerMode position = solidColorOverlay.position timing = solidColorOverlay.timing color = solidColorOverlay.color @@ -167,6 +210,42 @@ private constructor( additionalProperties = solidColorOverlay.additionalProperties.toMutableMap() } + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in + * the URL. By default, layers completely cover the base image beneath them. Layer modes + * change this behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is + * always darker than the original images. This is ideal for applying shadows or color + * tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. + * The red channel controls horizontal displacement, and the green channel controls + * vertical displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image + * transparent, while transparent areas leave the base image unchanged. This mode + * functions like a hole-punch, effectively cutting the shape of the layer out of the + * underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside + * the opaque area of the layer are preserved. This mode functions like a cookie-cutter, + * trimming the base image to match the specific dimensions and shape of the layer. See + * [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + */ + fun layerMode(layerMode: BaseOverlay.LayerMode) = layerMode(JsonField.of(layerMode)) + + /** + * Sets [Builder.layerMode] to an arbitrary JSON value. + * + * You should usually call [Builder.layerMode] with a well-typed [BaseOverlay.LayerMode] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun layerMode(layerMode: JsonField) = apply { + this.layerMode = layerMode + } + + /** + * Specifies the overlay's position relative to the parent asset. See + * [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + */ fun position(position: OverlayPosition) = position(JsonField.of(position)) /** @@ -178,6 +257,11 @@ private constructor( */ fun position(position: JsonField) = apply { this.position = position } + /** + * Specifies timing information for the overlay (only applicable if the base asset is a + * video). See + * [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + */ fun timing(timing: OverlayTiming) = timing(JsonField.of(timing)) /** @@ -286,6 +370,7 @@ private constructor( */ fun build(): SolidColorOverlay = SolidColorOverlay( + layerMode, position, timing, checkRequired("color", color), @@ -302,6 +387,7 @@ private constructor( return@apply } + layerMode().ifPresent { it.validate() } position().ifPresent { it.validate() } timing().ifPresent { it.validate() } color() @@ -329,7 +415,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (position.asKnown().getOrNull()?.validity() ?: 0) + + (layerMode.asKnown().getOrNull()?.validity() ?: 0) + + (position.asKnown().getOrNull()?.validity() ?: 0) + (timing.asKnown().getOrNull()?.validity() ?: 0) + (if (color.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("solidColor")) 1 else 0 } + @@ -341,6 +428,7 @@ private constructor( } return other is SolidColorOverlay && + layerMode == other.layerMode && position == other.position && timing == other.timing && color == other.color && @@ -350,11 +438,11 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(position, timing, color, type, transformation, additionalProperties) + Objects.hash(layerMode, position, timing, color, type, transformation, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "SolidColorOverlay{position=$position, timing=$timing, color=$color, type=$type, transformation=$transformation, additionalProperties=$additionalProperties}" + "SolidColorOverlay{layerMode=$layerMode, position=$position, timing=$timing, color=$color, type=$type, transformation=$transformation, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt index b4db2465..dc511d70 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt @@ -52,8 +52,8 @@ private constructor( ) : this(alpha, background, gradient, height, radius, width, mutableMapOf()) /** - * Specifies the transparency level of the solid color overlay. Accepts integers from `1` to - * `9`. + * Specifies the transparency level of the overlaid solid color layer. Supports integers from + * `1` to `9`. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -90,8 +90,12 @@ private constructor( fun height(): Optional = height.getOptional("height") /** - * Specifies the corner radius of the solid color overlay. Set to `max` for circular or oval - * shape. See [radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + * Specifies the corner radius of the solid color overlay. + * - Single value (positive integer): Applied to all corners (e.g., `20`). + * - `max`: Creates a circular or oval shape. + * - Per-corner array: Provide four underscore-separated values representing top-left, + * top-right, bottom-right, and bottom-left corners respectively (e.g., `10_20_30_40`). See + * [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -196,8 +200,8 @@ private constructor( } /** - * Specifies the transparency level of the solid color overlay. Accepts integers from `1` to - * `9`. + * Specifies the transparency level of the overlaid solid color layer. Supports integers + * from `1` to `9`. */ fun alpha(alpha: Double) = alpha(JsonField.of(alpha)) @@ -268,8 +272,12 @@ private constructor( fun height(string: String) = height(Height.ofString(string)) /** - * Specifies the corner radius of the solid color overlay. Set to `max` for circular or oval - * shape. See [radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + * Specifies the corner radius of the solid color overlay. + * - Single value (positive integer): Applied to all corners (e.g., `20`). + * - `max`: Creates a circular or oval shape. + * - Per-corner array: Provide four underscore-separated values representing top-left, + * top-right, bottom-right, and bottom-left corners respectively (e.g., `10_20_30_40`). + * See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). */ fun radius(radius: Radius) = radius(JsonField.of(radius)) @@ -287,6 +295,9 @@ private constructor( /** Alias for calling [radius] with `Radius.ofMax()`. */ fun radiusMax() = radius(Radius.ofMax()) + /** Alias for calling [radius] with `Radius.ofString(string)`. */ + fun radius(string: String) = radius(Radius.ofString(string)) + /** * Controls the width of the solid color overlay. Accepts a numeric value or an arithmetic * expression (e.g., `bw_mul_0.2` or `bh_div_2`). Learn about @@ -738,8 +749,12 @@ private constructor( } /** - * Specifies the corner radius of the solid color overlay. Set to `max` for circular or oval - * shape. See [radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + * Specifies the corner radius of the solid color overlay. + * - Single value (positive integer): Applied to all corners (e.g., `20`). + * - `max`: Creates a circular or oval shape. + * - Per-corner array: Provide four underscore-separated values representing top-left, + * top-right, bottom-right, and bottom-left corners respectively (e.g., `10_20_30_40`). See + * [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). */ @JsonDeserialize(using = Radius.Deserializer::class) @JsonSerialize(using = Radius.Serializer::class) @@ -747,6 +762,7 @@ private constructor( private constructor( private val number: Double? = null, private val max: JsonValue? = null, + private val string: String? = null, private val _json: JsonValue? = null, ) { @@ -754,20 +770,27 @@ private constructor( fun max(): Optional = Optional.ofNullable(max) + fun string(): Optional = Optional.ofNullable(string) + fun isNumber(): Boolean = number != null fun isMax(): Boolean = max != null + fun isString(): Boolean = string != null + fun asNumber(): Double = number.getOrThrow("number") fun asMax(): JsonValue = max.getOrThrow("max") + fun asString(): String = string.getOrThrow("string") + fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { number != null -> visitor.visitNumber(number) max != null -> visitor.visitMax(max) + string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } @@ -789,6 +812,8 @@ private constructor( } } } + + override fun visitString(string: String) {} } ) validated = true @@ -817,6 +842,8 @@ private constructor( override fun visitMax(max: JsonValue) = max.let { if (it == JsonValue.from("max")) 1 else 0 } + override fun visitString(string: String) = 1 + override fun unknown(json: JsonValue?) = 0 } ) @@ -826,15 +853,19 @@ private constructor( return true } - return other is Radius && number == other.number && max == other.max + return other is Radius && + number == other.number && + max == other.max && + string == other.string } - override fun hashCode(): Int = Objects.hash(number, max) + override fun hashCode(): Int = Objects.hash(number, max, string) override fun toString(): String = when { number != null -> "Radius{number=$number}" max != null -> "Radius{max=$max}" + string != null -> "Radius{string=$string}" _json != null -> "Radius{_unknown=$_json}" else -> throw IllegalStateException("Invalid Radius") } @@ -844,6 +875,8 @@ private constructor( @JvmStatic fun ofNumber(number: Double) = Radius(number = number) @JvmStatic fun ofMax() = Radius(max = JsonValue.from("max")) + + @JvmStatic fun ofString(string: String) = Radius(string = string) } /** An interface that defines how to map each variant of [Radius] to a value of type [T]. */ @@ -853,6 +886,8 @@ private constructor( fun visitMax(max: JsonValue): T + fun visitString(string: String): T + /** * Maps an unknown variant of [Radius] to a value of type [T]. * @@ -881,6 +916,9 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { Radius(number = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Radius(string = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -908,6 +946,7 @@ private constructor( when { value.number != null -> generator.writeObject(value.number) value.max != null -> generator.writeObject(value.max) + value.string != null -> generator.writeObject(value.string) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Radius") } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlay.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlay.kt index 02463135..e9df4a45 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlay.kt @@ -23,6 +23,7 @@ import kotlin.jvm.optionals.getOrNull class SubtitleOverlay @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val layerMode: JsonField, private val position: JsonField, private val timing: JsonField, private val input: JsonField, @@ -34,6 +35,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("layerMode") + @ExcludeMissing + layerMode: JsonField = JsonMissing.of(), @JsonProperty("position") @ExcludeMissing position: JsonField = JsonMissing.of(), @@ -44,18 +48,46 @@ private constructor( @JsonProperty("transformation") @ExcludeMissing transformation: JsonField> = JsonMissing.of(), - ) : this(position, timing, input, type, encoding, transformation, mutableMapOf()) + ) : this(layerMode, position, timing, input, type, encoding, transformation, mutableMapOf()) fun toBaseOverlay(): BaseOverlay = - BaseOverlay.builder().position(position).timing(timing).build() + BaseOverlay.builder().layerMode(layerMode).position(position).timing(timing).build() + + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in the + * URL. By default, layers completely cover the base image beneath them. Layer modes change this + * behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is + * always darker than the original images. This is ideal for applying shadows or color tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. The + * red channel controls horizontal displacement, and the green channel controls vertical + * displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image + * transparent, while transparent areas leave the base image unchanged. This mode functions + * like a hole-punch, effectively cutting the shape of the layer out of the underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside the + * opaque area of the layer are preserved. This mode functions like a cookie-cutter, trimming + * the base image to match the specific dimensions and shape of the layer. See + * [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun layerMode(): Optional = layerMode.getOptional("layerMode") /** + * Specifies the overlay's position relative to the parent asset. See + * [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun position(): Optional = position.getOptional("position") /** + * Specifies timing information for the overlay (only applicable if the base asset is a video). + * See [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -86,6 +118,10 @@ private constructor( * automatically. To always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. * To always use plain text (`i-{input}`), set it to `plain`. * + * Regardless of the encoding method: + * - Leading and trailing slashes are removed. + * - Remaining slashes within the path are replaced with `@@` when using plain text. + * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -101,6 +137,15 @@ private constructor( fun transformation(): Optional> = transformation.getOptional("transformation") + /** + * Returns the raw JSON value of [layerMode]. + * + * Unlike [layerMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("layerMode") + @ExcludeMissing + fun _layerMode(): JsonField = layerMode + /** * Returns the raw JSON value of [position]. * @@ -166,6 +211,7 @@ private constructor( /** A builder for [SubtitleOverlay]. */ class Builder internal constructor() { + private var layerMode: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() private var timing: JsonField = JsonMissing.of() private var input: JsonField? = null @@ -176,6 +222,7 @@ private constructor( @JvmSynthetic internal fun from(subtitleOverlay: SubtitleOverlay) = apply { + layerMode = subtitleOverlay.layerMode position = subtitleOverlay.position timing = subtitleOverlay.timing input = subtitleOverlay.input @@ -185,6 +232,42 @@ private constructor( additionalProperties = subtitleOverlay.additionalProperties.toMutableMap() } + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in + * the URL. By default, layers completely cover the base image beneath them. Layer modes + * change this behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is + * always darker than the original images. This is ideal for applying shadows or color + * tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. + * The red channel controls horizontal displacement, and the green channel controls + * vertical displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image + * transparent, while transparent areas leave the base image unchanged. This mode + * functions like a hole-punch, effectively cutting the shape of the layer out of the + * underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside + * the opaque area of the layer are preserved. This mode functions like a cookie-cutter, + * trimming the base image to match the specific dimensions and shape of the layer. See + * [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + */ + fun layerMode(layerMode: BaseOverlay.LayerMode) = layerMode(JsonField.of(layerMode)) + + /** + * Sets [Builder.layerMode] to an arbitrary JSON value. + * + * You should usually call [Builder.layerMode] with a well-typed [BaseOverlay.LayerMode] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun layerMode(layerMode: JsonField) = apply { + this.layerMode = layerMode + } + + /** + * Specifies the overlay's position relative to the parent asset. See + * [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + */ fun position(position: OverlayPosition) = position(JsonField.of(position)) /** @@ -196,6 +279,11 @@ private constructor( */ fun position(position: JsonField) = apply { this.position = position } + /** + * Specifies timing information for the overlay (only applicable if the base asset is a + * video). See + * [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + */ fun timing(timing: OverlayTiming) = timing(JsonField.of(timing)) /** @@ -237,6 +325,10 @@ private constructor( * `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate format * automatically. To always use base64 encoding (`ie-{base64}`), set this parameter to * `base64`. To always use plain text (`i-{input}`), set it to `plain`. + * + * Regardless of the encoding method: + * - Leading and trailing slashes are removed. + * - Remaining slashes within the path are replaced with `@@` when using plain text. */ fun encoding(encoding: Encoding) = encoding(JsonField.of(encoding)) @@ -312,6 +404,7 @@ private constructor( */ fun build(): SubtitleOverlay = SubtitleOverlay( + layerMode, position, timing, checkRequired("input", input), @@ -329,6 +422,7 @@ private constructor( return@apply } + layerMode().ifPresent { it.validate() } position().ifPresent { it.validate() } timing().ifPresent { it.validate() } input() @@ -357,7 +451,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (position.asKnown().getOrNull()?.validity() ?: 0) + + (layerMode.asKnown().getOrNull()?.validity() ?: 0) + + (position.asKnown().getOrNull()?.validity() ?: 0) + (timing.asKnown().getOrNull()?.validity() ?: 0) + (if (input.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("subtitle")) 1 else 0 } + @@ -369,6 +464,10 @@ private constructor( * `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate format * automatically. To always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. * To always use plain text (`i-{input}`), set it to `plain`. + * + * Regardless of the encoding method: + * - Leading and trailing slashes are removed. + * - Remaining slashes within the path are replaced with `@@` when using plain text. */ class Encoding @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -509,6 +608,7 @@ private constructor( } return other is SubtitleOverlay && + layerMode == other.layerMode && position == other.position && timing == other.timing && input == other.input && @@ -519,11 +619,20 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(position, timing, input, type, encoding, transformation, additionalProperties) + Objects.hash( + layerMode, + position, + timing, + input, + type, + encoding, + transformation, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "SubtitleOverlay{position=$position, timing=$timing, input=$input, type=$type, encoding=$encoding, transformation=$transformation, additionalProperties=$additionalProperties}" + "SubtitleOverlay{layerMode=$layerMode, position=$position, timing=$timing, input=$input, type=$type, encoding=$encoding, transformation=$transformation, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlayTransformation.kt index d75c55bb..ed11217f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlayTransformation.kt @@ -90,8 +90,9 @@ private constructor( fun color(): Optional = color.getOptional("color") /** - * Font family for subtitles. Refer to the - * [supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list). + * Sets the font family of subtitle text. Refer to the + * [supported fonts documented](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list) + * in the ImageKit transformations guide. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -283,8 +284,9 @@ private constructor( fun color(color: JsonField) = apply { this.color = color } /** - * Font family for subtitles. Refer to the - * [supported fonts](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list). + * Sets the font family of subtitle text. Refer to the + * [supported fonts documented](https://imagekit.io/docs/add-overlays-on-images#supported-text-font-list) + * in the ImageKit transformations guide. */ fun fontFamily(fontFamily: String) = fontFamily(JsonField.of(fontFamily)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlay.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlay.kt index 679b0f68..3ca84fd6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlay.kt @@ -23,6 +23,7 @@ import kotlin.jvm.optionals.getOrNull class TextOverlay @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val layerMode: JsonField, private val position: JsonField, private val timing: JsonField, private val text: JsonField, @@ -34,6 +35,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("layerMode") + @ExcludeMissing + layerMode: JsonField = JsonMissing.of(), @JsonProperty("position") @ExcludeMissing position: JsonField = JsonMissing.of(), @@ -44,18 +48,46 @@ private constructor( @JsonProperty("transformation") @ExcludeMissing transformation: JsonField> = JsonMissing.of(), - ) : this(position, timing, text, type, encoding, transformation, mutableMapOf()) + ) : this(layerMode, position, timing, text, type, encoding, transformation, mutableMapOf()) fun toBaseOverlay(): BaseOverlay = - BaseOverlay.builder().position(position).timing(timing).build() + BaseOverlay.builder().layerMode(layerMode).position(position).timing(timing).build() + + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in the + * URL. By default, layers completely cover the base image beneath them. Layer modes change this + * behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is + * always darker than the original images. This is ideal for applying shadows or color tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. The + * red channel controls horizontal displacement, and the green channel controls vertical + * displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image + * transparent, while transparent areas leave the base image unchanged. This mode functions + * like a hole-punch, effectively cutting the shape of the layer out of the underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside the + * opaque area of the layer are preserved. This mode functions like a cookie-cutter, trimming + * the base image to match the specific dimensions and shape of the layer. See + * [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun layerMode(): Optional = layerMode.getOptional("layerMode") /** + * Specifies the overlay's position relative to the parent asset. See + * [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun position(): Optional = position.getOptional("position") /** + * Specifies timing information for the overlay (only applicable if the base asset is a video). + * See [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -87,6 +119,9 @@ private constructor( * based on the input text. To always use base64 (`ie-{base64}`), set this parameter to * `base64`. To always use plain text (`i-{input}`), set it to `plain`. * + * Regardless of the encoding method, the input text is always percent-encoded to ensure it is + * URL-safe. + * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -102,6 +137,15 @@ private constructor( fun transformation(): Optional> = transformation.getOptional("transformation") + /** + * Returns the raw JSON value of [layerMode]. + * + * Unlike [layerMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("layerMode") + @ExcludeMissing + fun _layerMode(): JsonField = layerMode + /** * Returns the raw JSON value of [position]. * @@ -167,6 +211,7 @@ private constructor( /** A builder for [TextOverlay]. */ class Builder internal constructor() { + private var layerMode: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() private var timing: JsonField = JsonMissing.of() private var text: JsonField? = null @@ -177,6 +222,7 @@ private constructor( @JvmSynthetic internal fun from(textOverlay: TextOverlay) = apply { + layerMode = textOverlay.layerMode position = textOverlay.position timing = textOverlay.timing text = textOverlay.text @@ -186,6 +232,42 @@ private constructor( additionalProperties = textOverlay.additionalProperties.toMutableMap() } + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in + * the URL. By default, layers completely cover the base image beneath them. Layer modes + * change this behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is + * always darker than the original images. This is ideal for applying shadows or color + * tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. + * The red channel controls horizontal displacement, and the green channel controls + * vertical displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image + * transparent, while transparent areas leave the base image unchanged. This mode + * functions like a hole-punch, effectively cutting the shape of the layer out of the + * underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside + * the opaque area of the layer are preserved. This mode functions like a cookie-cutter, + * trimming the base image to match the specific dimensions and shape of the layer. See + * [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + */ + fun layerMode(layerMode: BaseOverlay.LayerMode) = layerMode(JsonField.of(layerMode)) + + /** + * Sets [Builder.layerMode] to an arbitrary JSON value. + * + * You should usually call [Builder.layerMode] with a well-typed [BaseOverlay.LayerMode] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun layerMode(layerMode: JsonField) = apply { + this.layerMode = layerMode + } + + /** + * Specifies the overlay's position relative to the parent asset. See + * [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + */ fun position(position: OverlayPosition) = position(JsonField.of(position)) /** @@ -197,6 +279,11 @@ private constructor( */ fun position(position: JsonField) = apply { this.position = position } + /** + * Specifies timing information for the overlay (only applicable if the base asset is a + * video). See + * [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + */ fun timing(timing: OverlayTiming) = timing(JsonField.of(timing)) /** @@ -241,6 +328,9 @@ private constructor( * `ie-{base64_encoded_input}` (base64). By default, the SDK selects the appropriate format * based on the input text. To always use base64 (`ie-{base64}`), set this parameter to * `base64`. To always use plain text (`i-{input}`), set it to `plain`. + * + * Regardless of the encoding method, the input text is always percent-encoded to ensure it + * is URL-safe. */ fun encoding(encoding: Encoding) = encoding(JsonField.of(encoding)) @@ -316,6 +406,7 @@ private constructor( */ fun build(): TextOverlay = TextOverlay( + layerMode, position, timing, checkRequired("text", text), @@ -333,6 +424,7 @@ private constructor( return@apply } + layerMode().ifPresent { it.validate() } position().ifPresent { it.validate() } timing().ifPresent { it.validate() } text() @@ -361,7 +453,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (position.asKnown().getOrNull()?.validity() ?: 0) + + (layerMode.asKnown().getOrNull()?.validity() ?: 0) + + (position.asKnown().getOrNull()?.validity() ?: 0) + (timing.asKnown().getOrNull()?.validity() ?: 0) + (if (text.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("text")) 1 else 0 } + @@ -373,6 +466,9 @@ private constructor( * `ie-{base64_encoded_input}` (base64). By default, the SDK selects the appropriate format * based on the input text. To always use base64 (`ie-{base64}`), set this parameter to * `base64`. To always use plain text (`i-{input}`), set it to `plain`. + * + * Regardless of the encoding method, the input text is always percent-encoded to ensure it is + * URL-safe. */ class Encoding @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -513,6 +609,7 @@ private constructor( } return other is TextOverlay && + layerMode == other.layerMode && position == other.position && timing == other.timing && text == other.text && @@ -523,11 +620,20 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(position, timing, text, type, encoding, transformation, additionalProperties) + Objects.hash( + layerMode, + position, + timing, + text, + type, + encoding, + transformation, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "TextOverlay{position=$position, timing=$timing, text=$text, type=$type, encoding=$encoding, transformation=$transformation, additionalProperties=$additionalProperties}" + "TextOverlay{layerMode=$layerMode, position=$position, timing=$timing, text=$text, type=$type, encoding=$encoding, transformation=$transformation, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt index cad7948e..026bffd9 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt @@ -107,7 +107,8 @@ private constructor( fun background(): Optional = background.getOptional("background") /** - * Flip the text overlay horizontally, vertically, or both. + * Flip/mirror the text horizontally, vertically, or in both directions. Acceptable values: `h` + * (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or `v_h`. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -153,10 +154,8 @@ private constructor( fun innerAlignment(): Optional = innerAlignment.getOptional("innerAlignment") /** - * Specifies the line height of the text overlay. Accepts integer values representing line - * height in points. It can also accept - * [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations) - * such as `bw_mul_0.2`, or `bh_div_20`. + * Specifies the line height for multi-line text overlays. It will come into effect only if the + * text wraps over multiple lines. Accepts either an integer value or an arithmetic expression. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -174,8 +173,12 @@ private constructor( fun padding(): Optional = padding.getOptional("padding") /** - * Specifies the corner radius of the text overlay. Set to `max` to achieve a circular or oval - * shape. + * Specifies the corner radius: + * - Single value (positive integer): Applied to all corners (e.g., `20`). + * - `max`: Creates a circular or oval shape. + * - Per-corner array: Provide four underscore-separated values representing top-left, + * top-right, bottom-right, and bottom-left corners respectively (e.g., `10_20_30_40`). See + * [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -391,7 +394,10 @@ private constructor( */ fun background(background: JsonField) = apply { this.background = background } - /** Flip the text overlay horizontally, vertically, or both. */ + /** + * Flip/mirror the text horizontally, vertically, or in both directions. Acceptable values: + * `h` (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or `v_h`. + */ fun flip(flip: Flip) = flip(JsonField.of(flip)) /** @@ -472,10 +478,9 @@ private constructor( } /** - * Specifies the line height of the text overlay. Accepts integer values representing line - * height in points. It can also accept - * [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations) - * such as `bw_mul_0.2`, or `bh_div_20`. + * Specifies the line height for multi-line text overlays. It will come into effect only if + * the text wraps over multiple lines. Accepts either an integer value or an arithmetic + * expression. */ fun lineHeight(lineHeight: LineHeight) = lineHeight(JsonField.of(lineHeight)) @@ -516,8 +521,12 @@ private constructor( fun padding(string: String) = padding(Padding.ofString(string)) /** - * Specifies the corner radius of the text overlay. Set to `max` to achieve a circular or - * oval shape. + * Specifies the corner radius: + * - Single value (positive integer): Applied to all corners (e.g., `20`). + * - `max`: Creates a circular or oval shape. + * - Per-corner array: Provide four underscore-separated values representing top-left, + * top-right, bottom-right, and bottom-left corners respectively (e.g., `10_20_30_40`). + * See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). */ fun radius(radius: Radius) = radius(JsonField.of(radius)) @@ -535,6 +544,9 @@ private constructor( /** Alias for calling [radius] with `Radius.ofMax()`. */ fun radiusMax() = radius(Radius.ofMax()) + /** Alias for calling [radius] with `Radius.ofString(string)`. */ + fun radius(string: String) = radius(Radius.ofString(string)) + /** * Specifies the rotation angle of the text overlay. Accepts a numeric value for clockwise * rotation or a string prefixed with "N" for counter-clockwise rotation. @@ -690,7 +702,10 @@ private constructor( (if (typography.asKnown().isPresent) 1 else 0) + (width.asKnown().getOrNull()?.validity() ?: 0) - /** Flip the text overlay horizontally, vertically, or both. */ + /** + * Flip/mirror the text horizontally, vertically, or in both directions. Acceptable values: `h` + * (horizontal), `v` (vertical), `h_v` (horizontal and vertical), or `v_h`. + */ class Flip @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -1142,10 +1157,8 @@ private constructor( } /** - * Specifies the line height of the text overlay. Accepts integer values representing line - * height in points. It can also accept - * [arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations) - * such as `bw_mul_0.2`, or `bh_div_20`. + * Specifies the line height for multi-line text overlays. It will come into effect only if the + * text wraps over multiple lines. Accepts either an integer value or an arithmetic expression. */ @JsonDeserialize(using = LineHeight.Deserializer::class) @JsonSerialize(using = LineHeight.Serializer::class) @@ -1491,8 +1504,12 @@ private constructor( } /** - * Specifies the corner radius of the text overlay. Set to `max` to achieve a circular or oval - * shape. + * Specifies the corner radius: + * - Single value (positive integer): Applied to all corners (e.g., `20`). + * - `max`: Creates a circular or oval shape. + * - Per-corner array: Provide four underscore-separated values representing top-left, + * top-right, bottom-right, and bottom-left corners respectively (e.g., `10_20_30_40`). See + * [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). */ @JsonDeserialize(using = Radius.Deserializer::class) @JsonSerialize(using = Radius.Serializer::class) @@ -1500,6 +1517,7 @@ private constructor( private constructor( private val number: Double? = null, private val max: JsonValue? = null, + private val string: String? = null, private val _json: JsonValue? = null, ) { @@ -1507,20 +1525,27 @@ private constructor( fun max(): Optional = Optional.ofNullable(max) + fun string(): Optional = Optional.ofNullable(string) + fun isNumber(): Boolean = number != null fun isMax(): Boolean = max != null + fun isString(): Boolean = string != null + fun asNumber(): Double = number.getOrThrow("number") fun asMax(): JsonValue = max.getOrThrow("max") + fun asString(): String = string.getOrThrow("string") + fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { number != null -> visitor.visitNumber(number) max != null -> visitor.visitMax(max) + string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } @@ -1542,6 +1567,8 @@ private constructor( } } } + + override fun visitString(string: String) {} } ) validated = true @@ -1570,6 +1597,8 @@ private constructor( override fun visitMax(max: JsonValue) = max.let { if (it == JsonValue.from("max")) 1 else 0 } + override fun visitString(string: String) = 1 + override fun unknown(json: JsonValue?) = 0 } ) @@ -1579,15 +1608,19 @@ private constructor( return true } - return other is Radius && number == other.number && max == other.max + return other is Radius && + number == other.number && + max == other.max && + string == other.string } - override fun hashCode(): Int = Objects.hash(number, max) + override fun hashCode(): Int = Objects.hash(number, max, string) override fun toString(): String = when { number != null -> "Radius{number=$number}" max != null -> "Radius{max=$max}" + string != null -> "Radius{string=$string}" _json != null -> "Radius{_unknown=$_json}" else -> throw IllegalStateException("Invalid Radius") } @@ -1597,6 +1630,8 @@ private constructor( @JvmStatic fun ofNumber(number: Double) = Radius(number = number) @JvmStatic fun ofMax() = Radius(max = JsonValue.from("max")) + + @JvmStatic fun ofString(string: String) = Radius(string = string) } /** An interface that defines how to map each variant of [Radius] to a value of type [T]. */ @@ -1606,6 +1641,8 @@ private constructor( fun visitMax(max: JsonValue): T + fun visitString(string: String): T + /** * Maps an unknown variant of [Radius] to a value of type [T]. * @@ -1634,6 +1671,9 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { Radius(number = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Radius(string = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1661,6 +1701,7 @@ private constructor( when { value.number != null -> generator.writeObject(value.number) value.max != null -> generator.writeObject(value.max) + value.string != null -> generator.writeObject(value.string) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Radius") } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt index 578ba09a..da307fcf 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt @@ -54,10 +54,12 @@ private constructor( private val blur: JsonField, private val border: JsonField, private val colorProfile: JsonField, + private val colorReplace: JsonField, private val contrastStretch: JsonField, private val crop: JsonField, private val cropMode: JsonField, private val defaultImage: JsonField, + private val distort: JsonField, private val dpr: JsonField, private val duration: JsonField, private val endOffset: JsonField, @@ -133,6 +135,9 @@ private constructor( @JsonProperty("colorProfile") @ExcludeMissing colorProfile: JsonField = JsonMissing.of(), + @JsonProperty("colorReplace") + @ExcludeMissing + colorReplace: JsonField = JsonMissing.of(), @JsonProperty("contrastStretch") @ExcludeMissing contrastStretch: JsonField = JsonMissing.of(), @@ -141,6 +146,7 @@ private constructor( @JsonProperty("defaultImage") @ExcludeMissing defaultImage: JsonField = JsonMissing.of(), + @JsonProperty("distort") @ExcludeMissing distort: JsonField = JsonMissing.of(), @JsonProperty("dpr") @ExcludeMissing dpr: JsonField = JsonMissing.of(), @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), @JsonProperty("endOffset") @@ -204,10 +210,12 @@ private constructor( blur, border, colorProfile, + colorReplace, contrastStretch, crop, cropMode, defaultImage, + distort, dpr, duration, endOffset, @@ -354,6 +362,11 @@ private constructor( * resizing an image. * - A solid color: e.g., `red`, `F3F3F3`, `AAFF0010`. See * [Solid color background](https://imagekit.io/docs/effects-and-enhancements#solid-color-background). + * - Dominant color: `dominant` extracts the dominant color from the image. See + * [Dominant color background](https://imagekit.io/docs/effects-and-enhancements#dominant-color-background). + * - Gradient: `gradient_dominant` or `gradient_dominant_2` creates a gradient using the + * dominant colors. Optionally specify palette size (2 or 4), e.g., `gradient_dominant_4`. See + * [Gradient background](https://imagekit.io/docs/effects-and-enhancements#gradient-background). * - A blurred background: e.g., `blurred`, `blurred_25_N15`, etc. See * [Blurred background](https://imagekit.io/docs/effects-and-enhancements#blurred-background). * - Expand the image boundaries using generative fill: `genfill`. Not supported inside overlay. @@ -395,6 +408,19 @@ private constructor( */ fun colorProfile(): Optional = colorProfile.getOptional("colorProfile") + /** + * Replaces colors in the image. Supports three formats: + * - `toColor` - Replace dominant color with the specified color. + * - `toColor_tolerance` - Replace dominant color with specified tolerance (0-100). + * - `toColor_tolerance_fromColor` - Replace a specific color with another within tolerance + * range. Colors can be hex codes (e.g., `FF0022`) or names (e.g., `red`, `blue`). See + * [Color replacement](https://imagekit.io/docs/effects-and-enhancements#color-replace---cr). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun colorReplace(): Optional = colorReplace.getOptional("colorReplace") + /** * Automatically enhances the contrast of an image (contrast stretch). See * [Contrast Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). @@ -432,9 +458,25 @@ private constructor( */ fun defaultImage(): Optional = defaultImage.getOptional("defaultImage") + /** + * Distorts the shape of an image. Supports two modes: + * - Perspective distortion: `p-x1_y1_x2_y2_x3_y3_x4_y4` changes the position of the four + * corners starting clockwise from top-left. + * - Arc distortion: `a-degrees` curves the image upwards (positive values) or downwards + * (negative values). See + * [Distort effect](https://imagekit.io/docs/effects-and-enhancements#distort---e-distort). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun distort(): Optional = distort.getOptional("distort") + /** * Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio (DPR) - * calculation. See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). + * calculation. Also accepts arithmetic expressions. + * - Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * - See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -619,8 +661,12 @@ private constructor( fun quality(): Optional = quality.getOptional("quality") /** - * Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular or oval - * shape. See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + * Specifies the corner radius for rounded corners. + * - Single value (positive integer): Applied to all corners (e.g., `20`). + * - `max`: Creates a circular or oval shape. + * - Per-corner array: Provide four underscore-separated values representing top-left, + * top-right, bottom-right, and bottom-left corners respectively (e.g., `10_20_30_40`). See + * [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -895,6 +941,15 @@ private constructor( @ExcludeMissing fun _colorProfile(): JsonField = colorProfile + /** + * Returns the raw JSON value of [colorReplace]. + * + * Unlike [colorReplace], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("colorReplace") + @ExcludeMissing + fun _colorReplace(): JsonField = colorReplace + /** * Returns the raw JSON value of [contrastStretch]. * @@ -927,6 +982,13 @@ private constructor( @ExcludeMissing fun _defaultImage(): JsonField = defaultImage + /** + * Returns the raw JSON value of [distort]. + * + * Unlike [distort], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("distort") @ExcludeMissing fun _distort(): JsonField = distort + /** * Returns the raw JSON value of [dpr]. * @@ -1212,10 +1274,12 @@ private constructor( private var blur: JsonField = JsonMissing.of() private var border: JsonField = JsonMissing.of() private var colorProfile: JsonField = JsonMissing.of() + private var colorReplace: JsonField = JsonMissing.of() private var contrastStretch: JsonField = JsonMissing.of() private var crop: JsonField = JsonMissing.of() private var cropMode: JsonField = JsonMissing.of() private var defaultImage: JsonField = JsonMissing.of() + private var distort: JsonField = JsonMissing.of() private var dpr: JsonField = JsonMissing.of() private var duration: JsonField = JsonMissing.of() private var endOffset: JsonField = JsonMissing.of() @@ -1268,10 +1332,12 @@ private constructor( blur = transformation.blur border = transformation.border colorProfile = transformation.colorProfile + colorReplace = transformation.colorReplace contrastStretch = transformation.contrastStretch crop = transformation.crop cropMode = transformation.cropMode defaultImage = transformation.defaultImage + distort = transformation.distort dpr = transformation.dpr duration = transformation.duration endOffset = transformation.endOffset @@ -1503,6 +1569,12 @@ private constructor( * resizing an image. * - A solid color: e.g., `red`, `F3F3F3`, `AAFF0010`. See * [Solid color background](https://imagekit.io/docs/effects-and-enhancements#solid-color-background). + * - Dominant color: `dominant` extracts the dominant color from the image. See + * [Dominant color background](https://imagekit.io/docs/effects-and-enhancements#dominant-color-background). + * - Gradient: `gradient_dominant` or `gradient_dominant_2` creates a gradient using the + * dominant colors. Optionally specify palette size (2 or 4), e.g., `gradient_dominant_4`. + * See + * [Gradient background](https://imagekit.io/docs/effects-and-enhancements#gradient-background). * - A blurred background: e.g., `blurred`, `blurred_25_N15`, etc. See * [Blurred background](https://imagekit.io/docs/effects-and-enhancements#blurred-background). * - Expand the image boundaries using generative fill: `genfill`. Not supported inside @@ -1570,6 +1642,27 @@ private constructor( this.colorProfile = colorProfile } + /** + * Replaces colors in the image. Supports three formats: + * - `toColor` - Replace dominant color with the specified color. + * - `toColor_tolerance` - Replace dominant color with specified tolerance (0-100). + * - `toColor_tolerance_fromColor` - Replace a specific color with another within tolerance + * range. Colors can be hex codes (e.g., `FF0022`) or names (e.g., `red`, `blue`). See + * [Color replacement](https://imagekit.io/docs/effects-and-enhancements#color-replace---cr). + */ + fun colorReplace(colorReplace: String) = colorReplace(JsonField.of(colorReplace)) + + /** + * Sets [Builder.colorReplace] to an arbitrary JSON value. + * + * You should usually call [Builder.colorReplace] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun colorReplace(colorReplace: JsonField) = apply { + this.colorReplace = colorReplace + } + /** * Automatically enhances the contrast of an image (contrast stretch). See * [Contrast Stretch](https://imagekit.io/docs/effects-and-enhancements#contrast-stretch---e-contrast). @@ -1634,9 +1727,30 @@ private constructor( this.defaultImage = defaultImage } + /** + * Distorts the shape of an image. Supports two modes: + * - Perspective distortion: `p-x1_y1_x2_y2_x3_y3_x4_y4` changes the position of the four + * corners starting clockwise from top-left. + * - Arc distortion: `a-degrees` curves the image upwards (positive values) or downwards + * (negative values). See + * [Distort effect](https://imagekit.io/docs/effects-and-enhancements#distort---e-distort). + */ + fun distort(distort: String) = distort(JsonField.of(distort)) + + /** + * Sets [Builder.distort] to an arbitrary JSON value. + * + * You should usually call [Builder.distort] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun distort(distort: JsonField) = apply { this.distort = distort } + /** * Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio (DPR) - * calculation. See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). + * calculation. Also accepts arithmetic expressions. + * - Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * - See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). */ fun dpr(dpr: Double) = dpr(JsonField.of(dpr)) @@ -2016,8 +2130,12 @@ private constructor( fun quality(quality: JsonField) = apply { this.quality = quality } /** - * Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular or oval - * shape. See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + * Specifies the corner radius for rounded corners. + * - Single value (positive integer): Applied to all corners (e.g., `20`). + * - `max`: Creates a circular or oval shape. + * - Per-corner array: Provide four underscore-separated values representing top-left, + * top-right, bottom-right, and bottom-left corners respectively (e.g., `10_20_30_40`). + * See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). */ fun radius(radius: Radius) = radius(JsonField.of(radius)) @@ -2035,6 +2153,9 @@ private constructor( /** Alias for calling [radius] with `Radius.ofMax()`. */ fun radiusMax() = radius(Radius.ofMax()) + /** Alias for calling [radius] with `Radius.ofString(string)`. */ + fun radius(string: String) = radius(Radius.ofString(string)) + /** * Pass any transformation not directly supported by the SDK. This transformation string is * appended to the URL as provided. @@ -2390,10 +2511,12 @@ private constructor( blur, border, colorProfile, + colorReplace, contrastStretch, crop, cropMode, defaultImage, + distort, dpr, duration, endOffset, @@ -2453,10 +2576,12 @@ private constructor( blur() border() colorProfile() + colorReplace() contrastStretch().ifPresent { it.validate() } crop().ifPresent { it.validate() } cropMode().ifPresent { it.validate() } defaultImage() + distort() dpr() duration().ifPresent { it.validate() } endOffset().ifPresent { it.validate() } @@ -2523,10 +2648,12 @@ private constructor( (if (blur.asKnown().isPresent) 1 else 0) + (if (border.asKnown().isPresent) 1 else 0) + (if (colorProfile.asKnown().isPresent) 1 else 0) + + (if (colorReplace.asKnown().isPresent) 1 else 0) + (contrastStretch.asKnown().getOrNull()?.validity() ?: 0) + (crop.asKnown().getOrNull()?.validity() ?: 0) + (cropMode.asKnown().getOrNull()?.validity() ?: 0) + (if (defaultImage.asKnown().isPresent) 1 else 0) + + (if (distort.asKnown().isPresent) 1 else 0) + (if (dpr.asKnown().isPresent) 1 else 0) + (duration.asKnown().getOrNull()?.validity() ?: 0) + (endOffset.asKnown().getOrNull()?.validity() ?: 0) + @@ -5443,8 +5570,12 @@ private constructor( } /** - * Specifies the corner radius for rounded corners (e.g., 20) or `max` for circular or oval - * shape. See [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). + * Specifies the corner radius for rounded corners. + * - Single value (positive integer): Applied to all corners (e.g., `20`). + * - `max`: Creates a circular or oval shape. + * - Per-corner array: Provide four underscore-separated values representing top-left, + * top-right, bottom-right, and bottom-left corners respectively (e.g., `10_20_30_40`). See + * [Radius](https://imagekit.io/docs/effects-and-enhancements#radius---r). */ @JsonDeserialize(using = Radius.Deserializer::class) @JsonSerialize(using = Radius.Serializer::class) @@ -5452,6 +5583,7 @@ private constructor( private constructor( private val number: Double? = null, private val max: JsonValue? = null, + private val string: String? = null, private val _json: JsonValue? = null, ) { @@ -5459,20 +5591,27 @@ private constructor( fun max(): Optional = Optional.ofNullable(max) + fun string(): Optional = Optional.ofNullable(string) + fun isNumber(): Boolean = number != null fun isMax(): Boolean = max != null + fun isString(): Boolean = string != null + fun asNumber(): Double = number.getOrThrow("number") fun asMax(): JsonValue = max.getOrThrow("max") + fun asString(): String = string.getOrThrow("string") + fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { number != null -> visitor.visitNumber(number) max != null -> visitor.visitMax(max) + string != null -> visitor.visitString(string) else -> visitor.unknown(_json) } @@ -5494,6 +5633,8 @@ private constructor( } } } + + override fun visitString(string: String) {} } ) validated = true @@ -5522,6 +5663,8 @@ private constructor( override fun visitMax(max: JsonValue) = max.let { if (it == JsonValue.from("max")) 1 else 0 } + override fun visitString(string: String) = 1 + override fun unknown(json: JsonValue?) = 0 } ) @@ -5531,15 +5674,19 @@ private constructor( return true } - return other is Radius && number == other.number && max == other.max + return other is Radius && + number == other.number && + max == other.max && + string == other.string } - override fun hashCode(): Int = Objects.hash(number, max) + override fun hashCode(): Int = Objects.hash(number, max, string) override fun toString(): String = when { number != null -> "Radius{number=$number}" max != null -> "Radius{max=$max}" + string != null -> "Radius{string=$string}" _json != null -> "Radius{_unknown=$_json}" else -> throw IllegalStateException("Invalid Radius") } @@ -5549,6 +5696,8 @@ private constructor( @JvmStatic fun ofNumber(number: Double) = Radius(number = number) @JvmStatic fun ofMax() = Radius(max = JsonValue.from("max")) + + @JvmStatic fun ofString(string: String) = Radius(string = string) } /** An interface that defines how to map each variant of [Radius] to a value of type [T]. */ @@ -5558,6 +5707,8 @@ private constructor( fun visitMax(max: JsonValue): T + fun visitString(string: String): T + /** * Maps an unknown variant of [Radius] to a value of type [T]. * @@ -5586,6 +5737,9 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { Radius(number = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Radius(string = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -5613,6 +5767,7 @@ private constructor( when { value.number != null -> generator.writeObject(value.number) value.max != null -> generator.writeObject(value.max) + value.string != null -> generator.writeObject(value.string) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Radius") } @@ -7725,10 +7880,12 @@ private constructor( blur == other.blur && border == other.border && colorProfile == other.colorProfile && + colorReplace == other.colorReplace && contrastStretch == other.contrastStretch && crop == other.crop && cropMode == other.cropMode && defaultImage == other.defaultImage && + distort == other.distort && dpr == other.dpr && duration == other.duration && endOffset == other.endOffset && @@ -7782,10 +7939,12 @@ private constructor( blur, border, colorProfile, + colorReplace, contrastStretch, crop, cropMode, defaultImage, + distort, dpr, duration, endOffset, @@ -7827,5 +7986,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Transformation{aiChangeBackground=$aiChangeBackground, aiDropShadow=$aiDropShadow, aiEdit=$aiEdit, aiRemoveBackground=$aiRemoveBackground, aiRemoveBackgroundExternal=$aiRemoveBackgroundExternal, aiRetouch=$aiRetouch, aiUpscale=$aiUpscale, aiVariation=$aiVariation, aspectRatio=$aspectRatio, audioCodec=$audioCodec, background=$background, blur=$blur, border=$border, colorProfile=$colorProfile, contrastStretch=$contrastStretch, crop=$crop, cropMode=$cropMode, defaultImage=$defaultImage, dpr=$dpr, duration=$duration, endOffset=$endOffset, flip=$flip, focus=$focus, format=$format, gradient=$gradient, grayscale=$grayscale, height=$height, lossless=$lossless, metadata=$metadata, named=$named, opacity=$opacity, original=$original, overlay=$overlay, page=$page, progressive=$progressive, quality=$quality, radius=$radius, raw=$raw, rotation=$rotation, shadow=$shadow, sharpen=$sharpen, startOffset=$startOffset, streamingResolutions=$streamingResolutions, trim=$trim, unsharpMask=$unsharpMask, videoCodec=$videoCodec, width=$width, x=$x, xCenter=$xCenter, y=$y, yCenter=$yCenter, zoom=$zoom, additionalProperties=$additionalProperties}" + "Transformation{aiChangeBackground=$aiChangeBackground, aiDropShadow=$aiDropShadow, aiEdit=$aiEdit, aiRemoveBackground=$aiRemoveBackground, aiRemoveBackgroundExternal=$aiRemoveBackgroundExternal, aiRetouch=$aiRetouch, aiUpscale=$aiUpscale, aiVariation=$aiVariation, aspectRatio=$aspectRatio, audioCodec=$audioCodec, background=$background, blur=$blur, border=$border, colorProfile=$colorProfile, colorReplace=$colorReplace, contrastStretch=$contrastStretch, crop=$crop, cropMode=$cropMode, defaultImage=$defaultImage, distort=$distort, dpr=$dpr, duration=$duration, endOffset=$endOffset, flip=$flip, focus=$focus, format=$format, gradient=$gradient, grayscale=$grayscale, height=$height, lossless=$lossless, metadata=$metadata, named=$named, opacity=$opacity, original=$original, overlay=$overlay, page=$page, progressive=$progressive, quality=$quality, radius=$radius, raw=$raw, rotation=$rotation, shadow=$shadow, sharpen=$sharpen, startOffset=$startOffset, streamingResolutions=$streamingResolutions, trim=$trim, unsharpMask=$unsharpMask, videoCodec=$videoCodec, width=$width, x=$x, xCenter=$xCenter, y=$y, yCenter=$yCenter, zoom=$zoom, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VideoOverlay.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VideoOverlay.kt index 8721b3ae..243162a6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VideoOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VideoOverlay.kt @@ -23,6 +23,7 @@ import kotlin.jvm.optionals.getOrNull class VideoOverlay @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val layerMode: JsonField, private val position: JsonField, private val timing: JsonField, private val input: JsonField, @@ -34,6 +35,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("layerMode") + @ExcludeMissing + layerMode: JsonField = JsonMissing.of(), @JsonProperty("position") @ExcludeMissing position: JsonField = JsonMissing.of(), @@ -44,18 +48,46 @@ private constructor( @JsonProperty("transformation") @ExcludeMissing transformation: JsonField> = JsonMissing.of(), - ) : this(position, timing, input, type, encoding, transformation, mutableMapOf()) + ) : this(layerMode, position, timing, input, type, encoding, transformation, mutableMapOf()) fun toBaseOverlay(): BaseOverlay = - BaseOverlay.builder().position(position).timing(timing).build() + BaseOverlay.builder().layerMode(layerMode).position(position).timing(timing).build() + + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in the + * URL. By default, layers completely cover the base image beneath them. Layer modes change this + * behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is + * always darker than the original images. This is ideal for applying shadows or color tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. The + * red channel controls horizontal displacement, and the green channel controls vertical + * displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image + * transparent, while transparent areas leave the base image unchanged. This mode functions + * like a hole-punch, effectively cutting the shape of the layer out of the underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside the + * opaque area of the layer are preserved. This mode functions like a cookie-cutter, trimming + * the base image to match the specific dimensions and shape of the layer. See + * [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun layerMode(): Optional = layerMode.getOptional("layerMode") /** + * Specifies the overlay's position relative to the parent asset. See + * [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun position(): Optional = position.getOptional("position") /** + * Specifies timing information for the overlay (only applicable if the base asset is a video). + * See [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -86,6 +118,10 @@ private constructor( * automatically. To always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. * To always use plain text (`i-{input}`), set it to `plain`. * + * Regardless of the encoding method: + * - Leading and trailing slashes are removed. + * - Remaining slashes within the path are replaced with `@@` when using plain text. + * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -102,6 +138,15 @@ private constructor( fun transformation(): Optional> = transformation.getOptional("transformation") + /** + * Returns the raw JSON value of [layerMode]. + * + * Unlike [layerMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("layerMode") + @ExcludeMissing + fun _layerMode(): JsonField = layerMode + /** * Returns the raw JSON value of [position]. * @@ -167,6 +212,7 @@ private constructor( /** A builder for [VideoOverlay]. */ class Builder internal constructor() { + private var layerMode: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() private var timing: JsonField = JsonMissing.of() private var input: JsonField? = null @@ -177,6 +223,7 @@ private constructor( @JvmSynthetic internal fun from(videoOverlay: VideoOverlay) = apply { + layerMode = videoOverlay.layerMode position = videoOverlay.position timing = videoOverlay.timing input = videoOverlay.input @@ -186,6 +233,42 @@ private constructor( additionalProperties = videoOverlay.additionalProperties.toMutableMap() } + /** + * Controls how the layer blends with the base image or underlying content. Maps to `lm` in + * the URL. By default, layers completely cover the base image beneath them. Layer modes + * change this behavior: + * - `multiply`: Multiplies the pixel values of the layer with the base image. The result is + * always darker than the original images. This is ideal for applying shadows or color + * tints. + * - `displace`: Uses the layer as a displacement map to distort pixels in the base image. + * The red channel controls horizontal displacement, and the green channel controls + * vertical displacement. Requires `x` or `y` parameter to control displacement magnitude. + * - `cutout`: Acts as an inverse mask where opaque areas of the layer turn the base image + * transparent, while transparent areas leave the base image unchanged. This mode + * functions like a hole-punch, effectively cutting the shape of the layer out of the + * underlying image. + * - `cutter`: Acts as a shape mask where only the parts of the base image that fall inside + * the opaque area of the layer are preserved. This mode functions like a cookie-cutter, + * trimming the base image to match the specific dimensions and shape of the layer. See + * [Layer modes](https://imagekit.io/docs/add-overlays-on-images#layer-modes). + */ + fun layerMode(layerMode: BaseOverlay.LayerMode) = layerMode(JsonField.of(layerMode)) + + /** + * Sets [Builder.layerMode] to an arbitrary JSON value. + * + * You should usually call [Builder.layerMode] with a well-typed [BaseOverlay.LayerMode] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun layerMode(layerMode: JsonField) = apply { + this.layerMode = layerMode + } + + /** + * Specifies the overlay's position relative to the parent asset. See + * [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + */ fun position(position: OverlayPosition) = position(JsonField.of(position)) /** @@ -197,6 +280,11 @@ private constructor( */ fun position(position: JsonField) = apply { this.position = position } + /** + * Specifies timing information for the overlay (only applicable if the base asset is a + * video). See + * [Position of Layer](https://imagekit.io/docs/transformations#position-of-layer). + */ fun timing(timing: OverlayTiming) = timing(JsonField.of(timing)) /** @@ -238,6 +326,10 @@ private constructor( * `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate format * automatically. To always use base64 encoding (`ie-{base64}`), set this parameter to * `base64`. To always use plain text (`i-{input}`), set it to `plain`. + * + * Regardless of the encoding method: + * - Leading and trailing slashes are removed. + * - Remaining slashes within the path are replaced with `@@` when using plain text. */ fun encoding(encoding: Encoding) = encoding(JsonField.of(encoding)) @@ -314,6 +406,7 @@ private constructor( */ fun build(): VideoOverlay = VideoOverlay( + layerMode, position, timing, checkRequired("input", input), @@ -331,6 +424,7 @@ private constructor( return@apply } + layerMode().ifPresent { it.validate() } position().ifPresent { it.validate() } timing().ifPresent { it.validate() } input() @@ -359,7 +453,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (position.asKnown().getOrNull()?.validity() ?: 0) + + (layerMode.asKnown().getOrNull()?.validity() ?: 0) + + (position.asKnown().getOrNull()?.validity() ?: 0) + (timing.asKnown().getOrNull()?.validity() ?: 0) + (if (input.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("video")) 1 else 0 } + @@ -371,6 +466,10 @@ private constructor( * `ie-{base64_encoded_input}`. By default, the SDK determines the appropriate format * automatically. To always use base64 encoding (`ie-{base64}`), set this parameter to `base64`. * To always use plain text (`i-{input}`), set it to `plain`. + * + * Regardless of the encoding method: + * - Leading and trailing slashes are removed. + * - Remaining slashes within the path are replaced with `@@` when using plain text. */ class Encoding @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -511,6 +610,7 @@ private constructor( } return other is VideoOverlay && + layerMode == other.layerMode && position == other.position && timing == other.timing && input == other.input && @@ -521,11 +621,20 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(position, timing, input, type, encoding, transformation, additionalProperties) + Objects.hash( + layerMode, + position, + timing, + input, + type, + encoding, + transformation, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "VideoOverlay{position=$position, timing=$timing, input=$input, type=$type, encoding=$encoding, transformation=$transformation, additionalProperties=$additionalProperties}" + "VideoOverlay{layerMode=$layerMode, position=$position, timing=$timing, input=$input, type=$type, encoding=$encoding, transformation=$transformation, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt index 004e5b27..a611622f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt @@ -24,7 +24,7 @@ import com.imagekit.api.core.http.Headers import com.imagekit.api.core.http.QueryParams import com.imagekit.api.core.toImmutable import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 import java.io.InputStream import java.nio.file.Path import java.util.Collections @@ -148,7 +148,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun extensions(): Optional> = body.extensions() + fun extensions(): Optional> = body.extensions() /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, @@ -335,7 +335,7 @@ private constructor( * * Unlike [extensions], this method doesn't throw if the multipart field has an unexpected type. */ - fun _extensions(): MultipartField> = body._extensions() + fun _extensions(): MultipartField> = body._extensions() /** * Returns the raw multipart value of [folder]. @@ -633,7 +633,7 @@ private constructor( * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ - fun extensions(extensions: List) = apply { + fun extensions(extensions: List) = apply { body.extensions(extensions) } @@ -641,45 +641,82 @@ private constructor( * Sets [Builder.extensions] to an arbitrary multipart value. * * You should usually call [Builder.extensions] with a well-typed - * `List` value instead. This method is primarily for setting + * `List` value instead. This method is primarily for setting * the field to an undocumented or not yet supported value. */ - fun extensions(extensions: MultipartField>) = apply { + fun extensions(extensions: MultipartField>) = apply { body.extensions(extensions) } /** - * Adds a single [UnnamedSchemaWithArrayParent1] to [extensions]. + * Adds a single [UnnamedSchemaWithArrayParent4] to [extensions]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addExtension(extension: UnnamedSchemaWithArrayParent1) = apply { + fun addExtension(extension: UnnamedSchemaWithArrayParent4) = apply { body.addExtension(extension) } /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent1.ofRemoveBg(removeBg)`. + * `UnnamedSchemaWithArrayParent4.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: UnnamedSchemaWithArrayParent1.RemoveBg) = apply { + fun addExtension(removeBg: UnnamedSchemaWithArrayParent4.RemoveBg) = apply { body.addExtension(removeBg) } /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(autoTaggingExtension)`. + * `UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension(autoTaggingExtension)`. */ - fun addExtension(autoTaggingExtension: UnnamedSchemaWithArrayParent1.AutoTaggingExtension) = + fun addExtension(autoTaggingExtension: UnnamedSchemaWithArrayParent4.AutoTaggingExtension) = apply { body.addExtension(autoTaggingExtension) } /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent1.ofAiAutoDescription()`. + * `UnnamedSchemaWithArrayParent4.ofAiAutoDescription()`. */ fun addExtensionAiAutoDescription() = apply { body.addExtensionAiAutoDescription() } + /** + * Alias for calling [addExtension] with `UnnamedSchemaWithArrayParent4.ofAiTasks(aiTasks)`. + */ + fun addExtension(aiTasks: UnnamedSchemaWithArrayParent4.AiTasks) = apply { + body.addExtension(aiTasks) + } + + /** + * Alias for calling [addExtension] with the following: + * ```java + * UnnamedSchemaWithArrayParent4.AiTasks.builder() + * .tasks(tasks) + * .build() + * ``` + */ + fun addAiTasksExtension(tasks: List) = apply { + body.addAiTasksExtension(tasks) + } + + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent4.ofSavedExtension(savedExtension)`. + */ + fun addExtension(savedExtension: UnnamedSchemaWithArrayParent4.SavedExtension) = apply { + body.addExtension(savedExtension) + } + + /** + * Alias for calling [addExtension] with the following: + * ```java + * UnnamedSchemaWithArrayParent4.SavedExtension.builder() + * .id(id) + * .build() + * ``` + */ + fun addSavedExtensionExtension(id: String) = apply { body.addSavedExtensionExtension(id) } + /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist * before, a new folder(s) is created. Using multiple `/` creates a nested folder. @@ -1094,7 +1131,7 @@ private constructor( private val customCoordinates: MultipartField, private val customMetadata: MultipartField, private val description: MultipartField, - private val extensions: MultipartField>, + private val extensions: MultipartField>, private val folder: MultipartField, private val isPrivateFile: MultipartField, private val isPublished: MultipartField, @@ -1199,7 +1236,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun extensions(): Optional> = + fun extensions(): Optional> = extensions.value.getOptional("extensions") /** @@ -1403,7 +1440,7 @@ private constructor( */ @JsonProperty("extensions") @ExcludeMissing - fun _extensions(): MultipartField> = extensions + fun _extensions(): MultipartField> = extensions /** * Returns the raw multipart value of [folder]. @@ -1555,7 +1592,7 @@ private constructor( private var customCoordinates: MultipartField = MultipartField.of(null) private var customMetadata: MultipartField = MultipartField.of(null) private var description: MultipartField = MultipartField.of(null) - private var extensions: MultipartField>? = + private var extensions: MultipartField>? = null private var folder: MultipartField = MultipartField.of(null) private var isPrivateFile: MultipartField = MultipartField.of(null) @@ -1756,27 +1793,27 @@ private constructor( * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ - fun extensions(extensions: List) = + fun extensions(extensions: List) = extensions(MultipartField.of(extensions)) /** * Sets [Builder.extensions] to an arbitrary multipart value. * * You should usually call [Builder.extensions] with a well-typed - * `List` value instead. This method is primarily for + * `List` value instead. This method is primarily for * setting the field to an undocumented or not yet supported value. */ - fun extensions(extensions: MultipartField>) = + fun extensions(extensions: MultipartField>) = apply { this.extensions = extensions.map { it.toMutableList() } } /** - * Adds a single [UnnamedSchemaWithArrayParent1] to [extensions]. + * Adds a single [UnnamedSchemaWithArrayParent4] to [extensions]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addExtension(extension: UnnamedSchemaWithArrayParent1) = apply { + fun addExtension(extension: UnnamedSchemaWithArrayParent4) = apply { extensions = (extensions ?: MultipartField.of(mutableListOf())).also { checkKnown("extensions", it).add(extension) @@ -1785,28 +1822,64 @@ private constructor( /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent1.ofRemoveBg(removeBg)`. + * `UnnamedSchemaWithArrayParent4.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: UnnamedSchemaWithArrayParent1.RemoveBg) = - addExtension(UnnamedSchemaWithArrayParent1.ofRemoveBg(removeBg)) + fun addExtension(removeBg: UnnamedSchemaWithArrayParent4.RemoveBg) = + addExtension(UnnamedSchemaWithArrayParent4.ofRemoveBg(removeBg)) /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(autoTaggingExtension)`. + * `UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension(autoTaggingExtension)`. */ fun addExtension( - autoTaggingExtension: UnnamedSchemaWithArrayParent1.AutoTaggingExtension + autoTaggingExtension: UnnamedSchemaWithArrayParent4.AutoTaggingExtension ) = addExtension( - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(autoTaggingExtension) + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension(autoTaggingExtension) ) /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent1.ofAiAutoDescription()`. + * `UnnamedSchemaWithArrayParent4.ofAiAutoDescription()`. */ fun addExtensionAiAutoDescription() = - addExtension(UnnamedSchemaWithArrayParent1.ofAiAutoDescription()) + addExtension(UnnamedSchemaWithArrayParent4.ofAiAutoDescription()) + + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent4.ofAiTasks(aiTasks)`. + */ + fun addExtension(aiTasks: UnnamedSchemaWithArrayParent4.AiTasks) = + addExtension(UnnamedSchemaWithArrayParent4.ofAiTasks(aiTasks)) + + /** + * Alias for calling [addExtension] with the following: + * ```java + * UnnamedSchemaWithArrayParent4.AiTasks.builder() + * .tasks(tasks) + * .build() + * ``` + */ + fun addAiTasksExtension(tasks: List) = + addExtension(UnnamedSchemaWithArrayParent4.AiTasks.builder().tasks(tasks).build()) + + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent4.ofSavedExtension(savedExtension)`. + */ + fun addExtension(savedExtension: UnnamedSchemaWithArrayParent4.SavedExtension) = + addExtension(UnnamedSchemaWithArrayParent4.ofSavedExtension(savedExtension)) + + /** + * Alias for calling [addExtension] with the following: + * ```java + * UnnamedSchemaWithArrayParent4.SavedExtension.builder() + * .id(id) + * .build() + * ``` + */ + fun addSavedExtensionExtension(id: String) = + addExtension(UnnamedSchemaWithArrayParent4.SavedExtension.builder().id(id).build()) /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist @@ -2312,12 +2385,14 @@ private constructor( override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" } - @JsonSerialize(using = UnnamedSchemaWithArrayParent1.Serializer::class) - class UnnamedSchemaWithArrayParent1 + @JsonSerialize(using = UnnamedSchemaWithArrayParent4.Serializer::class) + class UnnamedSchemaWithArrayParent4 private constructor( private val removeBg: RemoveBg? = null, private val autoTaggingExtension: AutoTaggingExtension? = null, private val aiAutoDescription: JsonValue? = null, + private val aiTasks: AiTasks? = null, + private val savedExtension: SavedExtension? = null, private val _json: JsonValue? = null, ) { @@ -2328,12 +2403,20 @@ private constructor( fun aiAutoDescription(): Optional = Optional.ofNullable(aiAutoDescription) + fun aiTasks(): Optional = Optional.ofNullable(aiTasks) + + fun savedExtension(): Optional = Optional.ofNullable(savedExtension) + fun isRemoveBg(): Boolean = removeBg != null fun isAutoTaggingExtension(): Boolean = autoTaggingExtension != null fun isAiAutoDescription(): Boolean = aiAutoDescription != null + fun isAiTasks(): Boolean = aiTasks != null + + fun isSavedExtension(): Boolean = savedExtension != null + fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") fun asAutoTaggingExtension(): AutoTaggingExtension = @@ -2341,6 +2424,10 @@ private constructor( fun asAiAutoDescription(): JsonValue = aiAutoDescription.getOrThrow("aiAutoDescription") + fun asAiTasks(): AiTasks = aiTasks.getOrThrow("aiTasks") + + fun asSavedExtension(): SavedExtension = savedExtension.getOrThrow("savedExtension") + fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = @@ -2349,12 +2436,14 @@ private constructor( autoTaggingExtension != null -> visitor.visitAutoTaggingExtension(autoTaggingExtension) aiAutoDescription != null -> visitor.visitAiAutoDescription(aiAutoDescription) + aiTasks != null -> visitor.visitAiTasks(aiTasks) + savedExtension != null -> visitor.visitSavedExtension(savedExtension) else -> visitor.unknown(_json) } private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent1 = apply { + fun validate(): UnnamedSchemaWithArrayParent4 = apply { if (validated) { return@apply } @@ -2380,6 +2469,14 @@ private constructor( } } } + + override fun visitAiTasks(aiTasks: AiTasks) { + aiTasks.validate() + } + + override fun visitSavedExtension(savedExtension: SavedExtension) { + savedExtension.validate() + } } ) validated = true @@ -2398,44 +2495,56 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent1 && + return other is UnnamedSchemaWithArrayParent4 && removeBg == other.removeBg && autoTaggingExtension == other.autoTaggingExtension && - aiAutoDescription == other.aiAutoDescription + aiAutoDescription == other.aiAutoDescription && + aiTasks == other.aiTasks && + savedExtension == other.savedExtension } override fun hashCode(): Int = - Objects.hash(removeBg, autoTaggingExtension, aiAutoDescription) + Objects.hash(removeBg, autoTaggingExtension, aiAutoDescription, aiTasks, savedExtension) override fun toString(): String = when { - removeBg != null -> "UnnamedSchemaWithArrayParent1{removeBg=$removeBg}" + removeBg != null -> "UnnamedSchemaWithArrayParent4{removeBg=$removeBg}" autoTaggingExtension != null -> - "UnnamedSchemaWithArrayParent1{autoTaggingExtension=$autoTaggingExtension}" + "UnnamedSchemaWithArrayParent4{autoTaggingExtension=$autoTaggingExtension}" aiAutoDescription != null -> - "UnnamedSchemaWithArrayParent1{aiAutoDescription=$aiAutoDescription}" - _json != null -> "UnnamedSchemaWithArrayParent1{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") + "UnnamedSchemaWithArrayParent4{aiAutoDescription=$aiAutoDescription}" + aiTasks != null -> "UnnamedSchemaWithArrayParent4{aiTasks=$aiTasks}" + savedExtension != null -> + "UnnamedSchemaWithArrayParent4{savedExtension=$savedExtension}" + _json != null -> "UnnamedSchemaWithArrayParent4{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent4") } companion object { @JvmStatic - fun ofRemoveBg(removeBg: RemoveBg) = UnnamedSchemaWithArrayParent1(removeBg = removeBg) + fun ofRemoveBg(removeBg: RemoveBg) = UnnamedSchemaWithArrayParent4(removeBg = removeBg) @JvmStatic fun ofAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension) = - UnnamedSchemaWithArrayParent1(autoTaggingExtension = autoTaggingExtension) + UnnamedSchemaWithArrayParent4(autoTaggingExtension = autoTaggingExtension) @JvmStatic fun ofAiAutoDescription() = - UnnamedSchemaWithArrayParent1( + UnnamedSchemaWithArrayParent4( aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) ) + + @JvmStatic + fun ofAiTasks(aiTasks: AiTasks) = UnnamedSchemaWithArrayParent4(aiTasks = aiTasks) + + @JvmStatic + fun ofSavedExtension(savedExtension: SavedExtension) = + UnnamedSchemaWithArrayParent4(savedExtension = savedExtension) } /** - * An interface that defines how to map each variant of [UnnamedSchemaWithArrayParent1] to a + * An interface that defines how to map each variant of [UnnamedSchemaWithArrayParent4] to a * value of type [T]. */ interface Visitor { @@ -2446,10 +2555,14 @@ private constructor( fun visitAiAutoDescription(aiAutoDescription: JsonValue): T + fun visitAiTasks(aiTasks: AiTasks): T + + fun visitSavedExtension(savedExtension: SavedExtension): T + /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent1] to a value of type [T]. + * Maps an unknown variant of [UnnamedSchemaWithArrayParent4] to a value of type [T]. * - * An instance of [UnnamedSchemaWithArrayParent1] can contain an unknown variant if it + * An instance of [UnnamedSchemaWithArrayParent4] can contain an unknown variant if it * was deserialized from data that doesn't match any known variant. For example, if the * SDK is on an older version than the API, then the API may respond with new variants * that the SDK is unaware of. @@ -2457,15 +2570,15 @@ private constructor( * @throws ImageKitInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown UnnamedSchemaWithArrayParent1: $json") + throw ImageKitInvalidDataException("Unknown UnnamedSchemaWithArrayParent4: $json") } } internal class Serializer : - BaseSerializer(UnnamedSchemaWithArrayParent1::class) { + BaseSerializer(UnnamedSchemaWithArrayParent4::class) { override fun serialize( - value: UnnamedSchemaWithArrayParent1, + value: UnnamedSchemaWithArrayParent4, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -2475,8 +2588,10 @@ private constructor( generator.writeObject(value.autoTaggingExtension) value.aiAutoDescription != null -> generator.writeObject(value.aiAutoDescription) + value.aiTasks != null -> generator.writeObject(value.aiTasks) + value.savedExtension != null -> generator.writeObject(value.savedExtension) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent4") } } } @@ -3281,6 +3396,4890 @@ private constructor( override fun toString() = "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" } + + class AiTasks + private constructor( + private val name: JsonValue, + private val tasks: JsonField>, + private val additionalProperties: MutableMap, + ) { + + /** + * Specifies the AI tasks extension for automated image analysis using AI models. + * + * Expected to always return the following: + * ```java + * JsonValue.from("ai-tasks") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Array of task objects defining AI operations to perform on the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tasks(): List = tasks.getRequired("tasks") + + /** + * Returns the raw JSON value of [tasks]. + * + * Unlike [tasks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tasks") @ExcludeMissing fun _tasks(): JsonField> = tasks + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AiTasks]. + * + * The following fields are required: + * ```java + * .tasks() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AiTasks]. */ + class Builder internal constructor() { + + private var name: JsonValue = JsonValue.from("ai-tasks") + private var tasks: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(aiTasks: AiTasks) = apply { + name = aiTasks.name + tasks = aiTasks.tasks.map { it.toMutableList() } + additionalProperties = aiTasks.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("ai-tasks") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** Array of task objects defining AI operations to perform on the asset. */ + fun tasks(tasks: List) = tasks(JsonField.of(tasks)) + + /** + * Sets [Builder.tasks] to an arbitrary JSON value. + * + * You should usually call [Builder.tasks] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tasks(tasks: JsonField>) = apply { + this.tasks = tasks.map { it.toMutableList() } + } + + /** + * Adds a single [Task] to [tasks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTask(task: Task) = apply { + tasks = + (tasks ?: JsonField.of(mutableListOf())).also { + checkKnown("tasks", it).add(task) + } + } + + /** Alias for calling [addTask] with `Task.ofSelectTags(selectTags)`. */ + fun addTask(selectTags: Task.SelectTags) = addTask(Task.ofSelectTags(selectTags)) + + /** Alias for calling [addTask] with `Task.ofSelectMetadata(selectMetadata)`. */ + fun addTask(selectMetadata: Task.SelectMetadata) = + addTask(Task.ofSelectMetadata(selectMetadata)) + + /** Alias for calling [addTask] with `Task.ofYesNo(yesNo)`. */ + fun addTask(yesNo: Task.YesNo) = addTask(Task.ofYesNo(yesNo)) + + /** + * Alias for calling [addTask] with the following: + * ```java + * Task.YesNo.builder() + * .instruction(instruction) + * .build() + * ``` + */ + fun addYesNoTask(instruction: String) = + addTask(Task.YesNo.builder().instruction(instruction).build()) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AiTasks]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tasks() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AiTasks = + AiTasks( + name, + checkRequired("tasks", tasks).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AiTasks = apply { + if (validated) { + return@apply + } + + _name().let { + if (it != JsonValue.from("ai-tasks")) { + throw ImageKitInvalidDataException("'name' is invalid, received $it") + } + } + tasks().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + @JsonSerialize(using = Task.Serializer::class) + class Task + private constructor( + private val selectTags: SelectTags? = null, + private val selectMetadata: SelectMetadata? = null, + private val yesNo: YesNo? = null, + private val _json: JsonValue? = null, + ) { + + fun selectTags(): Optional = Optional.ofNullable(selectTags) + + fun selectMetadata(): Optional = Optional.ofNullable(selectMetadata) + + fun yesNo(): Optional = Optional.ofNullable(yesNo) + + fun isSelectTags(): Boolean = selectTags != null + + fun isSelectMetadata(): Boolean = selectMetadata != null + + fun isYesNo(): Boolean = yesNo != null + + fun asSelectTags(): SelectTags = selectTags.getOrThrow("selectTags") + + fun asSelectMetadata(): SelectMetadata = selectMetadata.getOrThrow("selectMetadata") + + fun asYesNo(): YesNo = yesNo.getOrThrow("yesNo") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + selectTags != null -> visitor.visitSelectTags(selectTags) + selectMetadata != null -> visitor.visitSelectMetadata(selectMetadata) + yesNo != null -> visitor.visitYesNo(yesNo) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Task = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitSelectTags(selectTags: SelectTags) { + selectTags.validate() + } + + override fun visitSelectMetadata(selectMetadata: SelectMetadata) { + selectMetadata.validate() + } + + override fun visitYesNo(yesNo: YesNo) { + yesNo.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Task && + selectTags == other.selectTags && + selectMetadata == other.selectMetadata && + yesNo == other.yesNo + } + + override fun hashCode(): Int = Objects.hash(selectTags, selectMetadata, yesNo) + + override fun toString(): String = + when { + selectTags != null -> "Task{selectTags=$selectTags}" + selectMetadata != null -> "Task{selectMetadata=$selectMetadata}" + yesNo != null -> "Task{yesNo=$yesNo}" + _json != null -> "Task{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Task") + } + + companion object { + + @JvmStatic + fun ofSelectTags(selectTags: SelectTags) = Task(selectTags = selectTags) + + @JvmStatic + fun ofSelectMetadata(selectMetadata: SelectMetadata) = + Task(selectMetadata = selectMetadata) + + @JvmStatic fun ofYesNo(yesNo: YesNo) = Task(yesNo = yesNo) + } + + /** + * An interface that defines how to map each variant of [Task] to a value of type + * [T]. + */ + interface Visitor { + + fun visitSelectTags(selectTags: SelectTags): T + + fun visitSelectMetadata(selectMetadata: SelectMetadata): T + + fun visitYesNo(yesNo: YesNo): T + + /** + * Maps an unknown variant of [Task] to a value of type [T]. + * + * An instance of [Task] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on + * an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Task: $json") + } + } + + internal class Serializer : BaseSerializer(Task::class) { + + override fun serialize( + value: Task, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.selectTags != null -> generator.writeObject(value.selectTags) + value.selectMetadata != null -> + generator.writeObject(value.selectMetadata) + value.yesNo != null -> generator.writeObject(value.yesNo) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Task") + } + } + } + + class SelectTags + private constructor( + private val instruction: JsonField, + private val type: JsonValue, + private val vocabulary: JsonField>, + private val maxSelections: JsonField, + private val minSelections: JsonField, + private val additionalProperties: MutableMap, + ) { + + /** + * The question or instruction for the AI to analyze the image. + * + * @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 instruction(): String = instruction.getRequired("instruction") + + /** + * Task type that analyzes the image and adds matching tags from a vocabulary. + * + * Expected to always return the following: + * ```java + * JsonValue.from("select_tags") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Array of possible tag values. Combined length of all strings must not exceed + * 500 characters. Cannot contain the `%` character. + * + * @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 vocabulary(): List = vocabulary.getRequired("vocabulary") + + /** + * Maximum number of tags to select from the vocabulary. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun maxSelections(): Optional = + maxSelections.getOptional("max_selections") + + /** + * Minimum number of tags to select from the vocabulary. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun minSelections(): Optional = + minSelections.getOptional("min_selections") + + /** + * Returns the raw JSON value of [instruction]. + * + * Unlike [instruction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("instruction") + @ExcludeMissing + fun _instruction(): JsonField = instruction + + /** + * Returns the raw JSON value of [vocabulary]. + * + * Unlike [vocabulary], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("vocabulary") + @ExcludeMissing + fun _vocabulary(): JsonField> = vocabulary + + /** + * Returns the raw JSON value of [maxSelections]. + * + * Unlike [maxSelections], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("max_selections") + @ExcludeMissing + fun _maxSelections(): JsonField = maxSelections + + /** + * Returns the raw JSON value of [minSelections]. + * + * Unlike [minSelections], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("min_selections") + @ExcludeMissing + fun _minSelections(): JsonField = minSelections + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SelectTags]. + * + * The following fields are required: + * ```java + * .instruction() + * .vocabulary() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SelectTags]. */ + class Builder internal constructor() { + + private var instruction: JsonField? = null + private var type: JsonValue = JsonValue.from("select_tags") + private var vocabulary: JsonField>? = null + private var maxSelections: JsonField = JsonMissing.of() + private var minSelections: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(selectTags: SelectTags) = apply { + instruction = selectTags.instruction + type = selectTags.type + vocabulary = selectTags.vocabulary.map { it.toMutableList() } + maxSelections = selectTags.maxSelections + minSelections = selectTags.minSelections + additionalProperties = selectTags.additionalProperties.toMutableMap() + } + + /** The question or instruction for the AI to analyze the image. */ + fun instruction(instruction: String) = + instruction(JsonField.of(instruction)) + + /** + * Sets [Builder.instruction] to an arbitrary JSON value. + * + * You should usually call [Builder.instruction] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun instruction(instruction: JsonField) = apply { + this.instruction = instruction + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("select_tags") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Array of possible tag values. Combined length of all strings must not + * exceed 500 characters. Cannot contain the `%` character. + */ + fun vocabulary(vocabulary: List) = + vocabulary(JsonField.of(vocabulary)) + + /** + * Sets [Builder.vocabulary] to an arbitrary JSON value. + * + * You should usually call [Builder.vocabulary] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun vocabulary(vocabulary: JsonField>) = apply { + this.vocabulary = vocabulary.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.vocabulary]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addVocabulary(vocabulary: String) = apply { + this.vocabulary = + (this.vocabulary ?: JsonField.of(mutableListOf())).also { + checkKnown("vocabulary", it).add(vocabulary) + } + } + + /** Maximum number of tags to select from the vocabulary. */ + fun maxSelections(maxSelections: Long) = + maxSelections(JsonField.of(maxSelections)) + + /** + * Sets [Builder.maxSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.maxSelections] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun maxSelections(maxSelections: JsonField) = apply { + this.maxSelections = maxSelections + } + + /** Minimum number of tags to select from the vocabulary. */ + fun minSelections(minSelections: Long) = + minSelections(JsonField.of(minSelections)) + + /** + * Sets [Builder.minSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.minSelections] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minSelections(minSelections: JsonField) = apply { + this.minSelections = minSelections + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SelectTags]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .instruction() + * .vocabulary() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SelectTags = + SelectTags( + checkRequired("instruction", instruction), + type, + checkRequired("vocabulary", vocabulary).map { it.toImmutable() }, + maxSelections, + minSelections, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SelectTags = apply { + if (validated) { + return@apply + } + + instruction() + _type().let { + if (it != JsonValue.from("select_tags")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + vocabulary() + maxSelections() + minSelections() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SelectTags && + instruction == other.instruction && + type == other.type && + vocabulary == other.vocabulary && + maxSelections == other.maxSelections && + minSelections == other.minSelections && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + instruction, + type, + vocabulary, + maxSelections, + minSelections, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SelectTags{instruction=$instruction, type=$type, vocabulary=$vocabulary, maxSelections=$maxSelections, minSelections=$minSelections, additionalProperties=$additionalProperties}" + } + + class SelectMetadata + private constructor( + private val field: JsonField, + private val instruction: JsonField, + private val type: JsonValue, + private val maxSelections: JsonField, + private val minSelections: JsonField, + private val vocabulary: JsonField>, + private val additionalProperties: MutableMap, + ) { + + /** + * Name of the custom metadata field to set. The field must exist in 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 field(): String = field.getRequired("field") + + /** + * The question or instruction for the AI to analyze the image. + * + * @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 instruction(): String = instruction.getRequired("instruction") + + /** + * Task type that analyzes the image and sets a custom metadata field value from + * a vocabulary. + * + * Expected to always return the following: + * ```java + * JsonValue.from("select_metadata") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Maximum number of values to select from the vocabulary. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun maxSelections(): Optional = + maxSelections.getOptional("max_selections") + + /** + * Minimum number of values to select from the vocabulary. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun minSelections(): Optional = + minSelections.getOptional("min_selections") + + /** + * Array of possible values matching the custom metadata field type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun vocabulary(): Optional> = + vocabulary.getOptional("vocabulary") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [instruction]. + * + * Unlike [instruction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("instruction") + @ExcludeMissing + fun _instruction(): JsonField = instruction + + /** + * Returns the raw JSON value of [maxSelections]. + * + * Unlike [maxSelections], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("max_selections") + @ExcludeMissing + fun _maxSelections(): JsonField = maxSelections + + /** + * Returns the raw JSON value of [minSelections]. + * + * Unlike [minSelections], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("min_selections") + @ExcludeMissing + fun _minSelections(): JsonField = minSelections + + /** + * Returns the raw JSON value of [vocabulary]. + * + * Unlike [vocabulary], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("vocabulary") + @ExcludeMissing + fun _vocabulary(): JsonField> = vocabulary + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SelectMetadata]. + * + * The following fields are required: + * ```java + * .field() + * .instruction() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SelectMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var instruction: JsonField? = null + private var type: JsonValue = JsonValue.from("select_metadata") + private var maxSelections: JsonField = JsonMissing.of() + private var minSelections: JsonField = JsonMissing.of() + private var vocabulary: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(selectMetadata: SelectMetadata) = apply { + field = selectMetadata.field + instruction = selectMetadata.instruction + type = selectMetadata.type + maxSelections = selectMetadata.maxSelections + minSelections = selectMetadata.minSelections + vocabulary = selectMetadata.vocabulary.map { it.toMutableList() } + additionalProperties = + selectMetadata.additionalProperties.toMutableMap() + } + + /** + * Name of the custom metadata field to set. The field must exist in your + * account. + */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** The question or instruction for the AI to analyze the image. */ + fun instruction(instruction: String) = + instruction(JsonField.of(instruction)) + + /** + * Sets [Builder.instruction] to an arbitrary JSON value. + * + * You should usually call [Builder.instruction] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun instruction(instruction: JsonField) = apply { + this.instruction = instruction + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("select_metadata") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Maximum number of values to select from the vocabulary. */ + fun maxSelections(maxSelections: Long) = + maxSelections(JsonField.of(maxSelections)) + + /** + * Sets [Builder.maxSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.maxSelections] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun maxSelections(maxSelections: JsonField) = apply { + this.maxSelections = maxSelections + } + + /** Minimum number of values to select from the vocabulary. */ + fun minSelections(minSelections: Long) = + minSelections(JsonField.of(minSelections)) + + /** + * Sets [Builder.minSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.minSelections] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minSelections(minSelections: JsonField) = apply { + this.minSelections = minSelections + } + + /** Array of possible values matching the custom metadata field type. */ + fun vocabulary(vocabulary: List) = + vocabulary(JsonField.of(vocabulary)) + + /** + * Sets [Builder.vocabulary] to an arbitrary JSON value. + * + * You should usually call [Builder.vocabulary] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun vocabulary(vocabulary: JsonField>) = apply { + this.vocabulary = vocabulary.map { it.toMutableList() } + } + + /** + * Adds a single [Vocabulary] to [Builder.vocabulary]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addVocabulary(vocabulary: Vocabulary) = apply { + this.vocabulary = + (this.vocabulary ?: JsonField.of(mutableListOf())).also { + checkKnown("vocabulary", it).add(vocabulary) + } + } + + /** Alias for calling [addVocabulary] with `Vocabulary.ofString(string)`. */ + fun addVocabulary(string: String) = + addVocabulary(Vocabulary.ofString(string)) + + /** Alias for calling [addVocabulary] with `Vocabulary.ofNumber(number)`. */ + fun addVocabulary(number: Double) = + addVocabulary(Vocabulary.ofNumber(number)) + + /** Alias for calling [addVocabulary] with `Vocabulary.ofBool(bool)`. */ + fun addVocabulary(bool: Boolean) = addVocabulary(Vocabulary.ofBool(bool)) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SelectMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .field() + * .instruction() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SelectMetadata = + SelectMetadata( + checkRequired("field", field), + checkRequired("instruction", instruction), + type, + maxSelections, + minSelections, + (vocabulary ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SelectMetadata = apply { + if (validated) { + return@apply + } + + field() + instruction() + _type().let { + if (it != JsonValue.from("select_metadata")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + maxSelections() + minSelections() + vocabulary().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + @JsonSerialize(using = Vocabulary.Serializer::class) + class Vocabulary + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Vocabulary = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Vocabulary && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> "Vocabulary{string=$string}" + number != null -> "Vocabulary{number=$number}" + bool != null -> "Vocabulary{bool=$bool}" + _json != null -> "Vocabulary{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Vocabulary") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Vocabulary(string = string) + + @JvmStatic fun ofNumber(number: Double) = Vocabulary(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Vocabulary(bool = bool) + } + + /** + * An interface that defines how to map each variant of [Vocabulary] to a + * value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [Vocabulary] to a value of type [T]. + * + * An instance of [Vocabulary] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Vocabulary: $json") + } + } + + internal class Serializer : BaseSerializer(Vocabulary::class) { + + override fun serialize( + value: Vocabulary, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Vocabulary") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SelectMetadata && + field == other.field && + instruction == other.instruction && + type == other.type && + maxSelections == other.maxSelections && + minSelections == other.minSelections && + vocabulary == other.vocabulary && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + field, + instruction, + type, + maxSelections, + minSelections, + vocabulary, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SelectMetadata{field=$field, instruction=$instruction, type=$type, maxSelections=$maxSelections, minSelections=$minSelections, vocabulary=$vocabulary, additionalProperties=$additionalProperties}" + } + + class YesNo + private constructor( + private val instruction: JsonField, + private val type: JsonValue, + private val onNo: JsonField, + private val onUnknown: JsonField, + private val onYes: JsonField, + private val additionalProperties: MutableMap, + ) { + + /** + * The yes/no question for the AI to answer about the image. + * + * @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 instruction(): String = instruction.getRequired("instruction") + + /** + * Task type that asks a yes/no question and executes actions based on the + * answer. + * + * Expected to always return the following: + * ```java + * JsonValue.from("yes_no") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Actions to execute if the AI answers no. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun onNo(): Optional = onNo.getOptional("on_no") + + /** + * Actions to execute if the AI cannot determine the answer. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun onUnknown(): Optional = onUnknown.getOptional("on_unknown") + + /** + * Actions to execute if the AI answers yes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun onYes(): Optional = onYes.getOptional("on_yes") + + /** + * Returns the raw JSON value of [instruction]. + * + * Unlike [instruction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("instruction") + @ExcludeMissing + fun _instruction(): JsonField = instruction + + /** + * Returns the raw JSON value of [onNo]. + * + * Unlike [onNo], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("on_no") @ExcludeMissing fun _onNo(): JsonField = onNo + + /** + * Returns the raw JSON value of [onUnknown]. + * + * Unlike [onUnknown], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("on_unknown") + @ExcludeMissing + fun _onUnknown(): JsonField = onUnknown + + /** + * Returns the raw JSON value of [onYes]. + * + * Unlike [onYes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("on_yes") @ExcludeMissing fun _onYes(): JsonField = onYes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [YesNo]. + * + * The following fields are required: + * ```java + * .instruction() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [YesNo]. */ + class Builder internal constructor() { + + private var instruction: JsonField? = null + private var type: JsonValue = JsonValue.from("yes_no") + private var onNo: JsonField = JsonMissing.of() + private var onUnknown: JsonField = JsonMissing.of() + private var onYes: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(yesNo: YesNo) = apply { + instruction = yesNo.instruction + type = yesNo.type + onNo = yesNo.onNo + onUnknown = yesNo.onUnknown + onYes = yesNo.onYes + additionalProperties = yesNo.additionalProperties.toMutableMap() + } + + /** The yes/no question for the AI to answer about the image. */ + fun instruction(instruction: String) = + instruction(JsonField.of(instruction)) + + /** + * Sets [Builder.instruction] to an arbitrary JSON value. + * + * You should usually call [Builder.instruction] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun instruction(instruction: JsonField) = apply { + this.instruction = instruction + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("yes_no") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Actions to execute if the AI answers no. */ + fun onNo(onNo: OnNo) = onNo(JsonField.of(onNo)) + + /** + * Sets [Builder.onNo] to an arbitrary JSON value. + * + * You should usually call [Builder.onNo] with a well-typed [OnNo] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun onNo(onNo: JsonField) = apply { this.onNo = onNo } + + /** Actions to execute if the AI cannot determine the answer. */ + fun onUnknown(onUnknown: OnUnknown) = onUnknown(JsonField.of(onUnknown)) + + /** + * Sets [Builder.onUnknown] to an arbitrary JSON value. + * + * You should usually call [Builder.onUnknown] with a well-typed [OnUnknown] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun onUnknown(onUnknown: JsonField) = apply { + this.onUnknown = onUnknown + } + + /** Actions to execute if the AI answers yes. */ + fun onYes(onYes: OnYes) = onYes(JsonField.of(onYes)) + + /** + * Sets [Builder.onYes] to an arbitrary JSON value. + * + * You should usually call [Builder.onYes] with a well-typed [OnYes] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun onYes(onYes: JsonField) = apply { this.onYes = onYes } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [YesNo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .instruction() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): YesNo = + YesNo( + checkRequired("instruction", instruction), + type, + onNo, + onUnknown, + onYes, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): YesNo = apply { + if (validated) { + return@apply + } + + instruction() + _type().let { + if (it != JsonValue.from("yes_no")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + onNo().ifPresent { it.validate() } + onUnknown().ifPresent { it.validate() } + onYes().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Actions to execute if the AI answers no. */ + class OnNo + private constructor( + private val addTags: JsonField>, + private val removeTags: JsonField>, + private val setMetadata: JsonField>, + private val unsetMetadata: JsonField>, + private val additionalProperties: MutableMap, + ) { + + /** + * Array of tag strings to add to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun addTags(): Optional> = addTags.getOptional("add_tags") + + /** + * Array of tag strings to remove from the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun removeTags(): Optional> = + removeTags.getOptional("remove_tags") + + /** + * Array of custom metadata field updates. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun setMetadata(): Optional> = + setMetadata.getOptional("set_metadata") + + /** + * Array of custom metadata fields to remove. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun unsetMetadata(): Optional> = + unsetMetadata.getOptional("unset_metadata") + + /** + * Returns the raw JSON value of [addTags]. + * + * Unlike [addTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_tags") + @ExcludeMissing + fun _addTags(): JsonField> = addTags + + /** + * Returns the raw JSON value of [removeTags]. + * + * Unlike [removeTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("remove_tags") + @ExcludeMissing + fun _removeTags(): JsonField> = removeTags + + /** + * Returns the raw JSON value of [setMetadata]. + * + * Unlike [setMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("set_metadata") + @ExcludeMissing + fun _setMetadata(): JsonField> = setMetadata + + /** + * Returns the raw JSON value of [unsetMetadata]. + * + * Unlike [unsetMetadata], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unset_metadata") + @ExcludeMissing + fun _unsetMetadata(): JsonField> = unsetMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [OnNo]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OnNo]. */ + class Builder internal constructor() { + + private var addTags: JsonField>? = null + private var removeTags: JsonField>? = null + private var setMetadata: JsonField>? = null + private var unsetMetadata: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(onNo: OnNo) = apply { + addTags = onNo.addTags.map { it.toMutableList() } + removeTags = onNo.removeTags.map { it.toMutableList() } + setMetadata = onNo.setMetadata.map { it.toMutableList() } + unsetMetadata = onNo.unsetMetadata.map { it.toMutableList() } + additionalProperties = onNo.additionalProperties.toMutableMap() + } + + /** Array of tag strings to add to the asset. */ + fun addTags(addTags: List) = addTags(JsonField.of(addTags)) + + /** + * Sets [Builder.addTags] to an arbitrary JSON value. + * + * You should usually call [Builder.addTags] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun addTags(addTags: JsonField>) = apply { + this.addTags = addTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [addTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAddTag(addTag: String) = apply { + addTags = + (addTags ?: JsonField.of(mutableListOf())).also { + checkKnown("addTags", it).add(addTag) + } + } + + /** Array of tag strings to remove from the asset. */ + fun removeTags(removeTags: List) = + removeTags(JsonField.of(removeTags)) + + /** + * Sets [Builder.removeTags] to an arbitrary JSON value. + * + * You should usually call [Builder.removeTags] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun removeTags(removeTags: JsonField>) = apply { + this.removeTags = removeTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [removeTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addRemoveTag(removeTag: String) = apply { + removeTags = + (removeTags ?: JsonField.of(mutableListOf())).also { + checkKnown("removeTags", it).add(removeTag) + } + } + + /** Array of custom metadata field updates. */ + fun setMetadata(setMetadata: List) = + setMetadata(JsonField.of(setMetadata)) + + /** + * Sets [Builder.setMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.setMetadata] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun setMetadata(setMetadata: JsonField>) = apply { + this.setMetadata = setMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [SetMetadata] to [Builder.setMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addSetMetadata(setMetadata: SetMetadata) = apply { + this.setMetadata = + (this.setMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("setMetadata", it).add(setMetadata) + } + } + + /** Array of custom metadata fields to remove. */ + fun unsetMetadata(unsetMetadata: List) = + unsetMetadata(JsonField.of(unsetMetadata)) + + /** + * Sets [Builder.unsetMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.unsetMetadata] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun unsetMetadata(unsetMetadata: JsonField>) = + apply { + this.unsetMetadata = unsetMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { + this.unsetMetadata = + (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("unsetMetadata", it).add(unsetMetadata) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OnNo]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): OnNo = + OnNo( + (addTags ?: JsonMissing.of()).map { it.toImmutable() }, + (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, + (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + (unsetMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OnNo = apply { + if (validated) { + return@apply + } + + addTags() + removeTags() + setMetadata().ifPresent { it.forEach { it.validate() } } + unsetMetadata().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + class SetMetadata + private constructor( + private val field: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + /** + * Name of the custom metadata field to set. + * + * @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 field(): String = field.getRequired("field") + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + * + * @throws ImageKitInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun value(): Value = value.getRequired("value") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(setMetadata: SetMetadata) = apply { + field = setMetadata.field + value = setMetadata.value + additionalProperties = + setMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to set. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + */ + fun value(value: Value) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] + * value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ + fun valueOfMixed(mixed: List) = + value(Value.ofMixed(mixed)) + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SetMetadata = + SetMetadata( + checkRequired("field", field), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SetMetadata = apply { + if (validated) { + return@apply + } + + field() + value().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + */ + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val mixed: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun mixed(): Optional> = + Optional.ofNullable(mixed) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isMixed(): Boolean = mixed != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asMixed(): List = + mixed.getOrThrow("mixed") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + mixed != null -> visitor.visitMixed(mixed) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitMixed( + mixed: List + ) { + mixed.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + string == other.string && + number == other.number && + bool == other.bool && + mixed == other.mixed + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool, mixed) + + override fun toString(): String = + when { + string != null -> "Value{string=$string}" + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + mixed != null -> "Value{mixed=$mixed}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic + fun ofMixed(mixed: List) = + Value(mixed = mixed.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Value] to a + * value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitMixed(mixed: List): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it + * was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than + * the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Value: $json") + } + } + + internal class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.mixed != null -> + generator.writeObject(value.mixed) + value._json != null -> + generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + + @JsonSerialize( + using = UnnamedSchemaWithArrayParent5.Serializer::class + ) + class UnnamedSchemaWithArrayParent5 + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent5 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent5 && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> + "UnnamedSchemaWithArrayParent5{string=$string}" + number != null -> + "UnnamedSchemaWithArrayParent5{number=$number}" + bool != null -> + "UnnamedSchemaWithArrayParent5{bool=$bool}" + _json != null -> + "UnnamedSchemaWithArrayParent5{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent5" + ) + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent5(string = string) + + @JvmStatic + fun ofNumber(number: Double) = + UnnamedSchemaWithArrayParent5(number = number) + + @JvmStatic + fun ofBool(bool: Boolean) = + UnnamedSchemaWithArrayParent5(bool = bool) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent5] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of + * [UnnamedSchemaWithArrayParent5] to a value of type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent5] can + * contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the + * API may respond with new variants that the SDK is unaware + * of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent5: $json" + ) + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent5::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent5, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> + generator.writeObject(value.bool) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent5" + ) + } + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SetMetadata && + field == other.field && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" + } + + class UnsetMetadata + private constructor( + private val field: JsonField, + private val additionalProperties: MutableMap, + ) { + + /** + * Name of the custom metadata field to remove. + * + * @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 field(): String = field.getRequired("field") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnsetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnsetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unsetMetadata: UnsetMetadata) = apply { + field = unsetMetadata.field + additionalProperties = + unsetMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to remove. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnsetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnsetMetadata = + UnsetMetadata( + checkRequired("field", field), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnsetMetadata = apply { + if (validated) { + return@apply + } + + field() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnsetMetadata && + field == other.field && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OnNo && + addTags == other.addTags && + removeTags == other.removeTags && + setMetadata == other.setMetadata && + unsetMetadata == other.unsetMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addTags, + removeTags, + setMetadata, + unsetMetadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OnNo{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" + } + + /** Actions to execute if the AI cannot determine the answer. */ + class OnUnknown + private constructor( + private val addTags: JsonField>, + private val removeTags: JsonField>, + private val setMetadata: JsonField>, + private val unsetMetadata: JsonField>, + private val additionalProperties: MutableMap, + ) { + + /** + * Array of tag strings to add to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun addTags(): Optional> = addTags.getOptional("add_tags") + + /** + * Array of tag strings to remove from the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun removeTags(): Optional> = + removeTags.getOptional("remove_tags") + + /** + * Array of custom metadata field updates. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun setMetadata(): Optional> = + setMetadata.getOptional("set_metadata") + + /** + * Array of custom metadata fields to remove. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun unsetMetadata(): Optional> = + unsetMetadata.getOptional("unset_metadata") + + /** + * Returns the raw JSON value of [addTags]. + * + * Unlike [addTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_tags") + @ExcludeMissing + fun _addTags(): JsonField> = addTags + + /** + * Returns the raw JSON value of [removeTags]. + * + * Unlike [removeTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("remove_tags") + @ExcludeMissing + fun _removeTags(): JsonField> = removeTags + + /** + * Returns the raw JSON value of [setMetadata]. + * + * Unlike [setMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("set_metadata") + @ExcludeMissing + fun _setMetadata(): JsonField> = setMetadata + + /** + * Returns the raw JSON value of [unsetMetadata]. + * + * Unlike [unsetMetadata], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unset_metadata") + @ExcludeMissing + fun _unsetMetadata(): JsonField> = unsetMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [OnUnknown]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OnUnknown]. */ + class Builder internal constructor() { + + private var addTags: JsonField>? = null + private var removeTags: JsonField>? = null + private var setMetadata: JsonField>? = null + private var unsetMetadata: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(onUnknown: OnUnknown) = apply { + addTags = onUnknown.addTags.map { it.toMutableList() } + removeTags = onUnknown.removeTags.map { it.toMutableList() } + setMetadata = onUnknown.setMetadata.map { it.toMutableList() } + unsetMetadata = onUnknown.unsetMetadata.map { it.toMutableList() } + additionalProperties = onUnknown.additionalProperties.toMutableMap() + } + + /** Array of tag strings to add to the asset. */ + fun addTags(addTags: List) = addTags(JsonField.of(addTags)) + + /** + * Sets [Builder.addTags] to an arbitrary JSON value. + * + * You should usually call [Builder.addTags] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun addTags(addTags: JsonField>) = apply { + this.addTags = addTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [addTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAddTag(addTag: String) = apply { + addTags = + (addTags ?: JsonField.of(mutableListOf())).also { + checkKnown("addTags", it).add(addTag) + } + } + + /** Array of tag strings to remove from the asset. */ + fun removeTags(removeTags: List) = + removeTags(JsonField.of(removeTags)) + + /** + * Sets [Builder.removeTags] to an arbitrary JSON value. + * + * You should usually call [Builder.removeTags] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun removeTags(removeTags: JsonField>) = apply { + this.removeTags = removeTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [removeTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addRemoveTag(removeTag: String) = apply { + removeTags = + (removeTags ?: JsonField.of(mutableListOf())).also { + checkKnown("removeTags", it).add(removeTag) + } + } + + /** Array of custom metadata field updates. */ + fun setMetadata(setMetadata: List) = + setMetadata(JsonField.of(setMetadata)) + + /** + * Sets [Builder.setMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.setMetadata] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun setMetadata(setMetadata: JsonField>) = apply { + this.setMetadata = setMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [SetMetadata] to [Builder.setMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addSetMetadata(setMetadata: SetMetadata) = apply { + this.setMetadata = + (this.setMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("setMetadata", it).add(setMetadata) + } + } + + /** Array of custom metadata fields to remove. */ + fun unsetMetadata(unsetMetadata: List) = + unsetMetadata(JsonField.of(unsetMetadata)) + + /** + * Sets [Builder.unsetMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.unsetMetadata] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun unsetMetadata(unsetMetadata: JsonField>) = + apply { + this.unsetMetadata = unsetMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { + this.unsetMetadata = + (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("unsetMetadata", it).add(unsetMetadata) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OnUnknown]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): OnUnknown = + OnUnknown( + (addTags ?: JsonMissing.of()).map { it.toImmutable() }, + (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, + (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + (unsetMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OnUnknown = apply { + if (validated) { + return@apply + } + + addTags() + removeTags() + setMetadata().ifPresent { it.forEach { it.validate() } } + unsetMetadata().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + class SetMetadata + private constructor( + private val field: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + /** + * Name of the custom metadata field to set. + * + * @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 field(): String = field.getRequired("field") + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + * + * @throws ImageKitInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun value(): Value = value.getRequired("value") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(setMetadata: SetMetadata) = apply { + field = setMetadata.field + value = setMetadata.value + additionalProperties = + setMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to set. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + */ + fun value(value: Value) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] + * value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ + fun valueOfMixed(mixed: List) = + value(Value.ofMixed(mixed)) + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SetMetadata = + SetMetadata( + checkRequired("field", field), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SetMetadata = apply { + if (validated) { + return@apply + } + + field() + value().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + */ + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val mixed: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun mixed(): Optional> = + Optional.ofNullable(mixed) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isMixed(): Boolean = mixed != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asMixed(): List = + mixed.getOrThrow("mixed") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + mixed != null -> visitor.visitMixed(mixed) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitMixed( + mixed: List + ) { + mixed.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + string == other.string && + number == other.number && + bool == other.bool && + mixed == other.mixed + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool, mixed) + + override fun toString(): String = + when { + string != null -> "Value{string=$string}" + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + mixed != null -> "Value{mixed=$mixed}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic + fun ofMixed(mixed: List) = + Value(mixed = mixed.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Value] to a + * value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitMixed(mixed: List): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it + * was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than + * the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Value: $json") + } + } + + internal class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.mixed != null -> + generator.writeObject(value.mixed) + value._json != null -> + generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + + @JsonSerialize( + using = UnnamedSchemaWithArrayParent6.Serializer::class + ) + class UnnamedSchemaWithArrayParent6 + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent6 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent6 && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> + "UnnamedSchemaWithArrayParent6{string=$string}" + number != null -> + "UnnamedSchemaWithArrayParent6{number=$number}" + bool != null -> + "UnnamedSchemaWithArrayParent6{bool=$bool}" + _json != null -> + "UnnamedSchemaWithArrayParent6{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent6" + ) + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent6(string = string) + + @JvmStatic + fun ofNumber(number: Double) = + UnnamedSchemaWithArrayParent6(number = number) + + @JvmStatic + fun ofBool(bool: Boolean) = + UnnamedSchemaWithArrayParent6(bool = bool) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent6] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of + * [UnnamedSchemaWithArrayParent6] to a value of type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent6] can + * contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the + * API may respond with new variants that the SDK is unaware + * of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent6: $json" + ) + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent6::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent6, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> + generator.writeObject(value.bool) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent6" + ) + } + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SetMetadata && + field == other.field && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" + } + + class UnsetMetadata + private constructor( + private val field: JsonField, + private val additionalProperties: MutableMap, + ) { + + /** + * Name of the custom metadata field to remove. + * + * @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 field(): String = field.getRequired("field") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnsetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnsetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unsetMetadata: UnsetMetadata) = apply { + field = unsetMetadata.field + additionalProperties = + unsetMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to remove. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnsetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnsetMetadata = + UnsetMetadata( + checkRequired("field", field), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnsetMetadata = apply { + if (validated) { + return@apply + } + + field() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnsetMetadata && + field == other.field && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OnUnknown && + addTags == other.addTags && + removeTags == other.removeTags && + setMetadata == other.setMetadata && + unsetMetadata == other.unsetMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addTags, + removeTags, + setMetadata, + unsetMetadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OnUnknown{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" + } + + /** Actions to execute if the AI answers yes. */ + class OnYes + private constructor( + private val addTags: JsonField>, + private val removeTags: JsonField>, + private val setMetadata: JsonField>, + private val unsetMetadata: JsonField>, + private val additionalProperties: MutableMap, + ) { + + /** + * Array of tag strings to add to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun addTags(): Optional> = addTags.getOptional("add_tags") + + /** + * Array of tag strings to remove from the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun removeTags(): Optional> = + removeTags.getOptional("remove_tags") + + /** + * Array of custom metadata field updates. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun setMetadata(): Optional> = + setMetadata.getOptional("set_metadata") + + /** + * Array of custom metadata fields to remove. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun unsetMetadata(): Optional> = + unsetMetadata.getOptional("unset_metadata") + + /** + * Returns the raw JSON value of [addTags]. + * + * Unlike [addTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_tags") + @ExcludeMissing + fun _addTags(): JsonField> = addTags + + /** + * Returns the raw JSON value of [removeTags]. + * + * Unlike [removeTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("remove_tags") + @ExcludeMissing + fun _removeTags(): JsonField> = removeTags + + /** + * Returns the raw JSON value of [setMetadata]. + * + * Unlike [setMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("set_metadata") + @ExcludeMissing + fun _setMetadata(): JsonField> = setMetadata + + /** + * Returns the raw JSON value of [unsetMetadata]. + * + * Unlike [unsetMetadata], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unset_metadata") + @ExcludeMissing + fun _unsetMetadata(): JsonField> = unsetMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OnYes]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OnYes]. */ + class Builder internal constructor() { + + private var addTags: JsonField>? = null + private var removeTags: JsonField>? = null + private var setMetadata: JsonField>? = null + private var unsetMetadata: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(onYes: OnYes) = apply { + addTags = onYes.addTags.map { it.toMutableList() } + removeTags = onYes.removeTags.map { it.toMutableList() } + setMetadata = onYes.setMetadata.map { it.toMutableList() } + unsetMetadata = onYes.unsetMetadata.map { it.toMutableList() } + additionalProperties = onYes.additionalProperties.toMutableMap() + } + + /** Array of tag strings to add to the asset. */ + fun addTags(addTags: List) = addTags(JsonField.of(addTags)) + + /** + * Sets [Builder.addTags] to an arbitrary JSON value. + * + * You should usually call [Builder.addTags] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun addTags(addTags: JsonField>) = apply { + this.addTags = addTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [addTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAddTag(addTag: String) = apply { + addTags = + (addTags ?: JsonField.of(mutableListOf())).also { + checkKnown("addTags", it).add(addTag) + } + } + + /** Array of tag strings to remove from the asset. */ + fun removeTags(removeTags: List) = + removeTags(JsonField.of(removeTags)) + + /** + * Sets [Builder.removeTags] to an arbitrary JSON value. + * + * You should usually call [Builder.removeTags] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun removeTags(removeTags: JsonField>) = apply { + this.removeTags = removeTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [removeTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addRemoveTag(removeTag: String) = apply { + removeTags = + (removeTags ?: JsonField.of(mutableListOf())).also { + checkKnown("removeTags", it).add(removeTag) + } + } + + /** Array of custom metadata field updates. */ + fun setMetadata(setMetadata: List) = + setMetadata(JsonField.of(setMetadata)) + + /** + * Sets [Builder.setMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.setMetadata] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun setMetadata(setMetadata: JsonField>) = apply { + this.setMetadata = setMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [SetMetadata] to [Builder.setMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addSetMetadata(setMetadata: SetMetadata) = apply { + this.setMetadata = + (this.setMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("setMetadata", it).add(setMetadata) + } + } + + /** Array of custom metadata fields to remove. */ + fun unsetMetadata(unsetMetadata: List) = + unsetMetadata(JsonField.of(unsetMetadata)) + + /** + * Sets [Builder.unsetMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.unsetMetadata] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun unsetMetadata(unsetMetadata: JsonField>) = + apply { + this.unsetMetadata = unsetMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { + this.unsetMetadata = + (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("unsetMetadata", it).add(unsetMetadata) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OnYes]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): OnYes = + OnYes( + (addTags ?: JsonMissing.of()).map { it.toImmutable() }, + (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, + (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + (unsetMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OnYes = apply { + if (validated) { + return@apply + } + + addTags() + removeTags() + setMetadata().ifPresent { it.forEach { it.validate() } } + unsetMetadata().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + class SetMetadata + private constructor( + private val field: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + /** + * Name of the custom metadata field to set. + * + * @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 field(): String = field.getRequired("field") + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + * + * @throws ImageKitInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun value(): Value = value.getRequired("value") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(setMetadata: SetMetadata) = apply { + field = setMetadata.field + value = setMetadata.value + additionalProperties = + setMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to set. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + */ + fun value(value: Value) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] + * value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ + fun valueOfMixed(mixed: List) = + value(Value.ofMixed(mixed)) + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SetMetadata = + SetMetadata( + checkRequired("field", field), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SetMetadata = apply { + if (validated) { + return@apply + } + + field() + value().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + */ + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val mixed: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun mixed(): Optional> = + Optional.ofNullable(mixed) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isMixed(): Boolean = mixed != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asMixed(): List = + mixed.getOrThrow("mixed") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + mixed != null -> visitor.visitMixed(mixed) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitMixed( + mixed: List + ) { + mixed.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + string == other.string && + number == other.number && + bool == other.bool && + mixed == other.mixed + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool, mixed) + + override fun toString(): String = + when { + string != null -> "Value{string=$string}" + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + mixed != null -> "Value{mixed=$mixed}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic + fun ofMixed(mixed: List) = + Value(mixed = mixed.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Value] to a + * value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitMixed(mixed: List): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it + * was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than + * the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Value: $json") + } + } + + internal class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.mixed != null -> + generator.writeObject(value.mixed) + value._json != null -> + generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + + @JsonSerialize( + using = UnnamedSchemaWithArrayParent7.Serializer::class + ) + class UnnamedSchemaWithArrayParent7 + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent7 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent7 && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> + "UnnamedSchemaWithArrayParent7{string=$string}" + number != null -> + "UnnamedSchemaWithArrayParent7{number=$number}" + bool != null -> + "UnnamedSchemaWithArrayParent7{bool=$bool}" + _json != null -> + "UnnamedSchemaWithArrayParent7{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent7" + ) + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent7(string = string) + + @JvmStatic + fun ofNumber(number: Double) = + UnnamedSchemaWithArrayParent7(number = number) + + @JvmStatic + fun ofBool(bool: Boolean) = + UnnamedSchemaWithArrayParent7(bool = bool) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent7] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of + * [UnnamedSchemaWithArrayParent7] to a value of type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent7] can + * contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the + * API may respond with new variants that the SDK is unaware + * of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent7: $json" + ) + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent7::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent7, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> + generator.writeObject(value.bool) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent7" + ) + } + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SetMetadata && + field == other.field && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" + } + + class UnsetMetadata + private constructor( + private val field: JsonField, + private val additionalProperties: MutableMap, + ) { + + /** + * Name of the custom metadata field to remove. + * + * @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 field(): String = field.getRequired("field") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnsetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnsetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unsetMetadata: UnsetMetadata) = apply { + field = unsetMetadata.field + additionalProperties = + unsetMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to remove. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnsetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnsetMetadata = + UnsetMetadata( + checkRequired("field", field), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnsetMetadata = apply { + if (validated) { + return@apply + } + + field() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnsetMetadata && + field == other.field && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OnYes && + addTags == other.addTags && + removeTags == other.removeTags && + setMetadata == other.setMetadata && + unsetMetadata == other.unsetMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addTags, + removeTags, + setMetadata, + unsetMetadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OnYes{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is YesNo && + instruction == other.instruction && + type == other.type && + onNo == other.onNo && + onUnknown == other.onUnknown && + onYes == other.onYes && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + instruction, + type, + onNo, + onUnknown, + onYes, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "YesNo{instruction=$instruction, type=$type, onNo=$onNo, onUnknown=$onUnknown, onYes=$onYes, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiTasks && + name == other.name && + tasks == other.tasks && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, tasks, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AiTasks{name=$name, tasks=$tasks, additionalProperties=$additionalProperties}" + } + + class SavedExtension + private constructor( + private val id: JsonField, + private val name: JsonValue, + private val additionalProperties: MutableMap, + ) { + + /** + * The unique ID of the saved extension to apply. + * + * @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") + + /** + * Indicates this is a reference to a saved extension. + * + * Expected to always return the following: + * ```java + * JsonValue.from("saved-extension") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SavedExtension]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SavedExtension]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var name: JsonValue = JsonValue.from("saved-extension") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(savedExtension: SavedExtension) = apply { + id = savedExtension.id + name = savedExtension.name + additionalProperties = savedExtension.additionalProperties.toMutableMap() + } + + /** The unique ID of the saved extension to apply. */ + 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 } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("saved-extension") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SavedExtension]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SavedExtension = + SavedExtension( + checkRequired("id", id), + name, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SavedExtension = apply { + if (validated) { + return@apply + } + + id() + _name().let { + if (it != JsonValue.from("saved-extension")) { + throw ImageKitInvalidDataException("'name' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SavedExtension && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SavedExtension{id=$id, name=$name, additionalProperties=$additionalProperties}" + } } class ResponseField @JsonCreator private constructor(private val value: JsonField) : diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt index faf75e58..f46cd8ce 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt @@ -562,7 +562,7 @@ private constructor( fun defaultValue(bool: Boolean) = defaultValue(DefaultValue.ofBool(bool)) /** Alias for calling [defaultValue] with `DefaultValue.ofMixed(mixed)`. */ - fun defaultValueOfMixed(mixed: List) = + fun defaultValueOfMixed(mixed: List) = defaultValue(DefaultValue.ofMixed(mixed)) /** Specifies if the this custom metadata field is required or not. */ @@ -941,7 +941,7 @@ private constructor( private val string: String? = null, private val number: Double? = null, private val bool: Boolean? = null, - private val mixed: List? = null, + private val mixed: List? = null, private val _json: JsonValue? = null, ) { @@ -955,7 +955,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun mixed(): Optional> = Optional.ofNullable(mixed) + fun mixed(): Optional> = Optional.ofNullable(mixed) fun isString(): Boolean = string != null @@ -975,7 +975,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun asMixed(): List = mixed.getOrThrow("mixed") + fun asMixed(): List = mixed.getOrThrow("mixed") fun _json(): Optional = Optional.ofNullable(_json) @@ -1003,7 +1003,7 @@ private constructor( override fun visitBool(bool: Boolean) {} - override fun visitMixed(mixed: List) { + override fun visitMixed(mixed: List) { mixed.forEach { it.validate() } } } @@ -1035,7 +1035,7 @@ private constructor( override fun visitBool(bool: Boolean) = 1 - override fun visitMixed(mixed: List) = + override fun visitMixed(mixed: List) = mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 @@ -1079,7 +1079,7 @@ private constructor( * `MultiSelect`. */ @JvmStatic - fun ofMixed(mixed: List) = + fun ofMixed(mixed: List) = DefaultValue(mixed = mixed.toImmutable()) } @@ -1099,7 +1099,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun visitMixed(mixed: List): T + fun visitMixed(mixed: List): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1134,7 +1134,7 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef>(), + jacksonTypeRef>(), ) ?.let { DefaultValue(mixed = it, _json = json) }, ) @@ -1172,9 +1172,9 @@ private constructor( } } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent0.Deserializer::class) - @JsonSerialize(using = UnnamedSchemaWithArrayParent0.Serializer::class) - class UnnamedSchemaWithArrayParent0 + @JsonDeserialize(using = UnnamedSchemaWithArrayParent3.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent3.Serializer::class) + class UnnamedSchemaWithArrayParent3 private constructor( private val string: String? = null, private val number: Double? = null, @@ -1212,7 +1212,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent0 = apply { + fun validate(): UnnamedSchemaWithArrayParent3 = apply { if (validated) { return@apply } @@ -1262,7 +1262,7 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent0 && + return other is UnnamedSchemaWithArrayParent3 && string == other.string && number == other.number && bool == other.bool @@ -1272,28 +1272,28 @@ private constructor( override fun toString(): String = when { - string != null -> "UnnamedSchemaWithArrayParent0{string=$string}" - number != null -> "UnnamedSchemaWithArrayParent0{number=$number}" - bool != null -> "UnnamedSchemaWithArrayParent0{bool=$bool}" - _json != null -> "UnnamedSchemaWithArrayParent0{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent0") + string != null -> "UnnamedSchemaWithArrayParent3{string=$string}" + number != null -> "UnnamedSchemaWithArrayParent3{number=$number}" + bool != null -> "UnnamedSchemaWithArrayParent3{bool=$bool}" + _json != null -> "UnnamedSchemaWithArrayParent3{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") } companion object { @JvmStatic - fun ofString(string: String) = UnnamedSchemaWithArrayParent0(string = string) + fun ofString(string: String) = UnnamedSchemaWithArrayParent3(string = string) @JvmStatic - fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent0(number = number) + fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent3(number = number) @JvmStatic - fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent0(bool = bool) + fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent3(bool = bool) } /** * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent0] to a value of type [T]. + * [UnnamedSchemaWithArrayParent3] to a value of type [T]. */ interface Visitor { @@ -1304,10 +1304,10 @@ private constructor( fun visitBool(bool: Boolean): T /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent0] to a value of type + * Maps an unknown variant of [UnnamedSchemaWithArrayParent3] to a value of type * [T]. * - * An instance of [UnnamedSchemaWithArrayParent0] can contain an unknown variant + * An instance of [UnnamedSchemaWithArrayParent3] can contain an unknown variant * if it was deserialized from data that doesn't match any known variant. For * example, if the SDK is on an older version than the API, then the API may * respond with new variants that the SDK is unaware of. @@ -1316,31 +1316,31 @@ private constructor( */ fun unknown(json: JsonValue?): T { throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent0: $json" + "Unknown UnnamedSchemaWithArrayParent3: $json" ) } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent0::class + BaseDeserializer( + UnnamedSchemaWithArrayParent3::class ) { override fun ObjectCodec.deserialize( node: JsonNode - ): UnnamedSchemaWithArrayParent0 { + ): UnnamedSchemaWithArrayParent3 { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent0(string = it, _json = json) + UnnamedSchemaWithArrayParent3(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent0(number = it, _json = json) + UnnamedSchemaWithArrayParent3(number = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent0(bool = it, _json = json) + UnnamedSchemaWithArrayParent3(bool = it, _json = json) }, ) .filterNotNull() @@ -1350,7 +1350,7 @@ private constructor( // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from // object). - 0 -> UnnamedSchemaWithArrayParent0(_json = json) + 0 -> UnnamedSchemaWithArrayParent3(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use // the first completely valid match, or simply the first match if none @@ -1361,12 +1361,12 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent0::class + BaseSerializer( + UnnamedSchemaWithArrayParent3::class ) { override fun serialize( - value: UnnamedSchemaWithArrayParent0, + value: UnnamedSchemaWithArrayParent3, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -1376,7 +1376,7 @@ private constructor( value.bool != null -> generator.writeObject(value.bool) value._json != null -> generator.writeObject(value._json) else -> - throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent0") + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") } } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt index c3f218b0..097f44c2 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt @@ -856,7 +856,7 @@ private constructor( fun defaultValue(bool: Boolean) = defaultValue(DefaultValue.ofBool(bool)) /** Alias for calling [defaultValue] with `DefaultValue.ofMixed(mixed)`. */ - fun defaultValueOfMixed(mixed: List) = + fun defaultValueOfMixed(mixed: List) = defaultValue(DefaultValue.ofMixed(mixed)) /** @@ -1249,7 +1249,7 @@ private constructor( private val string: String? = null, private val number: Double? = null, private val bool: Boolean? = null, - private val mixed: List? = null, + private val mixed: List? = null, private val _json: JsonValue? = null, ) { @@ -1263,7 +1263,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun mixed(): Optional> = Optional.ofNullable(mixed) + fun mixed(): Optional> = Optional.ofNullable(mixed) fun isString(): Boolean = string != null @@ -1283,7 +1283,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun asMixed(): List = mixed.getOrThrow("mixed") + fun asMixed(): List = mixed.getOrThrow("mixed") fun _json(): Optional = Optional.ofNullable(_json) @@ -1311,7 +1311,7 @@ private constructor( override fun visitBool(bool: Boolean) {} - override fun visitMixed(mixed: List) { + override fun visitMixed(mixed: List) { mixed.forEach { it.validate() } } } @@ -1343,7 +1343,7 @@ private constructor( override fun visitBool(bool: Boolean) = 1 - override fun visitMixed(mixed: List) = + override fun visitMixed(mixed: List) = mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 @@ -1387,7 +1387,7 @@ private constructor( * `MultiSelect`. */ @JvmStatic - fun ofMixed(mixed: List) = + fun ofMixed(mixed: List) = DefaultValue(mixed = mixed.toImmutable()) } @@ -1407,7 +1407,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun visitMixed(mixed: List): T + fun visitMixed(mixed: List): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1442,7 +1442,7 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef>(), + jacksonTypeRef>(), ) ?.let { DefaultValue(mixed = it, _json = json) }, ) @@ -1480,9 +1480,9 @@ private constructor( } } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent2.Deserializer::class) - @JsonSerialize(using = UnnamedSchemaWithArrayParent2.Serializer::class) - class UnnamedSchemaWithArrayParent2 + @JsonDeserialize(using = UnnamedSchemaWithArrayParent8.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent8.Serializer::class) + class UnnamedSchemaWithArrayParent8 private constructor( private val string: String? = null, private val number: Double? = null, @@ -1520,7 +1520,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent2 = apply { + fun validate(): UnnamedSchemaWithArrayParent8 = apply { if (validated) { return@apply } @@ -1570,7 +1570,7 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent2 && + return other is UnnamedSchemaWithArrayParent8 && string == other.string && number == other.number && bool == other.bool @@ -1580,28 +1580,28 @@ private constructor( override fun toString(): String = when { - string != null -> "UnnamedSchemaWithArrayParent2{string=$string}" - number != null -> "UnnamedSchemaWithArrayParent2{number=$number}" - bool != null -> "UnnamedSchemaWithArrayParent2{bool=$bool}" - _json != null -> "UnnamedSchemaWithArrayParent2{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent2") + string != null -> "UnnamedSchemaWithArrayParent8{string=$string}" + number != null -> "UnnamedSchemaWithArrayParent8{number=$number}" + bool != null -> "UnnamedSchemaWithArrayParent8{bool=$bool}" + _json != null -> "UnnamedSchemaWithArrayParent8{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent8") } companion object { @JvmStatic - fun ofString(string: String) = UnnamedSchemaWithArrayParent2(string = string) + fun ofString(string: String) = UnnamedSchemaWithArrayParent8(string = string) @JvmStatic - fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent2(number = number) + fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent8(number = number) @JvmStatic - fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent2(bool = bool) + fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent8(bool = bool) } /** * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent2] to a value of type [T]. + * [UnnamedSchemaWithArrayParent8] to a value of type [T]. */ interface Visitor { @@ -1612,10 +1612,10 @@ private constructor( fun visitBool(bool: Boolean): T /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent2] to a value of type + * Maps an unknown variant of [UnnamedSchemaWithArrayParent8] to a value of type * [T]. * - * An instance of [UnnamedSchemaWithArrayParent2] can contain an unknown variant + * An instance of [UnnamedSchemaWithArrayParent8] can contain an unknown variant * if it was deserialized from data that doesn't match any known variant. For * example, if the SDK is on an older version than the API, then the API may * respond with new variants that the SDK is unaware of. @@ -1624,31 +1624,31 @@ private constructor( */ fun unknown(json: JsonValue?): T { throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent2: $json" + "Unknown UnnamedSchemaWithArrayParent8: $json" ) } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent2::class + BaseDeserializer( + UnnamedSchemaWithArrayParent8::class ) { override fun ObjectCodec.deserialize( node: JsonNode - ): UnnamedSchemaWithArrayParent2 { + ): UnnamedSchemaWithArrayParent8 { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent2(string = it, _json = json) + UnnamedSchemaWithArrayParent8(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent2(number = it, _json = json) + UnnamedSchemaWithArrayParent8(number = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent2(bool = it, _json = json) + UnnamedSchemaWithArrayParent8(bool = it, _json = json) }, ) .filterNotNull() @@ -1658,7 +1658,7 @@ private constructor( // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from // object). - 0 -> UnnamedSchemaWithArrayParent2(_json = json) + 0 -> UnnamedSchemaWithArrayParent8(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use // the first completely valid match, or simply the first match if none @@ -1669,12 +1669,12 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent2::class + BaseSerializer( + UnnamedSchemaWithArrayParent8::class ) { override fun serialize( - value: UnnamedSchemaWithArrayParent2, + value: UnnamedSchemaWithArrayParent8, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -1684,7 +1684,7 @@ private constructor( value.bool != null -> generator.writeObject(value.bool) value._json != null -> generator.writeObject(value._json) else -> - throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent2") + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent8") } } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt index a76a1adf..f90753d0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt @@ -746,7 +746,7 @@ private constructor( fun defaultValue(bool: Boolean) = defaultValue(DefaultValue.ofBool(bool)) /** Alias for calling [defaultValue] with `DefaultValue.ofMixed(mixed)`. */ - fun defaultValueOfMixed(mixed: List) = + fun defaultValueOfMixed(mixed: List) = defaultValue(DefaultValue.ofMixed(mixed)) /** @@ -971,7 +971,7 @@ private constructor( private val string: String? = null, private val number: Double? = null, private val bool: Boolean? = null, - private val mixed: List? = null, + private val mixed: List? = null, private val _json: JsonValue? = null, ) { @@ -985,7 +985,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun mixed(): Optional> = Optional.ofNullable(mixed) + fun mixed(): Optional> = Optional.ofNullable(mixed) fun isString(): Boolean = string != null @@ -1005,7 +1005,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun asMixed(): List = mixed.getOrThrow("mixed") + fun asMixed(): List = mixed.getOrThrow("mixed") fun _json(): Optional = Optional.ofNullable(_json) @@ -1033,7 +1033,7 @@ private constructor( override fun visitBool(bool: Boolean) {} - override fun visitMixed(mixed: List) { + override fun visitMixed(mixed: List) { mixed.forEach { it.validate() } } } @@ -1065,7 +1065,7 @@ private constructor( override fun visitBool(bool: Boolean) = 1 - override fun visitMixed(mixed: List) = + override fun visitMixed(mixed: List) = mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 @@ -1109,7 +1109,7 @@ private constructor( * `MultiSelect`. */ @JvmStatic - fun ofMixed(mixed: List) = + fun ofMixed(mixed: List) = DefaultValue(mixed = mixed.toImmutable()) } @@ -1129,7 +1129,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun visitMixed(mixed: List): T + fun visitMixed(mixed: List): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1164,7 +1164,7 @@ private constructor( }, tryDeserialize( node, - jacksonTypeRef>(), + jacksonTypeRef>(), ) ?.let { DefaultValue(mixed = it, _json = json) }, ) @@ -1202,9 +1202,9 @@ private constructor( } } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent3.Deserializer::class) - @JsonSerialize(using = UnnamedSchemaWithArrayParent3.Serializer::class) - class UnnamedSchemaWithArrayParent3 + @JsonDeserialize(using = UnnamedSchemaWithArrayParent9.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent9.Serializer::class) + class UnnamedSchemaWithArrayParent9 private constructor( private val string: String? = null, private val number: Double? = null, @@ -1242,7 +1242,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent3 = apply { + fun validate(): UnnamedSchemaWithArrayParent9 = apply { if (validated) { return@apply } @@ -1292,7 +1292,7 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent3 && + return other is UnnamedSchemaWithArrayParent9 && string == other.string && number == other.number && bool == other.bool @@ -1302,28 +1302,28 @@ private constructor( override fun toString(): String = when { - string != null -> "UnnamedSchemaWithArrayParent3{string=$string}" - number != null -> "UnnamedSchemaWithArrayParent3{number=$number}" - bool != null -> "UnnamedSchemaWithArrayParent3{bool=$bool}" - _json != null -> "UnnamedSchemaWithArrayParent3{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") + string != null -> "UnnamedSchemaWithArrayParent9{string=$string}" + number != null -> "UnnamedSchemaWithArrayParent9{number=$number}" + bool != null -> "UnnamedSchemaWithArrayParent9{bool=$bool}" + _json != null -> "UnnamedSchemaWithArrayParent9{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent9") } companion object { @JvmStatic - fun ofString(string: String) = UnnamedSchemaWithArrayParent3(string = string) + fun ofString(string: String) = UnnamedSchemaWithArrayParent9(string = string) @JvmStatic - fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent3(number = number) + fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent9(number = number) @JvmStatic - fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent3(bool = bool) + fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent9(bool = bool) } /** * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent3] to a value of type [T]. + * [UnnamedSchemaWithArrayParent9] to a value of type [T]. */ interface Visitor { @@ -1334,10 +1334,10 @@ private constructor( fun visitBool(bool: Boolean): T /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent3] to a value of type + * Maps an unknown variant of [UnnamedSchemaWithArrayParent9] to a value of type * [T]. * - * An instance of [UnnamedSchemaWithArrayParent3] can contain an unknown variant + * An instance of [UnnamedSchemaWithArrayParent9] can contain an unknown variant * if it was deserialized from data that doesn't match any known variant. For * example, if the SDK is on an older version than the API, then the API may * respond with new variants that the SDK is unaware of. @@ -1346,31 +1346,31 @@ private constructor( */ fun unknown(json: JsonValue?): T { throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent3: $json" + "Unknown UnnamedSchemaWithArrayParent9: $json" ) } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent3::class + BaseDeserializer( + UnnamedSchemaWithArrayParent9::class ) { override fun ObjectCodec.deserialize( node: JsonNode - ): UnnamedSchemaWithArrayParent3 { + ): UnnamedSchemaWithArrayParent9 { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent3(string = it, _json = json) + UnnamedSchemaWithArrayParent9(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent3(number = it, _json = json) + UnnamedSchemaWithArrayParent9(number = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent3(bool = it, _json = json) + UnnamedSchemaWithArrayParent9(bool = it, _json = json) }, ) .filterNotNull() @@ -1380,7 +1380,7 @@ private constructor( // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from // object). - 0 -> UnnamedSchemaWithArrayParent3(_json = json) + 0 -> UnnamedSchemaWithArrayParent9(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use // the first completely valid match, or simply the first match if none @@ -1391,12 +1391,12 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent3::class + BaseSerializer( + UnnamedSchemaWithArrayParent9::class ) { override fun serialize( - value: UnnamedSchemaWithArrayParent3, + value: UnnamedSchemaWithArrayParent9, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -1406,7 +1406,7 @@ private constructor( value.bool != null -> generator.writeObject(value.bool) value._json != null -> generator.writeObject(value._json) else -> - throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") + throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent9") } } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt index e5b9c421..9fa357ee 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -24,7 +24,7 @@ import com.imagekit.api.core.http.Headers import com.imagekit.api.core.http.QueryParams import com.imagekit.api.core.toImmutable import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 import java.io.InputStream import java.nio.file.Path import java.util.Collections @@ -161,7 +161,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun extensions(): Optional> = body.extensions() + fun extensions(): Optional> = body.extensions() /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, @@ -382,7 +382,7 @@ private constructor( * * Unlike [extensions], this method doesn't throw if the multipart field has an unexpected type. */ - fun _extensions(): MultipartField> = body._extensions() + fun _extensions(): MultipartField> = body._extensions() /** * Returns the raw multipart value of [folder]. @@ -713,7 +713,7 @@ private constructor( * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ - fun extensions(extensions: List) = apply { + fun extensions(extensions: List) = apply { body.extensions(extensions) } @@ -721,45 +721,82 @@ private constructor( * Sets [Builder.extensions] to an arbitrary multipart value. * * You should usually call [Builder.extensions] with a well-typed - * `List` value instead. This method is primarily for setting + * `List` value instead. This method is primarily for setting * the field to an undocumented or not yet supported value. */ - fun extensions(extensions: MultipartField>) = apply { + fun extensions(extensions: MultipartField>) = apply { body.extensions(extensions) } /** - * Adds a single [UnnamedSchemaWithArrayParent1] to [extensions]. + * Adds a single [UnnamedSchemaWithArrayParent4] to [extensions]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addExtension(extension: UnnamedSchemaWithArrayParent1) = apply { + fun addExtension(extension: UnnamedSchemaWithArrayParent4) = apply { body.addExtension(extension) } /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent1.ofRemoveBg(removeBg)`. + * `UnnamedSchemaWithArrayParent4.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: UnnamedSchemaWithArrayParent1.RemoveBg) = apply { + fun addExtension(removeBg: UnnamedSchemaWithArrayParent4.RemoveBg) = apply { body.addExtension(removeBg) } /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(autoTaggingExtension)`. + * `UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension(autoTaggingExtension)`. */ - fun addExtension(autoTaggingExtension: UnnamedSchemaWithArrayParent1.AutoTaggingExtension) = + fun addExtension(autoTaggingExtension: UnnamedSchemaWithArrayParent4.AutoTaggingExtension) = apply { body.addExtension(autoTaggingExtension) } /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent1.ofAiAutoDescription()`. + * `UnnamedSchemaWithArrayParent4.ofAiAutoDescription()`. */ fun addExtensionAiAutoDescription() = apply { body.addExtensionAiAutoDescription() } + /** + * Alias for calling [addExtension] with `UnnamedSchemaWithArrayParent4.ofAiTasks(aiTasks)`. + */ + fun addExtension(aiTasks: UnnamedSchemaWithArrayParent4.AiTasks) = apply { + body.addExtension(aiTasks) + } + + /** + * Alias for calling [addExtension] with the following: + * ```java + * UnnamedSchemaWithArrayParent4.AiTasks.builder() + * .tasks(tasks) + * .build() + * ``` + */ + fun addAiTasksExtension(tasks: List) = apply { + body.addAiTasksExtension(tasks) + } + + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent4.ofSavedExtension(savedExtension)`. + */ + fun addExtension(savedExtension: UnnamedSchemaWithArrayParent4.SavedExtension) = apply { + body.addExtension(savedExtension) + } + + /** + * Alias for calling [addExtension] with the following: + * ```java + * UnnamedSchemaWithArrayParent4.SavedExtension.builder() + * .id(id) + * .build() + * ``` + */ + fun addSavedExtensionExtension(id: String) = apply { body.addSavedExtensionExtension(id) } + /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist * before, a new folder(s) is created. @@ -1217,7 +1254,7 @@ private constructor( private val customMetadata: MultipartField, private val description: MultipartField, private val expire: MultipartField, - private val extensions: MultipartField>, + private val extensions: MultipartField>, private val folder: MultipartField, private val isPrivateFile: MultipartField, private val isPublished: MultipartField, @@ -1336,7 +1373,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun extensions(): Optional> = + fun extensions(): Optional> = extensions.value.getOptional("extensions") /** @@ -1574,7 +1611,7 @@ private constructor( */ @JsonProperty("extensions") @ExcludeMissing - fun _extensions(): MultipartField> = extensions + fun _extensions(): MultipartField> = extensions /** * Returns the raw multipart value of [folder]. @@ -1747,7 +1784,7 @@ private constructor( private var customMetadata: MultipartField = MultipartField.of(null) private var description: MultipartField = MultipartField.of(null) private var expire: MultipartField = MultipartField.of(null) - private var extensions: MultipartField>? = + private var extensions: MultipartField>? = null private var folder: MultipartField = MultipartField.of(null) private var isPrivateFile: MultipartField = MultipartField.of(null) @@ -1971,27 +2008,27 @@ private constructor( * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ - fun extensions(extensions: List) = + fun extensions(extensions: List) = extensions(MultipartField.of(extensions)) /** * Sets [Builder.extensions] to an arbitrary multipart value. * * You should usually call [Builder.extensions] with a well-typed - * `List` value instead. This method is primarily for + * `List` value instead. This method is primarily for * setting the field to an undocumented or not yet supported value. */ - fun extensions(extensions: MultipartField>) = + fun extensions(extensions: MultipartField>) = apply { this.extensions = extensions.map { it.toMutableList() } } /** - * Adds a single [UnnamedSchemaWithArrayParent1] to [extensions]. + * Adds a single [UnnamedSchemaWithArrayParent4] to [extensions]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addExtension(extension: UnnamedSchemaWithArrayParent1) = apply { + fun addExtension(extension: UnnamedSchemaWithArrayParent4) = apply { extensions = (extensions ?: MultipartField.of(mutableListOf())).also { checkKnown("extensions", it).add(extension) @@ -2000,28 +2037,64 @@ private constructor( /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent1.ofRemoveBg(removeBg)`. + * `UnnamedSchemaWithArrayParent4.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: UnnamedSchemaWithArrayParent1.RemoveBg) = - addExtension(UnnamedSchemaWithArrayParent1.ofRemoveBg(removeBg)) + fun addExtension(removeBg: UnnamedSchemaWithArrayParent4.RemoveBg) = + addExtension(UnnamedSchemaWithArrayParent4.ofRemoveBg(removeBg)) /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(autoTaggingExtension)`. + * `UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension(autoTaggingExtension)`. */ fun addExtension( - autoTaggingExtension: UnnamedSchemaWithArrayParent1.AutoTaggingExtension + autoTaggingExtension: UnnamedSchemaWithArrayParent4.AutoTaggingExtension ) = addExtension( - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(autoTaggingExtension) + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension(autoTaggingExtension) ) /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent1.ofAiAutoDescription()`. + * `UnnamedSchemaWithArrayParent4.ofAiAutoDescription()`. */ fun addExtensionAiAutoDescription() = - addExtension(UnnamedSchemaWithArrayParent1.ofAiAutoDescription()) + addExtension(UnnamedSchemaWithArrayParent4.ofAiAutoDescription()) + + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent4.ofAiTasks(aiTasks)`. + */ + fun addExtension(aiTasks: UnnamedSchemaWithArrayParent4.AiTasks) = + addExtension(UnnamedSchemaWithArrayParent4.ofAiTasks(aiTasks)) + + /** + * Alias for calling [addExtension] with the following: + * ```java + * UnnamedSchemaWithArrayParent4.AiTasks.builder() + * .tasks(tasks) + * .build() + * ``` + */ + fun addAiTasksExtension(tasks: List) = + addExtension(UnnamedSchemaWithArrayParent4.AiTasks.builder().tasks(tasks).build()) + + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent4.ofSavedExtension(savedExtension)`. + */ + fun addExtension(savedExtension: UnnamedSchemaWithArrayParent4.SavedExtension) = + addExtension(UnnamedSchemaWithArrayParent4.ofSavedExtension(savedExtension)) + + /** + * Alias for calling [addExtension] with the following: + * ```java + * UnnamedSchemaWithArrayParent4.SavedExtension.builder() + * .id(id) + * .build() + * ``` + */ + fun addSavedExtensionExtension(id: String) = + addExtension(UnnamedSchemaWithArrayParent4.SavedExtension.builder().id(id).build()) /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist @@ -2578,12 +2651,14 @@ private constructor( override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" } - @JsonSerialize(using = UnnamedSchemaWithArrayParent1.Serializer::class) - class UnnamedSchemaWithArrayParent1 + @JsonSerialize(using = UnnamedSchemaWithArrayParent4.Serializer::class) + class UnnamedSchemaWithArrayParent4 private constructor( private val removeBg: RemoveBg? = null, private val autoTaggingExtension: AutoTaggingExtension? = null, private val aiAutoDescription: JsonValue? = null, + private val aiTasks: AiTasks? = null, + private val savedExtension: SavedExtension? = null, private val _json: JsonValue? = null, ) { @@ -2594,12 +2669,20 @@ private constructor( fun aiAutoDescription(): Optional = Optional.ofNullable(aiAutoDescription) + fun aiTasks(): Optional = Optional.ofNullable(aiTasks) + + fun savedExtension(): Optional = Optional.ofNullable(savedExtension) + fun isRemoveBg(): Boolean = removeBg != null fun isAutoTaggingExtension(): Boolean = autoTaggingExtension != null fun isAiAutoDescription(): Boolean = aiAutoDescription != null + fun isAiTasks(): Boolean = aiTasks != null + + fun isSavedExtension(): Boolean = savedExtension != null + fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") fun asAutoTaggingExtension(): AutoTaggingExtension = @@ -2607,6 +2690,10 @@ private constructor( fun asAiAutoDescription(): JsonValue = aiAutoDescription.getOrThrow("aiAutoDescription") + fun asAiTasks(): AiTasks = aiTasks.getOrThrow("aiTasks") + + fun asSavedExtension(): SavedExtension = savedExtension.getOrThrow("savedExtension") + fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = @@ -2615,12 +2702,14 @@ private constructor( autoTaggingExtension != null -> visitor.visitAutoTaggingExtension(autoTaggingExtension) aiAutoDescription != null -> visitor.visitAiAutoDescription(aiAutoDescription) + aiTasks != null -> visitor.visitAiTasks(aiTasks) + savedExtension != null -> visitor.visitSavedExtension(savedExtension) else -> visitor.unknown(_json) } private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent1 = apply { + fun validate(): UnnamedSchemaWithArrayParent4 = apply { if (validated) { return@apply } @@ -2646,6 +2735,14 @@ private constructor( } } } + + override fun visitAiTasks(aiTasks: AiTasks) { + aiTasks.validate() + } + + override fun visitSavedExtension(savedExtension: SavedExtension) { + savedExtension.validate() + } } ) validated = true @@ -2664,44 +2761,56 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent1 && + return other is UnnamedSchemaWithArrayParent4 && removeBg == other.removeBg && autoTaggingExtension == other.autoTaggingExtension && - aiAutoDescription == other.aiAutoDescription + aiAutoDescription == other.aiAutoDescription && + aiTasks == other.aiTasks && + savedExtension == other.savedExtension } override fun hashCode(): Int = - Objects.hash(removeBg, autoTaggingExtension, aiAutoDescription) + Objects.hash(removeBg, autoTaggingExtension, aiAutoDescription, aiTasks, savedExtension) override fun toString(): String = when { - removeBg != null -> "UnnamedSchemaWithArrayParent1{removeBg=$removeBg}" + removeBg != null -> "UnnamedSchemaWithArrayParent4{removeBg=$removeBg}" autoTaggingExtension != null -> - "UnnamedSchemaWithArrayParent1{autoTaggingExtension=$autoTaggingExtension}" + "UnnamedSchemaWithArrayParent4{autoTaggingExtension=$autoTaggingExtension}" aiAutoDescription != null -> - "UnnamedSchemaWithArrayParent1{aiAutoDescription=$aiAutoDescription}" - _json != null -> "UnnamedSchemaWithArrayParent1{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") + "UnnamedSchemaWithArrayParent4{aiAutoDescription=$aiAutoDescription}" + aiTasks != null -> "UnnamedSchemaWithArrayParent4{aiTasks=$aiTasks}" + savedExtension != null -> + "UnnamedSchemaWithArrayParent4{savedExtension=$savedExtension}" + _json != null -> "UnnamedSchemaWithArrayParent4{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent4") } companion object { @JvmStatic - fun ofRemoveBg(removeBg: RemoveBg) = UnnamedSchemaWithArrayParent1(removeBg = removeBg) + fun ofRemoveBg(removeBg: RemoveBg) = UnnamedSchemaWithArrayParent4(removeBg = removeBg) @JvmStatic fun ofAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension) = - UnnamedSchemaWithArrayParent1(autoTaggingExtension = autoTaggingExtension) + UnnamedSchemaWithArrayParent4(autoTaggingExtension = autoTaggingExtension) @JvmStatic fun ofAiAutoDescription() = - UnnamedSchemaWithArrayParent1( + UnnamedSchemaWithArrayParent4( aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) ) + + @JvmStatic + fun ofAiTasks(aiTasks: AiTasks) = UnnamedSchemaWithArrayParent4(aiTasks = aiTasks) + + @JvmStatic + fun ofSavedExtension(savedExtension: SavedExtension) = + UnnamedSchemaWithArrayParent4(savedExtension = savedExtension) } /** - * An interface that defines how to map each variant of [UnnamedSchemaWithArrayParent1] to a + * An interface that defines how to map each variant of [UnnamedSchemaWithArrayParent4] to a * value of type [T]. */ interface Visitor { @@ -2712,10 +2821,14 @@ private constructor( fun visitAiAutoDescription(aiAutoDescription: JsonValue): T + fun visitAiTasks(aiTasks: AiTasks): T + + fun visitSavedExtension(savedExtension: SavedExtension): T + /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent1] to a value of type [T]. + * Maps an unknown variant of [UnnamedSchemaWithArrayParent4] to a value of type [T]. * - * An instance of [UnnamedSchemaWithArrayParent1] can contain an unknown variant if it + * An instance of [UnnamedSchemaWithArrayParent4] can contain an unknown variant if it * was deserialized from data that doesn't match any known variant. For example, if the * SDK is on an older version than the API, then the API may respond with new variants * that the SDK is unaware of. @@ -2723,15 +2836,15 @@ private constructor( * @throws ImageKitInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown UnnamedSchemaWithArrayParent1: $json") + throw ImageKitInvalidDataException("Unknown UnnamedSchemaWithArrayParent4: $json") } } internal class Serializer : - BaseSerializer(UnnamedSchemaWithArrayParent1::class) { + BaseSerializer(UnnamedSchemaWithArrayParent4::class) { override fun serialize( - value: UnnamedSchemaWithArrayParent1, + value: UnnamedSchemaWithArrayParent4, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -2741,8 +2854,10 @@ private constructor( generator.writeObject(value.autoTaggingExtension) value.aiAutoDescription != null -> generator.writeObject(value.aiAutoDescription) + value.aiTasks != null -> generator.writeObject(value.aiTasks) + value.savedExtension != null -> generator.writeObject(value.savedExtension) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent4") } } } @@ -3547,6 +3662,4890 @@ private constructor( override fun toString() = "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" } + + class AiTasks + private constructor( + private val name: JsonValue, + private val tasks: JsonField>, + private val additionalProperties: MutableMap, + ) { + + /** + * Specifies the AI tasks extension for automated image analysis using AI models. + * + * Expected to always return the following: + * ```java + * JsonValue.from("ai-tasks") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Array of task objects defining AI operations to perform on the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun tasks(): List = tasks.getRequired("tasks") + + /** + * Returns the raw JSON value of [tasks]. + * + * Unlike [tasks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tasks") @ExcludeMissing fun _tasks(): JsonField> = tasks + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AiTasks]. + * + * The following fields are required: + * ```java + * .tasks() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AiTasks]. */ + class Builder internal constructor() { + + private var name: JsonValue = JsonValue.from("ai-tasks") + private var tasks: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(aiTasks: AiTasks) = apply { + name = aiTasks.name + tasks = aiTasks.tasks.map { it.toMutableList() } + additionalProperties = aiTasks.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("ai-tasks") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** Array of task objects defining AI operations to perform on the asset. */ + fun tasks(tasks: List) = tasks(JsonField.of(tasks)) + + /** + * Sets [Builder.tasks] to an arbitrary JSON value. + * + * You should usually call [Builder.tasks] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tasks(tasks: JsonField>) = apply { + this.tasks = tasks.map { it.toMutableList() } + } + + /** + * Adds a single [Task] to [tasks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTask(task: Task) = apply { + tasks = + (tasks ?: JsonField.of(mutableListOf())).also { + checkKnown("tasks", it).add(task) + } + } + + /** Alias for calling [addTask] with `Task.ofSelectTags(selectTags)`. */ + fun addTask(selectTags: Task.SelectTags) = addTask(Task.ofSelectTags(selectTags)) + + /** Alias for calling [addTask] with `Task.ofSelectMetadata(selectMetadata)`. */ + fun addTask(selectMetadata: Task.SelectMetadata) = + addTask(Task.ofSelectMetadata(selectMetadata)) + + /** Alias for calling [addTask] with `Task.ofYesNo(yesNo)`. */ + fun addTask(yesNo: Task.YesNo) = addTask(Task.ofYesNo(yesNo)) + + /** + * Alias for calling [addTask] with the following: + * ```java + * Task.YesNo.builder() + * .instruction(instruction) + * .build() + * ``` + */ + fun addYesNoTask(instruction: String) = + addTask(Task.YesNo.builder().instruction(instruction).build()) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AiTasks]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tasks() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AiTasks = + AiTasks( + name, + checkRequired("tasks", tasks).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AiTasks = apply { + if (validated) { + return@apply + } + + _name().let { + if (it != JsonValue.from("ai-tasks")) { + throw ImageKitInvalidDataException("'name' is invalid, received $it") + } + } + tasks().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + @JsonSerialize(using = Task.Serializer::class) + class Task + private constructor( + private val selectTags: SelectTags? = null, + private val selectMetadata: SelectMetadata? = null, + private val yesNo: YesNo? = null, + private val _json: JsonValue? = null, + ) { + + fun selectTags(): Optional = Optional.ofNullable(selectTags) + + fun selectMetadata(): Optional = Optional.ofNullable(selectMetadata) + + fun yesNo(): Optional = Optional.ofNullable(yesNo) + + fun isSelectTags(): Boolean = selectTags != null + + fun isSelectMetadata(): Boolean = selectMetadata != null + + fun isYesNo(): Boolean = yesNo != null + + fun asSelectTags(): SelectTags = selectTags.getOrThrow("selectTags") + + fun asSelectMetadata(): SelectMetadata = selectMetadata.getOrThrow("selectMetadata") + + fun asYesNo(): YesNo = yesNo.getOrThrow("yesNo") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + selectTags != null -> visitor.visitSelectTags(selectTags) + selectMetadata != null -> visitor.visitSelectMetadata(selectMetadata) + yesNo != null -> visitor.visitYesNo(yesNo) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Task = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitSelectTags(selectTags: SelectTags) { + selectTags.validate() + } + + override fun visitSelectMetadata(selectMetadata: SelectMetadata) { + selectMetadata.validate() + } + + override fun visitYesNo(yesNo: YesNo) { + yesNo.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Task && + selectTags == other.selectTags && + selectMetadata == other.selectMetadata && + yesNo == other.yesNo + } + + override fun hashCode(): Int = Objects.hash(selectTags, selectMetadata, yesNo) + + override fun toString(): String = + when { + selectTags != null -> "Task{selectTags=$selectTags}" + selectMetadata != null -> "Task{selectMetadata=$selectMetadata}" + yesNo != null -> "Task{yesNo=$yesNo}" + _json != null -> "Task{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Task") + } + + companion object { + + @JvmStatic + fun ofSelectTags(selectTags: SelectTags) = Task(selectTags = selectTags) + + @JvmStatic + fun ofSelectMetadata(selectMetadata: SelectMetadata) = + Task(selectMetadata = selectMetadata) + + @JvmStatic fun ofYesNo(yesNo: YesNo) = Task(yesNo = yesNo) + } + + /** + * An interface that defines how to map each variant of [Task] to a value of type + * [T]. + */ + interface Visitor { + + fun visitSelectTags(selectTags: SelectTags): T + + fun visitSelectMetadata(selectMetadata: SelectMetadata): T + + fun visitYesNo(yesNo: YesNo): T + + /** + * Maps an unknown variant of [Task] to a value of type [T]. + * + * An instance of [Task] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on + * an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Task: $json") + } + } + + internal class Serializer : BaseSerializer(Task::class) { + + override fun serialize( + value: Task, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.selectTags != null -> generator.writeObject(value.selectTags) + value.selectMetadata != null -> + generator.writeObject(value.selectMetadata) + value.yesNo != null -> generator.writeObject(value.yesNo) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Task") + } + } + } + + class SelectTags + private constructor( + private val instruction: JsonField, + private val type: JsonValue, + private val vocabulary: JsonField>, + private val maxSelections: JsonField, + private val minSelections: JsonField, + private val additionalProperties: MutableMap, + ) { + + /** + * The question or instruction for the AI to analyze the image. + * + * @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 instruction(): String = instruction.getRequired("instruction") + + /** + * Task type that analyzes the image and adds matching tags from a vocabulary. + * + * Expected to always return the following: + * ```java + * JsonValue.from("select_tags") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Array of possible tag values. Combined length of all strings must not exceed + * 500 characters. Cannot contain the `%` character. + * + * @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 vocabulary(): List = vocabulary.getRequired("vocabulary") + + /** + * Maximum number of tags to select from the vocabulary. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun maxSelections(): Optional = + maxSelections.getOptional("max_selections") + + /** + * Minimum number of tags to select from the vocabulary. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun minSelections(): Optional = + minSelections.getOptional("min_selections") + + /** + * Returns the raw JSON value of [instruction]. + * + * Unlike [instruction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("instruction") + @ExcludeMissing + fun _instruction(): JsonField = instruction + + /** + * Returns the raw JSON value of [vocabulary]. + * + * Unlike [vocabulary], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("vocabulary") + @ExcludeMissing + fun _vocabulary(): JsonField> = vocabulary + + /** + * Returns the raw JSON value of [maxSelections]. + * + * Unlike [maxSelections], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("max_selections") + @ExcludeMissing + fun _maxSelections(): JsonField = maxSelections + + /** + * Returns the raw JSON value of [minSelections]. + * + * Unlike [minSelections], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("min_selections") + @ExcludeMissing + fun _minSelections(): JsonField = minSelections + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SelectTags]. + * + * The following fields are required: + * ```java + * .instruction() + * .vocabulary() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SelectTags]. */ + class Builder internal constructor() { + + private var instruction: JsonField? = null + private var type: JsonValue = JsonValue.from("select_tags") + private var vocabulary: JsonField>? = null + private var maxSelections: JsonField = JsonMissing.of() + private var minSelections: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(selectTags: SelectTags) = apply { + instruction = selectTags.instruction + type = selectTags.type + vocabulary = selectTags.vocabulary.map { it.toMutableList() } + maxSelections = selectTags.maxSelections + minSelections = selectTags.minSelections + additionalProperties = selectTags.additionalProperties.toMutableMap() + } + + /** The question or instruction for the AI to analyze the image. */ + fun instruction(instruction: String) = + instruction(JsonField.of(instruction)) + + /** + * Sets [Builder.instruction] to an arbitrary JSON value. + * + * You should usually call [Builder.instruction] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun instruction(instruction: JsonField) = apply { + this.instruction = instruction + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("select_tags") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Array of possible tag values. Combined length of all strings must not + * exceed 500 characters. Cannot contain the `%` character. + */ + fun vocabulary(vocabulary: List) = + vocabulary(JsonField.of(vocabulary)) + + /** + * Sets [Builder.vocabulary] to an arbitrary JSON value. + * + * You should usually call [Builder.vocabulary] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun vocabulary(vocabulary: JsonField>) = apply { + this.vocabulary = vocabulary.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.vocabulary]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addVocabulary(vocabulary: String) = apply { + this.vocabulary = + (this.vocabulary ?: JsonField.of(mutableListOf())).also { + checkKnown("vocabulary", it).add(vocabulary) + } + } + + /** Maximum number of tags to select from the vocabulary. */ + fun maxSelections(maxSelections: Long) = + maxSelections(JsonField.of(maxSelections)) + + /** + * Sets [Builder.maxSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.maxSelections] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun maxSelections(maxSelections: JsonField) = apply { + this.maxSelections = maxSelections + } + + /** Minimum number of tags to select from the vocabulary. */ + fun minSelections(minSelections: Long) = + minSelections(JsonField.of(minSelections)) + + /** + * Sets [Builder.minSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.minSelections] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minSelections(minSelections: JsonField) = apply { + this.minSelections = minSelections + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SelectTags]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .instruction() + * .vocabulary() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SelectTags = + SelectTags( + checkRequired("instruction", instruction), + type, + checkRequired("vocabulary", vocabulary).map { it.toImmutable() }, + maxSelections, + minSelections, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SelectTags = apply { + if (validated) { + return@apply + } + + instruction() + _type().let { + if (it != JsonValue.from("select_tags")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + vocabulary() + maxSelections() + minSelections() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SelectTags && + instruction == other.instruction && + type == other.type && + vocabulary == other.vocabulary && + maxSelections == other.maxSelections && + minSelections == other.minSelections && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + instruction, + type, + vocabulary, + maxSelections, + minSelections, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SelectTags{instruction=$instruction, type=$type, vocabulary=$vocabulary, maxSelections=$maxSelections, minSelections=$minSelections, additionalProperties=$additionalProperties}" + } + + class SelectMetadata + private constructor( + private val field: JsonField, + private val instruction: JsonField, + private val type: JsonValue, + private val maxSelections: JsonField, + private val minSelections: JsonField, + private val vocabulary: JsonField>, + private val additionalProperties: MutableMap, + ) { + + /** + * Name of the custom metadata field to set. The field must exist in 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 field(): String = field.getRequired("field") + + /** + * The question or instruction for the AI to analyze the image. + * + * @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 instruction(): String = instruction.getRequired("instruction") + + /** + * Task type that analyzes the image and sets a custom metadata field value from + * a vocabulary. + * + * Expected to always return the following: + * ```java + * JsonValue.from("select_metadata") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Maximum number of values to select from the vocabulary. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun maxSelections(): Optional = + maxSelections.getOptional("max_selections") + + /** + * Minimum number of values to select from the vocabulary. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun minSelections(): Optional = + minSelections.getOptional("min_selections") + + /** + * Array of possible values matching the custom metadata field type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun vocabulary(): Optional> = + vocabulary.getOptional("vocabulary") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [instruction]. + * + * Unlike [instruction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("instruction") + @ExcludeMissing + fun _instruction(): JsonField = instruction + + /** + * Returns the raw JSON value of [maxSelections]. + * + * Unlike [maxSelections], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("max_selections") + @ExcludeMissing + fun _maxSelections(): JsonField = maxSelections + + /** + * Returns the raw JSON value of [minSelections]. + * + * Unlike [minSelections], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("min_selections") + @ExcludeMissing + fun _minSelections(): JsonField = minSelections + + /** + * Returns the raw JSON value of [vocabulary]. + * + * Unlike [vocabulary], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("vocabulary") + @ExcludeMissing + fun _vocabulary(): JsonField> = vocabulary + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SelectMetadata]. + * + * The following fields are required: + * ```java + * .field() + * .instruction() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SelectMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var instruction: JsonField? = null + private var type: JsonValue = JsonValue.from("select_metadata") + private var maxSelections: JsonField = JsonMissing.of() + private var minSelections: JsonField = JsonMissing.of() + private var vocabulary: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(selectMetadata: SelectMetadata) = apply { + field = selectMetadata.field + instruction = selectMetadata.instruction + type = selectMetadata.type + maxSelections = selectMetadata.maxSelections + minSelections = selectMetadata.minSelections + vocabulary = selectMetadata.vocabulary.map { it.toMutableList() } + additionalProperties = + selectMetadata.additionalProperties.toMutableMap() + } + + /** + * Name of the custom metadata field to set. The field must exist in your + * account. + */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** The question or instruction for the AI to analyze the image. */ + fun instruction(instruction: String) = + instruction(JsonField.of(instruction)) + + /** + * Sets [Builder.instruction] to an arbitrary JSON value. + * + * You should usually call [Builder.instruction] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun instruction(instruction: JsonField) = apply { + this.instruction = instruction + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("select_metadata") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Maximum number of values to select from the vocabulary. */ + fun maxSelections(maxSelections: Long) = + maxSelections(JsonField.of(maxSelections)) + + /** + * Sets [Builder.maxSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.maxSelections] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun maxSelections(maxSelections: JsonField) = apply { + this.maxSelections = maxSelections + } + + /** Minimum number of values to select from the vocabulary. */ + fun minSelections(minSelections: Long) = + minSelections(JsonField.of(minSelections)) + + /** + * Sets [Builder.minSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.minSelections] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minSelections(minSelections: JsonField) = apply { + this.minSelections = minSelections + } + + /** Array of possible values matching the custom metadata field type. */ + fun vocabulary(vocabulary: List) = + vocabulary(JsonField.of(vocabulary)) + + /** + * Sets [Builder.vocabulary] to an arbitrary JSON value. + * + * You should usually call [Builder.vocabulary] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun vocabulary(vocabulary: JsonField>) = apply { + this.vocabulary = vocabulary.map { it.toMutableList() } + } + + /** + * Adds a single [Vocabulary] to [Builder.vocabulary]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addVocabulary(vocabulary: Vocabulary) = apply { + this.vocabulary = + (this.vocabulary ?: JsonField.of(mutableListOf())).also { + checkKnown("vocabulary", it).add(vocabulary) + } + } + + /** Alias for calling [addVocabulary] with `Vocabulary.ofString(string)`. */ + fun addVocabulary(string: String) = + addVocabulary(Vocabulary.ofString(string)) + + /** Alias for calling [addVocabulary] with `Vocabulary.ofNumber(number)`. */ + fun addVocabulary(number: Double) = + addVocabulary(Vocabulary.ofNumber(number)) + + /** Alias for calling [addVocabulary] with `Vocabulary.ofBool(bool)`. */ + fun addVocabulary(bool: Boolean) = addVocabulary(Vocabulary.ofBool(bool)) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SelectMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .field() + * .instruction() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SelectMetadata = + SelectMetadata( + checkRequired("field", field), + checkRequired("instruction", instruction), + type, + maxSelections, + minSelections, + (vocabulary ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SelectMetadata = apply { + if (validated) { + return@apply + } + + field() + instruction() + _type().let { + if (it != JsonValue.from("select_metadata")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + maxSelections() + minSelections() + vocabulary().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + @JsonSerialize(using = Vocabulary.Serializer::class) + class Vocabulary + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Vocabulary = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Vocabulary && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> "Vocabulary{string=$string}" + number != null -> "Vocabulary{number=$number}" + bool != null -> "Vocabulary{bool=$bool}" + _json != null -> "Vocabulary{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Vocabulary") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Vocabulary(string = string) + + @JvmStatic fun ofNumber(number: Double) = Vocabulary(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Vocabulary(bool = bool) + } + + /** + * An interface that defines how to map each variant of [Vocabulary] to a + * value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [Vocabulary] to a value of type [T]. + * + * An instance of [Vocabulary] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Vocabulary: $json") + } + } + + internal class Serializer : BaseSerializer(Vocabulary::class) { + + override fun serialize( + value: Vocabulary, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Vocabulary") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SelectMetadata && + field == other.field && + instruction == other.instruction && + type == other.type && + maxSelections == other.maxSelections && + minSelections == other.minSelections && + vocabulary == other.vocabulary && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + field, + instruction, + type, + maxSelections, + minSelections, + vocabulary, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SelectMetadata{field=$field, instruction=$instruction, type=$type, maxSelections=$maxSelections, minSelections=$minSelections, vocabulary=$vocabulary, additionalProperties=$additionalProperties}" + } + + class YesNo + private constructor( + private val instruction: JsonField, + private val type: JsonValue, + private val onNo: JsonField, + private val onUnknown: JsonField, + private val onYes: JsonField, + private val additionalProperties: MutableMap, + ) { + + /** + * The yes/no question for the AI to answer about the image. + * + * @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 instruction(): String = instruction.getRequired("instruction") + + /** + * Task type that asks a yes/no question and executes actions based on the + * answer. + * + * Expected to always return the following: + * ```java + * JsonValue.from("yes_no") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Actions to execute if the AI answers no. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun onNo(): Optional = onNo.getOptional("on_no") + + /** + * Actions to execute if the AI cannot determine the answer. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun onUnknown(): Optional = onUnknown.getOptional("on_unknown") + + /** + * Actions to execute if the AI answers yes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun onYes(): Optional = onYes.getOptional("on_yes") + + /** + * Returns the raw JSON value of [instruction]. + * + * Unlike [instruction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("instruction") + @ExcludeMissing + fun _instruction(): JsonField = instruction + + /** + * Returns the raw JSON value of [onNo]. + * + * Unlike [onNo], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("on_no") @ExcludeMissing fun _onNo(): JsonField = onNo + + /** + * Returns the raw JSON value of [onUnknown]. + * + * Unlike [onUnknown], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("on_unknown") + @ExcludeMissing + fun _onUnknown(): JsonField = onUnknown + + /** + * Returns the raw JSON value of [onYes]. + * + * Unlike [onYes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("on_yes") @ExcludeMissing fun _onYes(): JsonField = onYes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [YesNo]. + * + * The following fields are required: + * ```java + * .instruction() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [YesNo]. */ + class Builder internal constructor() { + + private var instruction: JsonField? = null + private var type: JsonValue = JsonValue.from("yes_no") + private var onNo: JsonField = JsonMissing.of() + private var onUnknown: JsonField = JsonMissing.of() + private var onYes: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(yesNo: YesNo) = apply { + instruction = yesNo.instruction + type = yesNo.type + onNo = yesNo.onNo + onUnknown = yesNo.onUnknown + onYes = yesNo.onYes + additionalProperties = yesNo.additionalProperties.toMutableMap() + } + + /** The yes/no question for the AI to answer about the image. */ + fun instruction(instruction: String) = + instruction(JsonField.of(instruction)) + + /** + * Sets [Builder.instruction] to an arbitrary JSON value. + * + * You should usually call [Builder.instruction] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun instruction(instruction: JsonField) = apply { + this.instruction = instruction + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("yes_no") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Actions to execute if the AI answers no. */ + fun onNo(onNo: OnNo) = onNo(JsonField.of(onNo)) + + /** + * Sets [Builder.onNo] to an arbitrary JSON value. + * + * You should usually call [Builder.onNo] with a well-typed [OnNo] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun onNo(onNo: JsonField) = apply { this.onNo = onNo } + + /** Actions to execute if the AI cannot determine the answer. */ + fun onUnknown(onUnknown: OnUnknown) = onUnknown(JsonField.of(onUnknown)) + + /** + * Sets [Builder.onUnknown] to an arbitrary JSON value. + * + * You should usually call [Builder.onUnknown] with a well-typed [OnUnknown] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun onUnknown(onUnknown: JsonField) = apply { + this.onUnknown = onUnknown + } + + /** Actions to execute if the AI answers yes. */ + fun onYes(onYes: OnYes) = onYes(JsonField.of(onYes)) + + /** + * Sets [Builder.onYes] to an arbitrary JSON value. + * + * You should usually call [Builder.onYes] with a well-typed [OnYes] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun onYes(onYes: JsonField) = apply { this.onYes = onYes } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [YesNo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .instruction() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): YesNo = + YesNo( + checkRequired("instruction", instruction), + type, + onNo, + onUnknown, + onYes, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): YesNo = apply { + if (validated) { + return@apply + } + + instruction() + _type().let { + if (it != JsonValue.from("yes_no")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + onNo().ifPresent { it.validate() } + onUnknown().ifPresent { it.validate() } + onYes().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** Actions to execute if the AI answers no. */ + class OnNo + private constructor( + private val addTags: JsonField>, + private val removeTags: JsonField>, + private val setMetadata: JsonField>, + private val unsetMetadata: JsonField>, + private val additionalProperties: MutableMap, + ) { + + /** + * Array of tag strings to add to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun addTags(): Optional> = addTags.getOptional("add_tags") + + /** + * Array of tag strings to remove from the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun removeTags(): Optional> = + removeTags.getOptional("remove_tags") + + /** + * Array of custom metadata field updates. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun setMetadata(): Optional> = + setMetadata.getOptional("set_metadata") + + /** + * Array of custom metadata fields to remove. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun unsetMetadata(): Optional> = + unsetMetadata.getOptional("unset_metadata") + + /** + * Returns the raw JSON value of [addTags]. + * + * Unlike [addTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_tags") + @ExcludeMissing + fun _addTags(): JsonField> = addTags + + /** + * Returns the raw JSON value of [removeTags]. + * + * Unlike [removeTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("remove_tags") + @ExcludeMissing + fun _removeTags(): JsonField> = removeTags + + /** + * Returns the raw JSON value of [setMetadata]. + * + * Unlike [setMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("set_metadata") + @ExcludeMissing + fun _setMetadata(): JsonField> = setMetadata + + /** + * Returns the raw JSON value of [unsetMetadata]. + * + * Unlike [unsetMetadata], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unset_metadata") + @ExcludeMissing + fun _unsetMetadata(): JsonField> = unsetMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [OnNo]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OnNo]. */ + class Builder internal constructor() { + + private var addTags: JsonField>? = null + private var removeTags: JsonField>? = null + private var setMetadata: JsonField>? = null + private var unsetMetadata: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(onNo: OnNo) = apply { + addTags = onNo.addTags.map { it.toMutableList() } + removeTags = onNo.removeTags.map { it.toMutableList() } + setMetadata = onNo.setMetadata.map { it.toMutableList() } + unsetMetadata = onNo.unsetMetadata.map { it.toMutableList() } + additionalProperties = onNo.additionalProperties.toMutableMap() + } + + /** Array of tag strings to add to the asset. */ + fun addTags(addTags: List) = addTags(JsonField.of(addTags)) + + /** + * Sets [Builder.addTags] to an arbitrary JSON value. + * + * You should usually call [Builder.addTags] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun addTags(addTags: JsonField>) = apply { + this.addTags = addTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [addTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAddTag(addTag: String) = apply { + addTags = + (addTags ?: JsonField.of(mutableListOf())).also { + checkKnown("addTags", it).add(addTag) + } + } + + /** Array of tag strings to remove from the asset. */ + fun removeTags(removeTags: List) = + removeTags(JsonField.of(removeTags)) + + /** + * Sets [Builder.removeTags] to an arbitrary JSON value. + * + * You should usually call [Builder.removeTags] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun removeTags(removeTags: JsonField>) = apply { + this.removeTags = removeTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [removeTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addRemoveTag(removeTag: String) = apply { + removeTags = + (removeTags ?: JsonField.of(mutableListOf())).also { + checkKnown("removeTags", it).add(removeTag) + } + } + + /** Array of custom metadata field updates. */ + fun setMetadata(setMetadata: List) = + setMetadata(JsonField.of(setMetadata)) + + /** + * Sets [Builder.setMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.setMetadata] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun setMetadata(setMetadata: JsonField>) = apply { + this.setMetadata = setMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [SetMetadata] to [Builder.setMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addSetMetadata(setMetadata: SetMetadata) = apply { + this.setMetadata = + (this.setMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("setMetadata", it).add(setMetadata) + } + } + + /** Array of custom metadata fields to remove. */ + fun unsetMetadata(unsetMetadata: List) = + unsetMetadata(JsonField.of(unsetMetadata)) + + /** + * Sets [Builder.unsetMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.unsetMetadata] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun unsetMetadata(unsetMetadata: JsonField>) = + apply { + this.unsetMetadata = unsetMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { + this.unsetMetadata = + (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("unsetMetadata", it).add(unsetMetadata) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OnNo]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): OnNo = + OnNo( + (addTags ?: JsonMissing.of()).map { it.toImmutable() }, + (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, + (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + (unsetMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OnNo = apply { + if (validated) { + return@apply + } + + addTags() + removeTags() + setMetadata().ifPresent { it.forEach { it.validate() } } + unsetMetadata().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + class SetMetadata + private constructor( + private val field: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + /** + * Name of the custom metadata field to set. + * + * @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 field(): String = field.getRequired("field") + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + * + * @throws ImageKitInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun value(): Value = value.getRequired("value") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(setMetadata: SetMetadata) = apply { + field = setMetadata.field + value = setMetadata.value + additionalProperties = + setMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to set. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + */ + fun value(value: Value) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] + * value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ + fun valueOfMixed(mixed: List) = + value(Value.ofMixed(mixed)) + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SetMetadata = + SetMetadata( + checkRequired("field", field), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SetMetadata = apply { + if (validated) { + return@apply + } + + field() + value().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + */ + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val mixed: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun mixed(): Optional> = + Optional.ofNullable(mixed) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isMixed(): Boolean = mixed != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asMixed(): List = + mixed.getOrThrow("mixed") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + mixed != null -> visitor.visitMixed(mixed) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitMixed( + mixed: List + ) { + mixed.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + string == other.string && + number == other.number && + bool == other.bool && + mixed == other.mixed + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool, mixed) + + override fun toString(): String = + when { + string != null -> "Value{string=$string}" + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + mixed != null -> "Value{mixed=$mixed}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic + fun ofMixed(mixed: List) = + Value(mixed = mixed.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Value] to a + * value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitMixed(mixed: List): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it + * was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than + * the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Value: $json") + } + } + + internal class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.mixed != null -> + generator.writeObject(value.mixed) + value._json != null -> + generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + + @JsonSerialize( + using = UnnamedSchemaWithArrayParent5.Serializer::class + ) + class UnnamedSchemaWithArrayParent5 + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent5 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent5 && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> + "UnnamedSchemaWithArrayParent5{string=$string}" + number != null -> + "UnnamedSchemaWithArrayParent5{number=$number}" + bool != null -> + "UnnamedSchemaWithArrayParent5{bool=$bool}" + _json != null -> + "UnnamedSchemaWithArrayParent5{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent5" + ) + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent5(string = string) + + @JvmStatic + fun ofNumber(number: Double) = + UnnamedSchemaWithArrayParent5(number = number) + + @JvmStatic + fun ofBool(bool: Boolean) = + UnnamedSchemaWithArrayParent5(bool = bool) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent5] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of + * [UnnamedSchemaWithArrayParent5] to a value of type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent5] can + * contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the + * API may respond with new variants that the SDK is unaware + * of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent5: $json" + ) + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent5::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent5, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> + generator.writeObject(value.bool) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent5" + ) + } + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SetMetadata && + field == other.field && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" + } + + class UnsetMetadata + private constructor( + private val field: JsonField, + private val additionalProperties: MutableMap, + ) { + + /** + * Name of the custom metadata field to remove. + * + * @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 field(): String = field.getRequired("field") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnsetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnsetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unsetMetadata: UnsetMetadata) = apply { + field = unsetMetadata.field + additionalProperties = + unsetMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to remove. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnsetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnsetMetadata = + UnsetMetadata( + checkRequired("field", field), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnsetMetadata = apply { + if (validated) { + return@apply + } + + field() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnsetMetadata && + field == other.field && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OnNo && + addTags == other.addTags && + removeTags == other.removeTags && + setMetadata == other.setMetadata && + unsetMetadata == other.unsetMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addTags, + removeTags, + setMetadata, + unsetMetadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OnNo{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" + } + + /** Actions to execute if the AI cannot determine the answer. */ + class OnUnknown + private constructor( + private val addTags: JsonField>, + private val removeTags: JsonField>, + private val setMetadata: JsonField>, + private val unsetMetadata: JsonField>, + private val additionalProperties: MutableMap, + ) { + + /** + * Array of tag strings to add to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun addTags(): Optional> = addTags.getOptional("add_tags") + + /** + * Array of tag strings to remove from the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun removeTags(): Optional> = + removeTags.getOptional("remove_tags") + + /** + * Array of custom metadata field updates. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun setMetadata(): Optional> = + setMetadata.getOptional("set_metadata") + + /** + * Array of custom metadata fields to remove. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun unsetMetadata(): Optional> = + unsetMetadata.getOptional("unset_metadata") + + /** + * Returns the raw JSON value of [addTags]. + * + * Unlike [addTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_tags") + @ExcludeMissing + fun _addTags(): JsonField> = addTags + + /** + * Returns the raw JSON value of [removeTags]. + * + * Unlike [removeTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("remove_tags") + @ExcludeMissing + fun _removeTags(): JsonField> = removeTags + + /** + * Returns the raw JSON value of [setMetadata]. + * + * Unlike [setMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("set_metadata") + @ExcludeMissing + fun _setMetadata(): JsonField> = setMetadata + + /** + * Returns the raw JSON value of [unsetMetadata]. + * + * Unlike [unsetMetadata], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unset_metadata") + @ExcludeMissing + fun _unsetMetadata(): JsonField> = unsetMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [OnUnknown]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OnUnknown]. */ + class Builder internal constructor() { + + private var addTags: JsonField>? = null + private var removeTags: JsonField>? = null + private var setMetadata: JsonField>? = null + private var unsetMetadata: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(onUnknown: OnUnknown) = apply { + addTags = onUnknown.addTags.map { it.toMutableList() } + removeTags = onUnknown.removeTags.map { it.toMutableList() } + setMetadata = onUnknown.setMetadata.map { it.toMutableList() } + unsetMetadata = onUnknown.unsetMetadata.map { it.toMutableList() } + additionalProperties = onUnknown.additionalProperties.toMutableMap() + } + + /** Array of tag strings to add to the asset. */ + fun addTags(addTags: List) = addTags(JsonField.of(addTags)) + + /** + * Sets [Builder.addTags] to an arbitrary JSON value. + * + * You should usually call [Builder.addTags] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun addTags(addTags: JsonField>) = apply { + this.addTags = addTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [addTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAddTag(addTag: String) = apply { + addTags = + (addTags ?: JsonField.of(mutableListOf())).also { + checkKnown("addTags", it).add(addTag) + } + } + + /** Array of tag strings to remove from the asset. */ + fun removeTags(removeTags: List) = + removeTags(JsonField.of(removeTags)) + + /** + * Sets [Builder.removeTags] to an arbitrary JSON value. + * + * You should usually call [Builder.removeTags] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun removeTags(removeTags: JsonField>) = apply { + this.removeTags = removeTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [removeTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addRemoveTag(removeTag: String) = apply { + removeTags = + (removeTags ?: JsonField.of(mutableListOf())).also { + checkKnown("removeTags", it).add(removeTag) + } + } + + /** Array of custom metadata field updates. */ + fun setMetadata(setMetadata: List) = + setMetadata(JsonField.of(setMetadata)) + + /** + * Sets [Builder.setMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.setMetadata] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun setMetadata(setMetadata: JsonField>) = apply { + this.setMetadata = setMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [SetMetadata] to [Builder.setMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addSetMetadata(setMetadata: SetMetadata) = apply { + this.setMetadata = + (this.setMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("setMetadata", it).add(setMetadata) + } + } + + /** Array of custom metadata fields to remove. */ + fun unsetMetadata(unsetMetadata: List) = + unsetMetadata(JsonField.of(unsetMetadata)) + + /** + * Sets [Builder.unsetMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.unsetMetadata] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun unsetMetadata(unsetMetadata: JsonField>) = + apply { + this.unsetMetadata = unsetMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { + this.unsetMetadata = + (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("unsetMetadata", it).add(unsetMetadata) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OnUnknown]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): OnUnknown = + OnUnknown( + (addTags ?: JsonMissing.of()).map { it.toImmutable() }, + (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, + (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + (unsetMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OnUnknown = apply { + if (validated) { + return@apply + } + + addTags() + removeTags() + setMetadata().ifPresent { it.forEach { it.validate() } } + unsetMetadata().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + class SetMetadata + private constructor( + private val field: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + /** + * Name of the custom metadata field to set. + * + * @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 field(): String = field.getRequired("field") + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + * + * @throws ImageKitInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun value(): Value = value.getRequired("value") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(setMetadata: SetMetadata) = apply { + field = setMetadata.field + value = setMetadata.value + additionalProperties = + setMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to set. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + */ + fun value(value: Value) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] + * value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ + fun valueOfMixed(mixed: List) = + value(Value.ofMixed(mixed)) + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SetMetadata = + SetMetadata( + checkRequired("field", field), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SetMetadata = apply { + if (validated) { + return@apply + } + + field() + value().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + */ + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val mixed: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun mixed(): Optional> = + Optional.ofNullable(mixed) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isMixed(): Boolean = mixed != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asMixed(): List = + mixed.getOrThrow("mixed") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + mixed != null -> visitor.visitMixed(mixed) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitMixed( + mixed: List + ) { + mixed.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + string == other.string && + number == other.number && + bool == other.bool && + mixed == other.mixed + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool, mixed) + + override fun toString(): String = + when { + string != null -> "Value{string=$string}" + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + mixed != null -> "Value{mixed=$mixed}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic + fun ofMixed(mixed: List) = + Value(mixed = mixed.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Value] to a + * value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitMixed(mixed: List): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it + * was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than + * the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Value: $json") + } + } + + internal class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.mixed != null -> + generator.writeObject(value.mixed) + value._json != null -> + generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + + @JsonSerialize( + using = UnnamedSchemaWithArrayParent6.Serializer::class + ) + class UnnamedSchemaWithArrayParent6 + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent6 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent6 && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> + "UnnamedSchemaWithArrayParent6{string=$string}" + number != null -> + "UnnamedSchemaWithArrayParent6{number=$number}" + bool != null -> + "UnnamedSchemaWithArrayParent6{bool=$bool}" + _json != null -> + "UnnamedSchemaWithArrayParent6{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent6" + ) + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent6(string = string) + + @JvmStatic + fun ofNumber(number: Double) = + UnnamedSchemaWithArrayParent6(number = number) + + @JvmStatic + fun ofBool(bool: Boolean) = + UnnamedSchemaWithArrayParent6(bool = bool) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent6] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of + * [UnnamedSchemaWithArrayParent6] to a value of type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent6] can + * contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the + * API may respond with new variants that the SDK is unaware + * of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent6: $json" + ) + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent6::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent6, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> + generator.writeObject(value.bool) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent6" + ) + } + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SetMetadata && + field == other.field && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" + } + + class UnsetMetadata + private constructor( + private val field: JsonField, + private val additionalProperties: MutableMap, + ) { + + /** + * Name of the custom metadata field to remove. + * + * @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 field(): String = field.getRequired("field") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnsetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnsetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unsetMetadata: UnsetMetadata) = apply { + field = unsetMetadata.field + additionalProperties = + unsetMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to remove. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnsetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnsetMetadata = + UnsetMetadata( + checkRequired("field", field), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnsetMetadata = apply { + if (validated) { + return@apply + } + + field() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnsetMetadata && + field == other.field && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OnUnknown && + addTags == other.addTags && + removeTags == other.removeTags && + setMetadata == other.setMetadata && + unsetMetadata == other.unsetMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addTags, + removeTags, + setMetadata, + unsetMetadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OnUnknown{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" + } + + /** Actions to execute if the AI answers yes. */ + class OnYes + private constructor( + private val addTags: JsonField>, + private val removeTags: JsonField>, + private val setMetadata: JsonField>, + private val unsetMetadata: JsonField>, + private val additionalProperties: MutableMap, + ) { + + /** + * Array of tag strings to add to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun addTags(): Optional> = addTags.getOptional("add_tags") + + /** + * Array of tag strings to remove from the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun removeTags(): Optional> = + removeTags.getOptional("remove_tags") + + /** + * Array of custom metadata field updates. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun setMetadata(): Optional> = + setMetadata.getOptional("set_metadata") + + /** + * Array of custom metadata fields to remove. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun unsetMetadata(): Optional> = + unsetMetadata.getOptional("unset_metadata") + + /** + * Returns the raw JSON value of [addTags]. + * + * Unlike [addTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_tags") + @ExcludeMissing + fun _addTags(): JsonField> = addTags + + /** + * Returns the raw JSON value of [removeTags]. + * + * Unlike [removeTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("remove_tags") + @ExcludeMissing + fun _removeTags(): JsonField> = removeTags + + /** + * Returns the raw JSON value of [setMetadata]. + * + * Unlike [setMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("set_metadata") + @ExcludeMissing + fun _setMetadata(): JsonField> = setMetadata + + /** + * Returns the raw JSON value of [unsetMetadata]. + * + * Unlike [unsetMetadata], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("unset_metadata") + @ExcludeMissing + fun _unsetMetadata(): JsonField> = unsetMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OnYes]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OnYes]. */ + class Builder internal constructor() { + + private var addTags: JsonField>? = null + private var removeTags: JsonField>? = null + private var setMetadata: JsonField>? = null + private var unsetMetadata: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(onYes: OnYes) = apply { + addTags = onYes.addTags.map { it.toMutableList() } + removeTags = onYes.removeTags.map { it.toMutableList() } + setMetadata = onYes.setMetadata.map { it.toMutableList() } + unsetMetadata = onYes.unsetMetadata.map { it.toMutableList() } + additionalProperties = onYes.additionalProperties.toMutableMap() + } + + /** Array of tag strings to add to the asset. */ + fun addTags(addTags: List) = addTags(JsonField.of(addTags)) + + /** + * Sets [Builder.addTags] to an arbitrary JSON value. + * + * You should usually call [Builder.addTags] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun addTags(addTags: JsonField>) = apply { + this.addTags = addTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [addTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAddTag(addTag: String) = apply { + addTags = + (addTags ?: JsonField.of(mutableListOf())).also { + checkKnown("addTags", it).add(addTag) + } + } + + /** Array of tag strings to remove from the asset. */ + fun removeTags(removeTags: List) = + removeTags(JsonField.of(removeTags)) + + /** + * Sets [Builder.removeTags] to an arbitrary JSON value. + * + * You should usually call [Builder.removeTags] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun removeTags(removeTags: JsonField>) = apply { + this.removeTags = removeTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [removeTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addRemoveTag(removeTag: String) = apply { + removeTags = + (removeTags ?: JsonField.of(mutableListOf())).also { + checkKnown("removeTags", it).add(removeTag) + } + } + + /** Array of custom metadata field updates. */ + fun setMetadata(setMetadata: List) = + setMetadata(JsonField.of(setMetadata)) + + /** + * Sets [Builder.setMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.setMetadata] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun setMetadata(setMetadata: JsonField>) = apply { + this.setMetadata = setMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [SetMetadata] to [Builder.setMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addSetMetadata(setMetadata: SetMetadata) = apply { + this.setMetadata = + (this.setMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("setMetadata", it).add(setMetadata) + } + } + + /** Array of custom metadata fields to remove. */ + fun unsetMetadata(unsetMetadata: List) = + unsetMetadata(JsonField.of(unsetMetadata)) + + /** + * Sets [Builder.unsetMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.unsetMetadata] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun unsetMetadata(unsetMetadata: JsonField>) = + apply { + this.unsetMetadata = unsetMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { + this.unsetMetadata = + (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("unsetMetadata", it).add(unsetMetadata) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OnYes]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): OnYes = + OnYes( + (addTags ?: JsonMissing.of()).map { it.toImmutable() }, + (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, + (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + (unsetMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OnYes = apply { + if (validated) { + return@apply + } + + addTags() + removeTags() + setMetadata().ifPresent { it.forEach { it.validate() } } + unsetMetadata().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + class SetMetadata + private constructor( + private val field: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + /** + * Name of the custom metadata field to set. + * + * @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 field(): String = field.getRequired("field") + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + * + * @throws ImageKitInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun value(): Value = value.getRequired("value") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(setMetadata: SetMetadata) = apply { + field = setMetadata.field + value = setMetadata.value + additionalProperties = + setMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to set. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + */ + fun value(value: Value) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] + * value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ + fun valueOfMixed(mixed: List) = + value(Value.ofMixed(mixed)) + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SetMetadata = + SetMetadata( + checkRequired("field", field), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SetMetadata = apply { + if (validated) { + return@apply + } + + field() + value().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + */ + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val mixed: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun mixed(): Optional> = + Optional.ofNullable(mixed) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isMixed(): Boolean = mixed != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asMixed(): List = + mixed.getOrThrow("mixed") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + mixed != null -> visitor.visitMixed(mixed) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitMixed( + mixed: List + ) { + mixed.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + string == other.string && + number == other.number && + bool == other.bool && + mixed == other.mixed + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool, mixed) + + override fun toString(): String = + when { + string != null -> "Value{string=$string}" + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + mixed != null -> "Value{mixed=$mixed}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic + fun ofMixed(mixed: List) = + Value(mixed = mixed.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Value] to a + * value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitMixed(mixed: List): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it + * was deserialized from data that doesn't match any known + * variant. For example, if the SDK is on an older version than + * the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Value: $json") + } + } + + internal class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.mixed != null -> + generator.writeObject(value.mixed) + value._json != null -> + generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + + @JsonSerialize( + using = UnnamedSchemaWithArrayParent7.Serializer::class + ) + class UnnamedSchemaWithArrayParent7 + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent7 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent7 && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> + "UnnamedSchemaWithArrayParent7{string=$string}" + number != null -> + "UnnamedSchemaWithArrayParent7{number=$number}" + bool != null -> + "UnnamedSchemaWithArrayParent7{bool=$bool}" + _json != null -> + "UnnamedSchemaWithArrayParent7{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent7" + ) + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent7(string = string) + + @JvmStatic + fun ofNumber(number: Double) = + UnnamedSchemaWithArrayParent7(number = number) + + @JvmStatic + fun ofBool(bool: Boolean) = + UnnamedSchemaWithArrayParent7(bool = bool) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent7] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of + * [UnnamedSchemaWithArrayParent7] to a value of type [T]. + * + * An instance of [UnnamedSchemaWithArrayParent7] can + * contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the + * API may respond with new variants that the SDK is unaware + * of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent7: $json" + ) + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent7::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent7, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> + generator.writeObject(value.bool) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent7" + ) + } + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SetMetadata && + field == other.field && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" + } + + class UnsetMetadata + private constructor( + private val field: JsonField, + private val additionalProperties: MutableMap, + ) { + + /** + * Name of the custom metadata field to remove. + * + * @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 field(): String = field.getRequired("field") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnsetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnsetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unsetMetadata: UnsetMetadata) = apply { + field = unsetMetadata.field + additionalProperties = + unsetMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to remove. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnsetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnsetMetadata = + UnsetMetadata( + checkRequired("field", field), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnsetMetadata = apply { + if (validated) { + return@apply + } + + field() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnsetMetadata && + field == other.field && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OnYes && + addTags == other.addTags && + removeTags == other.removeTags && + setMetadata == other.setMetadata && + unsetMetadata == other.unsetMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addTags, + removeTags, + setMetadata, + unsetMetadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OnYes{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is YesNo && + instruction == other.instruction && + type == other.type && + onNo == other.onNo && + onUnknown == other.onUnknown && + onYes == other.onYes && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + instruction, + type, + onNo, + onUnknown, + onYes, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "YesNo{instruction=$instruction, type=$type, onNo=$onNo, onUnknown=$onUnknown, onYes=$onYes, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiTasks && + name == other.name && + tasks == other.tasks && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, tasks, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AiTasks{name=$name, tasks=$tasks, additionalProperties=$additionalProperties}" + } + + class SavedExtension + private constructor( + private val id: JsonField, + private val name: JsonValue, + private val additionalProperties: MutableMap, + ) { + + /** + * The unique ID of the saved extension to apply. + * + * @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") + + /** + * Indicates this is a reference to a saved extension. + * + * Expected to always return the following: + * ```java + * JsonValue.from("saved-extension") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SavedExtension]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SavedExtension]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var name: JsonValue = JsonValue.from("saved-extension") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(savedExtension: SavedExtension) = apply { + id = savedExtension.id + name = savedExtension.name + additionalProperties = savedExtension.additionalProperties.toMutableMap() + } + + /** The unique ID of the saved extension to apply. */ + 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 } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("saved-extension") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SavedExtension]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SavedExtension = + SavedExtension( + checkRequired("id", id), + name, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SavedExtension = apply { + if (validated) { + return@apply + } + + id() + _name().let { + if (it != JsonValue.from("saved-extension")) { + throw ImageKitInvalidDataException("'name' is invalid, received $it") + } + } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SavedExtension && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SavedExtension{id=$id, name=$name, additionalProperties=$additionalProperties}" + } } class ResponseField @JsonCreator private constructor(private val value: JsonField) : diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt index ca32f900..6fa2463f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt @@ -26,7 +26,7 @@ import com.imagekit.api.core.checkRequired import com.imagekit.api.core.getOrThrow import com.imagekit.api.core.toImmutable import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 import java.util.Collections import java.util.Objects import java.util.Optional @@ -223,7 +223,7 @@ private constructor( private val customCoordinates: JsonField, private val customMetadata: JsonField, private val description: JsonField, - private val extensions: JsonField>, + private val extensions: JsonField>, private val removeAiTags: JsonField, private val tags: JsonField>, private val webhookUrl: JsonField, @@ -243,7 +243,7 @@ private constructor( description: JsonField = JsonMissing.of(), @JsonProperty("extensions") @ExcludeMissing - extensions: JsonField> = JsonMissing.of(), + extensions: JsonField> = JsonMissing.of(), @JsonProperty("removeAITags") @ExcludeMissing removeAiTags: JsonField = JsonMissing.of(), @@ -298,7 +298,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun extensions(): Optional> = + fun extensions(): Optional> = extensions.getOptional("extensions") /** @@ -371,7 +371,7 @@ private constructor( */ @JsonProperty("extensions") @ExcludeMissing - fun _extensions(): JsonField> = extensions + fun _extensions(): JsonField> = extensions /** * Returns the raw JSON value of [removeAiTags]. @@ -423,7 +423,7 @@ private constructor( private var customCoordinates: JsonField = JsonMissing.of() private var customMetadata: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() - private var extensions: JsonField>? = null + private var extensions: JsonField>? = null private var removeAiTags: JsonField = JsonMissing.of() private var tags: JsonField>? = null private var webhookUrl: JsonField = JsonMissing.of() @@ -502,26 +502,26 @@ private constructor( * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ - fun extensions(extensions: List) = + fun extensions(extensions: List) = extensions(JsonField.of(extensions)) /** * Sets [Builder.extensions] to an arbitrary JSON value. * * You should usually call [Builder.extensions] with a well-typed - * `List` value instead. This method is primarily for + * `List` value instead. This method is primarily for * setting the field to an undocumented or not yet supported value. */ - fun extensions(extensions: JsonField>) = apply { + fun extensions(extensions: JsonField>) = apply { this.extensions = extensions.map { it.toMutableList() } } /** - * Adds a single [UnnamedSchemaWithArrayParent1] to [extensions]. + * Adds a single [UnnamedSchemaWithArrayParent4] to [extensions]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addExtension(extension: UnnamedSchemaWithArrayParent1) = apply { + fun addExtension(extension: UnnamedSchemaWithArrayParent4) = apply { extensions = (extensions ?: JsonField.of(mutableListOf())).also { checkKnown("extensions", it).add(extension) @@ -530,28 +530,64 @@ private constructor( /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent1.ofRemoveBg(removeBg)`. + * `UnnamedSchemaWithArrayParent4.ofRemoveBg(removeBg)`. */ - fun addExtension(removeBg: UnnamedSchemaWithArrayParent1.RemoveBg) = - addExtension(UnnamedSchemaWithArrayParent1.ofRemoveBg(removeBg)) + fun addExtension(removeBg: UnnamedSchemaWithArrayParent4.RemoveBg) = + addExtension(UnnamedSchemaWithArrayParent4.ofRemoveBg(removeBg)) /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(autoTaggingExtension)`. + * `UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension(autoTaggingExtension)`. */ fun addExtension( - autoTaggingExtension: UnnamedSchemaWithArrayParent1.AutoTaggingExtension + autoTaggingExtension: UnnamedSchemaWithArrayParent4.AutoTaggingExtension ) = addExtension( - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension(autoTaggingExtension) + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension(autoTaggingExtension) ) /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent1.ofAiAutoDescription()`. + * `UnnamedSchemaWithArrayParent4.ofAiAutoDescription()`. */ fun addExtensionAiAutoDescription() = - addExtension(UnnamedSchemaWithArrayParent1.ofAiAutoDescription()) + addExtension(UnnamedSchemaWithArrayParent4.ofAiAutoDescription()) + + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent4.ofAiTasks(aiTasks)`. + */ + fun addExtension(aiTasks: UnnamedSchemaWithArrayParent4.AiTasks) = + addExtension(UnnamedSchemaWithArrayParent4.ofAiTasks(aiTasks)) + + /** + * Alias for calling [addExtension] with the following: + * ```java + * UnnamedSchemaWithArrayParent4.AiTasks.builder() + * .tasks(tasks) + * .build() + * ``` + */ + fun addAiTasksExtension(tasks: List) = + addExtension(UnnamedSchemaWithArrayParent4.AiTasks.builder().tasks(tasks).build()) + + /** + * Alias for calling [addExtension] with + * `UnnamedSchemaWithArrayParent4.ofSavedExtension(savedExtension)`. + */ + fun addExtension(savedExtension: UnnamedSchemaWithArrayParent4.SavedExtension) = + addExtension(UnnamedSchemaWithArrayParent4.ofSavedExtension(savedExtension)) + + /** + * Alias for calling [addExtension] with the following: + * ```java + * UnnamedSchemaWithArrayParent4.SavedExtension.builder() + * .id(id) + * .build() + * ``` + */ + fun addSavedExtensionExtension(id: String) = + addExtension(UnnamedSchemaWithArrayParent4.SavedExtension.builder().id(id).build()) /** * An array of AITags associated with the file that you want to remove, e.g. `["car", @@ -814,13 +850,15 @@ private constructor( override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent1.Deserializer::class) - @JsonSerialize(using = UnnamedSchemaWithArrayParent1.Serializer::class) - class UnnamedSchemaWithArrayParent1 + @JsonDeserialize(using = UnnamedSchemaWithArrayParent4.Deserializer::class) + @JsonSerialize(using = UnnamedSchemaWithArrayParent4.Serializer::class) + class UnnamedSchemaWithArrayParent4 private constructor( private val removeBg: RemoveBg? = null, private val autoTaggingExtension: AutoTaggingExtension? = null, private val aiAutoDescription: JsonValue? = null, + private val aiTasks: AiTasks? = null, + private val savedExtension: SavedExtension? = null, private val _json: JsonValue? = null, ) { @@ -831,12 +869,20 @@ private constructor( fun aiAutoDescription(): Optional = Optional.ofNullable(aiAutoDescription) + fun aiTasks(): Optional = Optional.ofNullable(aiTasks) + + fun savedExtension(): Optional = Optional.ofNullable(savedExtension) + fun isRemoveBg(): Boolean = removeBg != null fun isAutoTaggingExtension(): Boolean = autoTaggingExtension != null fun isAiAutoDescription(): Boolean = aiAutoDescription != null + fun isAiTasks(): Boolean = aiTasks != null + + fun isSavedExtension(): Boolean = savedExtension != null + fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") fun asAutoTaggingExtension(): AutoTaggingExtension = @@ -844,6 +890,10 @@ private constructor( fun asAiAutoDescription(): JsonValue = aiAutoDescription.getOrThrow("aiAutoDescription") + fun asAiTasks(): AiTasks = aiTasks.getOrThrow("aiTasks") + + fun asSavedExtension(): SavedExtension = savedExtension.getOrThrow("savedExtension") + fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = @@ -852,12 +902,14 @@ private constructor( autoTaggingExtension != null -> visitor.visitAutoTaggingExtension(autoTaggingExtension) aiAutoDescription != null -> visitor.visitAiAutoDescription(aiAutoDescription) + aiTasks != null -> visitor.visitAiTasks(aiTasks) + savedExtension != null -> visitor.visitSavedExtension(savedExtension) else -> visitor.unknown(_json) } private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent1 = apply { + fun validate(): UnnamedSchemaWithArrayParent4 = apply { if (validated) { return@apply } @@ -883,6 +935,14 @@ private constructor( } } } + + override fun visitAiTasks(aiTasks: AiTasks) { + aiTasks.validate() + } + + override fun visitSavedExtension(savedExtension: SavedExtension) { + savedExtension.validate() + } } ) validated = true @@ -918,6 +978,11 @@ private constructor( else 0 } + override fun visitAiTasks(aiTasks: AiTasks) = aiTasks.validity() + + override fun visitSavedExtension(savedExtension: SavedExtension) = + savedExtension.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -927,45 +992,63 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent1 && + return other is UnnamedSchemaWithArrayParent4 && removeBg == other.removeBg && autoTaggingExtension == other.autoTaggingExtension && - aiAutoDescription == other.aiAutoDescription + aiAutoDescription == other.aiAutoDescription && + aiTasks == other.aiTasks && + savedExtension == other.savedExtension } override fun hashCode(): Int = - Objects.hash(removeBg, autoTaggingExtension, aiAutoDescription) + Objects.hash( + removeBg, + autoTaggingExtension, + aiAutoDescription, + aiTasks, + savedExtension, + ) override fun toString(): String = when { - removeBg != null -> "UnnamedSchemaWithArrayParent1{removeBg=$removeBg}" + removeBg != null -> "UnnamedSchemaWithArrayParent4{removeBg=$removeBg}" autoTaggingExtension != null -> - "UnnamedSchemaWithArrayParent1{autoTaggingExtension=$autoTaggingExtension}" + "UnnamedSchemaWithArrayParent4{autoTaggingExtension=$autoTaggingExtension}" aiAutoDescription != null -> - "UnnamedSchemaWithArrayParent1{aiAutoDescription=$aiAutoDescription}" - _json != null -> "UnnamedSchemaWithArrayParent1{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") + "UnnamedSchemaWithArrayParent4{aiAutoDescription=$aiAutoDescription}" + aiTasks != null -> "UnnamedSchemaWithArrayParent4{aiTasks=$aiTasks}" + savedExtension != null -> + "UnnamedSchemaWithArrayParent4{savedExtension=$savedExtension}" + _json != null -> "UnnamedSchemaWithArrayParent4{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent4") } companion object { @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = - UnnamedSchemaWithArrayParent1(removeBg = removeBg) + UnnamedSchemaWithArrayParent4(removeBg = removeBg) @JvmStatic fun ofAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension) = - UnnamedSchemaWithArrayParent1(autoTaggingExtension = autoTaggingExtension) + UnnamedSchemaWithArrayParent4(autoTaggingExtension = autoTaggingExtension) @JvmStatic fun ofAiAutoDescription() = - UnnamedSchemaWithArrayParent1( + UnnamedSchemaWithArrayParent4( aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) ) + + @JvmStatic + fun ofAiTasks(aiTasks: AiTasks) = UnnamedSchemaWithArrayParent4(aiTasks = aiTasks) + + @JvmStatic + fun ofSavedExtension(savedExtension: SavedExtension) = + UnnamedSchemaWithArrayParent4(savedExtension = savedExtension) } /** - * An interface that defines how to map each variant of [UnnamedSchemaWithArrayParent1] + * An interface that defines how to map each variant of [UnnamedSchemaWithArrayParent4] * to a value of type [T]. */ interface Visitor { @@ -976,11 +1059,15 @@ private constructor( fun visitAiAutoDescription(aiAutoDescription: JsonValue): T + fun visitAiTasks(aiTasks: AiTasks): T + + fun visitSavedExtension(savedExtension: SavedExtension): T + /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent1] to a value of type + * Maps an unknown variant of [UnnamedSchemaWithArrayParent4] to a value of type * [T]. * - * An instance of [UnnamedSchemaWithArrayParent1] can contain an unknown variant if + * An instance of [UnnamedSchemaWithArrayParent4] can contain an unknown variant if * it was deserialized from data that doesn't match any known variant. For example, * if the SDK is on an older version than the API, then the API may respond with new * variants that the SDK is unaware of. @@ -989,54 +1076,64 @@ private constructor( */ fun unknown(json: JsonValue?): T { throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent1: $json" + "Unknown UnnamedSchemaWithArrayParent4: $json" ) } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent1::class + BaseDeserializer( + UnnamedSchemaWithArrayParent4::class ) { override fun ObjectCodec.deserialize( node: JsonNode - ): UnnamedSchemaWithArrayParent1 { + ): UnnamedSchemaWithArrayParent4 { val json = JsonValue.fromJsonNode(node) val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() when (name) { "remove-bg" -> { return tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent1(removeBg = it, _json = json) - } ?: UnnamedSchemaWithArrayParent1(_json = json) + UnnamedSchemaWithArrayParent4(removeBg = it, _json = json) + } ?: UnnamedSchemaWithArrayParent4(_json = json) } "ai-auto-description" -> { return tryDeserialize(node, jacksonTypeRef()) ?.let { - UnnamedSchemaWithArrayParent1( + UnnamedSchemaWithArrayParent4( aiAutoDescription = it, _json = json, ) } ?.takeIf { it.isValid() } - ?: UnnamedSchemaWithArrayParent1(_json = json) + ?: UnnamedSchemaWithArrayParent4(_json = json) + } + "ai-tasks" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent4(aiTasks = it, _json = json) + } ?: UnnamedSchemaWithArrayParent4(_json = json) + } + "saved-extension" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + UnnamedSchemaWithArrayParent4(savedExtension = it, _json = json) + } ?: UnnamedSchemaWithArrayParent4(_json = json) } } return tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent1(autoTaggingExtension = it, _json = json) - } ?: UnnamedSchemaWithArrayParent1(_json = json) + UnnamedSchemaWithArrayParent4(autoTaggingExtension = it, _json = json) + } ?: UnnamedSchemaWithArrayParent4(_json = json) } } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent1::class + BaseSerializer( + UnnamedSchemaWithArrayParent4::class ) { override fun serialize( - value: UnnamedSchemaWithArrayParent1, + value: UnnamedSchemaWithArrayParent4, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -1046,8 +1143,10 @@ private constructor( generator.writeObject(value.autoTaggingExtension) value.aiAutoDescription != null -> generator.writeObject(value.aiAutoDescription) + value.aiTasks != null -> generator.writeObject(value.aiTasks) + value.savedExtension != null -> generator.writeObject(value.savedExtension) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent1") + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent4") } } } @@ -1941,6 +2040,6059 @@ private constructor( override fun toString() = "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" } + + class AiTasks + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonValue, + private val tasks: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("tasks") + @ExcludeMissing + tasks: JsonField> = JsonMissing.of(), + ) : this(name, tasks, mutableMapOf()) + + /** + * Specifies the AI tasks extension for automated image analysis using AI models. + * + * Expected to always return the following: + * ```java + * JsonValue.from("ai-tasks") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Array of task objects defining AI operations to perform on the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tasks(): List = tasks.getRequired("tasks") + + /** + * Returns the raw JSON value of [tasks]. + * + * Unlike [tasks], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tasks") @ExcludeMissing fun _tasks(): JsonField> = tasks + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AiTasks]. + * + * The following fields are required: + * ```java + * .tasks() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AiTasks]. */ + class Builder internal constructor() { + + private var name: JsonValue = JsonValue.from("ai-tasks") + private var tasks: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(aiTasks: AiTasks) = apply { + name = aiTasks.name + tasks = aiTasks.tasks.map { it.toMutableList() } + additionalProperties = aiTasks.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("ai-tasks") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** Array of task objects defining AI operations to perform on the asset. */ + fun tasks(tasks: List) = tasks(JsonField.of(tasks)) + + /** + * Sets [Builder.tasks] to an arbitrary JSON value. + * + * You should usually call [Builder.tasks] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun tasks(tasks: JsonField>) = apply { + this.tasks = tasks.map { it.toMutableList() } + } + + /** + * Adds a single [Task] to [tasks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTask(task: Task) = apply { + tasks = + (tasks ?: JsonField.of(mutableListOf())).also { + checkKnown("tasks", it).add(task) + } + } + + /** Alias for calling [addTask] with `Task.ofSelectTags(selectTags)`. */ + fun addTask(selectTags: Task.SelectTags) = + addTask(Task.ofSelectTags(selectTags)) + + /** Alias for calling [addTask] with `Task.ofSelectMetadata(selectMetadata)`. */ + fun addTask(selectMetadata: Task.SelectMetadata) = + addTask(Task.ofSelectMetadata(selectMetadata)) + + /** Alias for calling [addTask] with `Task.ofYesNo(yesNo)`. */ + fun addTask(yesNo: Task.YesNo) = addTask(Task.ofYesNo(yesNo)) + + /** + * Alias for calling [addTask] with the following: + * ```java + * Task.YesNo.builder() + * .instruction(instruction) + * .build() + * ``` + */ + fun addYesNoTask(instruction: String) = + addTask(Task.YesNo.builder().instruction(instruction).build()) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AiTasks]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tasks() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AiTasks = + AiTasks( + name, + checkRequired("tasks", tasks).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AiTasks = apply { + if (validated) { + return@apply + } + + _name().let { + if (it != JsonValue.from("ai-tasks")) { + throw ImageKitInvalidDataException("'name' is invalid, received $it") + } + } + tasks().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + name.let { if (it == JsonValue.from("ai-tasks")) 1 else 0 } + + (tasks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + @JsonDeserialize(using = Task.Deserializer::class) + @JsonSerialize(using = Task.Serializer::class) + class Task + private constructor( + private val selectTags: SelectTags? = null, + private val selectMetadata: SelectMetadata? = null, + private val yesNo: YesNo? = null, + private val _json: JsonValue? = null, + ) { + + fun selectTags(): Optional = Optional.ofNullable(selectTags) + + fun selectMetadata(): Optional = + Optional.ofNullable(selectMetadata) + + fun yesNo(): Optional = Optional.ofNullable(yesNo) + + fun isSelectTags(): Boolean = selectTags != null + + fun isSelectMetadata(): Boolean = selectMetadata != null + + fun isYesNo(): Boolean = yesNo != null + + fun asSelectTags(): SelectTags = selectTags.getOrThrow("selectTags") + + fun asSelectMetadata(): SelectMetadata = + selectMetadata.getOrThrow("selectMetadata") + + fun asYesNo(): YesNo = yesNo.getOrThrow("yesNo") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + selectTags != null -> visitor.visitSelectTags(selectTags) + selectMetadata != null -> visitor.visitSelectMetadata(selectMetadata) + yesNo != null -> visitor.visitYesNo(yesNo) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Task = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitSelectTags(selectTags: SelectTags) { + selectTags.validate() + } + + override fun visitSelectMetadata(selectMetadata: SelectMetadata) { + selectMetadata.validate() + } + + override fun visitYesNo(yesNo: YesNo) { + yesNo.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitSelectTags(selectTags: SelectTags) = + selectTags.validity() + + override fun visitSelectMetadata(selectMetadata: SelectMetadata) = + selectMetadata.validity() + + override fun visitYesNo(yesNo: YesNo) = yesNo.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Task && + selectTags == other.selectTags && + selectMetadata == other.selectMetadata && + yesNo == other.yesNo + } + + override fun hashCode(): Int = Objects.hash(selectTags, selectMetadata, yesNo) + + override fun toString(): String = + when { + selectTags != null -> "Task{selectTags=$selectTags}" + selectMetadata != null -> "Task{selectMetadata=$selectMetadata}" + yesNo != null -> "Task{yesNo=$yesNo}" + _json != null -> "Task{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Task") + } + + companion object { + + @JvmStatic + fun ofSelectTags(selectTags: SelectTags) = Task(selectTags = selectTags) + + @JvmStatic + fun ofSelectMetadata(selectMetadata: SelectMetadata) = + Task(selectMetadata = selectMetadata) + + @JvmStatic fun ofYesNo(yesNo: YesNo) = Task(yesNo = yesNo) + } + + /** + * An interface that defines how to map each variant of [Task] to a value of + * type [T]. + */ + interface Visitor { + + fun visitSelectTags(selectTags: SelectTags): T + + fun visitSelectMetadata(selectMetadata: SelectMetadata): T + + fun visitYesNo(yesNo: YesNo): T + + /** + * Maps an unknown variant of [Task] to a value of type [T]. + * + * An instance of [Task] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the API may respond + * with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Task: $json") + } + } + + internal class Deserializer : BaseDeserializer(Task::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Task { + val json = JsonValue.fromJsonNode(node) + val type = + json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "select_tags" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Task(selectTags = it, _json = json) + } ?: Task(_json = json) + } + "select_metadata" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Task(selectMetadata = it, _json = json) } + ?: Task(_json = json) + } + "yes_no" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Task(yesNo = it, _json = json) + } ?: Task(_json = json) + } + } + + return Task(_json = json) + } + } + + internal class Serializer : BaseSerializer(Task::class) { + + override fun serialize( + value: Task, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.selectTags != null -> generator.writeObject(value.selectTags) + value.selectMetadata != null -> + generator.writeObject(value.selectMetadata) + value.yesNo != null -> generator.writeObject(value.yesNo) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Task") + } + } + } + + class SelectTags + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val instruction: JsonField, + private val type: JsonValue, + private val vocabulary: JsonField>, + private val maxSelections: JsonField, + private val minSelections: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("instruction") + @ExcludeMissing + instruction: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + @JsonProperty("vocabulary") + @ExcludeMissing + vocabulary: JsonField> = JsonMissing.of(), + @JsonProperty("max_selections") + @ExcludeMissing + maxSelections: JsonField = JsonMissing.of(), + @JsonProperty("min_selections") + @ExcludeMissing + minSelections: JsonField = JsonMissing.of(), + ) : this( + instruction, + type, + vocabulary, + maxSelections, + minSelections, + mutableMapOf(), + ) + + /** + * The question or instruction for the AI to analyze the image. + * + * @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 instruction(): String = instruction.getRequired("instruction") + + /** + * Task type that analyzes the image and adds matching tags from a + * vocabulary. + * + * Expected to always return the following: + * ```java + * JsonValue.from("select_tags") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Array of possible tag values. Combined length of all strings must not + * exceed 500 characters. Cannot contain the `%` character. + * + * @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 vocabulary(): List = vocabulary.getRequired("vocabulary") + + /** + * Maximum number of tags to select from the vocabulary. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun maxSelections(): Optional = + maxSelections.getOptional("max_selections") + + /** + * Minimum number of tags to select from the vocabulary. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun minSelections(): Optional = + minSelections.getOptional("min_selections") + + /** + * Returns the raw JSON value of [instruction]. + * + * Unlike [instruction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("instruction") + @ExcludeMissing + fun _instruction(): JsonField = instruction + + /** + * Returns the raw JSON value of [vocabulary]. + * + * Unlike [vocabulary], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("vocabulary") + @ExcludeMissing + fun _vocabulary(): JsonField> = vocabulary + + /** + * Returns the raw JSON value of [maxSelections]. + * + * Unlike [maxSelections], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("max_selections") + @ExcludeMissing + fun _maxSelections(): JsonField = maxSelections + + /** + * Returns the raw JSON value of [minSelections]. + * + * Unlike [minSelections], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("min_selections") + @ExcludeMissing + fun _minSelections(): JsonField = minSelections + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SelectTags]. + * + * The following fields are required: + * ```java + * .instruction() + * .vocabulary() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SelectTags]. */ + class Builder internal constructor() { + + private var instruction: JsonField? = null + private var type: JsonValue = JsonValue.from("select_tags") + private var vocabulary: JsonField>? = null + private var maxSelections: JsonField = JsonMissing.of() + private var minSelections: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(selectTags: SelectTags) = apply { + instruction = selectTags.instruction + type = selectTags.type + vocabulary = selectTags.vocabulary.map { it.toMutableList() } + maxSelections = selectTags.maxSelections + minSelections = selectTags.minSelections + additionalProperties = + selectTags.additionalProperties.toMutableMap() + } + + /** The question or instruction for the AI to analyze the image. */ + fun instruction(instruction: String) = + instruction(JsonField.of(instruction)) + + /** + * Sets [Builder.instruction] to an arbitrary JSON value. + * + * You should usually call [Builder.instruction] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun instruction(instruction: JsonField) = apply { + this.instruction = instruction + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("select_tags") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Array of possible tag values. Combined length of all strings must not + * exceed 500 characters. Cannot contain the `%` character. + */ + fun vocabulary(vocabulary: List) = + vocabulary(JsonField.of(vocabulary)) + + /** + * Sets [Builder.vocabulary] to an arbitrary JSON value. + * + * You should usually call [Builder.vocabulary] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun vocabulary(vocabulary: JsonField>) = apply { + this.vocabulary = vocabulary.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.vocabulary]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addVocabulary(vocabulary: String) = apply { + this.vocabulary = + (this.vocabulary ?: JsonField.of(mutableListOf())).also { + checkKnown("vocabulary", it).add(vocabulary) + } + } + + /** Maximum number of tags to select from the vocabulary. */ + fun maxSelections(maxSelections: Long) = + maxSelections(JsonField.of(maxSelections)) + + /** + * Sets [Builder.maxSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.maxSelections] with a well-typed + * [Long] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun maxSelections(maxSelections: JsonField) = apply { + this.maxSelections = maxSelections + } + + /** Minimum number of tags to select from the vocabulary. */ + fun minSelections(minSelections: Long) = + minSelections(JsonField.of(minSelections)) + + /** + * Sets [Builder.minSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.minSelections] with a well-typed + * [Long] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun minSelections(minSelections: JsonField) = apply { + this.minSelections = minSelections + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SelectTags]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .instruction() + * .vocabulary() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SelectTags = + SelectTags( + checkRequired("instruction", instruction), + type, + checkRequired("vocabulary", vocabulary).map { + it.toImmutable() + }, + maxSelections, + minSelections, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SelectTags = apply { + if (validated) { + return@apply + } + + instruction() + _type().let { + if (it != JsonValue.from("select_tags")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + vocabulary() + maxSelections() + minSelections() + 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 (instruction.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("select_tags")) 1 else 0 } + + (vocabulary.asKnown().getOrNull()?.size ?: 0) + + (if (maxSelections.asKnown().isPresent) 1 else 0) + + (if (minSelections.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SelectTags && + instruction == other.instruction && + type == other.type && + vocabulary == other.vocabulary && + maxSelections == other.maxSelections && + minSelections == other.minSelections && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + instruction, + type, + vocabulary, + maxSelections, + minSelections, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SelectTags{instruction=$instruction, type=$type, vocabulary=$vocabulary, maxSelections=$maxSelections, minSelections=$minSelections, additionalProperties=$additionalProperties}" + } + + class SelectMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val instruction: JsonField, + private val type: JsonValue, + private val maxSelections: JsonField, + private val minSelections: JsonField, + private val vocabulary: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of(), + @JsonProperty("instruction") + @ExcludeMissing + instruction: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + @JsonProperty("max_selections") + @ExcludeMissing + maxSelections: JsonField = JsonMissing.of(), + @JsonProperty("min_selections") + @ExcludeMissing + minSelections: JsonField = JsonMissing.of(), + @JsonProperty("vocabulary") + @ExcludeMissing + vocabulary: JsonField> = JsonMissing.of(), + ) : this( + field, + instruction, + type, + maxSelections, + minSelections, + vocabulary, + mutableMapOf(), + ) + + /** + * Name of the custom metadata field to set. The field must exist in 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 field(): String = field.getRequired("field") + + /** + * The question or instruction for the AI to analyze the image. + * + * @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 instruction(): String = instruction.getRequired("instruction") + + /** + * Task type that analyzes the image and sets a custom metadata field value + * from a vocabulary. + * + * Expected to always return the following: + * ```java + * JsonValue.from("select_metadata") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Maximum number of values to select from the vocabulary. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun maxSelections(): Optional = + maxSelections.getOptional("max_selections") + + /** + * Minimum number of values to select from the vocabulary. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun minSelections(): Optional = + minSelections.getOptional("min_selections") + + /** + * Array of possible values matching the custom metadata field type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun vocabulary(): Optional> = + vocabulary.getOptional("vocabulary") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [instruction]. + * + * Unlike [instruction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("instruction") + @ExcludeMissing + fun _instruction(): JsonField = instruction + + /** + * Returns the raw JSON value of [maxSelections]. + * + * Unlike [maxSelections], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("max_selections") + @ExcludeMissing + fun _maxSelections(): JsonField = maxSelections + + /** + * Returns the raw JSON value of [minSelections]. + * + * Unlike [minSelections], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("min_selections") + @ExcludeMissing + fun _minSelections(): JsonField = minSelections + + /** + * Returns the raw JSON value of [vocabulary]. + * + * Unlike [vocabulary], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("vocabulary") + @ExcludeMissing + fun _vocabulary(): JsonField> = vocabulary + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SelectMetadata]. + * + * The following fields are required: + * ```java + * .field() + * .instruction() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SelectMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var instruction: JsonField? = null + private var type: JsonValue = JsonValue.from("select_metadata") + private var maxSelections: JsonField = JsonMissing.of() + private var minSelections: JsonField = JsonMissing.of() + private var vocabulary: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(selectMetadata: SelectMetadata) = apply { + field = selectMetadata.field + instruction = selectMetadata.instruction + type = selectMetadata.type + maxSelections = selectMetadata.maxSelections + minSelections = selectMetadata.minSelections + vocabulary = selectMetadata.vocabulary.map { it.toMutableList() } + additionalProperties = + selectMetadata.additionalProperties.toMutableMap() + } + + /** + * Name of the custom metadata field to set. The field must exist in + * your account. + */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** The question or instruction for the AI to analyze the image. */ + fun instruction(instruction: String) = + instruction(JsonField.of(instruction)) + + /** + * Sets [Builder.instruction] to an arbitrary JSON value. + * + * You should usually call [Builder.instruction] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun instruction(instruction: JsonField) = apply { + this.instruction = instruction + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("select_metadata") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Maximum number of values to select from the vocabulary. */ + fun maxSelections(maxSelections: Long) = + maxSelections(JsonField.of(maxSelections)) + + /** + * Sets [Builder.maxSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.maxSelections] with a well-typed + * [Long] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun maxSelections(maxSelections: JsonField) = apply { + this.maxSelections = maxSelections + } + + /** Minimum number of values to select from the vocabulary. */ + fun minSelections(minSelections: Long) = + minSelections(JsonField.of(minSelections)) + + /** + * Sets [Builder.minSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.minSelections] with a well-typed + * [Long] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun minSelections(minSelections: JsonField) = apply { + this.minSelections = minSelections + } + + /** Array of possible values matching the custom metadata field type. */ + fun vocabulary(vocabulary: List) = + vocabulary(JsonField.of(vocabulary)) + + /** + * Sets [Builder.vocabulary] to an arbitrary JSON value. + * + * You should usually call [Builder.vocabulary] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun vocabulary(vocabulary: JsonField>) = apply { + this.vocabulary = vocabulary.map { it.toMutableList() } + } + + /** + * Adds a single [Vocabulary] to [Builder.vocabulary]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addVocabulary(vocabulary: Vocabulary) = apply { + this.vocabulary = + (this.vocabulary ?: JsonField.of(mutableListOf())).also { + checkKnown("vocabulary", it).add(vocabulary) + } + } + + /** + * Alias for calling [addVocabulary] with `Vocabulary.ofString(string)`. + */ + fun addVocabulary(string: String) = + addVocabulary(Vocabulary.ofString(string)) + + /** + * Alias for calling [addVocabulary] with `Vocabulary.ofNumber(number)`. + */ + fun addVocabulary(number: Double) = + addVocabulary(Vocabulary.ofNumber(number)) + + /** Alias for calling [addVocabulary] with `Vocabulary.ofBool(bool)`. */ + fun addVocabulary(bool: Boolean) = + addVocabulary(Vocabulary.ofBool(bool)) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SelectMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * .instruction() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SelectMetadata = + SelectMetadata( + checkRequired("field", field), + checkRequired("instruction", instruction), + type, + maxSelections, + minSelections, + (vocabulary ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SelectMetadata = apply { + if (validated) { + return@apply + } + + field() + instruction() + _type().let { + if (it != JsonValue.from("select_metadata")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + maxSelections() + minSelections() + vocabulary().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (field.asKnown().isPresent) 1 else 0) + + (if (instruction.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("select_metadata")) 1 else 0 } + + (if (maxSelections.asKnown().isPresent) 1 else 0) + + (if (minSelections.asKnown().isPresent) 1 else 0) + + (vocabulary.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + @JsonDeserialize(using = Vocabulary.Deserializer::class) + @JsonSerialize(using = Vocabulary.Serializer::class) + class Vocabulary + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Vocabulary = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Vocabulary && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> "Vocabulary{string=$string}" + number != null -> "Vocabulary{number=$number}" + bool != null -> "Vocabulary{bool=$bool}" + _json != null -> "Vocabulary{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Vocabulary") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = Vocabulary(string = string) + + @JvmStatic + fun ofNumber(number: Double) = Vocabulary(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Vocabulary(bool = bool) + } + + /** + * An interface that defines how to map each variant of [Vocabulary] to + * a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [Vocabulary] to a value of type [T]. + * + * An instance of [Vocabulary] can contain an unknown variant if it + * was deserialized from data that doesn't match any known variant. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Vocabulary: $json") + } + } + + internal class Deserializer : + BaseDeserializer(Vocabulary::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Vocabulary { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Vocabulary(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Vocabulary(number = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Vocabulary(bool = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. + // deserializing from object). + 0 -> Vocabulary(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, + // then use the first completely valid match, or simply the + // first match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(Vocabulary::class) { + + override fun serialize( + value: Vocabulary, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Vocabulary") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SelectMetadata && + field == other.field && + instruction == other.instruction && + type == other.type && + maxSelections == other.maxSelections && + minSelections == other.minSelections && + vocabulary == other.vocabulary && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + field, + instruction, + type, + maxSelections, + minSelections, + vocabulary, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SelectMetadata{field=$field, instruction=$instruction, type=$type, maxSelections=$maxSelections, minSelections=$minSelections, vocabulary=$vocabulary, additionalProperties=$additionalProperties}" + } + + class YesNo + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val instruction: JsonField, + private val type: JsonValue, + private val onNo: JsonField, + private val onUnknown: JsonField, + private val onYes: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("instruction") + @ExcludeMissing + instruction: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonValue = JsonMissing.of(), + @JsonProperty("on_no") + @ExcludeMissing + onNo: JsonField = JsonMissing.of(), + @JsonProperty("on_unknown") + @ExcludeMissing + onUnknown: JsonField = JsonMissing.of(), + @JsonProperty("on_yes") + @ExcludeMissing + onYes: JsonField = JsonMissing.of(), + ) : this(instruction, type, onNo, onUnknown, onYes, mutableMapOf()) + + /** + * The yes/no question for the AI to answer about the image. + * + * @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 instruction(): String = instruction.getRequired("instruction") + + /** + * Task type that asks a yes/no question and executes actions based on the + * answer. + * + * Expected to always return the following: + * ```java + * JsonValue.from("yes_no") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Actions to execute if the AI answers no. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun onNo(): Optional = onNo.getOptional("on_no") + + /** + * Actions to execute if the AI cannot determine the answer. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun onUnknown(): Optional = onUnknown.getOptional("on_unknown") + + /** + * Actions to execute if the AI answers yes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun onYes(): Optional = onYes.getOptional("on_yes") + + /** + * Returns the raw JSON value of [instruction]. + * + * Unlike [instruction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("instruction") + @ExcludeMissing + fun _instruction(): JsonField = instruction + + /** + * Returns the raw JSON value of [onNo]. + * + * Unlike [onNo], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("on_no") @ExcludeMissing fun _onNo(): JsonField = onNo + + /** + * Returns the raw JSON value of [onUnknown]. + * + * Unlike [onUnknown], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("on_unknown") + @ExcludeMissing + fun _onUnknown(): JsonField = onUnknown + + /** + * Returns the raw JSON value of [onYes]. + * + * Unlike [onYes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("on_yes") + @ExcludeMissing + fun _onYes(): JsonField = onYes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [YesNo]. + * + * The following fields are required: + * ```java + * .instruction() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [YesNo]. */ + class Builder internal constructor() { + + private var instruction: JsonField? = null + private var type: JsonValue = JsonValue.from("yes_no") + private var onNo: JsonField = JsonMissing.of() + private var onUnknown: JsonField = JsonMissing.of() + private var onYes: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(yesNo: YesNo) = apply { + instruction = yesNo.instruction + type = yesNo.type + onNo = yesNo.onNo + onUnknown = yesNo.onUnknown + onYes = yesNo.onYes + additionalProperties = yesNo.additionalProperties.toMutableMap() + } + + /** The yes/no question for the AI to answer about the image. */ + fun instruction(instruction: String) = + instruction(JsonField.of(instruction)) + + /** + * Sets [Builder.instruction] to an arbitrary JSON value. + * + * You should usually call [Builder.instruction] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun instruction(instruction: JsonField) = apply { + this.instruction = instruction + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field + * defaults to the following: + * ```java + * JsonValue.from("yes_no") + * ``` + * + * This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Actions to execute if the AI answers no. */ + fun onNo(onNo: OnNo) = onNo(JsonField.of(onNo)) + + /** + * Sets [Builder.onNo] to an arbitrary JSON value. + * + * You should usually call [Builder.onNo] with a well-typed [OnNo] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun onNo(onNo: JsonField) = apply { this.onNo = onNo } + + /** Actions to execute if the AI cannot determine the answer. */ + fun onUnknown(onUnknown: OnUnknown) = onUnknown(JsonField.of(onUnknown)) + + /** + * Sets [Builder.onUnknown] to an arbitrary JSON value. + * + * You should usually call [Builder.onUnknown] with a well-typed + * [OnUnknown] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun onUnknown(onUnknown: JsonField) = apply { + this.onUnknown = onUnknown + } + + /** Actions to execute if the AI answers yes. */ + fun onYes(onYes: OnYes) = onYes(JsonField.of(onYes)) + + /** + * Sets [Builder.onYes] to an arbitrary JSON value. + * + * You should usually call [Builder.onYes] with a well-typed [OnYes] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun onYes(onYes: JsonField) = apply { this.onYes = onYes } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [YesNo]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .instruction() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): YesNo = + YesNo( + checkRequired("instruction", instruction), + type, + onNo, + onUnknown, + onYes, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): YesNo = apply { + if (validated) { + return@apply + } + + instruction() + _type().let { + if (it != JsonValue.from("yes_no")) { + throw ImageKitInvalidDataException( + "'type' is invalid, received $it" + ) + } + } + onNo().ifPresent { it.validate() } + onUnknown().ifPresent { it.validate() } + onYes().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (instruction.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("yes_no")) 1 else 0 } + + (onNo.asKnown().getOrNull()?.validity() ?: 0) + + (onUnknown.asKnown().getOrNull()?.validity() ?: 0) + + (onYes.asKnown().getOrNull()?.validity() ?: 0) + + /** Actions to execute if the AI answers no. */ + class OnNo + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val addTags: JsonField>, + private val removeTags: JsonField>, + private val setMetadata: JsonField>, + private val unsetMetadata: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("add_tags") + @ExcludeMissing + addTags: JsonField> = JsonMissing.of(), + @JsonProperty("remove_tags") + @ExcludeMissing + removeTags: JsonField> = JsonMissing.of(), + @JsonProperty("set_metadata") + @ExcludeMissing + setMetadata: JsonField> = JsonMissing.of(), + @JsonProperty("unset_metadata") + @ExcludeMissing + unsetMetadata: JsonField> = JsonMissing.of(), + ) : this( + addTags, + removeTags, + setMetadata, + unsetMetadata, + mutableMapOf(), + ) + + /** + * Array of tag strings to add to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun addTags(): Optional> = addTags.getOptional("add_tags") + + /** + * Array of tag strings to remove from the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun removeTags(): Optional> = + removeTags.getOptional("remove_tags") + + /** + * Array of custom metadata field updates. + * + * @throws ImageKitInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun setMetadata(): Optional> = + setMetadata.getOptional("set_metadata") + + /** + * Array of custom metadata fields to remove. + * + * @throws ImageKitInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun unsetMetadata(): Optional> = + unsetMetadata.getOptional("unset_metadata") + + /** + * Returns the raw JSON value of [addTags]. + * + * Unlike [addTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_tags") + @ExcludeMissing + fun _addTags(): JsonField> = addTags + + /** + * Returns the raw JSON value of [removeTags]. + * + * Unlike [removeTags], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("remove_tags") + @ExcludeMissing + fun _removeTags(): JsonField> = removeTags + + /** + * Returns the raw JSON value of [setMetadata]. + * + * Unlike [setMetadata], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("set_metadata") + @ExcludeMissing + fun _setMetadata(): JsonField> = setMetadata + + /** + * Returns the raw JSON value of [unsetMetadata]. + * + * Unlike [unsetMetadata], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("unset_metadata") + @ExcludeMissing + fun _unsetMetadata(): JsonField> = unsetMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OnNo]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OnNo]. */ + class Builder internal constructor() { + + private var addTags: JsonField>? = null + private var removeTags: JsonField>? = null + private var setMetadata: JsonField>? = null + private var unsetMetadata: JsonField>? = + null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(onNo: OnNo) = apply { + addTags = onNo.addTags.map { it.toMutableList() } + removeTags = onNo.removeTags.map { it.toMutableList() } + setMetadata = onNo.setMetadata.map { it.toMutableList() } + unsetMetadata = onNo.unsetMetadata.map { it.toMutableList() } + additionalProperties = onNo.additionalProperties.toMutableMap() + } + + /** Array of tag strings to add to the asset. */ + fun addTags(addTags: List) = addTags(JsonField.of(addTags)) + + /** + * Sets [Builder.addTags] to an arbitrary JSON value. + * + * You should usually call [Builder.addTags] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun addTags(addTags: JsonField>) = apply { + this.addTags = addTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [addTags]. + * + * @throws IllegalStateException if the field was previously set to + * a non-list. + */ + fun addAddTag(addTag: String) = apply { + addTags = + (addTags ?: JsonField.of(mutableListOf())).also { + checkKnown("addTags", it).add(addTag) + } + } + + /** Array of tag strings to remove from the asset. */ + fun removeTags(removeTags: List) = + removeTags(JsonField.of(removeTags)) + + /** + * Sets [Builder.removeTags] to an arbitrary JSON value. + * + * You should usually call [Builder.removeTags] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun removeTags(removeTags: JsonField>) = apply { + this.removeTags = removeTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [removeTags]. + * + * @throws IllegalStateException if the field was previously set to + * a non-list. + */ + fun addRemoveTag(removeTag: String) = apply { + removeTags = + (removeTags ?: JsonField.of(mutableListOf())).also { + checkKnown("removeTags", it).add(removeTag) + } + } + + /** Array of custom metadata field updates. */ + fun setMetadata(setMetadata: List) = + setMetadata(JsonField.of(setMetadata)) + + /** + * Sets [Builder.setMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.setMetadata] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun setMetadata(setMetadata: JsonField>) = apply { + this.setMetadata = setMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [SetMetadata] to [Builder.setMetadata]. + * + * @throws IllegalStateException if the field was previously set to + * a non-list. + */ + fun addSetMetadata(setMetadata: SetMetadata) = apply { + this.setMetadata = + (this.setMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("setMetadata", it).add(setMetadata) + } + } + + /** Array of custom metadata fields to remove. */ + fun unsetMetadata(unsetMetadata: List) = + unsetMetadata(JsonField.of(unsetMetadata)) + + /** + * Sets [Builder.unsetMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.unsetMetadata] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun unsetMetadata(unsetMetadata: JsonField>) = + apply { + this.unsetMetadata = + unsetMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. + * + * @throws IllegalStateException if the field was previously set to + * a non-list. + */ + fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { + this.unsetMetadata = + (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("unsetMetadata", it).add(unsetMetadata) + } + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OnNo]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): OnNo = + OnNo( + (addTags ?: JsonMissing.of()).map { it.toImmutable() }, + (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, + (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + (unsetMetadata ?: JsonMissing.of()).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OnNo = apply { + if (validated) { + return@apply + } + + addTags() + removeTags() + setMetadata().ifPresent { it.forEach { it.validate() } } + unsetMetadata().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (addTags.asKnown().getOrNull()?.size ?: 0) + + (removeTags.asKnown().getOrNull()?.size ?: 0) + + (setMetadata.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (unsetMetadata.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + class SetMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this(field, value, mutableMapOf()) + + /** + * Name of the custom metadata field to set. + * + * @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 field(): String = field.getRequired("field") + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + * + * @throws ImageKitInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun value(): Value = value.getRequired("value") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(setMetadata: SetMetadata) = apply { + field = setMetadata.field + value = setMetadata.value + additionalProperties = + setMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to set. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { + this.field = field + } + + /** + * Value to set for the custom metadata field. The value type + * should match the custom metadata field type. + */ + fun value(value: Value) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed + * [Value] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { + this.value = value + } + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ + fun valueOfMixed( + mixed: List + ) = value(Value.ofMixed(mixed)) + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SetMetadata]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SetMetadata = + SetMetadata( + checkRequired("field", field), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SetMetadata = apply { + if (validated) { + return@apply + } + + field() + value().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (field.asKnown().isPresent) 1 else 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + */ + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val mixed: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun mixed(): Optional> = + Optional.ofNullable(mixed) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isMixed(): Boolean = mixed != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asMixed(): List = + mixed.getOrThrow("mixed") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + mixed != null -> visitor.visitMixed(mixed) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitMixed( + mixed: List + ) { + mixed.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are + * contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitMixed( + mixed: List + ) = mixed.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + string == other.string && + number == other.number && + bool == other.bool && + mixed == other.mixed + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool, mixed) + + override fun toString(): String = + when { + string != null -> "Value{string=$string}" + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + mixed != null -> "Value{mixed=$mixed}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = Value(string = string) + + @JvmStatic + fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic + fun ofMixed(mixed: List) = + Value(mixed = mixed.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Value] + * to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitMixed( + mixed: List + ): T + + /** + * Maps an unknown variant of [Value] to a value of type + * [T]. + * + * An instance of [Value] can contain an unknown variant if + * it was deserialized from data that doesn't match any + * known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown Value: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Value(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Value(number = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Value(bool = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef< + List< + UnnamedSchemaWithArrayParent5 + > + >(), + ) + ?.let { + Value(mixed = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is + // completely incompatible with all the possible + // variants (e.g. deserializing from object). + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest + // validity, then use the first completely valid + // match, or simply the first match if none are + // completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> + generator.writeObject(value.bool) + value.mixed != null -> + generator.writeObject(value.mixed) + value._json != null -> + generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + + @JsonDeserialize( + using = UnnamedSchemaWithArrayParent5.Deserializer::class + ) + @JsonSerialize( + using = UnnamedSchemaWithArrayParent5.Serializer::class + ) + class UnnamedSchemaWithArrayParent5 + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = + Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent5 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent5 && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> + "UnnamedSchemaWithArrayParent5{string=$string}" + number != null -> + "UnnamedSchemaWithArrayParent5{number=$number}" + bool != null -> + "UnnamedSchemaWithArrayParent5{bool=$bool}" + _json != null -> + "UnnamedSchemaWithArrayParent5{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent5" + ) + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent5(string = string) + + @JvmStatic + fun ofNumber(number: Double) = + UnnamedSchemaWithArrayParent5(number = number) + + @JvmStatic + fun ofBool(bool: Boolean) = + UnnamedSchemaWithArrayParent5(bool = bool) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent5] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of + * [UnnamedSchemaWithArrayParent5] to a value of type + * [T]. + * + * An instance of [UnnamedSchemaWithArrayParent5] can + * contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the + * API, then the API may respond with new variants that + * the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent5: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent5::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent5 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent5( + string = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent5( + number = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent5( + bool = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing + // is completely incompatible with all the + // possible variants (e.g. deserializing from + // object). + 0 -> UnnamedSchemaWithArrayParent5(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the + // highest validity, then use the first + // completely valid match, or simply the first + // match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent5::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent5, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> + generator.writeObject(value.bool) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent5" + ) + } + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SetMetadata && + field == other.field && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" + } + + class UnsetMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of() + ) : this(field, mutableMapOf()) + + /** + * Name of the custom metadata field to remove. + * + * @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 field(): String = field.getRequired("field") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnsetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnsetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unsetMetadata: UnsetMetadata) = apply { + field = unsetMetadata.field + additionalProperties = + unsetMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to remove. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { + this.field = field + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnsetMetadata]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .field() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnsetMetadata = + UnsetMetadata( + checkRequired("field", field), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnsetMetadata = apply { + if (validated) { + return@apply + } + + field() + 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 (field.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnsetMetadata && + field == other.field && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OnNo && + addTags == other.addTags && + removeTags == other.removeTags && + setMetadata == other.setMetadata && + unsetMetadata == other.unsetMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addTags, + removeTags, + setMetadata, + unsetMetadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OnNo{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" + } + + /** Actions to execute if the AI cannot determine the answer. */ + class OnUnknown + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val addTags: JsonField>, + private val removeTags: JsonField>, + private val setMetadata: JsonField>, + private val unsetMetadata: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("add_tags") + @ExcludeMissing + addTags: JsonField> = JsonMissing.of(), + @JsonProperty("remove_tags") + @ExcludeMissing + removeTags: JsonField> = JsonMissing.of(), + @JsonProperty("set_metadata") + @ExcludeMissing + setMetadata: JsonField> = JsonMissing.of(), + @JsonProperty("unset_metadata") + @ExcludeMissing + unsetMetadata: JsonField> = JsonMissing.of(), + ) : this( + addTags, + removeTags, + setMetadata, + unsetMetadata, + mutableMapOf(), + ) + + /** + * Array of tag strings to add to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun addTags(): Optional> = addTags.getOptional("add_tags") + + /** + * Array of tag strings to remove from the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun removeTags(): Optional> = + removeTags.getOptional("remove_tags") + + /** + * Array of custom metadata field updates. + * + * @throws ImageKitInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun setMetadata(): Optional> = + setMetadata.getOptional("set_metadata") + + /** + * Array of custom metadata fields to remove. + * + * @throws ImageKitInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun unsetMetadata(): Optional> = + unsetMetadata.getOptional("unset_metadata") + + /** + * Returns the raw JSON value of [addTags]. + * + * Unlike [addTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_tags") + @ExcludeMissing + fun _addTags(): JsonField> = addTags + + /** + * Returns the raw JSON value of [removeTags]. + * + * Unlike [removeTags], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("remove_tags") + @ExcludeMissing + fun _removeTags(): JsonField> = removeTags + + /** + * Returns the raw JSON value of [setMetadata]. + * + * Unlike [setMetadata], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("set_metadata") + @ExcludeMissing + fun _setMetadata(): JsonField> = setMetadata + + /** + * Returns the raw JSON value of [unsetMetadata]. + * + * Unlike [unsetMetadata], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("unset_metadata") + @ExcludeMissing + fun _unsetMetadata(): JsonField> = unsetMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [OnUnknown]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OnUnknown]. */ + class Builder internal constructor() { + + private var addTags: JsonField>? = null + private var removeTags: JsonField>? = null + private var setMetadata: JsonField>? = null + private var unsetMetadata: JsonField>? = + null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(onUnknown: OnUnknown) = apply { + addTags = onUnknown.addTags.map { it.toMutableList() } + removeTags = onUnknown.removeTags.map { it.toMutableList() } + setMetadata = onUnknown.setMetadata.map { it.toMutableList() } + unsetMetadata = + onUnknown.unsetMetadata.map { it.toMutableList() } + additionalProperties = + onUnknown.additionalProperties.toMutableMap() + } + + /** Array of tag strings to add to the asset. */ + fun addTags(addTags: List) = addTags(JsonField.of(addTags)) + + /** + * Sets [Builder.addTags] to an arbitrary JSON value. + * + * You should usually call [Builder.addTags] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun addTags(addTags: JsonField>) = apply { + this.addTags = addTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [addTags]. + * + * @throws IllegalStateException if the field was previously set to + * a non-list. + */ + fun addAddTag(addTag: String) = apply { + addTags = + (addTags ?: JsonField.of(mutableListOf())).also { + checkKnown("addTags", it).add(addTag) + } + } + + /** Array of tag strings to remove from the asset. */ + fun removeTags(removeTags: List) = + removeTags(JsonField.of(removeTags)) + + /** + * Sets [Builder.removeTags] to an arbitrary JSON value. + * + * You should usually call [Builder.removeTags] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun removeTags(removeTags: JsonField>) = apply { + this.removeTags = removeTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [removeTags]. + * + * @throws IllegalStateException if the field was previously set to + * a non-list. + */ + fun addRemoveTag(removeTag: String) = apply { + removeTags = + (removeTags ?: JsonField.of(mutableListOf())).also { + checkKnown("removeTags", it).add(removeTag) + } + } + + /** Array of custom metadata field updates. */ + fun setMetadata(setMetadata: List) = + setMetadata(JsonField.of(setMetadata)) + + /** + * Sets [Builder.setMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.setMetadata] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun setMetadata(setMetadata: JsonField>) = apply { + this.setMetadata = setMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [SetMetadata] to [Builder.setMetadata]. + * + * @throws IllegalStateException if the field was previously set to + * a non-list. + */ + fun addSetMetadata(setMetadata: SetMetadata) = apply { + this.setMetadata = + (this.setMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("setMetadata", it).add(setMetadata) + } + } + + /** Array of custom metadata fields to remove. */ + fun unsetMetadata(unsetMetadata: List) = + unsetMetadata(JsonField.of(unsetMetadata)) + + /** + * Sets [Builder.unsetMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.unsetMetadata] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun unsetMetadata(unsetMetadata: JsonField>) = + apply { + this.unsetMetadata = + unsetMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. + * + * @throws IllegalStateException if the field was previously set to + * a non-list. + */ + fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { + this.unsetMetadata = + (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("unsetMetadata", it).add(unsetMetadata) + } + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OnUnknown]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): OnUnknown = + OnUnknown( + (addTags ?: JsonMissing.of()).map { it.toImmutable() }, + (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, + (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + (unsetMetadata ?: JsonMissing.of()).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OnUnknown = apply { + if (validated) { + return@apply + } + + addTags() + removeTags() + setMetadata().ifPresent { it.forEach { it.validate() } } + unsetMetadata().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (addTags.asKnown().getOrNull()?.size ?: 0) + + (removeTags.asKnown().getOrNull()?.size ?: 0) + + (setMetadata.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (unsetMetadata.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + class SetMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this(field, value, mutableMapOf()) + + /** + * Name of the custom metadata field to set. + * + * @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 field(): String = field.getRequired("field") + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + * + * @throws ImageKitInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun value(): Value = value.getRequired("value") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(setMetadata: SetMetadata) = apply { + field = setMetadata.field + value = setMetadata.value + additionalProperties = + setMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to set. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { + this.field = field + } + + /** + * Value to set for the custom metadata field. The value type + * should match the custom metadata field type. + */ + fun value(value: Value) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed + * [Value] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { + this.value = value + } + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ + fun valueOfMixed( + mixed: List + ) = value(Value.ofMixed(mixed)) + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SetMetadata]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SetMetadata = + SetMetadata( + checkRequired("field", field), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SetMetadata = apply { + if (validated) { + return@apply + } + + field() + value().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (field.asKnown().isPresent) 1 else 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + */ + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val mixed: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun mixed(): Optional> = + Optional.ofNullable(mixed) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isMixed(): Boolean = mixed != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asMixed(): List = + mixed.getOrThrow("mixed") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + mixed != null -> visitor.visitMixed(mixed) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitMixed( + mixed: List + ) { + mixed.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are + * contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitMixed( + mixed: List + ) = mixed.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + string == other.string && + number == other.number && + bool == other.bool && + mixed == other.mixed + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool, mixed) + + override fun toString(): String = + when { + string != null -> "Value{string=$string}" + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + mixed != null -> "Value{mixed=$mixed}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = Value(string = string) + + @JvmStatic + fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic + fun ofMixed(mixed: List) = + Value(mixed = mixed.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Value] + * to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitMixed( + mixed: List + ): T + + /** + * Maps an unknown variant of [Value] to a value of type + * [T]. + * + * An instance of [Value] can contain an unknown variant if + * it was deserialized from data that doesn't match any + * known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown Value: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Value(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Value(number = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Value(bool = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef< + List< + UnnamedSchemaWithArrayParent6 + > + >(), + ) + ?.let { + Value(mixed = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is + // completely incompatible with all the possible + // variants (e.g. deserializing from object). + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest + // validity, then use the first completely valid + // match, or simply the first match if none are + // completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> + generator.writeObject(value.bool) + value.mixed != null -> + generator.writeObject(value.mixed) + value._json != null -> + generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + + @JsonDeserialize( + using = UnnamedSchemaWithArrayParent6.Deserializer::class + ) + @JsonSerialize( + using = UnnamedSchemaWithArrayParent6.Serializer::class + ) + class UnnamedSchemaWithArrayParent6 + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = + Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent6 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent6 && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> + "UnnamedSchemaWithArrayParent6{string=$string}" + number != null -> + "UnnamedSchemaWithArrayParent6{number=$number}" + bool != null -> + "UnnamedSchemaWithArrayParent6{bool=$bool}" + _json != null -> + "UnnamedSchemaWithArrayParent6{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent6" + ) + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent6(string = string) + + @JvmStatic + fun ofNumber(number: Double) = + UnnamedSchemaWithArrayParent6(number = number) + + @JvmStatic + fun ofBool(bool: Boolean) = + UnnamedSchemaWithArrayParent6(bool = bool) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent6] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of + * [UnnamedSchemaWithArrayParent6] to a value of type + * [T]. + * + * An instance of [UnnamedSchemaWithArrayParent6] can + * contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the + * API, then the API may respond with new variants that + * the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent6: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent6::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent6 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent6( + string = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent6( + number = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent6( + bool = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing + // is completely incompatible with all the + // possible variants (e.g. deserializing from + // object). + 0 -> UnnamedSchemaWithArrayParent6(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the + // highest validity, then use the first + // completely valid match, or simply the first + // match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent6::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent6, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> + generator.writeObject(value.bool) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent6" + ) + } + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SetMetadata && + field == other.field && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" + } + + class UnsetMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of() + ) : this(field, mutableMapOf()) + + /** + * Name of the custom metadata field to remove. + * + * @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 field(): String = field.getRequired("field") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnsetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnsetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unsetMetadata: UnsetMetadata) = apply { + field = unsetMetadata.field + additionalProperties = + unsetMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to remove. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { + this.field = field + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnsetMetadata]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .field() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnsetMetadata = + UnsetMetadata( + checkRequired("field", field), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnsetMetadata = apply { + if (validated) { + return@apply + } + + field() + 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 (field.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnsetMetadata && + field == other.field && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OnUnknown && + addTags == other.addTags && + removeTags == other.removeTags && + setMetadata == other.setMetadata && + unsetMetadata == other.unsetMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addTags, + removeTags, + setMetadata, + unsetMetadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OnUnknown{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" + } + + /** Actions to execute if the AI answers yes. */ + class OnYes + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val addTags: JsonField>, + private val removeTags: JsonField>, + private val setMetadata: JsonField>, + private val unsetMetadata: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("add_tags") + @ExcludeMissing + addTags: JsonField> = JsonMissing.of(), + @JsonProperty("remove_tags") + @ExcludeMissing + removeTags: JsonField> = JsonMissing.of(), + @JsonProperty("set_metadata") + @ExcludeMissing + setMetadata: JsonField> = JsonMissing.of(), + @JsonProperty("unset_metadata") + @ExcludeMissing + unsetMetadata: JsonField> = JsonMissing.of(), + ) : this( + addTags, + removeTags, + setMetadata, + unsetMetadata, + mutableMapOf(), + ) + + /** + * Array of tag strings to add to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun addTags(): Optional> = addTags.getOptional("add_tags") + + /** + * Array of tag strings to remove from the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun removeTags(): Optional> = + removeTags.getOptional("remove_tags") + + /** + * Array of custom metadata field updates. + * + * @throws ImageKitInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun setMetadata(): Optional> = + setMetadata.getOptional("set_metadata") + + /** + * Array of custom metadata fields to remove. + * + * @throws ImageKitInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun unsetMetadata(): Optional> = + unsetMetadata.getOptional("unset_metadata") + + /** + * Returns the raw JSON value of [addTags]. + * + * Unlike [addTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_tags") + @ExcludeMissing + fun _addTags(): JsonField> = addTags + + /** + * Returns the raw JSON value of [removeTags]. + * + * Unlike [removeTags], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("remove_tags") + @ExcludeMissing + fun _removeTags(): JsonField> = removeTags + + /** + * Returns the raw JSON value of [setMetadata]. + * + * Unlike [setMetadata], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("set_metadata") + @ExcludeMissing + fun _setMetadata(): JsonField> = setMetadata + + /** + * Returns the raw JSON value of [unsetMetadata]. + * + * Unlike [unsetMetadata], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("unset_metadata") + @ExcludeMissing + fun _unsetMetadata(): JsonField> = unsetMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [OnYes]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OnYes]. */ + class Builder internal constructor() { + + private var addTags: JsonField>? = null + private var removeTags: JsonField>? = null + private var setMetadata: JsonField>? = null + private var unsetMetadata: JsonField>? = + null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(onYes: OnYes) = apply { + addTags = onYes.addTags.map { it.toMutableList() } + removeTags = onYes.removeTags.map { it.toMutableList() } + setMetadata = onYes.setMetadata.map { it.toMutableList() } + unsetMetadata = onYes.unsetMetadata.map { it.toMutableList() } + additionalProperties = onYes.additionalProperties.toMutableMap() + } + + /** Array of tag strings to add to the asset. */ + fun addTags(addTags: List) = addTags(JsonField.of(addTags)) + + /** + * Sets [Builder.addTags] to an arbitrary JSON value. + * + * You should usually call [Builder.addTags] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun addTags(addTags: JsonField>) = apply { + this.addTags = addTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [addTags]. + * + * @throws IllegalStateException if the field was previously set to + * a non-list. + */ + fun addAddTag(addTag: String) = apply { + addTags = + (addTags ?: JsonField.of(mutableListOf())).also { + checkKnown("addTags", it).add(addTag) + } + } + + /** Array of tag strings to remove from the asset. */ + fun removeTags(removeTags: List) = + removeTags(JsonField.of(removeTags)) + + /** + * Sets [Builder.removeTags] to an arbitrary JSON value. + * + * You should usually call [Builder.removeTags] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun removeTags(removeTags: JsonField>) = apply { + this.removeTags = removeTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [removeTags]. + * + * @throws IllegalStateException if the field was previously set to + * a non-list. + */ + fun addRemoveTag(removeTag: String) = apply { + removeTags = + (removeTags ?: JsonField.of(mutableListOf())).also { + checkKnown("removeTags", it).add(removeTag) + } + } + + /** Array of custom metadata field updates. */ + fun setMetadata(setMetadata: List) = + setMetadata(JsonField.of(setMetadata)) + + /** + * Sets [Builder.setMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.setMetadata] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun setMetadata(setMetadata: JsonField>) = apply { + this.setMetadata = setMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [SetMetadata] to [Builder.setMetadata]. + * + * @throws IllegalStateException if the field was previously set to + * a non-list. + */ + fun addSetMetadata(setMetadata: SetMetadata) = apply { + this.setMetadata = + (this.setMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("setMetadata", it).add(setMetadata) + } + } + + /** Array of custom metadata fields to remove. */ + fun unsetMetadata(unsetMetadata: List) = + unsetMetadata(JsonField.of(unsetMetadata)) + + /** + * Sets [Builder.unsetMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.unsetMetadata] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun unsetMetadata(unsetMetadata: JsonField>) = + apply { + this.unsetMetadata = + unsetMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. + * + * @throws IllegalStateException if the field was previously set to + * a non-list. + */ + fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { + this.unsetMetadata = + (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("unsetMetadata", it).add(unsetMetadata) + } + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OnYes]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): OnYes = + OnYes( + (addTags ?: JsonMissing.of()).map { it.toImmutable() }, + (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, + (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + (unsetMetadata ?: JsonMissing.of()).map { + it.toImmutable() + }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OnYes = apply { + if (validated) { + return@apply + } + + addTags() + removeTags() + setMetadata().ifPresent { it.forEach { it.validate() } } + unsetMetadata().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (addTags.asKnown().getOrNull()?.size ?: 0) + + (removeTags.asKnown().getOrNull()?.size ?: 0) + + (setMetadata.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (unsetMetadata.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + class SetMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this(field, value, mutableMapOf()) + + /** + * Name of the custom metadata field to set. + * + * @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 field(): String = field.getRequired("field") + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + * + * @throws ImageKitInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun value(): Value = value.getRequired("value") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(setMetadata: SetMetadata) = apply { + field = setMetadata.field + value = setMetadata.value + additionalProperties = + setMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to set. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { + this.field = field + } + + /** + * Value to set for the custom metadata field. The value type + * should match the custom metadata field type. + */ + fun value(value: Value) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed + * [Value] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { + this.value = value + } + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ + fun valueOfMixed( + mixed: List + ) = value(Value.ofMixed(mixed)) + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SetMetadata]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SetMetadata = + SetMetadata( + checkRequired("field", field), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SetMetadata = apply { + if (validated) { + return@apply + } + + field() + value().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (field.asKnown().isPresent) 1 else 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + */ + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val mixed: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun mixed(): Optional> = + Optional.ofNullable(mixed) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isMixed(): Boolean = mixed != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asMixed(): List = + mixed.getOrThrow("mixed") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + mixed != null -> visitor.visitMixed(mixed) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitMixed( + mixed: List + ) { + mixed.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are + * contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitMixed( + mixed: List + ) = mixed.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + string == other.string && + number == other.number && + bool == other.bool && + mixed == other.mixed + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool, mixed) + + override fun toString(): String = + when { + string != null -> "Value{string=$string}" + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + mixed != null -> "Value{mixed=$mixed}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = Value(string = string) + + @JvmStatic + fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic + fun ofMixed(mixed: List) = + Value(mixed = mixed.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Value] + * to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitMixed( + mixed: List + ): T + + /** + * Maps an unknown variant of [Value] to a value of type + * [T]. + * + * An instance of [Value] can contain an unknown variant if + * it was deserialized from data that doesn't match any + * known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown Value: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Value(string = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Value(number = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Value(bool = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef< + List< + UnnamedSchemaWithArrayParent7 + > + >(), + ) + ?.let { + Value(mixed = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is + // completely incompatible with all the possible + // variants (e.g. deserializing from object). + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest + // validity, then use the first completely valid + // match, or simply the first match if none are + // completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> + generator.writeObject(value.bool) + value.mixed != null -> + generator.writeObject(value.mixed) + value._json != null -> + generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + + @JsonDeserialize( + using = UnnamedSchemaWithArrayParent7.Deserializer::class + ) + @JsonSerialize( + using = UnnamedSchemaWithArrayParent7.Serializer::class + ) + class UnnamedSchemaWithArrayParent7 + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = + Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): UnnamedSchemaWithArrayParent7 = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnnamedSchemaWithArrayParent7 && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = + Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> + "UnnamedSchemaWithArrayParent7{string=$string}" + number != null -> + "UnnamedSchemaWithArrayParent7{number=$number}" + bool != null -> + "UnnamedSchemaWithArrayParent7{bool=$bool}" + _json != null -> + "UnnamedSchemaWithArrayParent7{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent7" + ) + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + UnnamedSchemaWithArrayParent7(string = string) + + @JvmStatic + fun ofNumber(number: Double) = + UnnamedSchemaWithArrayParent7(number = number) + + @JvmStatic + fun ofBool(bool: Boolean) = + UnnamedSchemaWithArrayParent7(bool = bool) + } + + /** + * An interface that defines how to map each variant of + * [UnnamedSchemaWithArrayParent7] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of + * [UnnamedSchemaWithArrayParent7] to a value of type + * [T]. + * + * An instance of [UnnamedSchemaWithArrayParent7] can + * contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the + * API, then the API may respond with new variants that + * the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown UnnamedSchemaWithArrayParent7: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + UnnamedSchemaWithArrayParent7::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): UnnamedSchemaWithArrayParent7 { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent7( + string = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent7( + number = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + UnnamedSchemaWithArrayParent7( + bool = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing + // is completely incompatible with all the + // possible variants (e.g. deserializing from + // object). + 0 -> UnnamedSchemaWithArrayParent7(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the + // highest validity, then use the first + // completely valid match, or simply the first + // match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + UnnamedSchemaWithArrayParent7::class + ) { + + override fun serialize( + value: UnnamedSchemaWithArrayParent7, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> + generator.writeObject(value.bool) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid UnnamedSchemaWithArrayParent7" + ) + } + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SetMetadata && + field == other.field && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" + } + + class UnsetMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of() + ) : this(field, mutableMapOf()) + + /** + * Name of the custom metadata field to remove. + * + * @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 field(): String = field.getRequired("field") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnsetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnsetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var additionalProperties: + MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unsetMetadata: UnsetMetadata) = apply { + field = unsetMetadata.field + additionalProperties = + unsetMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to remove. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed + * [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { + this.field = field + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = + apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnsetMetadata]. + * + * Further updates to this [Builder] will not mutate the + * returned instance. + * + * The following fields are required: + * ```java + * .field() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnsetMetadata = + UnsetMetadata( + checkRequired("field", field), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnsetMetadata = apply { + if (validated) { + return@apply + } + + field() + 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 (field.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnsetMetadata && + field == other.field && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OnYes && + addTags == other.addTags && + removeTags == other.removeTags && + setMetadata == other.setMetadata && + unsetMetadata == other.unsetMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addTags, + removeTags, + setMetadata, + unsetMetadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OnYes{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is YesNo && + instruction == other.instruction && + type == other.type && + onNo == other.onNo && + onUnknown == other.onUnknown && + onYes == other.onYes && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + instruction, + type, + onNo, + onUnknown, + onYes, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "YesNo{instruction=$instruction, type=$type, onNo=$onNo, onUnknown=$onUnknown, onYes=$onYes, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiTasks && + name == other.name && + tasks == other.tasks && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(name, tasks, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AiTasks{name=$name, tasks=$tasks, additionalProperties=$additionalProperties}" + } + + class SavedExtension + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val name: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + ) : this(id, name, mutableMapOf()) + + /** + * The unique ID of the saved extension to apply. + * + * @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") + + /** + * Indicates this is a reference to a saved extension. + * + * Expected to always return the following: + * ```java + * JsonValue.from("saved-extension") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SavedExtension]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SavedExtension]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var name: JsonValue = JsonValue.from("saved-extension") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(savedExtension: SavedExtension) = apply { + id = savedExtension.id + name = savedExtension.name + additionalProperties = savedExtension.additionalProperties.toMutableMap() + } + + /** The unique ID of the saved extension to apply. */ + 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 } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("saved-extension") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SavedExtension]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SavedExtension = + SavedExtension( + checkRequired("id", id), + name, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SavedExtension = apply { + if (validated) { + return@apply + } + + id() + _name().let { + if (it != JsonValue.from("saved-extension")) { + throw ImageKitInvalidDataException("'name' is invalid, received $it") + } + } + 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) + + name.let { if (it == JsonValue.from("saved-extension")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SavedExtension && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SavedExtension{id=$id, name=$name, additionalProperties=$additionalProperties}" + } } /** diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionCreateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionCreateParams.kt new file mode 100644 index 00000000..d9eebe0a --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionCreateParams.kt @@ -0,0 +1,637 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.savedextensions + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.ExtensionConfig +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * This API creates a new saved extension. Saved extensions allow you to save complex extension + * configurations (like AI tasks) and reuse them by referencing the ID in upload or update file + * APIs. + * + * **Saved extension limit** \ You can create a maximum of 100 saved extensions per account. + */ +class SavedExtensionCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Configuration object for an extension (base extensions only, not saved extension references). + * + * @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 config(): ExtensionConfig = body.config() + + /** + * Description of what the saved extension does. + * + * @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 description(): String = body.description() + + /** + * Name of the saved extension. + * + * @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() + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _config(): JsonField = body._config() + + /** + * 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 [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SavedExtensionCreateParams]. + * + * The following fields are required: + * ```java + * .config() + * .description() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SavedExtensionCreateParams]. */ + 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(savedExtensionCreateParams: SavedExtensionCreateParams) = apply { + body = savedExtensionCreateParams.body.toBuilder() + additionalHeaders = savedExtensionCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = savedExtensionCreateParams.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: + * - [config] + * - [description] + * - [name] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * Configuration object for an extension (base extensions only, not saved extension + * references). + */ + fun config(config: ExtensionConfig) = apply { body.config(config) } + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [ExtensionConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun config(config: JsonField) = apply { body.config(config) } + + /** Alias for calling [config] with `ExtensionConfig.ofRemoveBg(removeBg)`. */ + fun config(removeBg: ExtensionConfig.RemoveBg) = apply { body.config(removeBg) } + + /** + * Alias for calling [config] with + * `ExtensionConfig.ofAutoTaggingExtension(autoTaggingExtension)`. + */ + fun config(autoTaggingExtension: ExtensionConfig.AutoTaggingExtension) = apply { + body.config(autoTaggingExtension) + } + + /** Alias for calling [config] with `ExtensionConfig.ofAiAutoDescription()`. */ + fun configAiAutoDescription() = apply { body.configAiAutoDescription() } + + /** Alias for calling [config] with `ExtensionConfig.ofAiTasks(aiTasks)`. */ + fun config(aiTasks: ExtensionConfig.AiTasks) = apply { body.config(aiTasks) } + + /** + * Alias for calling [config] with the following: + * ```java + * ExtensionConfig.AiTasks.builder() + * .tasks(tasks) + * .build() + * ``` + */ + fun aiTasksConfig(tasks: List) = apply { + body.aiTasksConfig(tasks) + } + + /** Description of what the saved extension does. */ + 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) } + + /** Name of the saved extension. */ + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { body.name(name) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SavedExtensionCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .config() + * .description() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SavedExtensionCreateParams = + SavedExtensionCreateParams( + 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 config: JsonField, + private val description: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("config") + @ExcludeMissing + config: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(config, description, name, mutableMapOf()) + + /** + * Configuration object for an extension (base extensions only, not saved extension + * references). + * + * @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 config(): ExtensionConfig = config.getRequired("config") + + /** + * Description of what the saved extension does. + * + * @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 description(): String = description.getRequired("description") + + /** + * Name of the saved extension. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config + + /** + * 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 [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .config() + * .description() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var config: JsonField? = null + private var description: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + config = body.config + description = body.description + name = body.name + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * Configuration object for an extension (base extensions only, not saved extension + * references). + */ + fun config(config: ExtensionConfig) = config(JsonField.of(config)) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [ExtensionConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun config(config: JsonField) = apply { this.config = config } + + /** Alias for calling [config] with `ExtensionConfig.ofRemoveBg(removeBg)`. */ + fun config(removeBg: ExtensionConfig.RemoveBg) = + config(ExtensionConfig.ofRemoveBg(removeBg)) + + /** + * Alias for calling [config] with + * `ExtensionConfig.ofAutoTaggingExtension(autoTaggingExtension)`. + */ + fun config(autoTaggingExtension: ExtensionConfig.AutoTaggingExtension) = + config(ExtensionConfig.ofAutoTaggingExtension(autoTaggingExtension)) + + /** Alias for calling [config] with `ExtensionConfig.ofAiAutoDescription()`. */ + fun configAiAutoDescription() = config(ExtensionConfig.ofAiAutoDescription()) + + /** Alias for calling [config] with `ExtensionConfig.ofAiTasks(aiTasks)`. */ + fun config(aiTasks: ExtensionConfig.AiTasks) = + config(ExtensionConfig.ofAiTasks(aiTasks)) + + /** + * Alias for calling [config] with the following: + * ```java + * ExtensionConfig.AiTasks.builder() + * .tasks(tasks) + * .build() + * ``` + */ + fun aiTasksConfig(tasks: List) = + config(ExtensionConfig.AiTasks.builder().tasks(tasks).build()) + + /** Description of what the saved extension does. */ + 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 + } + + /** Name of the saved extension. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .config() + * .description() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("config", config), + checkRequired("description", description), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + config().validate() + description() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (config.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + config == other.config && + description == other.description && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(config, description, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{config=$config, description=$description, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SavedExtensionCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SavedExtensionCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionDeleteParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionDeleteParams.kt new file mode 100644 index 00000000..8c45c4a6 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionDeleteParams.kt @@ -0,0 +1,232 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.savedextensions + +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** This API deletes a saved extension permanently. */ +class SavedExtensionDeleteParams +private constructor( + private val id: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SavedExtensionDeleteParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [SavedExtensionDeleteParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SavedExtensionDeleteParams]. */ + 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(savedExtensionDeleteParams: SavedExtensionDeleteParams) = apply { + id = savedExtensionDeleteParams.id + additionalHeaders = savedExtensionDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = savedExtensionDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + savedExtensionDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [SavedExtensionDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SavedExtensionDeleteParams = + SavedExtensionDeleteParams( + 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 SavedExtensionDeleteParams && + 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() = + "SavedExtensionDeleteParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionGetParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionGetParams.kt new file mode 100644 index 00000000..ff235907 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionGetParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.savedextensions + +import com.imagekit.api.core.Params +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** This API returns details of a specific saved extension by ID. */ +class SavedExtensionGetParams +private constructor( + private val id: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SavedExtensionGetParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SavedExtensionGetParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SavedExtensionGetParams]. */ + 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(savedExtensionGetParams: SavedExtensionGetParams) = apply { + id = savedExtensionGetParams.id + additionalHeaders = savedExtensionGetParams.additionalHeaders.toBuilder() + additionalQueryParams = savedExtensionGetParams.additionalQueryParams.toBuilder() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SavedExtensionGetParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SavedExtensionGetParams = + SavedExtensionGetParams(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 SavedExtensionGetParams && + id == other.id && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(id, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SavedExtensionGetParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionListParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionListParams.kt new file mode 100644 index 00000000..34e4dbc2 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionListParams.kt @@ -0,0 +1,174 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.savedextensions + +import com.imagekit.api.core.Params +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import java.util.Objects + +/** + * This API returns an array of all saved extensions for your account. Saved extensions allow you to + * save complex extension configurations and reuse them by referencing them by ID in upload or + * update file APIs. + */ +class SavedExtensionListParams +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(): SavedExtensionListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SavedExtensionListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SavedExtensionListParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(savedExtensionListParams: SavedExtensionListParams) = apply { + additionalHeaders = savedExtensionListParams.additionalHeaders.toBuilder() + additionalQueryParams = savedExtensionListParams.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 [SavedExtensionListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SavedExtensionListParams = + SavedExtensionListParams(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 SavedExtensionListParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "SavedExtensionListParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionUpdateParams.kt new file mode 100644 index 00000000..5d368dca --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionUpdateParams.kt @@ -0,0 +1,613 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.savedextensions + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.Params +import com.imagekit.api.core.http.Headers +import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.ExtensionConfig +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * This API updates an existing saved extension. You can update the name, description, or config. + */ +class SavedExtensionUpdateParams +private constructor( + private val id: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** + * Configuration object for an extension (base extensions only, not saved extension references). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun config(): Optional = body.config() + + /** + * Updated description of the saved extension. + * + * @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() + + /** + * Updated name of the saved extension. + * + * @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() + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _config(): JsonField = body._config() + + /** + * 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 [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SavedExtensionUpdateParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [SavedExtensionUpdateParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SavedExtensionUpdateParams]. */ + 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(savedExtensionUpdateParams: SavedExtensionUpdateParams) = apply { + id = savedExtensionUpdateParams.id + body = savedExtensionUpdateParams.body.toBuilder() + additionalHeaders = savedExtensionUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = savedExtensionUpdateParams.additionalQueryParams.toBuilder() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [config] + * - [description] + * - [name] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * Configuration object for an extension (base extensions only, not saved extension + * references). + */ + fun config(config: ExtensionConfig) = apply { body.config(config) } + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [ExtensionConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun config(config: JsonField) = apply { body.config(config) } + + /** Alias for calling [config] with `ExtensionConfig.ofRemoveBg(removeBg)`. */ + fun config(removeBg: ExtensionConfig.RemoveBg) = apply { body.config(removeBg) } + + /** + * Alias for calling [config] with + * `ExtensionConfig.ofAutoTaggingExtension(autoTaggingExtension)`. + */ + fun config(autoTaggingExtension: ExtensionConfig.AutoTaggingExtension) = apply { + body.config(autoTaggingExtension) + } + + /** Alias for calling [config] with `ExtensionConfig.ofAiAutoDescription()`. */ + fun configAiAutoDescription() = apply { body.configAiAutoDescription() } + + /** Alias for calling [config] with `ExtensionConfig.ofAiTasks(aiTasks)`. */ + fun config(aiTasks: ExtensionConfig.AiTasks) = apply { body.config(aiTasks) } + + /** + * Alias for calling [config] with the following: + * ```java + * ExtensionConfig.AiTasks.builder() + * .tasks(tasks) + * .build() + * ``` + */ + fun aiTasksConfig(tasks: List) = apply { + body.aiTasksConfig(tasks) + } + + /** Updated description of the saved extension. */ + 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) } + + /** Updated name of the saved extension. */ + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { body.name(name) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SavedExtensionUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SavedExtensionUpdateParams = + SavedExtensionUpdateParams( + 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 config: JsonField, + private val description: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("config") + @ExcludeMissing + config: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(config, description, name, mutableMapOf()) + + /** + * Configuration object for an extension (base extensions only, not saved extension + * references). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun config(): Optional = config.getOptional("config") + + /** + * Updated description of the saved extension. + * + * @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") + + /** + * Updated name of the saved extension. + * + * @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") + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config + + /** + * 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 [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var config: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + config = body.config + description = body.description + name = body.name + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * Configuration object for an extension (base extensions only, not saved extension + * references). + */ + fun config(config: ExtensionConfig) = config(JsonField.of(config)) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [ExtensionConfig] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun config(config: JsonField) = apply { this.config = config } + + /** Alias for calling [config] with `ExtensionConfig.ofRemoveBg(removeBg)`. */ + fun config(removeBg: ExtensionConfig.RemoveBg) = + config(ExtensionConfig.ofRemoveBg(removeBg)) + + /** + * Alias for calling [config] with + * `ExtensionConfig.ofAutoTaggingExtension(autoTaggingExtension)`. + */ + fun config(autoTaggingExtension: ExtensionConfig.AutoTaggingExtension) = + config(ExtensionConfig.ofAutoTaggingExtension(autoTaggingExtension)) + + /** Alias for calling [config] with `ExtensionConfig.ofAiAutoDescription()`. */ + fun configAiAutoDescription() = config(ExtensionConfig.ofAiAutoDescription()) + + /** Alias for calling [config] with `ExtensionConfig.ofAiTasks(aiTasks)`. */ + fun config(aiTasks: ExtensionConfig.AiTasks) = + config(ExtensionConfig.ofAiTasks(aiTasks)) + + /** + * Alias for calling [config] with the following: + * ```java + * ExtensionConfig.AiTasks.builder() + * .tasks(tasks) + * .build() + * ``` + */ + fun aiTasksConfig(tasks: List) = + config(ExtensionConfig.AiTasks.builder().tasks(tasks).build()) + + /** Updated description of the saved extension. */ + 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 + } + + /** Updated name of the saved extension. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(config, description, name, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + config().ifPresent { it.validate() } + description() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (config.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + config == other.config && + description == other.description && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(config, description, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{config=$config, description=$description, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SavedExtensionUpdateParams && + 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() = + "SavedExtensionUpdateParams{id=$id, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsync.kt new file mode 100644 index 00000000..aad46996 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsync.kt @@ -0,0 +1,335 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.SavedExtension +import com.imagekit.api.models.savedextensions.SavedExtensionCreateParams +import com.imagekit.api.models.savedextensions.SavedExtensionDeleteParams +import com.imagekit.api.models.savedextensions.SavedExtensionGetParams +import com.imagekit.api.models.savedextensions.SavedExtensionListParams +import com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface SavedExtensionServiceAsync { + + /** + * 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): SavedExtensionServiceAsync + + /** + * This API creates a new saved extension. Saved extensions allow you to save complex extension + * configurations (like AI tasks) and reuse them by referencing the ID in upload or update file + * APIs. + * + * **Saved extension limit** \ You can create a maximum of 100 saved extensions per account. + */ + fun create(params: SavedExtensionCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SavedExtensionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * This API updates an existing saved extension. You can update the name, description, or + * config. + */ + fun update(id: String): CompletableFuture = + update(id, SavedExtensionUpdateParams.none()) + + /** @see update */ + fun update( + id: String, + params: SavedExtensionUpdateParams = SavedExtensionUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update( + id: String, + params: SavedExtensionUpdateParams = SavedExtensionUpdateParams.none(), + ): CompletableFuture = update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: SavedExtensionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see update */ + fun update(params: SavedExtensionUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update(id: String, requestOptions: RequestOptions): CompletableFuture = + update(id, SavedExtensionUpdateParams.none(), requestOptions) + + /** + * This API returns an array of all saved extensions for your account. Saved extensions allow + * you to save complex extension configurations and reuse them by referencing them by ID in + * upload or update file APIs. + */ + fun list(): CompletableFuture> = list(SavedExtensionListParams.none()) + + /** @see list */ + fun list( + params: SavedExtensionListParams = SavedExtensionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: SavedExtensionListParams = SavedExtensionListParams.none() + ): CompletableFuture> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture> = + list(SavedExtensionListParams.none(), requestOptions) + + /** This API deletes a saved extension permanently. */ + fun delete(id: String): CompletableFuture = delete(id, SavedExtensionDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: SavedExtensionDeleteParams = SavedExtensionDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: SavedExtensionDeleteParams = SavedExtensionDeleteParams.none(), + ): CompletableFuture = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: SavedExtensionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: SavedExtensionDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions): CompletableFuture = + delete(id, SavedExtensionDeleteParams.none(), requestOptions) + + /** This API returns details of a specific saved extension by ID. */ + fun get(id: String): CompletableFuture = get(id, SavedExtensionGetParams.none()) + + /** @see get */ + fun get( + id: String, + params: SavedExtensionGetParams = SavedExtensionGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = get(params.toBuilder().id(id).build(), requestOptions) + + /** @see get */ + fun get( + id: String, + params: SavedExtensionGetParams = SavedExtensionGetParams.none(), + ): CompletableFuture = get(id, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: SavedExtensionGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see get */ + fun get(params: SavedExtensionGetParams): CompletableFuture = + get(params, RequestOptions.none()) + + /** @see get */ + fun get(id: String, requestOptions: RequestOptions): CompletableFuture = + get(id, SavedExtensionGetParams.none(), requestOptions) + + /** + * A view of [SavedExtensionServiceAsync] 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 + ): SavedExtensionServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/saved-extensions`, but is otherwise the same as + * [SavedExtensionServiceAsync.create]. + */ + fun create( + params: SavedExtensionCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SavedExtensionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `patch /v1/saved-extensions/{id}`, but is otherwise the + * same as [SavedExtensionServiceAsync.update]. + */ + fun update(id: String): CompletableFuture> = + update(id, SavedExtensionUpdateParams.none()) + + /** @see update */ + fun update( + id: String, + params: SavedExtensionUpdateParams = SavedExtensionUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update( + id: String, + params: SavedExtensionUpdateParams = SavedExtensionUpdateParams.none(), + ): CompletableFuture> = + update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: SavedExtensionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see update */ + fun update( + params: SavedExtensionUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(id, SavedExtensionUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/saved-extensions`, but is otherwise the same as + * [SavedExtensionServiceAsync.list]. + */ + fun list(): CompletableFuture>> = + list(SavedExtensionListParams.none()) + + /** @see list */ + fun list( + params: SavedExtensionListParams = SavedExtensionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture>> + + /** @see list */ + fun list( + params: SavedExtensionListParams = SavedExtensionListParams.none() + ): CompletableFuture>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture>> = + list(SavedExtensionListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/saved-extensions/{id}`, but is otherwise the + * same as [SavedExtensionServiceAsync.delete]. + */ + fun delete(id: String): CompletableFuture = + delete(id, SavedExtensionDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: SavedExtensionDeleteParams = SavedExtensionDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: SavedExtensionDeleteParams = SavedExtensionDeleteParams.none(), + ): CompletableFuture = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: SavedExtensionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: SavedExtensionDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions): CompletableFuture = + delete(id, SavedExtensionDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/saved-extensions/{id}`, but is otherwise the + * same as [SavedExtensionServiceAsync.get]. + */ + fun get(id: String): CompletableFuture> = + get(id, SavedExtensionGetParams.none()) + + /** @see get */ + fun get( + id: String, + params: SavedExtensionGetParams = SavedExtensionGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + get(params.toBuilder().id(id).build(), requestOptions) + + /** @see get */ + fun get( + id: String, + params: SavedExtensionGetParams = SavedExtensionGetParams.none(), + ): CompletableFuture> = + get(id, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: SavedExtensionGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see get */ + fun get( + params: SavedExtensionGetParams + ): CompletableFuture> = get(params, RequestOptions.none()) + + /** @see get */ + fun get( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + get(id, SavedExtensionGetParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncImpl.kt new file mode 100644 index 00000000..e9df15a3 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncImpl.kt @@ -0,0 +1,247 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.handlers.emptyHandler +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.json +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepareAsync +import com.imagekit.api.models.SavedExtension +import com.imagekit.api.models.savedextensions.SavedExtensionCreateParams +import com.imagekit.api.models.savedextensions.SavedExtensionDeleteParams +import com.imagekit.api.models.savedextensions.SavedExtensionGetParams +import com.imagekit.api.models.savedextensions.SavedExtensionListParams +import com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SavedExtensionServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : SavedExtensionServiceAsync { + + private val withRawResponse: SavedExtensionServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SavedExtensionServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): SavedExtensionServiceAsync = + SavedExtensionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: SavedExtensionCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/saved-extensions + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: SavedExtensionUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // patch /v1/saved-extensions/{id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: SavedExtensionListParams, + requestOptions: RequestOptions, + ): CompletableFuture> = + // get /v1/saved-extensions + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: SavedExtensionDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /v1/saved-extensions/{id} + withRawResponse().delete(params, requestOptions).thenAccept {} + + override fun get( + params: SavedExtensionGetParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/saved-extensions/{id} + withRawResponse().get(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SavedExtensionServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): SavedExtensionServiceAsync.WithRawResponse = + SavedExtensionServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: SavedExtensionCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "saved-extensions") + .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: SavedExtensionUpdateParams, + 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", "saved-extensions", 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: SavedExtensionListParams, + requestOptions: RequestOptions, + ): CompletableFuture>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "saved-extensions") + .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: SavedExtensionDeleteParams, + 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", "saved-extensions", 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: SavedExtensionGetParams, + 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", "saved-extensions", 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/com/imagekit/api/services/async/files/MetadataServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsync.kt index 1d7f3856..29bb636f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsync.kt @@ -126,7 +126,7 @@ interface MetadataServiceAsync { get(fileId, MetadataGetParams.none(), requestOptions) /** - * Returns a raw HTTP response for `get /v1/files/metadata`, but is otherwise the same as + * Returns a raw HTTP response for `get /v1/metadata`, but is otherwise the same as * [MetadataServiceAsync.getFromUrl]. */ fun getFromUrl( diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncImpl.kt index b9a0336a..6c02890b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncImpl.kt @@ -45,7 +45,7 @@ class MetadataServiceAsyncImpl internal constructor(private val clientOptions: C params: MetadataGetFromUrlParams, requestOptions: RequestOptions, ): CompletableFuture = - // get /v1/files/metadata + // get /v1/metadata withRawResponse().getFromUrl(params, requestOptions).thenApply { it.parse() } class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -104,7 +104,7 @@ class MetadataServiceAsyncImpl internal constructor(private val clientOptions: C HttpRequest.builder() .method(HttpMethod.GET) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v1", "files", "metadata") + .addPathSegments("v1", "metadata") .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/SavedExtensionService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/SavedExtensionService.kt new file mode 100644 index 00000000..8121edf1 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/SavedExtensionService.kt @@ -0,0 +1,333 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.models.SavedExtension +import com.imagekit.api.models.savedextensions.SavedExtensionCreateParams +import com.imagekit.api.models.savedextensions.SavedExtensionDeleteParams +import com.imagekit.api.models.savedextensions.SavedExtensionGetParams +import com.imagekit.api.models.savedextensions.SavedExtensionListParams +import com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams +import java.util.function.Consumer + +interface SavedExtensionService { + + /** + * 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): SavedExtensionService + + /** + * This API creates a new saved extension. Saved extensions allow you to save complex extension + * configurations (like AI tasks) and reuse them by referencing the ID in upload or update file + * APIs. + * + * **Saved extension limit** \ You can create a maximum of 100 saved extensions per account. + */ + fun create(params: SavedExtensionCreateParams): SavedExtension = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SavedExtensionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SavedExtension + + /** + * This API updates an existing saved extension. You can update the name, description, or + * config. + */ + fun update(id: String): SavedExtension = update(id, SavedExtensionUpdateParams.none()) + + /** @see update */ + fun update( + id: String, + params: SavedExtensionUpdateParams = SavedExtensionUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SavedExtension = update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + fun update( + id: String, + params: SavedExtensionUpdateParams = SavedExtensionUpdateParams.none(), + ): SavedExtension = update(id, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: SavedExtensionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SavedExtension + + /** @see update */ + fun update(params: SavedExtensionUpdateParams): SavedExtension = + update(params, RequestOptions.none()) + + /** @see update */ + fun update(id: String, requestOptions: RequestOptions): SavedExtension = + update(id, SavedExtensionUpdateParams.none(), requestOptions) + + /** + * This API returns an array of all saved extensions for your account. Saved extensions allow + * you to save complex extension configurations and reuse them by referencing them by ID in + * upload or update file APIs. + */ + fun list(): List = list(SavedExtensionListParams.none()) + + /** @see list */ + fun list( + params: SavedExtensionListParams = SavedExtensionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List + + /** @see list */ + fun list( + params: SavedExtensionListParams = SavedExtensionListParams.none() + ): List = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List = + list(SavedExtensionListParams.none(), requestOptions) + + /** This API deletes a saved extension permanently. */ + fun delete(id: String) = delete(id, SavedExtensionDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: SavedExtensionDeleteParams = SavedExtensionDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete(id: String, params: SavedExtensionDeleteParams = SavedExtensionDeleteParams.none()) = + delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: SavedExtensionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) + + /** @see delete */ + fun delete(params: SavedExtensionDeleteParams) = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions) = + delete(id, SavedExtensionDeleteParams.none(), requestOptions) + + /** This API returns details of a specific saved extension by ID. */ + fun get(id: String): SavedExtension = get(id, SavedExtensionGetParams.none()) + + /** @see get */ + fun get( + id: String, + params: SavedExtensionGetParams = SavedExtensionGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SavedExtension = get(params.toBuilder().id(id).build(), requestOptions) + + /** @see get */ + fun get( + id: String, + params: SavedExtensionGetParams = SavedExtensionGetParams.none(), + ): SavedExtension = get(id, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: SavedExtensionGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SavedExtension + + /** @see get */ + fun get(params: SavedExtensionGetParams): SavedExtension = get(params, RequestOptions.none()) + + /** @see get */ + fun get(id: String, requestOptions: RequestOptions): SavedExtension = + get(id, SavedExtensionGetParams.none(), requestOptions) + + /** + * A view of [SavedExtensionService] 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 + ): SavedExtensionService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/saved-extensions`, but is otherwise the same as + * [SavedExtensionService.create]. + */ + @MustBeClosed + fun create(params: SavedExtensionCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: SavedExtensionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `patch /v1/saved-extensions/{id}`, but is otherwise the + * same as [SavedExtensionService.update]. + */ + @MustBeClosed + fun update(id: String): HttpResponseFor = + update(id, SavedExtensionUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + id: String, + params: SavedExtensionUpdateParams = SavedExtensionUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().id(id).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + id: String, + params: SavedExtensionUpdateParams = SavedExtensionUpdateParams.none(), + ): HttpResponseFor = update(id, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: SavedExtensionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see update */ + @MustBeClosed + fun update(params: SavedExtensionUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update(id: String, requestOptions: RequestOptions): HttpResponseFor = + update(id, SavedExtensionUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/saved-extensions`, but is otherwise the same as + * [SavedExtensionService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor> = list(SavedExtensionListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: SavedExtensionListParams = SavedExtensionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor> + + /** @see list */ + @MustBeClosed + fun list( + params: SavedExtensionListParams = SavedExtensionListParams.none() + ): HttpResponseFor> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor> = + list(SavedExtensionListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /v1/saved-extensions/{id}`, but is otherwise the + * same as [SavedExtensionService.delete]. + */ + @MustBeClosed + fun delete(id: String): HttpResponse = delete(id, SavedExtensionDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: SavedExtensionDeleteParams = SavedExtensionDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: SavedExtensionDeleteParams = SavedExtensionDeleteParams.none(), + ): HttpResponse = delete(id, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: SavedExtensionDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see delete */ + @MustBeClosed + fun delete(params: SavedExtensionDeleteParams): HttpResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete(id: String, requestOptions: RequestOptions): HttpResponse = + delete(id, SavedExtensionDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/saved-extensions/{id}`, but is otherwise the + * same as [SavedExtensionService.get]. + */ + @MustBeClosed + fun get(id: String): HttpResponseFor = + get(id, SavedExtensionGetParams.none()) + + /** @see get */ + @MustBeClosed + fun get( + id: String, + params: SavedExtensionGetParams = SavedExtensionGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = get(params.toBuilder().id(id).build(), requestOptions) + + /** @see get */ + @MustBeClosed + fun get( + id: String, + params: SavedExtensionGetParams = SavedExtensionGetParams.none(), + ): HttpResponseFor = get(id, params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get( + params: SavedExtensionGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see get */ + @MustBeClosed + fun get(params: SavedExtensionGetParams): HttpResponseFor = + get(params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get(id: String, requestOptions: RequestOptions): HttpResponseFor = + get(id, SavedExtensionGetParams.none(), requestOptions) + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceImpl.kt new file mode 100644 index 00000000..c1eed28e --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceImpl.kt @@ -0,0 +1,227 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.RequestOptions +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.handlers.emptyHandler +import com.imagekit.api.core.handlers.errorBodyHandler +import com.imagekit.api.core.handlers.errorHandler +import com.imagekit.api.core.handlers.jsonHandler +import com.imagekit.api.core.http.HttpMethod +import com.imagekit.api.core.http.HttpRequest +import com.imagekit.api.core.http.HttpResponse +import com.imagekit.api.core.http.HttpResponse.Handler +import com.imagekit.api.core.http.HttpResponseFor +import com.imagekit.api.core.http.json +import com.imagekit.api.core.http.parseable +import com.imagekit.api.core.prepare +import com.imagekit.api.models.SavedExtension +import com.imagekit.api.models.savedextensions.SavedExtensionCreateParams +import com.imagekit.api.models.savedextensions.SavedExtensionDeleteParams +import com.imagekit.api.models.savedextensions.SavedExtensionGetParams +import com.imagekit.api.models.savedextensions.SavedExtensionListParams +import com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SavedExtensionServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SavedExtensionService { + + private val withRawResponse: SavedExtensionService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SavedExtensionService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): SavedExtensionService = + SavedExtensionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: SavedExtensionCreateParams, + requestOptions: RequestOptions, + ): SavedExtension = + // post /v1/saved-extensions + withRawResponse().create(params, requestOptions).parse() + + override fun update( + params: SavedExtensionUpdateParams, + requestOptions: RequestOptions, + ): SavedExtension = + // patch /v1/saved-extensions/{id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: SavedExtensionListParams, + requestOptions: RequestOptions, + ): List = + // get /v1/saved-extensions + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: SavedExtensionDeleteParams, requestOptions: RequestOptions) { + // delete /v1/saved-extensions/{id} + withRawResponse().delete(params, requestOptions) + } + + override fun get( + params: SavedExtensionGetParams, + requestOptions: RequestOptions, + ): SavedExtension = + // get /v1/saved-extensions/{id} + withRawResponse().get(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SavedExtensionService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): SavedExtensionService.WithRawResponse = + SavedExtensionServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: SavedExtensionCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "saved-extensions") + .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: SavedExtensionUpdateParams, + 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", "saved-extensions", 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: SavedExtensionListParams, + requestOptions: RequestOptions, + ): HttpResponseFor> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "saved-extensions") + .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: SavedExtensionDeleteParams, + 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", "saved-extensions", 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: SavedExtensionGetParams, + 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", "saved-extensions", 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/main/kotlin/com/imagekit/api/services/blocking/files/MetadataService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataService.kt index d873401f..95f9a8e4 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataService.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataService.kt @@ -121,7 +121,7 @@ interface MetadataService { get(fileId, MetadataGetParams.none(), requestOptions) /** - * Returns a raw HTTP response for `get /v1/files/metadata`, but is otherwise the same as + * Returns a raw HTTP response for `get /v1/metadata`, but is otherwise the same as * [MetadataService.getFromUrl]. */ @MustBeClosed diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceImpl.kt index 558676a7..f5ea7bb7 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceImpl.kt @@ -41,7 +41,7 @@ class MetadataServiceImpl internal constructor(private val clientOptions: Client params: MetadataGetFromUrlParams, requestOptions: RequestOptions, ): Metadata = - // get /v1/files/metadata + // get /v1/metadata withRawResponse().getFromUrl(params, requestOptions).parse() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -97,7 +97,7 @@ class MetadataServiceImpl internal constructor(private val clientOptions: Client HttpRequest.builder() .method(HttpMethod.GET) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v1", "files", "metadata") + .addPathSegments("v1", "metadata") .build() .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt index 1dab2e00..062380b7 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt @@ -13,6 +13,7 @@ internal class BaseOverlayTest { fun create() { val baseOverlay = BaseOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -23,6 +24,7 @@ internal class BaseOverlayTest { .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) .build() + assertThat(baseOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(baseOverlay.position()) .contains( OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() @@ -36,6 +38,7 @@ internal class BaseOverlayTest { val jsonMapper = jsonMapper() val baseOverlay = BaseOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExtensionConfigTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExtensionConfigTest.kt new file mode 100644 index 00000000..b2e6f0d6 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExtensionConfigTest.kt @@ -0,0 +1,193 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import com.imagekit.api.errors.ImageKitInvalidDataException +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class ExtensionConfigTest { + + @Test + fun ofRemoveBg() { + val removeBg = + ExtensionConfig.RemoveBg.builder() + .options( + ExtensionConfig.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + + val extensionConfig = ExtensionConfig.ofRemoveBg(removeBg) + + assertThat(extensionConfig.removeBg()).contains(removeBg) + assertThat(extensionConfig.autoTaggingExtension()).isEmpty + assertThat(extensionConfig.aiAutoDescription()).isEmpty + assertThat(extensionConfig.aiTasks()).isEmpty + } + + @Test + fun ofRemoveBgRoundtrip() { + val jsonMapper = jsonMapper() + val extensionConfig = + ExtensionConfig.ofRemoveBg( + ExtensionConfig.RemoveBg.builder() + .options( + ExtensionConfig.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + + val roundtrippedExtensionConfig = + jsonMapper.readValue( + jsonMapper.writeValueAsString(extensionConfig), + jacksonTypeRef(), + ) + + assertThat(roundtrippedExtensionConfig).isEqualTo(extensionConfig) + } + + @Test + fun ofAutoTaggingExtension() { + val autoTaggingExtension = + ExtensionConfig.AutoTaggingExtension.builder() + .maxTags(0L) + .minConfidence(0L) + .name(ExtensionConfig.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .build() + + val extensionConfig = ExtensionConfig.ofAutoTaggingExtension(autoTaggingExtension) + + assertThat(extensionConfig.removeBg()).isEmpty + assertThat(extensionConfig.autoTaggingExtension()).contains(autoTaggingExtension) + assertThat(extensionConfig.aiAutoDescription()).isEmpty + assertThat(extensionConfig.aiTasks()).isEmpty + } + + @Test + fun ofAutoTaggingExtensionRoundtrip() { + val jsonMapper = jsonMapper() + val extensionConfig = + ExtensionConfig.ofAutoTaggingExtension( + ExtensionConfig.AutoTaggingExtension.builder() + .maxTags(0L) + .minConfidence(0L) + .name(ExtensionConfig.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .build() + ) + + val roundtrippedExtensionConfig = + jsonMapper.readValue( + jsonMapper.writeValueAsString(extensionConfig), + jacksonTypeRef(), + ) + + assertThat(roundtrippedExtensionConfig).isEqualTo(extensionConfig) + } + + @Test + fun ofAiAutoDescription() { + val extensionConfig = ExtensionConfig.ofAiAutoDescription() + + assertThat(extensionConfig.removeBg()).isEmpty + assertThat(extensionConfig.autoTaggingExtension()).isEmpty + assertThat(extensionConfig.aiAutoDescription()) + .contains(JsonValue.from(mapOf("name" to "ai-auto-description"))) + assertThat(extensionConfig.aiTasks()).isEmpty + } + + @Test + fun ofAiAutoDescriptionRoundtrip() { + val jsonMapper = jsonMapper() + val extensionConfig = ExtensionConfig.ofAiAutoDescription() + + val roundtrippedExtensionConfig = + jsonMapper.readValue( + jsonMapper.writeValueAsString(extensionConfig), + jacksonTypeRef(), + ) + + assertThat(roundtrippedExtensionConfig).isEqualTo(extensionConfig) + } + + @Test + fun ofAiTasks() { + val aiTasks = + ExtensionConfig.AiTasks.builder() + .addTask( + ExtensionConfig.AiTasks.Task.SelectTags.builder() + .instruction("What types of clothing items are visible in this image?") + .vocabulary(listOf("shirt", "tshirt", "dress", "trousers", "jacket")) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .build() + + val extensionConfig = ExtensionConfig.ofAiTasks(aiTasks) + + assertThat(extensionConfig.removeBg()).isEmpty + assertThat(extensionConfig.autoTaggingExtension()).isEmpty + assertThat(extensionConfig.aiAutoDescription()).isEmpty + assertThat(extensionConfig.aiTasks()).contains(aiTasks) + } + + @Test + fun ofAiTasksRoundtrip() { + val jsonMapper = jsonMapper() + val extensionConfig = + ExtensionConfig.ofAiTasks( + ExtensionConfig.AiTasks.builder() + .addTask( + ExtensionConfig.AiTasks.Task.SelectTags.builder() + .instruction("What types of clothing items are visible in this image?") + .vocabulary(listOf("shirt", "tshirt", "dress", "trousers", "jacket")) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .build() + ) + + val roundtrippedExtensionConfig = + jsonMapper.readValue( + jsonMapper.writeValueAsString(extensionConfig), + jacksonTypeRef(), + ) + + assertThat(roundtrippedExtensionConfig).isEqualTo(extensionConfig) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val extensionConfig = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { extensionConfig.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt index cbf1479c..161d626e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt @@ -40,10 +40,12 @@ internal class GetImageAttributesOptionsTest { .blur(10.0) .border("5_FF0000") .colorProfile(true) + .colorReplace("colorReplace") .contrastStretch(Transformation.ContrastStretch.TRUE) .crop(Transformation.Crop.FORCE) .cropMode(Transformation.CropMode.PAD_RESIZE) .defaultImage("defaultImage") + .distort("distort") .dpr(2.0) .duration(0.0) .endOffset(0.0) @@ -60,6 +62,7 @@ internal class GetImageAttributesOptionsTest { .original(true) .overlay( TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -154,10 +157,12 @@ internal class GetImageAttributesOptionsTest { .blur(10.0) .border("5_FF0000") .colorProfile(true) + .colorReplace("colorReplace") .contrastStretch(Transformation.ContrastStretch.TRUE) .crop(Transformation.Crop.FORCE) .cropMode(Transformation.CropMode.PAD_RESIZE) .defaultImage("defaultImage") + .distort("distort") .dpr(2.0) .duration(0.0) .endOffset(0.0) @@ -174,6 +179,7 @@ internal class GetImageAttributesOptionsTest { .original(true) .overlay( TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -266,10 +272,12 @@ internal class GetImageAttributesOptionsTest { .blur(10.0) .border("5_FF0000") .colorProfile(true) + .colorReplace("colorReplace") .contrastStretch(Transformation.ContrastStretch.TRUE) .crop(Transformation.Crop.FORCE) .cropMode(Transformation.CropMode.PAD_RESIZE) .defaultImage("defaultImage") + .distort("distort") .dpr(2.0) .duration(0.0) .endOffset(0.0) @@ -286,6 +294,7 @@ internal class GetImageAttributesOptionsTest { .original(true) .overlay( TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt index fbcfd99f..ea386f83 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt @@ -14,6 +14,7 @@ internal class ImageOverlayTest { fun create() { val imageOverlay = ImageOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -40,10 +41,12 @@ internal class ImageOverlayTest { .blur(10.0) .border("5_FF0000") .colorProfile(true) + .colorReplace("colorReplace") .contrastStretch(Transformation.ContrastStretch.TRUE) .crop(Transformation.Crop.FORCE) .cropMode(Transformation.CropMode.PAD_RESIZE) .defaultImage("defaultImage") + .distort("distort") .dpr(2.0) .duration(0.0) .endOffset(0.0) @@ -60,6 +63,7 @@ internal class ImageOverlayTest { .original(true) .overlay( TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -120,6 +124,7 @@ internal class ImageOverlayTest { ) .build() + assertThat(imageOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(imageOverlay.position()) .contains( OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() @@ -145,10 +150,12 @@ internal class ImageOverlayTest { .blur(10.0) .border("5_FF0000") .colorProfile(true) + .colorReplace("colorReplace") .contrastStretch(Transformation.ContrastStretch.TRUE) .crop(Transformation.Crop.FORCE) .cropMode(Transformation.CropMode.PAD_RESIZE) .defaultImage("defaultImage") + .distort("distort") .dpr(2.0) .duration(0.0) .endOffset(0.0) @@ -165,6 +172,7 @@ internal class ImageOverlayTest { .original(true) .overlay( TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -224,6 +232,7 @@ internal class ImageOverlayTest { val jsonMapper = jsonMapper() val imageOverlay = ImageOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -250,10 +259,12 @@ internal class ImageOverlayTest { .blur(10.0) .border("5_FF0000") .colorProfile(true) + .colorReplace("colorReplace") .contrastStretch(Transformation.ContrastStretch.TRUE) .crop(Transformation.Crop.FORCE) .cropMode(Transformation.CropMode.PAD_RESIZE) .defaultImage("defaultImage") + .distort("distort") .dpr(2.0) .duration(0.0) .endOffset(0.0) @@ -270,6 +281,7 @@ internal class ImageOverlayTest { .original(true) .overlay( TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt index 12352e41..47c32e03 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt @@ -18,6 +18,7 @@ internal class OverlayTest { fun ofText() { val text = TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -62,6 +63,7 @@ internal class OverlayTest { val overlay = Overlay.ofText( TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -102,6 +104,7 @@ internal class OverlayTest { fun ofImage() { val image = ImageOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -128,10 +131,12 @@ internal class OverlayTest { .blur(10.0) .border("5_FF0000") .colorProfile(true) + .colorReplace("colorReplace") .contrastStretch(Transformation.ContrastStretch.TRUE) .crop(Transformation.Crop.FORCE) .cropMode(Transformation.CropMode.PAD_RESIZE) .defaultImage("defaultImage") + .distort("distort") .dpr(2.0) .duration(0.0) .endOffset(0.0) @@ -148,6 +153,7 @@ internal class OverlayTest { .original(true) .overlay( TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -223,6 +229,7 @@ internal class OverlayTest { val overlay = Overlay.ofImage( ImageOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -251,10 +258,12 @@ internal class OverlayTest { .blur(10.0) .border("5_FF0000") .colorProfile(true) + .colorReplace("colorReplace") .contrastStretch(Transformation.ContrastStretch.TRUE) .crop(Transformation.Crop.FORCE) .cropMode(Transformation.CropMode.PAD_RESIZE) .defaultImage("defaultImage") + .distort("distort") .dpr(2.0) .duration(0.0) .endOffset(0.0) @@ -271,6 +280,7 @@ internal class OverlayTest { .original(true) .overlay( TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -342,6 +352,7 @@ internal class OverlayTest { fun ofVideo() { val video = VideoOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -368,10 +379,12 @@ internal class OverlayTest { .blur(10.0) .border("5_FF0000") .colorProfile(true) + .colorReplace("colorReplace") .contrastStretch(Transformation.ContrastStretch.TRUE) .crop(Transformation.Crop.FORCE) .cropMode(Transformation.CropMode.PAD_RESIZE) .defaultImage("defaultImage") + .distort("distort") .dpr(2.0) .duration(0.0) .endOffset(0.0) @@ -388,6 +401,7 @@ internal class OverlayTest { .original(true) .overlay( TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -463,6 +477,7 @@ internal class OverlayTest { val overlay = Overlay.ofVideo( VideoOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -491,10 +506,12 @@ internal class OverlayTest { .blur(10.0) .border("5_FF0000") .colorProfile(true) + .colorReplace("colorReplace") .contrastStretch(Transformation.ContrastStretch.TRUE) .crop(Transformation.Crop.FORCE) .cropMode(Transformation.CropMode.PAD_RESIZE) .defaultImage("defaultImage") + .distort("distort") .dpr(2.0) .duration(0.0) .endOffset(0.0) @@ -511,6 +528,7 @@ internal class OverlayTest { .original(true) .overlay( TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -582,6 +600,7 @@ internal class OverlayTest { fun ofSubtitle() { val subtitle = SubtitleOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -620,6 +639,7 @@ internal class OverlayTest { val overlay = Overlay.ofSubtitle( SubtitleOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -654,6 +674,7 @@ internal class OverlayTest { fun ofSolidColor() { val solidColor = SolidColorOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -690,6 +711,7 @@ internal class OverlayTest { val overlay = Overlay.ofSolidColor( SolidColorOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SavedExtensionTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SavedExtensionTest.kt new file mode 100644 index 00000000..8b19dcd2 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SavedExtensionTest.kt @@ -0,0 +1,93 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SavedExtensionTest { + + @Test + fun create() { + val savedExtension = + SavedExtension.builder() + .id("ext_abc123") + .config( + ExtensionConfig.RemoveBg.builder() + .options( + ExtensionConfig.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("Analyzes vehicle images for type, condition, and quality assessment") + .name("Car Quality Analysis") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(savedExtension.id()).contains("ext_abc123") + assertThat(savedExtension.config()) + .contains( + ExtensionConfig.ofRemoveBg( + ExtensionConfig.RemoveBg.builder() + .options( + ExtensionConfig.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + ) + assertThat(savedExtension.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(savedExtension.description()) + .contains("Analyzes vehicle images for type, condition, and quality assessment") + assertThat(savedExtension.name()).contains("Car Quality Analysis") + assertThat(savedExtension.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val savedExtension = + SavedExtension.builder() + .id("ext_abc123") + .config( + ExtensionConfig.RemoveBg.builder() + .options( + ExtensionConfig.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .description("Analyzes vehicle images for type, condition, and quality assessment") + .name("Car Quality Analysis") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedSavedExtension = + jsonMapper.readValue( + jsonMapper.writeValueAsString(savedExtension), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSavedExtension).isEqualTo(savedExtension) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt index 7989cf7e..27cae13f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt @@ -14,6 +14,7 @@ internal class SolidColorOverlayTest { fun create() { val solidColorOverlay = SolidColorOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -35,6 +36,7 @@ internal class SolidColorOverlayTest { ) .build() + assertThat(solidColorOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(solidColorOverlay.position()) .contains( OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() @@ -60,6 +62,7 @@ internal class SolidColorOverlayTest { val jsonMapper = jsonMapper() val solidColorOverlay = SolidColorOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt index c5b2b7db..4589be89 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt @@ -40,10 +40,12 @@ internal class SrcOptionsTest { .blur(10.0) .border("5_FF0000") .colorProfile(true) + .colorReplace("colorReplace") .contrastStretch(Transformation.ContrastStretch.TRUE) .crop(Transformation.Crop.FORCE) .cropMode(Transformation.CropMode.PAD_RESIZE) .defaultImage("defaultImage") + .distort("distort") .dpr(2.0) .duration(0.0) .endOffset(0.0) @@ -60,6 +62,7 @@ internal class SrcOptionsTest { .original(true) .overlay( TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -148,10 +151,12 @@ internal class SrcOptionsTest { .blur(10.0) .border("5_FF0000") .colorProfile(true) + .colorReplace("colorReplace") .contrastStretch(Transformation.ContrastStretch.TRUE) .crop(Transformation.Crop.FORCE) .cropMode(Transformation.CropMode.PAD_RESIZE) .defaultImage("defaultImage") + .distort("distort") .dpr(2.0) .duration(0.0) .endOffset(0.0) @@ -168,6 +173,7 @@ internal class SrcOptionsTest { .original(true) .overlay( TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -253,10 +259,12 @@ internal class SrcOptionsTest { .blur(10.0) .border("5_FF0000") .colorProfile(true) + .colorReplace("colorReplace") .contrastStretch(Transformation.ContrastStretch.TRUE) .crop(Transformation.Crop.FORCE) .cropMode(Transformation.CropMode.PAD_RESIZE) .defaultImage("defaultImage") + .distort("distort") .dpr(2.0) .duration(0.0) .endOffset(0.0) @@ -273,6 +281,7 @@ internal class SrcOptionsTest { .original(true) .overlay( TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt index c0f445a6..35aea254 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt @@ -14,6 +14,7 @@ internal class SubtitleOverlayTest { fun create() { val subtitleOverlay = SubtitleOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -37,6 +38,7 @@ internal class SubtitleOverlayTest { ) .build() + assertThat(subtitleOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(subtitleOverlay.position()) .contains( OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() @@ -64,6 +66,7 @@ internal class SubtitleOverlayTest { val jsonMapper = jsonMapper() val subtitleOverlay = SubtitleOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt index 6b3a27b4..841a72dd 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt @@ -14,6 +14,7 @@ internal class TextOverlayTest { fun create() { val textOverlay = TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -43,6 +44,7 @@ internal class TextOverlayTest { ) .build() + assertThat(textOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(textOverlay.position()) .contains( OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() @@ -76,6 +78,7 @@ internal class TextOverlayTest { val jsonMapper = jsonMapper() val textOverlay = TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt index e90e156b..09bf721f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt @@ -28,10 +28,12 @@ internal class TransformationTest { .blur(10.0) .border("5_FF0000") .colorProfile(true) + .colorReplace("colorReplace") .contrastStretch(Transformation.ContrastStretch.TRUE) .crop(Transformation.Crop.FORCE) .cropMode(Transformation.CropMode.PAD_RESIZE) .defaultImage("defaultImage") + .distort("distort") .dpr(2.0) .duration(0.0) .endOffset(0.0) @@ -48,6 +50,7 @@ internal class TransformationTest { .original(true) .overlay( TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -115,10 +118,12 @@ internal class TransformationTest { assertThat(transformation.blur()).contains(10.0) assertThat(transformation.border()).contains("5_FF0000") assertThat(transformation.colorProfile()).contains(true) + assertThat(transformation.colorReplace()).contains("colorReplace") assertThat(transformation.contrastStretch()).contains(Transformation.ContrastStretch.TRUE) assertThat(transformation.crop()).contains(Transformation.Crop.FORCE) assertThat(transformation.cropMode()).contains(Transformation.CropMode.PAD_RESIZE) assertThat(transformation.defaultImage()).contains("defaultImage") + assertThat(transformation.distort()).contains("distort") assertThat(transformation.dpr()).contains(2.0) assertThat(transformation.duration()).contains(Transformation.Duration.ofNumber(0.0)) assertThat(transformation.endOffset()).contains(Transformation.EndOffset.ofNumber(0.0)) @@ -137,6 +142,7 @@ internal class TransformationTest { .contains( Overlay.ofText( TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -208,10 +214,12 @@ internal class TransformationTest { .blur(10.0) .border("5_FF0000") .colorProfile(true) + .colorReplace("colorReplace") .contrastStretch(Transformation.ContrastStretch.TRUE) .crop(Transformation.Crop.FORCE) .cropMode(Transformation.CropMode.PAD_RESIZE) .defaultImage("defaultImage") + .distort("distort") .dpr(2.0) .duration(0.0) .endOffset(0.0) @@ -228,6 +236,7 @@ internal class TransformationTest { .original(true) .overlay( TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt index 2f25fe21..19e48b9d 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt @@ -14,6 +14,7 @@ internal class VideoOverlayTest { fun create() { val videoOverlay = VideoOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -40,10 +41,12 @@ internal class VideoOverlayTest { .blur(10.0) .border("5_FF0000") .colorProfile(true) + .colorReplace("colorReplace") .contrastStretch(Transformation.ContrastStretch.TRUE) .crop(Transformation.Crop.FORCE) .cropMode(Transformation.CropMode.PAD_RESIZE) .defaultImage("defaultImage") + .distort("distort") .dpr(2.0) .duration(0.0) .endOffset(0.0) @@ -60,6 +63,7 @@ internal class VideoOverlayTest { .original(true) .overlay( TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -120,6 +124,7 @@ internal class VideoOverlayTest { ) .build() + assertThat(videoOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(videoOverlay.position()) .contains( OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() @@ -145,10 +150,12 @@ internal class VideoOverlayTest { .blur(10.0) .border("5_FF0000") .colorProfile(true) + .colorReplace("colorReplace") .contrastStretch(Transformation.ContrastStretch.TRUE) .crop(Transformation.Crop.FORCE) .cropMode(Transformation.CropMode.PAD_RESIZE) .defaultImage("defaultImage") + .distort("distort") .dpr(2.0) .duration(0.0) .endOffset(0.0) @@ -165,6 +172,7 @@ internal class VideoOverlayTest { .original(true) .overlay( TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -224,6 +232,7 @@ internal class VideoOverlayTest { val jsonMapper = jsonMapper() val videoOverlay = VideoOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) @@ -250,10 +259,12 @@ internal class VideoOverlayTest { .blur(10.0) .border("5_FF0000") .colorProfile(true) + .colorReplace("colorReplace") .contrastStretch(Transformation.ContrastStretch.TRUE) .crop(Transformation.Crop.FORCE) .cropMode(Transformation.CropMode.PAD_RESIZE) .defaultImage("defaultImage") + .distort("distort") .dpr(2.0) .duration(0.0) .endOffset(0.0) @@ -270,6 +281,7 @@ internal class VideoOverlayTest { .original(true) .overlay( TextOverlay.builder() + .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() .focus(OverlayPosition.Focus.CENTER) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt index e4adb865..4c3bb907 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt @@ -4,7 +4,7 @@ package com.imagekit.api.models.beta.v2.files import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField -import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -28,10 +28,10 @@ internal class FileUploadParamsTest { .description("Running shoes") .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -40,17 +40,121 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags.builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf("shirt", "tshirt", "dress", "trousers", "jacket") + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + .instruction("Is this a luxury or high-end fashion item?") + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") @@ -107,10 +211,10 @@ internal class FileUploadParamsTest { .description("Running shoes") .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -119,17 +223,122 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags.builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf("shirt", "tshirt", "dress", "trousers", "jacket") + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + .instruction("Is this a luxury or high-end fashion item?") + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") @@ -195,10 +404,10 @@ internal class FileUploadParamsTest { "extensions" to MultipartField.of( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options + UnnamedSchemaWithArrayParent4.RemoveBg.Options .builder() .addShadow(true) .bgColor("bg_color") @@ -208,18 +417,157 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension + UnnamedSchemaWithArrayParent4.AutoTaggingExtension .Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4 + .AiTasks + .Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4 + .AiTasks + .Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4 + .AiTasks + .Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4 + .AiTasks + .Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4 + .AiTasks + .Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4 + .AiTasks + .Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ), "folder" to MultipartField.of("folder"), diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt index 3ca3df31..da427b05 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt @@ -3,7 +3,7 @@ package com.imagekit.api.models.files import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -25,10 +25,10 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -37,27 +37,47 @@ internal class FileUpdateParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .AWS_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible?" + ) + .vocabulary(listOf("shirt", "dress", "jacket")) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) @@ -99,10 +119,10 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -111,27 +131,47 @@ internal class FileUpdateParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .AWS_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible?" + ) + .vocabulary(listOf("shirt", "dress", "jacket")) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) @@ -158,10 +198,10 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -170,27 +210,47 @@ internal class FileUpdateParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .AWS_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible?" + ) + .vocabulary(listOf("shirt", "dress", "jacket")) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt index fbea5ec8..85ae6fd7 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt @@ -4,7 +4,7 @@ package com.imagekit.api.models.files import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField -import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -29,10 +29,10 @@ internal class FileUploadParamsTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -41,17 +41,121 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags.builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf("shirt", "tshirt", "dress", "trousers", "jacket") + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + .instruction("Is this a luxury or high-end fashion item?") + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") @@ -111,10 +215,10 @@ internal class FileUploadParamsTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -123,17 +227,122 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags.builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf("shirt", "tshirt", "dress", "trousers", "jacket") + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + .instruction("Is this a luxury or high-end fashion item?") + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") @@ -202,10 +411,10 @@ internal class FileUploadParamsTest { "extensions" to MultipartField.of( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options + UnnamedSchemaWithArrayParent4.RemoveBg.Options .builder() .addShadow(true) .bgColor("bg_color") @@ -215,18 +424,157 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension + UnnamedSchemaWithArrayParent4.AutoTaggingExtension .Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4 + .AiTasks + .Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4 + .AiTasks + .Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4 + .AiTasks + .Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4 + .AiTasks + .Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4 + .AiTasks + .Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4 + .AiTasks + .Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ), "folder" to MultipartField.of("folder"), diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt index 2caf9099..a30a7f1a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt @@ -6,7 +6,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows @@ -28,10 +28,10 @@ internal class UpdateFileRequestTest { .description("description") .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -40,17 +40,122 @@ internal class UpdateFileRequestTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags.builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf("shirt", "tshirt", "dress", "trousers", "jacket") + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + .instruction("Is this a luxury or high-end fashion item?") + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .removeAiTagsOfStrings(listOf("string")) @@ -80,10 +185,10 @@ internal class UpdateFileRequestTest { .description("description") .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -92,17 +197,139 @@ internal class UpdateFileRequestTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .removeAiTagsOfStrings(listOf("string")) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionCreateParamsTest.kt new file mode 100644 index 00000000..2f40bb6c --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionCreateParamsTest.kt @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.savedextensions + +import com.imagekit.api.models.ExtensionConfig +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SavedExtensionCreateParamsTest { + + @Test + fun create() { + SavedExtensionCreateParams.builder() + .config( + ExtensionConfig.RemoveBg.builder() + .options( + ExtensionConfig.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .description("Analyzes vehicle images for type, condition, and quality assessment") + .name("Car Quality Analysis") + .build() + } + + @Test + fun body() { + val params = + SavedExtensionCreateParams.builder() + .config( + ExtensionConfig.RemoveBg.builder() + .options( + ExtensionConfig.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .description("Analyzes vehicle images for type, condition, and quality assessment") + .name("Car Quality Analysis") + .build() + + val body = params._body() + + assertThat(body.config()) + .isEqualTo( + ExtensionConfig.ofRemoveBg( + ExtensionConfig.RemoveBg.builder() + .options( + ExtensionConfig.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + ) + assertThat(body.description()) + .isEqualTo("Analyzes vehicle images for type, condition, and quality assessment") + assertThat(body.name()).isEqualTo("Car Quality Analysis") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + SavedExtensionCreateParams.builder() + .config(ExtensionConfig.RemoveBg.builder().build()) + .description("Analyzes vehicle images for type, condition, and quality assessment") + .name("Car Quality Analysis") + .build() + + val body = params._body() + + assertThat(body.config()) + .isEqualTo(ExtensionConfig.ofRemoveBg(ExtensionConfig.RemoveBg.builder().build())) + assertThat(body.description()) + .isEqualTo("Analyzes vehicle images for type, condition, and quality assessment") + assertThat(body.name()).isEqualTo("Car Quality Analysis") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionDeleteParamsTest.kt new file mode 100644 index 00000000..dbe6b570 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionDeleteParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.savedextensions + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SavedExtensionDeleteParamsTest { + + @Test + fun create() { + SavedExtensionDeleteParams.builder().id("id").build() + } + + @Test + fun pathParams() { + val params = SavedExtensionDeleteParams.builder().id("id").build() + + assertThat(params._pathParam(0)).isEqualTo("id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionGetParamsTest.kt new file mode 100644 index 00000000..da2a95b1 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionGetParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.savedextensions + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SavedExtensionGetParamsTest { + + @Test + fun create() { + SavedExtensionGetParams.builder().id("id").build() + } + + @Test + fun pathParams() { + val params = SavedExtensionGetParams.builder().id("id").build() + + assertThat(params._pathParam(0)).isEqualTo("id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionListParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionListParamsTest.kt new file mode 100644 index 00000000..ed9def38 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionListParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.savedextensions + +import org.junit.jupiter.api.Test + +internal class SavedExtensionListParamsTest { + + @Test + fun create() { + SavedExtensionListParams.builder().build() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionUpdateParamsTest.kt new file mode 100644 index 00000000..66429daf --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionUpdateParamsTest.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.savedextensions + +import com.imagekit.api.models.ExtensionConfig +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SavedExtensionUpdateParamsTest { + + @Test + fun create() { + SavedExtensionUpdateParams.builder() + .id("id") + .config( + ExtensionConfig.RemoveBg.builder() + .options( + ExtensionConfig.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .description("x") + .name("x") + .build() + } + + @Test + fun pathParams() { + val params = SavedExtensionUpdateParams.builder().id("id").build() + + assertThat(params._pathParam(0)).isEqualTo("id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + SavedExtensionUpdateParams.builder() + .id("id") + .config( + ExtensionConfig.RemoveBg.builder() + .options( + ExtensionConfig.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .description("x") + .name("x") + .build() + + val body = params._body() + + assertThat(body.config()) + .contains( + ExtensionConfig.ofRemoveBg( + ExtensionConfig.RemoveBg.builder() + .options( + ExtensionConfig.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + ) + assertThat(body.description()).contains("x") + assertThat(body.name()).contains("x") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = SavedExtensionUpdateParams.builder().id("id").build() + + val body = params._body() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt index 4978c043..e5b9a671 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt @@ -22,7 +22,7 @@ import com.imagekit.api.errors.RateLimitException import com.imagekit.api.errors.UnauthorizedException import com.imagekit.api.errors.UnexpectedStatusCodeException import com.imagekit.api.errors.UnprocessableEntityException -import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 import com.imagekit.api.models.files.FileUploadParams import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.entry @@ -89,10 +89,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -101,17 +101,146 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") @@ -189,10 +318,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -201,17 +330,146 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") @@ -289,10 +547,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -301,17 +559,146 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") @@ -389,10 +776,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -401,17 +788,146 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") @@ -489,10 +1005,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -501,17 +1017,146 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") @@ -589,10 +1234,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -601,17 +1246,146 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") @@ -689,10 +1463,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -701,17 +1475,146 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") @@ -789,10 +1692,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -801,17 +1704,146 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") @@ -889,10 +1921,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -901,17 +1933,146 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") @@ -989,10 +2150,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1001,17 +2162,146 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") @@ -1089,10 +2379,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1101,17 +2391,146 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") @@ -1189,10 +2608,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1201,17 +2620,146 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") @@ -1289,10 +2837,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1301,17 +2849,146 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") @@ -1389,10 +3066,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1401,17 +3078,146 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") @@ -1489,10 +3295,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1501,17 +3307,146 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") @@ -1589,10 +3524,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1601,17 +3536,146 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") @@ -1687,10 +3751,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1699,17 +3763,146 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks + .Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt index 59e7191c..398a0134 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt @@ -15,7 +15,7 @@ import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.imagekit.api.client.ImageKitClient import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 import com.imagekit.api.models.files.FileUploadParams import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Disabled @@ -61,10 +61,10 @@ internal class ServiceParamsTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -73,17 +73,122 @@ internal class ServiceParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags.builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf("shirt", "tshirt", "dress", "trousers", "jacket") + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + .instruction("Is this a luxury or high-end fashion item?") + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index f6a815c2..eaece89b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -5,7 +5,7 @@ package com.imagekit.api.services.async import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 import com.imagekit.api.models.files.FileCopyParams import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileRenameParams @@ -46,10 +46,10 @@ internal class FileServiceAsyncTest { .description("description") .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options + UnnamedSchemaWithArrayParent4.RemoveBg.Options .builder() .addShadow(true) .bgColor("bg_color") @@ -59,29 +59,50 @@ internal class FileServiceAsyncTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension + UnnamedSchemaWithArrayParent4.AutoTaggingExtension .Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension + UnnamedSchemaWithArrayParent4.AutoTaggingExtension .Name .AWS_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .SelectTags + .builder() + .instruction( + "What types of clothing items are visible?" + ) + .vocabulary(listOf("shirt", "dress", "jacket")) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) @@ -230,10 +251,10 @@ internal class FileServiceAsyncTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -242,17 +263,139 @@ internal class FileServiceAsyncTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt new file mode 100644 index 00000000..10b8b42c --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt @@ -0,0 +1,139 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import com.imagekit.api.models.ExtensionConfig +import com.imagekit.api.models.savedextensions.SavedExtensionCreateParams +import com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SavedExtensionServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateKey("My Private Key") + .password("My Password") + .build() + val savedExtensionServiceAsync = client.savedExtensions() + + val savedExtensionFuture = + savedExtensionServiceAsync.create( + SavedExtensionCreateParams.builder() + .config( + ExtensionConfig.RemoveBg.builder() + .options( + ExtensionConfig.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .description( + "Analyzes vehicle images for type, condition, and quality assessment" + ) + .name("Car Quality Analysis") + .build() + ) + + val savedExtension = savedExtensionFuture.get() + savedExtension.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateKey("My Private Key") + .password("My Password") + .build() + val savedExtensionServiceAsync = client.savedExtensions() + + val savedExtensionFuture = + savedExtensionServiceAsync.update( + SavedExtensionUpdateParams.builder() + .id("id") + .config( + ExtensionConfig.RemoveBg.builder() + .options( + ExtensionConfig.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .description("x") + .name("x") + .build() + ) + + val savedExtension = savedExtensionFuture.get() + savedExtension.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateKey("My Private Key") + .password("My Password") + .build() + val savedExtensionServiceAsync = client.savedExtensions() + + val savedExtensionsFuture = savedExtensionServiceAsync.list() + + val savedExtensions = savedExtensionsFuture.get() + savedExtensions.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateKey("My Private Key") + .password("My Password") + .build() + val savedExtensionServiceAsync = client.savedExtensions() + + val future = savedExtensionServiceAsync.delete("id") + + val response = future.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateKey("My Private Key") + .password("My Password") + .build() + val savedExtensionServiceAsync = client.savedExtensions() + + val savedExtensionFuture = savedExtensionServiceAsync.get("id") + + val savedExtension = savedExtensionFuture.get() + savedExtension.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt index 6973ea50..408d1bc7 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt @@ -5,7 +5,7 @@ package com.imagekit.api.services.async.beta.v2 import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 import com.imagekit.api.models.beta.v2.files.FileUploadParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -42,10 +42,10 @@ internal class FileServiceAsyncTest { .description("Running shoes") .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -54,17 +54,139 @@ internal class FileServiceAsyncTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index d3e8e8c0..7f61e8a7 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -5,7 +5,7 @@ package com.imagekit.api.services.blocking import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 import com.imagekit.api.models.files.FileCopyParams import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileRenameParams @@ -46,10 +46,10 @@ internal class FileServiceTest { .description("description") .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options + UnnamedSchemaWithArrayParent4.RemoveBg.Options .builder() .addShadow(true) .bgColor("bg_color") @@ -59,29 +59,50 @@ internal class FileServiceTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension + UnnamedSchemaWithArrayParent4.AutoTaggingExtension .Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension + UnnamedSchemaWithArrayParent4.AutoTaggingExtension .Name .AWS_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .SelectTags + .builder() + .instruction( + "What types of clothing items are visible?" + ) + .vocabulary(listOf("shirt", "dress", "jacket")) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) @@ -223,10 +244,10 @@ internal class FileServiceTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -235,17 +256,139 @@ internal class FileServiceTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt new file mode 100644 index 00000000..b2873c58 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.models.ExtensionConfig +import com.imagekit.api.models.savedextensions.SavedExtensionCreateParams +import com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SavedExtensionServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateKey("My Private Key") + .password("My Password") + .build() + val savedExtensionService = client.savedExtensions() + + val savedExtension = + savedExtensionService.create( + SavedExtensionCreateParams.builder() + .config( + ExtensionConfig.RemoveBg.builder() + .options( + ExtensionConfig.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .description( + "Analyzes vehicle images for type, condition, and quality assessment" + ) + .name("Car Quality Analysis") + .build() + ) + + savedExtension.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateKey("My Private Key") + .password("My Password") + .build() + val savedExtensionService = client.savedExtensions() + + val savedExtension = + savedExtensionService.update( + SavedExtensionUpdateParams.builder() + .id("id") + .config( + ExtensionConfig.RemoveBg.builder() + .options( + ExtensionConfig.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + .description("x") + .name("x") + .build() + ) + + savedExtension.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateKey("My Private Key") + .password("My Password") + .build() + val savedExtensionService = client.savedExtensions() + + val savedExtensions = savedExtensionService.list() + + savedExtensions.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateKey("My Private Key") + .password("My Password") + .build() + val savedExtensionService = client.savedExtensions() + + savedExtensionService.delete("id") + } + + @Disabled("Prism tests are disabled") + @Test + fun get() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateKey("My Private Key") + .password("My Password") + .build() + val savedExtensionService = client.savedExtensions() + + val savedExtension = savedExtensionService.get("id") + + savedExtension.validate() + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt index b0050868..1693e3f1 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt @@ -5,7 +5,7 @@ package com.imagekit.api.services.blocking.beta.v2 import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 import com.imagekit.api.models.beta.v2.files.FileUploadParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -42,10 +42,10 @@ internal class FileServiceTest { .description("Running shoes") .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -54,17 +54,139 @@ internal class FileServiceTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible in this image?" + ) + .vocabulary( + listOf( + "shirt", + "tshirt", + "dress", + "trousers", + "jacket", + ) + ) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + .instruction( + "Is this a luxury or high-end fashion item?" + ) + .onNo( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnNo + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnNo + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnNo + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onUnknown( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnUnknown + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnUnknown + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnUnknown + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .onYes( + UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo + .OnYes + .builder() + .addAddTag("luxury") + .addAddTag("premium") + .addRemoveTag("budget") + .addRemoveTag("affordable") + .addSetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnYes + .SetMetadata + .builder() + .field("price_range") + .value("premium") + .build() + ) + .addUnsetMetadata( + UnnamedSchemaWithArrayParent4.AiTasks.Task + .YesNo + .OnYes + .UnsetMetadata + .builder() + .field("price_range") + .build() + ) + .build() + ) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .folder("folder") diff --git a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt index 41078fe2..05387c60 100644 --- a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt +++ b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt @@ -7,7 +7,7 @@ import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper import com.imagekit.api.models.StreamingResolution -import com.imagekit.api.models.UnnamedSchemaWithArrayParent1 +import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 import com.imagekit.api.models.files.File import com.imagekit.api.models.files.UpdateFileRequest import java.time.OffsetDateTime @@ -58,6 +58,7 @@ internal class ProGuardCompatibilityTest { assertThat(client).isNotNull() assertThat(client.customMetadataFields()).isNotNull() assertThat(client.files()).isNotNull() + assertThat(client.savedExtensions()).isNotNull() assertThat(client.assets()).isNotNull() assertThat(client.cache()).isNotNull() assertThat(client.folders()).isNotNull() @@ -145,10 +146,10 @@ internal class ProGuardCompatibilityTest { .description("description") .extensions( listOf( - UnnamedSchemaWithArrayParent1.ofRemoveBg( - UnnamedSchemaWithArrayParent1.RemoveBg.builder() + UnnamedSchemaWithArrayParent4.ofRemoveBg( + UnnamedSchemaWithArrayParent4.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent1.RemoveBg.Options.builder() + UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -157,27 +158,47 @@ internal class ProGuardCompatibilityTest { ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.builder() + UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent1.AutoTaggingExtension.Name + UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name .AWS_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent1.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), + UnnamedSchemaWithArrayParent4.ofAiTasks( + UnnamedSchemaWithArrayParent4.AiTasks.builder() + .addTask( + UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags + .builder() + .instruction( + "What types of clothing items are visible?" + ) + .vocabulary(listOf("shirt", "dress", "jacket")) + .maxSelections(1L) + .minSelections(0L) + .build() + ) + .build() + ), + UnnamedSchemaWithArrayParent4.ofSavedExtension( + UnnamedSchemaWithArrayParent4.SavedExtension.builder() + .id("ext_abc123") + .build() + ), ) ) .removeAiTagsOfStrings(listOf("car", "vehicle", "motorsports")) From 4b083bbd1d119b86b543c7b37f73f4b2dca4e665 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 15 Jan 2026 10:09:39 +0000 Subject: [PATCH 073/142] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index fdbd8925..f7feecbe 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-7a3257eb171467b637c8d72877f201c2e6038c71ed447a9453230b7309ce7416.yml -openapi_spec_hash: 87b000a9989ad5c9526f28d91b8a1749 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-606f0e2a6ecb6c36557e166764d39b8f619a74904db6bb5ed8bb348ed451b337.yml +openapi_spec_hash: 1d5f5cdb3f7992a183c368ecd009316e config_hash: aeb6eb949d73382270bbd8bbf2e4cf2a From b0bfdf6c142e23170be4051a985d7206c74f5958 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 15 Jan 2026 11:21:31 +0000 Subject: [PATCH 074/142] fix: add ai-tasks property to response schemas with enum values --- .stats.yml | 4 +- .../beta/v2/files/FileUploadResponse.kt | 182 ++++++++++++++++- .../api/models/files/FileUpdateResponse.kt | 182 ++++++++++++++++- .../api/models/files/FileUploadResponse.kt | 182 ++++++++++++++++- .../UploadPreTransformSuccessEvent.kt | 183 +++++++++++++++++- .../beta/v2/files/FileUploadResponseTest.kt | 3 + .../models/files/FileUpdateResponseTest.kt | 3 + .../models/files/FileUploadResponseTest.kt | 3 + .../webhooks/UnsafeUnwrapWebhookEventTest.kt | 8 + .../models/webhooks/UnwrapWebhookEventTest.kt | 8 + .../UploadPreTransformSuccessEventTest.kt | 11 ++ 11 files changed, 759 insertions(+), 10 deletions(-) diff --git a/.stats.yml b/.stats.yml index f7feecbe..dc3fb535 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-606f0e2a6ecb6c36557e166764d39b8f619a74904db6bb5ed8bb348ed451b337.yml -openapi_spec_hash: 1d5f5cdb3f7992a183c368ecd009316e +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c028a7584d3508f268ce5c5b824b50af88eaa140620dd03a1b35f409f510603c.yml +openapi_spec_hash: f9b780b2398a87678a13355e48cd515f config_hash: aeb6eb949d73382270bbd8bbf2e4cf2a diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt index f4dbf49e..311e5191 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt @@ -1610,6 +1610,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val aiAutoDescription: JsonField, + private val aiTasks: JsonField, private val awsAutoTagging: JsonField, private val googleAutoTagging: JsonField, private val removeBg: JsonField, @@ -1621,6 +1622,9 @@ private constructor( @JsonProperty("ai-auto-description") @ExcludeMissing aiAutoDescription: JsonField = JsonMissing.of(), + @JsonProperty("ai-tasks") + @ExcludeMissing + aiTasks: JsonField = JsonMissing.of(), @JsonProperty("aws-auto-tagging") @ExcludeMissing awsAutoTagging: JsonField = JsonMissing.of(), @@ -1630,7 +1634,14 @@ private constructor( @JsonProperty("remove-bg") @ExcludeMissing removeBg: JsonField = JsonMissing.of(), - ) : this(aiAutoDescription, awsAutoTagging, googleAutoTagging, removeBg, mutableMapOf()) + ) : this( + aiAutoDescription, + aiTasks, + awsAutoTagging, + googleAutoTagging, + removeBg, + mutableMapOf(), + ) /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -1639,6 +1650,12 @@ private constructor( fun aiAutoDescription(): Optional = aiAutoDescription.getOptional("ai-auto-description") + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun aiTasks(): Optional = aiTasks.getOptional("ai-tasks") + /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -1669,6 +1686,13 @@ private constructor( @ExcludeMissing fun _aiAutoDescription(): JsonField = aiAutoDescription + /** + * Returns the raw JSON value of [aiTasks]. + * + * Unlike [aiTasks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ai-tasks") @ExcludeMissing fun _aiTasks(): JsonField = aiTasks + /** * Returns the raw JSON value of [awsAutoTagging]. * @@ -1718,6 +1742,7 @@ private constructor( class Builder internal constructor() { private var aiAutoDescription: JsonField = JsonMissing.of() + private var aiTasks: JsonField = JsonMissing.of() private var awsAutoTagging: JsonField = JsonMissing.of() private var googleAutoTagging: JsonField = JsonMissing.of() private var removeBg: JsonField = JsonMissing.of() @@ -1726,6 +1751,7 @@ private constructor( @JvmSynthetic internal fun from(extensionStatus: ExtensionStatus) = apply { aiAutoDescription = extensionStatus.aiAutoDescription + aiTasks = extensionStatus.aiTasks awsAutoTagging = extensionStatus.awsAutoTagging googleAutoTagging = extensionStatus.googleAutoTagging removeBg = extensionStatus.removeBg @@ -1746,6 +1772,17 @@ private constructor( this.aiAutoDescription = aiAutoDescription } + fun aiTasks(aiTasks: AiTasks) = aiTasks(JsonField.of(aiTasks)) + + /** + * Sets [Builder.aiTasks] to an arbitrary JSON value. + * + * You should usually call [Builder.aiTasks] with a well-typed [AiTasks] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun aiTasks(aiTasks: JsonField) = apply { this.aiTasks = aiTasks } + fun awsAutoTagging(awsAutoTagging: AwsAutoTagging) = awsAutoTagging(JsonField.of(awsAutoTagging)) @@ -1812,6 +1849,7 @@ private constructor( fun build(): ExtensionStatus = ExtensionStatus( aiAutoDescription, + aiTasks, awsAutoTagging, googleAutoTagging, removeBg, @@ -1827,6 +1865,7 @@ private constructor( } aiAutoDescription().ifPresent { it.validate() } + aiTasks().ifPresent { it.validate() } awsAutoTagging().ifPresent { it.validate() } googleAutoTagging().ifPresent { it.validate() } removeBg().ifPresent { it.validate() } @@ -1850,6 +1889,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (aiAutoDescription.asKnown().getOrNull()?.validity() ?: 0) + + (aiTasks.asKnown().getOrNull()?.validity() ?: 0) + (awsAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + (googleAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + (removeBg.asKnown().getOrNull()?.validity() ?: 0) @@ -1993,6 +2033,142 @@ private constructor( override fun toString() = value.toString() } + class AiTasks @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val PENDING = of("pending") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = AiTasks(JsonField.of(value)) + } + + /** An enum containing [AiTasks]'s known values. */ + enum class Known { + SUCCESS, + PENDING, + FAILED, + } + + /** + * An enum containing [AiTasks]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AiTasks] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + PENDING, + FAILED, + /** + * An enum member indicating that [AiTasks] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + PENDING -> Value.PENDING + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + PENDING -> Known.PENDING + FAILED -> Known.FAILED + else -> throw ImageKitInvalidDataException("Unknown AiTasks: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AiTasks = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiTasks && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class AwsAutoTagging @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2413,6 +2589,7 @@ private constructor( return other is ExtensionStatus && aiAutoDescription == other.aiAutoDescription && + aiTasks == other.aiTasks && awsAutoTagging == other.awsAutoTagging && googleAutoTagging == other.googleAutoTagging && removeBg == other.removeBg && @@ -2422,6 +2599,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( aiAutoDescription, + aiTasks, awsAutoTagging, googleAutoTagging, removeBg, @@ -2432,7 +2610,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ExtensionStatus{aiAutoDescription=$aiAutoDescription, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" + "ExtensionStatus{aiAutoDescription=$aiAutoDescription, aiTasks=$aiTasks, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" } /** diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt index 182020c9..f602334a 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt @@ -1103,6 +1103,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val aiAutoDescription: JsonField, + private val aiTasks: JsonField, private val awsAutoTagging: JsonField, private val googleAutoTagging: JsonField, private val removeBg: JsonField, @@ -1114,6 +1115,9 @@ private constructor( @JsonProperty("ai-auto-description") @ExcludeMissing aiAutoDescription: JsonField = JsonMissing.of(), + @JsonProperty("ai-tasks") + @ExcludeMissing + aiTasks: JsonField = JsonMissing.of(), @JsonProperty("aws-auto-tagging") @ExcludeMissing awsAutoTagging: JsonField = JsonMissing.of(), @@ -1123,7 +1127,14 @@ private constructor( @JsonProperty("remove-bg") @ExcludeMissing removeBg: JsonField = JsonMissing.of(), - ) : this(aiAutoDescription, awsAutoTagging, googleAutoTagging, removeBg, mutableMapOf()) + ) : this( + aiAutoDescription, + aiTasks, + awsAutoTagging, + googleAutoTagging, + removeBg, + mutableMapOf(), + ) /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -1132,6 +1143,12 @@ private constructor( fun aiAutoDescription(): Optional = aiAutoDescription.getOptional("ai-auto-description") + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun aiTasks(): Optional = aiTasks.getOptional("ai-tasks") + /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -1162,6 +1179,13 @@ private constructor( @ExcludeMissing fun _aiAutoDescription(): JsonField = aiAutoDescription + /** + * Returns the raw JSON value of [aiTasks]. + * + * Unlike [aiTasks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ai-tasks") @ExcludeMissing fun _aiTasks(): JsonField = aiTasks + /** * Returns the raw JSON value of [awsAutoTagging]. * @@ -1211,6 +1235,7 @@ private constructor( class Builder internal constructor() { private var aiAutoDescription: JsonField = JsonMissing.of() + private var aiTasks: JsonField = JsonMissing.of() private var awsAutoTagging: JsonField = JsonMissing.of() private var googleAutoTagging: JsonField = JsonMissing.of() private var removeBg: JsonField = JsonMissing.of() @@ -1219,6 +1244,7 @@ private constructor( @JvmSynthetic internal fun from(extensionStatus: ExtensionStatus) = apply { aiAutoDescription = extensionStatus.aiAutoDescription + aiTasks = extensionStatus.aiTasks awsAutoTagging = extensionStatus.awsAutoTagging googleAutoTagging = extensionStatus.googleAutoTagging removeBg = extensionStatus.removeBg @@ -1239,6 +1265,17 @@ private constructor( this.aiAutoDescription = aiAutoDescription } + fun aiTasks(aiTasks: AiTasks) = aiTasks(JsonField.of(aiTasks)) + + /** + * Sets [Builder.aiTasks] to an arbitrary JSON value. + * + * You should usually call [Builder.aiTasks] with a well-typed [AiTasks] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun aiTasks(aiTasks: JsonField) = apply { this.aiTasks = aiTasks } + fun awsAutoTagging(awsAutoTagging: AwsAutoTagging) = awsAutoTagging(JsonField.of(awsAutoTagging)) @@ -1305,6 +1342,7 @@ private constructor( fun build(): ExtensionStatus = ExtensionStatus( aiAutoDescription, + aiTasks, awsAutoTagging, googleAutoTagging, removeBg, @@ -1320,6 +1358,7 @@ private constructor( } aiAutoDescription().ifPresent { it.validate() } + aiTasks().ifPresent { it.validate() } awsAutoTagging().ifPresent { it.validate() } googleAutoTagging().ifPresent { it.validate() } removeBg().ifPresent { it.validate() } @@ -1343,6 +1382,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (aiAutoDescription.asKnown().getOrNull()?.validity() ?: 0) + + (aiTasks.asKnown().getOrNull()?.validity() ?: 0) + (awsAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + (googleAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + (removeBg.asKnown().getOrNull()?.validity() ?: 0) @@ -1486,6 +1526,142 @@ private constructor( override fun toString() = value.toString() } + class AiTasks @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val PENDING = of("pending") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = AiTasks(JsonField.of(value)) + } + + /** An enum containing [AiTasks]'s known values. */ + enum class Known { + SUCCESS, + PENDING, + FAILED, + } + + /** + * An enum containing [AiTasks]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AiTasks] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + PENDING, + FAILED, + /** + * An enum member indicating that [AiTasks] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + PENDING -> Value.PENDING + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + PENDING -> Known.PENDING + FAILED -> Known.FAILED + else -> throw ImageKitInvalidDataException("Unknown AiTasks: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AiTasks = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiTasks && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class AwsAutoTagging @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1906,6 +2082,7 @@ private constructor( return other is ExtensionStatus && aiAutoDescription == other.aiAutoDescription && + aiTasks == other.aiTasks && awsAutoTagging == other.awsAutoTagging && googleAutoTagging == other.googleAutoTagging && removeBg == other.removeBg && @@ -1915,6 +2092,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( aiAutoDescription, + aiTasks, awsAutoTagging, googleAutoTagging, removeBg, @@ -1925,7 +2103,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ExtensionStatus{aiAutoDescription=$aiAutoDescription, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" + "ExtensionStatus{aiAutoDescription=$aiAutoDescription, aiTasks=$aiTasks, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt index 9b414c10..436475a2 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt @@ -1609,6 +1609,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val aiAutoDescription: JsonField, + private val aiTasks: JsonField, private val awsAutoTagging: JsonField, private val googleAutoTagging: JsonField, private val removeBg: JsonField, @@ -1620,6 +1621,9 @@ private constructor( @JsonProperty("ai-auto-description") @ExcludeMissing aiAutoDescription: JsonField = JsonMissing.of(), + @JsonProperty("ai-tasks") + @ExcludeMissing + aiTasks: JsonField = JsonMissing.of(), @JsonProperty("aws-auto-tagging") @ExcludeMissing awsAutoTagging: JsonField = JsonMissing.of(), @@ -1629,7 +1633,14 @@ private constructor( @JsonProperty("remove-bg") @ExcludeMissing removeBg: JsonField = JsonMissing.of(), - ) : this(aiAutoDescription, awsAutoTagging, googleAutoTagging, removeBg, mutableMapOf()) + ) : this( + aiAutoDescription, + aiTasks, + awsAutoTagging, + googleAutoTagging, + removeBg, + mutableMapOf(), + ) /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -1638,6 +1649,12 @@ private constructor( fun aiAutoDescription(): Optional = aiAutoDescription.getOptional("ai-auto-description") + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun aiTasks(): Optional = aiTasks.getOptional("ai-tasks") + /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -1668,6 +1685,13 @@ private constructor( @ExcludeMissing fun _aiAutoDescription(): JsonField = aiAutoDescription + /** + * Returns the raw JSON value of [aiTasks]. + * + * Unlike [aiTasks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ai-tasks") @ExcludeMissing fun _aiTasks(): JsonField = aiTasks + /** * Returns the raw JSON value of [awsAutoTagging]. * @@ -1717,6 +1741,7 @@ private constructor( class Builder internal constructor() { private var aiAutoDescription: JsonField = JsonMissing.of() + private var aiTasks: JsonField = JsonMissing.of() private var awsAutoTagging: JsonField = JsonMissing.of() private var googleAutoTagging: JsonField = JsonMissing.of() private var removeBg: JsonField = JsonMissing.of() @@ -1725,6 +1750,7 @@ private constructor( @JvmSynthetic internal fun from(extensionStatus: ExtensionStatus) = apply { aiAutoDescription = extensionStatus.aiAutoDescription + aiTasks = extensionStatus.aiTasks awsAutoTagging = extensionStatus.awsAutoTagging googleAutoTagging = extensionStatus.googleAutoTagging removeBg = extensionStatus.removeBg @@ -1745,6 +1771,17 @@ private constructor( this.aiAutoDescription = aiAutoDescription } + fun aiTasks(aiTasks: AiTasks) = aiTasks(JsonField.of(aiTasks)) + + /** + * Sets [Builder.aiTasks] to an arbitrary JSON value. + * + * You should usually call [Builder.aiTasks] with a well-typed [AiTasks] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun aiTasks(aiTasks: JsonField) = apply { this.aiTasks = aiTasks } + fun awsAutoTagging(awsAutoTagging: AwsAutoTagging) = awsAutoTagging(JsonField.of(awsAutoTagging)) @@ -1811,6 +1848,7 @@ private constructor( fun build(): ExtensionStatus = ExtensionStatus( aiAutoDescription, + aiTasks, awsAutoTagging, googleAutoTagging, removeBg, @@ -1826,6 +1864,7 @@ private constructor( } aiAutoDescription().ifPresent { it.validate() } + aiTasks().ifPresent { it.validate() } awsAutoTagging().ifPresent { it.validate() } googleAutoTagging().ifPresent { it.validate() } removeBg().ifPresent { it.validate() } @@ -1849,6 +1888,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (aiAutoDescription.asKnown().getOrNull()?.validity() ?: 0) + + (aiTasks.asKnown().getOrNull()?.validity() ?: 0) + (awsAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + (googleAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + (removeBg.asKnown().getOrNull()?.validity() ?: 0) @@ -1992,6 +2032,142 @@ private constructor( override fun toString() = value.toString() } + class AiTasks @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val PENDING = of("pending") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = AiTasks(JsonField.of(value)) + } + + /** An enum containing [AiTasks]'s known values. */ + enum class Known { + SUCCESS, + PENDING, + FAILED, + } + + /** + * An enum containing [AiTasks]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AiTasks] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + PENDING, + FAILED, + /** + * An enum member indicating that [AiTasks] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + PENDING -> Value.PENDING + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + PENDING -> Known.PENDING + FAILED -> Known.FAILED + else -> throw ImageKitInvalidDataException("Unknown AiTasks: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AiTasks = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiTasks && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class AwsAutoTagging @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2412,6 +2588,7 @@ private constructor( return other is ExtensionStatus && aiAutoDescription == other.aiAutoDescription && + aiTasks == other.aiTasks && awsAutoTagging == other.awsAutoTagging && googleAutoTagging == other.googleAutoTagging && removeBg == other.removeBg && @@ -2421,6 +2598,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( aiAutoDescription, + aiTasks, awsAutoTagging, googleAutoTagging, removeBg, @@ -2431,7 +2609,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ExtensionStatus{aiAutoDescription=$aiAutoDescription, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" + "ExtensionStatus{aiAutoDescription=$aiAutoDescription, aiTasks=$aiTasks, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" } /** diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt index 1e48aded..2a0dc788 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt @@ -1961,6 +1961,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val aiAutoDescription: JsonField, + private val aiTasks: JsonField, private val awsAutoTagging: JsonField, private val googleAutoTagging: JsonField, private val removeBg: JsonField, @@ -1972,6 +1973,9 @@ private constructor( @JsonProperty("ai-auto-description") @ExcludeMissing aiAutoDescription: JsonField = JsonMissing.of(), + @JsonProperty("ai-tasks") + @ExcludeMissing + aiTasks: JsonField = JsonMissing.of(), @JsonProperty("aws-auto-tagging") @ExcludeMissing awsAutoTagging: JsonField = JsonMissing.of(), @@ -1981,7 +1985,14 @@ private constructor( @JsonProperty("remove-bg") @ExcludeMissing removeBg: JsonField = JsonMissing.of(), - ) : this(aiAutoDescription, awsAutoTagging, googleAutoTagging, removeBg, mutableMapOf()) + ) : this( + aiAutoDescription, + aiTasks, + awsAutoTagging, + googleAutoTagging, + removeBg, + mutableMapOf(), + ) /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. @@ -1990,6 +2001,12 @@ private constructor( fun aiAutoDescription(): Optional = aiAutoDescription.getOptional("ai-auto-description") + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun aiTasks(): Optional = aiTasks.getOptional("ai-tasks") + /** * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -2020,6 +2037,13 @@ private constructor( @ExcludeMissing fun _aiAutoDescription(): JsonField = aiAutoDescription + /** + * Returns the raw JSON value of [aiTasks]. + * + * Unlike [aiTasks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ai-tasks") @ExcludeMissing fun _aiTasks(): JsonField = aiTasks + /** * Returns the raw JSON value of [awsAutoTagging]. * @@ -2072,6 +2096,7 @@ private constructor( class Builder internal constructor() { private var aiAutoDescription: JsonField = JsonMissing.of() + private var aiTasks: JsonField = JsonMissing.of() private var awsAutoTagging: JsonField = JsonMissing.of() private var googleAutoTagging: JsonField = JsonMissing.of() private var removeBg: JsonField = JsonMissing.of() @@ -2080,6 +2105,7 @@ private constructor( @JvmSynthetic internal fun from(extensionStatus: ExtensionStatus) = apply { aiAutoDescription = extensionStatus.aiAutoDescription + aiTasks = extensionStatus.aiTasks awsAutoTagging = extensionStatus.awsAutoTagging googleAutoTagging = extensionStatus.googleAutoTagging removeBg = extensionStatus.removeBg @@ -2100,6 +2126,17 @@ private constructor( this.aiAutoDescription = aiAutoDescription } + fun aiTasks(aiTasks: AiTasks) = aiTasks(JsonField.of(aiTasks)) + + /** + * Sets [Builder.aiTasks] to an arbitrary JSON value. + * + * You should usually call [Builder.aiTasks] with a well-typed [AiTasks] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun aiTasks(aiTasks: JsonField) = apply { this.aiTasks = aiTasks } + fun awsAutoTagging(awsAutoTagging: AwsAutoTagging) = awsAutoTagging(JsonField.of(awsAutoTagging)) @@ -2169,6 +2206,7 @@ private constructor( fun build(): ExtensionStatus = ExtensionStatus( aiAutoDescription, + aiTasks, awsAutoTagging, googleAutoTagging, removeBg, @@ -2184,6 +2222,7 @@ private constructor( } aiAutoDescription().ifPresent { it.validate() } + aiTasks().ifPresent { it.validate() } awsAutoTagging().ifPresent { it.validate() } googleAutoTagging().ifPresent { it.validate() } removeBg().ifPresent { it.validate() } @@ -2207,6 +2246,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (aiAutoDescription.asKnown().getOrNull()?.validity() ?: 0) + + (aiTasks.asKnown().getOrNull()?.validity() ?: 0) + (awsAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + (googleAutoTagging.asKnown().getOrNull()?.validity() ?: 0) + (removeBg.asKnown().getOrNull()?.validity() ?: 0) @@ -2352,6 +2392,143 @@ private constructor( override fun toString() = value.toString() } + class AiTasks @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("success") + + @JvmField val PENDING = of("pending") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = AiTasks(JsonField.of(value)) + } + + /** An enum containing [AiTasks]'s known values. */ + enum class Known { + SUCCESS, + PENDING, + FAILED, + } + + /** + * An enum containing [AiTasks]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AiTasks] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + PENDING, + FAILED, + /** + * An enum member indicating that [AiTasks] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + PENDING -> Value.PENDING + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + PENDING -> Known.PENDING + FAILED -> Known.FAILED + else -> throw ImageKitInvalidDataException("Unknown AiTasks: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AiTasks = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiTasks && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class AwsAutoTagging @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2777,6 +2954,7 @@ private constructor( return other is ExtensionStatus && aiAutoDescription == other.aiAutoDescription && + aiTasks == other.aiTasks && awsAutoTagging == other.awsAutoTagging && googleAutoTagging == other.googleAutoTagging && removeBg == other.removeBg && @@ -2786,6 +2964,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( aiAutoDescription, + aiTasks, awsAutoTagging, googleAutoTagging, removeBg, @@ -2796,7 +2975,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ExtensionStatus{aiAutoDescription=$aiAutoDescription, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" + "ExtensionStatus{aiAutoDescription=$aiAutoDescription, aiTasks=$aiTasks, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" } /** diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt index 8793dc70..b01ab273 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt @@ -43,6 +43,7 @@ internal class FileUploadResponseTest { .aiAutoDescription( FileUploadResponse.ExtensionStatus.AiAutoDescription.SUCCESS ) + .aiTasks(FileUploadResponse.ExtensionStatus.AiTasks.SUCCESS) .awsAutoTagging(FileUploadResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) .googleAutoTagging( FileUploadResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS @@ -205,6 +206,7 @@ internal class FileUploadResponseTest { .contains( FileUploadResponse.ExtensionStatus.builder() .aiAutoDescription(FileUploadResponse.ExtensionStatus.AiAutoDescription.SUCCESS) + .aiTasks(FileUploadResponse.ExtensionStatus.AiTasks.SUCCESS) .awsAutoTagging(FileUploadResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) .googleAutoTagging(FileUploadResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS) .removeBg(FileUploadResponse.ExtensionStatus.RemoveBg.SUCCESS) @@ -370,6 +372,7 @@ internal class FileUploadResponseTest { .aiAutoDescription( FileUploadResponse.ExtensionStatus.AiAutoDescription.SUCCESS ) + .aiTasks(FileUploadResponse.ExtensionStatus.AiTasks.SUCCESS) .awsAutoTagging(FileUploadResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) .googleAutoTagging( FileUploadResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt index f9202b81..a2eb81ba 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt @@ -71,6 +71,7 @@ internal class FileUpdateResponseTest { .aiAutoDescription( FileUpdateResponse.ExtensionStatus.AiAutoDescription.SUCCESS ) + .aiTasks(FileUpdateResponse.ExtensionStatus.AiTasks.SUCCESS) .awsAutoTagging(FileUpdateResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) .googleAutoTagging( FileUpdateResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS @@ -139,6 +140,7 @@ internal class FileUpdateResponseTest { .contains( FileUpdateResponse.ExtensionStatus.builder() .aiAutoDescription(FileUpdateResponse.ExtensionStatus.AiAutoDescription.SUCCESS) + .aiTasks(FileUpdateResponse.ExtensionStatus.AiTasks.SUCCESS) .awsAutoTagging(FileUpdateResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) .googleAutoTagging(FileUpdateResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS) .removeBg(FileUpdateResponse.ExtensionStatus.RemoveBg.SUCCESS) @@ -206,6 +208,7 @@ internal class FileUpdateResponseTest { .aiAutoDescription( FileUpdateResponse.ExtensionStatus.AiAutoDescription.SUCCESS ) + .aiTasks(FileUpdateResponse.ExtensionStatus.AiTasks.SUCCESS) .awsAutoTagging(FileUpdateResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) .googleAutoTagging( FileUpdateResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt index 17484f6b..5a7ea647 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt @@ -42,6 +42,7 @@ internal class FileUploadResponseTest { .aiAutoDescription( FileUploadResponse.ExtensionStatus.AiAutoDescription.SUCCESS ) + .aiTasks(FileUploadResponse.ExtensionStatus.AiTasks.SUCCESS) .awsAutoTagging(FileUploadResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) .googleAutoTagging( FileUploadResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS @@ -204,6 +205,7 @@ internal class FileUploadResponseTest { .contains( FileUploadResponse.ExtensionStatus.builder() .aiAutoDescription(FileUploadResponse.ExtensionStatus.AiAutoDescription.SUCCESS) + .aiTasks(FileUploadResponse.ExtensionStatus.AiTasks.SUCCESS) .awsAutoTagging(FileUploadResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) .googleAutoTagging(FileUploadResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS) .removeBg(FileUploadResponse.ExtensionStatus.RemoveBg.SUCCESS) @@ -369,6 +371,7 @@ internal class FileUploadResponseTest { .aiAutoDescription( FileUploadResponse.ExtensionStatus.AiAutoDescription.SUCCESS ) + .aiTasks(FileUploadResponse.ExtensionStatus.AiTasks.SUCCESS) .awsAutoTagging(FileUploadResponse.ExtensionStatus.AwsAutoTagging.SUCCESS) .googleAutoTagging( FileUploadResponse.ExtensionStatus.GoogleAutoTagging.SUCCESS diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt index fffd15cd..420976f4 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt @@ -585,6 +585,10 @@ internal class UnsafeUnwrapWebhookEventTest { .AiAutoDescription .SUCCESS ) + .aiTasks( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.AiTasks + .SUCCESS + ) .awsAutoTagging( UploadPreTransformSuccessEvent.Data.ExtensionStatus .AwsAutoTagging @@ -795,6 +799,10 @@ internal class UnsafeUnwrapWebhookEventTest { .AiAutoDescription .SUCCESS ) + .aiTasks( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.AiTasks + .SUCCESS + ) .awsAutoTagging( UploadPreTransformSuccessEvent.Data.ExtensionStatus .AwsAutoTagging diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt index 24dfa675..52ff87bf 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt @@ -583,6 +583,10 @@ internal class UnwrapWebhookEventTest { .AiAutoDescription .SUCCESS ) + .aiTasks( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.AiTasks + .SUCCESS + ) .awsAutoTagging( UploadPreTransformSuccessEvent.Data.ExtensionStatus .AwsAutoTagging @@ -793,6 +797,10 @@ internal class UnwrapWebhookEventTest { .AiAutoDescription .SUCCESS ) + .aiTasks( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.AiTasks + .SUCCESS + ) .awsAutoTagging( UploadPreTransformSuccessEvent.Data.ExtensionStatus .AwsAutoTagging diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt index c0975186..1230eaf9 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt @@ -50,6 +50,10 @@ internal class UploadPreTransformSuccessEventTest { .AiAutoDescription .SUCCESS ) + .aiTasks( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.AiTasks + .SUCCESS + ) .awsAutoTagging( UploadPreTransformSuccessEvent.Data.ExtensionStatus .AwsAutoTagging @@ -243,6 +247,9 @@ internal class UploadPreTransformSuccessEventTest { .AiAutoDescription .SUCCESS ) + .aiTasks( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.AiTasks.SUCCESS + ) .awsAutoTagging( UploadPreTransformSuccessEvent.Data.ExtensionStatus.AwsAutoTagging .SUCCESS @@ -436,6 +443,10 @@ internal class UploadPreTransformSuccessEventTest { .AiAutoDescription .SUCCESS ) + .aiTasks( + UploadPreTransformSuccessEvent.Data.ExtensionStatus.AiTasks + .SUCCESS + ) .awsAutoTagging( UploadPreTransformSuccessEvent.Data.ExtensionStatus .AwsAutoTagging From 8e34e08c8aa939a06b933c0c29c0df46b175b8c2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 15 Jan 2026 19:38:57 +0000 Subject: [PATCH 075/142] chore(internal): clean up maven repo artifact script and add html documentation to repo root --- scripts/upload-artifacts | 44 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/scripts/upload-artifacts b/scripts/upload-artifacts index 729e6f22..df0c8d9f 100755 --- a/scripts/upload-artifacts +++ b/scripts/upload-artifacts @@ -7,6 +7,8 @@ GREEN='\033[32m' RED='\033[31m' NC='\033[0m' # No Color +MAVEN_REPO_PATH="./build/local-maven-repo" + log_error() { local msg="$1" local headers="$2" @@ -24,7 +26,7 @@ upload_file() { if [ -f "$file_name" ]; then echo -e "${GREEN}Processing file: $file_name${NC}" - pkg_file_name="mvn${file_name#./build/local-maven-repo}" + pkg_file_name="mvn${file_name#"${MAVEN_REPO_PATH}"}" # Get signed URL for uploading artifact file signed_url_response=$(curl -X POST -G "$URL" \ @@ -47,6 +49,7 @@ upload_file() { md5|sha1|sha256|sha512) content_type="text/plain" ;; module) content_type="application/json" ;; pom|xml) content_type="application/xml" ;; + html) content_type="text/html" ;; *) content_type="application/octet-stream" ;; esac @@ -81,6 +84,41 @@ walk_tree() { done } +generate_instructions() { + cat << EOF > "$MAVEN_REPO_PATH/index.html" + + + + Maven Repo + + +

Stainless SDK Maven Repository

+

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

+ +

Directions

+

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

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

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

+
repositories {
+    maven {
+        url 'https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn'
+    }
+}
+ + +EOF + upload_file "${MAVEN_REPO_PATH}/index.html" + + echo "Configure maven or gradle to use the repo located at 'https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn'" + echo "For more details, see the directions in https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn/index.html" +} + cd "$(dirname "$0")/.." echo "::group::Creating local Maven content" @@ -88,9 +126,9 @@ echo "::group::Creating local Maven content" echo "::endgroup::" echo "::group::Uploading to pkg.stainless.com" -walk_tree "./build/local-maven-repo" +walk_tree "$MAVEN_REPO_PATH" echo "::endgroup::" echo "::group::Generating instructions" -echo "Configure maven or gradle to use the repo located at 'https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn'" +generate_instructions echo "::endgroup::" From 7f3e0d6f67a4e7b598ef2763d81faff8e00b9959 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 16 Jan 2026 06:13:48 +0000 Subject: [PATCH 076/142] chore: test on Jackson 2.14.0 to avoid encountering FasterXML/jackson-databind#3240 in tests fix: date time deserialization leniency --- README.md | 2 ++ image-kit-java-core/build.gradle.kts | 18 +++++----- .../com/imagekit/api/core/ObjectMappers.kt | 33 +++++++++++------- .../imagekit/api/models/OverlayPosition.kt | 4 +-- .../com/imagekit/api/models/OverlayTiming.kt | 6 ++-- .../models/SolidColorOverlayTransformation.kt | 8 ++--- .../api/models/TextOverlayTransformation.kt | 12 +++---- .../com/imagekit/api/models/Transformation.kt | 34 +++++++++---------- .../CustomMetadataField.kt | 4 +-- .../CustomMetadataFieldCreateParams.kt | 4 +-- .../CustomMetadataFieldUpdateParams.kt | 4 +-- .../api/models/files/UpdateFileRequest.kt | 2 +- .../imagekit/api/core/ObjectMappersTest.kt | 16 +++------ image-kit-java-proguard-test/build.gradle.kts | 2 +- 14 files changed, 77 insertions(+), 72 deletions(-) diff --git a/README.md b/README.md index 70c2d6f0..5da339b3 100644 --- a/README.md +++ b/README.md @@ -340,6 +340,8 @@ If the SDK threw an exception, but you're _certain_ the version is compatible, t > [!CAUTION] > We make no guarantee that the SDK works correctly when the Jackson version check is disabled. +Also note that there are bugs in older Jackson versions that can affect the SDK. We don't work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead. + ## Network options ### Retries diff --git a/image-kit-java-core/build.gradle.kts b/image-kit-java-core/build.gradle.kts index 92263956..178d6aa7 100644 --- a/image-kit-java-core/build.gradle.kts +++ b/image-kit-java-core/build.gradle.kts @@ -5,14 +5,16 @@ plugins { configurations.all { resolutionStrategy { - // Compile and test against a lower Jackson version to ensure we're compatible with it. - // We publish with a higher version (see below) to ensure users depend on a secure version by default. - force("com.fasterxml.jackson.core:jackson-core:2.13.4") - force("com.fasterxml.jackson.core:jackson-databind:2.13.4") - force("com.fasterxml.jackson.core:jackson-annotations:2.13.4") - force("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.13.4") - force("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.4") - force("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4") + // Compile and test against a lower Jackson version to ensure we're compatible with it. Note that + // we generally support 2.13.4, but test against 2.14.0 because 2.13.4 has some annoying (but + // niche) bugs (users should upgrade if they encounter them). We publish with a higher version + // (see below) to ensure users depend on a secure version by default. + force("com.fasterxml.jackson.core:jackson-core:2.14.0") + force("com.fasterxml.jackson.core:jackson-databind:2.14.0") + force("com.fasterxml.jackson.core:jackson-annotations:2.14.0") + force("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.0") + force("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.0") + force("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.0") } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ObjectMappers.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ObjectMappers.kt index beaef0fa..53acf997 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ObjectMappers.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ObjectMappers.kt @@ -24,6 +24,7 @@ import java.io.InputStream import java.time.DateTimeException import java.time.LocalDate import java.time.LocalDateTime +import java.time.OffsetDateTime import java.time.ZonedDateTime import java.time.format.DateTimeFormatter import java.time.temporal.ChronoField @@ -36,7 +37,7 @@ fun jsonMapper(): JsonMapper = .addModule( SimpleModule() .addSerializer(InputStreamSerializer) - .addDeserializer(LocalDateTime::class.java, LenientLocalDateTimeDeserializer()) + .addDeserializer(OffsetDateTime::class.java, LenientOffsetDateTimeDeserializer()) ) .withCoercionConfig(LogicalType.Boolean) { it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) @@ -64,6 +65,12 @@ fun jsonMapper(): JsonMapper = .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) } + .withCoercionConfig(LogicalType.DateTime) { + it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } .withCoercionConfig(LogicalType.Array) { it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) @@ -124,10 +131,10 @@ private object InputStreamSerializer : BaseSerializer(InputStream:: } /** - * A deserializer that can deserialize [LocalDateTime] from datetimes, dates, and zoned datetimes. + * A deserializer that can deserialize [OffsetDateTime] from datetimes, dates, and zoned datetimes. */ -private class LenientLocalDateTimeDeserializer : - StdDeserializer(LocalDateTime::class.java) { +private class LenientOffsetDateTimeDeserializer : + StdDeserializer(OffsetDateTime::class.java) { companion object { @@ -141,7 +148,7 @@ private class LenientLocalDateTimeDeserializer : override fun logicalType(): LogicalType = LogicalType.DateTime - override fun deserialize(p: JsonParser, context: DeserializationContext?): LocalDateTime { + override fun deserialize(p: JsonParser, context: DeserializationContext): OffsetDateTime { val exceptions = mutableListOf() for (formatter in DATE_TIME_FORMATTERS) { @@ -149,18 +156,20 @@ private class LenientLocalDateTimeDeserializer : val temporal = formatter.parse(p.text) return when { - !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> - LocalDate.from(temporal).atStartOfDay() - !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> - LocalDateTime.from(temporal) - else -> ZonedDateTime.from(temporal).toLocalDateTime() - } + !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> + LocalDate.from(temporal).atStartOfDay() + !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> + LocalDateTime.from(temporal) + else -> ZonedDateTime.from(temporal).toLocalDateTime() + } + .atZone(context.timeZone.toZoneId()) + .toOffsetDateTime() } catch (e: DateTimeException) { exceptions.add(e) } } - throw JsonParseException(p, "Cannot parse `LocalDateTime` from value: ${p.text}").apply { + throw JsonParseException(p, "Cannot parse `OffsetDateTime` from value: ${p.text}").apply { exceptions.forEach { addSuppressed(it) } } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt index 1ad0cf1d..a06a80f0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt @@ -565,7 +565,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> X(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -737,7 +737,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> Y(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayTiming.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayTiming.kt index 27365d42..87b66b4d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayTiming.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayTiming.kt @@ -407,7 +407,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> Duration(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -580,7 +580,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> End(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -753,7 +753,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> Start(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt index dc511d70..0c825d4d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt @@ -548,7 +548,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from integer). 0 -> Gradient(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -720,7 +720,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> Height(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -925,7 +925,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> Radius(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -1098,7 +1098,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> Width(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt index 026bffd9..ca07ce6a 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt @@ -990,7 +990,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> FontSize(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -1301,7 +1301,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> LineHeight(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -1475,7 +1475,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> Padding(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -1680,7 +1680,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> Radius(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -1854,7 +1854,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> Rotation(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -2027,7 +2027,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> Width(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt index da307fcf..894e90c3 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt @@ -2847,7 +2847,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from integer). 0 -> AiDropShadow(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -3656,7 +3656,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> AspectRatio(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -4381,7 +4381,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> Duration(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -4555,7 +4555,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> EndOffset(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -5071,7 +5071,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from integer). 0 -> Gradient(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -5369,7 +5369,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> Height(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -5541,7 +5541,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> Page(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -5746,7 +5746,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> Radius(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -5923,7 +5923,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> Rotation(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -6105,7 +6105,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from integer). 0 -> Shadow(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -6463,7 +6463,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> StartOffset(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -6827,7 +6827,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from integer). 0 -> UnsharpMask(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -7146,7 +7146,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> Width(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -7316,7 +7316,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> X(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -7489,7 +7489,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> XCenter(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -7659,7 +7659,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> Y(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -7832,7 +7832,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> YCenter(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt index f46cd8ce..d5d717ea 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt @@ -1530,7 +1530,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). + // with all the possible variants (e.g. deserializing from boolean). 0 -> MaxValue(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the @@ -1705,7 +1705,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). + // with all the possible variants (e.g. deserializing from boolean). 0 -> MinValue(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt index 097f44c2..81b0ae90 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt @@ -1838,7 +1838,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). + // with all the possible variants (e.g. deserializing from boolean). 0 -> MaxValue(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the @@ -2013,7 +2013,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). + // with all the possible variants (e.g. deserializing from boolean). 0 -> MinValue(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt index f90753d0..5454e40b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt @@ -1560,7 +1560,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). + // with all the possible variants (e.g. deserializing from boolean). 0 -> MaxValue(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the @@ -1735,7 +1735,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). + // with all the possible variants (e.g. deserializing from boolean). 0 -> MinValue(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt index 6fa2463f..ae212b42 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt @@ -8256,7 +8256,7 @@ private constructor( .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). + // with all the possible variants (e.g. deserializing from boolean). 0 -> RemoveAiTags(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ObjectMappersTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ObjectMappersTest.kt index b340cb7d..27da86f7 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ObjectMappersTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ObjectMappersTest.kt @@ -3,7 +3,7 @@ package com.imagekit.api.core import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.exc.MismatchedInputException import com.fasterxml.jackson.module.kotlin.readValue -import java.time.LocalDateTime +import java.time.OffsetDateTime import kotlin.reflect.KClass import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.catchThrowable @@ -58,14 +58,6 @@ internal class ObjectMappersTest { LONG to DOUBLE, LONG to INTEGER, CLASS to MAP, - // These aren't actually valid, but coercion configs don't work for String until - // v2.14.0: https://github.com/FasterXML/jackson-databind/issues/3240 - // We currently test on v2.13.4. - BOOLEAN to STRING, - FLOAT to STRING, - DOUBLE to STRING, - INTEGER to STRING, - LONG to STRING, ) } } @@ -84,7 +76,7 @@ internal class ObjectMappersTest { } } - enum class LenientLocalDateTimeTestCase(val string: String) { + enum class LenientOffsetDateTimeTestCase(val string: String) { DATE("1998-04-21"), DATE_TIME("1998-04-21T04:00:00"), ZONED_DATE_TIME_1("1998-04-21T04:00:00+03:00"), @@ -93,10 +85,10 @@ internal class ObjectMappersTest { @ParameterizedTest @EnumSource - fun readLocalDateTime_lenient(testCase: LenientLocalDateTimeTestCase) { + fun readOffsetDateTime_lenient(testCase: LenientOffsetDateTimeTestCase) { val jsonMapper = jsonMapper() val json = jsonMapper.writeValueAsString(testCase.string) - assertDoesNotThrow { jsonMapper().readValue(json) } + assertDoesNotThrow { jsonMapper().readValue(json) } } } diff --git a/image-kit-java-proguard-test/build.gradle.kts b/image-kit-java-proguard-test/build.gradle.kts index c541ddc4..ea537228 100644 --- a/image-kit-java-proguard-test/build.gradle.kts +++ b/image-kit-java-proguard-test/build.gradle.kts @@ -19,7 +19,7 @@ dependencies { testImplementation(kotlin("test")) testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") testImplementation("org.assertj:assertj-core:3.25.3") - testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4") + testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.0") } tasks.shadowJar { From b92f5f0ea9c1defd19ed0224471dc6cd2bed2e2e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 16 Jan 2026 15:04:03 +0000 Subject: [PATCH 077/142] chore(internal): improve maven repo docs --- scripts/upload-artifacts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/upload-artifacts b/scripts/upload-artifacts index df0c8d9f..548d1527 100755 --- a/scripts/upload-artifacts +++ b/scripts/upload-artifacts @@ -56,12 +56,13 @@ upload_file() { # Upload file upload_response=$(curl -v -X PUT \ --retry 5 \ + --retry-all-errors \ -D "$tmp_headers" \ -H "Content-Type: $content_type" \ --data-binary "@${file_name}" "$signed_url" 2>&1) if ! echo "$upload_response" | grep -q "HTTP/[0-9.]* 200"; then - log_error "Failed upload artifact file" "$tmp_headers" "$upload_response" + log_error "Failed to upload artifact file" "$tmp_headers" "$upload_response" fi # Insert small throttle to reduce rate limiting risk @@ -110,6 +111,10 @@ generate_instructions() { url 'https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn' } } + +

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

EOF From a6dc3e26f63b2b3c2d5a8185c329f5140f84076d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 16 Jan 2026 18:23:56 +0000 Subject: [PATCH 078/142] fix(client): disallow coercion from float to int --- .../src/main/kotlin/com/imagekit/api/core/ObjectMappers.kt | 1 + .../test/kotlin/com/imagekit/api/core/ObjectMappersTest.kt | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ObjectMappers.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ObjectMappers.kt index 53acf997..1aad185a 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ObjectMappers.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ObjectMappers.kt @@ -48,6 +48,7 @@ fun jsonMapper(): JsonMapper = } .withCoercionConfig(LogicalType.Integer) { it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) .setCoercion(CoercionInputShape.String, CoercionAction.Fail) .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ObjectMappersTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ObjectMappersTest.kt index 27da86f7..28051b74 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ObjectMappersTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ObjectMappersTest.kt @@ -46,11 +46,7 @@ internal class ObjectMappersTest { val VALID_CONVERSIONS = listOf( FLOAT to DOUBLE, - FLOAT to INTEGER, - FLOAT to LONG, DOUBLE to FLOAT, - DOUBLE to INTEGER, - DOUBLE to LONG, INTEGER to FLOAT, INTEGER to DOUBLE, INTEGER to LONG, From 7115c3879f8983659e87b369a23600d4c2ae9646 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 16 Jan 2026 18:32:00 +0000 Subject: [PATCH 079/142] chore(internal): update `actions/checkout` version --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89204503..00beb894 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Java uses: actions/setup-java@v4 @@ -47,7 +47,7 @@ jobs: if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Java uses: actions/setup-java@v4 @@ -85,7 +85,7 @@ jobs: runs-on: ${{ github.repository == 'stainless-sdks/imagekit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Java uses: actions/setup-java@v4 From a7d3f1e74b0cd489ed67458efe462996b2706e50 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 16 Jan 2026 20:08:10 +0000 Subject: [PATCH 080/142] fix: deserialization order --- .../imagekit/api/models/OverlayPosition.kt | 12 +-- .../com/imagekit/api/models/OverlayTiming.kt | 18 ++--- .../models/SolidColorOverlayTransformation.kt | 18 ++--- .../api/models/TextOverlayTransformation.kt | 36 ++++----- .../com/imagekit/api/models/Transformation.kt | 78 +++++++++---------- 5 files changed, 81 insertions(+), 81 deletions(-) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt index a06a80f0..020f99a5 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt @@ -553,12 +553,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - X(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { X(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + X(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -725,12 +725,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Y(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Y(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Y(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayTiming.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayTiming.kt index 87b66b4d..d9a4b897 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayTiming.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayTiming.kt @@ -395,12 +395,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Duration(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Duration(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Duration(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -568,12 +568,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - End(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { End(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + End(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -741,12 +741,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Start(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Start(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Start(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt index 0c825d4d..89a9ee26 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt @@ -708,12 +708,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Height(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Height(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Height(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -913,12 +913,12 @@ private constructor( tryDeserialize(node, jacksonTypeRef()) ?.let { Radius(max = it, _json = json) } ?.takeIf { it.isValid() }, - tryDeserialize(node, jacksonTypeRef())?.let { - Radius(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Radius(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Radius(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1086,12 +1086,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Width(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Width(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Width(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt index ca07ce6a..737b98a8 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt @@ -978,12 +978,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - FontSize(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { FontSize(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + FontSize(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1289,12 +1289,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - LineHeight(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { LineHeight(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + LineHeight(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1463,12 +1463,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Padding(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Padding(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Padding(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1668,12 +1668,12 @@ private constructor( tryDeserialize(node, jacksonTypeRef()) ?.let { Radius(max = it, _json = json) } ?.takeIf { it.isValid() }, - tryDeserialize(node, jacksonTypeRef())?.let { - Radius(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Radius(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Radius(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -1842,12 +1842,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Rotation(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Rotation(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Rotation(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -2015,12 +2015,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Width(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Width(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Width(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt index 894e90c3..ef063f90 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt @@ -3644,12 +3644,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - AspectRatio(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { AspectRatio(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + AspectRatio(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -4369,12 +4369,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Duration(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Duration(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Duration(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -4543,12 +4543,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - EndOffset(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { EndOffset(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + EndOffset(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -5357,12 +5357,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Height(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Height(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Height(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -5529,12 +5529,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Page(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Page(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Page(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -5734,12 +5734,12 @@ private constructor( tryDeserialize(node, jacksonTypeRef()) ?.let { Radius(max = it, _json = json) } ?.takeIf { it.isValid() }, - tryDeserialize(node, jacksonTypeRef())?.let { - Radius(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Radius(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Radius(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -5911,12 +5911,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Rotation(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Rotation(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Rotation(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -6451,12 +6451,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - StartOffset(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { StartOffset(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + StartOffset(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -7134,12 +7134,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Width(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Width(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Width(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -7304,12 +7304,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - X(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { X(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + X(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -7477,12 +7477,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - XCenter(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { XCenter(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + XCenter(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -7647,12 +7647,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Y(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Y(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Y(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -7820,12 +7820,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - YCenter(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { YCenter(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + YCenter(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } From 87d2ad3db0d0730371b5f814dd5a14c2c0ab0ee0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 16 Jan 2026 20:16:54 +0000 Subject: [PATCH 081/142] fix(client): fully respect max retries fix(client): send retry count header for max retries 0 chore(internal): depend on packages directly in example --- .../api/client/okhttp/OkHttpClient.kt | 2 ++ .../api/core/http/RetryingHttpClient.kt | 20 +++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt index 8f64b63d..5cc27388 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt @@ -230,6 +230,8 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien fun build(): OkHttpClient = OkHttpClient( okhttp3.OkHttpClient.Builder() + // `RetryingHttpClient` handles retries if the user enabled them. + .retryOnConnectionFailure(false) .connectTimeout(timeout.connect()) .readTimeout(timeout.read()) .writeTimeout(timeout.write()) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt index 0e3fcde5..787b5be8 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt @@ -31,10 +31,6 @@ private constructor( ) : HttpClient { override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { - if (!isRetryable(request) || maxRetries <= 0) { - return httpClient.execute(request, requestOptions) - } - var modifiedRequest = maybeAddIdempotencyHeader(request) // Don't send the current retry count in the headers if the caller set their own value. @@ -48,6 +44,10 @@ private constructor( modifiedRequest = setRetryCountHeader(modifiedRequest, retries) } + if (!isRetryable(modifiedRequest)) { + return httpClient.execute(modifiedRequest, requestOptions) + } + val response = try { val response = httpClient.execute(modifiedRequest, requestOptions) @@ -75,10 +75,6 @@ private constructor( request: HttpRequest, requestOptions: RequestOptions, ): CompletableFuture { - if (!isRetryable(request) || maxRetries <= 0) { - return httpClient.executeAsync(request, requestOptions) - } - val modifiedRequest = maybeAddIdempotencyHeader(request) // Don't send the current retry count in the headers if the caller set their own value. @@ -94,8 +90,12 @@ private constructor( val requestWithRetryCount = if (shouldSendRetryCount) setRetryCountHeader(request, retries) else request - return httpClient - .executeAsync(requestWithRetryCount, requestOptions) + val responseFuture = httpClient.executeAsync(requestWithRetryCount, requestOptions) + if (!isRetryable(requestWithRetryCount)) { + return responseFuture + } + + return responseFuture .handleAsync( fun( response: HttpResponse?, From e60fd58b5a303ea126c427f046fc30c0c63bfa79 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 16 Jan 2026 20:37:03 +0000 Subject: [PATCH 082/142] chore(ci): upgrade `actions/setup-java` --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00beb894..bd493e07 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: - uses: actions/checkout@v6 - name: Set up Java - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: temurin java-version: | @@ -50,7 +50,7 @@ jobs: - uses: actions/checkout@v6 - name: Set up Java - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: temurin java-version: | @@ -88,7 +88,7 @@ jobs: - uses: actions/checkout@v6 - name: Set up Java - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: temurin java-version: | From ea9bfc30c34316aca3f1536e366b920e7e9c8bb7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 20 Jan 2026 06:11:01 +0000 Subject: [PATCH 083/142] fix: vocab field is required --- .stats.yml | 4 +- .../imagekit/api/models/ExtensionConfig.kt | 138 +++++++++-------- .../models/beta/v2/files/FileUploadParams.kt | 128 ++++++++-------- .../api/models/files/FileUploadParams.kt | 128 ++++++++-------- .../api/models/files/UpdateFileRequest.kt | 143 +++++++++--------- .../api/models/ExtensionConfigTest.kt | 4 +- .../beta/v2/files/FileUploadParamsTest.kt | 12 +- .../api/models/files/FileUpdateParamsTest.kt | 6 +- .../api/models/files/FileUploadParamsTest.kt | 12 +- .../api/models/files/UpdateFileRequestTest.kt | 8 +- .../api/services/ErrorHandlingTest.kt | 68 ++++----- .../api/services/ServiceParamsTest.kt | 4 +- .../services/async/FileServiceAsyncTest.kt | 6 +- .../async/beta/v2/FileServiceAsyncTest.kt | 4 +- .../api/services/blocking/FileServiceTest.kt | 6 +- .../blocking/beta/v2/FileServiceTest.kt | 4 +- .../api/proguard/ProGuardCompatibilityTest.kt | 2 +- 17 files changed, 354 insertions(+), 323 deletions(-) diff --git a/.stats.yml b/.stats.yml index dc3fb535..751099cf 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c028a7584d3508f268ce5c5b824b50af88eaa140620dd03a1b35f409f510603c.yml -openapi_spec_hash: f9b780b2398a87678a13355e48cd515f +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-84f0d75048a9268981a84800b4190e3691997ce57dcfc0876f38a5b3fce6bacd.yml +openapi_spec_hash: 35607d4e850c8a60524223ff632c83bb config_hash: aeb6eb949d73382270bbd8bbf2e4cf2a diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt index 12fba239..89692a98 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt @@ -1240,6 +1240,17 @@ private constructor( /** Alias for calling [addTask] with `Task.ofSelectTags(selectTags)`. */ fun addTask(selectTags: Task.SelectTags) = addTask(Task.ofSelectTags(selectTags)) + /** + * Alias for calling [addTask] with the following: + * ```java + * Task.SelectTags.builder() + * .instruction(instruction) + * .build() + * ``` + */ + fun addSelectTagsTask(instruction: String) = + addTask(Task.SelectTags.builder().instruction(instruction).build()) + /** Alias for calling [addTask] with `Task.ofSelectMetadata(selectMetadata)`. */ fun addTask(selectMetadata: Task.SelectMetadata) = addTask(Task.ofSelectMetadata(selectMetadata)) @@ -1533,9 +1544,9 @@ private constructor( private constructor( private val instruction: JsonField, private val type: JsonValue, - private val vocabulary: JsonField>, private val maxSelections: JsonField, private val minSelections: JsonField, + private val vocabulary: JsonField>, private val additionalProperties: MutableMap, ) { @@ -1545,21 +1556,21 @@ private constructor( @ExcludeMissing instruction: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - @JsonProperty("vocabulary") - @ExcludeMissing - vocabulary: JsonField> = JsonMissing.of(), @JsonProperty("max_selections") @ExcludeMissing maxSelections: JsonField = JsonMissing.of(), @JsonProperty("min_selections") @ExcludeMissing minSelections: JsonField = JsonMissing.of(), + @JsonProperty("vocabulary") + @ExcludeMissing + vocabulary: JsonField> = JsonMissing.of(), ) : this( instruction, type, - vocabulary, maxSelections, minSelections, + vocabulary, mutableMapOf(), ) @@ -1585,16 +1596,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * Array of possible tag values. Combined length of all strings must not exceed 500 - * characters. Cannot contain the `%` character. - * - * @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 vocabulary(): List = vocabulary.getRequired("vocabulary") - /** * Maximum number of tags to select from the vocabulary. * @@ -1612,24 +1613,23 @@ private constructor( fun minSelections(): Optional = minSelections.getOptional("min_selections") /** - * Returns the raw JSON value of [instruction]. + * Array of possible tag values. Combined length of all strings must not exceed 500 + * characters. Cannot contain the `%` character. * - * Unlike [instruction], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - @JsonProperty("instruction") - @ExcludeMissing - fun _instruction(): JsonField = instruction + fun vocabulary(): Optional> = vocabulary.getOptional("vocabulary") /** - * Returns the raw JSON value of [vocabulary]. + * Returns the raw JSON value of [instruction]. * - * Unlike [vocabulary], this method doesn't throw if the JSON field has an + * Unlike [instruction], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("vocabulary") + @JsonProperty("instruction") @ExcludeMissing - fun _vocabulary(): JsonField> = vocabulary + fun _instruction(): JsonField = instruction /** * Returns the raw JSON value of [maxSelections]. @@ -1651,6 +1651,16 @@ private constructor( @ExcludeMissing fun _minSelections(): JsonField = minSelections + /** + * Returns the raw JSON value of [vocabulary]. + * + * Unlike [vocabulary], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("vocabulary") + @ExcludeMissing + fun _vocabulary(): JsonField> = vocabulary + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -1671,7 +1681,6 @@ private constructor( * The following fields are required: * ```java * .instruction() - * .vocabulary() * ``` */ @JvmStatic fun builder() = Builder() @@ -1682,18 +1691,18 @@ private constructor( private var instruction: JsonField? = null private var type: JsonValue = JsonValue.from("select_tags") - private var vocabulary: JsonField>? = null private var maxSelections: JsonField = JsonMissing.of() private var minSelections: JsonField = JsonMissing.of() + private var vocabulary: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(selectTags: SelectTags) = apply { instruction = selectTags.instruction type = selectTags.type - vocabulary = selectTags.vocabulary.map { it.toMutableList() } maxSelections = selectTags.maxSelections minSelections = selectTags.minSelections + vocabulary = selectTags.vocabulary.map { it.toMutableList() } additionalProperties = selectTags.additionalProperties.toMutableMap() } @@ -1725,35 +1734,6 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } - /** - * Array of possible tag values. Combined length of all strings must not exceed - * 500 characters. Cannot contain the `%` character. - */ - fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) - - /** - * Sets [Builder.vocabulary] to an arbitrary JSON value. - * - * You should usually call [Builder.vocabulary] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun vocabulary(vocabulary: JsonField>) = apply { - this.vocabulary = vocabulary.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.vocabulary]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addVocabulary(vocabulary: String) = apply { - this.vocabulary = - (this.vocabulary ?: JsonField.of(mutableListOf())).also { - checkKnown("vocabulary", it).add(vocabulary) - } - } - /** Maximum number of tags to select from the vocabulary. */ fun maxSelections(maxSelections: Long) = maxSelections(JsonField.of(maxSelections)) @@ -1784,6 +1764,35 @@ private constructor( this.minSelections = minSelections } + /** + * Array of possible tag values. Combined length of all strings must not exceed + * 500 characters. Cannot contain the `%` character. + */ + fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) + + /** + * Sets [Builder.vocabulary] to an arbitrary JSON value. + * + * You should usually call [Builder.vocabulary] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun vocabulary(vocabulary: JsonField>) = apply { + this.vocabulary = vocabulary.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.vocabulary]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVocabulary(vocabulary: String) = apply { + this.vocabulary = + (this.vocabulary ?: JsonField.of(mutableListOf())).also { + checkKnown("vocabulary", it).add(vocabulary) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1814,7 +1823,6 @@ private constructor( * The following fields are required: * ```java * .instruction() - * .vocabulary() * ``` * * @throws IllegalStateException if any required field is unset. @@ -1823,9 +1831,9 @@ private constructor( SelectTags( checkRequired("instruction", instruction), type, - checkRequired("vocabulary", vocabulary).map { it.toImmutable() }, maxSelections, minSelections, + (vocabulary ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } @@ -1843,9 +1851,9 @@ private constructor( throw ImageKitInvalidDataException("'type' is invalid, received $it") } } - vocabulary() maxSelections() minSelections() + vocabulary() validated = true } @@ -1867,9 +1875,9 @@ private constructor( internal fun validity(): Int = (if (instruction.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("select_tags")) 1 else 0 } + - (vocabulary.asKnown().getOrNull()?.size ?: 0) + (if (maxSelections.asKnown().isPresent) 1 else 0) + - (if (minSelections.asKnown().isPresent) 1 else 0) + (if (minSelections.asKnown().isPresent) 1 else 0) + + (vocabulary.asKnown().getOrNull()?.size ?: 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -1879,9 +1887,9 @@ private constructor( return other is SelectTags && instruction == other.instruction && type == other.type && - vocabulary == other.vocabulary && maxSelections == other.maxSelections && minSelections == other.minSelections && + vocabulary == other.vocabulary && additionalProperties == other.additionalProperties } @@ -1889,9 +1897,9 @@ private constructor( Objects.hash( instruction, type, - vocabulary, maxSelections, minSelections, + vocabulary, additionalProperties, ) } @@ -1899,7 +1907,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "SelectTags{instruction=$instruction, type=$type, vocabulary=$vocabulary, maxSelections=$maxSelections, minSelections=$minSelections, additionalProperties=$additionalProperties}" + "SelectTags{instruction=$instruction, type=$type, maxSelections=$maxSelections, minSelections=$minSelections, vocabulary=$vocabulary, additionalProperties=$additionalProperties}" } class SelectMetadata diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt index a611622f..f875e7ac 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt @@ -3515,6 +3515,17 @@ private constructor( /** Alias for calling [addTask] with `Task.ofSelectTags(selectTags)`. */ fun addTask(selectTags: Task.SelectTags) = addTask(Task.ofSelectTags(selectTags)) + /** + * Alias for calling [addTask] with the following: + * ```java + * Task.SelectTags.builder() + * .instruction(instruction) + * .build() + * ``` + */ + fun addSelectTagsTask(instruction: String) = + addTask(Task.SelectTags.builder().instruction(instruction).build()) + /** Alias for calling [addTask] with `Task.ofSelectMetadata(selectMetadata)`. */ fun addTask(selectMetadata: Task.SelectMetadata) = addTask(Task.ofSelectMetadata(selectMetadata)) @@ -3752,9 +3763,9 @@ private constructor( private constructor( private val instruction: JsonField, private val type: JsonValue, - private val vocabulary: JsonField>, private val maxSelections: JsonField, private val minSelections: JsonField, + private val vocabulary: JsonField>, private val additionalProperties: MutableMap, ) { @@ -3780,16 +3791,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * Array of possible tag values. Combined length of all strings must not exceed - * 500 characters. Cannot contain the `%` character. - * - * @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 vocabulary(): List = vocabulary.getRequired("vocabulary") - /** * Maximum number of tags to select from the vocabulary. * @@ -3809,24 +3810,23 @@ private constructor( minSelections.getOptional("min_selections") /** - * Returns the raw JSON value of [instruction]. + * Array of possible tag values. Combined length of all strings must not exceed + * 500 characters. Cannot contain the `%` character. * - * Unlike [instruction], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - @JsonProperty("instruction") - @ExcludeMissing - fun _instruction(): JsonField = instruction + fun vocabulary(): Optional> = vocabulary.getOptional("vocabulary") /** - * Returns the raw JSON value of [vocabulary]. + * Returns the raw JSON value of [instruction]. * - * Unlike [vocabulary], this method doesn't throw if the JSON field has an + * Unlike [instruction], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("vocabulary") + @JsonProperty("instruction") @ExcludeMissing - fun _vocabulary(): JsonField> = vocabulary + fun _instruction(): JsonField = instruction /** * Returns the raw JSON value of [maxSelections]. @@ -3848,6 +3848,16 @@ private constructor( @ExcludeMissing fun _minSelections(): JsonField = minSelections + /** + * Returns the raw JSON value of [vocabulary]. + * + * Unlike [vocabulary], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("vocabulary") + @ExcludeMissing + fun _vocabulary(): JsonField> = vocabulary + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -3868,7 +3878,6 @@ private constructor( * The following fields are required: * ```java * .instruction() - * .vocabulary() * ``` */ @JvmStatic fun builder() = Builder() @@ -3879,9 +3888,9 @@ private constructor( private var instruction: JsonField? = null private var type: JsonValue = JsonValue.from("select_tags") - private var vocabulary: JsonField>? = null private var maxSelections: JsonField = JsonMissing.of() private var minSelections: JsonField = JsonMissing.of() + private var vocabulary: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -3889,9 +3898,9 @@ private constructor( internal fun from(selectTags: SelectTags) = apply { instruction = selectTags.instruction type = selectTags.type - vocabulary = selectTags.vocabulary.map { it.toMutableList() } maxSelections = selectTags.maxSelections minSelections = selectTags.minSelections + vocabulary = selectTags.vocabulary.map { it.toMutableList() } additionalProperties = selectTags.additionalProperties.toMutableMap() } @@ -3924,6 +3933,36 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + /** Maximum number of tags to select from the vocabulary. */ + fun maxSelections(maxSelections: Long) = + maxSelections(JsonField.of(maxSelections)) + + /** + * Sets [Builder.maxSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.maxSelections] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun maxSelections(maxSelections: JsonField) = apply { + this.maxSelections = maxSelections + } + + /** Minimum number of tags to select from the vocabulary. */ + fun minSelections(minSelections: Long) = + minSelections(JsonField.of(minSelections)) + + /** + * Sets [Builder.minSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.minSelections] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minSelections(minSelections: JsonField) = apply { + this.minSelections = minSelections + } + /** * Array of possible tag values. Combined length of all strings must not * exceed 500 characters. Cannot contain the `%` character. @@ -3955,36 +3994,6 @@ private constructor( } } - /** Maximum number of tags to select from the vocabulary. */ - fun maxSelections(maxSelections: Long) = - maxSelections(JsonField.of(maxSelections)) - - /** - * Sets [Builder.maxSelections] to an arbitrary JSON value. - * - * You should usually call [Builder.maxSelections] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun maxSelections(maxSelections: JsonField) = apply { - this.maxSelections = maxSelections - } - - /** Minimum number of tags to select from the vocabulary. */ - fun minSelections(minSelections: Long) = - minSelections(JsonField.of(minSelections)) - - /** - * Sets [Builder.minSelections] to an arbitrary JSON value. - * - * You should usually call [Builder.minSelections] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun minSelections(minSelections: JsonField) = apply { - this.minSelections = minSelections - } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4015,7 +4024,6 @@ private constructor( * The following fields are required: * ```java * .instruction() - * .vocabulary() * ``` * * @throws IllegalStateException if any required field is unset. @@ -4024,9 +4032,9 @@ private constructor( SelectTags( checkRequired("instruction", instruction), type, - checkRequired("vocabulary", vocabulary).map { it.toImmutable() }, maxSelections, minSelections, + (vocabulary ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } @@ -4046,9 +4054,9 @@ private constructor( ) } } - vocabulary() maxSelections() minSelections() + vocabulary() validated = true } @@ -4068,9 +4076,9 @@ private constructor( return other is SelectTags && instruction == other.instruction && type == other.type && - vocabulary == other.vocabulary && maxSelections == other.maxSelections && minSelections == other.minSelections && + vocabulary == other.vocabulary && additionalProperties == other.additionalProperties } @@ -4078,9 +4086,9 @@ private constructor( Objects.hash( instruction, type, - vocabulary, maxSelections, minSelections, + vocabulary, additionalProperties, ) } @@ -4088,7 +4096,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "SelectTags{instruction=$instruction, type=$type, vocabulary=$vocabulary, maxSelections=$maxSelections, minSelections=$minSelections, additionalProperties=$additionalProperties}" + "SelectTags{instruction=$instruction, type=$type, maxSelections=$maxSelections, minSelections=$minSelections, vocabulary=$vocabulary, additionalProperties=$additionalProperties}" } class SelectMetadata diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt index 9fa357ee..2b1fa12c 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -3781,6 +3781,17 @@ private constructor( /** Alias for calling [addTask] with `Task.ofSelectTags(selectTags)`. */ fun addTask(selectTags: Task.SelectTags) = addTask(Task.ofSelectTags(selectTags)) + /** + * Alias for calling [addTask] with the following: + * ```java + * Task.SelectTags.builder() + * .instruction(instruction) + * .build() + * ``` + */ + fun addSelectTagsTask(instruction: String) = + addTask(Task.SelectTags.builder().instruction(instruction).build()) + /** Alias for calling [addTask] with `Task.ofSelectMetadata(selectMetadata)`. */ fun addTask(selectMetadata: Task.SelectMetadata) = addTask(Task.ofSelectMetadata(selectMetadata)) @@ -4018,9 +4029,9 @@ private constructor( private constructor( private val instruction: JsonField, private val type: JsonValue, - private val vocabulary: JsonField>, private val maxSelections: JsonField, private val minSelections: JsonField, + private val vocabulary: JsonField>, private val additionalProperties: MutableMap, ) { @@ -4046,16 +4057,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * Array of possible tag values. Combined length of all strings must not exceed - * 500 characters. Cannot contain the `%` character. - * - * @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 vocabulary(): List = vocabulary.getRequired("vocabulary") - /** * Maximum number of tags to select from the vocabulary. * @@ -4075,24 +4076,23 @@ private constructor( minSelections.getOptional("min_selections") /** - * Returns the raw JSON value of [instruction]. + * Array of possible tag values. Combined length of all strings must not exceed + * 500 characters. Cannot contain the `%` character. * - * Unlike [instruction], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - @JsonProperty("instruction") - @ExcludeMissing - fun _instruction(): JsonField = instruction + fun vocabulary(): Optional> = vocabulary.getOptional("vocabulary") /** - * Returns the raw JSON value of [vocabulary]. + * Returns the raw JSON value of [instruction]. * - * Unlike [vocabulary], this method doesn't throw if the JSON field has an + * Unlike [instruction], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("vocabulary") + @JsonProperty("instruction") @ExcludeMissing - fun _vocabulary(): JsonField> = vocabulary + fun _instruction(): JsonField = instruction /** * Returns the raw JSON value of [maxSelections]. @@ -4114,6 +4114,16 @@ private constructor( @ExcludeMissing fun _minSelections(): JsonField = minSelections + /** + * Returns the raw JSON value of [vocabulary]. + * + * Unlike [vocabulary], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("vocabulary") + @ExcludeMissing + fun _vocabulary(): JsonField> = vocabulary + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -4134,7 +4144,6 @@ private constructor( * The following fields are required: * ```java * .instruction() - * .vocabulary() * ``` */ @JvmStatic fun builder() = Builder() @@ -4145,9 +4154,9 @@ private constructor( private var instruction: JsonField? = null private var type: JsonValue = JsonValue.from("select_tags") - private var vocabulary: JsonField>? = null private var maxSelections: JsonField = JsonMissing.of() private var minSelections: JsonField = JsonMissing.of() + private var vocabulary: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -4155,9 +4164,9 @@ private constructor( internal fun from(selectTags: SelectTags) = apply { instruction = selectTags.instruction type = selectTags.type - vocabulary = selectTags.vocabulary.map { it.toMutableList() } maxSelections = selectTags.maxSelections minSelections = selectTags.minSelections + vocabulary = selectTags.vocabulary.map { it.toMutableList() } additionalProperties = selectTags.additionalProperties.toMutableMap() } @@ -4190,6 +4199,36 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + /** Maximum number of tags to select from the vocabulary. */ + fun maxSelections(maxSelections: Long) = + maxSelections(JsonField.of(maxSelections)) + + /** + * Sets [Builder.maxSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.maxSelections] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun maxSelections(maxSelections: JsonField) = apply { + this.maxSelections = maxSelections + } + + /** Minimum number of tags to select from the vocabulary. */ + fun minSelections(minSelections: Long) = + minSelections(JsonField.of(minSelections)) + + /** + * Sets [Builder.minSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.minSelections] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minSelections(minSelections: JsonField) = apply { + this.minSelections = minSelections + } + /** * Array of possible tag values. Combined length of all strings must not * exceed 500 characters. Cannot contain the `%` character. @@ -4221,36 +4260,6 @@ private constructor( } } - /** Maximum number of tags to select from the vocabulary. */ - fun maxSelections(maxSelections: Long) = - maxSelections(JsonField.of(maxSelections)) - - /** - * Sets [Builder.maxSelections] to an arbitrary JSON value. - * - * You should usually call [Builder.maxSelections] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun maxSelections(maxSelections: JsonField) = apply { - this.maxSelections = maxSelections - } - - /** Minimum number of tags to select from the vocabulary. */ - fun minSelections(minSelections: Long) = - minSelections(JsonField.of(minSelections)) - - /** - * Sets [Builder.minSelections] to an arbitrary JSON value. - * - * You should usually call [Builder.minSelections] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun minSelections(minSelections: JsonField) = apply { - this.minSelections = minSelections - } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4281,7 +4290,6 @@ private constructor( * The following fields are required: * ```java * .instruction() - * .vocabulary() * ``` * * @throws IllegalStateException if any required field is unset. @@ -4290,9 +4298,9 @@ private constructor( SelectTags( checkRequired("instruction", instruction), type, - checkRequired("vocabulary", vocabulary).map { it.toImmutable() }, maxSelections, minSelections, + (vocabulary ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } @@ -4312,9 +4320,9 @@ private constructor( ) } } - vocabulary() maxSelections() minSelections() + vocabulary() validated = true } @@ -4334,9 +4342,9 @@ private constructor( return other is SelectTags && instruction == other.instruction && type == other.type && - vocabulary == other.vocabulary && maxSelections == other.maxSelections && minSelections == other.minSelections && + vocabulary == other.vocabulary && additionalProperties == other.additionalProperties } @@ -4344,9 +4352,9 @@ private constructor( Objects.hash( instruction, type, - vocabulary, maxSelections, minSelections, + vocabulary, additionalProperties, ) } @@ -4354,7 +4362,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "SelectTags{instruction=$instruction, type=$type, vocabulary=$vocabulary, maxSelections=$maxSelections, minSelections=$minSelections, additionalProperties=$additionalProperties}" + "SelectTags{instruction=$instruction, type=$type, maxSelections=$maxSelections, minSelections=$minSelections, vocabulary=$vocabulary, additionalProperties=$additionalProperties}" } class SelectMetadata diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt index ae212b42..888c2852 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt @@ -2170,6 +2170,17 @@ private constructor( fun addTask(selectTags: Task.SelectTags) = addTask(Task.ofSelectTags(selectTags)) + /** + * Alias for calling [addTask] with the following: + * ```java + * Task.SelectTags.builder() + * .instruction(instruction) + * .build() + * ``` + */ + fun addSelectTagsTask(instruction: String) = + addTask(Task.SelectTags.builder().instruction(instruction).build()) + /** Alias for calling [addTask] with `Task.ofSelectMetadata(selectMetadata)`. */ fun addTask(selectMetadata: Task.SelectMetadata) = addTask(Task.ofSelectMetadata(selectMetadata)) @@ -2473,9 +2484,9 @@ private constructor( private constructor( private val instruction: JsonField, private val type: JsonValue, - private val vocabulary: JsonField>, private val maxSelections: JsonField, private val minSelections: JsonField, + private val vocabulary: JsonField>, private val additionalProperties: MutableMap, ) { @@ -2487,21 +2498,21 @@ private constructor( @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), - @JsonProperty("vocabulary") - @ExcludeMissing - vocabulary: JsonField> = JsonMissing.of(), @JsonProperty("max_selections") @ExcludeMissing maxSelections: JsonField = JsonMissing.of(), @JsonProperty("min_selections") @ExcludeMissing minSelections: JsonField = JsonMissing.of(), + @JsonProperty("vocabulary") + @ExcludeMissing + vocabulary: JsonField> = JsonMissing.of(), ) : this( instruction, type, - vocabulary, maxSelections, minSelections, + vocabulary, mutableMapOf(), ) @@ -2528,16 +2539,6 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - /** - * Array of possible tag values. Combined length of all strings must not - * exceed 500 characters. Cannot contain the `%` character. - * - * @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 vocabulary(): List = vocabulary.getRequired("vocabulary") - /** * Maximum number of tags to select from the vocabulary. * @@ -2557,24 +2558,24 @@ private constructor( minSelections.getOptional("min_selections") /** - * Returns the raw JSON value of [instruction]. + * Array of possible tag values. Combined length of all strings must not + * exceed 500 characters. Cannot contain the `%` character. * - * Unlike [instruction], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). */ - @JsonProperty("instruction") - @ExcludeMissing - fun _instruction(): JsonField = instruction + fun vocabulary(): Optional> = + vocabulary.getOptional("vocabulary") /** - * Returns the raw JSON value of [vocabulary]. + * Returns the raw JSON value of [instruction]. * - * Unlike [vocabulary], this method doesn't throw if the JSON field has an + * Unlike [instruction], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("vocabulary") + @JsonProperty("instruction") @ExcludeMissing - fun _vocabulary(): JsonField> = vocabulary + fun _instruction(): JsonField = instruction /** * Returns the raw JSON value of [maxSelections]. @@ -2596,6 +2597,16 @@ private constructor( @ExcludeMissing fun _minSelections(): JsonField = minSelections + /** + * Returns the raw JSON value of [vocabulary]. + * + * Unlike [vocabulary], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("vocabulary") + @ExcludeMissing + fun _vocabulary(): JsonField> = vocabulary + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -2617,7 +2628,6 @@ private constructor( * The following fields are required: * ```java * .instruction() - * .vocabulary() * ``` */ @JvmStatic fun builder() = Builder() @@ -2628,9 +2638,9 @@ private constructor( private var instruction: JsonField? = null private var type: JsonValue = JsonValue.from("select_tags") - private var vocabulary: JsonField>? = null private var maxSelections: JsonField = JsonMissing.of() private var minSelections: JsonField = JsonMissing.of() + private var vocabulary: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -2638,9 +2648,9 @@ private constructor( internal fun from(selectTags: SelectTags) = apply { instruction = selectTags.instruction type = selectTags.type - vocabulary = selectTags.vocabulary.map { it.toMutableList() } maxSelections = selectTags.maxSelections minSelections = selectTags.minSelections + vocabulary = selectTags.vocabulary.map { it.toMutableList() } additionalProperties = selectTags.additionalProperties.toMutableMap() } @@ -2674,6 +2684,36 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + /** Maximum number of tags to select from the vocabulary. */ + fun maxSelections(maxSelections: Long) = + maxSelections(JsonField.of(maxSelections)) + + /** + * Sets [Builder.maxSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.maxSelections] with a well-typed + * [Long] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun maxSelections(maxSelections: JsonField) = apply { + this.maxSelections = maxSelections + } + + /** Minimum number of tags to select from the vocabulary. */ + fun minSelections(minSelections: Long) = + minSelections(JsonField.of(minSelections)) + + /** + * Sets [Builder.minSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.minSelections] with a well-typed + * [Long] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun minSelections(minSelections: JsonField) = apply { + this.minSelections = minSelections + } + /** * Array of possible tag values. Combined length of all strings must not * exceed 500 characters. Cannot contain the `%` character. @@ -2705,36 +2745,6 @@ private constructor( } } - /** Maximum number of tags to select from the vocabulary. */ - fun maxSelections(maxSelections: Long) = - maxSelections(JsonField.of(maxSelections)) - - /** - * Sets [Builder.maxSelections] to an arbitrary JSON value. - * - * You should usually call [Builder.maxSelections] with a well-typed - * [Long] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun maxSelections(maxSelections: JsonField) = apply { - this.maxSelections = maxSelections - } - - /** Minimum number of tags to select from the vocabulary. */ - fun minSelections(minSelections: Long) = - minSelections(JsonField.of(minSelections)) - - /** - * Sets [Builder.minSelections] to an arbitrary JSON value. - * - * You should usually call [Builder.minSelections] with a well-typed - * [Long] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun minSelections(minSelections: JsonField) = apply { - this.minSelections = minSelections - } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2766,7 +2776,6 @@ private constructor( * The following fields are required: * ```java * .instruction() - * .vocabulary() * ``` * * @throws IllegalStateException if any required field is unset. @@ -2775,11 +2784,9 @@ private constructor( SelectTags( checkRequired("instruction", instruction), type, - checkRequired("vocabulary", vocabulary).map { - it.toImmutable() - }, maxSelections, minSelections, + (vocabulary ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } @@ -2799,9 +2806,9 @@ private constructor( ) } } - vocabulary() maxSelections() minSelections() + vocabulary() validated = true } @@ -2823,9 +2830,9 @@ private constructor( internal fun validity(): Int = (if (instruction.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("select_tags")) 1 else 0 } + - (vocabulary.asKnown().getOrNull()?.size ?: 0) + (if (maxSelections.asKnown().isPresent) 1 else 0) + - (if (minSelections.asKnown().isPresent) 1 else 0) + (if (minSelections.asKnown().isPresent) 1 else 0) + + (vocabulary.asKnown().getOrNull()?.size ?: 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -2835,9 +2842,9 @@ private constructor( return other is SelectTags && instruction == other.instruction && type == other.type && - vocabulary == other.vocabulary && maxSelections == other.maxSelections && minSelections == other.minSelections && + vocabulary == other.vocabulary && additionalProperties == other.additionalProperties } @@ -2845,9 +2852,9 @@ private constructor( Objects.hash( instruction, type, - vocabulary, maxSelections, minSelections, + vocabulary, additionalProperties, ) } @@ -2855,7 +2862,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "SelectTags{instruction=$instruction, type=$type, vocabulary=$vocabulary, maxSelections=$maxSelections, minSelections=$minSelections, additionalProperties=$additionalProperties}" + "SelectTags{instruction=$instruction, type=$type, maxSelections=$maxSelections, minSelections=$minSelections, vocabulary=$vocabulary, additionalProperties=$additionalProperties}" } class SelectMetadata diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExtensionConfigTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExtensionConfigTest.kt index b2e6f0d6..9d548b34 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExtensionConfigTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExtensionConfigTest.kt @@ -132,9 +132,9 @@ internal class ExtensionConfigTest { .addTask( ExtensionConfig.AiTasks.Task.SelectTags.builder() .instruction("What types of clothing items are visible in this image?") - .vocabulary(listOf("shirt", "tshirt", "dress", "trousers", "jacket")) .maxSelections(1L) .minSelections(0L) + .vocabulary(listOf("shirt", "tshirt", "dress", "trousers", "jacket")) .build() ) .build() @@ -156,9 +156,9 @@ internal class ExtensionConfigTest { .addTask( ExtensionConfig.AiTasks.Task.SelectTags.builder() .instruction("What types of clothing items are visible in this image?") - .vocabulary(listOf("shirt", "tshirt", "dress", "trousers", "jacket")) .maxSelections(1L) .minSelections(0L) + .vocabulary(listOf("shirt", "tshirt", "dress", "trousers", "jacket")) .build() ) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt index 4c3bb907..43390b56 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt @@ -58,11 +58,11 @@ internal class FileUploadParamsTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf("shirt", "tshirt", "dress", "trousers", "jacket") ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( @@ -241,11 +241,11 @@ internal class FileUploadParamsTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf("shirt", "tshirt", "dress", "trousers", "jacket") ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( @@ -438,6 +438,8 @@ internal class FileUploadParamsTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -447,8 +449,6 @@ internal class FileUploadParamsTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt index da427b05..0daa7c0e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt @@ -66,9 +66,9 @@ internal class FileUpdateParamsTest { .instruction( "What types of clothing items are visible?" ) - .vocabulary(listOf("shirt", "dress", "jacket")) .maxSelections(1L) .minSelections(0L) + .vocabulary(listOf("shirt", "dress", "jacket")) .build() ) .build() @@ -160,9 +160,9 @@ internal class FileUpdateParamsTest { .instruction( "What types of clothing items are visible?" ) - .vocabulary(listOf("shirt", "dress", "jacket")) .maxSelections(1L) .minSelections(0L) + .vocabulary(listOf("shirt", "dress", "jacket")) .build() ) .build() @@ -239,9 +239,9 @@ internal class FileUpdateParamsTest { .instruction( "What types of clothing items are visible?" ) - .vocabulary(listOf("shirt", "dress", "jacket")) .maxSelections(1L) .minSelections(0L) + .vocabulary(listOf("shirt", "dress", "jacket")) .build() ) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt index 85ae6fd7..01baff33 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt @@ -59,11 +59,11 @@ internal class FileUploadParamsTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf("shirt", "tshirt", "dress", "trousers", "jacket") ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( @@ -245,11 +245,11 @@ internal class FileUploadParamsTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf("shirt", "tshirt", "dress", "trousers", "jacket") ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( @@ -445,6 +445,8 @@ internal class FileUploadParamsTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -454,8 +456,6 @@ internal class FileUploadParamsTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt index a30a7f1a..be849e19 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt @@ -58,11 +58,11 @@ internal class UpdateFileRequestTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf("shirt", "tshirt", "dress", "trousers", "jacket") ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( @@ -216,6 +216,8 @@ internal class UpdateFileRequestTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -225,8 +227,6 @@ internal class UpdateFileRequestTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt index e5b9a671..2fa949f7 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt @@ -120,6 +120,8 @@ internal class ErrorHandlingTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -129,8 +131,6 @@ internal class ErrorHandlingTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( @@ -349,6 +349,8 @@ internal class ErrorHandlingTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -358,8 +360,6 @@ internal class ErrorHandlingTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( @@ -578,6 +578,8 @@ internal class ErrorHandlingTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -587,8 +589,6 @@ internal class ErrorHandlingTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( @@ -807,6 +807,8 @@ internal class ErrorHandlingTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -816,8 +818,6 @@ internal class ErrorHandlingTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( @@ -1036,6 +1036,8 @@ internal class ErrorHandlingTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -1045,8 +1047,6 @@ internal class ErrorHandlingTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( @@ -1265,6 +1265,8 @@ internal class ErrorHandlingTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -1274,8 +1276,6 @@ internal class ErrorHandlingTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( @@ -1494,6 +1494,8 @@ internal class ErrorHandlingTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -1503,8 +1505,6 @@ internal class ErrorHandlingTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( @@ -1723,6 +1723,8 @@ internal class ErrorHandlingTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -1732,8 +1734,6 @@ internal class ErrorHandlingTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( @@ -1952,6 +1952,8 @@ internal class ErrorHandlingTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -1961,8 +1963,6 @@ internal class ErrorHandlingTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( @@ -2181,6 +2181,8 @@ internal class ErrorHandlingTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -2190,8 +2192,6 @@ internal class ErrorHandlingTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( @@ -2410,6 +2410,8 @@ internal class ErrorHandlingTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -2419,8 +2421,6 @@ internal class ErrorHandlingTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( @@ -2639,6 +2639,8 @@ internal class ErrorHandlingTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -2648,8 +2650,6 @@ internal class ErrorHandlingTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( @@ -2868,6 +2868,8 @@ internal class ErrorHandlingTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -2877,8 +2879,6 @@ internal class ErrorHandlingTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( @@ -3097,6 +3097,8 @@ internal class ErrorHandlingTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -3106,8 +3108,6 @@ internal class ErrorHandlingTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( @@ -3326,6 +3326,8 @@ internal class ErrorHandlingTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -3335,8 +3337,6 @@ internal class ErrorHandlingTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( @@ -3555,6 +3555,8 @@ internal class ErrorHandlingTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -3564,8 +3566,6 @@ internal class ErrorHandlingTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( @@ -3782,6 +3782,8 @@ internal class ErrorHandlingTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -3791,8 +3793,6 @@ internal class ErrorHandlingTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt index 398a0134..f5b2e1b0 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt @@ -91,11 +91,11 @@ internal class ServiceParamsTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf("shirt", "tshirt", "dress", "trousers", "jacket") ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index eaece89b..4be1061b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -91,9 +91,9 @@ internal class FileServiceAsyncTest { .instruction( "What types of clothing items are visible?" ) - .vocabulary(listOf("shirt", "dress", "jacket")) .maxSelections(1L) .minSelections(0L) + .vocabulary(listOf("shirt", "dress", "jacket")) .build() ) .build() @@ -282,6 +282,8 @@ internal class FileServiceAsyncTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -291,8 +293,6 @@ internal class FileServiceAsyncTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt index 408d1bc7..4b92a496 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt @@ -73,6 +73,8 @@ internal class FileServiceAsyncTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -82,8 +84,6 @@ internal class FileServiceAsyncTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index 7f61e8a7..3929f7ba 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -91,9 +91,9 @@ internal class FileServiceTest { .instruction( "What types of clothing items are visible?" ) - .vocabulary(listOf("shirt", "dress", "jacket")) .maxSelections(1L) .minSelections(0L) + .vocabulary(listOf("shirt", "dress", "jacket")) .build() ) .build() @@ -275,6 +275,8 @@ internal class FileServiceTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -284,8 +286,6 @@ internal class FileServiceTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt index 1693e3f1..3d54e0a0 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt @@ -73,6 +73,8 @@ internal class FileServiceTest { .instruction( "What types of clothing items are visible in this image?" ) + .maxSelections(1L) + .minSelections(0L) .vocabulary( listOf( "shirt", @@ -82,8 +84,6 @@ internal class FileServiceTest { "jacket", ) ) - .maxSelections(1L) - .minSelections(0L) .build() ) .addTask( diff --git a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt index 05387c60..53101a1c 100644 --- a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt +++ b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt @@ -187,9 +187,9 @@ internal class ProGuardCompatibilityTest { .instruction( "What types of clothing items are visible?" ) - .vocabulary(listOf("shirt", "dress", "jacket")) .maxSelections(1L) .minSelections(0L) + .vocabulary(listOf("shirt", "dress", "jacket")) .build() ) .build() From 7156f6fa1a10aa4d4cd1655d2a3612239fc25422 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 21 Jan 2026 19:09:09 +0000 Subject: [PATCH 084/142] chore(internal): update maven repo doc to include authentication --- scripts/upload-artifacts | 64 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/scripts/upload-artifacts b/scripts/upload-artifacts index 548d1527..10f3c705 100755 --- a/scripts/upload-artifacts +++ b/scripts/upload-artifacts @@ -96,8 +96,52 @@ generate_instructions() {

Stainless SDK Maven Repository

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

-

Directions

-

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

+

Project configuration

+ +

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

+ +

Maven

+ +

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

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

Gradle

+

Add the following to your build.gradle file:

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

Configuring authentication (if required)

+ +

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

+ +

Maven with authentication

+ +

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

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

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

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

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

+

Gradle with authentication

+

Add the following to your build.gradle file:

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

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

Using the repository

+

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

From 2224a1264e0fd8772808873c4978b7930f0acb4b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 21 Jan 2026 21:08:52 +0000 Subject: [PATCH 085/142] feat(client): send `X-Stainless-Kotlin-Version` header --- .../src/main/kotlin/com/imagekit/api/core/ClientOptions.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt index bce756cf..c850d2f7 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt @@ -465,6 +465,7 @@ private constructor( headers.put("X-Stainless-Package-Version", getPackageVersion()) headers.put("X-Stainless-Runtime", "JRE") headers.put("X-Stainless-Runtime-Version", getJavaVersion()) + headers.put("X-Stainless-Kotlin-Version", KotlinVersion.CURRENT.toString()) privateKey.let { username -> password?.let { password -> if (!username.isEmpty() && !password.isEmpty()) { From 1f6f1dcfb312298c1cbb524512d0a8aa7e05560e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 22 Jan 2026 23:03:25 +0000 Subject: [PATCH 086/142] chore(internal): correct cache invalidation for `SKIP_MOCK_TESTS` --- buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts b/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts index aaec88fc..edcc2ab3 100644 --- a/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts @@ -33,6 +33,9 @@ kotlin { tasks.withType().configureEach { systemProperty("junit.jupiter.execution.parallel.enabled", true) systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent") + + // `SKIP_MOCK_TESTS` affects which tests run so it must be added as input for proper cache invalidation. + inputs.property("skipMockTests", System.getenv("SKIP_MOCK_TESTS")).optional(true) } val ktfmt by configurations.creating From 3c1ce699ab55a45358fc78b2437ca1971c6918ea Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 23 Jan 2026 02:42:53 +0000 Subject: [PATCH 087/142] fix(client): preserve time zone in lenient date-time parsing --- .../com/imagekit/api/core/ObjectMappers.kt | 19 +++++---- .../imagekit/api/core/ObjectMappersTest.kt | 41 +++++++++++++++---- 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ObjectMappers.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ObjectMappers.kt index 1aad185a..765f7633 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ObjectMappers.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ObjectMappers.kt @@ -25,7 +25,7 @@ import java.time.DateTimeException import java.time.LocalDate import java.time.LocalDateTime import java.time.OffsetDateTime -import java.time.ZonedDateTime +import java.time.ZoneId import java.time.format.DateTimeFormatter import java.time.temporal.ChronoField @@ -157,14 +157,15 @@ private class LenientOffsetDateTimeDeserializer : val temporal = formatter.parse(p.text) return when { - !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> - LocalDate.from(temporal).atStartOfDay() - !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> - LocalDateTime.from(temporal) - else -> ZonedDateTime.from(temporal).toLocalDateTime() - } - .atZone(context.timeZone.toZoneId()) - .toOffsetDateTime() + !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> + LocalDate.from(temporal) + .atStartOfDay() + .atZone(ZoneId.of("UTC")) + .toOffsetDateTime() + !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> + LocalDateTime.from(temporal).atZone(ZoneId.of("UTC")).toOffsetDateTime() + else -> OffsetDateTime.from(temporal) + } } catch (e: DateTimeException) { exceptions.add(e) } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ObjectMappersTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ObjectMappersTest.kt index 28051b74..4f6d8c5e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ObjectMappersTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ObjectMappersTest.kt @@ -3,12 +3,14 @@ package com.imagekit.api.core import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.exc.MismatchedInputException import com.fasterxml.jackson.module.kotlin.readValue +import java.time.LocalDate +import java.time.LocalTime import java.time.OffsetDateTime +import java.time.ZoneOffset import kotlin.reflect.KClass import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.catchThrowable import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.EnumSource import org.junitpioneer.jupiter.cartesian.CartesianTest @@ -72,11 +74,34 @@ internal class ObjectMappersTest { } } - enum class LenientOffsetDateTimeTestCase(val string: String) { - DATE("1998-04-21"), - DATE_TIME("1998-04-21T04:00:00"), - ZONED_DATE_TIME_1("1998-04-21T04:00:00+03:00"), - ZONED_DATE_TIME_2("1998-04-21T04:00:00Z"), + enum class LenientOffsetDateTimeTestCase( + val string: String, + val expectedOffsetDateTime: OffsetDateTime, + ) { + DATE( + "1998-04-21", + expectedOffsetDateTime = + OffsetDateTime.of(LocalDate.of(1998, 4, 21), LocalTime.of(0, 0), ZoneOffset.UTC), + ), + DATE_TIME( + "1998-04-21T04:00:00", + expectedOffsetDateTime = + OffsetDateTime.of(LocalDate.of(1998, 4, 21), LocalTime.of(4, 0), ZoneOffset.UTC), + ), + ZONED_DATE_TIME_1( + "1998-04-21T04:00:00+03:00", + expectedOffsetDateTime = + OffsetDateTime.of( + LocalDate.of(1998, 4, 21), + LocalTime.of(4, 0), + ZoneOffset.ofHours(3), + ), + ), + ZONED_DATE_TIME_2( + "1998-04-21T04:00:00Z", + expectedOffsetDateTime = + OffsetDateTime.of(LocalDate.of(1998, 4, 21), LocalTime.of(4, 0), ZoneOffset.UTC), + ), } @ParameterizedTest @@ -85,6 +110,8 @@ internal class ObjectMappersTest { val jsonMapper = jsonMapper() val json = jsonMapper.writeValueAsString(testCase.string) - assertDoesNotThrow { jsonMapper().readValue(json) } + val offsetDateTime = jsonMapper().readValue(json) + + assertThat(offsetDateTime).isEqualTo(testCase.expectedOffsetDateTime) } } From 940ebfcf3a2153e86b2292f2ca6077874d9fb170 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 23 Jan 2026 18:13:20 +0000 Subject: [PATCH 088/142] chore(ci): upgrade `actions/github-script` --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd493e07..2944deae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,7 @@ jobs: - name: Get GitHub OIDC Token if: github.repository == 'stainless-sdks/imagekit-java' id: github-oidc - uses: actions/github-script@v6 + uses: actions/github-script@v8 with: script: core.setOutput('github_token', await core.getIDToken()); From 74087c57ab4cbe16cf9627cf39a7768a2605bfa7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 07:54:48 +0000 Subject: [PATCH 089/142] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 751099cf..011cf609 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-84f0d75048a9268981a84800b4190e3691997ce57dcfc0876f38a5b3fce6bacd.yml openapi_spec_hash: 35607d4e850c8a60524223ff632c83bb -config_hash: aeb6eb949d73382270bbd8bbf2e4cf2a +config_hash: 47cb702ee2cb52c58d803ae39ade9b44 From 2a727d401b4dff5441414b565ba081822a737926 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 Jan 2026 16:36:19 +0000 Subject: [PATCH 090/142] fix(docs): fix mcp installation instructions for remote servers --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5da339b3..c882c6b0 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ The Image Kit Java SDK provides convenient access to the [Image Kit REST API](ht Use the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application. -[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl19) -[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%7D) +[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19) +[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D) > Note: You may need to set environment variables in your MCP client. From 1d14a5930b16ce47c2f85e2e5e8b2507dec9a61f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 30 Jan 2026 22:40:36 +0000 Subject: [PATCH 091/142] chore(internal): allow passing args to `./scripts/test` --- scripts/build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build b/scripts/build index f4063482..16a2b00d 100755 --- a/scripts/build +++ b/scripts/build @@ -5,4 +5,4 @@ set -e cd "$(dirname "$0")/.." echo "==> Building classes" -./gradlew build testClasses -x test +./gradlew build testClasses "$@" -x test From ceb43ddf46ac19fc90fb28e716d6f5490630bc30 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 2 Feb 2026 03:51:16 +0000 Subject: [PATCH 092/142] fix(api): add missing embeddedMetadata and video properties to FileDetails --- .stats.yml | 4 +- .../com/imagekit/api/models/files/File.kt | 305 +++++++++++++++++- .../api/models/files/FileUpdateResponse.kt | 207 +++++++++++- .../models/assets/AssetListResponseTest.kt | 18 ++ .../com/imagekit/api/models/files/FileTest.kt | 28 ++ .../models/files/FileUpdateResponseTest.kt | 28 ++ .../api/proguard/ProGuardCompatibilityTest.kt | 9 + 7 files changed, 595 insertions(+), 4 deletions(-) diff --git a/.stats.yml b/.stats.yml index 011cf609..db4fc3c8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-84f0d75048a9268981a84800b4190e3691997ce57dcfc0876f38a5b3fce6bacd.yml -openapi_spec_hash: 35607d4e850c8a60524223ff632c83bb +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-f2eb530f43b355f7ddab66187e45e4ca6da195825b66ea193bbf38acd3deb055.yml +openapi_spec_hash: 2137c56fcf6ae4c09fcac2891b35f789 config_hash: 47cb702ee2cb52c58d803ae39ade9b44 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt index 3c7ce9e1..bbd0b1ac 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt @@ -25,10 +25,14 @@ class File @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val aiTags: JsonField>, + private val audioCodec: JsonField, + private val bitRate: JsonField, private val createdAt: JsonField, private val customCoordinates: JsonField, private val customMetadata: JsonField, private val description: JsonField, + private val duration: JsonField, + private val embeddedMetadata: JsonField, private val fileId: JsonField, private val filePath: JsonField, private val fileType: JsonField, @@ -46,6 +50,7 @@ private constructor( private val updatedAt: JsonField, private val url: JsonField, private val versionInfo: JsonField, + private val videoCodec: JsonField, private val width: JsonField, private val additionalProperties: MutableMap, ) { @@ -53,6 +58,10 @@ private constructor( @JsonCreator private constructor( @JsonProperty("AITags") @ExcludeMissing aiTags: JsonField> = JsonMissing.of(), + @JsonProperty("audioCodec") + @ExcludeMissing + audioCodec: JsonField = JsonMissing.of(), + @JsonProperty("bitRate") @ExcludeMissing bitRate: JsonField = JsonMissing.of(), @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @@ -65,6 +74,10 @@ private constructor( @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), + @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), + @JsonProperty("embeddedMetadata") + @ExcludeMissing + embeddedMetadata: JsonField = JsonMissing.of(), @JsonProperty("fileId") @ExcludeMissing fileId: JsonField = JsonMissing.of(), @JsonProperty("filePath") @ExcludeMissing filePath: JsonField = JsonMissing.of(), @JsonProperty("fileType") @ExcludeMissing fileType: JsonField = JsonMissing.of(), @@ -92,13 +105,20 @@ private constructor( @JsonProperty("versionInfo") @ExcludeMissing versionInfo: JsonField = JsonMissing.of(), + @JsonProperty("videoCodec") + @ExcludeMissing + videoCodec: JsonField = JsonMissing.of(), @JsonProperty("width") @ExcludeMissing width: JsonField = JsonMissing.of(), ) : this( aiTags, + audioCodec, + bitRate, createdAt, customCoordinates, customMetadata, description, + duration, + embeddedMetadata, fileId, filePath, fileType, @@ -116,6 +136,7 @@ private constructor( updatedAt, url, versionInfo, + videoCodec, width, mutableMapOf(), ) @@ -128,6 +149,22 @@ private constructor( */ fun aiTags(): Optional> = aiTags.getOptional("AITags") + /** + * The audio codec used in the video (only for video/audio). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun audioCodec(): Optional = audioCodec.getOptional("audioCodec") + + /** + * The bit rate of the video in kbps (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun bitRate(): Optional = bitRate.getOptional("bitRate") + /** * Date and time when the file was uploaded. The date and time is in ISO8601 format. * @@ -161,6 +198,24 @@ private constructor( */ fun description(): Optional = description.getOptional("description") + /** + * The duration of the video in seconds (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun duration(): Optional = duration.getOptional("duration") + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp + * data. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun embeddedMetadata(): Optional = + embeddedMetadata.getOptional("embeddedMetadata") + /** * Unique identifier of the asset. * @@ -307,6 +362,14 @@ private constructor( */ fun versionInfo(): Optional = versionInfo.getOptional("versionInfo") + /** + * The video codec used in the video (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun videoCodec(): Optional = videoCodec.getOptional("videoCodec") + /** * Width of the file. * @@ -322,6 +385,20 @@ private constructor( */ @JsonProperty("AITags") @ExcludeMissing fun _aiTags(): JsonField> = aiTags + /** + * Returns the raw JSON value of [audioCodec]. + * + * Unlike [audioCodec], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("audioCodec") @ExcludeMissing fun _audioCodec(): JsonField = audioCodec + + /** + * Returns the raw JSON value of [bitRate]. + * + * Unlike [bitRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bitRate") @ExcludeMissing fun _bitRate(): JsonField = bitRate + /** * Returns the raw JSON value of [createdAt]. * @@ -357,6 +434,23 @@ private constructor( */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [embeddedMetadata]. + * + * Unlike [embeddedMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("embeddedMetadata") + @ExcludeMissing + fun _embeddedMetadata(): JsonField = embeddedMetadata + /** * Returns the raw JSON value of [fileId]. * @@ -487,6 +581,13 @@ private constructor( @ExcludeMissing fun _versionInfo(): JsonField = versionInfo + /** + * Returns the raw JSON value of [videoCodec]. + * + * Unlike [videoCodec], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("videoCodec") @ExcludeMissing fun _videoCodec(): JsonField = videoCodec + /** * Returns the raw JSON value of [width]. * @@ -516,10 +617,14 @@ private constructor( class Builder internal constructor() { private var aiTags: JsonField>? = null + private var audioCodec: JsonField = JsonMissing.of() + private var bitRate: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() private var customCoordinates: JsonField = JsonMissing.of() private var customMetadata: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() + private var duration: JsonField = JsonMissing.of() + private var embeddedMetadata: JsonField = JsonMissing.of() private var fileId: JsonField = JsonMissing.of() private var filePath: JsonField = JsonMissing.of() private var fileType: JsonField = JsonMissing.of() @@ -537,16 +642,21 @@ private constructor( private var updatedAt: JsonField = JsonMissing.of() private var url: JsonField = JsonMissing.of() private var versionInfo: JsonField = JsonMissing.of() + private var videoCodec: JsonField = JsonMissing.of() private var width: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(file: File) = apply { aiTags = file.aiTags.map { it.toMutableList() } + audioCodec = file.audioCodec + bitRate = file.bitRate createdAt = file.createdAt customCoordinates = file.customCoordinates customMetadata = file.customMetadata description = file.description + duration = file.duration + embeddedMetadata = file.embeddedMetadata fileId = file.fileId filePath = file.filePath fileType = file.fileType @@ -564,6 +674,7 @@ private constructor( updatedAt = file.updatedAt url = file.url versionInfo = file.versionInfo + videoCodec = file.videoCodec width = file.width additionalProperties = file.additionalProperties.toMutableMap() } @@ -597,6 +708,29 @@ private constructor( } } + /** The audio codec used in the video (only for video/audio). */ + fun audioCodec(audioCodec: String) = audioCodec(JsonField.of(audioCodec)) + + /** + * Sets [Builder.audioCodec] to an arbitrary JSON value. + * + * You should usually call [Builder.audioCodec] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun audioCodec(audioCodec: JsonField) = apply { this.audioCodec = audioCodec } + + /** The bit rate of the video in kbps (only for video). */ + fun bitRate(bitRate: Long) = bitRate(JsonField.of(bitRate)) + + /** + * Sets [Builder.bitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.bitRate] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun bitRate(bitRate: JsonField) = apply { this.bitRate = bitRate } + /** Date and time when the file was uploaded. The date and time is in ISO8601 format. */ fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) @@ -658,6 +792,35 @@ private constructor( */ fun description(description: JsonField) = apply { this.description = description } + /** The duration of the video in seconds (only for video). */ + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp + * data. + */ + fun embeddedMetadata(embeddedMetadata: EmbeddedMetadata) = + embeddedMetadata(JsonField.of(embeddedMetadata)) + + /** + * Sets [Builder.embeddedMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.embeddedMetadata] with a well-typed [EmbeddedMetadata] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun embeddedMetadata(embeddedMetadata: JsonField) = apply { + this.embeddedMetadata = embeddedMetadata + } + /** Unique identifier of the asset. */ fun fileId(fileId: String) = fileId(JsonField.of(fileId)) @@ -892,6 +1055,18 @@ private constructor( this.versionInfo = versionInfo } + /** The video codec used in the video (only for video). */ + fun videoCodec(videoCodec: String) = videoCodec(JsonField.of(videoCodec)) + + /** + * Sets [Builder.videoCodec] to an arbitrary JSON value. + * + * You should usually call [Builder.videoCodec] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun videoCodec(videoCodec: JsonField) = apply { this.videoCodec = videoCodec } + /** Width of the file. */ fun width(width: Double) = width(JsonField.of(width)) @@ -930,10 +1105,14 @@ private constructor( fun build(): File = File( (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, + audioCodec, + bitRate, createdAt, customCoordinates, customMetadata, description, + duration, + embeddedMetadata, fileId, filePath, fileType, @@ -951,6 +1130,7 @@ private constructor( updatedAt, url, versionInfo, + videoCodec, width, additionalProperties.toMutableMap(), ) @@ -964,10 +1144,14 @@ private constructor( } aiTags().ifPresent { it.forEach { it.validate() } } + audioCodec() + bitRate() createdAt() customCoordinates() customMetadata().ifPresent { it.validate() } description() + duration() + embeddedMetadata().ifPresent { it.validate() } fileId() filePath() fileType() @@ -985,6 +1169,7 @@ private constructor( updatedAt() url() versionInfo().ifPresent { it.validate() } + videoCodec() width() validated = true } @@ -1005,10 +1190,14 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (aiTags.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (audioCodec.asKnown().isPresent) 1 else 0) + + (if (bitRate.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (if (customCoordinates.asKnown().isPresent) 1 else 0) + (customMetadata.asKnown().getOrNull()?.validity() ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + + (if (duration.asKnown().isPresent) 1 else 0) + + (embeddedMetadata.asKnown().getOrNull()?.validity() ?: 0) + (if (fileId.asKnown().isPresent) 1 else 0) + (if (filePath.asKnown().isPresent) 1 else 0) + (if (fileType.asKnown().isPresent) 1 else 0) + @@ -1026,6 +1215,7 @@ private constructor( (if (updatedAt.asKnown().isPresent) 1 else 0) + (if (url.asKnown().isPresent) 1 else 0) + (versionInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (videoCodec.asKnown().isPresent) 1 else 0) + (if (width.asKnown().isPresent) 1 else 0) class AiTag @@ -1348,6 +1538,109 @@ private constructor( override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" } + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp + * data. + */ + class EmbeddedMetadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [EmbeddedMetadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EmbeddedMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(embeddedMetadata: EmbeddedMetadata) = apply { + additionalProperties = embeddedMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EmbeddedMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): EmbeddedMetadata = EmbeddedMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): EmbeddedMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EmbeddedMetadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "EmbeddedMetadata{additionalProperties=$additionalProperties}" + } + /** * This field is included in the response only if the Path policy feature is available in the * plan. It contains schema definitions for the custom metadata fields selected for the @@ -1770,10 +2063,14 @@ private constructor( return other is File && aiTags == other.aiTags && + audioCodec == other.audioCodec && + bitRate == other.bitRate && createdAt == other.createdAt && customCoordinates == other.customCoordinates && customMetadata == other.customMetadata && description == other.description && + duration == other.duration && + embeddedMetadata == other.embeddedMetadata && fileId == other.fileId && filePath == other.filePath && fileType == other.fileType && @@ -1791,6 +2088,7 @@ private constructor( updatedAt == other.updatedAt && url == other.url && versionInfo == other.versionInfo && + videoCodec == other.videoCodec && width == other.width && additionalProperties == other.additionalProperties } @@ -1798,10 +2096,14 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( aiTags, + audioCodec, + bitRate, createdAt, customCoordinates, customMetadata, description, + duration, + embeddedMetadata, fileId, filePath, fileType, @@ -1819,6 +2121,7 @@ private constructor( updatedAt, url, versionInfo, + videoCodec, width, additionalProperties, ) @@ -1827,5 +2130,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "File{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, fileId=$fileId, filePath=$filePath, fileType=$fileType, hasAlpha=$hasAlpha, height=$height, isPrivateFile=$isPrivateFile, isPublished=$isPublished, mime=$mime, name=$name, selectedFieldsSchema=$selectedFieldsSchema, size=$size, tags=$tags, thumbnail=$thumbnail, type=$type, updatedAt=$updatedAt, url=$url, versionInfo=$versionInfo, width=$width, additionalProperties=$additionalProperties}" + "File{aiTags=$aiTags, audioCodec=$audioCodec, bitRate=$bitRate, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, duration=$duration, embeddedMetadata=$embeddedMetadata, fileId=$fileId, filePath=$filePath, fileType=$fileType, hasAlpha=$hasAlpha, height=$height, isPrivateFile=$isPrivateFile, isPublished=$isPublished, mime=$mime, name=$name, selectedFieldsSchema=$selectedFieldsSchema, size=$size, tags=$tags, thumbnail=$thumbnail, type=$type, updatedAt=$updatedAt, url=$url, versionInfo=$versionInfo, videoCodec=$videoCodec, width=$width, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt index f602334a..5758fe5e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt @@ -25,10 +25,14 @@ class FileUpdateResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val aiTags: JsonField>, + private val audioCodec: JsonField, + private val bitRate: JsonField, private val createdAt: JsonField, private val customCoordinates: JsonField, private val customMetadata: JsonField, private val description: JsonField, + private val duration: JsonField, + private val embeddedMetadata: JsonField, private val fileId: JsonField, private val filePath: JsonField, private val fileType: JsonField, @@ -46,6 +50,7 @@ private constructor( private val updatedAt: JsonField, private val url: JsonField, private val versionInfo: JsonField, + private val videoCodec: JsonField, private val width: JsonField, private val extensionStatus: JsonField, private val additionalProperties: MutableMap, @@ -56,6 +61,10 @@ private constructor( @JsonProperty("AITags") @ExcludeMissing aiTags: JsonField> = JsonMissing.of(), + @JsonProperty("audioCodec") + @ExcludeMissing + audioCodec: JsonField = JsonMissing.of(), + @JsonProperty("bitRate") @ExcludeMissing bitRate: JsonField = JsonMissing.of(), @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @@ -68,6 +77,10 @@ private constructor( @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), + @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), + @JsonProperty("embeddedMetadata") + @ExcludeMissing + embeddedMetadata: JsonField = JsonMissing.of(), @JsonProperty("fileId") @ExcludeMissing fileId: JsonField = JsonMissing.of(), @JsonProperty("filePath") @ExcludeMissing filePath: JsonField = JsonMissing.of(), @JsonProperty("fileType") @ExcludeMissing fileType: JsonField = JsonMissing.of(), @@ -95,16 +108,23 @@ private constructor( @JsonProperty("versionInfo") @ExcludeMissing versionInfo: JsonField = JsonMissing.of(), + @JsonProperty("videoCodec") + @ExcludeMissing + videoCodec: JsonField = JsonMissing.of(), @JsonProperty("width") @ExcludeMissing width: JsonField = JsonMissing.of(), @JsonProperty("extensionStatus") @ExcludeMissing extensionStatus: JsonField = JsonMissing.of(), ) : this( aiTags, + audioCodec, + bitRate, createdAt, customCoordinates, customMetadata, description, + duration, + embeddedMetadata, fileId, filePath, fileType, @@ -122,6 +142,7 @@ private constructor( updatedAt, url, versionInfo, + videoCodec, width, extensionStatus, mutableMapOf(), @@ -130,10 +151,14 @@ private constructor( fun toFile(): File = File.builder() .aiTags(aiTags) + .audioCodec(audioCodec) + .bitRate(bitRate) .createdAt(createdAt) .customCoordinates(customCoordinates) .customMetadata(customMetadata) .description(description) + .duration(duration) + .embeddedMetadata(embeddedMetadata) .fileId(fileId) .filePath(filePath) .fileType(fileType) @@ -151,6 +176,7 @@ private constructor( .updatedAt(updatedAt) .url(url) .versionInfo(versionInfo) + .videoCodec(videoCodec) .width(width) .build() @@ -162,6 +188,22 @@ private constructor( */ fun aiTags(): Optional> = aiTags.getOptional("AITags") + /** + * The audio codec used in the video (only for video/audio). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun audioCodec(): Optional = audioCodec.getOptional("audioCodec") + + /** + * The bit rate of the video in kbps (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun bitRate(): Optional = bitRate.getOptional("bitRate") + /** * Date and time when the file was uploaded. The date and time is in ISO8601 format. * @@ -196,6 +238,24 @@ private constructor( */ fun description(): Optional = description.getOptional("description") + /** + * The duration of the video in seconds (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun duration(): Optional = duration.getOptional("duration") + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp + * data. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun embeddedMetadata(): Optional = + embeddedMetadata.getOptional("embeddedMetadata") + /** * Unique identifier of the asset. * @@ -342,6 +402,14 @@ private constructor( */ fun versionInfo(): Optional = versionInfo.getOptional("versionInfo") + /** + * The video codec used in the video (only for video). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun videoCodec(): Optional = videoCodec.getOptional("videoCodec") + /** * Width of the file. * @@ -364,6 +432,20 @@ private constructor( */ @JsonProperty("AITags") @ExcludeMissing fun _aiTags(): JsonField> = aiTags + /** + * Returns the raw JSON value of [audioCodec]. + * + * Unlike [audioCodec], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("audioCodec") @ExcludeMissing fun _audioCodec(): JsonField = audioCodec + + /** + * Returns the raw JSON value of [bitRate]. + * + * Unlike [bitRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bitRate") @ExcludeMissing fun _bitRate(): JsonField = bitRate + /** * Returns the raw JSON value of [createdAt]. * @@ -399,6 +481,23 @@ private constructor( */ @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [embeddedMetadata]. + * + * Unlike [embeddedMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("embeddedMetadata") + @ExcludeMissing + fun _embeddedMetadata(): JsonField = embeddedMetadata + /** * Returns the raw JSON value of [fileId]. * @@ -529,6 +628,13 @@ private constructor( @ExcludeMissing fun _versionInfo(): JsonField = versionInfo + /** + * Returns the raw JSON value of [videoCodec]. + * + * Unlike [videoCodec], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("videoCodec") @ExcludeMissing fun _videoCodec(): JsonField = videoCodec + /** * Returns the raw JSON value of [width]. * @@ -567,10 +673,14 @@ private constructor( class Builder internal constructor() { private var aiTags: JsonField>? = null + private var audioCodec: JsonField = JsonMissing.of() + private var bitRate: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() private var customCoordinates: JsonField = JsonMissing.of() private var customMetadata: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() + private var duration: JsonField = JsonMissing.of() + private var embeddedMetadata: JsonField = JsonMissing.of() private var fileId: JsonField = JsonMissing.of() private var filePath: JsonField = JsonMissing.of() private var fileType: JsonField = JsonMissing.of() @@ -588,6 +698,7 @@ private constructor( private var updatedAt: JsonField = JsonMissing.of() private var url: JsonField = JsonMissing.of() private var versionInfo: JsonField = JsonMissing.of() + private var videoCodec: JsonField = JsonMissing.of() private var width: JsonField = JsonMissing.of() private var extensionStatus: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -595,10 +706,14 @@ private constructor( @JvmSynthetic internal fun from(fileUpdateResponse: FileUpdateResponse) = apply { aiTags = fileUpdateResponse.aiTags.map { it.toMutableList() } + audioCodec = fileUpdateResponse.audioCodec + bitRate = fileUpdateResponse.bitRate createdAt = fileUpdateResponse.createdAt customCoordinates = fileUpdateResponse.customCoordinates customMetadata = fileUpdateResponse.customMetadata description = fileUpdateResponse.description + duration = fileUpdateResponse.duration + embeddedMetadata = fileUpdateResponse.embeddedMetadata fileId = fileUpdateResponse.fileId filePath = fileUpdateResponse.filePath fileType = fileUpdateResponse.fileType @@ -616,6 +731,7 @@ private constructor( updatedAt = fileUpdateResponse.updatedAt url = fileUpdateResponse.url versionInfo = fileUpdateResponse.versionInfo + videoCodec = fileUpdateResponse.videoCodec width = fileUpdateResponse.width extensionStatus = fileUpdateResponse.extensionStatus additionalProperties = fileUpdateResponse.additionalProperties.toMutableMap() @@ -650,6 +766,29 @@ private constructor( } } + /** The audio codec used in the video (only for video/audio). */ + fun audioCodec(audioCodec: String) = audioCodec(JsonField.of(audioCodec)) + + /** + * Sets [Builder.audioCodec] to an arbitrary JSON value. + * + * You should usually call [Builder.audioCodec] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun audioCodec(audioCodec: JsonField) = apply { this.audioCodec = audioCodec } + + /** The bit rate of the video in kbps (only for video). */ + fun bitRate(bitRate: Long) = bitRate(JsonField.of(bitRate)) + + /** + * Sets [Builder.bitRate] to an arbitrary JSON value. + * + * You should usually call [Builder.bitRate] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun bitRate(bitRate: JsonField) = apply { this.bitRate = bitRate } + /** Date and time when the file was uploaded. The date and time is in ISO8601 format. */ fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) @@ -711,6 +850,35 @@ private constructor( */ fun description(description: JsonField) = apply { this.description = description } + /** The duration of the video in seconds (only for video). */ + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp + * data. + */ + fun embeddedMetadata(embeddedMetadata: File.EmbeddedMetadata) = + embeddedMetadata(JsonField.of(embeddedMetadata)) + + /** + * Sets [Builder.embeddedMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.embeddedMetadata] with a well-typed + * [File.EmbeddedMetadata] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun embeddedMetadata(embeddedMetadata: JsonField) = apply { + this.embeddedMetadata = embeddedMetadata + } + /** Unique identifier of the asset. */ fun fileId(fileId: String) = fileId(JsonField.of(fileId)) @@ -946,6 +1114,18 @@ private constructor( this.versionInfo = versionInfo } + /** The video codec used in the video (only for video). */ + fun videoCodec(videoCodec: String) = videoCodec(JsonField.of(videoCodec)) + + /** + * Sets [Builder.videoCodec] to an arbitrary JSON value. + * + * You should usually call [Builder.videoCodec] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun videoCodec(videoCodec: JsonField) = apply { this.videoCodec = videoCodec } + /** Width of the file. */ fun width(width: Double) = width(JsonField.of(width)) @@ -998,10 +1178,14 @@ private constructor( fun build(): FileUpdateResponse = FileUpdateResponse( (aiTags ?: JsonMissing.of()).map { it.toImmutable() }, + audioCodec, + bitRate, createdAt, customCoordinates, customMetadata, description, + duration, + embeddedMetadata, fileId, filePath, fileType, @@ -1019,6 +1203,7 @@ private constructor( updatedAt, url, versionInfo, + videoCodec, width, extensionStatus, additionalProperties.toMutableMap(), @@ -1033,10 +1218,14 @@ private constructor( } aiTags().ifPresent { it.forEach { it.validate() } } + audioCodec() + bitRate() createdAt() customCoordinates() customMetadata().ifPresent { it.validate() } description() + duration() + embeddedMetadata().ifPresent { it.validate() } fileId() filePath() fileType() @@ -1054,6 +1243,7 @@ private constructor( updatedAt() url() versionInfo().ifPresent { it.validate() } + videoCodec() width() extensionStatus().ifPresent { it.validate() } validated = true @@ -1075,10 +1265,14 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (aiTags.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (audioCodec.asKnown().isPresent) 1 else 0) + + (if (bitRate.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (if (customCoordinates.asKnown().isPresent) 1 else 0) + (customMetadata.asKnown().getOrNull()?.validity() ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + + (if (duration.asKnown().isPresent) 1 else 0) + + (embeddedMetadata.asKnown().getOrNull()?.validity() ?: 0) + (if (fileId.asKnown().isPresent) 1 else 0) + (if (filePath.asKnown().isPresent) 1 else 0) + (if (fileType.asKnown().isPresent) 1 else 0) + @@ -1096,6 +1290,7 @@ private constructor( (if (updatedAt.asKnown().isPresent) 1 else 0) + (if (url.asKnown().isPresent) 1 else 0) + (versionInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (videoCodec.asKnown().isPresent) 1 else 0) + (if (width.asKnown().isPresent) 1 else 0) + (extensionStatus.asKnown().getOrNull()?.validity() ?: 0) @@ -2113,10 +2308,14 @@ private constructor( return other is FileUpdateResponse && aiTags == other.aiTags && + audioCodec == other.audioCodec && + bitRate == other.bitRate && createdAt == other.createdAt && customCoordinates == other.customCoordinates && customMetadata == other.customMetadata && description == other.description && + duration == other.duration && + embeddedMetadata == other.embeddedMetadata && fileId == other.fileId && filePath == other.filePath && fileType == other.fileType && @@ -2134,6 +2333,7 @@ private constructor( updatedAt == other.updatedAt && url == other.url && versionInfo == other.versionInfo && + videoCodec == other.videoCodec && width == other.width && extensionStatus == other.extensionStatus && additionalProperties == other.additionalProperties @@ -2142,10 +2342,14 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( aiTags, + audioCodec, + bitRate, createdAt, customCoordinates, customMetadata, description, + duration, + embeddedMetadata, fileId, filePath, fileType, @@ -2163,6 +2367,7 @@ private constructor( updatedAt, url, versionInfo, + videoCodec, width, extensionStatus, additionalProperties, @@ -2172,5 +2377,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FileUpdateResponse{aiTags=$aiTags, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, fileId=$fileId, filePath=$filePath, fileType=$fileType, hasAlpha=$hasAlpha, height=$height, isPrivateFile=$isPrivateFile, isPublished=$isPublished, mime=$mime, name=$name, selectedFieldsSchema=$selectedFieldsSchema, size=$size, tags=$tags, thumbnail=$thumbnail, type=$type, updatedAt=$updatedAt, url=$url, versionInfo=$versionInfo, width=$width, extensionStatus=$extensionStatus, additionalProperties=$additionalProperties}" + "FileUpdateResponse{aiTags=$aiTags, audioCodec=$audioCodec, bitRate=$bitRate, createdAt=$createdAt, customCoordinates=$customCoordinates, customMetadata=$customMetadata, description=$description, duration=$duration, embeddedMetadata=$embeddedMetadata, fileId=$fileId, filePath=$filePath, fileType=$fileType, hasAlpha=$hasAlpha, height=$height, isPrivateFile=$isPrivateFile, isPublished=$isPublished, mime=$mime, name=$name, selectedFieldsSchema=$selectedFieldsSchema, size=$size, tags=$tags, thumbnail=$thumbnail, type=$type, updatedAt=$updatedAt, url=$url, versionInfo=$versionInfo, videoCodec=$videoCodec, width=$width, extensionStatus=$extensionStatus, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt index 6cbde398..58a986d1 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt @@ -24,6 +24,8 @@ internal class AssetListResponseTest { .addAiTag( File.AiTag.builder().confidence(0.0).name("name").source("source").build() ) + .audioCodec("audioCodec") + .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( @@ -32,6 +34,12 @@ internal class AssetListResponseTest { .build() ) .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .fileId("fileId") .filePath("filePath") .fileType("fileType") @@ -70,6 +78,7 @@ internal class AssetListResponseTest { .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") .width(0.0) .build() @@ -88,6 +97,8 @@ internal class AssetListResponseTest { .addAiTag( File.AiTag.builder().confidence(0.0).name("name").source("source").build() ) + .audioCodec("audioCodec") + .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( @@ -96,6 +107,12 @@ internal class AssetListResponseTest { .build() ) .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .fileId("fileId") .filePath("filePath") .fileType("fileType") @@ -134,6 +151,7 @@ internal class AssetListResponseTest { .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") .width(0.0) .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt index daf4fec8..01ec117a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt @@ -19,6 +19,8 @@ internal class FileTest { .addAiTag( File.AiTag.builder().confidence(0.0).name("name").source("source").build() ) + .audioCodec("audioCodec") + .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( @@ -27,6 +29,12 @@ internal class FileTest { .build() ) .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .fileId("fileId") .filePath("filePath") .fileType("fileType") @@ -65,6 +73,7 @@ internal class FileTest { .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") .width(0.0) .build() @@ -72,6 +81,8 @@ internal class FileTest { .containsExactly( File.AiTag.builder().confidence(0.0).name("name").source("source").build() ) + assertThat(file.audioCodec()).contains("audioCodec") + assertThat(file.bitRate()).contains(0L) assertThat(file.createdAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(file.customCoordinates()).contains("customCoordinates") assertThat(file.customMetadata()) @@ -81,6 +92,13 @@ internal class FileTest { .build() ) assertThat(file.description()).contains("description") + assertThat(file.duration()).contains(0L) + assertThat(file.embeddedMetadata()) + .contains( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(file.fileId()).contains("fileId") assertThat(file.filePath()).contains("filePath") assertThat(file.fileType()).contains("fileType") @@ -120,6 +138,7 @@ internal class FileTest { assertThat(file.url()).contains("https://example.com") assertThat(file.versionInfo()) .contains(File.VersionInfo.builder().id("id").name("name").build()) + assertThat(file.videoCodec()).contains("videoCodec") assertThat(file.width()).contains(0.0) } @@ -131,6 +150,8 @@ internal class FileTest { .addAiTag( File.AiTag.builder().confidence(0.0).name("name").source("source").build() ) + .audioCodec("audioCodec") + .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( @@ -139,6 +160,12 @@ internal class FileTest { .build() ) .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .fileId("fileId") .filePath("filePath") .fileType("fileType") @@ -177,6 +204,7 @@ internal class FileTest { .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") .width(0.0) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt index a2eb81ba..c098e695 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt @@ -19,6 +19,8 @@ internal class FileUpdateResponseTest { .addAiTag( File.AiTag.builder().confidence(0.0).name("name").source("source").build() ) + .audioCodec("audioCodec") + .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( @@ -27,6 +29,12 @@ internal class FileUpdateResponseTest { .build() ) .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .fileId("fileId") .filePath("filePath") .fileType("fileType") @@ -65,6 +73,7 @@ internal class FileUpdateResponseTest { .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") .width(0.0) .extensionStatus( FileUpdateResponse.ExtensionStatus.builder() @@ -85,6 +94,8 @@ internal class FileUpdateResponseTest { .containsExactly( File.AiTag.builder().confidence(0.0).name("name").source("source").build() ) + assertThat(fileUpdateResponse.audioCodec()).contains("audioCodec") + assertThat(fileUpdateResponse.bitRate()).contains(0L) assertThat(fileUpdateResponse.createdAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(fileUpdateResponse.customCoordinates()).contains("customCoordinates") @@ -95,6 +106,13 @@ internal class FileUpdateResponseTest { .build() ) assertThat(fileUpdateResponse.description()).contains("description") + assertThat(fileUpdateResponse.duration()).contains(0L) + assertThat(fileUpdateResponse.embeddedMetadata()) + .contains( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(fileUpdateResponse.fileId()).contains("fileId") assertThat(fileUpdateResponse.filePath()).contains("filePath") assertThat(fileUpdateResponse.fileType()).contains("fileType") @@ -135,6 +153,7 @@ internal class FileUpdateResponseTest { assertThat(fileUpdateResponse.url()).contains("https://example.com") assertThat(fileUpdateResponse.versionInfo()) .contains(File.VersionInfo.builder().id("id").name("name").build()) + assertThat(fileUpdateResponse.videoCodec()).contains("videoCodec") assertThat(fileUpdateResponse.width()).contains(0.0) assertThat(fileUpdateResponse.extensionStatus()) .contains( @@ -156,6 +175,8 @@ internal class FileUpdateResponseTest { .addAiTag( File.AiTag.builder().confidence(0.0).name("name").source("source").build() ) + .audioCodec("audioCodec") + .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( @@ -164,6 +185,12 @@ internal class FileUpdateResponseTest { .build() ) .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .fileId("fileId") .filePath("filePath") .fileType("fileType") @@ -202,6 +229,7 @@ internal class FileUpdateResponseTest { .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") .width(0.0) .extensionStatus( FileUpdateResponse.ExtensionStatus.builder() diff --git a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt index 53101a1c..a1ecd8d3 100644 --- a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt +++ b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt @@ -75,6 +75,8 @@ internal class ProGuardCompatibilityTest { .addAiTag( File.AiTag.builder().confidence(0.0).name("name").source("source").build() ) + .audioCodec("audioCodec") + .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( @@ -83,6 +85,12 @@ internal class ProGuardCompatibilityTest { .build() ) .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .fileId("fileId") .filePath("filePath") .fileType("fileType") @@ -121,6 +129,7 @@ internal class ProGuardCompatibilityTest { .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") .width(0.0) .build() From 0413e64aa737500a42764fb2613f94cf582cb2b8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 2 Feb 2026 04:47:27 +0000 Subject: [PATCH 093/142] feat(api): add customMetadata property to folder schema --- .stats.yml | 4 +- .../com/imagekit/api/models/files/Folder.kt | 165 +++++++++++++++++- .../models/assets/AssetListResponseTest.kt | 10 ++ .../imagekit/api/models/files/FolderTest.kt | 17 ++ 4 files changed, 191 insertions(+), 5 deletions(-) diff --git a/.stats.yml b/.stats.yml index db4fc3c8..dbc39e12 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-f2eb530f43b355f7ddab66187e45e4ca6da195825b66ea193bbf38acd3deb055.yml -openapi_spec_hash: 2137c56fcf6ae4c09fcac2891b35f789 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-13fc3d7cafdea492f62eef7c1d63424d6d9d8adbff74b9f6ca6fd3fc12a36840.yml +openapi_spec_hash: a1fe6fa48207791657a1ea2d60a6dfcc config_hash: 47cb702ee2cb52c58d803ae39ade9b44 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Folder.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Folder.kt index 0a3a88f7..54b903e6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Folder.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Folder.kt @@ -11,6 +11,7 @@ import com.imagekit.api.core.ExcludeMissing import com.imagekit.api.core.JsonField import com.imagekit.api.core.JsonMissing import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.toImmutable import com.imagekit.api.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections @@ -22,6 +23,7 @@ class Folder @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val createdAt: JsonField, + private val customMetadata: JsonField, private val folderId: JsonField, private val folderPath: JsonField, private val name: JsonField, @@ -35,6 +37,9 @@ private constructor( @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("customMetadata") + @ExcludeMissing + customMetadata: JsonField = JsonMissing.of(), @JsonProperty("folderId") @ExcludeMissing folderId: JsonField = JsonMissing.of(), @JsonProperty("folderPath") @ExcludeMissing @@ -44,7 +49,7 @@ private constructor( @JsonProperty("updatedAt") @ExcludeMissing updatedAt: JsonField = JsonMissing.of(), - ) : this(createdAt, folderId, folderPath, name, type, updatedAt, mutableMapOf()) + ) : this(createdAt, customMetadata, folderId, folderPath, name, type, updatedAt, mutableMapOf()) /** * Date and time when the folder was created. The date and time is in ISO8601 format. @@ -54,6 +59,15 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * An object with custom metadata for the folder. Returns empty object if no custom metadata is + * set. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customMetadata(): Optional = customMetadata.getOptional("customMetadata") + /** * Unique identifier of the asset. * @@ -105,6 +119,15 @@ private constructor( @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [customMetadata]. + * + * Unlike [customMetadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customMetadata") + @ExcludeMissing + fun _customMetadata(): JsonField = customMetadata + /** * Returns the raw JSON value of [folderId]. * @@ -164,6 +187,7 @@ private constructor( class Builder internal constructor() { private var createdAt: JsonField = JsonMissing.of() + private var customMetadata: JsonField = JsonMissing.of() private var folderId: JsonField = JsonMissing.of() private var folderPath: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() @@ -174,6 +198,7 @@ private constructor( @JvmSynthetic internal fun from(folder: Folder) = apply { createdAt = folder.createdAt + customMetadata = folder.customMetadata folderId = folder.folderId folderPath = folder.folderPath name = folder.name @@ -194,6 +219,24 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** + * An object with custom metadata for the folder. Returns empty object if no custom metadata + * is set. + */ + fun customMetadata(customMetadata: CustomMetadata) = + customMetadata(JsonField.of(customMetadata)) + + /** + * Sets [Builder.customMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.customMetadata] with a well-typed [CustomMetadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customMetadata(customMetadata: JsonField) = apply { + this.customMetadata = customMetadata + } + /** Unique identifier of the asset. */ fun folderId(folderId: String) = folderId(JsonField.of(folderId)) @@ -284,6 +327,7 @@ private constructor( fun build(): Folder = Folder( createdAt, + customMetadata, folderId, folderPath, name, @@ -301,6 +345,7 @@ private constructor( } createdAt() + customMetadata().ifPresent { it.validate() } folderId() folderPath() name() @@ -325,12 +370,116 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (createdAt.asKnown().isPresent) 1 else 0) + + (customMetadata.asKnown().getOrNull()?.validity() ?: 0) + (if (folderId.asKnown().isPresent) 1 else 0) + (if (folderPath.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (updatedAt.asKnown().isPresent) 1 else 0) + /** + * An object with custom metadata for the folder. Returns empty object if no custom metadata is + * set. + */ + class CustomMetadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CustomMetadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customMetadata: CustomMetadata) = apply { + additionalProperties = customMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CustomMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomMetadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" + } + /** Type of the asset. */ class Type @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -460,6 +609,7 @@ private constructor( return other is Folder && createdAt == other.createdAt && + customMetadata == other.customMetadata && folderId == other.folderId && folderPath == other.folderPath && name == other.name && @@ -469,11 +619,20 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(createdAt, folderId, folderPath, name, type, updatedAt, additionalProperties) + Objects.hash( + createdAt, + customMetadata, + folderId, + folderPath, + name, + type, + updatedAt, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Folder{createdAt=$createdAt, folderId=$folderId, folderPath=$folderPath, name=$name, type=$type, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" + "Folder{createdAt=$createdAt, customMetadata=$customMetadata, folderId=$folderId, folderPath=$folderPath, name=$name, type=$type, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt index 58a986d1..cc8f4deb 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt @@ -170,6 +170,11 @@ internal class AssetListResponseTest { val folder = Folder.builder() .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customMetadata( + Folder.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .folderId("folderId") .folderPath("folderPath") .name("name") @@ -190,6 +195,11 @@ internal class AssetListResponseTest { AssetListResponse.ofFolder( Folder.builder() .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customMetadata( + Folder.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .folderId("folderId") .folderPath("folderPath") .name("name") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FolderTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FolderTest.kt index e4c406e6..71de26a4 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FolderTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FolderTest.kt @@ -3,6 +3,7 @@ package com.imagekit.api.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -15,6 +16,11 @@ internal class FolderTest { val folder = Folder.builder() .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customMetadata( + Folder.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .folderId("folderId") .folderPath("folderPath") .name("name") @@ -23,6 +29,12 @@ internal class FolderTest { .build() assertThat(folder.createdAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(folder.customMetadata()) + .contains( + Folder.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(folder.folderId()).contains("folderId") assertThat(folder.folderPath()).contains("folderPath") assertThat(folder.name()).contains("name") @@ -36,6 +48,11 @@ internal class FolderTest { val folder = Folder.builder() .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customMetadata( + Folder.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .folderId("folderId") .folderPath("folderPath") .name("name") From ff73a7abfc250eb2558c073684d328a48b9df29e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 6 Feb 2026 19:59:53 +0000 Subject: [PATCH 094/142] feat(api): add webhook signature verification --- image-kit-java-core/build.gradle.kts | 1 + .../imagekit/api/core/UnwrapWebhookParams.kt | 102 +++++++++++++++ .../api/errors/ImageKitWebhookException.kt | 5 + .../api/services/async/WebhookServiceAsync.kt | 10 ++ .../services/async/WebhookServiceAsyncImpl.kt | 15 +-- .../api/services/blocking/WebhookService.kt | 10 ++ .../services/blocking/WebhookServiceImpl.kt | 38 ++++-- .../services/async/WebhookServiceAsyncTest.kt | 117 ++++++++++++++++++ .../services/blocking/WebhookServiceTest.kt | 117 ++++++++++++++++++ 9 files changed, 394 insertions(+), 21 deletions(-) create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/core/UnwrapWebhookParams.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitWebhookException.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt diff --git a/image-kit-java-core/build.gradle.kts b/image-kit-java-core/build.gradle.kts index 178d6aa7..4fdcf36d 100644 --- a/image-kit-java-core/build.gradle.kts +++ b/image-kit-java-core/build.gradle.kts @@ -22,6 +22,7 @@ dependencies { api("com.fasterxml.jackson.core:jackson-core:2.18.2") api("com.fasterxml.jackson.core:jackson-databind:2.18.2") api("com.google.errorprone:error_prone_annotations:2.33.0") + api("com.standardwebhooks:standardwebhooks:1.1.0") implementation("com.fasterxml.jackson.core:jackson-annotations:2.18.2") implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2") diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/UnwrapWebhookParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/UnwrapWebhookParams.kt new file mode 100644 index 00000000..58dc26b8 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/UnwrapWebhookParams.kt @@ -0,0 +1,102 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.core + +import com.imagekit.api.core.http.Headers +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class UnwrapWebhookParams +private constructor( + private val body: String, + private val headers: Headers?, + private val secret: String?, +) { + + /** The raw JSON body of the webhook request. */ + fun body(): String = body + + /** The headers from the webhook request. */ + fun headers(): Optional = Optional.ofNullable(headers) + + /** The secret used to verify the webhook signature. */ + fun secret(): Optional = Optional.ofNullable(secret) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnwrapWebhookParams]. + * + * The following fields are required: + * ```java + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnwrapWebhookParams]. */ + class Builder internal constructor() { + + private var body: String? = null + private var headers: Headers? = null + private var secret: String? = null + + @JvmSynthetic + internal fun from(unwrapWebhookParams: UnwrapWebhookParams) = apply { + body = unwrapWebhookParams.body + headers = unwrapWebhookParams.headers + secret = unwrapWebhookParams.secret + } + + /** The raw JSON body of the webhook request. */ + fun body(body: String) = apply { this.body = body } + + /** The headers from the webhook request. */ + fun headers(headers: Headers?) = apply { this.headers = headers } + + /** Alias for calling [Builder.headers] with `headers.orElse(null)`. */ + fun headers(headers: Optional) = headers(headers.getOrNull()) + + /** The secret used to verify the webhook signature. */ + fun secret(secret: String?) = apply { this.secret = secret } + + /** Alias for calling [Builder.secret] with `secret.orElse(null)`. */ + fun secret(secret: Optional) = secret(secret.getOrNull()) + + /** + * Returns an immutable instance of [UnwrapWebhookParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnwrapWebhookParams = + UnwrapWebhookParams(checkRequired("body", body), headers, secret) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnwrapWebhookParams && + body == other.body && + headers == other.headers && + secret == other.secret + } + + private val hashCode: Int by lazy { Objects.hash(body, headers, secret) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnwrapWebhookParams{body=$body, headers=$headers, secret=$secret}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitWebhookException.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitWebhookException.kt new file mode 100644 index 00000000..7b846cc8 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitWebhookException.kt @@ -0,0 +1,5 @@ +package com.imagekit.api.errors + +class ImageKitWebhookException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : ImageKitException(message, cause) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsync.kt index 68d16414..0ba2e5ca 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsync.kt @@ -3,7 +3,9 @@ package com.imagekit.api.services.async import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.UnwrapWebhookParams import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.errors.ImageKitWebhookException import com.imagekit.api.models.webhooks.UnsafeUnwrapWebhookEvent import com.imagekit.api.models.webhooks.UnwrapWebhookEvent import java.util.function.Consumer @@ -36,6 +38,14 @@ interface WebhookServiceAsync { */ fun unwrap(body: String): UnwrapWebhookEvent + /** + * Unwraps a webhook event from its JSON representation. + * + * @throws ImageKitInvalidDataException if the body could not be parsed. + * @throws ImageKitWebhookException if the webhook signature could not be verified + */ + fun unwrap(unwrapParams: UnwrapWebhookParams): UnwrapWebhookEvent + /** * A view of [WebhookServiceAsync] that provides access to raw HTTP responses for each method. */ diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncImpl.kt index b2c9b205..5ea79828 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncImpl.kt @@ -3,7 +3,7 @@ package com.imagekit.api.services.async import com.imagekit.api.core.ClientOptions -import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.core.UnwrapWebhookParams import com.imagekit.api.models.webhooks.UnsafeUnwrapWebhookEvent import com.imagekit.api.models.webhooks.UnwrapWebhookEvent import com.imagekit.api.services.blocking.WebhookServiceImpl @@ -21,22 +21,15 @@ class WebhookServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withOptions(modifier: Consumer): WebhookServiceAsync = WebhookServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - /** - * Unwraps a webhook event from its JSON representation. - * - * @throws ImageKitInvalidDataException if the body could not be parsed. - */ override fun unsafeUnwrap(body: String): UnsafeUnwrapWebhookEvent = WebhookServiceImpl(clientOptions).unsafeUnwrap(body) - /** - * Unwraps a webhook event from its JSON representation. - * - * @throws ImageKitInvalidDataException if the body could not be parsed. - */ override fun unwrap(body: String): UnwrapWebhookEvent = WebhookServiceImpl(clientOptions).unwrap(body) + override fun unwrap(unwrapParams: UnwrapWebhookParams): UnwrapWebhookEvent = + WebhookServiceImpl(clientOptions).unwrap(unwrapParams) + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : WebhookServiceAsync.WithRawResponse { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookService.kt index 953d9d20..fbbfb89b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookService.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookService.kt @@ -3,7 +3,9 @@ package com.imagekit.api.services.blocking import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.UnwrapWebhookParams import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.errors.ImageKitWebhookException import com.imagekit.api.models.webhooks.UnsafeUnwrapWebhookEvent import com.imagekit.api.models.webhooks.UnwrapWebhookEvent import java.util.function.Consumer @@ -36,6 +38,14 @@ interface WebhookService { */ fun unwrap(body: String): UnwrapWebhookEvent + /** + * Unwraps a webhook event from its JSON representation. + * + * @throws ImageKitInvalidDataException if the body could not be parsed. + * @throws ImageKitWebhookException if the webhook signature could not be verified + */ + fun unwrap(unwrapParams: UnwrapWebhookParams): UnwrapWebhookEvent + /** A view of [WebhookService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookServiceImpl.kt index 7e81f403..85e3f9d9 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookServiceImpl.kt @@ -4,10 +4,16 @@ package com.imagekit.api.services.blocking import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.ClientOptions +import com.imagekit.api.core.UnwrapWebhookParams +import com.imagekit.api.core.checkRequired import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.errors.ImageKitWebhookException import com.imagekit.api.models.webhooks.UnsafeUnwrapWebhookEvent import com.imagekit.api.models.webhooks.UnwrapWebhookEvent +import com.standardwebhooks.Webhook +import com.standardwebhooks.exceptions.WebhookVerificationException import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull class WebhookServiceImpl internal constructor(private val clientOptions: ClientOptions) : WebhookService { @@ -21,11 +27,6 @@ class WebhookServiceImpl internal constructor(private val clientOptions: ClientO override fun withOptions(modifier: Consumer): WebhookService = WebhookServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - /** - * Unwraps a webhook event from its JSON representation. - * - * @throws ImageKitInvalidDataException if the body could not be parsed. - */ override fun unsafeUnwrap(body: String): UnsafeUnwrapWebhookEvent = try { clientOptions.jsonMapper.readValue(body, jacksonTypeRef()) @@ -33,11 +34,6 @@ class WebhookServiceImpl internal constructor(private val clientOptions: ClientO throw ImageKitInvalidDataException("Error parsing body", e) } - /** - * Unwraps a webhook event from its JSON representation. - * - * @throws ImageKitInvalidDataException if the body could not be parsed. - */ override fun unwrap(body: String): UnwrapWebhookEvent = try { clientOptions.jsonMapper.readValue(body, jacksonTypeRef()) @@ -45,6 +41,28 @@ class WebhookServiceImpl internal constructor(private val clientOptions: ClientO throw ImageKitInvalidDataException("Error parsing body", e) } + override fun unwrap(unwrapParams: UnwrapWebhookParams): UnwrapWebhookEvent { + val headers = unwrapParams.headers().getOrNull() + if (headers != null) { + try { + val webhookSecret = + checkRequired( + "webhookSecret", + unwrapParams.secret().getOrNull() + ?: clientOptions.webhookSecret().getOrNull(), + ) + val headersMap = + headers.names().associateWith { name -> headers.values(name) }.toMap() + + val webhook = Webhook(webhookSecret) + webhook.verify(unwrapParams.body(), headersMap) + } catch (e: WebhookVerificationException) { + throw ImageKitWebhookException("Could not verify webhook event signature", e) + } + } + return unwrap(unwrapParams.body()) + } + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : WebhookService.WithRawResponse { diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt new file mode 100644 index 00000000..634d86de --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.async + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import com.imagekit.api.core.UnwrapWebhookParams +import com.imagekit.api.core.http.Headers +import com.imagekit.api.errors.ImageKitWebhookException +import com.standardwebhooks.Webhook +import java.time.Instant +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class WebhookServiceAsyncTest { + + @Test + fun unsafeUnwrap() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateKey("My Private Key") + .password("My Password") + .build() + val webhookServiceAsync = client.webhooks() + + val payload = + "{\"id\":\"id\",\"type\":\"video.transformation.accepted\",\"created_at\":\"2019-12-27T18:11:19.117Z\",\"data\":{\"asset\":{\"url\":\"https://example.com\"},\"transformation\":{\"type\":\"video-transformation\",\"options\":{\"audio_codec\":\"aac\",\"auto_rotate\":true,\"format\":\"mp4\",\"quality\":0,\"stream_protocol\":\"HLS\",\"variants\":[\"string\"],\"video_codec\":\"h264\"}}},\"request\":{\"url\":\"https://example.com\",\"x_request_id\":\"x_request_id\",\"user_agent\":\"user_agent\"}}" + val webhookSecret = "whsec_c2VjcmV0Cg==" + val headers = Headers.builder().build() + + webhookServiceAsync.unsafeUnwrap(payload).validate() + } + + @Test + fun unwrap() { + val client = + ImageKitOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateKey("My Private Key") + .password("My Password") + .build() + val webhookServiceAsync = client.webhooks() + + val payload = + "{\"id\":\"id\",\"type\":\"video.transformation.accepted\",\"created_at\":\"2019-12-27T18:11:19.117Z\",\"data\":{\"asset\":{\"url\":\"https://example.com\"},\"transformation\":{\"type\":\"video-transformation\",\"options\":{\"audio_codec\":\"aac\",\"auto_rotate\":true,\"format\":\"mp4\",\"quality\":0,\"stream_protocol\":\"HLS\",\"variants\":[\"string\"],\"video_codec\":\"h264\"}}},\"request\":{\"url\":\"https://example.com\",\"x_request_id\":\"x_request_id\",\"user_agent\":\"user_agent\"}}" + val webhookSecret = "whsec_c2VjcmV0Cg==" + val messageId = "1" + val timestampSeconds = Instant.now().epochSecond + val webhook = Webhook(webhookSecret) + val signature = webhook.sign(messageId, timestampSeconds, payload) + val headers = + Headers.builder() + .putAll( + mapOf( + "webhook-signature" to listOf(signature), + "webhook-id" to listOf(messageId), + "webhook-timestamp" to listOf(timestampSeconds.toString()), + ) + ) + .build() + + webhookServiceAsync.unwrap(payload).validate() + + // Wrong key should throw + assertThrows { + val wrongKey = "whsec_aaaaaaaaaa" + webhookServiceAsync.unwrap( + UnwrapWebhookParams.builder() + .body(payload) + .headers(headers) + .secret(wrongKey) + .build() + ) + } + + // Bad signature should throw + assertThrows { + val badSig = webhook.sign(messageId, timestampSeconds, "some other payload") + val badHeaders = + headers.toBuilder().replace("webhook-signature", listOf(badSig)).build() + webhookServiceAsync.unwrap( + UnwrapWebhookParams.builder() + .body(payload) + .headers(badHeaders) + .secret(webhookSecret) + .build() + ) + } + + // Old timestamp should throw + assertThrows { + val oldHeaders = headers.toBuilder().replace("webhook-timestamp", listOf("5")).build() + webhookServiceAsync.unwrap( + UnwrapWebhookParams.builder() + .body(payload) + .headers(oldHeaders) + .secret(webhookSecret) + .build() + ) + } + + // Wrong message ID should throw + assertThrows { + val wrongIdHeaders = headers.toBuilder().replace("webhook-id", listOf("wrong")).build() + webhookServiceAsync.unwrap( + UnwrapWebhookParams.builder() + .body(payload) + .headers(wrongIdHeaders) + .secret(webhookSecret) + .build() + ) + } + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt new file mode 100644 index 00000000..5ca6da09 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.services.blocking + +import com.imagekit.api.TestServerExtension +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.core.UnwrapWebhookParams +import com.imagekit.api.core.http.Headers +import com.imagekit.api.errors.ImageKitWebhookException +import com.standardwebhooks.Webhook +import java.time.Instant +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class WebhookServiceTest { + + @Test + fun unsafeUnwrap() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateKey("My Private Key") + .password("My Password") + .build() + val webhookService = client.webhooks() + + val payload = + "{\"id\":\"id\",\"type\":\"video.transformation.accepted\",\"created_at\":\"2019-12-27T18:11:19.117Z\",\"data\":{\"asset\":{\"url\":\"https://example.com\"},\"transformation\":{\"type\":\"video-transformation\",\"options\":{\"audio_codec\":\"aac\",\"auto_rotate\":true,\"format\":\"mp4\",\"quality\":0,\"stream_protocol\":\"HLS\",\"variants\":[\"string\"],\"video_codec\":\"h264\"}}},\"request\":{\"url\":\"https://example.com\",\"x_request_id\":\"x_request_id\",\"user_agent\":\"user_agent\"}}" + val webhookSecret = "whsec_c2VjcmV0Cg==" + val headers = Headers.builder().build() + + webhookService.unsafeUnwrap(payload).validate() + } + + @Test + fun unwrap() { + val client = + ImageKitOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .privateKey("My Private Key") + .password("My Password") + .build() + val webhookService = client.webhooks() + + val payload = + "{\"id\":\"id\",\"type\":\"video.transformation.accepted\",\"created_at\":\"2019-12-27T18:11:19.117Z\",\"data\":{\"asset\":{\"url\":\"https://example.com\"},\"transformation\":{\"type\":\"video-transformation\",\"options\":{\"audio_codec\":\"aac\",\"auto_rotate\":true,\"format\":\"mp4\",\"quality\":0,\"stream_protocol\":\"HLS\",\"variants\":[\"string\"],\"video_codec\":\"h264\"}}},\"request\":{\"url\":\"https://example.com\",\"x_request_id\":\"x_request_id\",\"user_agent\":\"user_agent\"}}" + val webhookSecret = "whsec_c2VjcmV0Cg==" + val messageId = "1" + val timestampSeconds = Instant.now().epochSecond + val webhook = Webhook(webhookSecret) + val signature = webhook.sign(messageId, timestampSeconds, payload) + val headers = + Headers.builder() + .putAll( + mapOf( + "webhook-signature" to listOf(signature), + "webhook-id" to listOf(messageId), + "webhook-timestamp" to listOf(timestampSeconds.toString()), + ) + ) + .build() + + webhookService.unwrap(payload).validate() + + // Wrong key should throw + assertThrows { + val wrongKey = "whsec_aaaaaaaaaa" + webhookService.unwrap( + UnwrapWebhookParams.builder() + .body(payload) + .headers(headers) + .secret(wrongKey) + .build() + ) + } + + // Bad signature should throw + assertThrows { + val badSig = webhook.sign(messageId, timestampSeconds, "some other payload") + val badHeaders = + headers.toBuilder().replace("webhook-signature", listOf(badSig)).build() + webhookService.unwrap( + UnwrapWebhookParams.builder() + .body(payload) + .headers(badHeaders) + .secret(webhookSecret) + .build() + ) + } + + // Old timestamp should throw + assertThrows { + val oldHeaders = headers.toBuilder().replace("webhook-timestamp", listOf("5")).build() + webhookService.unwrap( + UnwrapWebhookParams.builder() + .body(payload) + .headers(oldHeaders) + .secret(webhookSecret) + .build() + ) + } + + // Wrong message ID should throw + assertThrows { + val wrongIdHeaders = headers.toBuilder().replace("webhook-id", listOf("wrong")).build() + webhookService.unwrap( + UnwrapWebhookParams.builder() + .body(payload) + .headers(wrongIdHeaders) + .secret(webhookSecret) + .build() + ) + } + } +} From 99a48d6896e90c14b96e182b85692a7f1b6aece7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 6 Feb 2026 20:55:31 +0000 Subject: [PATCH 095/142] chore(internal): upgrade AssertJ --- image-kit-java-client-okhttp/build.gradle.kts | 2 +- image-kit-java-core/build.gradle.kts | 2 +- image-kit-java-proguard-test/build.gradle.kts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/image-kit-java-client-okhttp/build.gradle.kts b/image-kit-java-client-okhttp/build.gradle.kts index fae6d579..51259131 100644 --- a/image-kit-java-client-okhttp/build.gradle.kts +++ b/image-kit-java-client-okhttp/build.gradle.kts @@ -10,6 +10,6 @@ dependencies { implementation("com.squareup.okhttp3:logging-interceptor:4.12.0") testImplementation(kotlin("test")) - testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.assertj:assertj-core:3.27.7") testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") } diff --git a/image-kit-java-core/build.gradle.kts b/image-kit-java-core/build.gradle.kts index 4fdcf36d..eb5fb491 100644 --- a/image-kit-java-core/build.gradle.kts +++ b/image-kit-java-core/build.gradle.kts @@ -34,7 +34,7 @@ dependencies { testImplementation(kotlin("test")) testImplementation(project(":image-kit-java-client-okhttp")) testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") - testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.assertj:assertj-core:3.27.7") testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3") testImplementation("org.junit-pioneer:junit-pioneer:1.9.1") diff --git a/image-kit-java-proguard-test/build.gradle.kts b/image-kit-java-proguard-test/build.gradle.kts index ea537228..13025755 100644 --- a/image-kit-java-proguard-test/build.gradle.kts +++ b/image-kit-java-proguard-test/build.gradle.kts @@ -18,7 +18,7 @@ dependencies { testImplementation(project(":image-kit-java")) testImplementation(kotlin("test")) testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") - testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.assertj:assertj-core:3.27.7") testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.0") } From 89b85982f5be8ac9de8b4ea05a6ca0490951f21b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Feb 2026 17:57:52 +0000 Subject: [PATCH 096/142] chore(internal): update `TestServerExtension` comment --- .../com/imagekit/api/TestServerExtension.kt | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/TestServerExtension.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/TestServerExtension.kt index ac78240e..bdd90d75 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/TestServerExtension.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/TestServerExtension.kt @@ -15,25 +15,12 @@ class TestServerExtension : BeforeAllCallback, ExecutionCondition { } catch (e: Exception) { throw RuntimeException( """ - The test suite will not run without a mock Prism server running against your OpenAPI spec. + The test suite will not run without a mock server running against your OpenAPI spec. You can set the environment variable `SKIP_MOCK_TESTS` to `true` to skip running any tests that require the mock server. - To fix: - - 1. Install Prism (requires Node 16+): - - With npm: - $ npm install -g @stoplight/prism-cli - - With yarn: - $ yarn global add @stoplight/prism-cli - - 2. Run the mock server - - To run the server, pass in the path of your OpenAPI spec to the prism command: - $ prism mock path/to/your.openapi.yml + To fix run `./scripts/mock` in a separate terminal. """ .trimIndent(), e, From 98d50fa72841ab2a4fe4baf62861f4c2e911a23b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Feb 2026 18:06:38 +0000 Subject: [PATCH 097/142] chore(internal): remove unnecessary base URL --- .../com/imagekit/api/services/async/WebhookServiceAsyncTest.kt | 2 -- .../com/imagekit/api/services/blocking/WebhookServiceTest.kt | 2 -- 2 files changed, 4 deletions(-) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt index 634d86de..e470bd2c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt @@ -20,7 +20,6 @@ internal class WebhookServiceAsyncTest { fun unsafeUnwrap() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -38,7 +37,6 @@ internal class WebhookServiceAsyncTest { fun unwrap() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt index 5ca6da09..033df2d9 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt @@ -20,7 +20,6 @@ internal class WebhookServiceTest { fun unsafeUnwrap() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -38,7 +37,6 @@ internal class WebhookServiceTest { fun unwrap() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() From 534feb30f3c327e09d1e13423e447224e2da90d7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 20:47:27 +0000 Subject: [PATCH 098/142] chore(internal): make `OkHttp` constructor internal --- .../main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt index 5cc27388..eae703d7 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt @@ -33,7 +33,7 @@ import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink class OkHttpClient -private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient { +internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient { override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { val call = newCall(request, requestOptions) From f462bfff56865ae16dadb5a404c696d3d5ff1ff9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 22:00:17 +0000 Subject: [PATCH 099/142] feat(client): add more convenience service method overloads --- .../async/accounts/OriginServiceAsync.kt | 187 ++++++++++++++++++ .../blocking/accounts/OriginService.kt | 181 +++++++++++++++++ .../async/accounts/OriginServiceAsyncTest.kt | 20 +- .../blocking/accounts/OriginServiceTest.kt | 20 +- 4 files changed, 386 insertions(+), 22 deletions(-) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsync.kt index f21f8782..c568f188 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsync.kt @@ -53,6 +53,93 @@ interface OriginServiceAsync { fun create(originRequest: OriginRequest): CompletableFuture = create(originRequest, RequestOptions.none()) + /** @see create */ + fun create( + s3: OriginRequest.S3, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = create(OriginRequest.ofS3(s3), requestOptions) + + /** @see create */ + fun create(s3: OriginRequest.S3): CompletableFuture = + create(s3, RequestOptions.none()) + + /** @see create */ + fun create( + s3Compatible: OriginRequest.S3Compatible, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(OriginRequest.ofS3Compatible(s3Compatible), requestOptions) + + /** @see create */ + fun create(s3Compatible: OriginRequest.S3Compatible): CompletableFuture = + create(s3Compatible, RequestOptions.none()) + + /** @see create */ + fun create( + cloudinaryBackup: OriginRequest.CloudinaryBackup, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(OriginRequest.ofCloudinaryBackup(cloudinaryBackup), requestOptions) + + /** @see create */ + fun create( + cloudinaryBackup: OriginRequest.CloudinaryBackup + ): CompletableFuture = create(cloudinaryBackup, RequestOptions.none()) + + /** @see create */ + fun create( + webFolder: OriginRequest.WebFolder, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(OriginRequest.ofWebFolder(webFolder), requestOptions) + + /** @see create */ + fun create(webFolder: OriginRequest.WebFolder): CompletableFuture = + create(webFolder, RequestOptions.none()) + + /** @see create */ + fun create( + webProxy: OriginRequest.WebProxy, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(OriginRequest.ofWebProxy(webProxy), requestOptions) + + /** @see create */ + fun create(webProxy: OriginRequest.WebProxy): CompletableFuture = + create(webProxy, RequestOptions.none()) + + /** @see create */ + fun create( + gcs: OriginRequest.Gcs, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = create(OriginRequest.ofGcs(gcs), requestOptions) + + /** @see create */ + fun create(gcs: OriginRequest.Gcs): CompletableFuture = + create(gcs, RequestOptions.none()) + + /** @see create */ + fun create( + azureBlob: OriginRequest.AzureBlob, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(OriginRequest.ofAzureBlob(azureBlob), requestOptions) + + /** @see create */ + fun create(azureBlob: OriginRequest.AzureBlob): CompletableFuture = + create(azureBlob, RequestOptions.none()) + + /** @see create */ + fun create( + akeneoPim: OriginRequest.AkeneoPim, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(OriginRequest.ofAkeneoPim(akeneoPim), requestOptions) + + /** @see create */ + fun create(akeneoPim: OriginRequest.AkeneoPim): CompletableFuture = + create(akeneoPim, RequestOptions.none()) + /** * **Note:** This API is currently in beta. Updates the origin identified by `id` and returns * the updated origin object. @@ -204,6 +291,106 @@ interface OriginServiceAsync { ): CompletableFuture> = create(originRequest, RequestOptions.none()) + /** @see create */ + fun create( + s3: OriginRequest.S3, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(OriginRequest.ofS3(s3), requestOptions) + + /** @see create */ + fun create(s3: OriginRequest.S3): CompletableFuture> = + create(s3, RequestOptions.none()) + + /** @see create */ + fun create( + s3Compatible: OriginRequest.S3Compatible, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(OriginRequest.ofS3Compatible(s3Compatible), requestOptions) + + /** @see create */ + fun create( + s3Compatible: OriginRequest.S3Compatible + ): CompletableFuture> = + create(s3Compatible, RequestOptions.none()) + + /** @see create */ + fun create( + cloudinaryBackup: OriginRequest.CloudinaryBackup, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(OriginRequest.ofCloudinaryBackup(cloudinaryBackup), requestOptions) + + /** @see create */ + fun create( + cloudinaryBackup: OriginRequest.CloudinaryBackup + ): CompletableFuture> = + create(cloudinaryBackup, RequestOptions.none()) + + /** @see create */ + fun create( + webFolder: OriginRequest.WebFolder, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(OriginRequest.ofWebFolder(webFolder), requestOptions) + + /** @see create */ + fun create( + webFolder: OriginRequest.WebFolder + ): CompletableFuture> = + create(webFolder, RequestOptions.none()) + + /** @see create */ + fun create( + webProxy: OriginRequest.WebProxy, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(OriginRequest.ofWebProxy(webProxy), requestOptions) + + /** @see create */ + fun create( + webProxy: OriginRequest.WebProxy + ): CompletableFuture> = + create(webProxy, RequestOptions.none()) + + /** @see create */ + fun create( + gcs: OriginRequest.Gcs, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(OriginRequest.ofGcs(gcs), requestOptions) + + /** @see create */ + fun create(gcs: OriginRequest.Gcs): CompletableFuture> = + create(gcs, RequestOptions.none()) + + /** @see create */ + fun create( + azureBlob: OriginRequest.AzureBlob, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(OriginRequest.ofAzureBlob(azureBlob), requestOptions) + + /** @see create */ + fun create( + azureBlob: OriginRequest.AzureBlob + ): CompletableFuture> = + create(azureBlob, RequestOptions.none()) + + /** @see create */ + fun create( + akeneoPim: OriginRequest.AkeneoPim, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(OriginRequest.ofAkeneoPim(akeneoPim), requestOptions) + + /** @see create */ + fun create( + akeneoPim: OriginRequest.AkeneoPim + ): CompletableFuture> = + create(akeneoPim, RequestOptions.none()) + /** * Returns a raw HTTP response for `put /v1/accounts/origins/{id}`, but is otherwise the * same as [OriginServiceAsync.update]. diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginService.kt index 2ccb9932..4cbab138 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginService.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginService.kt @@ -52,6 +52,84 @@ interface OriginService { fun create(originRequest: OriginRequest): OriginResponse = create(originRequest, RequestOptions.none()) + /** @see create */ + fun create( + s3: OriginRequest.S3, + requestOptions: RequestOptions = RequestOptions.none(), + ): OriginResponse = create(OriginRequest.ofS3(s3), requestOptions) + + /** @see create */ + fun create(s3: OriginRequest.S3): OriginResponse = create(s3, RequestOptions.none()) + + /** @see create */ + fun create( + s3Compatible: OriginRequest.S3Compatible, + requestOptions: RequestOptions = RequestOptions.none(), + ): OriginResponse = create(OriginRequest.ofS3Compatible(s3Compatible), requestOptions) + + /** @see create */ + fun create(s3Compatible: OriginRequest.S3Compatible): OriginResponse = + create(s3Compatible, RequestOptions.none()) + + /** @see create */ + fun create( + cloudinaryBackup: OriginRequest.CloudinaryBackup, + requestOptions: RequestOptions = RequestOptions.none(), + ): OriginResponse = create(OriginRequest.ofCloudinaryBackup(cloudinaryBackup), requestOptions) + + /** @see create */ + fun create(cloudinaryBackup: OriginRequest.CloudinaryBackup): OriginResponse = + create(cloudinaryBackup, RequestOptions.none()) + + /** @see create */ + fun create( + webFolder: OriginRequest.WebFolder, + requestOptions: RequestOptions = RequestOptions.none(), + ): OriginResponse = create(OriginRequest.ofWebFolder(webFolder), requestOptions) + + /** @see create */ + fun create(webFolder: OriginRequest.WebFolder): OriginResponse = + create(webFolder, RequestOptions.none()) + + /** @see create */ + fun create( + webProxy: OriginRequest.WebProxy, + requestOptions: RequestOptions = RequestOptions.none(), + ): OriginResponse = create(OriginRequest.ofWebProxy(webProxy), requestOptions) + + /** @see create */ + fun create(webProxy: OriginRequest.WebProxy): OriginResponse = + create(webProxy, RequestOptions.none()) + + /** @see create */ + fun create( + gcs: OriginRequest.Gcs, + requestOptions: RequestOptions = RequestOptions.none(), + ): OriginResponse = create(OriginRequest.ofGcs(gcs), requestOptions) + + /** @see create */ + fun create(gcs: OriginRequest.Gcs): OriginResponse = create(gcs, RequestOptions.none()) + + /** @see create */ + fun create( + azureBlob: OriginRequest.AzureBlob, + requestOptions: RequestOptions = RequestOptions.none(), + ): OriginResponse = create(OriginRequest.ofAzureBlob(azureBlob), requestOptions) + + /** @see create */ + fun create(azureBlob: OriginRequest.AzureBlob): OriginResponse = + create(azureBlob, RequestOptions.none()) + + /** @see create */ + fun create( + akeneoPim: OriginRequest.AkeneoPim, + requestOptions: RequestOptions = RequestOptions.none(), + ): OriginResponse = create(OriginRequest.ofAkeneoPim(akeneoPim), requestOptions) + + /** @see create */ + fun create(akeneoPim: OriginRequest.AkeneoPim): OriginResponse = + create(akeneoPim, RequestOptions.none()) + /** * **Note:** This API is currently in beta. Updates the origin identified by `id` and returns * the updated origin object. @@ -190,6 +268,109 @@ interface OriginService { fun create(originRequest: OriginRequest): HttpResponseFor = create(originRequest, RequestOptions.none()) + /** @see create */ + @MustBeClosed + fun create( + s3: OriginRequest.S3, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = create(OriginRequest.ofS3(s3), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(s3: OriginRequest.S3): HttpResponseFor = + create(s3, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + s3Compatible: OriginRequest.S3Compatible, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(OriginRequest.ofS3Compatible(s3Compatible), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(s3Compatible: OriginRequest.S3Compatible): HttpResponseFor = + create(s3Compatible, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + cloudinaryBackup: OriginRequest.CloudinaryBackup, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(OriginRequest.ofCloudinaryBackup(cloudinaryBackup), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + cloudinaryBackup: OriginRequest.CloudinaryBackup + ): HttpResponseFor = create(cloudinaryBackup, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + webFolder: OriginRequest.WebFolder, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(OriginRequest.ofWebFolder(webFolder), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(webFolder: OriginRequest.WebFolder): HttpResponseFor = + create(webFolder, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + webProxy: OriginRequest.WebProxy, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(OriginRequest.ofWebProxy(webProxy), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(webProxy: OriginRequest.WebProxy): HttpResponseFor = + create(webProxy, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + gcs: OriginRequest.Gcs, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = create(OriginRequest.ofGcs(gcs), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(gcs: OriginRequest.Gcs): HttpResponseFor = + create(gcs, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + azureBlob: OriginRequest.AzureBlob, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(OriginRequest.ofAzureBlob(azureBlob), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(azureBlob: OriginRequest.AzureBlob): HttpResponseFor = + create(azureBlob, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + akeneoPim: OriginRequest.AkeneoPim, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(OriginRequest.ofAkeneoPim(akeneoPim), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(akeneoPim: OriginRequest.AkeneoPim): HttpResponseFor = + create(akeneoPim, RequestOptions.none()) + /** * Returns a raw HTTP response for `put /v1/accounts/origins/{id}`, but is otherwise the * same as [OriginService.update]. diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt index 0175764c..94691800 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt @@ -26,17 +26,15 @@ internal class OriginServiceAsyncTest { val originResponseFuture = originServiceAsync.create( - OriginRequest.ofS3( - OriginRequest.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("images") - .build() - ) + OriginRequest.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() ) val originResponse = originResponseFuture.get() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt index 14b8b7a4..e66eb4ba 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt @@ -26,17 +26,15 @@ internal class OriginServiceTest { val originResponse = originService.create( - OriginRequest.ofS3( - OriginRequest.S3.builder() - .accessKey("AKIATEST123") - .bucket("test-bucket") - .name("My S3 Origin") - .secretKey("secrettest123") - .baseUrlForCanonicalHeader("https://cdn.example.com") - .includeCanonicalHeader(false) - .prefix("images") - .build() - ) + OriginRequest.S3.builder() + .accessKey("AKIATEST123") + .bucket("test-bucket") + .name("My S3 Origin") + .secretKey("secrettest123") + .baseUrlForCanonicalHeader("https://cdn.example.com") + .includeCanonicalHeader(false) + .prefix("images") + .build() ) originResponse.validate() From c7a72959cf29e796657dea8d7590f4b96d5fb542 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 23:02:58 +0000 Subject: [PATCH 100/142] feat(client): add connection pooling option --- README.md | 19 ++++++++ .../api/client/okhttp/ImageKitOkHttpClient.kt | 44 +++++++++++++++++++ .../okhttp/ImageKitOkHttpClientAsync.kt | 44 +++++++++++++++++++ .../api/client/okhttp/OkHttpClient.kt | 42 ++++++++++++++++++ 4 files changed, 149 insertions(+) diff --git a/README.md b/README.md index c882c6b0..5cca7f58 100644 --- a/README.md +++ b/README.md @@ -417,6 +417,25 @@ ImageKitClient client = ImageKitOkHttpClient.builder() .build(); ``` +### Connection pooling + +To customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods: + +```java +import com.imagekit.api.client.ImageKitClient; +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import java.time.Duration; + +ImageKitClient client = ImageKitOkHttpClient.builder() + .fromEnv() + // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa. + .maxIdleConnections(10) + .keepAliveDuration(Duration.ofMinutes(2)) + .build(); +``` + +If both options are unset, OkHttp's default connection pool settings are used. + ### HTTPS > [!NOTE] diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt index 8f719c14..24ad8e9e 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt @@ -47,6 +47,8 @@ class ImageKitOkHttpClient private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null + private var maxIdleConnections: Int? = null + private var keepAliveDuration: Duration? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null @@ -75,6 +77,46 @@ class ImageKitOkHttpClient private constructor() { /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + /** + * The maximum number of idle connections kept by the underlying OkHttp connection pool. + * + * If this is set, then [keepAliveDuration] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun maxIdleConnections(maxIdleConnections: Int?) = apply { + this.maxIdleConnections = maxIdleConnections + } + + /** + * Alias for [Builder.maxIdleConnections]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxIdleConnections(maxIdleConnections: Int) = + maxIdleConnections(maxIdleConnections as Int?) + + /** + * Alias for calling [Builder.maxIdleConnections] with `maxIdleConnections.orElse(null)`. + */ + fun maxIdleConnections(maxIdleConnections: Optional) = + maxIdleConnections(maxIdleConnections.getOrNull()) + + /** + * The keep-alive duration for idle connections in the underlying OkHttp connection pool. + * + * If this is set, then [maxIdleConnections] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun keepAliveDuration(keepAliveDuration: Duration?) = apply { + this.keepAliveDuration = keepAliveDuration + } + + /** Alias for calling [Builder.keepAliveDuration] with `keepAliveDuration.orElse(null)`. */ + fun keepAliveDuration(keepAliveDuration: Optional) = + keepAliveDuration(keepAliveDuration.getOrNull()) + /** * The socket factory used to secure HTTPS connections. * @@ -346,6 +388,8 @@ class ImageKitOkHttpClient private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .maxIdleConnections(maxIdleConnections) + .keepAliveDuration(keepAliveDuration) .dispatcherExecutorService(dispatcherExecutorService) .sslSocketFactory(sslSocketFactory) .trustManager(trustManager) diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt index ec9c933f..eb060bd7 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt @@ -47,6 +47,8 @@ class ImageKitOkHttpClientAsync private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null + private var maxIdleConnections: Int? = null + private var keepAliveDuration: Duration? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null @@ -75,6 +77,46 @@ class ImageKitOkHttpClientAsync private constructor() { /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + /** + * The maximum number of idle connections kept by the underlying OkHttp connection pool. + * + * If this is set, then [keepAliveDuration] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun maxIdleConnections(maxIdleConnections: Int?) = apply { + this.maxIdleConnections = maxIdleConnections + } + + /** + * Alias for [Builder.maxIdleConnections]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxIdleConnections(maxIdleConnections: Int) = + maxIdleConnections(maxIdleConnections as Int?) + + /** + * Alias for calling [Builder.maxIdleConnections] with `maxIdleConnections.orElse(null)`. + */ + fun maxIdleConnections(maxIdleConnections: Optional) = + maxIdleConnections(maxIdleConnections.getOrNull()) + + /** + * The keep-alive duration for idle connections in the underlying OkHttp connection pool. + * + * If this is set, then [maxIdleConnections] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun keepAliveDuration(keepAliveDuration: Duration?) = apply { + this.keepAliveDuration = keepAliveDuration + } + + /** Alias for calling [Builder.keepAliveDuration] with `keepAliveDuration.orElse(null)`. */ + fun keepAliveDuration(keepAliveDuration: Optional) = + keepAliveDuration(keepAliveDuration.getOrNull()) + /** * The socket factory used to secure HTTPS connections. * @@ -346,6 +388,8 @@ class ImageKitOkHttpClientAsync private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .maxIdleConnections(maxIdleConnections) + .keepAliveDuration(keepAliveDuration) .dispatcherExecutorService(dispatcherExecutorService) .sslSocketFactory(sslSocketFactory) .trustManager(trustManager) diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt index eae703d7..b9b0e81d 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt @@ -16,11 +16,13 @@ import java.time.Duration import java.util.concurrent.CancellationException import java.util.concurrent.CompletableFuture import java.util.concurrent.ExecutorService +import java.util.concurrent.TimeUnit import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager import okhttp3.Call import okhttp3.Callback +import okhttp3.ConnectionPool import okhttp3.Dispatcher import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType @@ -200,6 +202,8 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null + private var maxIdleConnections: Int? = null + private var keepAliveDuration: Duration? = null private var dispatcherExecutorService: ExecutorService? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null @@ -211,6 +215,28 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + /** + * Sets the maximum number of idle connections kept by the underlying [ConnectionPool]. + * + * If this is set, then [keepAliveDuration] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun maxIdleConnections(maxIdleConnections: Int?) = apply { + this.maxIdleConnections = maxIdleConnections + } + + /** + * Sets the keep-alive duration for idle connections in the underlying [ConnectionPool]. + * + * If this is set, then [maxIdleConnections] must also be set. + * + * If unset, then OkHttp's default is used. + */ + fun keepAliveDuration(keepAliveDuration: Duration?) = apply { + this.keepAliveDuration = keepAliveDuration + } + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { this.dispatcherExecutorService = dispatcherExecutorService } @@ -240,6 +266,22 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie .apply { dispatcherExecutorService?.let { dispatcher(Dispatcher(it)) } + val maxIdleConnections = maxIdleConnections + val keepAliveDuration = keepAliveDuration + if (maxIdleConnections != null && keepAliveDuration != null) { + connectionPool( + ConnectionPool( + maxIdleConnections, + keepAliveDuration.toNanos(), + TimeUnit.NANOSECONDS, + ) + ) + } else { + check((maxIdleConnections != null) == (keepAliveDuration != null)) { + "Both or none of `maxIdleConnections` and `keepAliveDuration` must be set, but only one was set" + } + } + val sslSocketFactory = sslSocketFactory val trustManager = trustManager if (sslSocketFactory != null && trustManager != null) { From 3f1d1c67caa0d9824d3c03bef1c8b58a5d58c76e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 19 Feb 2026 16:03:07 +0000 Subject: [PATCH 101/142] chore(internal): remove mock server code --- .../com/imagekit/api/TestServerExtension.kt | 49 ------------------- .../services/async/AssetServiceAsyncTest.kt | 4 -- .../CustomMetadataFieldServiceAsyncTest.kt | 7 --- .../services/async/FileServiceAsyncTest.kt | 10 ---- .../services/async/FolderServiceAsyncTest.kt | 8 --- .../async/SavedExtensionServiceAsyncTest.kt | 8 --- .../services/async/WebhookServiceAsyncTest.kt | 3 -- .../async/accounts/OriginServiceAsyncTest.kt | 8 --- .../accounts/UrlEndpointServiceAsyncTest.kt | 8 --- .../async/accounts/UsageServiceAsyncTest.kt | 4 -- .../async/beta/v2/FileServiceAsyncTest.kt | 4 -- .../cache/InvalidationServiceAsyncTest.kt | 5 -- .../async/files/BulkServiceAsyncTest.kt | 7 --- .../async/files/MetadataServiceAsyncTest.kt | 5 -- .../async/files/VersionServiceAsyncTest.kt | 7 --- .../async/folders/JobServiceAsyncTest.kt | 4 -- .../api/services/blocking/AssetServiceTest.kt | 4 -- .../CustomMetadataFieldServiceTest.kt | 7 --- .../api/services/blocking/FileServiceTest.kt | 10 ---- .../services/blocking/FolderServiceTest.kt | 8 --- .../blocking/SavedExtensionServiceTest.kt | 8 --- .../services/blocking/WebhookServiceTest.kt | 3 -- .../blocking/accounts/OriginServiceTest.kt | 8 --- .../accounts/UrlEndpointServiceTest.kt | 8 --- .../blocking/accounts/UsageServiceTest.kt | 4 -- .../blocking/beta/v2/FileServiceTest.kt | 4 -- .../blocking/cache/InvalidationServiceTest.kt | 5 -- .../blocking/files/BulkServiceTest.kt | 7 --- .../blocking/files/MetadataServiceTest.kt | 5 -- .../blocking/files/VersionServiceTest.kt | 7 --- .../blocking/folders/JobServiceTest.kt | 4 -- scripts/mock | 41 ---------------- scripts/test | 46 ----------------- 33 files changed, 320 deletions(-) delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/TestServerExtension.kt delete mode 100755 scripts/mock diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/TestServerExtension.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/TestServerExtension.kt deleted file mode 100644 index bdd90d75..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/TestServerExtension.kt +++ /dev/null @@ -1,49 +0,0 @@ -package com.imagekit.api - -import java.lang.RuntimeException -import java.net.URL -import org.junit.jupiter.api.extension.BeforeAllCallback -import org.junit.jupiter.api.extension.ConditionEvaluationResult -import org.junit.jupiter.api.extension.ExecutionCondition -import org.junit.jupiter.api.extension.ExtensionContext - -class TestServerExtension : BeforeAllCallback, ExecutionCondition { - - override fun beforeAll(context: ExtensionContext?) { - try { - URL(BASE_URL).openConnection().connect() - } catch (e: Exception) { - throw RuntimeException( - """ - The test suite will not run without a mock server running against your OpenAPI spec. - - You can set the environment variable `SKIP_MOCK_TESTS` to `true` to skip running any tests - that require the mock server. - - To fix run `./scripts/mock` in a separate terminal. - """ - .trimIndent(), - e, - ) - } - } - - override fun evaluateExecutionCondition(context: ExtensionContext): ConditionEvaluationResult { - return if (System.getenv(SKIP_TESTS_ENV).toBoolean()) { - ConditionEvaluationResult.disabled( - "Environment variable $SKIP_TESTS_ENV is set to true" - ) - } else { - ConditionEvaluationResult.enabled( - "Environment variable $SKIP_TESTS_ENV is not set to true" - ) - } - } - - companion object { - - val BASE_URL = System.getenv("TEST_API_BASE_URL") ?: "http://localhost:4010" - - const val SKIP_TESTS_ENV: String = "SKIP_MOCK_TESTS" - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt index 7dbc2604..feeff759 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt @@ -2,14 +2,11 @@ package com.imagekit.api.services.async -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.models.assets.AssetListParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class AssetServiceAsyncTest { @Disabled("Prism tests are disabled") @@ -17,7 +14,6 @@ internal class AssetServiceAsyncTest { fun list() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt index 99e2bc5a..a2492b33 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt @@ -2,16 +2,13 @@ package com.imagekit.api.services.async -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class CustomMetadataFieldServiceAsyncTest { @Disabled("Prism tests are disabled") @@ -19,7 +16,6 @@ internal class CustomMetadataFieldServiceAsyncTest { fun create() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -73,7 +69,6 @@ internal class CustomMetadataFieldServiceAsyncTest { fun update() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -126,7 +121,6 @@ internal class CustomMetadataFieldServiceAsyncTest { fun list() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -149,7 +143,6 @@ internal class CustomMetadataFieldServiceAsyncTest { fun delete() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index 4be1061b..d219647d 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -2,7 +2,6 @@ package com.imagekit.api.services.async -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.core.JsonValue import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 @@ -14,9 +13,7 @@ import com.imagekit.api.models.files.FileUploadParams import com.imagekit.api.models.files.UpdateFileRequest import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class FileServiceAsyncTest { @Disabled("Prism tests are disabled") @@ -24,7 +21,6 @@ internal class FileServiceAsyncTest { fun update() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -123,7 +119,6 @@ internal class FileServiceAsyncTest { fun delete() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -139,7 +134,6 @@ internal class FileServiceAsyncTest { fun copy() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -163,7 +157,6 @@ internal class FileServiceAsyncTest { fun get() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -180,7 +173,6 @@ internal class FileServiceAsyncTest { fun move() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -203,7 +195,6 @@ internal class FileServiceAsyncTest { fun rename() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -227,7 +218,6 @@ internal class FileServiceAsyncTest { fun upload() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt index 3d3bd3de..bdf59245 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt @@ -2,7 +2,6 @@ package com.imagekit.api.services.async -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.models.folders.FolderCopyParams import com.imagekit.api.models.folders.FolderCreateParams @@ -11,9 +10,7 @@ import com.imagekit.api.models.folders.FolderMoveParams import com.imagekit.api.models.folders.FolderRenameParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class FolderServiceAsyncTest { @Disabled("Prism tests are disabled") @@ -21,7 +18,6 @@ internal class FolderServiceAsyncTest { fun create() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -44,7 +40,6 @@ internal class FolderServiceAsyncTest { fun delete() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -64,7 +59,6 @@ internal class FolderServiceAsyncTest { fun copy() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -88,7 +82,6 @@ internal class FolderServiceAsyncTest { fun move() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -111,7 +104,6 @@ internal class FolderServiceAsyncTest { fun rename() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt index 10b8b42c..5258a7fc 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt @@ -2,16 +2,13 @@ package com.imagekit.api.services.async -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.models.ExtensionConfig import com.imagekit.api.models.savedextensions.SavedExtensionCreateParams import com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class SavedExtensionServiceAsyncTest { @Disabled("Prism tests are disabled") @@ -19,7 +16,6 @@ internal class SavedExtensionServiceAsyncTest { fun create() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -56,7 +52,6 @@ internal class SavedExtensionServiceAsyncTest { fun update() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -92,7 +87,6 @@ internal class SavedExtensionServiceAsyncTest { fun list() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -109,7 +103,6 @@ internal class SavedExtensionServiceAsyncTest { fun delete() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -125,7 +118,6 @@ internal class SavedExtensionServiceAsyncTest { fun get() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt index e470bd2c..4cbf570e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt @@ -2,7 +2,6 @@ package com.imagekit.api.services.async -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.core.UnwrapWebhookParams import com.imagekit.api.core.http.Headers @@ -11,9 +10,7 @@ import com.standardwebhooks.Webhook import java.time.Instant import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class WebhookServiceAsyncTest { @Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt index 94691800..ae51158a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt @@ -2,15 +2,12 @@ package com.imagekit.api.services.async.accounts -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.models.accounts.origins.OriginRequest import com.imagekit.api.models.accounts.origins.OriginUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class OriginServiceAsyncTest { @Disabled("Prism tests are disabled") @@ -18,7 +15,6 @@ internal class OriginServiceAsyncTest { fun create() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -46,7 +42,6 @@ internal class OriginServiceAsyncTest { fun update() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -79,7 +74,6 @@ internal class OriginServiceAsyncTest { fun list() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -96,7 +90,6 @@ internal class OriginServiceAsyncTest { fun delete() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -112,7 +105,6 @@ internal class OriginServiceAsyncTest { fun get() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt index ebe07b02..a95f1adc 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt @@ -2,15 +2,12 @@ package com.imagekit.api.services.async.accounts -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class UrlEndpointServiceAsyncTest { @Disabled("Prism tests are disabled") @@ -18,7 +15,6 @@ internal class UrlEndpointServiceAsyncTest { fun create() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -47,7 +43,6 @@ internal class UrlEndpointServiceAsyncTest { fun update() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -81,7 +76,6 @@ internal class UrlEndpointServiceAsyncTest { fun list() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -98,7 +92,6 @@ internal class UrlEndpointServiceAsyncTest { fun delete() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -114,7 +107,6 @@ internal class UrlEndpointServiceAsyncTest { fun get() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt index 5de37787..fd1d98d3 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt @@ -2,15 +2,12 @@ package com.imagekit.api.services.async.accounts -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.models.accounts.usage.UsageGetParams import java.time.LocalDate import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class UsageServiceAsyncTest { @Disabled("Prism tests are disabled") @@ -18,7 +15,6 @@ internal class UsageServiceAsyncTest { fun get() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt index 4b92a496..457491f3 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt @@ -2,16 +2,13 @@ package com.imagekit.api.services.async.beta.v2 -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.core.JsonValue import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 import com.imagekit.api.models.beta.v2.files.FileUploadParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class FileServiceAsyncTest { @Disabled("Prism tests are disabled") @@ -19,7 +16,6 @@ internal class FileServiceAsyncTest { fun upload() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt index 9ad34dff..ad13189c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt @@ -2,14 +2,11 @@ package com.imagekit.api.services.async.cache -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.models.cache.invalidation.InvalidationCreateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class InvalidationServiceAsyncTest { @Disabled("Prism tests are disabled") @@ -17,7 +14,6 @@ internal class InvalidationServiceAsyncTest { fun create() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -39,7 +35,6 @@ internal class InvalidationServiceAsyncTest { fun get() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt index e5d5b31d..ad894be8 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt @@ -2,7 +2,6 @@ package com.imagekit.api.services.async.files -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.models.files.bulk.BulkAddTagsParams import com.imagekit.api.models.files.bulk.BulkDeleteParams @@ -10,9 +9,7 @@ import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams import com.imagekit.api.models.files.bulk.BulkRemoveTagsParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class BulkServiceAsyncTest { @Disabled("Prism tests are disabled") @@ -20,7 +17,6 @@ internal class BulkServiceAsyncTest { fun delete() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -43,7 +39,6 @@ internal class BulkServiceAsyncTest { fun addTags() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -67,7 +62,6 @@ internal class BulkServiceAsyncTest { fun removeAiTags() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -91,7 +85,6 @@ internal class BulkServiceAsyncTest { fun removeTags() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt index 27b2dbd5..8dd3baf9 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt @@ -2,14 +2,11 @@ package com.imagekit.api.services.async.files -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class MetadataServiceAsyncTest { @Disabled("Prism tests are disabled") @@ -17,7 +14,6 @@ internal class MetadataServiceAsyncTest { fun get() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -34,7 +30,6 @@ internal class MetadataServiceAsyncTest { fun getFromUrl() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt index 133c1ea0..18011e82 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt @@ -2,16 +2,13 @@ package com.imagekit.api.services.async.files -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.models.files.versions.VersionDeleteParams import com.imagekit.api.models.files.versions.VersionGetParams import com.imagekit.api.models.files.versions.VersionRestoreParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class VersionServiceAsyncTest { @Disabled("Prism tests are disabled") @@ -19,7 +16,6 @@ internal class VersionServiceAsyncTest { fun list() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -36,7 +32,6 @@ internal class VersionServiceAsyncTest { fun delete() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -56,7 +51,6 @@ internal class VersionServiceAsyncTest { fun get() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -76,7 +70,6 @@ internal class VersionServiceAsyncTest { fun restore() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt index 1297b395..6bda6641 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt @@ -2,13 +2,10 @@ package com.imagekit.api.services.async.folders -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class JobServiceAsyncTest { @Disabled("Prism tests are disabled") @@ -16,7 +13,6 @@ internal class JobServiceAsyncTest { fun get() { val client = ImageKitOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt index 41c8d85e..104a2133 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt @@ -2,14 +2,11 @@ package com.imagekit.api.services.blocking -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.models.assets.AssetListParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class AssetServiceTest { @Disabled("Prism tests are disabled") @@ -17,7 +14,6 @@ internal class AssetServiceTest { fun list() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt index d7cf6630..c39d1960 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt @@ -2,16 +2,13 @@ package com.imagekit.api.services.blocking -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class CustomMetadataFieldServiceTest { @Disabled("Prism tests are disabled") @@ -19,7 +16,6 @@ internal class CustomMetadataFieldServiceTest { fun create() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -72,7 +68,6 @@ internal class CustomMetadataFieldServiceTest { fun update() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -124,7 +119,6 @@ internal class CustomMetadataFieldServiceTest { fun list() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -146,7 +140,6 @@ internal class CustomMetadataFieldServiceTest { fun delete() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index 3929f7ba..c10997eb 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -2,7 +2,6 @@ package com.imagekit.api.services.blocking -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.core.JsonValue import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 @@ -14,9 +13,7 @@ import com.imagekit.api.models.files.FileUploadParams import com.imagekit.api.models.files.UpdateFileRequest import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class FileServiceTest { @Disabled("Prism tests are disabled") @@ -24,7 +21,6 @@ internal class FileServiceTest { fun update() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -122,7 +118,6 @@ internal class FileServiceTest { fun delete() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -136,7 +131,6 @@ internal class FileServiceTest { fun copy() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -159,7 +153,6 @@ internal class FileServiceTest { fun get() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -175,7 +168,6 @@ internal class FileServiceTest { fun move() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -197,7 +189,6 @@ internal class FileServiceTest { fun rename() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -220,7 +211,6 @@ internal class FileServiceTest { fun upload() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt index 0acddac1..416a5e18 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt @@ -2,7 +2,6 @@ package com.imagekit.api.services.blocking -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.models.folders.FolderCopyParams import com.imagekit.api.models.folders.FolderCreateParams @@ -11,9 +10,7 @@ import com.imagekit.api.models.folders.FolderMoveParams import com.imagekit.api.models.folders.FolderRenameParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class FolderServiceTest { @Disabled("Prism tests are disabled") @@ -21,7 +18,6 @@ internal class FolderServiceTest { fun create() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -43,7 +39,6 @@ internal class FolderServiceTest { fun delete() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -62,7 +57,6 @@ internal class FolderServiceTest { fun copy() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -85,7 +79,6 @@ internal class FolderServiceTest { fun move() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -107,7 +100,6 @@ internal class FolderServiceTest { fun rename() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt index b2873c58..22294a7e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt @@ -2,16 +2,13 @@ package com.imagekit.api.services.blocking -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.models.ExtensionConfig import com.imagekit.api.models.savedextensions.SavedExtensionCreateParams import com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class SavedExtensionServiceTest { @Disabled("Prism tests are disabled") @@ -19,7 +16,6 @@ internal class SavedExtensionServiceTest { fun create() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -55,7 +51,6 @@ internal class SavedExtensionServiceTest { fun update() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -90,7 +85,6 @@ internal class SavedExtensionServiceTest { fun list() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -106,7 +100,6 @@ internal class SavedExtensionServiceTest { fun delete() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -120,7 +113,6 @@ internal class SavedExtensionServiceTest { fun get() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt index 033df2d9..6b85e385 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt @@ -2,7 +2,6 @@ package com.imagekit.api.services.blocking -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.core.UnwrapWebhookParams import com.imagekit.api.core.http.Headers @@ -11,9 +10,7 @@ import com.standardwebhooks.Webhook import java.time.Instant import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class WebhookServiceTest { @Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt index e66eb4ba..5eafbaa4 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt @@ -2,15 +2,12 @@ package com.imagekit.api.services.blocking.accounts -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.models.accounts.origins.OriginRequest import com.imagekit.api.models.accounts.origins.OriginUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class OriginServiceTest { @Disabled("Prism tests are disabled") @@ -18,7 +15,6 @@ internal class OriginServiceTest { fun create() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -45,7 +41,6 @@ internal class OriginServiceTest { fun update() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -77,7 +72,6 @@ internal class OriginServiceTest { fun list() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -93,7 +87,6 @@ internal class OriginServiceTest { fun delete() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -107,7 +100,6 @@ internal class OriginServiceTest { fun get() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt index e9773bf0..a7894617 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt @@ -2,15 +2,12 @@ package com.imagekit.api.services.blocking.accounts -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class UrlEndpointServiceTest { @Disabled("Prism tests are disabled") @@ -18,7 +15,6 @@ internal class UrlEndpointServiceTest { fun create() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -46,7 +42,6 @@ internal class UrlEndpointServiceTest { fun update() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -79,7 +74,6 @@ internal class UrlEndpointServiceTest { fun list() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -95,7 +89,6 @@ internal class UrlEndpointServiceTest { fun delete() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -109,7 +102,6 @@ internal class UrlEndpointServiceTest { fun get() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt index 3899e0d7..5885a860 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt @@ -2,15 +2,12 @@ package com.imagekit.api.services.blocking.accounts -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.models.accounts.usage.UsageGetParams import java.time.LocalDate import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class UsageServiceTest { @Disabled("Prism tests are disabled") @@ -18,7 +15,6 @@ internal class UsageServiceTest { fun get() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt index 3d54e0a0..1a3b11ef 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt @@ -2,16 +2,13 @@ package com.imagekit.api.services.blocking.beta.v2 -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.core.JsonValue import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 import com.imagekit.api.models.beta.v2.files.FileUploadParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class FileServiceTest { @Disabled("Prism tests are disabled") @@ -19,7 +16,6 @@ internal class FileServiceTest { fun upload() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt index b1148d83..ba90d2d6 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt @@ -2,14 +2,11 @@ package com.imagekit.api.services.blocking.cache -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.models.cache.invalidation.InvalidationCreateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class InvalidationServiceTest { @Disabled("Prism tests are disabled") @@ -17,7 +14,6 @@ internal class InvalidationServiceTest { fun create() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -38,7 +34,6 @@ internal class InvalidationServiceTest { fun get() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt index 90b69e4a..80fe5d43 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt @@ -2,7 +2,6 @@ package com.imagekit.api.services.blocking.files -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.models.files.bulk.BulkAddTagsParams import com.imagekit.api.models.files.bulk.BulkDeleteParams @@ -10,9 +9,7 @@ import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams import com.imagekit.api.models.files.bulk.BulkRemoveTagsParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class BulkServiceTest { @Disabled("Prism tests are disabled") @@ -20,7 +17,6 @@ internal class BulkServiceTest { fun delete() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -42,7 +38,6 @@ internal class BulkServiceTest { fun addTags() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -65,7 +60,6 @@ internal class BulkServiceTest { fun removeAiTags() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -88,7 +82,6 @@ internal class BulkServiceTest { fun removeTags() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt index d0ca7732..f1eae03e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt @@ -2,14 +2,11 @@ package com.imagekit.api.services.blocking.files -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class MetadataServiceTest { @Disabled("Prism tests are disabled") @@ -17,7 +14,6 @@ internal class MetadataServiceTest { fun get() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -33,7 +29,6 @@ internal class MetadataServiceTest { fun getFromUrl() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt index fce39206..1cb7b60f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt @@ -2,16 +2,13 @@ package com.imagekit.api.services.blocking.files -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.models.files.versions.VersionDeleteParams import com.imagekit.api.models.files.versions.VersionGetParams import com.imagekit.api.models.files.versions.VersionRestoreParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class VersionServiceTest { @Disabled("Prism tests are disabled") @@ -19,7 +16,6 @@ internal class VersionServiceTest { fun list() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -35,7 +31,6 @@ internal class VersionServiceTest { fun delete() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -54,7 +49,6 @@ internal class VersionServiceTest { fun get() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() @@ -73,7 +67,6 @@ internal class VersionServiceTest { fun restore() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt index 4c515532..cafeca96 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt @@ -2,13 +2,10 @@ package com.imagekit.api.services.blocking.folders -import com.imagekit.api.TestServerExtension import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) internal class JobServiceTest { @Disabled("Prism tests are disabled") @@ -16,7 +13,6 @@ internal class JobServiceTest { fun get() { val client = ImageKitOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) .privateKey("My Private Key") .password("My Password") .build() diff --git a/scripts/mock b/scripts/mock deleted file mode 100755 index 0b28f6ea..00000000 --- a/scripts/mock +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -set -e - -cd "$(dirname "$0")/.." - -if [[ -n "$1" && "$1" != '--'* ]]; then - URL="$1" - shift -else - URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)" -fi - -# Check if the URL is empty -if [ -z "$URL" ]; then - echo "Error: No OpenAPI spec path/url provided or found in .stats.yml" - exit 1 -fi - -echo "==> Starting mock server with URL ${URL}" - -# Run prism mock on the given spec -if [ "$1" == "--daemon" ]; then - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & - - # Wait for server to come online - echo -n "Waiting for server" - while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do - echo -n "." - sleep 0.1 - done - - if grep -q "✖ fatal" ".prism.log"; then - cat .prism.log - exit 1 - fi - - echo -else - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" -fi diff --git a/scripts/test b/scripts/test index 047bc1db..904aea60 100755 --- a/scripts/test +++ b/scripts/test @@ -4,53 +4,7 @@ set -e cd "$(dirname "$0")/.." -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[0;33m' -NC='\033[0m' # No Color -function prism_is_running() { - curl --silent "http://localhost:4010" >/dev/null 2>&1 -} - -kill_server_on_port() { - pids=$(lsof -t -i tcp:"$1" || echo "") - if [ "$pids" != "" ]; then - kill "$pids" - echo "Stopped $pids." - fi -} - -function is_overriding_api_base_url() { - [ -n "$TEST_API_BASE_URL" ] -} - -if ! is_overriding_api_base_url && ! prism_is_running ; then - # When we exit this script, make sure to kill the background mock server process - trap 'kill_server_on_port 4010' EXIT - - # Start the dev server - ./scripts/mock --daemon -fi - -if is_overriding_api_base_url ; then - echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" - echo -elif ! prism_is_running ; then - echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" - echo -e "running against your OpenAPI spec." - echo - echo -e "To run the server, pass in the path or url of your OpenAPI" - echo -e "spec to the prism command:" - echo - echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" - echo - - exit 1 -else - echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" - echo -fi echo "==> Running tests" ./gradlew test "$@" From 6fb3f0cfd3a1f8bb17c9c632c56db7f5a7240948 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 19 Feb 2026 16:33:29 +0000 Subject: [PATCH 102/142] chore: update mock server docs --- .../com/imagekit/api/services/ServiceParamsTest.kt | 2 +- .../api/services/async/AssetServiceAsyncTest.kt | 2 +- .../async/CustomMetadataFieldServiceAsyncTest.kt | 8 ++++---- .../api/services/async/FileServiceAsyncTest.kt | 14 +++++++------- .../api/services/async/FolderServiceAsyncTest.kt | 10 +++++----- .../async/SavedExtensionServiceAsyncTest.kt | 10 +++++----- .../async/accounts/OriginServiceAsyncTest.kt | 10 +++++----- .../async/accounts/UrlEndpointServiceAsyncTest.kt | 10 +++++----- .../async/accounts/UsageServiceAsyncTest.kt | 2 +- .../services/async/beta/v2/FileServiceAsyncTest.kt | 2 +- .../async/cache/InvalidationServiceAsyncTest.kt | 4 ++-- .../services/async/files/BulkServiceAsyncTest.kt | 8 ++++---- .../async/files/MetadataServiceAsyncTest.kt | 4 ++-- .../async/files/VersionServiceAsyncTest.kt | 8 ++++---- .../services/async/folders/JobServiceAsyncTest.kt | 2 +- .../api/services/blocking/AssetServiceTest.kt | 2 +- .../blocking/CustomMetadataFieldServiceTest.kt | 8 ++++---- .../api/services/blocking/FileServiceTest.kt | 14 +++++++------- .../api/services/blocking/FolderServiceTest.kt | 10 +++++----- .../services/blocking/SavedExtensionServiceTest.kt | 10 +++++----- .../blocking/accounts/OriginServiceTest.kt | 10 +++++----- .../blocking/accounts/UrlEndpointServiceTest.kt | 10 +++++----- .../services/blocking/accounts/UsageServiceTest.kt | 2 +- .../services/blocking/beta/v2/FileServiceTest.kt | 2 +- .../blocking/cache/InvalidationServiceTest.kt | 4 ++-- .../api/services/blocking/files/BulkServiceTest.kt | 8 ++++---- .../services/blocking/files/MetadataServiceTest.kt | 4 ++-- .../services/blocking/files/VersionServiceTest.kt | 8 ++++---- .../services/blocking/folders/JobServiceTest.kt | 2 +- 29 files changed, 95 insertions(+), 95 deletions(-) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt index f5b2e1b0..211ca9ca 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt @@ -38,7 +38,7 @@ internal class ServiceParamsTest { .build() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun upload() { val fileService = client.files() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt index feeff759..e7a3e05a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test internal class AssetServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun list() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt index a2492b33..05126f0d 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test internal class CustomMetadataFieldServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun create() { val client = @@ -64,7 +64,7 @@ internal class CustomMetadataFieldServiceAsyncTest { customMetadataField.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun update() { val client = @@ -116,7 +116,7 @@ internal class CustomMetadataFieldServiceAsyncTest { customMetadataField.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun list() { val client = @@ -138,7 +138,7 @@ internal class CustomMetadataFieldServiceAsyncTest { customMetadataFields.forEach { it.validate() } } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun delete() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index d219647d..622313be 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -16,7 +16,7 @@ import org.junit.jupiter.api.Test internal class FileServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun update() { val client = @@ -114,7 +114,7 @@ internal class FileServiceAsyncTest { file.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun delete() { val client = @@ -129,7 +129,7 @@ internal class FileServiceAsyncTest { val response = future.get() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun copy() { val client = @@ -152,7 +152,7 @@ internal class FileServiceAsyncTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun get() { val client = @@ -168,7 +168,7 @@ internal class FileServiceAsyncTest { file.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun move() { val client = @@ -190,7 +190,7 @@ internal class FileServiceAsyncTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun rename() { val client = @@ -213,7 +213,7 @@ internal class FileServiceAsyncTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun upload() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt index bdf59245..5d9e7f7b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test internal class FolderServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun create() { val client = @@ -35,7 +35,7 @@ internal class FolderServiceAsyncTest { folder.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun delete() { val client = @@ -54,7 +54,7 @@ internal class FolderServiceAsyncTest { folder.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun copy() { val client = @@ -77,7 +77,7 @@ internal class FolderServiceAsyncTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun move() { val client = @@ -99,7 +99,7 @@ internal class FolderServiceAsyncTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun rename() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt index 5258a7fc..60099607 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test internal class SavedExtensionServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun create() { val client = @@ -47,7 +47,7 @@ internal class SavedExtensionServiceAsyncTest { savedExtension.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun update() { val client = @@ -82,7 +82,7 @@ internal class SavedExtensionServiceAsyncTest { savedExtension.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun list() { val client = @@ -98,7 +98,7 @@ internal class SavedExtensionServiceAsyncTest { savedExtensions.forEach { it.validate() } } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun delete() { val client = @@ -113,7 +113,7 @@ internal class SavedExtensionServiceAsyncTest { val response = future.get() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun get() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt index ae51158a..85eaf6b8 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test internal class OriginServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun create() { val client = @@ -37,7 +37,7 @@ internal class OriginServiceAsyncTest { originResponse.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun update() { val client = @@ -69,7 +69,7 @@ internal class OriginServiceAsyncTest { originResponse.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun list() { val client = @@ -85,7 +85,7 @@ internal class OriginServiceAsyncTest { originResponses.forEach { it.validate() } } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun delete() { val client = @@ -100,7 +100,7 @@ internal class OriginServiceAsyncTest { val response = future.get() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun get() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt index a95f1adc..b5a0bbb1 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test internal class UrlEndpointServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun create() { val client = @@ -38,7 +38,7 @@ internal class UrlEndpointServiceAsyncTest { urlEndpointResponse.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun update() { val client = @@ -71,7 +71,7 @@ internal class UrlEndpointServiceAsyncTest { urlEndpointResponse.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun list() { val client = @@ -87,7 +87,7 @@ internal class UrlEndpointServiceAsyncTest { urlEndpointResponses.forEach { it.validate() } } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun delete() { val client = @@ -102,7 +102,7 @@ internal class UrlEndpointServiceAsyncTest { val response = future.get() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun get() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt index fd1d98d3..1ff7697b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test internal class UsageServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun get() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt index 457491f3..503767ac 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test internal class FileServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun upload() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt index ad13189c..373cbd39 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test internal class InvalidationServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun create() { val client = @@ -30,7 +30,7 @@ internal class InvalidationServiceAsyncTest { invalidation.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun get() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt index ad894be8..f4726319 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt @@ -12,7 +12,7 @@ import org.junit.jupiter.api.Test internal class BulkServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun delete() { val client = @@ -34,7 +34,7 @@ internal class BulkServiceAsyncTest { bulk.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun addTags() { val client = @@ -57,7 +57,7 @@ internal class BulkServiceAsyncTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun removeAiTags() { val client = @@ -80,7 +80,7 @@ internal class BulkServiceAsyncTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun removeTags() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt index 8dd3baf9..a60fc3c3 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test internal class MetadataServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun get() { val client = @@ -25,7 +25,7 @@ internal class MetadataServiceAsyncTest { metadata.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun getFromUrl() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt index 18011e82..4774b045 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test internal class VersionServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun list() { val client = @@ -27,7 +27,7 @@ internal class VersionServiceAsyncTest { files.forEach { it.validate() } } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun delete() { val client = @@ -46,7 +46,7 @@ internal class VersionServiceAsyncTest { version.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun get() { val client = @@ -65,7 +65,7 @@ internal class VersionServiceAsyncTest { file.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun restore() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt index 6bda6641..0013515c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test internal class JobServiceAsyncTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun get() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt index 104a2133..8e46580b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test internal class AssetServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun list() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt index c39d1960..a88b8c8b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test internal class CustomMetadataFieldServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun create() { val client = @@ -63,7 +63,7 @@ internal class CustomMetadataFieldServiceTest { customMetadataField.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun update() { val client = @@ -114,7 +114,7 @@ internal class CustomMetadataFieldServiceTest { customMetadataField.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun list() { val client = @@ -135,7 +135,7 @@ internal class CustomMetadataFieldServiceTest { customMetadataFields.forEach { it.validate() } } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun delete() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index c10997eb..7fd19909 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -16,7 +16,7 @@ import org.junit.jupiter.api.Test internal class FileServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun update() { val client = @@ -113,7 +113,7 @@ internal class FileServiceTest { file.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun delete() { val client = @@ -126,7 +126,7 @@ internal class FileServiceTest { fileService.delete("fileId") } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun copy() { val client = @@ -148,7 +148,7 @@ internal class FileServiceTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun get() { val client = @@ -163,7 +163,7 @@ internal class FileServiceTest { file.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun move() { val client = @@ -184,7 +184,7 @@ internal class FileServiceTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun rename() { val client = @@ -206,7 +206,7 @@ internal class FileServiceTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun upload() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt index 416a5e18..6b2960a6 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test internal class FolderServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun create() { val client = @@ -34,7 +34,7 @@ internal class FolderServiceTest { folder.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun delete() { val client = @@ -52,7 +52,7 @@ internal class FolderServiceTest { folder.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun copy() { val client = @@ -74,7 +74,7 @@ internal class FolderServiceTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun move() { val client = @@ -95,7 +95,7 @@ internal class FolderServiceTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun rename() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt index 22294a7e..fdc452d2 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test internal class SavedExtensionServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun create() { val client = @@ -46,7 +46,7 @@ internal class SavedExtensionServiceTest { savedExtension.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun update() { val client = @@ -80,7 +80,7 @@ internal class SavedExtensionServiceTest { savedExtension.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun list() { val client = @@ -95,7 +95,7 @@ internal class SavedExtensionServiceTest { savedExtensions.forEach { it.validate() } } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun delete() { val client = @@ -108,7 +108,7 @@ internal class SavedExtensionServiceTest { savedExtensionService.delete("id") } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun get() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt index 5eafbaa4..9ce07bc5 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test internal class OriginServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun create() { val client = @@ -36,7 +36,7 @@ internal class OriginServiceTest { originResponse.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun update() { val client = @@ -67,7 +67,7 @@ internal class OriginServiceTest { originResponse.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun list() { val client = @@ -82,7 +82,7 @@ internal class OriginServiceTest { originResponses.forEach { it.validate() } } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun delete() { val client = @@ -95,7 +95,7 @@ internal class OriginServiceTest { originService.delete("id") } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun get() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt index a7894617..b0970249 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test internal class UrlEndpointServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun create() { val client = @@ -37,7 +37,7 @@ internal class UrlEndpointServiceTest { urlEndpointResponse.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun update() { val client = @@ -69,7 +69,7 @@ internal class UrlEndpointServiceTest { urlEndpointResponse.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun list() { val client = @@ -84,7 +84,7 @@ internal class UrlEndpointServiceTest { urlEndpointResponses.forEach { it.validate() } } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun delete() { val client = @@ -97,7 +97,7 @@ internal class UrlEndpointServiceTest { urlEndpointService.delete("id") } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun get() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt index 5885a860..74cf58ed 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test internal class UsageServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun get() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt index 1a3b11ef..10f4c49f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test internal class FileServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun upload() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt index ba90d2d6..9d0a4b88 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test internal class InvalidationServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun create() { val client = @@ -29,7 +29,7 @@ internal class InvalidationServiceTest { invalidation.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun get() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt index 80fe5d43..4c5321e0 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt @@ -12,7 +12,7 @@ import org.junit.jupiter.api.Test internal class BulkServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun delete() { val client = @@ -33,7 +33,7 @@ internal class BulkServiceTest { bulk.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun addTags() { val client = @@ -55,7 +55,7 @@ internal class BulkServiceTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun removeAiTags() { val client = @@ -77,7 +77,7 @@ internal class BulkServiceTest { response.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun removeTags() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt index f1eae03e..3c5e115f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test internal class MetadataServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun get() { val client = @@ -24,7 +24,7 @@ internal class MetadataServiceTest { metadata.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun getFromUrl() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt index 1cb7b60f..383718f3 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test internal class VersionServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun list() { val client = @@ -26,7 +26,7 @@ internal class VersionServiceTest { files.forEach { it.validate() } } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun delete() { val client = @@ -44,7 +44,7 @@ internal class VersionServiceTest { version.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun get() { val client = @@ -62,7 +62,7 @@ internal class VersionServiceTest { file.validate() } - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun restore() { val client = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt index cafeca96..fe1ac070 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test internal class JobServiceTest { - @Disabled("Prism tests are disabled") + @Disabled("Mock server tests are disabled") @Test fun get() { val client = From 34b930ad491dafb8e94442ef07864d47d1f54137 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Feb 2026 17:42:28 +0000 Subject: [PATCH 103/142] chore: make `Properties` more resilient to `null` --- .../src/main/kotlin/com/imagekit/api/core/Properties.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Properties.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Properties.kt index d6ec5697..f2b87adf 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Properties.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Properties.kt @@ -34,9 +34,9 @@ fun getOsName(): String { } } -fun getOsVersion(): String = System.getProperty("os.version", "unknown") +fun getOsVersion(): String = System.getProperty("os.version", "unknown") ?: "unknown" fun getPackageVersion(): String = - ImageKitClient::class.java.`package`.implementationVersion ?: "unknown" + ImageKitClient::class.java.`package`?.implementationVersion ?: "unknown" -fun getJavaVersion(): String = System.getProperty("java.version", "unknown") +fun getJavaVersion(): String = System.getProperty("java.version", "unknown") ?: "unknown" From 48e02f702dea5f4c0553740e48bd670c63477f51 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Feb 2026 17:57:04 +0000 Subject: [PATCH 104/142] chore: drop apache dependency --- image-kit-java-core/build.gradle.kts | 2 - .../api/core/http/HttpRequestBodies.kt | 295 +++++-- .../api/core/http/HttpRequestBodiesTest.kt | 729 ++++++++++++++++++ 3 files changed, 946 insertions(+), 80 deletions(-) create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/HttpRequestBodiesTest.kt diff --git a/image-kit-java-core/build.gradle.kts b/image-kit-java-core/build.gradle.kts index eb5fb491..ca321408 100644 --- a/image-kit-java-core/build.gradle.kts +++ b/image-kit-java-core/build.gradle.kts @@ -28,8 +28,6 @@ dependencies { implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2") implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2") implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.2") - implementation("org.apache.httpcomponents.core5:httpcore5:5.2.4") - implementation("org.apache.httpcomponents.client5:httpclient5:5.3.1") testImplementation(kotlin("test")) testImplementation(project(":image-kit-java-client-okhttp")) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequestBodies.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequestBodies.kt index 82008d23..e8ee34a2 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequestBodies.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequestBodies.kt @@ -8,13 +8,13 @@ import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.databind.node.JsonNodeType import com.imagekit.api.core.MultipartField +import com.imagekit.api.core.toImmutable import com.imagekit.api.errors.ImageKitInvalidDataException +import java.io.ByteArrayInputStream import java.io.InputStream import java.io.OutputStream +import java.util.UUID import kotlin.jvm.optionals.getOrNull -import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder -import org.apache.hc.core5.http.ContentType -import org.apache.hc.core5.http.HttpEntity @JvmSynthetic internal inline fun json(jsonMapper: JsonMapper, value: T): HttpRequestBody = @@ -37,92 +37,231 @@ internal fun multipartFormData( jsonMapper: JsonMapper, fields: Map>, ): HttpRequestBody = - object : HttpRequestBody { - private val entity: HttpEntity by lazy { - MultipartEntityBuilder.create() - .apply { - fields.forEach { (name, field) -> - val knownValue = field.value.asKnown().getOrNull() - val parts = - if (knownValue is InputStream) { - // Read directly from the `InputStream` instead of reading it all - // into memory due to the `jsonMapper` serialization below. - sequenceOf(name to knownValue) - } else { - val node = jsonMapper.valueToTree(field.value) - serializePart(name, node) + MultipartBody.Builder() + .apply { + fields.forEach { (name, field) -> + val knownValue = field.value.asKnown().getOrNull() + val parts = + if (knownValue is InputStream) { + // Read directly from the `InputStream` instead of reading it all + // into memory due to the `jsonMapper` serialization below. + sequenceOf(name to knownValue) + } else { + val node = jsonMapper.valueToTree(field.value) + serializePart(name, node) + } + + parts.forEach { (name, bytes) -> + val partBody = + if (bytes is ByteArrayInputStream) { + val byteArray = bytes.readBytes() + + object : HttpRequestBody { + + override fun writeTo(outputStream: OutputStream) { + outputStream.write(byteArray) + } + + override fun contentType(): String = field.contentType + + override fun contentLength(): Long = byteArray.size.toLong() + + override fun repeatable(): Boolean = true + + override fun close() {} } + } else { + object : HttpRequestBody { + + override fun writeTo(outputStream: OutputStream) { + bytes.copyTo(outputStream) + } + + override fun contentType(): String = field.contentType + + override fun contentLength(): Long = -1L - parts.forEach { (name, bytes) -> - addBinaryBody( - name, - bytes, - ContentType.parseLenient(field.contentType), - field.filename().getOrNull(), - ) + override fun repeatable(): Boolean = false + + override fun close() = bytes.close() + } } - } + + addPart( + MultipartBody.Part.create( + name, + field.filename().getOrNull(), + field.contentType, + partBody, + ) + ) } - .build() + } } + .build() - private fun serializePart( - name: String, - node: JsonNode, - ): Sequence> = - when (node.nodeType) { - JsonNodeType.MISSING, - JsonNodeType.NULL -> emptySequence() - JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue().inputStream()) - JsonNodeType.STRING -> sequenceOf(name to node.textValue().inputStream()) - JsonNodeType.BOOLEAN -> - sequenceOf(name to node.booleanValue().toString().inputStream()) - JsonNodeType.NUMBER -> - sequenceOf(name to node.numberValue().toString().inputStream()) - JsonNodeType.ARRAY -> - sequenceOf( - name to - node - .elements() - .asSequence() - .mapNotNull { element -> - when (element.nodeType) { - JsonNodeType.MISSING, - JsonNodeType.NULL -> null - JsonNodeType.STRING -> node.textValue() - JsonNodeType.BOOLEAN -> node.booleanValue().toString() - JsonNodeType.NUMBER -> node.numberValue().toString() - null, - JsonNodeType.BINARY, - JsonNodeType.ARRAY, - JsonNodeType.OBJECT, - JsonNodeType.POJO -> - throw ImageKitInvalidDataException( - "Unexpected JsonNode type in array: ${node.nodeType}" - ) - } - } - .joinToString(",") - .inputStream() - ) - JsonNodeType.OBJECT -> - node.fields().asSequence().flatMap { (key, value) -> - serializePart("$name[$key]", value) - } - JsonNodeType.POJO, - null -> - throw ImageKitInvalidDataException("Unexpected JsonNode type: ${node.nodeType}") +private fun serializePart(name: String, node: JsonNode): Sequence> = + when (node.nodeType) { + JsonNodeType.MISSING, + JsonNodeType.NULL -> emptySequence() + JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue().inputStream()) + JsonNodeType.STRING -> sequenceOf(name to node.textValue().byteInputStream()) + JsonNodeType.BOOLEAN -> sequenceOf(name to node.booleanValue().toString().byteInputStream()) + JsonNodeType.NUMBER -> sequenceOf(name to node.numberValue().toString().byteInputStream()) + JsonNodeType.ARRAY -> + sequenceOf( + name to + node + .elements() + .asSequence() + .mapNotNull { element -> + when (element.nodeType) { + JsonNodeType.MISSING, + JsonNodeType.NULL -> null + JsonNodeType.STRING -> element.textValue() + JsonNodeType.BOOLEAN -> element.booleanValue().toString() + JsonNodeType.NUMBER -> element.numberValue().toString() + null, + JsonNodeType.BINARY, + JsonNodeType.ARRAY, + JsonNodeType.OBJECT, + JsonNodeType.POJO -> + throw ImageKitInvalidDataException( + "Unexpected JsonNode type in array: ${element.nodeType}" + ) + } + } + .joinToString(",") + .byteInputStream() + ) + JsonNodeType.OBJECT -> + node.fields().asSequence().flatMap { (key, value) -> + serializePart("$name[$key]", value) + } + JsonNodeType.POJO, + null -> throw ImageKitInvalidDataException("Unexpected JsonNode type: ${node.nodeType}") + } + +private class MultipartBody +private constructor(private val boundary: String, private val parts: List) : HttpRequestBody { + private val boundaryBytes: ByteArray = boundary.toByteArray() + private val contentType = "multipart/form-data; boundary=$boundary" + + // This must remain in sync with `contentLength`. + override fun writeTo(outputStream: OutputStream) { + parts.forEach { part -> + outputStream.write(DASHDASH) + outputStream.write(boundaryBytes) + outputStream.write(CRLF) + + outputStream.write(CONTENT_DISPOSITION) + outputStream.write(part.contentDisposition.toByteArray()) + outputStream.write(CRLF) + + outputStream.write(CONTENT_TYPE) + outputStream.write(part.contentType.toByteArray()) + outputStream.write(CRLF) + + outputStream.write(CRLF) + part.body.writeTo(outputStream) + outputStream.write(CRLF) + } + + outputStream.write(DASHDASH) + outputStream.write(boundaryBytes) + outputStream.write(DASHDASH) + outputStream.write(CRLF) + } + + override fun contentType(): String = contentType + + // This must remain in sync with `writeTo`. + override fun contentLength(): Long { + var byteCount = 0L + + parts.forEach { part -> + val contentLength = part.body.contentLength() + if (contentLength == -1L) { + return -1L } - private fun String.inputStream(): InputStream = toByteArray().inputStream() + byteCount += + DASHDASH.size + + boundaryBytes.size + + CRLF.size + + CONTENT_DISPOSITION.size + + part.contentDisposition.toByteArray().size + + CRLF.size + + CONTENT_TYPE.size + + part.contentType.toByteArray().size + + CRLF.size + + CRLF.size + + contentLength + + CRLF.size + } - override fun writeTo(outputStream: OutputStream) = entity.writeTo(outputStream) + byteCount += DASHDASH.size + boundaryBytes.size + DASHDASH.size + CRLF.size + return byteCount + } - override fun contentType(): String = entity.contentType + override fun repeatable(): Boolean = parts.all { it.body.repeatable() } - override fun contentLength(): Long = entity.contentLength + override fun close() { + parts.forEach { it.body.close() } + } - override fun repeatable(): Boolean = entity.isRepeatable + class Builder { + private val boundary = UUID.randomUUID().toString() + private val parts: MutableList = mutableListOf() - override fun close() = entity.close() + fun addPart(part: Part) = apply { parts.add(part) } + + fun build() = MultipartBody(boundary, parts.toImmutable()) + } + + class Part + private constructor( + val contentDisposition: String, + val contentType: String, + val body: HttpRequestBody, + ) { + companion object { + fun create( + name: String, + filename: String?, + contentType: String, + body: HttpRequestBody, + ): Part { + val disposition = buildString { + append("form-data; name=") + appendQuotedString(name) + if (filename != null) { + append("; filename=") + appendQuotedString(filename) + } + } + return Part(disposition, contentType, body) + } + } + } + + companion object { + private val CRLF = byteArrayOf('\r'.code.toByte(), '\n'.code.toByte()) + private val DASHDASH = byteArrayOf('-'.code.toByte(), '-'.code.toByte()) + private val CONTENT_DISPOSITION = "Content-Disposition: ".toByteArray() + private val CONTENT_TYPE = "Content-Type: ".toByteArray() + + private fun StringBuilder.appendQuotedString(key: String) { + append('"') + for (ch in key) { + when (ch) { + '\n' -> append("%0A") + '\r' -> append("%0D") + '"' -> append("%22") + else -> append(ch) + } + } + append('"') + } } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/HttpRequestBodiesTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/HttpRequestBodiesTest.kt new file mode 100644 index 00000000..40f188f6 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/HttpRequestBodiesTest.kt @@ -0,0 +1,729 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.core.http + +import com.imagekit.api.core.MultipartField +import com.imagekit.api.core.jsonMapper +import java.io.ByteArrayOutputStream +import java.io.InputStream +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class HttpRequestBodiesTest { + + @Test + fun multipartFormData_serializesFieldWithFilename() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "file" to + MultipartField.builder() + .value("hello") + .filename("hello.txt") + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(output.size().toLong()).isEqualTo(body.contentLength()) + val boundary = body.contentType()!!.substringAfter("multipart/form-data; boundary=") + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="file"; filename="hello.txt" + |Content-Type: text/plain + | + |hello + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesFieldWithoutFilename() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "field" to + MultipartField.builder() + .value("value") + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(output.size().toLong()).isEqualTo(body.contentLength()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="field" + |Content-Type: text/plain + | + |value + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesInputStream() { + // Use `.buffered()` to get a non-ByteArrayInputStream, which hits the non-repeatable code + // path. + val inputStream = "stream content".byteInputStream().buffered() + val body = + multipartFormData( + jsonMapper(), + mapOf( + "data" to + MultipartField.builder() + .value(inputStream) + .contentType("application/octet-stream") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isFalse() + assertThat(body.contentLength()).isEqualTo(-1L) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="data" + |Content-Type: application/octet-stream + | + |stream content + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesByteArray() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "binary" to + MultipartField.builder() + .value("abc".toByteArray()) + .contentType("application/octet-stream") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="binary" + |Content-Type: application/octet-stream + | + |abc + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesBooleanValue() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "flag" to + MultipartField.builder() + .value(true) + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="flag" + |Content-Type: text/plain + | + |true + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesNumberValue() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "count" to + MultipartField.builder().value(42).contentType("text/plain").build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="count" + |Content-Type: text/plain + | + |42 + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesNullValueAsNoParts() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "present" to + MultipartField.builder() + .value("yes") + .contentType("text/plain") + .build(), + "absent" to + MultipartField.builder() + .value(null as String?) + .contentType("text/plain") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="present" + |Content-Type: text/plain + | + |yes + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesArray() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "items" to + MultipartField.builder>() + .value(listOf("alpha", "beta", "gamma")) + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="items" + |Content-Type: text/plain + | + |alpha,beta,gamma + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesObjectAsNestedParts() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "meta" to + MultipartField.builder>() + .value(mapOf("key1" to "val1", "key2" to "val2")) + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="meta[key1]" + |Content-Type: text/plain + | + |val1 + |--$boundary + |Content-Disposition: form-data; name="meta[key2]" + |Content-Type: text/plain + | + |val2 + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesMultipleFields() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "name" to + MultipartField.builder() + .value("Alice") + .contentType("text/plain") + .build(), + "age" to + MultipartField.builder().value(30).contentType("text/plain").build(), + "file" to + MultipartField.builder() + .value("file contents") + .filename("doc.txt") + .contentType("text/plain") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="name" + |Content-Type: text/plain + | + |Alice + |--$boundary + |Content-Disposition: form-data; name="age" + |Content-Type: text/plain + | + |30 + |--$boundary + |Content-Disposition: form-data; name="file"; filename="doc.txt" + |Content-Type: text/plain + | + |file contents + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_quotesSpecialCharactersInNameAndFilename() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "field\nname" to + MultipartField.builder() + .value("value") + .filename("file\r\"name.txt") + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="field%0Aname"; filename="file%0D%22name.txt" + |Content-Type: text/plain + | + |value + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_writeIsRepeatable() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "field" to + MultipartField.builder() + .value("repeatable") + .contentType("text/plain") + .build() + ), + ) + + val output1 = ByteArrayOutputStream() + body.writeTo(output1) + val output2 = ByteArrayOutputStream() + body.writeTo(output2) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output1.size().toLong()) + val boundary = boundary(body) + val expected = + """ + |--$boundary + |Content-Disposition: form-data; name="field" + |Content-Type: text/plain + | + |repeatable + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + assertThat(output1.toString("UTF-8")).isEqualTo(expected) + assertThat(output2.toString("UTF-8")).isEqualTo(expected) + } + + @Test + fun multipartFormData_serializesByteArrayInputStream() { + // ByteArrayInputStream is specifically handled as repeatable with known content length. + val inputStream = "byte array stream".byteInputStream() + val body = + multipartFormData( + jsonMapper(), + mapOf( + "data" to + MultipartField.builder() + .value(inputStream) + .contentType("application/octet-stream") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="data" + |Content-Type: application/octet-stream + | + |byte array stream + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesInputStreamWithFilename() { + // Use `.buffered()` to get a non-ByteArrayInputStream, which hits the non-repeatable code + // path. + val inputStream = "file data".byteInputStream().buffered() + val body = + multipartFormData( + jsonMapper(), + mapOf( + "upload" to + MultipartField.builder() + .value(inputStream) + .filename("upload.bin") + .contentType("application/octet-stream") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isFalse() + assertThat(body.contentLength()).isEqualTo(-1L) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="upload"; filename="upload.bin" + |Content-Type: application/octet-stream + | + |file data + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesNestedArrayInObject() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "data" to + MultipartField.builder>>() + .value(mapOf("tags" to listOf("a", "b"))) + .contentType("text/plain") + .build() + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="data[tags]" + |Content-Type: text/plain + | + |a,b + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_contentLengthIsUnknownWhenInputStreamPresent() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "text" to + MultipartField.builder() + .value("hello") + .contentType("text/plain") + .build(), + "stream" to + MultipartField.builder() + // Use `.buffered()` to get a non-ByteArrayInputStream, which hits the + // non-repeatable code path. + .value("data".byteInputStream().buffered()) + .contentType("application/octet-stream") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isFalse() + assertThat(body.contentLength()).isEqualTo(-1L) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="text" + |Content-Type: text/plain + | + |hello + |--$boundary + |Content-Disposition: form-data; name="stream" + |Content-Type: application/octet-stream + | + |data + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesEmptyArray() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "required" to + MultipartField.builder() + .value("present") + .contentType("text/plain") + .build(), + "items" to + MultipartField.builder>() + .value(emptyList()) + .contentType("text/plain") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="required" + |Content-Type: text/plain + | + |present + |--$boundary + |Content-Disposition: form-data; name="items" + |Content-Type: text/plain + | + | + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + @Test + fun multipartFormData_serializesEmptyObject() { + val body = + multipartFormData( + jsonMapper(), + mapOf( + "required" to + MultipartField.builder() + .value("present") + .contentType("text/plain") + .build(), + "meta" to + MultipartField.builder>() + .value(emptyMap()) + .contentType("text/plain") + .build(), + ), + ) + + val output = ByteArrayOutputStream() + body.writeTo(output) + + assertThat(body.repeatable()).isTrue() + assertThat(body.contentLength()).isEqualTo(output.size().toLong()) + val boundary = boundary(body) + assertThat(output.toString("UTF-8")) + .isEqualTo( + """ + |--$boundary + |Content-Disposition: form-data; name="required" + |Content-Type: text/plain + | + |present + |--$boundary-- + | + """ + .trimMargin() + .replace("\n", "\r\n") + ) + } + + private fun boundary(body: HttpRequestBody): String = + body.contentType()!!.substringAfter("multipart/form-data; boundary=") +} From f10c1b040943402094e0f75669b0eb61503d9875 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 24 Feb 2026 17:16:57 +0000 Subject: [PATCH 105/142] chore(internal): expand imports --- .../imagekit/api/core/http/RetryingHttpClient.kt | 2 ++ .../api/core/http/RetryingHttpClientTest.kt | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt index 787b5be8..3a0b6cb7 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt @@ -1,3 +1,5 @@ +// File generated from our OpenAPI spec by Stainless. + package com.imagekit.api.core.http import com.imagekit.api.core.DefaultSleeper diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt index d2f9ff61..421ac593 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt @@ -1,6 +1,17 @@ +// File generated from our OpenAPI spec by Stainless. + package com.imagekit.api.core.http -import com.github.tomakehurst.wiremock.client.WireMock.* +import com.github.tomakehurst.wiremock.client.WireMock.equalTo +import com.github.tomakehurst.wiremock.client.WireMock.matching +import com.github.tomakehurst.wiremock.client.WireMock.ok +import com.github.tomakehurst.wiremock.client.WireMock.post +import com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor +import com.github.tomakehurst.wiremock.client.WireMock.resetAllScenarios +import com.github.tomakehurst.wiremock.client.WireMock.serviceUnavailable +import com.github.tomakehurst.wiremock.client.WireMock.stubFor +import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.github.tomakehurst.wiremock.client.WireMock.verify import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.github.tomakehurst.wiremock.stubbing.Scenario From 6a528ff9db3c2123c79997bd48b503be731cca65 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 26 Feb 2026 11:23:51 +0000 Subject: [PATCH 106/142] feat(api): dpr type update --- .stats.yml | 4 +- .../com/imagekit/api/models/Transformation.kt | 201 +++++++++++++++++- .../models/beta/v2/files/FileUploadParams.kt | 9 +- .../api/models/files/FileUploadParams.kt | 9 +- .../api/services/async/FileServiceAsync.kt | 9 +- .../async/beta/v2/FileServiceAsync.kt | 9 +- .../api/services/blocking/FileService.kt | 9 +- .../services/blocking/beta/v2/FileService.kt | 9 +- .../imagekit/api/models/TransformationTest.kt | 2 +- 9 files changed, 223 insertions(+), 38 deletions(-) diff --git a/.stats.yml b/.stats.yml index dbc39e12..7401c19f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-13fc3d7cafdea492f62eef7c1d63424d6d9d8adbff74b9f6ca6fd3fc12a36840.yml -openapi_spec_hash: a1fe6fa48207791657a1ea2d60a6dfcc +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-e5b5a158784fff63311ceef956e8d5ce9e87c6b557d23ab737270040eb39adcd.yml +openapi_spec_hash: b0293985a8806f367319af573d1b418c config_hash: 47cb702ee2cb52c58d803ae39ade9b44 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt index ef063f90..a13cab78 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt @@ -60,7 +60,7 @@ private constructor( private val cropMode: JsonField, private val defaultImage: JsonField, private val distort: JsonField, - private val dpr: JsonField, + private val dpr: JsonField, private val duration: JsonField, private val endOffset: JsonField, private val flip: JsonField, @@ -147,7 +147,7 @@ private constructor( @ExcludeMissing defaultImage: JsonField = JsonMissing.of(), @JsonProperty("distort") @ExcludeMissing distort: JsonField = JsonMissing.of(), - @JsonProperty("dpr") @ExcludeMissing dpr: JsonField = JsonMissing.of(), + @JsonProperty("dpr") @ExcludeMissing dpr: JsonField = JsonMissing.of(), @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), @JsonProperty("endOffset") @ExcludeMissing @@ -481,7 +481,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun dpr(): Optional = dpr.getOptional("dpr") + fun dpr(): Optional = dpr.getOptional("dpr") /** * Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. Typically used @@ -994,7 +994,7 @@ private constructor( * * Unlike [dpr], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("dpr") @ExcludeMissing fun _dpr(): JsonField = dpr + @JsonProperty("dpr") @ExcludeMissing fun _dpr(): JsonField = dpr /** * Returns the raw JSON value of [duration]. @@ -1280,7 +1280,7 @@ private constructor( private var cropMode: JsonField = JsonMissing.of() private var defaultImage: JsonField = JsonMissing.of() private var distort: JsonField = JsonMissing.of() - private var dpr: JsonField = JsonMissing.of() + private var dpr: JsonField = JsonMissing.of() private var duration: JsonField = JsonMissing.of() private var endOffset: JsonField = JsonMissing.of() private var flip: JsonField = JsonMissing.of() @@ -1752,15 +1752,21 @@ private constructor( * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). * - See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). */ - fun dpr(dpr: Double) = dpr(JsonField.of(dpr)) + fun dpr(dpr: Dpr) = dpr(JsonField.of(dpr)) /** * Sets [Builder.dpr] to an arbitrary JSON value. * - * You should usually call [Builder.dpr] with a well-typed [Double] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.dpr] with a well-typed [Dpr] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. */ - fun dpr(dpr: JsonField) = apply { this.dpr = dpr } + fun dpr(dpr: JsonField) = apply { this.dpr = dpr } + + /** Alias for calling [dpr] with `Dpr.ofNumber(number)`. */ + fun dpr(number: Double) = dpr(Dpr.ofNumber(number)) + + /** Alias for calling [dpr] with `Dpr.ofString(string)`. */ + fun dpr(string: String) = dpr(Dpr.ofString(string)) /** * Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. Typically @@ -2582,7 +2588,7 @@ private constructor( cropMode().ifPresent { it.validate() } defaultImage() distort() - dpr() + dpr().ifPresent { it.validate() } duration().ifPresent { it.validate() } endOffset().ifPresent { it.validate() } flip().ifPresent { it.validate() } @@ -2654,7 +2660,7 @@ private constructor( (cropMode.asKnown().getOrNull()?.validity() ?: 0) + (if (defaultImage.asKnown().isPresent) 1 else 0) + (if (distort.asKnown().isPresent) 1 else 0) + - (if (dpr.asKnown().isPresent) 1 else 0) + + (dpr.asKnown().getOrNull()?.validity() ?: 0) + (duration.asKnown().getOrNull()?.validity() ?: 0) + (endOffset.asKnown().getOrNull()?.validity() ?: 0) + (flip.asKnown().getOrNull()?.validity() ?: 0) + @@ -4235,6 +4241,179 @@ private constructor( override fun toString() = value.toString() } + /** + * Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio (DPR) + * calculation. Also accepts arithmetic expressions. + * - Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * - See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). + */ + @JsonDeserialize(using = Dpr.Deserializer::class) + @JsonSerialize(using = Dpr.Serializer::class) + class Dpr + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Dpr = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Dpr && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "Dpr{number=$number}" + string != null -> "Dpr{string=$string}" + _json != null -> "Dpr{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Dpr") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Dpr(number = number) + + @JvmStatic fun ofString(string: String) = Dpr(string = string) + } + + /** An interface that defines how to map each variant of [Dpr] to a value of type [T]. */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Dpr] to a value of type [T]. + * + * An instance of [Dpr] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Dpr: $json") + } + } + + internal class Deserializer : BaseDeserializer(Dpr::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Dpr { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Dpr(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Dpr(number = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Dpr(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Dpr::class) { + + override fun serialize( + value: Dpr, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Dpr") + } + } + } + } + /** * Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. Typically used * with startOffset to indicate the length from the start offset. Arithmetic expressions are diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt index f875e7ac..9e52f25b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt @@ -42,10 +42,11 @@ import kotlin.io.path.name * [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) * about how to implement secure client-side file upload. * - * **File size limit** \ On the free plan, the maximum upload file sizes are 20MB for images, audio, - * and raw files, and 100MB for videos. On the paid plan, these limits increase to 40MB for images, - * audio, and raw files, and 2GB for videos. These limits can be further increased with higher-tier - * plans. + * **File size limit** \ On the free plan, the maximum upload file sizes are 25MB for images, audio, + * and raw files, and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for + * images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits + * increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further + * increased with enterprise plans. * * **Version limit** \ A file can have a maximum of 100 versions. * diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt index 2b1fa12c..a188bdb5 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -43,10 +43,11 @@ import kotlin.io.path.name * The [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security by verifying the * entire payload using JWT. * - * **File size limit** \ On the free plan, the maximum upload file sizes are 20MB for images, audio, - * and raw files and 100MB for videos. On the paid plan, these limits increase to 40MB for images, - * audio, and raw files and 2GB for videos. These limits can be further increased with higher-tier - * plans. + * **File size limit** \ On the free plan, the maximum upload file sizes are 25MB for images, audio, + * and raw files and 100MB for videos. On the Lite paid plan, these limits increase to 40MB for + * images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, these limits + * increase to 50MB for images, audio, and raw files and 2GB for videos. These limits can be further + * increased with enterprise plans. * * **Version limit** \ A file can have a maximum of 100 versions. * diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt index d608c612..24b3f071 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt @@ -194,10 +194,11 @@ interface FileServiceAsync { * The [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security by verifying * the entire payload using JWT. * - * **File size limit** \ On the free plan, the maximum upload file sizes are 20MB for images, - * audio, and raw files and 100MB for videos. On the paid plan, these limits increase to 40MB - * for images, audio, and raw files and 2GB for videos. These limits can be further increased - * with higher-tier plans. + * **File size limit** \ On the free plan, the maximum upload file sizes are 25MB for images, + * audio, and raw files and 100MB for videos. On the Lite paid plan, these limits increase to + * 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, + * these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These + * limits can be further increased with enterprise plans. * * **Version limit** \ A file can have a maximum of 100 versions. * diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsync.kt index d8db93f4..389f5f70 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsync.kt @@ -33,10 +33,11 @@ interface FileServiceAsync { * [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) * about how to implement secure client-side file upload. * - * **File size limit** \ On the free plan, the maximum upload file sizes are 20MB for images, - * audio, and raw files, and 100MB for videos. On the paid plan, these limits increase to 40MB - * for images, audio, and raw files, and 2GB for videos. These limits can be further increased - * with higher-tier plans. + * **File size limit** \ On the free plan, the maximum upload file sizes are 25MB for images, + * audio, and raw files, and 100MB for videos. On the Lite paid plan, these limits increase to + * 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, + * these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These + * limits can be further increased with enterprise plans. * * **Version limit** \ A file can have a maximum of 100 versions. * diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt index c2b3b7fa..d5031fd9 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt @@ -180,10 +180,11 @@ interface FileService { * The [V2 API](/docs/api-reference/upload-file/upload-file-v2) enhances security by verifying * the entire payload using JWT. * - * **File size limit** \ On the free plan, the maximum upload file sizes are 20MB for images, - * audio, and raw files and 100MB for videos. On the paid plan, these limits increase to 40MB - * for images, audio, and raw files and 2GB for videos. These limits can be further increased - * with higher-tier plans. + * **File size limit** \ On the free plan, the maximum upload file sizes are 25MB for images, + * audio, and raw files and 100MB for videos. On the Lite paid plan, these limits increase to + * 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, + * these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These + * limits can be further increased with enterprise plans. * * **Version limit** \ A file can have a maximum of 100 versions. * diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/v2/FileService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/v2/FileService.kt index 70d9c464..5f365a33 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/v2/FileService.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/v2/FileService.kt @@ -33,10 +33,11 @@ interface FileService { * [Learn more](/docs/api-reference/upload-file/upload-file-v2#how-to-implement-secure-client-side-file-upload) * about how to implement secure client-side file upload. * - * **File size limit** \ On the free plan, the maximum upload file sizes are 20MB for images, - * audio, and raw files, and 100MB for videos. On the paid plan, these limits increase to 40MB - * for images, audio, and raw files, and 2GB for videos. These limits can be further increased - * with higher-tier plans. + * **File size limit** \ On the free plan, the maximum upload file sizes are 25MB for images, + * audio, and raw files, and 100MB for videos. On the Lite paid plan, these limits increase to + * 40MB for images, audio, and raw files and 300MB for videos, whereas on the Pro paid plan, + * these limits increase to 50MB for images, audio, and raw files and 2GB for videos. These + * limits can be further increased with enterprise plans. * * **Version limit** \ A file can have a maximum of 100 versions. * diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt index 09bf721f..e88ba0c6 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt @@ -124,7 +124,7 @@ internal class TransformationTest { assertThat(transformation.cropMode()).contains(Transformation.CropMode.PAD_RESIZE) assertThat(transformation.defaultImage()).contains("defaultImage") assertThat(transformation.distort()).contains("distort") - assertThat(transformation.dpr()).contains(2.0) + assertThat(transformation.dpr()).contains(Transformation.Dpr.ofNumber(2.0)) assertThat(transformation.duration()).contains(Transformation.Duration.ofNumber(0.0)) assertThat(transformation.endOffset()).contains(Transformation.EndOffset.ofNumber(0.0)) assertThat(transformation.flip()).contains(Transformation.Flip.H) From 2f221f7678f232232a18d3b533bbeb93a7758599 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 3 Mar 2026 00:26:29 +0000 Subject: [PATCH 107/142] chore(tests): update webhook tests --- .../services/blocking/WebhookServiceImpl.kt | 1 + .../services/async/WebhookServiceAsyncTest.kt | 67 ++++++++++++++++++- .../services/blocking/WebhookServiceTest.kt | 67 ++++++++++++++++++- 3 files changed, 133 insertions(+), 2 deletions(-) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookServiceImpl.kt index 85e3f9d9..f028a009 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookServiceImpl.kt @@ -51,6 +51,7 @@ class WebhookServiceImpl internal constructor(private val clientOptions: ClientO unwrapParams.secret().getOrNull() ?: clientOptions.webhookSecret().getOrNull(), ) + val headersMap = headers.names().associateWith { name -> headers.values(name) }.toMap() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt index 4cbf570e..1b7f1056 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt @@ -57,7 +57,29 @@ internal class WebhookServiceAsyncTest { ) .build() - webhookServiceAsync.unwrap(payload).validate() + // Correct key should not throw + webhookServiceAsync.unwrap( + UnwrapWebhookParams.builder() + .body(payload) + .headers(headers) + .secret(webhookSecret) + .build() + ) + webhookServiceAsync + .withOptions { it.webhookSecret(webhookSecret) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(headers).build()) + + // Secret in method takes precedence to secret on client + val wrongKey = "whsec_aaaaaaaaaa" + webhookServiceAsync + .withOptions { it.webhookSecret(wrongKey) } + .unwrap( + UnwrapWebhookParams.builder() + .body(payload) + .headers(headers) + .secret(webhookSecret) + .build() + ) // Wrong key should throw assertThrows { @@ -70,6 +92,29 @@ internal class WebhookServiceAsyncTest { .build() ) } + assertThrows { + val wrongKey = "whsec_aaaaaaaaaa" + webhookServiceAsync + .withOptions { it.webhookSecret(wrongKey) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(headers).build()) + } + + assertThrows { + val wrongKey = "whsec_aaaaaaaaaa" + webhookServiceAsync.unwrap( + UnwrapWebhookParams.builder() + .body(payload) + .headers(headers) + .secret(wrongKey) + .build() + ) + } + assertThrows { + val wrongKey = "whsec_aaaaaaaaaa" + webhookServiceAsync + .withOptions { it.webhookSecret(wrongKey) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(headers).build()) + } // Bad signature should throw assertThrows { @@ -84,6 +129,14 @@ internal class WebhookServiceAsyncTest { .build() ) } + assertThrows { + val badSig = webhook.sign(messageId, timestampSeconds, "some other payload") + val badHeaders = + headers.toBuilder().replace("webhook-signature", listOf(badSig)).build() + webhookServiceAsync + .withOptions { it.webhookSecret(webhookSecret) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(badHeaders).build()) + } // Old timestamp should throw assertThrows { @@ -96,6 +149,12 @@ internal class WebhookServiceAsyncTest { .build() ) } + assertThrows { + val oldHeaders = headers.toBuilder().replace("webhook-timestamp", listOf("5")).build() + webhookServiceAsync + .withOptions { it.webhookSecret(webhookSecret) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(oldHeaders).build()) + } // Wrong message ID should throw assertThrows { @@ -108,5 +167,11 @@ internal class WebhookServiceAsyncTest { .build() ) } + assertThrows { + val wrongIdHeaders = headers.toBuilder().replace("webhook-id", listOf("wrong")).build() + webhookServiceAsync + .withOptions { it.webhookSecret(webhookSecret) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(wrongIdHeaders).build()) + } } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt index 6b85e385..c8c85d90 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt @@ -57,7 +57,29 @@ internal class WebhookServiceTest { ) .build() - webhookService.unwrap(payload).validate() + // Correct key should not throw + webhookService.unwrap( + UnwrapWebhookParams.builder() + .body(payload) + .headers(headers) + .secret(webhookSecret) + .build() + ) + webhookService + .withOptions { it.webhookSecret(webhookSecret) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(headers).build()) + + // Secret in method takes precedence to secret on client + val wrongKey = "whsec_aaaaaaaaaa" + webhookService + .withOptions { it.webhookSecret(wrongKey) } + .unwrap( + UnwrapWebhookParams.builder() + .body(payload) + .headers(headers) + .secret(webhookSecret) + .build() + ) // Wrong key should throw assertThrows { @@ -70,6 +92,29 @@ internal class WebhookServiceTest { .build() ) } + assertThrows { + val wrongKey = "whsec_aaaaaaaaaa" + webhookService + .withOptions { it.webhookSecret(wrongKey) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(headers).build()) + } + + assertThrows { + val wrongKey = "whsec_aaaaaaaaaa" + webhookService.unwrap( + UnwrapWebhookParams.builder() + .body(payload) + .headers(headers) + .secret(wrongKey) + .build() + ) + } + assertThrows { + val wrongKey = "whsec_aaaaaaaaaa" + webhookService + .withOptions { it.webhookSecret(wrongKey) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(headers).build()) + } // Bad signature should throw assertThrows { @@ -84,6 +129,14 @@ internal class WebhookServiceTest { .build() ) } + assertThrows { + val badSig = webhook.sign(messageId, timestampSeconds, "some other payload") + val badHeaders = + headers.toBuilder().replace("webhook-signature", listOf(badSig)).build() + webhookService + .withOptions { it.webhookSecret(webhookSecret) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(badHeaders).build()) + } // Old timestamp should throw assertThrows { @@ -96,6 +149,12 @@ internal class WebhookServiceTest { .build() ) } + assertThrows { + val oldHeaders = headers.toBuilder().replace("webhook-timestamp", listOf("5")).build() + webhookService + .withOptions { it.webhookSecret(webhookSecret) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(oldHeaders).build()) + } // Wrong message ID should throw assertThrows { @@ -108,5 +167,11 @@ internal class WebhookServiceTest { .build() ) } + assertThrows { + val wrongIdHeaders = headers.toBuilder().replace("webhook-id", listOf("wrong")).build() + webhookService + .withOptions { it.webhookSecret(webhookSecret) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(wrongIdHeaders).build()) + } } } From 997ab6353eeb46a8b97cad9f9688a11b9d700fc3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 5 Mar 2026 03:16:53 +0000 Subject: [PATCH 108/142] feat(api): revert dpr breaking change --- .stats.yml | 4 +- .../com/imagekit/api/models/Transformation.kt | 201 +----------------- .../imagekit/api/models/TransformationTest.kt | 2 +- 3 files changed, 14 insertions(+), 193 deletions(-) diff --git a/.stats.yml b/.stats.yml index 7401c19f..749d6988 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-e5b5a158784fff63311ceef956e8d5ce9e87c6b557d23ab737270040eb39adcd.yml -openapi_spec_hash: b0293985a8806f367319af573d1b418c +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-83a7f3659a437113f2a79e1e72794be19eff00ec232fd0206198c80364ccfebf.yml +openapi_spec_hash: b327552548ab641eb4ea3b45e643dfce config_hash: 47cb702ee2cb52c58d803ae39ade9b44 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt index a13cab78..ef063f90 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt @@ -60,7 +60,7 @@ private constructor( private val cropMode: JsonField, private val defaultImage: JsonField, private val distort: JsonField, - private val dpr: JsonField, + private val dpr: JsonField, private val duration: JsonField, private val endOffset: JsonField, private val flip: JsonField, @@ -147,7 +147,7 @@ private constructor( @ExcludeMissing defaultImage: JsonField = JsonMissing.of(), @JsonProperty("distort") @ExcludeMissing distort: JsonField = JsonMissing.of(), - @JsonProperty("dpr") @ExcludeMissing dpr: JsonField = JsonMissing.of(), + @JsonProperty("dpr") @ExcludeMissing dpr: JsonField = JsonMissing.of(), @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), @JsonProperty("endOffset") @ExcludeMissing @@ -481,7 +481,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun dpr(): Optional = dpr.getOptional("dpr") + fun dpr(): Optional = dpr.getOptional("dpr") /** * Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. Typically used @@ -994,7 +994,7 @@ private constructor( * * Unlike [dpr], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("dpr") @ExcludeMissing fun _dpr(): JsonField = dpr + @JsonProperty("dpr") @ExcludeMissing fun _dpr(): JsonField = dpr /** * Returns the raw JSON value of [duration]. @@ -1280,7 +1280,7 @@ private constructor( private var cropMode: JsonField = JsonMissing.of() private var defaultImage: JsonField = JsonMissing.of() private var distort: JsonField = JsonMissing.of() - private var dpr: JsonField = JsonMissing.of() + private var dpr: JsonField = JsonMissing.of() private var duration: JsonField = JsonMissing.of() private var endOffset: JsonField = JsonMissing.of() private var flip: JsonField = JsonMissing.of() @@ -1752,21 +1752,15 @@ private constructor( * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). * - See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). */ - fun dpr(dpr: Dpr) = dpr(JsonField.of(dpr)) + fun dpr(dpr: Double) = dpr(JsonField.of(dpr)) /** * Sets [Builder.dpr] to an arbitrary JSON value. * - * You should usually call [Builder.dpr] with a well-typed [Dpr] value instead. This method - * is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.dpr] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ - fun dpr(dpr: JsonField) = apply { this.dpr = dpr } - - /** Alias for calling [dpr] with `Dpr.ofNumber(number)`. */ - fun dpr(number: Double) = dpr(Dpr.ofNumber(number)) - - /** Alias for calling [dpr] with `Dpr.ofString(string)`. */ - fun dpr(string: String) = dpr(Dpr.ofString(string)) + fun dpr(dpr: JsonField) = apply { this.dpr = dpr } /** * Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. Typically @@ -2588,7 +2582,7 @@ private constructor( cropMode().ifPresent { it.validate() } defaultImage() distort() - dpr().ifPresent { it.validate() } + dpr() duration().ifPresent { it.validate() } endOffset().ifPresent { it.validate() } flip().ifPresent { it.validate() } @@ -2660,7 +2654,7 @@ private constructor( (cropMode.asKnown().getOrNull()?.validity() ?: 0) + (if (defaultImage.asKnown().isPresent) 1 else 0) + (if (distort.asKnown().isPresent) 1 else 0) + - (dpr.asKnown().getOrNull()?.validity() ?: 0) + + (if (dpr.asKnown().isPresent) 1 else 0) + (duration.asKnown().getOrNull()?.validity() ?: 0) + (endOffset.asKnown().getOrNull()?.validity() ?: 0) + (flip.asKnown().getOrNull()?.validity() ?: 0) + @@ -4241,179 +4235,6 @@ private constructor( override fun toString() = value.toString() } - /** - * Accepts values between 0.1 and 5, or `auto` for automatic device pixel ratio (DPR) - * calculation. Also accepts arithmetic expressions. - * - Learn about - * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). - * - See [DPR](https://imagekit.io/docs/image-resize-and-crop#dpr---dpr). - */ - @JsonDeserialize(using = Dpr.Deserializer::class) - @JsonSerialize(using = Dpr.Serializer::class) - class Dpr - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { - - fun number(): Optional = Optional.ofNullable(number) - - fun string(): Optional = Optional.ofNullable(string) - - fun isNumber(): Boolean = number != null - - fun isString(): Boolean = string != null - - fun asNumber(): Double = number.getOrThrow("number") - - fun asString(): String = string.getOrThrow("string") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Dpr = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNumber(number: Double) {} - - override fun visitString(string: String) {} - } - ) - 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 = - accept( - object : Visitor { - override fun visitNumber(number: Double) = 1 - - override fun visitString(string: String) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Dpr && number == other.number && string == other.string - } - - override fun hashCode(): Int = Objects.hash(number, string) - - override fun toString(): String = - when { - number != null -> "Dpr{number=$number}" - string != null -> "Dpr{string=$string}" - _json != null -> "Dpr{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Dpr") - } - - companion object { - - @JvmStatic fun ofNumber(number: Double) = Dpr(number = number) - - @JvmStatic fun ofString(string: String) = Dpr(string = string) - } - - /** An interface that defines how to map each variant of [Dpr] to a value of type [T]. */ - interface Visitor { - - fun visitNumber(number: Double): T - - fun visitString(string: String): T - - /** - * Maps an unknown variant of [Dpr] to a value of type [T]. - * - * An instance of [Dpr] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Dpr: $json") - } - } - - internal class Deserializer : BaseDeserializer(Dpr::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Dpr { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Dpr(string = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Dpr(number = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from boolean). - 0 -> Dpr(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely - // valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Dpr::class) { - - override fun serialize( - value: Dpr, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.number != null -> generator.writeObject(value.number) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Dpr") - } - } - } - } - /** * Specifies the duration (in seconds) for trimming videos, e.g., `5` or `10.5`. Typically used * with startOffset to indicate the length from the start offset. Arithmetic expressions are diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt index e88ba0c6..09bf721f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt @@ -124,7 +124,7 @@ internal class TransformationTest { assertThat(transformation.cropMode()).contains(Transformation.CropMode.PAD_RESIZE) assertThat(transformation.defaultImage()).contains("defaultImage") assertThat(transformation.distort()).contains("distort") - assertThat(transformation.dpr()).contains(Transformation.Dpr.ofNumber(2.0)) + assertThat(transformation.dpr()).contains(2.0) assertThat(transformation.duration()).contains(Transformation.Duration.ofNumber(0.0)) assertThat(transformation.endOffset()).contains(Transformation.EndOffset.ofNumber(0.0)) assertThat(transformation.flip()).contains(Transformation.Flip.H) From eb80ae59186571723c253602ebf87e31bc52b988 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 5 Mar 2026 09:25:28 +0000 Subject: [PATCH 109/142] fix: fix request delays for retrying to be more respectful of high requested delays --- .../com/imagekit/api/core/http/RetryingHttpClient.kt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt index 3a0b6cb7..5844a0af 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt @@ -214,13 +214,8 @@ private constructor( } } ?.let { retryAfterNanos -> - // If the API asks us to wait a certain amount of time (and it's a reasonable - // amount), just - // do what it says. - val retryAfter = Duration.ofNanos(retryAfterNanos.toLong()) - if (retryAfter in Duration.ofNanos(0)..Duration.ofMinutes(1)) { - return retryAfter - } + // If the API asks us to wait a certain amount of time, do what it says. + return Duration.ofNanos(retryAfterNanos.toLong()) } // Apply exponential backoff, but not more than the max. From 87b5f1817dda7429a6b4a154f71d4196198df0c0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 5 Mar 2026 09:46:32 +0000 Subject: [PATCH 110/142] chore(internal): bump palantir-java-format --- buildSrc/src/main/kotlin/image-kit.java.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/image-kit.java.gradle.kts b/buildSrc/src/main/kotlin/image-kit.java.gradle.kts index 81d5d32b..a3cfe28e 100644 --- a/buildSrc/src/main/kotlin/image-kit.java.gradle.kts +++ b/buildSrc/src/main/kotlin/image-kit.java.gradle.kts @@ -54,7 +54,7 @@ tasks.withType().configureEach { val palantir by configurations.creating dependencies { - palantir("com.palantir.javaformat:palantir-java-format:2.73.0") + palantir("com.palantir.javaformat:palantir-java-format:2.89.0") } fun registerPalantir( From 19e8f78f7ee6e65ad0943dcccc7e17af31cf074c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 7 Mar 2026 13:01:05 +0000 Subject: [PATCH 111/142] chore(ci): skip uploading artifacts on stainless-internal branches --- .github/workflows/ci.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2944deae..b0e4693a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,14 +65,18 @@ jobs: run: ./scripts/build - name: Get GitHub OIDC Token - if: github.repository == 'stainless-sdks/imagekit-java' + if: |- + github.repository == 'stainless-sdks/imagekit-java' && + !startsWith(github.ref, 'refs/heads/stl/') id: github-oidc uses: actions/github-script@v8 with: script: core.setOutput('github_token', await core.getIDToken()); - name: Build and upload Maven artifacts - if: github.repository == 'stainless-sdks/imagekit-java' + if: |- + github.repository == 'stainless-sdks/imagekit-java' && + !startsWith(github.ref, 'refs/heads/stl/') env: URL: https://pkg.stainless.com/s AUTH: ${{ steps.github-oidc.outputs.github_token }} From 6b3d9f5c59f9e416ea67380045bf54ef9f48f135 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 7 Mar 2026 13:17:34 +0000 Subject: [PATCH 112/142] chore: update placeholder string --- .../beta/v2/files/FileUploadParamsTest.kt | 10 +++--- .../api/models/files/FileUploadParamsTest.kt | 10 +++--- .../api/services/ErrorHandlingTest.kt | 34 +++++++++---------- .../api/services/ServiceParamsTest.kt | 2 +- .../services/async/FileServiceAsyncTest.kt | 2 +- .../async/beta/v2/FileServiceAsyncTest.kt | 2 +- .../api/services/blocking/FileServiceTest.kt | 2 +- .../blocking/beta/v2/FileServiceTest.kt | 2 +- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt index 43390b56..20626522 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt @@ -14,7 +14,7 @@ internal class FileUploadParamsTest { @Test fun create() { FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -197,7 +197,7 @@ internal class FileUploadParamsTest { fun body() { val params = FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -388,7 +388,7 @@ internal class FileUploadParamsTest { ) .isEqualTo( mapOf( - "file" to MultipartField.of("some content".byteInputStream()), + "file" to MultipartField.of("Example data".byteInputStream()), "fileName" to MultipartField.of("fileName"), "token" to MultipartField.of("token"), "checks" to MultipartField.of("\"request.folder\" : \"marketing/\"\n"), @@ -619,7 +619,7 @@ internal class FileUploadParamsTest { fun bodyWithoutOptionalFields() { val params = FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .build() @@ -635,7 +635,7 @@ internal class FileUploadParamsTest { ) .isEqualTo( mapOf( - "file" to MultipartField.of("some content".byteInputStream()), + "file" to MultipartField.of("Example data".byteInputStream()), "fileName" to MultipartField.of("fileName"), ) .mapValues { (_, field) -> diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt index 01baff33..c2b7158a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt @@ -14,7 +14,7 @@ internal class FileUploadParamsTest { @Test fun create() { FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -200,7 +200,7 @@ internal class FileUploadParamsTest { fun body() { val params = FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -394,7 +394,7 @@ internal class FileUploadParamsTest { ) .isEqualTo( mapOf( - "file" to MultipartField.of("some content".byteInputStream()), + "file" to MultipartField.of("Example data".byteInputStream()), "fileName" to MultipartField.of("fileName"), "token" to MultipartField.of("token"), "checks" to MultipartField.of("\"request.folder\" : \"marketing/\"\n"), @@ -628,7 +628,7 @@ internal class FileUploadParamsTest { fun bodyWithoutOptionalFields() { val params = FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .build() @@ -644,7 +644,7 @@ internal class FileUploadParamsTest { ) .isEqualTo( mapOf( - "file" to MultipartField.of("some content".byteInputStream()), + "file" to MultipartField.of("Example data".byteInputStream()), "fileName" to MultipartField.of("fileName"), ) .mapValues { (_, field) -> diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt index 2fa949f7..15ebd90e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt @@ -74,7 +74,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -303,7 +303,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -532,7 +532,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -761,7 +761,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -990,7 +990,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1219,7 +1219,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1448,7 +1448,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1677,7 +1677,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -1906,7 +1906,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -2135,7 +2135,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -2364,7 +2364,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -2593,7 +2593,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -2822,7 +2822,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -3051,7 +3051,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -3280,7 +3280,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -3509,7 +3509,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") @@ -3736,7 +3736,7 @@ internal class ErrorHandlingTest { assertThrows { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt index 211ca9ca..0f2117e7 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt @@ -46,7 +46,7 @@ internal class ServiceParamsTest { fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index 622313be..f9d0c9ab 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -226,7 +226,7 @@ internal class FileServiceAsyncTest { val responseFuture = fileServiceAsync.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt index 503767ac..9ac39ec8 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt @@ -24,7 +24,7 @@ internal class FileServiceAsyncTest { val responseFuture = fileServiceAsync.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index 7fd19909..477c11b0 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -219,7 +219,7 @@ internal class FileServiceTest { val response = fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt index 10f4c49f..63433f0d 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt @@ -24,7 +24,7 @@ internal class FileServiceTest { val response = fileService.upload( FileUploadParams.builder() - .file("some content".byteInputStream()) + .file("Example data".byteInputStream()) .fileName("fileName") .token("token") .checks("\"request.folder\" : \"marketing/\"\n") From 15b04f7bfb7677c941dda5db230b273115551600 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 10 Mar 2026 14:15:29 +0000 Subject: [PATCH 113/142] fix(client): incorrect `Retry-After` parsing --- .../api/core/http/RetryingHttpClient.kt | 2 +- .../api/core/http/RetryingHttpClientTest.kt | 224 +++++++++++++++--- 2 files changed, 192 insertions(+), 34 deletions(-) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt index 5844a0af..7b72b0b3 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt @@ -201,7 +201,7 @@ private constructor( ?: headers.values("Retry-After").getOrNull(0)?.let { retryAfter -> retryAfter.toFloatOrNull()?.times(TimeUnit.SECONDS.toNanos(1)) ?: try { - ChronoUnit.MILLIS.between( + ChronoUnit.NANOS.between( OffsetDateTime.now(clock), OffsetDateTime.parse( retryAfter, diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt index 421ac593..9403fafb 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt @@ -20,7 +20,11 @@ import com.imagekit.api.core.RequestOptions import com.imagekit.api.core.Sleeper import com.imagekit.api.errors.ImageKitRetryableException import java.io.InputStream +import java.time.Clock import java.time.Duration +import java.time.OffsetDateTime +import java.time.ZoneOffset +import java.time.format.DateTimeFormatter import java.util.concurrent.CompletableFuture import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach @@ -36,6 +40,21 @@ internal class RetryingHttpClientTest { private lateinit var baseUrl: String private lateinit var httpClient: HttpClient + private class RecordingSleeper : Sleeper { + val durations = mutableListOf() + + override fun sleep(duration: Duration) { + durations.add(duration) + } + + override fun sleepAsync(duration: Duration): CompletableFuture { + durations.add(duration) + return CompletableFuture.completedFuture(null) + } + + override fun close() {} + } + @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { baseUrl = wmRuntimeInfo.httpBaseUrl @@ -86,7 +105,8 @@ internal class RetryingHttpClientTest { @ValueSource(booleans = [false, true]) fun execute(async: Boolean) { stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) - val retryingClient = retryingHttpClientBuilder().build() + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).build() val response = retryingClient.execute( @@ -100,6 +120,7 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).isEmpty() assertNoResponseLeaks() } @@ -111,8 +132,12 @@ internal class RetryingHttpClientTest { .withHeader("X-Some-Header", matching("stainless-java-retry-.+")) .willReturn(ok()) ) + val sleeper = RecordingSleeper() val retryingClient = - retryingHttpClientBuilder().maxRetries(2).idempotencyHeader("X-Some-Header").build() + retryingHttpClientBuilder(sleeper) + .maxRetries(2) + .idempotencyHeader("X-Some-Header") + .build() val response = retryingClient.execute( @@ -126,20 +151,20 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).isEmpty() assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) fun execute_withRetryAfterHeader(async: Boolean) { + val retryAfterDate = "Wed, 21 Oct 2015 07:28:00 GMT" stubFor( post(urlPathEqualTo("/something")) // First we fail with a retry after header given as a date .inScenario("foo") .whenScenarioStateIs(Scenario.STARTED) - .willReturn( - serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") - ) + .willReturn(serviceUnavailable().withHeader("Retry-After", retryAfterDate)) .willSetStateTo("RETRY_AFTER_DATE") ) stubFor( @@ -158,7 +183,13 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() + // Fix the clock to 5 seconds before the Retry-After date so the date-based backoff is + // deterministic. + val retryAfterDateTime = + OffsetDateTime.parse(retryAfterDate, DateTimeFormatter.RFC_1123_DATE_TIME) + val clock = Clock.fixed(retryAfterDateTime.minusSeconds(5).toInstant(), ZoneOffset.UTC) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper, clock).maxRetries(2).build() val response = retryingClient.execute( @@ -186,19 +217,20 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("2")), ) + assertThat(sleeper.durations) + .containsExactly(Duration.ofSeconds(5), Duration.ofMillis(1234)) assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) fun execute_withOverwrittenRetryCountHeader(async: Boolean) { + val retryAfterDate = "Wed, 21 Oct 2015 07:28:00 GMT" stubFor( post(urlPathEqualTo("/something")) .inScenario("foo") // first we fail with a retry after header given as a date .whenScenarioStateIs(Scenario.STARTED) - .willReturn( - serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") - ) + .willReturn(serviceUnavailable().withHeader("Retry-After", retryAfterDate)) .willSetStateTo("RETRY_AFTER_DATE") ) stubFor( @@ -208,7 +240,11 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() + val retryAfterDateTime = + OffsetDateTime.parse(retryAfterDate, DateTimeFormatter.RFC_1123_DATE_TIME) + val clock = Clock.fixed(retryAfterDateTime.minusSeconds(5).toInstant(), ZoneOffset.UTC) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper, clock).maxRetries(2).build() val response = retryingClient.execute( @@ -227,6 +263,7 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("42")), ) + assertThat(sleeper.durations).containsExactly(Duration.ofSeconds(5)) assertNoResponseLeaks() } @@ -247,7 +284,8 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = retryingHttpClientBuilder().maxRetries(1).build() + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(1).build() val response = retryingClient.execute( @@ -261,6 +299,7 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(200) verify(2, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).containsExactly(Duration.ofMillis(10)) assertNoResponseLeaks() } @@ -301,21 +340,12 @@ internal class RetryingHttpClientTest { override fun close() = httpClient.close() } + val sleeper = RecordingSleeper() val retryingClient = RetryingHttpClient.builder() .httpClient(failingHttpClient) .maxRetries(2) - .sleeper( - object : Sleeper { - - override fun sleep(duration: Duration) {} - - override fun sleepAsync(duration: Duration): CompletableFuture = - CompletableFuture.completedFuture(null) - - override fun close() {} - } - ) + .sleeper(sleeper) .build() val response = @@ -339,25 +369,153 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("0")), ) + // Exponential backoff with jitter: 0.5s * jitter where jitter is in [0.75, 1.0]. + assertThat(sleeper.durations).hasSize(1) + assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) assertNoResponseLeaks() } - private fun retryingHttpClientBuilder() = - RetryingHttpClient.builder() - .httpClient(httpClient) - // Use a no-op `Sleeper` to make the test fast. - .sleeper( - object : Sleeper { + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withExponentialBackoff(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(serviceUnavailable())) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(3).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) - override fun sleep(duration: Duration) {} + // All retries exhausted; the last 503 response is returned. + assertThat(response.statusCode()).isEqualTo(503) + verify(4, postRequestedFor(urlPathEqualTo("/something"))) + // Exponential backoff with jitter: backoff = min(0.5 * 2^(retries-1), 8) * jitter where + // jitter is in [0.75, 1.0]. + assertThat(sleeper.durations).hasSize(3) + // retries=1: 0.5s * [0.75, 1.0] + assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) + // retries=2: 1.0s * [0.75, 1.0] + assertThat(sleeper.durations[1]).isBetween(Duration.ofMillis(750), Duration.ofMillis(1000)) + // retries=3: 2.0s * [0.75, 1.0] + assertThat(sleeper.durations[2]).isBetween(Duration.ofMillis(1500), Duration.ofMillis(2000)) + assertNoResponseLeaks() + } - override fun sleepAsync(duration: Duration): CompletableFuture = - CompletableFuture.completedFuture(null) + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withExponentialBackoffCap(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(serviceUnavailable())) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(6).build() - override fun close() {} - } + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, ) + assertThat(response.statusCode()).isEqualTo(503) + verify(7, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).hasSize(6) + // retries=5: min(0.5 * 2^4, 8) = 8.0s * [0.75, 1.0] + assertThat(sleeper.durations[4]).isBetween(Duration.ofMillis(6000), Duration.ofMillis(8000)) + // retries=6: min(0.5 * 2^5, 8) = min(16, 8) = 8.0s * [0.75, 1.0] (capped) + assertThat(sleeper.durations[5]).isBetween(Duration.ofMillis(6000), Duration.ofMillis(8000)) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterMsPriorityOverRetryAfter(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn( + serviceUnavailable() + .withHeader("Retry-After-Ms", "50") + .withHeader("Retry-After", "2") + ) + .willSetStateTo("RETRY") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs("RETRY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(1).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + // Retry-After-Ms (50ms) takes priority over Retry-After (2s). + assertThat(sleeper.durations).containsExactly(Duration.ofMillis(50)) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterUnparseable(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn(serviceUnavailable().withHeader("Retry-After", "not-a-date-or-number")) + .willSetStateTo("RETRY") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs("RETRY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(1).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + // Unparseable Retry-After falls through to exponential backoff. + assertThat(sleeper.durations).hasSize(1) + assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) + assertNoResponseLeaks() + } + + private fun retryingHttpClientBuilder( + sleeper: RecordingSleeper, + clock: Clock = Clock.systemUTC(), + ) = RetryingHttpClient.builder().httpClient(httpClient).sleeper(sleeper).clock(clock) + private fun HttpClient.execute(request: HttpRequest, async: Boolean): HttpResponse = if (async) executeAsync(request).get() else execute(request) From e970882efd7aa0f4770edce814c9b837e8ae247c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 13 Mar 2026 00:43:26 +0000 Subject: [PATCH 114/142] chore(internal): codegen related update --- .../kotlin/com/imagekit/api/models/Overlay.kt | 60 +++++++++---------- .../webhooks/UnsafeUnwrapWebhookEvent.kt | 4 ++ .../api/models/webhooks/UnwrapWebhookEvent.kt | 4 ++ 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Overlay.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Overlay.kt index 51a9db0f..52adca4d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Overlay.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Overlay.kt @@ -12,11 +12,11 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.BaseDeserializer import com.imagekit.api.core.BaseSerializer import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.allMaxBy import com.imagekit.api.core.getOrThrow import com.imagekit.api.errors.ImageKitInvalidDataException import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Specifies an overlay to be applied on the parent image or video. ImageKit supports overlays @@ -212,37 +212,37 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Overlay { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Overlay(text = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Overlay(image = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Overlay(video = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Overlay(subtitle = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Overlay(solidColor = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with all - // the possible variants (e.g. deserializing from boolean). - 0 -> Overlay(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + when (type) { + "text" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Overlay(text = it, _json = json) + } ?: Overlay(_json = json) + } + "image" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Overlay(image = it, _json = json) + } ?: Overlay(_json = json) + } + "video" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Overlay(video = it, _json = json) + } ?: Overlay(_json = json) + } + "subtitle" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Overlay(subtitle = it, _json = json) + } ?: Overlay(_json = json) + } + "solidColor" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Overlay(solidColor = it, _json = json) + } ?: Overlay(_json = json) + } } + + return Overlay(_json = json) } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt index a989564a..aefc49f6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt @@ -17,6 +17,7 @@ import com.imagekit.api.core.getOrThrow import com.imagekit.api.errors.ImageKitInvalidDataException import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Triggered when a new video transformation request is accepted for processing. This event confirms @@ -477,6 +478,9 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): UnsafeUnwrapWebhookEvent { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) {} val bestMatches = sequenceOf( diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt index 8e1eab97..df37c012 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt @@ -17,6 +17,7 @@ import com.imagekit.api.core.getOrThrow import com.imagekit.api.errors.ImageKitInvalidDataException import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Triggered when a new video transformation request is accepted for processing. This event confirms @@ -476,6 +477,9 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): UnwrapWebhookEvent { val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) {} val bestMatches = sequenceOf( From 3e76397ba5582f39d56aeb243d2fa81564814604 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 16 Mar 2026 20:46:30 +0000 Subject: [PATCH 115/142] chore(internal): tweak CI branches --- .github/workflows/ci.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0e4693a..36fabea5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,14 @@ name: CI on: push: - branches-ignore: - - 'generated' - - 'codegen/**' - - 'integrated/**' - - 'stl-preview-head/**' - - 'stl-preview-base/**' + branches: + - '**' + - '!integrated/**' + - '!stl-preview-head/**' + - '!stl-preview-base/**' + - '!generated' + - '!codegen/**' + - 'codegen/stl/**' pull_request: branches-ignore: - 'stl-preview-head/**' From 51a3135751d0ff2bdc2c741e714061615d232b7b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Mar 2026 16:48:39 +0000 Subject: [PATCH 116/142] chore(internal): update retry delay tests --- .../com/imagekit/api/core/http/RetryingHttpClientTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt index 9403fafb..3d2a391c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt @@ -400,9 +400,9 @@ internal class RetryingHttpClientTest { assertThat(sleeper.durations).hasSize(3) // retries=1: 0.5s * [0.75, 1.0] assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) - // retries=2: 1.0s * [0.75, 1.0] + // retries=2: 1s * [0.75, 1.0] assertThat(sleeper.durations[1]).isBetween(Duration.ofMillis(750), Duration.ofMillis(1000)) - // retries=3: 2.0s * [0.75, 1.0] + // retries=3: 2s * [0.75, 1.0] assertThat(sleeper.durations[2]).isBetween(Duration.ofMillis(1500), Duration.ofMillis(2000)) assertNoResponseLeaks() } @@ -427,9 +427,9 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(503) verify(7, postRequestedFor(urlPathEqualTo("/something"))) assertThat(sleeper.durations).hasSize(6) - // retries=5: min(0.5 * 2^4, 8) = 8.0s * [0.75, 1.0] + // retries=5: backoff hits the 8s cap * [0.75, 1.0] assertThat(sleeper.durations[4]).isBetween(Duration.ofMillis(6000), Duration.ofMillis(8000)) - // retries=6: min(0.5 * 2^5, 8) = min(16, 8) = 8.0s * [0.75, 1.0] (capped) + // retries=6: still capped at 8s * [0.75, 1.0] assertThat(sleeper.durations[5]).isBetween(Duration.ofMillis(6000), Duration.ofMillis(8000)) assertNoResponseLeaks() } From 91e327e82db972ae6e5a50f9fb14e52ead007621 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Mar 2026 21:18:50 +0000 Subject: [PATCH 117/142] fix(client): allow updating header/query affecting fields in `toBuilder()` --- .../com/imagekit/api/core/ClientOptions.kt | 7 ++-- .../imagekit/api/core/ClientOptionsTest.kt | 33 +++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt index c850d2f7..bfd06a44 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt @@ -466,18 +466,19 @@ private constructor( headers.put("X-Stainless-Runtime", "JRE") headers.put("X-Stainless-Runtime-Version", getJavaVersion()) headers.put("X-Stainless-Kotlin-Version", KotlinVersion.CURRENT.toString()) + // We replace after all the default headers to allow end-users to overwrite them. + headers.replaceAll(this.headers.build()) + queryParams.replaceAll(this.queryParams.build()) privateKey.let { username -> password?.let { password -> if (!username.isEmpty() && !password.isEmpty()) { - headers.put( + headers.replace( "Authorization", "Basic ${Base64.getEncoder().encodeToString("$username:$password".toByteArray())}", ) } } } - headers.replaceAll(this.headers.build()) - queryParams.replaceAll(this.queryParams.build()) return ClientOptions( httpClient, diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt index 3d1af46c..323aed25 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt @@ -16,6 +16,39 @@ internal class ClientOptionsTest { private val httpClient = mock() + @Test + fun putHeader_canOverwriteDefaultHeader() { + val clientOptions = + ClientOptions.builder() + .httpClient(httpClient) + .putHeader("User-Agent", "My User Agent") + .privateKey("My Private Key") + .password("My Password") + .build() + + assertThat(clientOptions.headers.values("User-Agent")).containsExactly("My User Agent") + } + + @Test + fun toBuilder_basicAuthCanBeUpdated() { + var clientOptions = + ClientOptions.builder() + .httpClient(httpClient) + .privateKey("My Private Key") + .password("My Password") + .build() + + clientOptions = + clientOptions + .toBuilder() + .privateKey("another My Private Key") + .password("another My Password") + .build() + + assertThat(clientOptions.headers.values("Authorization")) + .containsExactly("Basic YW5vdGhlciBNeSBQcml2YXRlIEtleTphbm90aGVyIE15IFBhc3N3b3Jk") + } + @Test fun toBuilder_whenOriginalClientOptionsGarbageCollected_doesNotCloseOriginalClient() { var clientOptions = From 3b0fc2efe92fcf1733f4bbdefe779cd2203e585a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 20 Mar 2026 17:51:45 +0000 Subject: [PATCH 118/142] chore(tests): bump steady to v0.19.4 --- buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts | 2 +- scripts/fast-format | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts b/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts index edcc2ab3..dd476783 100644 --- a/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts @@ -40,7 +40,7 @@ tasks.withType().configureEach { val ktfmt by configurations.creating dependencies { - ktfmt("com.facebook:ktfmt:0.56") + ktfmt("com.facebook:ktfmt:0.61") } fun registerKtfmt( diff --git a/scripts/fast-format b/scripts/fast-format index 1b3bc473..35a1dee2 100755 --- a/scripts/fast-format +++ b/scripts/fast-format @@ -24,8 +24,8 @@ if [ ! -f "$FILE_LIST" ]; then exit 1 fi -if ! command -v ktfmt-fast-format &> /dev/null; then - echo "Error: ktfmt-fast-format not found" +if ! command -v ktfmt &> /dev/null; then + echo "Error: ktfmt not found" exit 1 fi @@ -36,7 +36,7 @@ echo "==> Done looking for Kotlin files" if [[ -n "$kt_files" ]]; then echo "==> will format Kotlin files" - echo "$kt_files" | tr '\n' '\0' | xargs -0 ktfmt-fast-format --kotlinlang-style "$@" + echo "$kt_files" | tr '\n' '\0' | xargs -0 ktfmt --kotlinlang-style "$@" else echo "No Kotlin files to format -- expected outcome during incremental formatting" fi From 4c944e0804b949085602a5d724120ab40acba53d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2026 12:39:00 +0000 Subject: [PATCH 119/142] chore(internal): update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b1346e6d..90b85e94 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .prism.log +.stdy.log .gradle .idea .kotlin From f43fd3ae0642cc33b727775e62eb58a6fb3f0123 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 24 Mar 2026 15:16:58 +0000 Subject: [PATCH 120/142] chore(ci): skip lint on metadata-only changes Note that we still want to run tests, as these depend on the metadata. --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 36fabea5..c7af40ff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: timeout-minutes: 15 name: lint runs-on: ${{ github.repository == 'stainless-sdks/imagekit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - uses: actions/checkout@v6 @@ -46,7 +46,7 @@ jobs: contents: read id-token: write runs-on: ${{ github.repository == 'stainless-sdks/imagekit-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - uses: actions/checkout@v6 From 11184c77fbc86d278f2791bdbbfcaa1cb542eaae Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 26 Mar 2026 19:26:11 +0000 Subject: [PATCH 121/142] chore(internal): update multipart form array serialization --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5cca7f58..a7b10f6c 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ import java.io.ByteArrayInputStream; ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) .fileName("file-name.jpg") .build(); FileUploadResponse response = client.files().upload(params); @@ -158,7 +158,7 @@ import java.util.concurrent.CompletableFuture; ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) .fileName("file-name.jpg") .build(); CompletableFuture response = client.async().files().upload(params); @@ -179,7 +179,7 @@ import java.util.concurrent.CompletableFuture; ImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv(); FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) .fileName("file-name.jpg") .build(); CompletableFuture response = client.files().upload(params); @@ -265,7 +265,7 @@ import com.imagekit.api.models.files.FileUploadResponse; import java.io.ByteArrayInputStream; FileUploadParams params = FileUploadParams.builder() - .file(ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) .fileName("file-name.jpg") .build(); HttpResponseFor response = client.files().withRawResponse().upload(params); From e3b34fb41f580c5bd557c99cc7c26af6d5583b20 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 6 Apr 2026 06:34:47 +0000 Subject: [PATCH 122/142] feat(api): Introduce lxc, lyc, lap parameters in overlays. --- .stats.yml | 4 +- .../imagekit/api/models/ExtensionConfig.kt | 23 +- .../imagekit/api/models/OverlayPosition.kt | 758 +++++++++++++++++- .../models/beta/v2/files/FileUploadParams.kt | 25 +- .../api/models/files/FileUploadParams.kt | 25 +- .../api/models/files/UpdateFileRequest.kt | 26 +- .../imagekit/api/models/BaseOverlayTest.kt | 15 +- .../models/GetImageAttributesOptionsTest.kt | 9 + .../imagekit/api/models/ImageOverlayTest.kt | 24 +- .../api/models/OverlayPositionTest.kt | 23 +- .../com/imagekit/api/models/OverlayTest.kt | 42 + .../api/models/SolidColorOverlayTest.kt | 15 +- .../com/imagekit/api/models/SrcOptionsTest.kt | 9 + .../api/models/SubtitleOverlayTest.kt | 15 +- .../imagekit/api/models/TextOverlayTest.kt | 15 +- .../imagekit/api/models/TransformationTest.kt | 9 + .../imagekit/api/models/VideoOverlayTest.kt | 24 +- 17 files changed, 988 insertions(+), 73 deletions(-) diff --git a/.stats.yml b/.stats.yml index 749d6988..df5aafb6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-83a7f3659a437113f2a79e1e72794be19eff00ec232fd0206198c80364ccfebf.yml -openapi_spec_hash: b327552548ab641eb4ea3b45e643dfce +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-63aff1629530786015da3c86131afa8a9b60545d488884b77641f1d4b89c6e9d.yml +openapi_spec_hash: 586d357bd7e5217d240a99e0d83c6d1f config_hash: 47cb702ee2cb52c58d803ae39ade9b44 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt index 89692a98..fce20326 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt @@ -1613,8 +1613,9 @@ private constructor( fun minSelections(): Optional = minSelections.getOptional("min_selections") /** - * Array of possible tag values. Combined length of all strings must not exceed 500 - * characters. Cannot contain the `%` character. + * Array of possible tag values. The combined length of all strings must not exceed + * 500 characters, and values cannot include the `%` character. When providing large + * vocabularies (more than 30 items), the AI may not follow the list strictly. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -1765,8 +1766,10 @@ private constructor( } /** - * Array of possible tag values. Combined length of all strings must not exceed - * 500 characters. Cannot contain the `%` character. + * Array of possible tag values. The combined length of all strings must not + * exceed 500 characters, and values cannot include the `%` character. When + * providing large vocabularies (more than 30 items), the AI may not follow the + * list strictly. */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) @@ -1999,7 +2002,10 @@ private constructor( fun minSelections(): Optional = minSelections.getOptional("min_selections") /** - * Array of possible values matching the custom metadata field type. + * An array of possible values matching the custom metadata field type. If not + * provided for SingleSelect or MultiSelect field types, all values from the custom + * metadata field definition will be used. When providing large vocabularies (above + * 30 items), the AI may not strictly adhere to the list. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -2175,7 +2181,12 @@ private constructor( this.minSelections = minSelections } - /** Array of possible values matching the custom metadata field type. */ + /** + * An array of possible values matching the custom metadata field type. If not + * provided for SingleSelect or MultiSelect field types, all values from the + * custom metadata field definition will be used. When providing large + * vocabularies (above 30 items), the AI may not strictly adhere to the list. + */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt index 020f99a5..9baf1c6c 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt @@ -31,22 +31,41 @@ import kotlin.jvm.optionals.getOrNull class OverlayPosition @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val anchorPoint: JsonField, private val focus: JsonField, private val x: JsonField, + private val xCenter: JsonField, private val y: JsonField, + private val yCenter: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("anchorPoint") + @ExcludeMissing + anchorPoint: JsonField = JsonMissing.of(), @JsonProperty("focus") @ExcludeMissing focus: JsonField = JsonMissing.of(), @JsonProperty("x") @ExcludeMissing x: JsonField = JsonMissing.of(), + @JsonProperty("xCenter") @ExcludeMissing xCenter: JsonField = JsonMissing.of(), @JsonProperty("y") @ExcludeMissing y: JsonField = JsonMissing.of(), - ) : this(focus, x, y, mutableMapOf()) + @JsonProperty("yCenter") @ExcludeMissing yCenter: JsonField = JsonMissing.of(), + ) : this(anchorPoint, focus, x, xCenter, y, yCenter, mutableMapOf()) /** - * Specifies the position of the overlay relative to the parent image or video. Maps to `lfo` in - * the URL. + * Sets the anchor point on the base asset from which the overlay offset is calculated. The + * default value is `top_left`. Maps to `lap` in the URL. Can only be used with one or more of + * `x`, `y`, `xCenter`, or `yCenter`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun anchorPoint(): Optional = anchorPoint.getOptional("anchorPoint") + + /** + * Specifies the position of the overlay relative to the parent image or video. If one or more + * of `x`, `y`, `xCenter`, or `yCenter` parameters are specified, this parameter is ignored. + * Maps to `lfo` in the URL. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -64,6 +83,17 @@ private constructor( */ fun x(): Optional = x.getOptional("x") + /** + * Specifies the x-coordinate on the base asset where the overlay's center will be positioned. + * It also accepts arithmetic expressions such as `bw_mul_0.4` or `bw_sub_cw`. Maps to `lxc` in + * the URL. Cannot be used together with `x`, but can be used with `y`. Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun xCenter(): Optional = xCenter.getOptional("xCenter") + /** * Specifies the y-coordinate of the top-left corner of the base asset where the overlay's * top-left corner will be positioned. It also accepts arithmetic expressions such as @@ -75,6 +105,26 @@ private constructor( */ fun y(): Optional = y.getOptional("y") + /** + * Specifies the y-coordinate on the base asset where the overlay's center will be positioned. + * It also accepts arithmetic expressions such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `lyc` in + * the URL. Cannot be used together with `y`, but can be used with `x`. Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun yCenter(): Optional = yCenter.getOptional("yCenter") + + /** + * Returns the raw JSON value of [anchorPoint]. + * + * Unlike [anchorPoint], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("anchorPoint") + @ExcludeMissing + fun _anchorPoint(): JsonField = anchorPoint + /** * Returns the raw JSON value of [focus]. * @@ -89,6 +139,13 @@ private constructor( */ @JsonProperty("x") @ExcludeMissing fun _x(): JsonField = x + /** + * Returns the raw JSON value of [xCenter]. + * + * Unlike [xCenter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("xCenter") @ExcludeMissing fun _xCenter(): JsonField = xCenter + /** * Returns the raw JSON value of [y]. * @@ -96,6 +153,13 @@ private constructor( */ @JsonProperty("y") @ExcludeMissing fun _y(): JsonField = y + /** + * Returns the raw JSON value of [yCenter]. + * + * Unlike [yCenter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("yCenter") @ExcludeMissing fun _yCenter(): JsonField = yCenter + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -117,22 +181,47 @@ private constructor( /** A builder for [OverlayPosition]. */ class Builder internal constructor() { + private var anchorPoint: JsonField = JsonMissing.of() private var focus: JsonField = JsonMissing.of() private var x: JsonField = JsonMissing.of() + private var xCenter: JsonField = JsonMissing.of() private var y: JsonField = JsonMissing.of() + private var yCenter: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(overlayPosition: OverlayPosition) = apply { + anchorPoint = overlayPosition.anchorPoint focus = overlayPosition.focus x = overlayPosition.x + xCenter = overlayPosition.xCenter y = overlayPosition.y + yCenter = overlayPosition.yCenter additionalProperties = overlayPosition.additionalProperties.toMutableMap() } /** - * Specifies the position of the overlay relative to the parent image or video. Maps to - * `lfo` in the URL. + * Sets the anchor point on the base asset from which the overlay offset is calculated. The + * default value is `top_left`. Maps to `lap` in the URL. Can only be used with one or more + * of `x`, `y`, `xCenter`, or `yCenter`. + */ + fun anchorPoint(anchorPoint: AnchorPoint) = anchorPoint(JsonField.of(anchorPoint)) + + /** + * Sets [Builder.anchorPoint] to an arbitrary JSON value. + * + * You should usually call [Builder.anchorPoint] with a well-typed [AnchorPoint] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun anchorPoint(anchorPoint: JsonField) = apply { + this.anchorPoint = anchorPoint + } + + /** + * Specifies the position of the overlay relative to the parent image or video. If one or + * more of `x`, `y`, `xCenter`, or `yCenter` parameters are specified, this parameter is + * ignored. Maps to `lfo` in the URL. */ fun focus(focus: Focus) = focus(JsonField.of(focus)) @@ -166,6 +255,29 @@ private constructor( /** Alias for calling [x] with `X.ofString(string)`. */ fun x(string: String) = x(X.ofString(string)) + /** + * Specifies the x-coordinate on the base asset where the overlay's center will be + * positioned. It also accepts arithmetic expressions such as `bw_mul_0.4` or `bw_sub_cw`. + * Maps to `lxc` in the URL. Cannot be used together with `x`, but can be used with `y`. + * Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + */ + fun xCenter(xCenter: XCenter) = xCenter(JsonField.of(xCenter)) + + /** + * Sets [Builder.xCenter] to an arbitrary JSON value. + * + * You should usually call [Builder.xCenter] with a well-typed [XCenter] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun xCenter(xCenter: JsonField) = apply { this.xCenter = xCenter } + + /** Alias for calling [xCenter] with `XCenter.ofNumber(number)`. */ + fun xCenter(number: Double) = xCenter(XCenter.ofNumber(number)) + + /** Alias for calling [xCenter] with `XCenter.ofString(string)`. */ + fun xCenter(string: String) = xCenter(XCenter.ofString(string)) + /** * Specifies the y-coordinate of the top-left corner of the base asset where the overlay's * top-left corner will be positioned. It also accepts arithmetic expressions such as @@ -188,6 +300,29 @@ private constructor( /** Alias for calling [y] with `Y.ofString(string)`. */ fun y(string: String) = y(Y.ofString(string)) + /** + * Specifies the y-coordinate on the base asset where the overlay's center will be + * positioned. It also accepts arithmetic expressions such as `bh_mul_0.4` or `bh_sub_ch`. + * Maps to `lyc` in the URL. Cannot be used together with `y`, but can be used with `x`. + * Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + */ + fun yCenter(yCenter: YCenter) = yCenter(JsonField.of(yCenter)) + + /** + * Sets [Builder.yCenter] to an arbitrary JSON value. + * + * You should usually call [Builder.yCenter] with a well-typed [YCenter] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun yCenter(yCenter: JsonField) = apply { this.yCenter = yCenter } + + /** Alias for calling [yCenter] with `YCenter.ofNumber(number)`. */ + fun yCenter(number: Double) = yCenter(YCenter.ofNumber(number)) + + /** Alias for calling [yCenter] with `YCenter.ofString(string)`. */ + fun yCenter(string: String) = yCenter(YCenter.ofString(string)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -213,7 +348,15 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): OverlayPosition = - OverlayPosition(focus, x, y, additionalProperties.toMutableMap()) + OverlayPosition( + anchorPoint, + focus, + x, + xCenter, + y, + yCenter, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -223,9 +366,12 @@ private constructor( return@apply } + anchorPoint().ifPresent { it.validate() } focus().ifPresent { it.validate() } x().ifPresent { it.validate() } + xCenter().ifPresent { it.validate() } y().ifPresent { it.validate() } + yCenter().ifPresent { it.validate() } validated = true } @@ -244,13 +390,194 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (focus.asKnown().getOrNull()?.validity() ?: 0) + + (anchorPoint.asKnown().getOrNull()?.validity() ?: 0) + + (focus.asKnown().getOrNull()?.validity() ?: 0) + (x.asKnown().getOrNull()?.validity() ?: 0) + - (y.asKnown().getOrNull()?.validity() ?: 0) + (xCenter.asKnown().getOrNull()?.validity() ?: 0) + + (y.asKnown().getOrNull()?.validity() ?: 0) + + (yCenter.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Sets the anchor point on the base asset from which the overlay offset is calculated. The + * default value is `top_left`. Maps to `lap` in the URL. Can only be used with one or more of + * `x`, `y`, `xCenter`, or `yCenter`. + */ + class AnchorPoint @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TOP = of("top") + + @JvmField val LEFT = of("left") + + @JvmField val RIGHT = of("right") + + @JvmField val BOTTOM = of("bottom") + + @JvmField val TOP_LEFT = of("top_left") + + @JvmField val TOP_RIGHT = of("top_right") + + @JvmField val BOTTOM_LEFT = of("bottom_left") + + @JvmField val BOTTOM_RIGHT = of("bottom_right") + + @JvmField val CENTER = of("center") + + @JvmStatic fun of(value: String) = AnchorPoint(JsonField.of(value)) + } + + /** An enum containing [AnchorPoint]'s known values. */ + enum class Known { + TOP, + LEFT, + RIGHT, + BOTTOM, + TOP_LEFT, + TOP_RIGHT, + BOTTOM_LEFT, + BOTTOM_RIGHT, + CENTER, + } + + /** + * An enum containing [AnchorPoint]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AnchorPoint] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TOP, + LEFT, + RIGHT, + BOTTOM, + TOP_LEFT, + TOP_RIGHT, + BOTTOM_LEFT, + BOTTOM_RIGHT, + CENTER, + /** + * An enum member indicating that [AnchorPoint] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TOP -> Value.TOP + LEFT -> Value.LEFT + RIGHT -> Value.RIGHT + BOTTOM -> Value.BOTTOM + TOP_LEFT -> Value.TOP_LEFT + TOP_RIGHT -> Value.TOP_RIGHT + BOTTOM_LEFT -> Value.BOTTOM_LEFT + BOTTOM_RIGHT -> Value.BOTTOM_RIGHT + CENTER -> Value.CENTER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TOP -> Known.TOP + LEFT -> Known.LEFT + RIGHT -> Known.RIGHT + BOTTOM -> Known.BOTTOM + TOP_LEFT -> Known.TOP_LEFT + TOP_RIGHT -> Known.TOP_RIGHT + BOTTOM_LEFT -> Known.BOTTOM_LEFT + BOTTOM_RIGHT -> Known.BOTTOM_RIGHT + CENTER -> Known.CENTER + else -> throw ImageKitInvalidDataException("Unknown AnchorPoint: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AnchorPoint = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnchorPoint && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } /** - * Specifies the position of the overlay relative to the parent image or video. Maps to `lfo` in - * the URL. + * Specifies the position of the overlay relative to the parent image or video. If one or more + * of `x`, `y`, `xCenter`, or `yCenter` parameters are specified, this parameter is ignored. + * Maps to `lfo` in the URL. */ class Focus @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -594,14 +921,14 @@ private constructor( } /** - * Specifies the y-coordinate of the top-left corner of the base asset where the overlay's - * top-left corner will be positioned. It also accepts arithmetic expressions such as - * `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn about + * Specifies the x-coordinate on the base asset where the overlay's center will be positioned. + * It also accepts arithmetic expressions such as `bw_mul_0.4` or `bw_sub_cw`. Maps to `lxc` in + * the URL. Cannot be used together with `x`, but can be used with `y`. Learn about * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). */ - @JsonDeserialize(using = Y.Deserializer::class) - @JsonSerialize(using = Y.Serializer::class) - class Y + @JsonDeserialize(using = XCenter.Deserializer::class) + @JsonSerialize(using = XCenter.Serializer::class) + class XCenter private constructor( private val number: Double? = null, private val string: String? = null, @@ -631,7 +958,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Y = apply { + fun validate(): XCenter = apply { if (validated) { return@apply } @@ -677,27 +1004,29 @@ private constructor( return true } - return other is Y && number == other.number && string == other.string + return other is XCenter && number == other.number && string == other.string } override fun hashCode(): Int = Objects.hash(number, string) override fun toString(): String = when { - number != null -> "Y{number=$number}" - string != null -> "Y{string=$string}" - _json != null -> "Y{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Y") + number != null -> "XCenter{number=$number}" + string != null -> "XCenter{string=$string}" + _json != null -> "XCenter{_unknown=$_json}" + else -> throw IllegalStateException("Invalid XCenter") } companion object { - @JvmStatic fun ofNumber(number: Double) = Y(number = number) + @JvmStatic fun ofNumber(number: Double) = XCenter(number = number) - @JvmStatic fun ofString(string: String) = Y(string = string) + @JvmStatic fun ofString(string: String) = XCenter(string = string) } - /** An interface that defines how to map each variant of [Y] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [XCenter] to a value of type [T]. + */ interface Visitor { fun visitNumber(number: Double): T @@ -705,31 +1034,32 @@ private constructor( fun visitString(string: String): T /** - * Maps an unknown variant of [Y] to a value of type [T]. + * Maps an unknown variant of [XCenter] to a value of type [T]. * - * An instance of [Y] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [XCenter] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. * * @throws ImageKitInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Y: $json") + throw ImageKitInvalidDataException("Unknown XCenter: $json") } } - internal class Deserializer : BaseDeserializer(Y::class) { + internal class Deserializer : BaseDeserializer(XCenter::class) { - override fun ObjectCodec.deserialize(node: JsonNode): Y { + override fun ObjectCodec.deserialize(node: JsonNode): XCenter { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - Y(string = it, _json = json) + XCenter(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - Y(number = it, _json = json) + XCenter(number = it, _json = json) }, ) .filterNotNull() @@ -738,7 +1068,7 @@ private constructor( return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with // all the possible variants (e.g. deserializing from boolean). - 0 -> Y(_json = json) + 0 -> XCenter(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first // completely valid match, or simply the first match if none are completely @@ -748,7 +1078,179 @@ private constructor( } } - internal class Serializer : BaseSerializer(Y::class) { + internal class Serializer : BaseSerializer(XCenter::class) { + + override fun serialize( + value: XCenter, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid XCenter") + } + } + } + } + + /** + * Specifies the y-coordinate of the top-left corner of the base asset where the overlay's + * top-left corner will be positioned. It also accepts arithmetic expressions such as + * `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + */ + @JsonDeserialize(using = Y.Deserializer::class) + @JsonSerialize(using = Y.Serializer::class) + class Y + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Y = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Y && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "Y{number=$number}" + string != null -> "Y{string=$string}" + _json != null -> "Y{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Y") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Y(number = number) + + @JvmStatic fun ofString(string: String) = Y(string = string) + } + + /** An interface that defines how to map each variant of [Y] to a value of type [T]. */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Y] to a value of type [T]. + * + * An instance of [Y] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Y: $json") + } + } + + internal class Deserializer : BaseDeserializer(Y::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Y { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Y(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Y(number = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Y(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Y::class) { override fun serialize( value: Y, @@ -765,22 +1267,202 @@ private constructor( } } + /** + * Specifies the y-coordinate on the base asset where the overlay's center will be positioned. + * It also accepts arithmetic expressions such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `lyc` in + * the URL. Cannot be used together with `y`, but can be used with `x`. Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + */ + @JsonDeserialize(using = YCenter.Deserializer::class) + @JsonSerialize(using = YCenter.Serializer::class) + class YCenter + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): YCenter = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is YCenter && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "YCenter{number=$number}" + string != null -> "YCenter{string=$string}" + _json != null -> "YCenter{_unknown=$_json}" + else -> throw IllegalStateException("Invalid YCenter") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = YCenter(number = number) + + @JvmStatic fun ofString(string: String) = YCenter(string = string) + } + + /** + * An interface that defines how to map each variant of [YCenter] to a value of type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [YCenter] to a value of type [T]. + * + * An instance of [YCenter] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown YCenter: $json") + } + } + + internal class Deserializer : BaseDeserializer(YCenter::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): YCenter { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + YCenter(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + YCenter(number = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> YCenter(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(YCenter::class) { + + override fun serialize( + value: YCenter, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid YCenter") + } + } + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } return other is OverlayPosition && + anchorPoint == other.anchorPoint && focus == other.focus && x == other.x && + xCenter == other.xCenter && y == other.y && + yCenter == other.yCenter && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(focus, x, y, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(anchorPoint, focus, x, xCenter, y, yCenter, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "OverlayPosition{focus=$focus, x=$x, y=$y, additionalProperties=$additionalProperties}" + "OverlayPosition{anchorPoint=$anchorPoint, focus=$focus, x=$x, xCenter=$xCenter, y=$y, yCenter=$yCenter, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt index 9e52f25b..43895867 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt @@ -3811,8 +3811,10 @@ private constructor( minSelections.getOptional("min_selections") /** - * Array of possible tag values. Combined length of all strings must not exceed - * 500 characters. Cannot contain the `%` character. + * Array of possible tag values. The combined length of all strings must not + * exceed 500 characters, and values cannot include the `%` character. When + * providing large vocabularies (more than 30 items), the AI may not follow the + * list strictly. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -3965,8 +3967,10 @@ private constructor( } /** - * Array of possible tag values. Combined length of all strings must not - * exceed 500 characters. Cannot contain the `%` character. + * Array of possible tag values. The combined length of all strings must not + * exceed 500 characters, and values cannot include the `%` character. When + * providing large vocabularies (more than 30 items), the AI may not follow + * the list strictly. */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) @@ -4163,7 +4167,10 @@ private constructor( minSelections.getOptional("min_selections") /** - * Array of possible values matching the custom metadata field type. + * An array of possible values matching the custom metadata field type. If not + * provided for SingleSelect or MultiSelect field types, all values from the + * custom metadata field definition will be used. When providing large + * vocabularies (above 30 items), the AI may not strictly adhere to the list. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -4344,7 +4351,13 @@ private constructor( this.minSelections = minSelections } - /** Array of possible values matching the custom metadata field type. */ + /** + * An array of possible values matching the custom metadata field type. If + * not provided for SingleSelect or MultiSelect field types, all values from + * the custom metadata field definition will be used. When providing large + * vocabularies (above 30 items), the AI may not strictly adhere to the + * list. + */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt index a188bdb5..7d9abc94 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -4077,8 +4077,10 @@ private constructor( minSelections.getOptional("min_selections") /** - * Array of possible tag values. Combined length of all strings must not exceed - * 500 characters. Cannot contain the `%` character. + * Array of possible tag values. The combined length of all strings must not + * exceed 500 characters, and values cannot include the `%` character. When + * providing large vocabularies (more than 30 items), the AI may not follow the + * list strictly. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -4231,8 +4233,10 @@ private constructor( } /** - * Array of possible tag values. Combined length of all strings must not - * exceed 500 characters. Cannot contain the `%` character. + * Array of possible tag values. The combined length of all strings must not + * exceed 500 characters, and values cannot include the `%` character. When + * providing large vocabularies (more than 30 items), the AI may not follow + * the list strictly. */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) @@ -4429,7 +4433,10 @@ private constructor( minSelections.getOptional("min_selections") /** - * Array of possible values matching the custom metadata field type. + * An array of possible values matching the custom metadata field type. If not + * provided for SingleSelect or MultiSelect field types, all values from the + * custom metadata field definition will be used. When providing large + * vocabularies (above 30 items), the AI may not strictly adhere to the list. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -4610,7 +4617,13 @@ private constructor( this.minSelections = minSelections } - /** Array of possible values matching the custom metadata field type. */ + /** + * An array of possible values matching the custom metadata field type. If + * not provided for SingleSelect or MultiSelect field types, all values from + * the custom metadata field definition will be used. When providing large + * vocabularies (above 30 items), the AI may not strictly adhere to the + * list. + */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt index 888c2852..b61f39f0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt @@ -2558,8 +2558,10 @@ private constructor( minSelections.getOptional("min_selections") /** - * Array of possible tag values. Combined length of all strings must not - * exceed 500 characters. Cannot contain the `%` character. + * Array of possible tag values. The combined length of all strings must not + * exceed 500 characters, and values cannot include the `%` character. When + * providing large vocabularies (more than 30 items), the AI may not follow + * the list strictly. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). @@ -2715,8 +2717,10 @@ private constructor( } /** - * Array of possible tag values. Combined length of all strings must not - * exceed 500 characters. Cannot contain the `%` character. + * Array of possible tag values. The combined length of all strings must + * not exceed 500 characters, and values cannot include the `%` + * character. When providing large vocabularies (more than 30 items), + * the AI may not follow the list strictly. */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) @@ -2959,7 +2963,11 @@ private constructor( minSelections.getOptional("min_selections") /** - * Array of possible values matching the custom metadata field type. + * An array of possible values matching the custom metadata field type. If + * not provided for SingleSelect or MultiSelect field types, all values from + * the custom metadata field definition will be used. When providing large + * vocabularies (above 30 items), the AI may not strictly adhere to the + * list. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). @@ -3142,7 +3150,13 @@ private constructor( this.minSelections = minSelections } - /** Array of possible values matching the custom metadata field type. */ + /** + * An array of possible values matching the custom metadata field type. + * If not provided for SingleSelect or MultiSelect field types, all + * values from the custom metadata field definition will be used. When + * providing large vocabularies (above 30 items), the AI may not + * strictly adhere to the list. + */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt index 062380b7..4955f427 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt @@ -16,9 +16,12 @@ internal class BaseOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -27,7 +30,14 @@ internal class BaseOverlayTest { assertThat(baseOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(baseOverlay.position()) .contains( - OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .build() ) assertThat(baseOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -41,9 +51,12 @@ internal class BaseOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt index 161d626e..71e02e02 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt @@ -65,9 +65,12 @@ internal class GetImageAttributesOptionsTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -182,9 +185,12 @@ internal class GetImageAttributesOptionsTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -297,9 +303,12 @@ internal class GetImageAttributesOptionsTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt index ea386f83..f6866ef5 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt @@ -17,9 +17,12 @@ internal class ImageOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -66,9 +69,12 @@ internal class ImageOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -127,7 +133,14 @@ internal class ImageOverlayTest { assertThat(imageOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(imageOverlay.position()) .contains( - OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .build() ) assertThat(imageOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -175,9 +188,12 @@ internal class ImageOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -235,9 +251,12 @@ internal class ImageOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -284,9 +303,12 @@ internal class ImageOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayPositionTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayPositionTest.kt index a39aa652..3d474c62 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayPositionTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayPositionTest.kt @@ -12,18 +12,35 @@ internal class OverlayPositionTest { @Test fun create() { val overlayPosition = - OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() - + OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .build() + + assertThat(overlayPosition.anchorPoint()).contains(OverlayPosition.AnchorPoint.TOP) assertThat(overlayPosition.focus()).contains(OverlayPosition.Focus.CENTER) assertThat(overlayPosition.x()).contains(OverlayPosition.X.ofNumber(0.0)) + assertThat(overlayPosition.xCenter()).contains(OverlayPosition.XCenter.ofNumber(0.0)) assertThat(overlayPosition.y()).contains(OverlayPosition.Y.ofNumber(0.0)) + assertThat(overlayPosition.yCenter()).contains(OverlayPosition.YCenter.ofNumber(0.0)) } @Test fun roundtrip() { val jsonMapper = jsonMapper() val overlayPosition = - OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .build() val roundtrippedOverlayPosition = jsonMapper.readValue( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt index 47c32e03..cc0a81b5 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt @@ -21,9 +21,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -66,9 +69,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -107,9 +113,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -156,9 +165,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -232,9 +244,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -283,9 +298,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -355,9 +373,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -404,9 +425,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -480,9 +504,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -531,9 +558,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -603,9 +633,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -642,9 +675,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -677,9 +713,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -714,9 +753,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt index 27cae13f..a53b4de6 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt @@ -17,9 +17,12 @@ internal class SolidColorOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -39,7 +42,14 @@ internal class SolidColorOverlayTest { assertThat(solidColorOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(solidColorOverlay.position()) .contains( - OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .build() ) assertThat(solidColorOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -65,9 +75,12 @@ internal class SolidColorOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt index 4589be89..5e6f2a29 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt @@ -65,9 +65,12 @@ internal class SrcOptionsTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -176,9 +179,12 @@ internal class SrcOptionsTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -284,9 +290,12 @@ internal class SrcOptionsTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt index 35aea254..be605a48 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt @@ -17,9 +17,12 @@ internal class SubtitleOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -41,7 +44,14 @@ internal class SubtitleOverlayTest { assertThat(subtitleOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(subtitleOverlay.position()) .contains( - OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .build() ) assertThat(subtitleOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -69,9 +79,12 @@ internal class SubtitleOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt index 841a72dd..8227d262 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt @@ -17,9 +17,12 @@ internal class TextOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -47,7 +50,14 @@ internal class TextOverlayTest { assertThat(textOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(textOverlay.position()) .contains( - OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .build() ) assertThat(textOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -81,9 +91,12 @@ internal class TextOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt index 09bf721f..b27f75bd 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt @@ -53,9 +53,12 @@ internal class TransformationTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -145,9 +148,12 @@ internal class TransformationTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -239,9 +245,12 @@ internal class TransformationTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt index 19e48b9d..50cb287d 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt @@ -17,9 +17,12 @@ internal class VideoOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -66,9 +69,12 @@ internal class VideoOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -127,7 +133,14 @@ internal class VideoOverlayTest { assertThat(videoOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(videoOverlay.position()) .contains( - OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .build() ) assertThat(videoOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -175,9 +188,12 @@ internal class VideoOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -235,9 +251,12 @@ internal class VideoOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -284,9 +303,12 @@ internal class VideoOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( From 8352cbaa2184947c142175d475c2cc06c9e9f57f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 06:07:48 +0000 Subject: [PATCH 123/142] feat(api): dam related webhook events --- .stats.yml | 6 +- README.md | 1 - .../api/client/okhttp/OkHttpClient.kt | 4 +- .../com/imagekit/api/core/ClientOptions.kt | 11 - .../imagekit/api/models/ExtensionConfig.kt | 23 +- .../imagekit/api/models/OverlayPosition.kt | 758 +----------------- .../models/beta/v2/files/FileUploadParams.kt | 25 +- .../api/models/files/FileUploadParams.kt | 25 +- .../api/models/files/UpdateFileRequest.kt | 26 +- .../api/models/webhooks/DamFileCreateEvent.kt | 297 +++++++ .../api/models/webhooks/DamFileDeleteEvent.kt | 448 +++++++++++ .../api/models/webhooks/DamFileUpdateEvent.kt | 297 +++++++ .../webhooks/DamFileVersionCreateEvent.kt | 277 +++++++ .../webhooks/DamFileVersionDeleteEvent.kt | 493 ++++++++++++ .../webhooks/UnsafeUnwrapWebhookEvent.kt | 176 +++- .../api/models/webhooks/UnwrapWebhookEvent.kt | 176 +++- .../imagekit/api/core/ClientOptionsTest.kt | 27 +- .../imagekit/api/models/BaseOverlayTest.kt | 15 +- .../models/GetImageAttributesOptionsTest.kt | 9 - .../imagekit/api/models/ImageOverlayTest.kt | 24 +- .../api/models/OverlayPositionTest.kt | 23 +- .../com/imagekit/api/models/OverlayTest.kt | 42 - .../api/models/SolidColorOverlayTest.kt | 15 +- .../com/imagekit/api/models/SrcOptionsTest.kt | 9 - .../api/models/SubtitleOverlayTest.kt | 15 +- .../imagekit/api/models/TextOverlayTest.kt | 15 +- .../imagekit/api/models/TransformationTest.kt | 9 - .../imagekit/api/models/VideoOverlayTest.kt | 24 +- .../models/webhooks/DamFileCreateEventTest.kt | 246 ++++++ .../models/webhooks/DamFileDeleteEventTest.kt | 50 ++ .../models/webhooks/DamFileUpdateEventTest.kt | 246 ++++++ .../webhooks/DamFileVersionCreateEventTest.kt | 51 ++ .../webhooks/DamFileVersionDeleteEventTest.kt | 65 ++ .../webhooks/UnsafeUnwrapWebhookEventTest.kt | 566 +++++++++++++ .../models/webhooks/UnwrapWebhookEventTest.kt | 564 +++++++++++++ .../api/services/ErrorHandlingTest.kt | 1 - .../api/services/ServiceParamsTest.kt | 1 - .../services/async/AssetServiceAsyncTest.kt | 6 +- .../CustomMetadataFieldServiceAsyncTest.kt | 24 +- .../services/async/FileServiceAsyncTest.kt | 42 +- .../services/async/FolderServiceAsyncTest.kt | 30 +- .../async/SavedExtensionServiceAsyncTest.kt | 30 +- .../services/async/WebhookServiceAsyncTest.kt | 12 +- .../async/accounts/OriginServiceAsyncTest.kt | 30 +- .../accounts/UrlEndpointServiceAsyncTest.kt | 30 +- .../async/accounts/UsageServiceAsyncTest.kt | 6 +- .../async/beta/v2/FileServiceAsyncTest.kt | 6 +- .../cache/InvalidationServiceAsyncTest.kt | 12 +- .../async/files/BulkServiceAsyncTest.kt | 24 +- .../async/files/MetadataServiceAsyncTest.kt | 12 +- .../async/files/VersionServiceAsyncTest.kt | 24 +- .../async/folders/JobServiceAsyncTest.kt | 6 +- .../api/services/blocking/AssetServiceTest.kt | 6 +- .../CustomMetadataFieldServiceTest.kt | 24 +- .../api/services/blocking/FileServiceTest.kt | 42 +- .../services/blocking/FolderServiceTest.kt | 30 +- .../blocking/SavedExtensionServiceTest.kt | 30 +- .../services/blocking/WebhookServiceTest.kt | 12 +- .../blocking/accounts/OriginServiceTest.kt | 30 +- .../accounts/UrlEndpointServiceTest.kt | 30 +- .../blocking/accounts/UsageServiceTest.kt | 6 +- .../blocking/beta/v2/FileServiceTest.kt | 6 +- .../blocking/cache/InvalidationServiceTest.kt | 12 +- .../blocking/files/BulkServiceTest.kt | 24 +- .../blocking/files/MetadataServiceTest.kt | 12 +- .../blocking/files/VersionServiceTest.kt | 24 +- .../blocking/folders/JobServiceTest.kt | 6 +- .../api/proguard/ProGuardCompatibilityTest.kt | 6 +- 68 files changed, 4125 insertions(+), 1529 deletions(-) create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileCreateEvent.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileDeleteEvent.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileUpdateEvent.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEvent.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileVersionDeleteEvent.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileCreateEventTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileDeleteEventTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileUpdateEventTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEventTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileVersionDeleteEventTest.kt diff --git a/.stats.yml b/.stats.yml index df5aafb6..3e331fe9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-63aff1629530786015da3c86131afa8a9b60545d488884b77641f1d4b89c6e9d.yml -openapi_spec_hash: 586d357bd7e5217d240a99e0d83c6d1f -config_hash: 47cb702ee2cb52c58d803ae39ade9b44 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-1422f7513f230162270b197061e5768c2e0c803b94b8cd03a5e72544ac75a27f.yml +openapi_spec_hash: 41175e752e6f6ce900b36aecba687fa7 +config_hash: 17e408231b0b01676298010c7405f483 diff --git a/README.md b/README.md index a7b10f6c..bceef44c 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,6 @@ import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; ImageKitClient client = ImageKitOkHttpClient.builder() .privateKey("My Private Key") - .password("My Password") .build(); ``` diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt index b9b0e81d..708f2bc9 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt @@ -94,9 +94,7 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie else -> null } if (logLevel != null) { - clientBuilder.addNetworkInterceptor( - HttpLoggingInterceptor().setLevel(logLevel).apply { redactHeader("Authorization") } - ) + clientBuilder.addNetworkInterceptor(HttpLoggingInterceptor().setLevel(logLevel)) } requestOptions.timeout?.let { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt index bfd06a44..ec994183 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt @@ -10,7 +10,6 @@ import com.imagekit.api.core.http.QueryParams import com.imagekit.api.core.http.RetryingHttpClient import java.time.Clock import java.time.Duration -import java.util.Base64 import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -469,16 +468,6 @@ private constructor( // We replace after all the default headers to allow end-users to overwrite them. headers.replaceAll(this.headers.build()) queryParams.replaceAll(this.queryParams.build()) - privateKey.let { username -> - password?.let { password -> - if (!username.isEmpty() && !password.isEmpty()) { - headers.replace( - "Authorization", - "Basic ${Base64.getEncoder().encodeToString("$username:$password".toByteArray())}", - ) - } - } - } return ClientOptions( httpClient, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt index fce20326..89692a98 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt @@ -1613,9 +1613,8 @@ private constructor( fun minSelections(): Optional = minSelections.getOptional("min_selections") /** - * Array of possible tag values. The combined length of all strings must not exceed - * 500 characters, and values cannot include the `%` character. When providing large - * vocabularies (more than 30 items), the AI may not follow the list strictly. + * Array of possible tag values. Combined length of all strings must not exceed 500 + * characters. Cannot contain the `%` character. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -1766,10 +1765,8 @@ private constructor( } /** - * Array of possible tag values. The combined length of all strings must not - * exceed 500 characters, and values cannot include the `%` character. When - * providing large vocabularies (more than 30 items), the AI may not follow the - * list strictly. + * Array of possible tag values. Combined length of all strings must not exceed + * 500 characters. Cannot contain the `%` character. */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) @@ -2002,10 +1999,7 @@ private constructor( fun minSelections(): Optional = minSelections.getOptional("min_selections") /** - * An array of possible values matching the custom metadata field type. If not - * provided for SingleSelect or MultiSelect field types, all values from the custom - * metadata field definition will be used. When providing large vocabularies (above - * 30 items), the AI may not strictly adhere to the list. + * Array of possible values matching the custom metadata field type. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -2181,12 +2175,7 @@ private constructor( this.minSelections = minSelections } - /** - * An array of possible values matching the custom metadata field type. If not - * provided for SingleSelect or MultiSelect field types, all values from the - * custom metadata field definition will be used. When providing large - * vocabularies (above 30 items), the AI may not strictly adhere to the list. - */ + /** Array of possible values matching the custom metadata field type. */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt index 9baf1c6c..020f99a5 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt @@ -31,41 +31,22 @@ import kotlin.jvm.optionals.getOrNull class OverlayPosition @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val anchorPoint: JsonField, private val focus: JsonField, private val x: JsonField, - private val xCenter: JsonField, private val y: JsonField, - private val yCenter: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("anchorPoint") - @ExcludeMissing - anchorPoint: JsonField = JsonMissing.of(), @JsonProperty("focus") @ExcludeMissing focus: JsonField = JsonMissing.of(), @JsonProperty("x") @ExcludeMissing x: JsonField = JsonMissing.of(), - @JsonProperty("xCenter") @ExcludeMissing xCenter: JsonField = JsonMissing.of(), @JsonProperty("y") @ExcludeMissing y: JsonField = JsonMissing.of(), - @JsonProperty("yCenter") @ExcludeMissing yCenter: JsonField = JsonMissing.of(), - ) : this(anchorPoint, focus, x, xCenter, y, yCenter, mutableMapOf()) + ) : this(focus, x, y, mutableMapOf()) /** - * Sets the anchor point on the base asset from which the overlay offset is calculated. The - * default value is `top_left`. Maps to `lap` in the URL. Can only be used with one or more of - * `x`, `y`, `xCenter`, or `yCenter`. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun anchorPoint(): Optional = anchorPoint.getOptional("anchorPoint") - - /** - * Specifies the position of the overlay relative to the parent image or video. If one or more - * of `x`, `y`, `xCenter`, or `yCenter` parameters are specified, this parameter is ignored. - * Maps to `lfo` in the URL. + * Specifies the position of the overlay relative to the parent image or video. Maps to `lfo` in + * the URL. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -83,17 +64,6 @@ private constructor( */ fun x(): Optional = x.getOptional("x") - /** - * Specifies the x-coordinate on the base asset where the overlay's center will be positioned. - * It also accepts arithmetic expressions such as `bw_mul_0.4` or `bw_sub_cw`. Maps to `lxc` in - * the URL. Cannot be used together with `x`, but can be used with `y`. Learn about - * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun xCenter(): Optional = xCenter.getOptional("xCenter") - /** * Specifies the y-coordinate of the top-left corner of the base asset where the overlay's * top-left corner will be positioned. It also accepts arithmetic expressions such as @@ -105,26 +75,6 @@ private constructor( */ fun y(): Optional = y.getOptional("y") - /** - * Specifies the y-coordinate on the base asset where the overlay's center will be positioned. - * It also accepts arithmetic expressions such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `lyc` in - * the URL. Cannot be used together with `y`, but can be used with `x`. Learn about - * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun yCenter(): Optional = yCenter.getOptional("yCenter") - - /** - * Returns the raw JSON value of [anchorPoint]. - * - * Unlike [anchorPoint], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("anchorPoint") - @ExcludeMissing - fun _anchorPoint(): JsonField = anchorPoint - /** * Returns the raw JSON value of [focus]. * @@ -139,13 +89,6 @@ private constructor( */ @JsonProperty("x") @ExcludeMissing fun _x(): JsonField = x - /** - * Returns the raw JSON value of [xCenter]. - * - * Unlike [xCenter], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("xCenter") @ExcludeMissing fun _xCenter(): JsonField = xCenter - /** * Returns the raw JSON value of [y]. * @@ -153,13 +96,6 @@ private constructor( */ @JsonProperty("y") @ExcludeMissing fun _y(): JsonField = y - /** - * Returns the raw JSON value of [yCenter]. - * - * Unlike [yCenter], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("yCenter") @ExcludeMissing fun _yCenter(): JsonField = yCenter - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -181,47 +117,22 @@ private constructor( /** A builder for [OverlayPosition]. */ class Builder internal constructor() { - private var anchorPoint: JsonField = JsonMissing.of() private var focus: JsonField = JsonMissing.of() private var x: JsonField = JsonMissing.of() - private var xCenter: JsonField = JsonMissing.of() private var y: JsonField = JsonMissing.of() - private var yCenter: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(overlayPosition: OverlayPosition) = apply { - anchorPoint = overlayPosition.anchorPoint focus = overlayPosition.focus x = overlayPosition.x - xCenter = overlayPosition.xCenter y = overlayPosition.y - yCenter = overlayPosition.yCenter additionalProperties = overlayPosition.additionalProperties.toMutableMap() } /** - * Sets the anchor point on the base asset from which the overlay offset is calculated. The - * default value is `top_left`. Maps to `lap` in the URL. Can only be used with one or more - * of `x`, `y`, `xCenter`, or `yCenter`. - */ - fun anchorPoint(anchorPoint: AnchorPoint) = anchorPoint(JsonField.of(anchorPoint)) - - /** - * Sets [Builder.anchorPoint] to an arbitrary JSON value. - * - * You should usually call [Builder.anchorPoint] with a well-typed [AnchorPoint] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun anchorPoint(anchorPoint: JsonField) = apply { - this.anchorPoint = anchorPoint - } - - /** - * Specifies the position of the overlay relative to the parent image or video. If one or - * more of `x`, `y`, `xCenter`, or `yCenter` parameters are specified, this parameter is - * ignored. Maps to `lfo` in the URL. + * Specifies the position of the overlay relative to the parent image or video. Maps to + * `lfo` in the URL. */ fun focus(focus: Focus) = focus(JsonField.of(focus)) @@ -255,29 +166,6 @@ private constructor( /** Alias for calling [x] with `X.ofString(string)`. */ fun x(string: String) = x(X.ofString(string)) - /** - * Specifies the x-coordinate on the base asset where the overlay's center will be - * positioned. It also accepts arithmetic expressions such as `bw_mul_0.4` or `bw_sub_cw`. - * Maps to `lxc` in the URL. Cannot be used together with `x`, but can be used with `y`. - * Learn about - * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). - */ - fun xCenter(xCenter: XCenter) = xCenter(JsonField.of(xCenter)) - - /** - * Sets [Builder.xCenter] to an arbitrary JSON value. - * - * You should usually call [Builder.xCenter] with a well-typed [XCenter] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun xCenter(xCenter: JsonField) = apply { this.xCenter = xCenter } - - /** Alias for calling [xCenter] with `XCenter.ofNumber(number)`. */ - fun xCenter(number: Double) = xCenter(XCenter.ofNumber(number)) - - /** Alias for calling [xCenter] with `XCenter.ofString(string)`. */ - fun xCenter(string: String) = xCenter(XCenter.ofString(string)) - /** * Specifies the y-coordinate of the top-left corner of the base asset where the overlay's * top-left corner will be positioned. It also accepts arithmetic expressions such as @@ -300,29 +188,6 @@ private constructor( /** Alias for calling [y] with `Y.ofString(string)`. */ fun y(string: String) = y(Y.ofString(string)) - /** - * Specifies the y-coordinate on the base asset where the overlay's center will be - * positioned. It also accepts arithmetic expressions such as `bh_mul_0.4` or `bh_sub_ch`. - * Maps to `lyc` in the URL. Cannot be used together with `y`, but can be used with `x`. - * Learn about - * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). - */ - fun yCenter(yCenter: YCenter) = yCenter(JsonField.of(yCenter)) - - /** - * Sets [Builder.yCenter] to an arbitrary JSON value. - * - * You should usually call [Builder.yCenter] with a well-typed [YCenter] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun yCenter(yCenter: JsonField) = apply { this.yCenter = yCenter } - - /** Alias for calling [yCenter] with `YCenter.ofNumber(number)`. */ - fun yCenter(number: Double) = yCenter(YCenter.ofNumber(number)) - - /** Alias for calling [yCenter] with `YCenter.ofString(string)`. */ - fun yCenter(string: String) = yCenter(YCenter.ofString(string)) - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -348,15 +213,7 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): OverlayPosition = - OverlayPosition( - anchorPoint, - focus, - x, - xCenter, - y, - yCenter, - additionalProperties.toMutableMap(), - ) + OverlayPosition(focus, x, y, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -366,12 +223,9 @@ private constructor( return@apply } - anchorPoint().ifPresent { it.validate() } focus().ifPresent { it.validate() } x().ifPresent { it.validate() } - xCenter().ifPresent { it.validate() } y().ifPresent { it.validate() } - yCenter().ifPresent { it.validate() } validated = true } @@ -390,194 +244,13 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (anchorPoint.asKnown().getOrNull()?.validity() ?: 0) + - (focus.asKnown().getOrNull()?.validity() ?: 0) + + (focus.asKnown().getOrNull()?.validity() ?: 0) + (x.asKnown().getOrNull()?.validity() ?: 0) + - (xCenter.asKnown().getOrNull()?.validity() ?: 0) + - (y.asKnown().getOrNull()?.validity() ?: 0) + - (yCenter.asKnown().getOrNull()?.validity() ?: 0) - - /** - * Sets the anchor point on the base asset from which the overlay offset is calculated. The - * default value is `top_left`. Maps to `lap` in the URL. Can only be used with one or more of - * `x`, `y`, `xCenter`, or `yCenter`. - */ - class AnchorPoint @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TOP = of("top") - - @JvmField val LEFT = of("left") - - @JvmField val RIGHT = of("right") - - @JvmField val BOTTOM = of("bottom") - - @JvmField val TOP_LEFT = of("top_left") - - @JvmField val TOP_RIGHT = of("top_right") - - @JvmField val BOTTOM_LEFT = of("bottom_left") - - @JvmField val BOTTOM_RIGHT = of("bottom_right") - - @JvmField val CENTER = of("center") - - @JvmStatic fun of(value: String) = AnchorPoint(JsonField.of(value)) - } - - /** An enum containing [AnchorPoint]'s known values. */ - enum class Known { - TOP, - LEFT, - RIGHT, - BOTTOM, - TOP_LEFT, - TOP_RIGHT, - BOTTOM_LEFT, - BOTTOM_RIGHT, - CENTER, - } - - /** - * An enum containing [AnchorPoint]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [AnchorPoint] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TOP, - LEFT, - RIGHT, - BOTTOM, - TOP_LEFT, - TOP_RIGHT, - BOTTOM_LEFT, - BOTTOM_RIGHT, - CENTER, - /** - * An enum member indicating that [AnchorPoint] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TOP -> Value.TOP - LEFT -> Value.LEFT - RIGHT -> Value.RIGHT - BOTTOM -> Value.BOTTOM - TOP_LEFT -> Value.TOP_LEFT - TOP_RIGHT -> Value.TOP_RIGHT - BOTTOM_LEFT -> Value.BOTTOM_LEFT - BOTTOM_RIGHT -> Value.BOTTOM_RIGHT - CENTER -> Value.CENTER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TOP -> Known.TOP - LEFT -> Known.LEFT - RIGHT -> Known.RIGHT - BOTTOM -> Known.BOTTOM - TOP_LEFT -> Known.TOP_LEFT - TOP_RIGHT -> Known.TOP_RIGHT - BOTTOM_LEFT -> Known.BOTTOM_LEFT - BOTTOM_RIGHT -> Known.BOTTOM_RIGHT - CENTER -> Known.CENTER - else -> throw ImageKitInvalidDataException("Unknown AnchorPoint: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): AnchorPoint = apply { - if (validated) { - return@apply - } - - known() - 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 (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AnchorPoint && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + (y.asKnown().getOrNull()?.validity() ?: 0) /** - * Specifies the position of the overlay relative to the parent image or video. If one or more - * of `x`, `y`, `xCenter`, or `yCenter` parameters are specified, this parameter is ignored. - * Maps to `lfo` in the URL. + * Specifies the position of the overlay relative to the parent image or video. Maps to `lfo` in + * the URL. */ class Focus @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -921,14 +594,14 @@ private constructor( } /** - * Specifies the x-coordinate on the base asset where the overlay's center will be positioned. - * It also accepts arithmetic expressions such as `bw_mul_0.4` or `bw_sub_cw`. Maps to `lxc` in - * the URL. Cannot be used together with `x`, but can be used with `y`. Learn about + * Specifies the y-coordinate of the top-left corner of the base asset where the overlay's + * top-left corner will be positioned. It also accepts arithmetic expressions such as + * `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn about * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). */ - @JsonDeserialize(using = XCenter.Deserializer::class) - @JsonSerialize(using = XCenter.Serializer::class) - class XCenter + @JsonDeserialize(using = Y.Deserializer::class) + @JsonSerialize(using = Y.Serializer::class) + class Y private constructor( private val number: Double? = null, private val string: String? = null, @@ -958,7 +631,7 @@ private constructor( private var validated: Boolean = false - fun validate(): XCenter = apply { + fun validate(): Y = apply { if (validated) { return@apply } @@ -1004,29 +677,27 @@ private constructor( return true } - return other is XCenter && number == other.number && string == other.string + return other is Y && number == other.number && string == other.string } override fun hashCode(): Int = Objects.hash(number, string) override fun toString(): String = when { - number != null -> "XCenter{number=$number}" - string != null -> "XCenter{string=$string}" - _json != null -> "XCenter{_unknown=$_json}" - else -> throw IllegalStateException("Invalid XCenter") + number != null -> "Y{number=$number}" + string != null -> "Y{string=$string}" + _json != null -> "Y{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Y") } companion object { - @JvmStatic fun ofNumber(number: Double) = XCenter(number = number) + @JvmStatic fun ofNumber(number: Double) = Y(number = number) - @JvmStatic fun ofString(string: String) = XCenter(string = string) + @JvmStatic fun ofString(string: String) = Y(string = string) } - /** - * An interface that defines how to map each variant of [XCenter] to a value of type [T]. - */ + /** An interface that defines how to map each variant of [Y] to a value of type [T]. */ interface Visitor { fun visitNumber(number: Double): T @@ -1034,32 +705,31 @@ private constructor( fun visitString(string: String): T /** - * Maps an unknown variant of [XCenter] to a value of type [T]. + * Maps an unknown variant of [Y] to a value of type [T]. * - * An instance of [XCenter] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * An instance of [Y] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * * @throws ImageKitInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown XCenter: $json") + throw ImageKitInvalidDataException("Unknown Y: $json") } } - internal class Deserializer : BaseDeserializer(XCenter::class) { + internal class Deserializer : BaseDeserializer(Y::class) { - override fun ObjectCodec.deserialize(node: JsonNode): XCenter { + override fun ObjectCodec.deserialize(node: JsonNode): Y { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - XCenter(string = it, _json = json) + Y(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - XCenter(number = it, _json = json) + Y(number = it, _json = json) }, ) .filterNotNull() @@ -1068,7 +738,7 @@ private constructor( return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with // all the possible variants (e.g. deserializing from boolean). - 0 -> XCenter(_json = json) + 0 -> Y(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first // completely valid match, or simply the first match if none are completely @@ -1078,179 +748,7 @@ private constructor( } } - internal class Serializer : BaseSerializer(XCenter::class) { - - override fun serialize( - value: XCenter, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.number != null -> generator.writeObject(value.number) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid XCenter") - } - } - } - } - - /** - * Specifies the y-coordinate of the top-left corner of the base asset where the overlay's - * top-left corner will be positioned. It also accepts arithmetic expressions such as - * `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn about - * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). - */ - @JsonDeserialize(using = Y.Deserializer::class) - @JsonSerialize(using = Y.Serializer::class) - class Y - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { - - fun number(): Optional = Optional.ofNullable(number) - - fun string(): Optional = Optional.ofNullable(string) - - fun isNumber(): Boolean = number != null - - fun isString(): Boolean = string != null - - fun asNumber(): Double = number.getOrThrow("number") - - fun asString(): String = string.getOrThrow("string") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Y = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNumber(number: Double) {} - - override fun visitString(string: String) {} - } - ) - 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 = - accept( - object : Visitor { - override fun visitNumber(number: Double) = 1 - - override fun visitString(string: String) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Y && number == other.number && string == other.string - } - - override fun hashCode(): Int = Objects.hash(number, string) - - override fun toString(): String = - when { - number != null -> "Y{number=$number}" - string != null -> "Y{string=$string}" - _json != null -> "Y{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Y") - } - - companion object { - - @JvmStatic fun ofNumber(number: Double) = Y(number = number) - - @JvmStatic fun ofString(string: String) = Y(string = string) - } - - /** An interface that defines how to map each variant of [Y] to a value of type [T]. */ - interface Visitor { - - fun visitNumber(number: Double): T - - fun visitString(string: String): T - - /** - * Maps an unknown variant of [Y] to a value of type [T]. - * - * An instance of [Y] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Y: $json") - } - } - - internal class Deserializer : BaseDeserializer(Y::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Y { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Y(string = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Y(number = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from boolean). - 0 -> Y(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely - // valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Y::class) { + internal class Serializer : BaseSerializer(Y::class) { override fun serialize( value: Y, @@ -1267,202 +765,22 @@ private constructor( } } - /** - * Specifies the y-coordinate on the base asset where the overlay's center will be positioned. - * It also accepts arithmetic expressions such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `lyc` in - * the URL. Cannot be used together with `y`, but can be used with `x`. Learn about - * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). - */ - @JsonDeserialize(using = YCenter.Deserializer::class) - @JsonSerialize(using = YCenter.Serializer::class) - class YCenter - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { - - fun number(): Optional = Optional.ofNullable(number) - - fun string(): Optional = Optional.ofNullable(string) - - fun isNumber(): Boolean = number != null - - fun isString(): Boolean = string != null - - fun asNumber(): Double = number.getOrThrow("number") - - fun asString(): String = string.getOrThrow("string") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): YCenter = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNumber(number: Double) {} - - override fun visitString(string: String) {} - } - ) - 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 = - accept( - object : Visitor { - override fun visitNumber(number: Double) = 1 - - override fun visitString(string: String) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is YCenter && number == other.number && string == other.string - } - - override fun hashCode(): Int = Objects.hash(number, string) - - override fun toString(): String = - when { - number != null -> "YCenter{number=$number}" - string != null -> "YCenter{string=$string}" - _json != null -> "YCenter{_unknown=$_json}" - else -> throw IllegalStateException("Invalid YCenter") - } - - companion object { - - @JvmStatic fun ofNumber(number: Double) = YCenter(number = number) - - @JvmStatic fun ofString(string: String) = YCenter(string = string) - } - - /** - * An interface that defines how to map each variant of [YCenter] to a value of type [T]. - */ - interface Visitor { - - fun visitNumber(number: Double): T - - fun visitString(string: String): T - - /** - * Maps an unknown variant of [YCenter] to a value of type [T]. - * - * An instance of [YCenter] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown YCenter: $json") - } - } - - internal class Deserializer : BaseDeserializer(YCenter::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): YCenter { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - YCenter(string = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - YCenter(number = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from boolean). - 0 -> YCenter(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely - // valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(YCenter::class) { - - override fun serialize( - value: YCenter, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.number != null -> generator.writeObject(value.number) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid YCenter") - } - } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } return other is OverlayPosition && - anchorPoint == other.anchorPoint && focus == other.focus && x == other.x && - xCenter == other.xCenter && y == other.y && - yCenter == other.yCenter && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(anchorPoint, focus, x, xCenter, y, yCenter, additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(focus, x, y, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "OverlayPosition{anchorPoint=$anchorPoint, focus=$focus, x=$x, xCenter=$xCenter, y=$y, yCenter=$yCenter, additionalProperties=$additionalProperties}" + "OverlayPosition{focus=$focus, x=$x, y=$y, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt index 43895867..9e52f25b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt @@ -3811,10 +3811,8 @@ private constructor( minSelections.getOptional("min_selections") /** - * Array of possible tag values. The combined length of all strings must not - * exceed 500 characters, and values cannot include the `%` character. When - * providing large vocabularies (more than 30 items), the AI may not follow the - * list strictly. + * Array of possible tag values. Combined length of all strings must not exceed + * 500 characters. Cannot contain the `%` character. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -3967,10 +3965,8 @@ private constructor( } /** - * Array of possible tag values. The combined length of all strings must not - * exceed 500 characters, and values cannot include the `%` character. When - * providing large vocabularies (more than 30 items), the AI may not follow - * the list strictly. + * Array of possible tag values. Combined length of all strings must not + * exceed 500 characters. Cannot contain the `%` character. */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) @@ -4167,10 +4163,7 @@ private constructor( minSelections.getOptional("min_selections") /** - * An array of possible values matching the custom metadata field type. If not - * provided for SingleSelect or MultiSelect field types, all values from the - * custom metadata field definition will be used. When providing large - * vocabularies (above 30 items), the AI may not strictly adhere to the list. + * Array of possible values matching the custom metadata field type. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -4351,13 +4344,7 @@ private constructor( this.minSelections = minSelections } - /** - * An array of possible values matching the custom metadata field type. If - * not provided for SingleSelect or MultiSelect field types, all values from - * the custom metadata field definition will be used. When providing large - * vocabularies (above 30 items), the AI may not strictly adhere to the - * list. - */ + /** Array of possible values matching the custom metadata field type. */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt index 7d9abc94..a188bdb5 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -4077,10 +4077,8 @@ private constructor( minSelections.getOptional("min_selections") /** - * Array of possible tag values. The combined length of all strings must not - * exceed 500 characters, and values cannot include the `%` character. When - * providing large vocabularies (more than 30 items), the AI may not follow the - * list strictly. + * Array of possible tag values. Combined length of all strings must not exceed + * 500 characters. Cannot contain the `%` character. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -4233,10 +4231,8 @@ private constructor( } /** - * Array of possible tag values. The combined length of all strings must not - * exceed 500 characters, and values cannot include the `%` character. When - * providing large vocabularies (more than 30 items), the AI may not follow - * the list strictly. + * Array of possible tag values. Combined length of all strings must not + * exceed 500 characters. Cannot contain the `%` character. */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) @@ -4433,10 +4429,7 @@ private constructor( minSelections.getOptional("min_selections") /** - * An array of possible values matching the custom metadata field type. If not - * provided for SingleSelect or MultiSelect field types, all values from the - * custom metadata field definition will be used. When providing large - * vocabularies (above 30 items), the AI may not strictly adhere to the list. + * Array of possible values matching the custom metadata field type. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -4617,13 +4610,7 @@ private constructor( this.minSelections = minSelections } - /** - * An array of possible values matching the custom metadata field type. If - * not provided for SingleSelect or MultiSelect field types, all values from - * the custom metadata field definition will be used. When providing large - * vocabularies (above 30 items), the AI may not strictly adhere to the - * list. - */ + /** Array of possible values matching the custom metadata field type. */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt index b61f39f0..888c2852 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt @@ -2558,10 +2558,8 @@ private constructor( minSelections.getOptional("min_selections") /** - * Array of possible tag values. The combined length of all strings must not - * exceed 500 characters, and values cannot include the `%` character. When - * providing large vocabularies (more than 30 items), the AI may not follow - * the list strictly. + * Array of possible tag values. Combined length of all strings must not + * exceed 500 characters. Cannot contain the `%` character. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). @@ -2717,10 +2715,8 @@ private constructor( } /** - * Array of possible tag values. The combined length of all strings must - * not exceed 500 characters, and values cannot include the `%` - * character. When providing large vocabularies (more than 30 items), - * the AI may not follow the list strictly. + * Array of possible tag values. Combined length of all strings must not + * exceed 500 characters. Cannot contain the `%` character. */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) @@ -2963,11 +2959,7 @@ private constructor( minSelections.getOptional("min_selections") /** - * An array of possible values matching the custom metadata field type. If - * not provided for SingleSelect or MultiSelect field types, all values from - * the custom metadata field definition will be used. When providing large - * vocabularies (above 30 items), the AI may not strictly adhere to the - * list. + * Array of possible values matching the custom metadata field type. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). @@ -3150,13 +3142,7 @@ private constructor( this.minSelections = minSelections } - /** - * An array of possible values matching the custom metadata field type. - * If not provided for SingleSelect or MultiSelect field types, all - * values from the custom metadata field definition will be used. When - * providing large vocabularies (above 30 items), the AI may not - * strictly adhere to the list. - */ + /** Array of possible values matching the custom metadata field type. */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileCreateEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileCreateEvent.kt new file mode 100644 index 00000000..d8c15c8d --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileCreateEvent.kt @@ -0,0 +1,297 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.files.File +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Triggered when a file is created. */ +class DamFileCreateEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val type: JsonField, + private val createdAt: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(id, type, createdAt, data, mutableMapOf()) + + fun toBaseWebhookEvent(): BaseWebhookEvent = + BaseWebhookEvent.builder().id(id).type(type).build() + + /** + * Unique identifier for the event. + * + * @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") + + /** + * The type of webhook event. + * + * @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 type(): String = type.getRequired("type") + + /** + * Timestamp of when the event occurred in ISO8601 format. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * Object containing details of a file or file version. + * + * @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 data(): File = data.getRequired("data") + + /** + * 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 [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DamFileCreateEvent]. + * + * The following fields are required: + * ```java + * .id() + * .type() + * .createdAt() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DamFileCreateEvent]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var type: JsonField? = null + private var createdAt: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(damFileCreateEvent: DamFileCreateEvent) = apply { + id = damFileCreateEvent.id + type = damFileCreateEvent.type + createdAt = damFileCreateEvent.createdAt + data = damFileCreateEvent.data + additionalProperties = damFileCreateEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the event. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The type of webhook event. */ + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Timestamp of when the event occurred in ISO8601 format. */ + 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 } + + /** Object containing details of a file or file version. */ + fun data(data: File) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [File] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DamFileCreateEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .type() + * .createdAt() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DamFileCreateEvent = + DamFileCreateEvent( + checkRequired("id", id), + checkRequired("type", type), + checkRequired("createdAt", createdAt), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DamFileCreateEvent = apply { + if (validated) { + return@apply + } + + id() + type() + createdAt() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DamFileCreateEvent && + id == other.id && + type == other.type && + createdAt == other.createdAt && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, type, createdAt, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DamFileCreateEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileDeleteEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileDeleteEvent.kt new file mode 100644 index 00000000..ae5f73cb --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileDeleteEvent.kt @@ -0,0 +1,448 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Triggered when a file is deleted. */ +class DamFileDeleteEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val type: JsonField, + private val createdAt: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(id, type, createdAt, data, mutableMapOf()) + + fun toBaseWebhookEvent(): BaseWebhookEvent = + BaseWebhookEvent.builder().id(id).type(type).build() + + /** + * Unique identifier for the event. + * + * @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") + + /** + * The type of webhook event. + * + * @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 type(): String = type.getRequired("type") + + /** + * Timestamp of when the event occurred in ISO8601 format. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @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 data(): Data = data.getRequired("data") + + /** + * 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 [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DamFileDeleteEvent]. + * + * The following fields are required: + * ```java + * .id() + * .type() + * .createdAt() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DamFileDeleteEvent]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var type: JsonField? = null + private var createdAt: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(damFileDeleteEvent: DamFileDeleteEvent) = apply { + id = damFileDeleteEvent.id + type = damFileDeleteEvent.type + createdAt = damFileDeleteEvent.createdAt + data = damFileDeleteEvent.data + additionalProperties = damFileDeleteEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the event. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The type of webhook event. */ + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Timestamp of when the event occurred in ISO8601 format. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DamFileDeleteEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .type() + * .createdAt() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DamFileDeleteEvent = + DamFileDeleteEvent( + checkRequired("id", id), + checkRequired("type", type), + checkRequired("createdAt", createdAt), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DamFileDeleteEvent = apply { + if (validated) { + return@apply + } + + id() + type() + createdAt() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val fileId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("fileId") @ExcludeMissing fileId: JsonField = JsonMissing.of() + ) : this(fileId, mutableMapOf()) + + /** + * The unique `fileId` of the deleted file. + * + * @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 fileId(): String = fileId.getRequired("fileId") + + /** + * Returns the raw JSON value of [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fileId") @ExcludeMissing fun _fileId(): JsonField = fileId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .fileId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var fileId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + fileId = data.fileId + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** The unique `fileId` of the deleted file. */ + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fileId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data(checkRequired("fileId", fileId), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + fileId() + 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 (fileId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + fileId == other.fileId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(fileId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Data{fileId=$fileId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DamFileDeleteEvent && + id == other.id && + type == other.type && + createdAt == other.createdAt && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, type, createdAt, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DamFileDeleteEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileUpdateEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileUpdateEvent.kt new file mode 100644 index 00000000..2f6770c5 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileUpdateEvent.kt @@ -0,0 +1,297 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.files.File +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Triggered when a file is updated. */ +class DamFileUpdateEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val type: JsonField, + private val createdAt: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(id, type, createdAt, data, mutableMapOf()) + + fun toBaseWebhookEvent(): BaseWebhookEvent = + BaseWebhookEvent.builder().id(id).type(type).build() + + /** + * Unique identifier for the event. + * + * @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") + + /** + * The type of webhook event. + * + * @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 type(): String = type.getRequired("type") + + /** + * Timestamp of when the event occurred in ISO8601 format. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * Object containing details of a file or file version. + * + * @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 data(): File = data.getRequired("data") + + /** + * 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 [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DamFileUpdateEvent]. + * + * The following fields are required: + * ```java + * .id() + * .type() + * .createdAt() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DamFileUpdateEvent]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var type: JsonField? = null + private var createdAt: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(damFileUpdateEvent: DamFileUpdateEvent) = apply { + id = damFileUpdateEvent.id + type = damFileUpdateEvent.type + createdAt = damFileUpdateEvent.createdAt + data = damFileUpdateEvent.data + additionalProperties = damFileUpdateEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the event. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The type of webhook event. */ + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Timestamp of when the event occurred in ISO8601 format. */ + 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 } + + /** Object containing details of a file or file version. */ + fun data(data: File) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [File] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DamFileUpdateEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .type() + * .createdAt() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DamFileUpdateEvent = + DamFileUpdateEvent( + checkRequired("id", id), + checkRequired("type", type), + checkRequired("createdAt", createdAt), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DamFileUpdateEvent = apply { + if (validated) { + return@apply + } + + id() + type() + createdAt() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DamFileUpdateEvent && + id == other.id && + type == other.type && + createdAt == other.createdAt && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, type, createdAt, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DamFileUpdateEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEvent.kt new file mode 100644 index 00000000..a915c1b5 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEvent.kt @@ -0,0 +1,277 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects + +/** Triggered when a file version is created. */ +class DamFileVersionCreateEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val type: JsonField, + private val createdAt: JsonField, + private val data: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonValue = JsonMissing.of(), + ) : this(id, type, createdAt, data, mutableMapOf()) + + fun toBaseWebhookEvent(): BaseWebhookEvent = + BaseWebhookEvent.builder().id(id).type(type).build() + + /** + * Unique identifier for the event. + * + * @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") + + /** + * The type of webhook event. + * + * @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 type(): String = type.getRequired("type") + + /** + * Timestamp of when the event occurred in ISO8601 format. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * This arbitrary value can be deserialized into a custom type using the `convert` method: + * ```java + * MyClass myObject = damFileVersionCreateEvent.data().convert(MyClass.class); + * ``` + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonValue = data + + /** + * 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 [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DamFileVersionCreateEvent]. + * + * The following fields are required: + * ```java + * .id() + * .type() + * .createdAt() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DamFileVersionCreateEvent]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var type: JsonField? = null + private var createdAt: JsonField? = null + private var data: JsonValue? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(damFileVersionCreateEvent: DamFileVersionCreateEvent) = apply { + id = damFileVersionCreateEvent.id + type = damFileVersionCreateEvent.type + createdAt = damFileVersionCreateEvent.createdAt + data = damFileVersionCreateEvent.data + additionalProperties = damFileVersionCreateEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the event. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The type of webhook event. */ + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Timestamp of when the event occurred in ISO8601 format. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + fun data(data: JsonValue) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DamFileVersionCreateEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .type() + * .createdAt() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DamFileVersionCreateEvent = + DamFileVersionCreateEvent( + checkRequired("id", id), + checkRequired("type", type), + checkRequired("createdAt", createdAt), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DamFileVersionCreateEvent = apply { + if (validated) { + return@apply + } + + id() + type() + createdAt() + 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 (type.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DamFileVersionCreateEvent && + id == other.id && + type == other.type && + createdAt == other.createdAt && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, type, createdAt, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DamFileVersionCreateEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileVersionDeleteEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileVersionDeleteEvent.kt new file mode 100644 index 00000000..7da1a908 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileVersionDeleteEvent.kt @@ -0,0 +1,493 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.checkRequired +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Triggered when a file version is deleted. */ +class DamFileVersionDeleteEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val type: JsonField, + private val createdAt: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(id, type, createdAt, data, mutableMapOf()) + + fun toBaseWebhookEvent(): BaseWebhookEvent = + BaseWebhookEvent.builder().id(id).type(type).build() + + /** + * Unique identifier for the event. + * + * @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") + + /** + * The type of webhook event. + * + * @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 type(): String = type.getRequired("type") + + /** + * Timestamp of when the event occurred in ISO8601 format. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * @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 data(): Data = data.getRequired("data") + + /** + * 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 [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DamFileVersionDeleteEvent]. + * + * The following fields are required: + * ```java + * .id() + * .type() + * .createdAt() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DamFileVersionDeleteEvent]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var type: JsonField? = null + private var createdAt: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(damFileVersionDeleteEvent: DamFileVersionDeleteEvent) = apply { + id = damFileVersionDeleteEvent.id + type = damFileVersionDeleteEvent.type + createdAt = damFileVersionDeleteEvent.createdAt + data = damFileVersionDeleteEvent.data + additionalProperties = damFileVersionDeleteEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the event. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The type of webhook event. */ + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Timestamp of when the event occurred in ISO8601 format. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DamFileVersionDeleteEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .type() + * .createdAt() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DamFileVersionDeleteEvent = + DamFileVersionDeleteEvent( + checkRequired("id", id), + checkRequired("type", type), + checkRequired("createdAt", createdAt), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DamFileVersionDeleteEvent = apply { + if (validated) { + return@apply + } + + id() + type() + createdAt() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val fileId: JsonField, + private val versionId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("fileId") @ExcludeMissing fileId: JsonField = JsonMissing.of(), + @JsonProperty("versionId") + @ExcludeMissing + versionId: JsonField = JsonMissing.of(), + ) : this(fileId, versionId, mutableMapOf()) + + /** + * The unique `fileId` of the deleted file. + * + * @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 fileId(): String = fileId.getRequired("fileId") + + /** + * The unique `versionId` of the deleted file version. + * + * @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 versionId(): String = versionId.getRequired("versionId") + + /** + * Returns the raw JSON value of [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fileId") @ExcludeMissing fun _fileId(): JsonField = fileId + + /** + * Returns the raw JSON value of [versionId]. + * + * Unlike [versionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("versionId") @ExcludeMissing fun _versionId(): JsonField = versionId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .fileId() + * .versionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var fileId: JsonField? = null + private var versionId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + fileId = data.fileId + versionId = data.versionId + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** The unique `fileId` of the deleted file. */ + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + + /** The unique `versionId` of the deleted file version. */ + fun versionId(versionId: String) = versionId(JsonField.of(versionId)) + + /** + * Sets [Builder.versionId] to an arbitrary JSON value. + * + * You should usually call [Builder.versionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun versionId(versionId: JsonField) = apply { this.versionId = versionId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fileId() + * .versionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("fileId", fileId), + checkRequired("versionId", versionId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + fileId() + versionId() + 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 (fileId.asKnown().isPresent) 1 else 0) + + (if (versionId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + fileId == other.fileId && + versionId == other.versionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(fileId, versionId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{fileId=$fileId, versionId=$versionId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DamFileVersionDeleteEvent && + id == other.id && + type == other.type && + createdAt == other.createdAt && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, type, createdAt, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DamFileVersionDeleteEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt index aefc49f6..8f42bb62 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt @@ -35,6 +35,11 @@ private constructor( private val uploadPreTransformError: UploadPreTransformErrorEvent? = null, private val uploadPostTransformSuccess: UploadPostTransformSuccessEvent? = null, private val uploadPostTransformError: UploadPostTransformErrorEvent? = null, + private val damFileCreate: DamFileCreateEvent? = null, + private val damFileUpdate: DamFileUpdateEvent? = null, + private val damFileDelete: DamFileDeleteEvent? = null, + private val damFileVersionCreate: DamFileVersionCreateEvent? = null, + private val damFileVersionDelete: DamFileVersionDeleteEvent? = null, private val _json: JsonValue? = null, ) { @@ -91,6 +96,23 @@ private constructor( fun uploadPostTransformError(): Optional = Optional.ofNullable(uploadPostTransformError) + /** Triggered when a file is created. */ + fun damFileCreate(): Optional = Optional.ofNullable(damFileCreate) + + /** Triggered when a file is updated. */ + fun damFileUpdate(): Optional = Optional.ofNullable(damFileUpdate) + + /** Triggered when a file is deleted. */ + fun damFileDelete(): Optional = Optional.ofNullable(damFileDelete) + + /** Triggered when a file version is created. */ + fun damFileVersionCreate(): Optional = + Optional.ofNullable(damFileVersionCreate) + + /** Triggered when a file version is deleted. */ + fun damFileVersionDelete(): Optional = + Optional.ofNullable(damFileVersionDelete) + fun isVideoTransformationAccepted(): Boolean = videoTransformationAccepted != null fun isVideoTransformationReady(): Boolean = videoTransformationReady != null @@ -105,6 +127,16 @@ private constructor( fun isUploadPostTransformError(): Boolean = uploadPostTransformError != null + fun isDamFileCreate(): Boolean = damFileCreate != null + + fun isDamFileUpdate(): Boolean = damFileUpdate != null + + fun isDamFileDelete(): Boolean = damFileDelete != null + + fun isDamFileVersionCreate(): Boolean = damFileVersionCreate != null + + fun isDamFileVersionDelete(): Boolean = damFileVersionDelete != null + /** * Triggered when a new video transformation request is accepted for processing. This event * confirms that ImageKit has received and queued your transformation request. Use this for @@ -158,6 +190,23 @@ private constructor( fun asUploadPostTransformError(): UploadPostTransformErrorEvent = uploadPostTransformError.getOrThrow("uploadPostTransformError") + /** Triggered when a file is created. */ + fun asDamFileCreate(): DamFileCreateEvent = damFileCreate.getOrThrow("damFileCreate") + + /** Triggered when a file is updated. */ + fun asDamFileUpdate(): DamFileUpdateEvent = damFileUpdate.getOrThrow("damFileUpdate") + + /** Triggered when a file is deleted. */ + fun asDamFileDelete(): DamFileDeleteEvent = damFileDelete.getOrThrow("damFileDelete") + + /** Triggered when a file version is created. */ + fun asDamFileVersionCreate(): DamFileVersionCreateEvent = + damFileVersionCreate.getOrThrow("damFileVersionCreate") + + /** Triggered when a file version is deleted. */ + fun asDamFileVersionDelete(): DamFileVersionDeleteEvent = + damFileVersionDelete.getOrThrow("damFileVersionDelete") + fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = @@ -176,6 +225,11 @@ private constructor( visitor.visitUploadPostTransformSuccess(uploadPostTransformSuccess) uploadPostTransformError != null -> visitor.visitUploadPostTransformError(uploadPostTransformError) + damFileCreate != null -> visitor.visitDamFileCreate(damFileCreate) + damFileUpdate != null -> visitor.visitDamFileUpdate(damFileUpdate) + damFileDelete != null -> visitor.visitDamFileDelete(damFileDelete) + damFileVersionCreate != null -> visitor.visitDamFileVersionCreate(damFileVersionCreate) + damFileVersionDelete != null -> visitor.visitDamFileVersionDelete(damFileVersionDelete) else -> visitor.unknown(_json) } @@ -229,6 +283,30 @@ private constructor( ) { uploadPostTransformError.validate() } + + override fun visitDamFileCreate(damFileCreate: DamFileCreateEvent) { + damFileCreate.validate() + } + + override fun visitDamFileUpdate(damFileUpdate: DamFileUpdateEvent) { + damFileUpdate.validate() + } + + override fun visitDamFileDelete(damFileDelete: DamFileDeleteEvent) { + damFileDelete.validate() + } + + override fun visitDamFileVersionCreate( + damFileVersionCreate: DamFileVersionCreateEvent + ) { + damFileVersionCreate.validate() + } + + override fun visitDamFileVersionDelete( + damFileVersionDelete: DamFileVersionDeleteEvent + ) { + damFileVersionDelete.validate() + } } ) validated = true @@ -279,6 +357,23 @@ private constructor( uploadPostTransformError: UploadPostTransformErrorEvent ) = uploadPostTransformError.validity() + override fun visitDamFileCreate(damFileCreate: DamFileCreateEvent) = + damFileCreate.validity() + + override fun visitDamFileUpdate(damFileUpdate: DamFileUpdateEvent) = + damFileUpdate.validity() + + override fun visitDamFileDelete(damFileDelete: DamFileDeleteEvent) = + damFileDelete.validity() + + override fun visitDamFileVersionCreate( + damFileVersionCreate: DamFileVersionCreateEvent + ) = damFileVersionCreate.validity() + + override fun visitDamFileVersionDelete( + damFileVersionDelete: DamFileVersionDeleteEvent + ) = damFileVersionDelete.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -295,7 +390,12 @@ private constructor( uploadPreTransformSuccess == other.uploadPreTransformSuccess && uploadPreTransformError == other.uploadPreTransformError && uploadPostTransformSuccess == other.uploadPostTransformSuccess && - uploadPostTransformError == other.uploadPostTransformError + uploadPostTransformError == other.uploadPostTransformError && + damFileCreate == other.damFileCreate && + damFileUpdate == other.damFileUpdate && + damFileDelete == other.damFileDelete && + damFileVersionCreate == other.damFileVersionCreate && + damFileVersionDelete == other.damFileVersionDelete } override fun hashCode(): Int = @@ -307,6 +407,11 @@ private constructor( uploadPreTransformError, uploadPostTransformSuccess, uploadPostTransformError, + damFileCreate, + damFileUpdate, + damFileDelete, + damFileVersionCreate, + damFileVersionDelete, ) override fun toString(): String = @@ -325,6 +430,13 @@ private constructor( "UnsafeUnwrapWebhookEvent{uploadPostTransformSuccess=$uploadPostTransformSuccess}" uploadPostTransformError != null -> "UnsafeUnwrapWebhookEvent{uploadPostTransformError=$uploadPostTransformError}" + damFileCreate != null -> "UnsafeUnwrapWebhookEvent{damFileCreate=$damFileCreate}" + damFileUpdate != null -> "UnsafeUnwrapWebhookEvent{damFileUpdate=$damFileUpdate}" + damFileDelete != null -> "UnsafeUnwrapWebhookEvent{damFileDelete=$damFileDelete}" + damFileVersionCreate != null -> + "UnsafeUnwrapWebhookEvent{damFileVersionCreate=$damFileVersionCreate}" + damFileVersionDelete != null -> + "UnsafeUnwrapWebhookEvent{damFileVersionDelete=$damFileVersionDelete}" _json != null -> "UnsafeUnwrapWebhookEvent{_unknown=$_json}" else -> throw IllegalStateException("Invalid UnsafeUnwrapWebhookEvent") } @@ -392,6 +504,31 @@ private constructor( @JvmStatic fun ofUploadPostTransformError(uploadPostTransformError: UploadPostTransformErrorEvent) = UnsafeUnwrapWebhookEvent(uploadPostTransformError = uploadPostTransformError) + + /** Triggered when a file is created. */ + @JvmStatic + fun ofDamFileCreate(damFileCreate: DamFileCreateEvent) = + UnsafeUnwrapWebhookEvent(damFileCreate = damFileCreate) + + /** Triggered when a file is updated. */ + @JvmStatic + fun ofDamFileUpdate(damFileUpdate: DamFileUpdateEvent) = + UnsafeUnwrapWebhookEvent(damFileUpdate = damFileUpdate) + + /** Triggered when a file is deleted. */ + @JvmStatic + fun ofDamFileDelete(damFileDelete: DamFileDeleteEvent) = + UnsafeUnwrapWebhookEvent(damFileDelete = damFileDelete) + + /** Triggered when a file version is created. */ + @JvmStatic + fun ofDamFileVersionCreate(damFileVersionCreate: DamFileVersionCreateEvent) = + UnsafeUnwrapWebhookEvent(damFileVersionCreate = damFileVersionCreate) + + /** Triggered when a file version is deleted. */ + @JvmStatic + fun ofDamFileVersionDelete(damFileVersionDelete: DamFileVersionDeleteEvent) = + UnsafeUnwrapWebhookEvent(damFileVersionDelete = damFileVersionDelete) } /** @@ -458,6 +595,21 @@ private constructor( uploadPostTransformError: UploadPostTransformErrorEvent ): T + /** Triggered when a file is created. */ + fun visitDamFileCreate(damFileCreate: DamFileCreateEvent): T + + /** Triggered when a file is updated. */ + fun visitDamFileUpdate(damFileUpdate: DamFileUpdateEvent): T + + /** Triggered when a file is deleted. */ + fun visitDamFileDelete(damFileDelete: DamFileDeleteEvent): T + + /** Triggered when a file version is created. */ + fun visitDamFileVersionCreate(damFileVersionCreate: DamFileVersionCreateEvent): T + + /** Triggered when a file version is deleted. */ + fun visitDamFileVersionDelete(damFileVersionDelete: DamFileVersionDeleteEvent): T + /** * Maps an unknown variant of [UnsafeUnwrapWebhookEvent] to a value of type [T]. * @@ -517,6 +669,21 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { UnsafeUnwrapWebhookEvent(uploadPostTransformError = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnsafeUnwrapWebhookEvent(damFileCreate = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnsafeUnwrapWebhookEvent(damFileUpdate = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnsafeUnwrapWebhookEvent(damFileDelete = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnsafeUnwrapWebhookEvent(damFileVersionCreate = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnsafeUnwrapWebhookEvent(damFileVersionDelete = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -556,6 +723,13 @@ private constructor( generator.writeObject(value.uploadPostTransformSuccess) value.uploadPostTransformError != null -> generator.writeObject(value.uploadPostTransformError) + value.damFileCreate != null -> generator.writeObject(value.damFileCreate) + value.damFileUpdate != null -> generator.writeObject(value.damFileUpdate) + value.damFileDelete != null -> generator.writeObject(value.damFileDelete) + value.damFileVersionCreate != null -> + generator.writeObject(value.damFileVersionCreate) + value.damFileVersionDelete != null -> + generator.writeObject(value.damFileVersionDelete) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid UnsafeUnwrapWebhookEvent") } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt index df37c012..949f6694 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt @@ -35,6 +35,11 @@ private constructor( private val uploadPreTransformError: UploadPreTransformErrorEvent? = null, private val uploadPostTransformSuccess: UploadPostTransformSuccessEvent? = null, private val uploadPostTransformError: UploadPostTransformErrorEvent? = null, + private val damFileCreate: DamFileCreateEvent? = null, + private val damFileUpdate: DamFileUpdateEvent? = null, + private val damFileDelete: DamFileDeleteEvent? = null, + private val damFileVersionCreate: DamFileVersionCreateEvent? = null, + private val damFileVersionDelete: DamFileVersionDeleteEvent? = null, private val _json: JsonValue? = null, ) { @@ -91,6 +96,23 @@ private constructor( fun uploadPostTransformError(): Optional = Optional.ofNullable(uploadPostTransformError) + /** Triggered when a file is created. */ + fun damFileCreate(): Optional = Optional.ofNullable(damFileCreate) + + /** Triggered when a file is updated. */ + fun damFileUpdate(): Optional = Optional.ofNullable(damFileUpdate) + + /** Triggered when a file is deleted. */ + fun damFileDelete(): Optional = Optional.ofNullable(damFileDelete) + + /** Triggered when a file version is created. */ + fun damFileVersionCreate(): Optional = + Optional.ofNullable(damFileVersionCreate) + + /** Triggered when a file version is deleted. */ + fun damFileVersionDelete(): Optional = + Optional.ofNullable(damFileVersionDelete) + fun isVideoTransformationAccepted(): Boolean = videoTransformationAccepted != null fun isVideoTransformationReady(): Boolean = videoTransformationReady != null @@ -105,6 +127,16 @@ private constructor( fun isUploadPostTransformError(): Boolean = uploadPostTransformError != null + fun isDamFileCreate(): Boolean = damFileCreate != null + + fun isDamFileUpdate(): Boolean = damFileUpdate != null + + fun isDamFileDelete(): Boolean = damFileDelete != null + + fun isDamFileVersionCreate(): Boolean = damFileVersionCreate != null + + fun isDamFileVersionDelete(): Boolean = damFileVersionDelete != null + /** * Triggered when a new video transformation request is accepted for processing. This event * confirms that ImageKit has received and queued your transformation request. Use this for @@ -158,6 +190,23 @@ private constructor( fun asUploadPostTransformError(): UploadPostTransformErrorEvent = uploadPostTransformError.getOrThrow("uploadPostTransformError") + /** Triggered when a file is created. */ + fun asDamFileCreate(): DamFileCreateEvent = damFileCreate.getOrThrow("damFileCreate") + + /** Triggered when a file is updated. */ + fun asDamFileUpdate(): DamFileUpdateEvent = damFileUpdate.getOrThrow("damFileUpdate") + + /** Triggered when a file is deleted. */ + fun asDamFileDelete(): DamFileDeleteEvent = damFileDelete.getOrThrow("damFileDelete") + + /** Triggered when a file version is created. */ + fun asDamFileVersionCreate(): DamFileVersionCreateEvent = + damFileVersionCreate.getOrThrow("damFileVersionCreate") + + /** Triggered when a file version is deleted. */ + fun asDamFileVersionDelete(): DamFileVersionDeleteEvent = + damFileVersionDelete.getOrThrow("damFileVersionDelete") + fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = @@ -176,6 +225,11 @@ private constructor( visitor.visitUploadPostTransformSuccess(uploadPostTransformSuccess) uploadPostTransformError != null -> visitor.visitUploadPostTransformError(uploadPostTransformError) + damFileCreate != null -> visitor.visitDamFileCreate(damFileCreate) + damFileUpdate != null -> visitor.visitDamFileUpdate(damFileUpdate) + damFileDelete != null -> visitor.visitDamFileDelete(damFileDelete) + damFileVersionCreate != null -> visitor.visitDamFileVersionCreate(damFileVersionCreate) + damFileVersionDelete != null -> visitor.visitDamFileVersionDelete(damFileVersionDelete) else -> visitor.unknown(_json) } @@ -229,6 +283,30 @@ private constructor( ) { uploadPostTransformError.validate() } + + override fun visitDamFileCreate(damFileCreate: DamFileCreateEvent) { + damFileCreate.validate() + } + + override fun visitDamFileUpdate(damFileUpdate: DamFileUpdateEvent) { + damFileUpdate.validate() + } + + override fun visitDamFileDelete(damFileDelete: DamFileDeleteEvent) { + damFileDelete.validate() + } + + override fun visitDamFileVersionCreate( + damFileVersionCreate: DamFileVersionCreateEvent + ) { + damFileVersionCreate.validate() + } + + override fun visitDamFileVersionDelete( + damFileVersionDelete: DamFileVersionDeleteEvent + ) { + damFileVersionDelete.validate() + } } ) validated = true @@ -279,6 +357,23 @@ private constructor( uploadPostTransformError: UploadPostTransformErrorEvent ) = uploadPostTransformError.validity() + override fun visitDamFileCreate(damFileCreate: DamFileCreateEvent) = + damFileCreate.validity() + + override fun visitDamFileUpdate(damFileUpdate: DamFileUpdateEvent) = + damFileUpdate.validity() + + override fun visitDamFileDelete(damFileDelete: DamFileDeleteEvent) = + damFileDelete.validity() + + override fun visitDamFileVersionCreate( + damFileVersionCreate: DamFileVersionCreateEvent + ) = damFileVersionCreate.validity() + + override fun visitDamFileVersionDelete( + damFileVersionDelete: DamFileVersionDeleteEvent + ) = damFileVersionDelete.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -295,7 +390,12 @@ private constructor( uploadPreTransformSuccess == other.uploadPreTransformSuccess && uploadPreTransformError == other.uploadPreTransformError && uploadPostTransformSuccess == other.uploadPostTransformSuccess && - uploadPostTransformError == other.uploadPostTransformError + uploadPostTransformError == other.uploadPostTransformError && + damFileCreate == other.damFileCreate && + damFileUpdate == other.damFileUpdate && + damFileDelete == other.damFileDelete && + damFileVersionCreate == other.damFileVersionCreate && + damFileVersionDelete == other.damFileVersionDelete } override fun hashCode(): Int = @@ -307,6 +407,11 @@ private constructor( uploadPreTransformError, uploadPostTransformSuccess, uploadPostTransformError, + damFileCreate, + damFileUpdate, + damFileDelete, + damFileVersionCreate, + damFileVersionDelete, ) override fun toString(): String = @@ -325,6 +430,13 @@ private constructor( "UnwrapWebhookEvent{uploadPostTransformSuccess=$uploadPostTransformSuccess}" uploadPostTransformError != null -> "UnwrapWebhookEvent{uploadPostTransformError=$uploadPostTransformError}" + damFileCreate != null -> "UnwrapWebhookEvent{damFileCreate=$damFileCreate}" + damFileUpdate != null -> "UnwrapWebhookEvent{damFileUpdate=$damFileUpdate}" + damFileDelete != null -> "UnwrapWebhookEvent{damFileDelete=$damFileDelete}" + damFileVersionCreate != null -> + "UnwrapWebhookEvent{damFileVersionCreate=$damFileVersionCreate}" + damFileVersionDelete != null -> + "UnwrapWebhookEvent{damFileVersionDelete=$damFileVersionDelete}" _json != null -> "UnwrapWebhookEvent{_unknown=$_json}" else -> throw IllegalStateException("Invalid UnwrapWebhookEvent") } @@ -392,6 +504,31 @@ private constructor( @JvmStatic fun ofUploadPostTransformError(uploadPostTransformError: UploadPostTransformErrorEvent) = UnwrapWebhookEvent(uploadPostTransformError = uploadPostTransformError) + + /** Triggered when a file is created. */ + @JvmStatic + fun ofDamFileCreate(damFileCreate: DamFileCreateEvent) = + UnwrapWebhookEvent(damFileCreate = damFileCreate) + + /** Triggered when a file is updated. */ + @JvmStatic + fun ofDamFileUpdate(damFileUpdate: DamFileUpdateEvent) = + UnwrapWebhookEvent(damFileUpdate = damFileUpdate) + + /** Triggered when a file is deleted. */ + @JvmStatic + fun ofDamFileDelete(damFileDelete: DamFileDeleteEvent) = + UnwrapWebhookEvent(damFileDelete = damFileDelete) + + /** Triggered when a file version is created. */ + @JvmStatic + fun ofDamFileVersionCreate(damFileVersionCreate: DamFileVersionCreateEvent) = + UnwrapWebhookEvent(damFileVersionCreate = damFileVersionCreate) + + /** Triggered when a file version is deleted. */ + @JvmStatic + fun ofDamFileVersionDelete(damFileVersionDelete: DamFileVersionDeleteEvent) = + UnwrapWebhookEvent(damFileVersionDelete = damFileVersionDelete) } /** @@ -458,6 +595,21 @@ private constructor( uploadPostTransformError: UploadPostTransformErrorEvent ): T + /** Triggered when a file is created. */ + fun visitDamFileCreate(damFileCreate: DamFileCreateEvent): T + + /** Triggered when a file is updated. */ + fun visitDamFileUpdate(damFileUpdate: DamFileUpdateEvent): T + + /** Triggered when a file is deleted. */ + fun visitDamFileDelete(damFileDelete: DamFileDeleteEvent): T + + /** Triggered when a file version is created. */ + fun visitDamFileVersionCreate(damFileVersionCreate: DamFileVersionCreateEvent): T + + /** Triggered when a file version is deleted. */ + fun visitDamFileVersionDelete(damFileVersionDelete: DamFileVersionDeleteEvent): T + /** * Maps an unknown variant of [UnwrapWebhookEvent] to a value of type [T]. * @@ -507,6 +659,21 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { UnwrapWebhookEvent(uploadPostTransformError = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnwrapWebhookEvent(damFileCreate = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnwrapWebhookEvent(damFileUpdate = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnwrapWebhookEvent(damFileDelete = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnwrapWebhookEvent(damFileVersionCreate = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnwrapWebhookEvent(damFileVersionDelete = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -545,6 +712,13 @@ private constructor( generator.writeObject(value.uploadPostTransformSuccess) value.uploadPostTransformError != null -> generator.writeObject(value.uploadPostTransformError) + value.damFileCreate != null -> generator.writeObject(value.damFileCreate) + value.damFileUpdate != null -> generator.writeObject(value.damFileUpdate) + value.damFileDelete != null -> generator.writeObject(value.damFileDelete) + value.damFileVersionCreate != null -> + generator.writeObject(value.damFileVersionCreate) + value.damFileVersionDelete != null -> + generator.writeObject(value.damFileVersionDelete) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid UnwrapWebhookEvent") } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt index 323aed25..6eaf057f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt @@ -23,40 +23,15 @@ internal class ClientOptionsTest { .httpClient(httpClient) .putHeader("User-Agent", "My User Agent") .privateKey("My Private Key") - .password("My Password") .build() assertThat(clientOptions.headers.values("User-Agent")).containsExactly("My User Agent") } - @Test - fun toBuilder_basicAuthCanBeUpdated() { - var clientOptions = - ClientOptions.builder() - .httpClient(httpClient) - .privateKey("My Private Key") - .password("My Password") - .build() - - clientOptions = - clientOptions - .toBuilder() - .privateKey("another My Private Key") - .password("another My Password") - .build() - - assertThat(clientOptions.headers.values("Authorization")) - .containsExactly("Basic YW5vdGhlciBNeSBQcml2YXRlIEtleTphbm90aGVyIE15IFBhc3N3b3Jk") - } - @Test fun toBuilder_whenOriginalClientOptionsGarbageCollected_doesNotCloseOriginalClient() { var clientOptions = - ClientOptions.builder() - .httpClient(httpClient) - .privateKey("My Private Key") - .password("My Password") - .build() + ClientOptions.builder().httpClient(httpClient).privateKey("My Private Key").build() verify(httpClient, never()).close() // Overwrite the `clientOptions` variable so that the original `ClientOptions` is GC'd. diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt index 4955f427..062380b7 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt @@ -16,12 +16,9 @@ internal class BaseOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -30,14 +27,7 @@ internal class BaseOverlayTest { assertThat(baseOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(baseOverlay.position()) .contains( - OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) - .focus(OverlayPosition.Focus.CENTER) - .x(0.0) - .xCenter(0.0) - .y(0.0) - .yCenter(0.0) - .build() + OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() ) assertThat(baseOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -51,12 +41,9 @@ internal class BaseOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt index 71e02e02..161d626e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt @@ -65,12 +65,9 @@ internal class GetImageAttributesOptionsTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing( @@ -185,12 +182,9 @@ internal class GetImageAttributesOptionsTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing( @@ -303,12 +297,9 @@ internal class GetImageAttributesOptionsTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt index f6866ef5..ea386f83 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt @@ -17,12 +17,9 @@ internal class ImageOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -69,12 +66,9 @@ internal class ImageOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing( @@ -133,14 +127,7 @@ internal class ImageOverlayTest { assertThat(imageOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(imageOverlay.position()) .contains( - OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) - .focus(OverlayPosition.Focus.CENTER) - .x(0.0) - .xCenter(0.0) - .y(0.0) - .yCenter(0.0) - .build() + OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() ) assertThat(imageOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -188,12 +175,9 @@ internal class ImageOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing( @@ -251,12 +235,9 @@ internal class ImageOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -303,12 +284,9 @@ internal class ImageOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayPositionTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayPositionTest.kt index 3d474c62..a39aa652 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayPositionTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayPositionTest.kt @@ -12,35 +12,18 @@ internal class OverlayPositionTest { @Test fun create() { val overlayPosition = - OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) - .focus(OverlayPosition.Focus.CENTER) - .x(0.0) - .xCenter(0.0) - .y(0.0) - .yCenter(0.0) - .build() - - assertThat(overlayPosition.anchorPoint()).contains(OverlayPosition.AnchorPoint.TOP) + OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + assertThat(overlayPosition.focus()).contains(OverlayPosition.Focus.CENTER) assertThat(overlayPosition.x()).contains(OverlayPosition.X.ofNumber(0.0)) - assertThat(overlayPosition.xCenter()).contains(OverlayPosition.XCenter.ofNumber(0.0)) assertThat(overlayPosition.y()).contains(OverlayPosition.Y.ofNumber(0.0)) - assertThat(overlayPosition.yCenter()).contains(OverlayPosition.YCenter.ofNumber(0.0)) } @Test fun roundtrip() { val jsonMapper = jsonMapper() val overlayPosition = - OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) - .focus(OverlayPosition.Focus.CENTER) - .x(0.0) - .xCenter(0.0) - .y(0.0) - .yCenter(0.0) - .build() + OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() val roundtrippedOverlayPosition = jsonMapper.readValue( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt index cc0a81b5..47c32e03 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt @@ -21,12 +21,9 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -69,12 +66,9 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -113,12 +107,9 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -165,12 +156,9 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing( @@ -244,12 +232,9 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -298,12 +283,9 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing( @@ -373,12 +355,9 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -425,12 +404,9 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing( @@ -504,12 +480,9 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -558,12 +531,9 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing( @@ -633,12 +603,9 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -675,12 +642,9 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -713,12 +677,9 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -753,12 +714,9 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt index a53b4de6..27cae13f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt @@ -17,12 +17,9 @@ internal class SolidColorOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -42,14 +39,7 @@ internal class SolidColorOverlayTest { assertThat(solidColorOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(solidColorOverlay.position()) .contains( - OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) - .focus(OverlayPosition.Focus.CENTER) - .x(0.0) - .xCenter(0.0) - .y(0.0) - .yCenter(0.0) - .build() + OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() ) assertThat(solidColorOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -75,12 +65,9 @@ internal class SolidColorOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt index 5e6f2a29..4589be89 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt @@ -65,12 +65,9 @@ internal class SrcOptionsTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing( @@ -179,12 +176,9 @@ internal class SrcOptionsTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing( @@ -290,12 +284,9 @@ internal class SrcOptionsTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt index be605a48..35aea254 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt @@ -17,12 +17,9 @@ internal class SubtitleOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -44,14 +41,7 @@ internal class SubtitleOverlayTest { assertThat(subtitleOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(subtitleOverlay.position()) .contains( - OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) - .focus(OverlayPosition.Focus.CENTER) - .x(0.0) - .xCenter(0.0) - .y(0.0) - .yCenter(0.0) - .build() + OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() ) assertThat(subtitleOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -79,12 +69,9 @@ internal class SubtitleOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt index 8227d262..841a72dd 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt @@ -17,12 +17,9 @@ internal class TextOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -50,14 +47,7 @@ internal class TextOverlayTest { assertThat(textOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(textOverlay.position()) .contains( - OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) - .focus(OverlayPosition.Focus.CENTER) - .x(0.0) - .xCenter(0.0) - .y(0.0) - .yCenter(0.0) - .build() + OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() ) assertThat(textOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -91,12 +81,9 @@ internal class TextOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt index b27f75bd..09bf721f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt @@ -53,12 +53,9 @@ internal class TransformationTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -148,12 +145,9 @@ internal class TransformationTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -245,12 +239,9 @@ internal class TransformationTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt index 50cb287d..19e48b9d 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt @@ -17,12 +17,9 @@ internal class VideoOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -69,12 +66,9 @@ internal class VideoOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing( @@ -133,14 +127,7 @@ internal class VideoOverlayTest { assertThat(videoOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(videoOverlay.position()) .contains( - OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) - .focus(OverlayPosition.Focus.CENTER) - .x(0.0) - .xCenter(0.0) - .y(0.0) - .yCenter(0.0) - .build() + OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() ) assertThat(videoOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -188,12 +175,9 @@ internal class VideoOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing( @@ -251,12 +235,9 @@ internal class VideoOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -303,12 +284,9 @@ internal class VideoOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() - .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) - .xCenter(0.0) .y(0.0) - .yCenter(0.0) .build() ) .timing( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileCreateEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileCreateEventTest.kt new file mode 100644 index 00000000..869912af --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileCreateEventTest.kt @@ -0,0 +1,246 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import com.imagekit.api.models.files.File +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DamFileCreateEventTest { + + @Test + fun create() { + val damFileCreateEvent = + DamFileCreateEvent.builder() + .id("id") + .type("file.created") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + File.builder() + .addAiTag( + File.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .build() + + assertThat(damFileCreateEvent.id()).isEqualTo("id") + assertThat(damFileCreateEvent.type()).isEqualTo("file.created") + assertThat(damFileCreateEvent.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(damFileCreateEvent.data()) + .isEqualTo( + File.builder() + .addAiTag( + File.AiTag.builder().confidence(0.0).name("name").source("source").build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val damFileCreateEvent = + DamFileCreateEvent.builder() + .id("id") + .type("file.created") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + File.builder() + .addAiTag( + File.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .build() + + val roundtrippedDamFileCreateEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(damFileCreateEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDamFileCreateEvent).isEqualTo(damFileCreateEvent) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileDeleteEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileDeleteEventTest.kt new file mode 100644 index 00000000..b8905e08 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileDeleteEventTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DamFileDeleteEventTest { + + @Test + fun create() { + val damFileDeleteEvent = + DamFileDeleteEvent.builder() + .id("id") + .type("file.deleted") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data(DamFileDeleteEvent.Data.builder().fileId("fileId").build()) + .build() + + assertThat(damFileDeleteEvent.id()).isEqualTo("id") + assertThat(damFileDeleteEvent.type()).isEqualTo("file.deleted") + assertThat(damFileDeleteEvent.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(damFileDeleteEvent.data()) + .isEqualTo(DamFileDeleteEvent.Data.builder().fileId("fileId").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val damFileDeleteEvent = + DamFileDeleteEvent.builder() + .id("id") + .type("file.deleted") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data(DamFileDeleteEvent.Data.builder().fileId("fileId").build()) + .build() + + val roundtrippedDamFileDeleteEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(damFileDeleteEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDamFileDeleteEvent).isEqualTo(damFileDeleteEvent) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileUpdateEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileUpdateEventTest.kt new file mode 100644 index 00000000..a6c8f0e2 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileUpdateEventTest.kt @@ -0,0 +1,246 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import com.imagekit.api.models.files.File +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DamFileUpdateEventTest { + + @Test + fun create() { + val damFileUpdateEvent = + DamFileUpdateEvent.builder() + .id("id") + .type("file.updated") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + File.builder() + .addAiTag( + File.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .build() + + assertThat(damFileUpdateEvent.id()).isEqualTo("id") + assertThat(damFileUpdateEvent.type()).isEqualTo("file.updated") + assertThat(damFileUpdateEvent.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(damFileUpdateEvent.data()) + .isEqualTo( + File.builder() + .addAiTag( + File.AiTag.builder().confidence(0.0).name("name").source("source").build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val damFileUpdateEvent = + DamFileUpdateEvent.builder() + .id("id") + .type("file.updated") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + File.builder() + .addAiTag( + File.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .build() + + val roundtrippedDamFileUpdateEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(damFileUpdateEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDamFileUpdateEvent).isEqualTo(damFileUpdateEvent) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEventTest.kt new file mode 100644 index 00000000..c4c929f5 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEventTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DamFileVersionCreateEventTest { + + @Test + fun create() { + val damFileVersionCreateEvent = + DamFileVersionCreateEvent.builder() + .id("id") + .type("file-version.created") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data(JsonValue.from(mapOf())) + .build() + + assertThat(damFileVersionCreateEvent.id()).isEqualTo("id") + assertThat(damFileVersionCreateEvent.type()).isEqualTo("file-version.created") + assertThat(damFileVersionCreateEvent.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(damFileVersionCreateEvent._data()) + .isEqualTo(JsonValue.from(mapOf())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val damFileVersionCreateEvent = + DamFileVersionCreateEvent.builder() + .id("id") + .type("file-version.created") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data(JsonValue.from(mapOf())) + .build() + + val roundtrippedDamFileVersionCreateEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(damFileVersionCreateEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDamFileVersionCreateEvent).isEqualTo(damFileVersionCreateEvent) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileVersionDeleteEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileVersionDeleteEventTest.kt new file mode 100644 index 00000000..ecee651b --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileVersionDeleteEventTest.kt @@ -0,0 +1,65 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DamFileVersionDeleteEventTest { + + @Test + fun create() { + val damFileVersionDeleteEvent = + DamFileVersionDeleteEvent.builder() + .id("id") + .type("file-version.deleted") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + DamFileVersionDeleteEvent.Data.builder() + .fileId("fileId") + .versionId("versionId") + .build() + ) + .build() + + assertThat(damFileVersionDeleteEvent.id()).isEqualTo("id") + assertThat(damFileVersionDeleteEvent.type()).isEqualTo("file-version.deleted") + assertThat(damFileVersionDeleteEvent.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(damFileVersionDeleteEvent.data()) + .isEqualTo( + DamFileVersionDeleteEvent.Data.builder() + .fileId("fileId") + .versionId("versionId") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val damFileVersionDeleteEvent = + DamFileVersionDeleteEvent.builder() + .id("id") + .type("file-version.deleted") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + DamFileVersionDeleteEvent.Data.builder() + .fileId("fileId") + .versionId("versionId") + .build() + ) + .build() + + val roundtrippedDamFileVersionDeleteEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(damFileVersionDeleteEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDamFileVersionDeleteEvent).isEqualTo(damFileVersionDeleteEvent) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt index 420976f4..5d626e01 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.files.File import com.imagekit.api.models.files.Metadata import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -92,6 +93,11 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty } @Test @@ -269,6 +275,11 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty } @Test @@ -457,6 +468,11 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty } @Test @@ -757,6 +773,11 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty } @Test @@ -1023,6 +1044,11 @@ internal class UnsafeUnwrapWebhookEventTest { .contains(uploadPreTransformError) assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty } @Test @@ -1113,6 +1139,11 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()) .contains(uploadPostTransformSuccess) assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty } @Test @@ -1218,6 +1249,11 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()) .contains(uploadPostTransformError) + assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty } @Test @@ -1278,6 +1314,536 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(roundtrippedUnsafeUnwrapWebhookEvent).isEqualTo(unsafeUnwrapWebhookEvent) } + @Test + fun ofDamFileCreate() { + val damFileCreate = + DamFileCreateEvent.builder() + .id("id") + .type("file.created") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + File.builder() + .addAiTag( + File.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .build() + + val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofDamFileCreate(damFileCreate) + + assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).contains(damFileCreate) + assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty + } + + @Test + fun ofDamFileCreateRoundtrip() { + val jsonMapper = jsonMapper() + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofDamFileCreate( + DamFileCreateEvent.builder() + .id("id") + .type("file.created") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + File.builder() + .addAiTag( + File.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf( + "small", + "medium", + "large", + 30, + 40, + true, + ), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .build() + ) + + val roundtrippedUnsafeUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unsafeUnwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnsafeUnwrapWebhookEvent).isEqualTo(unsafeUnwrapWebhookEvent) + } + + @Test + fun ofDamFileUpdate() { + val damFileUpdate = + DamFileUpdateEvent.builder() + .id("id") + .type("file.updated") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + File.builder() + .addAiTag( + File.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .build() + + val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofDamFileUpdate(damFileUpdate) + + assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).contains(damFileUpdate) + assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty + } + + @Test + fun ofDamFileUpdateRoundtrip() { + val jsonMapper = jsonMapper() + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofDamFileUpdate( + DamFileUpdateEvent.builder() + .id("id") + .type("file.updated") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + File.builder() + .addAiTag( + File.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf( + "small", + "medium", + "large", + 30, + 40, + true, + ), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .build() + ) + + val roundtrippedUnsafeUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unsafeUnwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnsafeUnwrapWebhookEvent).isEqualTo(unsafeUnwrapWebhookEvent) + } + + @Test + fun ofDamFileDelete() { + val damFileDelete = + DamFileDeleteEvent.builder() + .id("id") + .type("file.deleted") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data(DamFileDeleteEvent.Data.builder().fileId("fileId").build()) + .build() + + val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofDamFileDelete(damFileDelete) + + assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).contains(damFileDelete) + assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty + } + + @Test + fun ofDamFileDeleteRoundtrip() { + val jsonMapper = jsonMapper() + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofDamFileDelete( + DamFileDeleteEvent.builder() + .id("id") + .type("file.deleted") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data(DamFileDeleteEvent.Data.builder().fileId("fileId").build()) + .build() + ) + + val roundtrippedUnsafeUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unsafeUnwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnsafeUnwrapWebhookEvent).isEqualTo(unsafeUnwrapWebhookEvent) + } + + @Test + fun ofDamFileVersionCreate() { + val damFileVersionCreate = + DamFileVersionCreateEvent.builder() + .id("id") + .type("file-version.created") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data(JsonValue.from(mapOf())) + .build() + + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofDamFileVersionCreate(damFileVersionCreate) + + assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).contains(damFileVersionCreate) + assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty + } + + @Test + fun ofDamFileVersionCreateRoundtrip() { + val jsonMapper = jsonMapper() + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofDamFileVersionCreate( + DamFileVersionCreateEvent.builder() + .id("id") + .type("file-version.created") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data(JsonValue.from(mapOf())) + .build() + ) + + val roundtrippedUnsafeUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unsafeUnwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnsafeUnwrapWebhookEvent).isEqualTo(unsafeUnwrapWebhookEvent) + } + + @Test + fun ofDamFileVersionDelete() { + val damFileVersionDelete = + DamFileVersionDeleteEvent.builder() + .id("id") + .type("file-version.deleted") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + DamFileVersionDeleteEvent.Data.builder() + .fileId("fileId") + .versionId("versionId") + .build() + ) + .build() + + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofDamFileVersionDelete(damFileVersionDelete) + + assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).contains(damFileVersionDelete) + } + + @Test + fun ofDamFileVersionDeleteRoundtrip() { + val jsonMapper = jsonMapper() + val unsafeUnwrapWebhookEvent = + UnsafeUnwrapWebhookEvent.ofDamFileVersionDelete( + DamFileVersionDeleteEvent.builder() + .id("id") + .type("file-version.deleted") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + DamFileVersionDeleteEvent.Data.builder() + .fileId("fileId") + .versionId("versionId") + .build() + ) + .build() + ) + + val roundtrippedUnsafeUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unsafeUnwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnsafeUnwrapWebhookEvent).isEqualTo(unsafeUnwrapWebhookEvent) + } + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { BOOLEAN(JsonValue.from(false)), STRING(JsonValue.from("invalid")), diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt index 52ff87bf..7576efbb 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.files.File import com.imagekit.api.models.files.Metadata import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -92,6 +93,11 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty } @Test @@ -268,6 +274,11 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty } @Test @@ -455,6 +466,11 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty } @Test @@ -755,6 +771,11 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty } @Test @@ -1020,6 +1041,11 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).contains(uploadPreTransformError) assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty } @Test @@ -1110,6 +1136,11 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()) .contains(uploadPostTransformSuccess) assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty } @Test @@ -1214,6 +1245,11 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).contains(uploadPostTransformError) + assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty } @Test @@ -1274,6 +1310,534 @@ internal class UnwrapWebhookEventTest { assertThat(roundtrippedUnwrapWebhookEvent).isEqualTo(unwrapWebhookEvent) } + @Test + fun ofDamFileCreate() { + val damFileCreate = + DamFileCreateEvent.builder() + .id("id") + .type("file.created") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + File.builder() + .addAiTag( + File.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .build() + + val unwrapWebhookEvent = UnwrapWebhookEvent.ofDamFileCreate(damFileCreate) + + assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unwrapWebhookEvent.damFileCreate()).contains(damFileCreate) + assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty + } + + @Test + fun ofDamFileCreateRoundtrip() { + val jsonMapper = jsonMapper() + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofDamFileCreate( + DamFileCreateEvent.builder() + .id("id") + .type("file.created") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + File.builder() + .addAiTag( + File.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf( + "small", + "medium", + "large", + 30, + 40, + true, + ), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .build() + ) + + val roundtrippedUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnwrapWebhookEvent).isEqualTo(unwrapWebhookEvent) + } + + @Test + fun ofDamFileUpdate() { + val damFileUpdate = + DamFileUpdateEvent.builder() + .id("id") + .type("file.updated") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + File.builder() + .addAiTag( + File.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .build() + + val unwrapWebhookEvent = UnwrapWebhookEvent.ofDamFileUpdate(damFileUpdate) + + assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileUpdate()).contains(damFileUpdate) + assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty + } + + @Test + fun ofDamFileUpdateRoundtrip() { + val jsonMapper = jsonMapper() + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofDamFileUpdate( + DamFileUpdateEvent.builder() + .id("id") + .type("file.updated") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + File.builder() + .addAiTag( + File.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf( + "small", + "medium", + "large", + 30, + 40, + true, + ), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) + .build() + ) + + val roundtrippedUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnwrapWebhookEvent).isEqualTo(unwrapWebhookEvent) + } + + @Test + fun ofDamFileDelete() { + val damFileDelete = + DamFileDeleteEvent.builder() + .id("id") + .type("file.deleted") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data(DamFileDeleteEvent.Data.builder().fileId("fileId").build()) + .build() + + val unwrapWebhookEvent = UnwrapWebhookEvent.ofDamFileDelete(damFileDelete) + + assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.damFileDelete()).contains(damFileDelete) + assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty + } + + @Test + fun ofDamFileDeleteRoundtrip() { + val jsonMapper = jsonMapper() + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofDamFileDelete( + DamFileDeleteEvent.builder() + .id("id") + .type("file.deleted") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data(DamFileDeleteEvent.Data.builder().fileId("fileId").build()) + .build() + ) + + val roundtrippedUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnwrapWebhookEvent).isEqualTo(unwrapWebhookEvent) + } + + @Test + fun ofDamFileVersionCreate() { + val damFileVersionCreate = + DamFileVersionCreateEvent.builder() + .id("id") + .type("file-version.created") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data(JsonValue.from(mapOf())) + .build() + + val unwrapWebhookEvent = UnwrapWebhookEvent.ofDamFileVersionCreate(damFileVersionCreate) + + assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionCreate()).contains(damFileVersionCreate) + assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty + } + + @Test + fun ofDamFileVersionCreateRoundtrip() { + val jsonMapper = jsonMapper() + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofDamFileVersionCreate( + DamFileVersionCreateEvent.builder() + .id("id") + .type("file-version.created") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data(JsonValue.from(mapOf())) + .build() + ) + + val roundtrippedUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnwrapWebhookEvent).isEqualTo(unwrapWebhookEvent) + } + + @Test + fun ofDamFileVersionDelete() { + val damFileVersionDelete = + DamFileVersionDeleteEvent.builder() + .id("id") + .type("file-version.deleted") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + DamFileVersionDeleteEvent.Data.builder() + .fileId("fileId") + .versionId("versionId") + .build() + ) + .build() + + val unwrapWebhookEvent = UnwrapWebhookEvent.ofDamFileVersionDelete(damFileVersionDelete) + + assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty + assertThat(unwrapWebhookEvent.videoTransformationError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty + assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty + assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.damFileVersionDelete()).contains(damFileVersionDelete) + } + + @Test + fun ofDamFileVersionDeleteRoundtrip() { + val jsonMapper = jsonMapper() + val unwrapWebhookEvent = + UnwrapWebhookEvent.ofDamFileVersionDelete( + DamFileVersionDeleteEvent.builder() + .id("id") + .type("file-version.deleted") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + DamFileVersionDeleteEvent.Data.builder() + .fileId("fileId") + .versionId("versionId") + .build() + ) + .build() + ) + + val roundtrippedUnwrapWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unwrapWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnwrapWebhookEvent).isEqualTo(unwrapWebhookEvent) + } + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { BOOLEAN(JsonValue.from(false)), STRING(JsonValue.from("invalid")), diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt index 15ebd90e..d0448524 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt @@ -56,7 +56,6 @@ internal class ErrorHandlingTest { ImageKitOkHttpClient.builder() .baseUrl(wmRuntimeInfo.httpBaseUrl) .privateKey("My Private Key") - .password("My Password") .build() } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt index 0f2117e7..7163c1ac 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt @@ -34,7 +34,6 @@ internal class ServiceParamsTest { ImageKitOkHttpClient.builder() .baseUrl(wmRuntimeInfo.httpBaseUrl) .privateKey("My Private Key") - .password("My Password") .build() } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt index e7a3e05a..794701e1 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt @@ -12,11 +12,7 @@ internal class AssetServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val assetServiceAsync = client.assets() val assetsFuture = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt index 05126f0d..bb7d6b7f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt @@ -14,11 +14,7 @@ internal class CustomMetadataFieldServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val customMetadataFieldServiceAsync = client.customMetadataFields() val customMetadataFieldFuture = @@ -67,11 +63,7 @@ internal class CustomMetadataFieldServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun update() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val customMetadataFieldServiceAsync = client.customMetadataFields() val customMetadataFieldFuture = @@ -119,11 +111,7 @@ internal class CustomMetadataFieldServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val customMetadataFieldServiceAsync = client.customMetadataFields() val customMetadataFieldsFuture = @@ -141,11 +129,7 @@ internal class CustomMetadataFieldServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val customMetadataFieldServiceAsync = client.customMetadataFields() val customMetadataFieldFuture = customMetadataFieldServiceAsync.delete("id") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index f9d0c9ab..b25f3b6c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -19,11 +19,7 @@ internal class FileServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun update() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val fileServiceAsync = client.files() val fileFuture = @@ -117,11 +113,7 @@ internal class FileServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val fileServiceAsync = client.files() val future = fileServiceAsync.delete("fileId") @@ -132,11 +124,7 @@ internal class FileServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun copy() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val fileServiceAsync = client.files() val responseFuture = @@ -155,11 +143,7 @@ internal class FileServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val fileServiceAsync = client.files() val fileFuture = fileServiceAsync.get("fileId") @@ -171,11 +155,7 @@ internal class FileServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun move() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val fileServiceAsync = client.files() val responseFuture = @@ -193,11 +173,7 @@ internal class FileServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun rename() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val fileServiceAsync = client.files() val responseFuture = @@ -216,11 +192,7 @@ internal class FileServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun upload() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val fileServiceAsync = client.files() val responseFuture = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt index 5d9e7f7b..26b74d1c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt @@ -16,11 +16,7 @@ internal class FolderServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val folderServiceAsync = client.folders() val folderFuture = @@ -38,11 +34,7 @@ internal class FolderServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val folderServiceAsync = client.folders() val folderFuture = @@ -57,11 +49,7 @@ internal class FolderServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun copy() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val folderServiceAsync = client.folders() val responseFuture = @@ -80,11 +68,7 @@ internal class FolderServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun move() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val folderServiceAsync = client.folders() val responseFuture = @@ -102,11 +86,7 @@ internal class FolderServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun rename() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val folderServiceAsync = client.folders() val responseFuture = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt index 60099607..018ac83d 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt @@ -14,11 +14,7 @@ internal class SavedExtensionServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val savedExtensionServiceAsync = client.savedExtensions() val savedExtensionFuture = @@ -50,11 +46,7 @@ internal class SavedExtensionServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun update() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val savedExtensionServiceAsync = client.savedExtensions() val savedExtensionFuture = @@ -85,11 +77,7 @@ internal class SavedExtensionServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val savedExtensionServiceAsync = client.savedExtensions() val savedExtensionsFuture = savedExtensionServiceAsync.list() @@ -101,11 +89,7 @@ internal class SavedExtensionServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val savedExtensionServiceAsync = client.savedExtensions() val future = savedExtensionServiceAsync.delete("id") @@ -116,11 +100,7 @@ internal class SavedExtensionServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val savedExtensionServiceAsync = client.savedExtensions() val savedExtensionFuture = savedExtensionServiceAsync.get("id") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt index 1b7f1056..4af4d40b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt @@ -15,11 +15,7 @@ internal class WebhookServiceAsyncTest { @Test fun unsafeUnwrap() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val webhookServiceAsync = client.webhooks() val payload = @@ -32,11 +28,7 @@ internal class WebhookServiceAsyncTest { @Test fun unwrap() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val webhookServiceAsync = client.webhooks() val payload = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt index 85eaf6b8..94223e47 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt @@ -13,11 +13,7 @@ internal class OriginServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val originServiceAsync = client.accounts().origins() val originResponseFuture = @@ -40,11 +36,7 @@ internal class OriginServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun update() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val originServiceAsync = client.accounts().origins() val originResponseFuture = @@ -72,11 +64,7 @@ internal class OriginServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val originServiceAsync = client.accounts().origins() val originResponsesFuture = originServiceAsync.list() @@ -88,11 +76,7 @@ internal class OriginServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val originServiceAsync = client.accounts().origins() val future = originServiceAsync.delete("id") @@ -103,11 +87,7 @@ internal class OriginServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val originServiceAsync = client.accounts().origins() val originResponseFuture = originServiceAsync.get("id") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt index b5a0bbb1..fe2d4f8d 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt @@ -13,11 +13,7 @@ internal class UrlEndpointServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val urlEndpointServiceAsync = client.accounts().urlEndpoints() val urlEndpointResponseFuture = @@ -41,11 +37,7 @@ internal class UrlEndpointServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun update() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val urlEndpointServiceAsync = client.accounts().urlEndpoints() val urlEndpointResponseFuture = @@ -74,11 +66,7 @@ internal class UrlEndpointServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val urlEndpointServiceAsync = client.accounts().urlEndpoints() val urlEndpointResponsesFuture = urlEndpointServiceAsync.list() @@ -90,11 +78,7 @@ internal class UrlEndpointServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val urlEndpointServiceAsync = client.accounts().urlEndpoints() val future = urlEndpointServiceAsync.delete("id") @@ -105,11 +89,7 @@ internal class UrlEndpointServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val urlEndpointServiceAsync = client.accounts().urlEndpoints() val urlEndpointResponseFuture = urlEndpointServiceAsync.get("id") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt index 1ff7697b..3b33aeda 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt @@ -13,11 +13,7 @@ internal class UsageServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val usageServiceAsync = client.accounts().usage() val usageFuture = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt index 9ac39ec8..95871e90 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt @@ -14,11 +14,7 @@ internal class FileServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun upload() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val fileServiceAsync = client.beta().v2().files() val responseFuture = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt index 373cbd39..c3710fa4 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt @@ -12,11 +12,7 @@ internal class InvalidationServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val invalidationServiceAsync = client.cache().invalidation() val invalidationFuture = @@ -33,11 +29,7 @@ internal class InvalidationServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val invalidationServiceAsync = client.cache().invalidation() val invalidationFuture = invalidationServiceAsync.get("requestId") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt index f4726319..750b00c1 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt @@ -15,11 +15,7 @@ internal class BulkServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val bulkServiceAsync = client.files().bulk() val bulkFuture = @@ -37,11 +33,7 @@ internal class BulkServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun addTags() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val bulkServiceAsync = client.files().bulk() val responseFuture = @@ -60,11 +52,7 @@ internal class BulkServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun removeAiTags() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val bulkServiceAsync = client.files().bulk() val responseFuture = @@ -83,11 +71,7 @@ internal class BulkServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun removeTags() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val bulkServiceAsync = client.files().bulk() val responseFuture = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt index a60fc3c3..d3b5a86d 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt @@ -12,11 +12,7 @@ internal class MetadataServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val metadataServiceAsync = client.files().metadata() val metadataFuture = metadataServiceAsync.get("fileId") @@ -28,11 +24,7 @@ internal class MetadataServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun getFromUrl() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val metadataServiceAsync = client.files().metadata() val metadataFuture = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt index 4774b045..f7674393 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt @@ -14,11 +14,7 @@ internal class VersionServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val versionServiceAsync = client.files().versions() val filesFuture = versionServiceAsync.list("fileId") @@ -30,11 +26,7 @@ internal class VersionServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val versionServiceAsync = client.files().versions() val versionFuture = @@ -49,11 +41,7 @@ internal class VersionServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val versionServiceAsync = client.files().versions() val fileFuture = @@ -68,11 +56,7 @@ internal class VersionServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun restore() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val versionServiceAsync = client.files().versions() val fileFuture = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt index 0013515c..91ef7197 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt @@ -11,11 +11,7 @@ internal class JobServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = - ImageKitOkHttpClientAsync.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() val jobServiceAsync = client.folders().job() val jobFuture = jobServiceAsync.get("jobId") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt index 8e46580b..0924f451 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt @@ -12,11 +12,7 @@ internal class AssetServiceTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val assetService = client.assets() val assets = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt index a88b8c8b..13e2d3d4 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt @@ -14,11 +14,7 @@ internal class CustomMetadataFieldServiceTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val customMetadataFieldService = client.customMetadataFields() val customMetadataField = @@ -66,11 +62,7 @@ internal class CustomMetadataFieldServiceTest { @Disabled("Mock server tests are disabled") @Test fun update() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val customMetadataFieldService = client.customMetadataFields() val customMetadataField = @@ -117,11 +109,7 @@ internal class CustomMetadataFieldServiceTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val customMetadataFieldService = client.customMetadataFields() val customMetadataFields = @@ -138,11 +126,7 @@ internal class CustomMetadataFieldServiceTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val customMetadataFieldService = client.customMetadataFields() val customMetadataField = customMetadataFieldService.delete("id") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index 477c11b0..9e490aa1 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -19,11 +19,7 @@ internal class FileServiceTest { @Disabled("Mock server tests are disabled") @Test fun update() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val fileService = client.files() val file = @@ -116,11 +112,7 @@ internal class FileServiceTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val fileService = client.files() fileService.delete("fileId") @@ -129,11 +121,7 @@ internal class FileServiceTest { @Disabled("Mock server tests are disabled") @Test fun copy() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val fileService = client.files() val response = @@ -151,11 +139,7 @@ internal class FileServiceTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val fileService = client.files() val file = fileService.get("fileId") @@ -166,11 +150,7 @@ internal class FileServiceTest { @Disabled("Mock server tests are disabled") @Test fun move() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val fileService = client.files() val response = @@ -187,11 +167,7 @@ internal class FileServiceTest { @Disabled("Mock server tests are disabled") @Test fun rename() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val fileService = client.files() val response = @@ -209,11 +185,7 @@ internal class FileServiceTest { @Disabled("Mock server tests are disabled") @Test fun upload() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val fileService = client.files() val response = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt index 6b2960a6..3f4f4a4e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt @@ -16,11 +16,7 @@ internal class FolderServiceTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val folderService = client.folders() val folder = @@ -37,11 +33,7 @@ internal class FolderServiceTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val folderService = client.folders() val folder = @@ -55,11 +47,7 @@ internal class FolderServiceTest { @Disabled("Mock server tests are disabled") @Test fun copy() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val folderService = client.folders() val response = @@ -77,11 +65,7 @@ internal class FolderServiceTest { @Disabled("Mock server tests are disabled") @Test fun move() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val folderService = client.folders() val response = @@ -98,11 +82,7 @@ internal class FolderServiceTest { @Disabled("Mock server tests are disabled") @Test fun rename() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val folderService = client.folders() val response = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt index fdc452d2..c4236c8a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt @@ -14,11 +14,7 @@ internal class SavedExtensionServiceTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val savedExtensionService = client.savedExtensions() val savedExtension = @@ -49,11 +45,7 @@ internal class SavedExtensionServiceTest { @Disabled("Mock server tests are disabled") @Test fun update() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val savedExtensionService = client.savedExtensions() val savedExtension = @@ -83,11 +75,7 @@ internal class SavedExtensionServiceTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val savedExtensionService = client.savedExtensions() val savedExtensions = savedExtensionService.list() @@ -98,11 +86,7 @@ internal class SavedExtensionServiceTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val savedExtensionService = client.savedExtensions() savedExtensionService.delete("id") @@ -111,11 +95,7 @@ internal class SavedExtensionServiceTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val savedExtensionService = client.savedExtensions() val savedExtension = savedExtensionService.get("id") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt index c8c85d90..c071f641 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt @@ -15,11 +15,7 @@ internal class WebhookServiceTest { @Test fun unsafeUnwrap() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val webhookService = client.webhooks() val payload = @@ -32,11 +28,7 @@ internal class WebhookServiceTest { @Test fun unwrap() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val webhookService = client.webhooks() val payload = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt index 9ce07bc5..bdf8ed80 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt @@ -13,11 +13,7 @@ internal class OriginServiceTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val originService = client.accounts().origins() val originResponse = @@ -39,11 +35,7 @@ internal class OriginServiceTest { @Disabled("Mock server tests are disabled") @Test fun update() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val originService = client.accounts().origins() val originResponse = @@ -70,11 +62,7 @@ internal class OriginServiceTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val originService = client.accounts().origins() val originResponses = originService.list() @@ -85,11 +73,7 @@ internal class OriginServiceTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val originService = client.accounts().origins() originService.delete("id") @@ -98,11 +82,7 @@ internal class OriginServiceTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val originService = client.accounts().origins() val originResponse = originService.get("id") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt index b0970249..2dab41aa 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt @@ -13,11 +13,7 @@ internal class UrlEndpointServiceTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val urlEndpointService = client.accounts().urlEndpoints() val urlEndpointResponse = @@ -40,11 +36,7 @@ internal class UrlEndpointServiceTest { @Disabled("Mock server tests are disabled") @Test fun update() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val urlEndpointService = client.accounts().urlEndpoints() val urlEndpointResponse = @@ -72,11 +64,7 @@ internal class UrlEndpointServiceTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val urlEndpointService = client.accounts().urlEndpoints() val urlEndpointResponses = urlEndpointService.list() @@ -87,11 +75,7 @@ internal class UrlEndpointServiceTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val urlEndpointService = client.accounts().urlEndpoints() urlEndpointService.delete("id") @@ -100,11 +84,7 @@ internal class UrlEndpointServiceTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val urlEndpointService = client.accounts().urlEndpoints() val urlEndpointResponse = urlEndpointService.get("id") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt index 74cf58ed..8685c0d9 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt @@ -13,11 +13,7 @@ internal class UsageServiceTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val usageService = client.accounts().usage() val usage = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt index 63433f0d..452f9911 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt @@ -14,11 +14,7 @@ internal class FileServiceTest { @Disabled("Mock server tests are disabled") @Test fun upload() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val fileService = client.beta().v2().files() val response = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt index 9d0a4b88..68be866a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt @@ -12,11 +12,7 @@ internal class InvalidationServiceTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val invalidationService = client.cache().invalidation() val invalidation = @@ -32,11 +28,7 @@ internal class InvalidationServiceTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val invalidationService = client.cache().invalidation() val invalidation = invalidationService.get("requestId") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt index 4c5321e0..67ee5e75 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt @@ -15,11 +15,7 @@ internal class BulkServiceTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val bulkService = client.files().bulk() val bulk = @@ -36,11 +32,7 @@ internal class BulkServiceTest { @Disabled("Mock server tests are disabled") @Test fun addTags() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val bulkService = client.files().bulk() val response = @@ -58,11 +50,7 @@ internal class BulkServiceTest { @Disabled("Mock server tests are disabled") @Test fun removeAiTags() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val bulkService = client.files().bulk() val response = @@ -80,11 +68,7 @@ internal class BulkServiceTest { @Disabled("Mock server tests are disabled") @Test fun removeTags() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val bulkService = client.files().bulk() val response = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt index 3c5e115f..9a64c696 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt @@ -12,11 +12,7 @@ internal class MetadataServiceTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val metadataService = client.files().metadata() val metadata = metadataService.get("fileId") @@ -27,11 +23,7 @@ internal class MetadataServiceTest { @Disabled("Mock server tests are disabled") @Test fun getFromUrl() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val metadataService = client.files().metadata() val metadata = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt index 383718f3..1c463694 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt @@ -14,11 +14,7 @@ internal class VersionServiceTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val versionService = client.files().versions() val files = versionService.list("fileId") @@ -29,11 +25,7 @@ internal class VersionServiceTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val versionService = client.files().versions() val version = @@ -47,11 +39,7 @@ internal class VersionServiceTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val versionService = client.files().versions() val file = @@ -65,11 +53,7 @@ internal class VersionServiceTest { @Disabled("Mock server tests are disabled") @Test fun restore() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val versionService = client.files().versions() val file = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt index fe1ac070..c6f1c4f2 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt @@ -11,11 +11,7 @@ internal class JobServiceTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() val jobService = client.folders().job() val job = jobService.get("jobId") diff --git a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt index a1ecd8d3..32fce394 100644 --- a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt +++ b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt @@ -49,11 +49,7 @@ internal class ProGuardCompatibilityTest { @Test fun client() { - val client = - ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") - .build() + val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() assertThat(client).isNotNull() assertThat(client.customMetadataFields()).isNotNull() From 26eba981e412103f0293fafd8888e3d075deec0d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 06:24:02 +0000 Subject: [PATCH 124/142] feat(api): fix spec indentation --- .stats.yml | 4 +- README.md | 1 + .../api/client/okhttp/OkHttpClient.kt | 4 +- .../com/imagekit/api/core/ClientOptions.kt | 11 +++++ .../imagekit/api/core/ClientOptionsTest.kt | 27 +++++++++++- .../api/services/ErrorHandlingTest.kt | 1 + .../api/services/ServiceParamsTest.kt | 1 + .../services/async/AssetServiceAsyncTest.kt | 6 ++- .../CustomMetadataFieldServiceAsyncTest.kt | 24 +++++++++-- .../services/async/FileServiceAsyncTest.kt | 42 +++++++++++++++---- .../services/async/FolderServiceAsyncTest.kt | 30 ++++++++++--- .../async/SavedExtensionServiceAsyncTest.kt | 30 ++++++++++--- .../services/async/WebhookServiceAsyncTest.kt | 12 +++++- .../async/accounts/OriginServiceAsyncTest.kt | 30 ++++++++++--- .../accounts/UrlEndpointServiceAsyncTest.kt | 30 ++++++++++--- .../async/accounts/UsageServiceAsyncTest.kt | 6 ++- .../async/beta/v2/FileServiceAsyncTest.kt | 6 ++- .../cache/InvalidationServiceAsyncTest.kt | 12 +++++- .../async/files/BulkServiceAsyncTest.kt | 24 +++++++++-- .../async/files/MetadataServiceAsyncTest.kt | 12 +++++- .../async/files/VersionServiceAsyncTest.kt | 24 +++++++++-- .../async/folders/JobServiceAsyncTest.kt | 6 ++- .../api/services/blocking/AssetServiceTest.kt | 6 ++- .../CustomMetadataFieldServiceTest.kt | 24 +++++++++-- .../api/services/blocking/FileServiceTest.kt | 42 +++++++++++++++---- .../services/blocking/FolderServiceTest.kt | 30 ++++++++++--- .../blocking/SavedExtensionServiceTest.kt | 30 ++++++++++--- .../services/blocking/WebhookServiceTest.kt | 12 +++++- .../blocking/accounts/OriginServiceTest.kt | 30 ++++++++++--- .../accounts/UrlEndpointServiceTest.kt | 30 ++++++++++--- .../blocking/accounts/UsageServiceTest.kt | 6 ++- .../blocking/beta/v2/FileServiceTest.kt | 6 ++- .../blocking/cache/InvalidationServiceTest.kt | 12 +++++- .../blocking/files/BulkServiceTest.kt | 24 +++++++++-- .../blocking/files/MetadataServiceTest.kt | 12 +++++- .../blocking/files/VersionServiceTest.kt | 24 +++++++++-- .../blocking/folders/JobServiceTest.kt | 6 ++- .../api/proguard/ProGuardCompatibilityTest.kt | 6 ++- 38 files changed, 540 insertions(+), 103 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3e331fe9..5beb1d71 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-1422f7513f230162270b197061e5768c2e0c803b94b8cd03a5e72544ac75a27f.yml -openapi_spec_hash: 41175e752e6f6ce900b36aecba687fa7 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-f4cd00365ba96133e0675eae3d5d3c6ac13874789e2ce69a84310ab64a4f87dd.yml +openapi_spec_hash: dce632cfbb5464a98c0f5d8eb9573d68 config_hash: 17e408231b0b01676298010c7405f483 diff --git a/README.md b/README.md index bceef44c..a7b10f6c 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; ImageKitClient client = ImageKitOkHttpClient.builder() .privateKey("My Private Key") + .password("My Password") .build(); ``` diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt index 708f2bc9..b9b0e81d 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt @@ -94,7 +94,9 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie else -> null } if (logLevel != null) { - clientBuilder.addNetworkInterceptor(HttpLoggingInterceptor().setLevel(logLevel)) + clientBuilder.addNetworkInterceptor( + HttpLoggingInterceptor().setLevel(logLevel).apply { redactHeader("Authorization") } + ) } requestOptions.timeout?.let { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt index ec994183..bfd06a44 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt @@ -10,6 +10,7 @@ import com.imagekit.api.core.http.QueryParams import com.imagekit.api.core.http.RetryingHttpClient import java.time.Clock import java.time.Duration +import java.util.Base64 import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -468,6 +469,16 @@ private constructor( // We replace after all the default headers to allow end-users to overwrite them. headers.replaceAll(this.headers.build()) queryParams.replaceAll(this.queryParams.build()) + privateKey.let { username -> + password?.let { password -> + if (!username.isEmpty() && !password.isEmpty()) { + headers.replace( + "Authorization", + "Basic ${Base64.getEncoder().encodeToString("$username:$password".toByteArray())}", + ) + } + } + } return ClientOptions( httpClient, diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt index 6eaf057f..323aed25 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt @@ -23,15 +23,40 @@ internal class ClientOptionsTest { .httpClient(httpClient) .putHeader("User-Agent", "My User Agent") .privateKey("My Private Key") + .password("My Password") .build() assertThat(clientOptions.headers.values("User-Agent")).containsExactly("My User Agent") } + @Test + fun toBuilder_basicAuthCanBeUpdated() { + var clientOptions = + ClientOptions.builder() + .httpClient(httpClient) + .privateKey("My Private Key") + .password("My Password") + .build() + + clientOptions = + clientOptions + .toBuilder() + .privateKey("another My Private Key") + .password("another My Password") + .build() + + assertThat(clientOptions.headers.values("Authorization")) + .containsExactly("Basic YW5vdGhlciBNeSBQcml2YXRlIEtleTphbm90aGVyIE15IFBhc3N3b3Jk") + } + @Test fun toBuilder_whenOriginalClientOptionsGarbageCollected_doesNotCloseOriginalClient() { var clientOptions = - ClientOptions.builder().httpClient(httpClient).privateKey("My Private Key").build() + ClientOptions.builder() + .httpClient(httpClient) + .privateKey("My Private Key") + .password("My Password") + .build() verify(httpClient, never()).close() // Overwrite the `clientOptions` variable so that the original `ClientOptions` is GC'd. diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt index d0448524..15ebd90e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt @@ -56,6 +56,7 @@ internal class ErrorHandlingTest { ImageKitOkHttpClient.builder() .baseUrl(wmRuntimeInfo.httpBaseUrl) .privateKey("My Private Key") + .password("My Password") .build() } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt index 7163c1ac..0f2117e7 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt @@ -34,6 +34,7 @@ internal class ServiceParamsTest { ImageKitOkHttpClient.builder() .baseUrl(wmRuntimeInfo.httpBaseUrl) .privateKey("My Private Key") + .password("My Password") .build() } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt index 794701e1..e7a3e05a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt @@ -12,7 +12,11 @@ internal class AssetServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val assetServiceAsync = client.assets() val assetsFuture = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt index bb7d6b7f..05126f0d 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt @@ -14,7 +14,11 @@ internal class CustomMetadataFieldServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val customMetadataFieldServiceAsync = client.customMetadataFields() val customMetadataFieldFuture = @@ -63,7 +67,11 @@ internal class CustomMetadataFieldServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun update() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val customMetadataFieldServiceAsync = client.customMetadataFields() val customMetadataFieldFuture = @@ -111,7 +119,11 @@ internal class CustomMetadataFieldServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val customMetadataFieldServiceAsync = client.customMetadataFields() val customMetadataFieldsFuture = @@ -129,7 +141,11 @@ internal class CustomMetadataFieldServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val customMetadataFieldServiceAsync = client.customMetadataFields() val customMetadataFieldFuture = customMetadataFieldServiceAsync.delete("id") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index b25f3b6c..f9d0c9ab 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -19,7 +19,11 @@ internal class FileServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun update() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val fileServiceAsync = client.files() val fileFuture = @@ -113,7 +117,11 @@ internal class FileServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val fileServiceAsync = client.files() val future = fileServiceAsync.delete("fileId") @@ -124,7 +132,11 @@ internal class FileServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun copy() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val fileServiceAsync = client.files() val responseFuture = @@ -143,7 +155,11 @@ internal class FileServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val fileServiceAsync = client.files() val fileFuture = fileServiceAsync.get("fileId") @@ -155,7 +171,11 @@ internal class FileServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun move() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val fileServiceAsync = client.files() val responseFuture = @@ -173,7 +193,11 @@ internal class FileServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun rename() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val fileServiceAsync = client.files() val responseFuture = @@ -192,7 +216,11 @@ internal class FileServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun upload() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val fileServiceAsync = client.files() val responseFuture = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt index 26b74d1c..5d9e7f7b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt @@ -16,7 +16,11 @@ internal class FolderServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val folderServiceAsync = client.folders() val folderFuture = @@ -34,7 +38,11 @@ internal class FolderServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val folderServiceAsync = client.folders() val folderFuture = @@ -49,7 +57,11 @@ internal class FolderServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun copy() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val folderServiceAsync = client.folders() val responseFuture = @@ -68,7 +80,11 @@ internal class FolderServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun move() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val folderServiceAsync = client.folders() val responseFuture = @@ -86,7 +102,11 @@ internal class FolderServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun rename() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val folderServiceAsync = client.folders() val responseFuture = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt index 018ac83d..60099607 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt @@ -14,7 +14,11 @@ internal class SavedExtensionServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val savedExtensionServiceAsync = client.savedExtensions() val savedExtensionFuture = @@ -46,7 +50,11 @@ internal class SavedExtensionServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun update() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val savedExtensionServiceAsync = client.savedExtensions() val savedExtensionFuture = @@ -77,7 +85,11 @@ internal class SavedExtensionServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val savedExtensionServiceAsync = client.savedExtensions() val savedExtensionsFuture = savedExtensionServiceAsync.list() @@ -89,7 +101,11 @@ internal class SavedExtensionServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val savedExtensionServiceAsync = client.savedExtensions() val future = savedExtensionServiceAsync.delete("id") @@ -100,7 +116,11 @@ internal class SavedExtensionServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val savedExtensionServiceAsync = client.savedExtensions() val savedExtensionFuture = savedExtensionServiceAsync.get("id") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt index 4af4d40b..1b7f1056 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt @@ -15,7 +15,11 @@ internal class WebhookServiceAsyncTest { @Test fun unsafeUnwrap() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val webhookServiceAsync = client.webhooks() val payload = @@ -28,7 +32,11 @@ internal class WebhookServiceAsyncTest { @Test fun unwrap() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val webhookServiceAsync = client.webhooks() val payload = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt index 94223e47..85eaf6b8 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt @@ -13,7 +13,11 @@ internal class OriginServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val originServiceAsync = client.accounts().origins() val originResponseFuture = @@ -36,7 +40,11 @@ internal class OriginServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun update() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val originServiceAsync = client.accounts().origins() val originResponseFuture = @@ -64,7 +72,11 @@ internal class OriginServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val originServiceAsync = client.accounts().origins() val originResponsesFuture = originServiceAsync.list() @@ -76,7 +88,11 @@ internal class OriginServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val originServiceAsync = client.accounts().origins() val future = originServiceAsync.delete("id") @@ -87,7 +103,11 @@ internal class OriginServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val originServiceAsync = client.accounts().origins() val originResponseFuture = originServiceAsync.get("id") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt index fe2d4f8d..b5a0bbb1 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt @@ -13,7 +13,11 @@ internal class UrlEndpointServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val urlEndpointServiceAsync = client.accounts().urlEndpoints() val urlEndpointResponseFuture = @@ -37,7 +41,11 @@ internal class UrlEndpointServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun update() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val urlEndpointServiceAsync = client.accounts().urlEndpoints() val urlEndpointResponseFuture = @@ -66,7 +74,11 @@ internal class UrlEndpointServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val urlEndpointServiceAsync = client.accounts().urlEndpoints() val urlEndpointResponsesFuture = urlEndpointServiceAsync.list() @@ -78,7 +90,11 @@ internal class UrlEndpointServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val urlEndpointServiceAsync = client.accounts().urlEndpoints() val future = urlEndpointServiceAsync.delete("id") @@ -89,7 +105,11 @@ internal class UrlEndpointServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val urlEndpointServiceAsync = client.accounts().urlEndpoints() val urlEndpointResponseFuture = urlEndpointServiceAsync.get("id") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt index 3b33aeda..1ff7697b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt @@ -13,7 +13,11 @@ internal class UsageServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val usageServiceAsync = client.accounts().usage() val usageFuture = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt index 95871e90..9ac39ec8 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt @@ -14,7 +14,11 @@ internal class FileServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun upload() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val fileServiceAsync = client.beta().v2().files() val responseFuture = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt index c3710fa4..373cbd39 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt @@ -12,7 +12,11 @@ internal class InvalidationServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val invalidationServiceAsync = client.cache().invalidation() val invalidationFuture = @@ -29,7 +33,11 @@ internal class InvalidationServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val invalidationServiceAsync = client.cache().invalidation() val invalidationFuture = invalidationServiceAsync.get("requestId") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt index 750b00c1..f4726319 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt @@ -15,7 +15,11 @@ internal class BulkServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val bulkServiceAsync = client.files().bulk() val bulkFuture = @@ -33,7 +37,11 @@ internal class BulkServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun addTags() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val bulkServiceAsync = client.files().bulk() val responseFuture = @@ -52,7 +60,11 @@ internal class BulkServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun removeAiTags() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val bulkServiceAsync = client.files().bulk() val responseFuture = @@ -71,7 +83,11 @@ internal class BulkServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun removeTags() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val bulkServiceAsync = client.files().bulk() val responseFuture = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt index d3b5a86d..a60fc3c3 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt @@ -12,7 +12,11 @@ internal class MetadataServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val metadataServiceAsync = client.files().metadata() val metadataFuture = metadataServiceAsync.get("fileId") @@ -24,7 +28,11 @@ internal class MetadataServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun getFromUrl() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val metadataServiceAsync = client.files().metadata() val metadataFuture = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt index f7674393..4774b045 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt @@ -14,7 +14,11 @@ internal class VersionServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val versionServiceAsync = client.files().versions() val filesFuture = versionServiceAsync.list("fileId") @@ -26,7 +30,11 @@ internal class VersionServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val versionServiceAsync = client.files().versions() val versionFuture = @@ -41,7 +49,11 @@ internal class VersionServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val versionServiceAsync = client.files().versions() val fileFuture = @@ -56,7 +68,11 @@ internal class VersionServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun restore() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val versionServiceAsync = client.files().versions() val fileFuture = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt index 91ef7197..0013515c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt @@ -11,7 +11,11 @@ internal class JobServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = ImageKitOkHttpClientAsync.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClientAsync.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val jobServiceAsync = client.folders().job() val jobFuture = jobServiceAsync.get("jobId") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt index 0924f451..8e46580b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt @@ -12,7 +12,11 @@ internal class AssetServiceTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val assetService = client.assets() val assets = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt index 13e2d3d4..a88b8c8b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt @@ -14,7 +14,11 @@ internal class CustomMetadataFieldServiceTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val customMetadataFieldService = client.customMetadataFields() val customMetadataField = @@ -62,7 +66,11 @@ internal class CustomMetadataFieldServiceTest { @Disabled("Mock server tests are disabled") @Test fun update() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val customMetadataFieldService = client.customMetadataFields() val customMetadataField = @@ -109,7 +117,11 @@ internal class CustomMetadataFieldServiceTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val customMetadataFieldService = client.customMetadataFields() val customMetadataFields = @@ -126,7 +138,11 @@ internal class CustomMetadataFieldServiceTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val customMetadataFieldService = client.customMetadataFields() val customMetadataField = customMetadataFieldService.delete("id") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index 9e490aa1..477c11b0 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -19,7 +19,11 @@ internal class FileServiceTest { @Disabled("Mock server tests are disabled") @Test fun update() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val fileService = client.files() val file = @@ -112,7 +116,11 @@ internal class FileServiceTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val fileService = client.files() fileService.delete("fileId") @@ -121,7 +129,11 @@ internal class FileServiceTest { @Disabled("Mock server tests are disabled") @Test fun copy() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val fileService = client.files() val response = @@ -139,7 +151,11 @@ internal class FileServiceTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val fileService = client.files() val file = fileService.get("fileId") @@ -150,7 +166,11 @@ internal class FileServiceTest { @Disabled("Mock server tests are disabled") @Test fun move() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val fileService = client.files() val response = @@ -167,7 +187,11 @@ internal class FileServiceTest { @Disabled("Mock server tests are disabled") @Test fun rename() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val fileService = client.files() val response = @@ -185,7 +209,11 @@ internal class FileServiceTest { @Disabled("Mock server tests are disabled") @Test fun upload() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val fileService = client.files() val response = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt index 3f4f4a4e..6b2960a6 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt @@ -16,7 +16,11 @@ internal class FolderServiceTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val folderService = client.folders() val folder = @@ -33,7 +37,11 @@ internal class FolderServiceTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val folderService = client.folders() val folder = @@ -47,7 +55,11 @@ internal class FolderServiceTest { @Disabled("Mock server tests are disabled") @Test fun copy() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val folderService = client.folders() val response = @@ -65,7 +77,11 @@ internal class FolderServiceTest { @Disabled("Mock server tests are disabled") @Test fun move() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val folderService = client.folders() val response = @@ -82,7 +98,11 @@ internal class FolderServiceTest { @Disabled("Mock server tests are disabled") @Test fun rename() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val folderService = client.folders() val response = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt index c4236c8a..fdc452d2 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt @@ -14,7 +14,11 @@ internal class SavedExtensionServiceTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val savedExtensionService = client.savedExtensions() val savedExtension = @@ -45,7 +49,11 @@ internal class SavedExtensionServiceTest { @Disabled("Mock server tests are disabled") @Test fun update() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val savedExtensionService = client.savedExtensions() val savedExtension = @@ -75,7 +83,11 @@ internal class SavedExtensionServiceTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val savedExtensionService = client.savedExtensions() val savedExtensions = savedExtensionService.list() @@ -86,7 +98,11 @@ internal class SavedExtensionServiceTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val savedExtensionService = client.savedExtensions() savedExtensionService.delete("id") @@ -95,7 +111,11 @@ internal class SavedExtensionServiceTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val savedExtensionService = client.savedExtensions() val savedExtension = savedExtensionService.get("id") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt index c071f641..c8c85d90 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt @@ -15,7 +15,11 @@ internal class WebhookServiceTest { @Test fun unsafeUnwrap() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val webhookService = client.webhooks() val payload = @@ -28,7 +32,11 @@ internal class WebhookServiceTest { @Test fun unwrap() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val webhookService = client.webhooks() val payload = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt index bdf8ed80..9ce07bc5 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt @@ -13,7 +13,11 @@ internal class OriginServiceTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val originService = client.accounts().origins() val originResponse = @@ -35,7 +39,11 @@ internal class OriginServiceTest { @Disabled("Mock server tests are disabled") @Test fun update() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val originService = client.accounts().origins() val originResponse = @@ -62,7 +70,11 @@ internal class OriginServiceTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val originService = client.accounts().origins() val originResponses = originService.list() @@ -73,7 +85,11 @@ internal class OriginServiceTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val originService = client.accounts().origins() originService.delete("id") @@ -82,7 +98,11 @@ internal class OriginServiceTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val originService = client.accounts().origins() val originResponse = originService.get("id") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt index 2dab41aa..b0970249 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt @@ -13,7 +13,11 @@ internal class UrlEndpointServiceTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val urlEndpointService = client.accounts().urlEndpoints() val urlEndpointResponse = @@ -36,7 +40,11 @@ internal class UrlEndpointServiceTest { @Disabled("Mock server tests are disabled") @Test fun update() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val urlEndpointService = client.accounts().urlEndpoints() val urlEndpointResponse = @@ -64,7 +72,11 @@ internal class UrlEndpointServiceTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val urlEndpointService = client.accounts().urlEndpoints() val urlEndpointResponses = urlEndpointService.list() @@ -75,7 +87,11 @@ internal class UrlEndpointServiceTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val urlEndpointService = client.accounts().urlEndpoints() urlEndpointService.delete("id") @@ -84,7 +100,11 @@ internal class UrlEndpointServiceTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val urlEndpointService = client.accounts().urlEndpoints() val urlEndpointResponse = urlEndpointService.get("id") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt index 8685c0d9..74cf58ed 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt @@ -13,7 +13,11 @@ internal class UsageServiceTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val usageService = client.accounts().usage() val usage = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt index 452f9911..63433f0d 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt @@ -14,7 +14,11 @@ internal class FileServiceTest { @Disabled("Mock server tests are disabled") @Test fun upload() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val fileService = client.beta().v2().files() val response = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt index 68be866a..9d0a4b88 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt @@ -12,7 +12,11 @@ internal class InvalidationServiceTest { @Disabled("Mock server tests are disabled") @Test fun create() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val invalidationService = client.cache().invalidation() val invalidation = @@ -28,7 +32,11 @@ internal class InvalidationServiceTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val invalidationService = client.cache().invalidation() val invalidation = invalidationService.get("requestId") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt index 67ee5e75..4c5321e0 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt @@ -15,7 +15,11 @@ internal class BulkServiceTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val bulkService = client.files().bulk() val bulk = @@ -32,7 +36,11 @@ internal class BulkServiceTest { @Disabled("Mock server tests are disabled") @Test fun addTags() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val bulkService = client.files().bulk() val response = @@ -50,7 +58,11 @@ internal class BulkServiceTest { @Disabled("Mock server tests are disabled") @Test fun removeAiTags() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val bulkService = client.files().bulk() val response = @@ -68,7 +80,11 @@ internal class BulkServiceTest { @Disabled("Mock server tests are disabled") @Test fun removeTags() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val bulkService = client.files().bulk() val response = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt index 9a64c696..3c5e115f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt @@ -12,7 +12,11 @@ internal class MetadataServiceTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val metadataService = client.files().metadata() val metadata = metadataService.get("fileId") @@ -23,7 +27,11 @@ internal class MetadataServiceTest { @Disabled("Mock server tests are disabled") @Test fun getFromUrl() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val metadataService = client.files().metadata() val metadata = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt index 1c463694..383718f3 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt @@ -14,7 +14,11 @@ internal class VersionServiceTest { @Disabled("Mock server tests are disabled") @Test fun list() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val versionService = client.files().versions() val files = versionService.list("fileId") @@ -25,7 +29,11 @@ internal class VersionServiceTest { @Disabled("Mock server tests are disabled") @Test fun delete() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val versionService = client.files().versions() val version = @@ -39,7 +47,11 @@ internal class VersionServiceTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val versionService = client.files().versions() val file = @@ -53,7 +65,11 @@ internal class VersionServiceTest { @Disabled("Mock server tests are disabled") @Test fun restore() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val versionService = client.files().versions() val file = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt index c6f1c4f2..fe1ac070 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt @@ -11,7 +11,11 @@ internal class JobServiceTest { @Disabled("Mock server tests are disabled") @Test fun get() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() val jobService = client.folders().job() val job = jobService.get("jobId") diff --git a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt index 32fce394..a1ecd8d3 100644 --- a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt +++ b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt @@ -49,7 +49,11 @@ internal class ProGuardCompatibilityTest { @Test fun client() { - val client = ImageKitOkHttpClient.builder().privateKey("My Private Key").build() + val client = + ImageKitOkHttpClient.builder() + .privateKey("My Private Key") + .password("My Password") + .build() assertThat(client).isNotNull() assertThat(client.customMetadataFields()).isNotNull() From 0caeef861804c31031de369a40e0ac755ff26396 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 06:30:44 +0000 Subject: [PATCH 125/142] feat(api): indentation fix --- .stats.yml | 4 +- .../webhooks/DamFileVersionCreateEvent.kt | 40 +++- .../webhooks/DamFileVersionCreateEventTest.kt | 203 +++++++++++++++++- .../webhooks/UnsafeUnwrapWebhookEventTest.kt | 143 +++++++++++- .../models/webhooks/UnwrapWebhookEventTest.kt | 143 +++++++++++- 5 files changed, 513 insertions(+), 20 deletions(-) diff --git a/.stats.yml b/.stats.yml index 5beb1d71..3ae941b7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-f4cd00365ba96133e0675eae3d5d3c6ac13874789e2ce69a84310ab64a4f87dd.yml -openapi_spec_hash: dce632cfbb5464a98c0f5d8eb9573d68 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-3234424a3a5871f31f5d6dcb8173593fc6c1db14802a0e71f14f3527ad16c871.yml +openapi_spec_hash: 017a8ab68d905ed9e163022f68d8be78 config_hash: 17e408231b0b01676298010c7405f483 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEvent.kt index a915c1b5..10663dd1 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEvent.kt @@ -12,9 +12,11 @@ import com.imagekit.api.core.JsonMissing import com.imagekit.api.core.JsonValue import com.imagekit.api.core.checkRequired import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.files.File import java.time.OffsetDateTime import java.util.Collections import java.util.Objects +import kotlin.jvm.optionals.getOrNull /** Triggered when a file version is created. */ class DamFileVersionCreateEvent @@ -23,7 +25,7 @@ private constructor( private val id: JsonField, private val type: JsonField, private val createdAt: JsonField, - private val data: JsonValue, + private val data: JsonField, private val additionalProperties: MutableMap, ) { @@ -34,7 +36,7 @@ private constructor( @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing data: JsonValue = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), ) : this(id, type, createdAt, data, mutableMapOf()) fun toBaseWebhookEvent(): BaseWebhookEvent = @@ -65,12 +67,12 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") /** - * This arbitrary value can be deserialized into a custom type using the `convert` method: - * ```java - * MyClass myObject = damFileVersionCreateEvent.data().convert(MyClass.class); - * ``` + * Object containing details of a file or file version. + * + * @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). */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonValue = data + fun data(): File = data.getRequired("data") /** * Returns the raw JSON value of [id]. @@ -95,6 +97,13 @@ private constructor( @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -129,7 +138,7 @@ private constructor( private var id: JsonField? = null private var type: JsonField? = null private var createdAt: JsonField? = null - private var data: JsonValue? = null + private var data: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -175,7 +184,16 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - fun data(data: JsonValue) = apply { this.data = data } + /** Object containing details of a file or file version. */ + fun data(data: File) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [File] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -231,6 +249,7 @@ private constructor( id() type() createdAt() + data().validate() validated = true } @@ -251,7 +270,8 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (type.asKnown().isPresent) 1 else 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) override fun equals(other: Any?): Boolean { if (this === other) { diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEventTest.kt index c4c929f5..57ac1f9c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEventTest.kt @@ -5,6 +5,7 @@ package com.imagekit.api.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper +import com.imagekit.api.models.files.File import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -18,15 +19,143 @@ internal class DamFileVersionCreateEventTest { .id("id") .type("file-version.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .data(JsonValue.from(mapOf())) + .data( + File.builder() + .addAiTag( + File.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) .build() assertThat(damFileVersionCreateEvent.id()).isEqualTo("id") assertThat(damFileVersionCreateEvent.type()).isEqualTo("file-version.created") assertThat(damFileVersionCreateEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(damFileVersionCreateEvent._data()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(damFileVersionCreateEvent.data()) + .isEqualTo( + File.builder() + .addAiTag( + File.AiTag.builder().confidence(0.0).name("name").source("source").build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) } @Test @@ -37,7 +166,73 @@ internal class DamFileVersionCreateEventTest { .id("id") .type("file-version.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .data(JsonValue.from(mapOf())) + .data( + File.builder() + .addAiTag( + File.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) .build() val roundtrippedDamFileVersionCreateEvent = diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt index 5d626e01..05850b5b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt @@ -1743,7 +1743,73 @@ internal class UnsafeUnwrapWebhookEventTest { .id("id") .type("file-version.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .data(JsonValue.from(mapOf())) + .data( + File.builder() + .addAiTag( + File.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) .build() val unsafeUnwrapWebhookEvent = @@ -1772,7 +1838,80 @@ internal class UnsafeUnwrapWebhookEventTest { .id("id") .type("file-version.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .data(JsonValue.from(mapOf())) + .data( + File.builder() + .addAiTag( + File.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf( + "small", + "medium", + "large", + 30, + 40, + true, + ), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt index 7576efbb..3cf50400 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt @@ -1739,7 +1739,73 @@ internal class UnwrapWebhookEventTest { .id("id") .type("file-version.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .data(JsonValue.from(mapOf())) + .data( + File.builder() + .addAiTag( + File.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) .build() val unwrapWebhookEvent = UnwrapWebhookEvent.ofDamFileVersionCreate(damFileVersionCreate) @@ -1767,7 +1833,80 @@ internal class UnwrapWebhookEventTest { .id("id") .type("file-version.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .data(JsonValue.from(mapOf())) + .data( + File.builder() + .addAiTag( + File.AiTag.builder() + .confidence(0.0) + .name("name") + .source("source") + .build() + ) + .audioCodec("audioCodec") + .bitRate(0L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customCoordinates("customCoordinates") + .customMetadata( + File.CustomMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .description("description") + .duration(0L) + .embeddedMetadata( + File.EmbeddedMetadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .fileId("fileId") + .filePath("filePath") + .fileType("fileType") + .hasAlpha(true) + .height(0.0) + .isPrivateFile(true) + .isPublished(true) + .mime("mime") + .name("name") + .selectedFieldsSchema( + File.SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to "string", + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to + listOf( + "small", + "medium", + "large", + 30, + 40, + true, + ), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + ) + .size(0.0) + .addTag("string") + .thumbnail("https://example.com") + .type(File.Type.FILE) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .videoCodec("videoCodec") + .width(0.0) + .build() + ) .build() ) From fb7f512d8932eb43656a89fdce6ccc8f59b3ebb6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 06:39:12 +0000 Subject: [PATCH 126/142] feat(api): merge with main to bring back missing parameters --- .stats.yml | 4 +- .../imagekit/api/models/ExtensionConfig.kt | 23 +- .../imagekit/api/models/OverlayPosition.kt | 758 +++++++++++++++++- .../models/beta/v2/files/FileUploadParams.kt | 25 +- .../api/models/files/FileUploadParams.kt | 25 +- .../api/models/files/UpdateFileRequest.kt | 26 +- .../imagekit/api/models/BaseOverlayTest.kt | 15 +- .../models/GetImageAttributesOptionsTest.kt | 9 + .../imagekit/api/models/ImageOverlayTest.kt | 24 +- .../api/models/OverlayPositionTest.kt | 23 +- .../com/imagekit/api/models/OverlayTest.kt | 42 + .../api/models/SolidColorOverlayTest.kt | 15 +- .../com/imagekit/api/models/SrcOptionsTest.kt | 9 + .../api/models/SubtitleOverlayTest.kt | 15 +- .../imagekit/api/models/TextOverlayTest.kt | 15 +- .../imagekit/api/models/TransformationTest.kt | 9 + .../imagekit/api/models/VideoOverlayTest.kt | 24 +- 17 files changed, 988 insertions(+), 73 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3ae941b7..0898c6b1 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-3234424a3a5871f31f5d6dcb8173593fc6c1db14802a0e71f14f3527ad16c871.yml -openapi_spec_hash: 017a8ab68d905ed9e163022f68d8be78 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-18b46cb8c1dd5cd0eea8559fa9671600540c5c4bee32f2d74f932416b7a1aee0.yml +openapi_spec_hash: 539770659847d04a92ef965a5313adde config_hash: 17e408231b0b01676298010c7405f483 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt index 89692a98..fce20326 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt @@ -1613,8 +1613,9 @@ private constructor( fun minSelections(): Optional = minSelections.getOptional("min_selections") /** - * Array of possible tag values. Combined length of all strings must not exceed 500 - * characters. Cannot contain the `%` character. + * Array of possible tag values. The combined length of all strings must not exceed + * 500 characters, and values cannot include the `%` character. When providing large + * vocabularies (more than 30 items), the AI may not follow the list strictly. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -1765,8 +1766,10 @@ private constructor( } /** - * Array of possible tag values. Combined length of all strings must not exceed - * 500 characters. Cannot contain the `%` character. + * Array of possible tag values. The combined length of all strings must not + * exceed 500 characters, and values cannot include the `%` character. When + * providing large vocabularies (more than 30 items), the AI may not follow the + * list strictly. */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) @@ -1999,7 +2002,10 @@ private constructor( fun minSelections(): Optional = minSelections.getOptional("min_selections") /** - * Array of possible values matching the custom metadata field type. + * An array of possible values matching the custom metadata field type. If not + * provided for SingleSelect or MultiSelect field types, all values from the custom + * metadata field definition will be used. When providing large vocabularies (above + * 30 items), the AI may not strictly adhere to the list. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -2175,7 +2181,12 @@ private constructor( this.minSelections = minSelections } - /** Array of possible values matching the custom metadata field type. */ + /** + * An array of possible values matching the custom metadata field type. If not + * provided for SingleSelect or MultiSelect field types, all values from the + * custom metadata field definition will be used. When providing large + * vocabularies (above 30 items), the AI may not strictly adhere to the list. + */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt index 020f99a5..9baf1c6c 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt @@ -31,22 +31,41 @@ import kotlin.jvm.optionals.getOrNull class OverlayPosition @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val anchorPoint: JsonField, private val focus: JsonField, private val x: JsonField, + private val xCenter: JsonField, private val y: JsonField, + private val yCenter: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("anchorPoint") + @ExcludeMissing + anchorPoint: JsonField = JsonMissing.of(), @JsonProperty("focus") @ExcludeMissing focus: JsonField = JsonMissing.of(), @JsonProperty("x") @ExcludeMissing x: JsonField = JsonMissing.of(), + @JsonProperty("xCenter") @ExcludeMissing xCenter: JsonField = JsonMissing.of(), @JsonProperty("y") @ExcludeMissing y: JsonField = JsonMissing.of(), - ) : this(focus, x, y, mutableMapOf()) + @JsonProperty("yCenter") @ExcludeMissing yCenter: JsonField = JsonMissing.of(), + ) : this(anchorPoint, focus, x, xCenter, y, yCenter, mutableMapOf()) /** - * Specifies the position of the overlay relative to the parent image or video. Maps to `lfo` in - * the URL. + * Sets the anchor point on the base asset from which the overlay offset is calculated. The + * default value is `top_left`. Maps to `lap` in the URL. Can only be used with one or more of + * `x`, `y`, `xCenter`, or `yCenter`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun anchorPoint(): Optional = anchorPoint.getOptional("anchorPoint") + + /** + * Specifies the position of the overlay relative to the parent image or video. If one or more + * of `x`, `y`, `xCenter`, or `yCenter` parameters are specified, this parameter is ignored. + * Maps to `lfo` in the URL. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -64,6 +83,17 @@ private constructor( */ fun x(): Optional = x.getOptional("x") + /** + * Specifies the x-coordinate on the base asset where the overlay's center will be positioned. + * It also accepts arithmetic expressions such as `bw_mul_0.4` or `bw_sub_cw`. Maps to `lxc` in + * the URL. Cannot be used together with `x`, but can be used with `y`. Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun xCenter(): Optional = xCenter.getOptional("xCenter") + /** * Specifies the y-coordinate of the top-left corner of the base asset where the overlay's * top-left corner will be positioned. It also accepts arithmetic expressions such as @@ -75,6 +105,26 @@ private constructor( */ fun y(): Optional = y.getOptional("y") + /** + * Specifies the y-coordinate on the base asset where the overlay's center will be positioned. + * It also accepts arithmetic expressions such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `lyc` in + * the URL. Cannot be used together with `y`, but can be used with `x`. Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun yCenter(): Optional = yCenter.getOptional("yCenter") + + /** + * Returns the raw JSON value of [anchorPoint]. + * + * Unlike [anchorPoint], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("anchorPoint") + @ExcludeMissing + fun _anchorPoint(): JsonField = anchorPoint + /** * Returns the raw JSON value of [focus]. * @@ -89,6 +139,13 @@ private constructor( */ @JsonProperty("x") @ExcludeMissing fun _x(): JsonField = x + /** + * Returns the raw JSON value of [xCenter]. + * + * Unlike [xCenter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("xCenter") @ExcludeMissing fun _xCenter(): JsonField = xCenter + /** * Returns the raw JSON value of [y]. * @@ -96,6 +153,13 @@ private constructor( */ @JsonProperty("y") @ExcludeMissing fun _y(): JsonField = y + /** + * Returns the raw JSON value of [yCenter]. + * + * Unlike [yCenter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("yCenter") @ExcludeMissing fun _yCenter(): JsonField = yCenter + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -117,22 +181,47 @@ private constructor( /** A builder for [OverlayPosition]. */ class Builder internal constructor() { + private var anchorPoint: JsonField = JsonMissing.of() private var focus: JsonField = JsonMissing.of() private var x: JsonField = JsonMissing.of() + private var xCenter: JsonField = JsonMissing.of() private var y: JsonField = JsonMissing.of() + private var yCenter: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(overlayPosition: OverlayPosition) = apply { + anchorPoint = overlayPosition.anchorPoint focus = overlayPosition.focus x = overlayPosition.x + xCenter = overlayPosition.xCenter y = overlayPosition.y + yCenter = overlayPosition.yCenter additionalProperties = overlayPosition.additionalProperties.toMutableMap() } /** - * Specifies the position of the overlay relative to the parent image or video. Maps to - * `lfo` in the URL. + * Sets the anchor point on the base asset from which the overlay offset is calculated. The + * default value is `top_left`. Maps to `lap` in the URL. Can only be used with one or more + * of `x`, `y`, `xCenter`, or `yCenter`. + */ + fun anchorPoint(anchorPoint: AnchorPoint) = anchorPoint(JsonField.of(anchorPoint)) + + /** + * Sets [Builder.anchorPoint] to an arbitrary JSON value. + * + * You should usually call [Builder.anchorPoint] with a well-typed [AnchorPoint] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun anchorPoint(anchorPoint: JsonField) = apply { + this.anchorPoint = anchorPoint + } + + /** + * Specifies the position of the overlay relative to the parent image or video. If one or + * more of `x`, `y`, `xCenter`, or `yCenter` parameters are specified, this parameter is + * ignored. Maps to `lfo` in the URL. */ fun focus(focus: Focus) = focus(JsonField.of(focus)) @@ -166,6 +255,29 @@ private constructor( /** Alias for calling [x] with `X.ofString(string)`. */ fun x(string: String) = x(X.ofString(string)) + /** + * Specifies the x-coordinate on the base asset where the overlay's center will be + * positioned. It also accepts arithmetic expressions such as `bw_mul_0.4` or `bw_sub_cw`. + * Maps to `lxc` in the URL. Cannot be used together with `x`, but can be used with `y`. + * Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + */ + fun xCenter(xCenter: XCenter) = xCenter(JsonField.of(xCenter)) + + /** + * Sets [Builder.xCenter] to an arbitrary JSON value. + * + * You should usually call [Builder.xCenter] with a well-typed [XCenter] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun xCenter(xCenter: JsonField) = apply { this.xCenter = xCenter } + + /** Alias for calling [xCenter] with `XCenter.ofNumber(number)`. */ + fun xCenter(number: Double) = xCenter(XCenter.ofNumber(number)) + + /** Alias for calling [xCenter] with `XCenter.ofString(string)`. */ + fun xCenter(string: String) = xCenter(XCenter.ofString(string)) + /** * Specifies the y-coordinate of the top-left corner of the base asset where the overlay's * top-left corner will be positioned. It also accepts arithmetic expressions such as @@ -188,6 +300,29 @@ private constructor( /** Alias for calling [y] with `Y.ofString(string)`. */ fun y(string: String) = y(Y.ofString(string)) + /** + * Specifies the y-coordinate on the base asset where the overlay's center will be + * positioned. It also accepts arithmetic expressions such as `bh_mul_0.4` or `bh_sub_ch`. + * Maps to `lyc` in the URL. Cannot be used together with `y`, but can be used with `x`. + * Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + */ + fun yCenter(yCenter: YCenter) = yCenter(JsonField.of(yCenter)) + + /** + * Sets [Builder.yCenter] to an arbitrary JSON value. + * + * You should usually call [Builder.yCenter] with a well-typed [YCenter] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun yCenter(yCenter: JsonField) = apply { this.yCenter = yCenter } + + /** Alias for calling [yCenter] with `YCenter.ofNumber(number)`. */ + fun yCenter(number: Double) = yCenter(YCenter.ofNumber(number)) + + /** Alias for calling [yCenter] with `YCenter.ofString(string)`. */ + fun yCenter(string: String) = yCenter(YCenter.ofString(string)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -213,7 +348,15 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): OverlayPosition = - OverlayPosition(focus, x, y, additionalProperties.toMutableMap()) + OverlayPosition( + anchorPoint, + focus, + x, + xCenter, + y, + yCenter, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -223,9 +366,12 @@ private constructor( return@apply } + anchorPoint().ifPresent { it.validate() } focus().ifPresent { it.validate() } x().ifPresent { it.validate() } + xCenter().ifPresent { it.validate() } y().ifPresent { it.validate() } + yCenter().ifPresent { it.validate() } validated = true } @@ -244,13 +390,194 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (focus.asKnown().getOrNull()?.validity() ?: 0) + + (anchorPoint.asKnown().getOrNull()?.validity() ?: 0) + + (focus.asKnown().getOrNull()?.validity() ?: 0) + (x.asKnown().getOrNull()?.validity() ?: 0) + - (y.asKnown().getOrNull()?.validity() ?: 0) + (xCenter.asKnown().getOrNull()?.validity() ?: 0) + + (y.asKnown().getOrNull()?.validity() ?: 0) + + (yCenter.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Sets the anchor point on the base asset from which the overlay offset is calculated. The + * default value is `top_left`. Maps to `lap` in the URL. Can only be used with one or more of + * `x`, `y`, `xCenter`, or `yCenter`. + */ + class AnchorPoint @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TOP = of("top") + + @JvmField val LEFT = of("left") + + @JvmField val RIGHT = of("right") + + @JvmField val BOTTOM = of("bottom") + + @JvmField val TOP_LEFT = of("top_left") + + @JvmField val TOP_RIGHT = of("top_right") + + @JvmField val BOTTOM_LEFT = of("bottom_left") + + @JvmField val BOTTOM_RIGHT = of("bottom_right") + + @JvmField val CENTER = of("center") + + @JvmStatic fun of(value: String) = AnchorPoint(JsonField.of(value)) + } + + /** An enum containing [AnchorPoint]'s known values. */ + enum class Known { + TOP, + LEFT, + RIGHT, + BOTTOM, + TOP_LEFT, + TOP_RIGHT, + BOTTOM_LEFT, + BOTTOM_RIGHT, + CENTER, + } + + /** + * An enum containing [AnchorPoint]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AnchorPoint] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TOP, + LEFT, + RIGHT, + BOTTOM, + TOP_LEFT, + TOP_RIGHT, + BOTTOM_LEFT, + BOTTOM_RIGHT, + CENTER, + /** + * An enum member indicating that [AnchorPoint] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TOP -> Value.TOP + LEFT -> Value.LEFT + RIGHT -> Value.RIGHT + BOTTOM -> Value.BOTTOM + TOP_LEFT -> Value.TOP_LEFT + TOP_RIGHT -> Value.TOP_RIGHT + BOTTOM_LEFT -> Value.BOTTOM_LEFT + BOTTOM_RIGHT -> Value.BOTTOM_RIGHT + CENTER -> Value.CENTER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TOP -> Known.TOP + LEFT -> Known.LEFT + RIGHT -> Known.RIGHT + BOTTOM -> Known.BOTTOM + TOP_LEFT -> Known.TOP_LEFT + TOP_RIGHT -> Known.TOP_RIGHT + BOTTOM_LEFT -> Known.BOTTOM_LEFT + BOTTOM_RIGHT -> Known.BOTTOM_RIGHT + CENTER -> Known.CENTER + else -> throw ImageKitInvalidDataException("Unknown AnchorPoint: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AnchorPoint = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AnchorPoint && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } /** - * Specifies the position of the overlay relative to the parent image or video. Maps to `lfo` in - * the URL. + * Specifies the position of the overlay relative to the parent image or video. If one or more + * of `x`, `y`, `xCenter`, or `yCenter` parameters are specified, this parameter is ignored. + * Maps to `lfo` in the URL. */ class Focus @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -594,14 +921,14 @@ private constructor( } /** - * Specifies the y-coordinate of the top-left corner of the base asset where the overlay's - * top-left corner will be positioned. It also accepts arithmetic expressions such as - * `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn about + * Specifies the x-coordinate on the base asset where the overlay's center will be positioned. + * It also accepts arithmetic expressions such as `bw_mul_0.4` or `bw_sub_cw`. Maps to `lxc` in + * the URL. Cannot be used together with `x`, but can be used with `y`. Learn about * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). */ - @JsonDeserialize(using = Y.Deserializer::class) - @JsonSerialize(using = Y.Serializer::class) - class Y + @JsonDeserialize(using = XCenter.Deserializer::class) + @JsonSerialize(using = XCenter.Serializer::class) + class XCenter private constructor( private val number: Double? = null, private val string: String? = null, @@ -631,7 +958,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Y = apply { + fun validate(): XCenter = apply { if (validated) { return@apply } @@ -677,27 +1004,29 @@ private constructor( return true } - return other is Y && number == other.number && string == other.string + return other is XCenter && number == other.number && string == other.string } override fun hashCode(): Int = Objects.hash(number, string) override fun toString(): String = when { - number != null -> "Y{number=$number}" - string != null -> "Y{string=$string}" - _json != null -> "Y{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Y") + number != null -> "XCenter{number=$number}" + string != null -> "XCenter{string=$string}" + _json != null -> "XCenter{_unknown=$_json}" + else -> throw IllegalStateException("Invalid XCenter") } companion object { - @JvmStatic fun ofNumber(number: Double) = Y(number = number) + @JvmStatic fun ofNumber(number: Double) = XCenter(number = number) - @JvmStatic fun ofString(string: String) = Y(string = string) + @JvmStatic fun ofString(string: String) = XCenter(string = string) } - /** An interface that defines how to map each variant of [Y] to a value of type [T]. */ + /** + * An interface that defines how to map each variant of [XCenter] to a value of type [T]. + */ interface Visitor { fun visitNumber(number: Double): T @@ -705,31 +1034,32 @@ private constructor( fun visitString(string: String): T /** - * Maps an unknown variant of [Y] to a value of type [T]. + * Maps an unknown variant of [XCenter] to a value of type [T]. * - * An instance of [Y] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * An instance of [XCenter] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. * * @throws ImageKitInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Y: $json") + throw ImageKitInvalidDataException("Unknown XCenter: $json") } } - internal class Deserializer : BaseDeserializer(Y::class) { + internal class Deserializer : BaseDeserializer(XCenter::class) { - override fun ObjectCodec.deserialize(node: JsonNode): Y { + override fun ObjectCodec.deserialize(node: JsonNode): XCenter { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - Y(string = it, _json = json) + XCenter(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - Y(number = it, _json = json) + XCenter(number = it, _json = json) }, ) .filterNotNull() @@ -738,7 +1068,7 @@ private constructor( return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with // all the possible variants (e.g. deserializing from boolean). - 0 -> Y(_json = json) + 0 -> XCenter(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first // completely valid match, or simply the first match if none are completely @@ -748,7 +1078,179 @@ private constructor( } } - internal class Serializer : BaseSerializer(Y::class) { + internal class Serializer : BaseSerializer(XCenter::class) { + + override fun serialize( + value: XCenter, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid XCenter") + } + } + } + } + + /** + * Specifies the y-coordinate of the top-left corner of the base asset where the overlay's + * top-left corner will be positioned. It also accepts arithmetic expressions such as + * `bh_mul_0.4` or `bh_sub_ch`. Maps to `ly` in the URL. Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + */ + @JsonDeserialize(using = Y.Deserializer::class) + @JsonSerialize(using = Y.Serializer::class) + class Y + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Y = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Y && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "Y{number=$number}" + string != null -> "Y{string=$string}" + _json != null -> "Y{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Y") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Y(number = number) + + @JvmStatic fun ofString(string: String) = Y(string = string) + } + + /** An interface that defines how to map each variant of [Y] to a value of type [T]. */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Y] to a value of type [T]. + * + * An instance of [Y] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Y: $json") + } + } + + internal class Deserializer : BaseDeserializer(Y::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Y { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Y(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Y(number = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Y(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Y::class) { override fun serialize( value: Y, @@ -765,22 +1267,202 @@ private constructor( } } + /** + * Specifies the y-coordinate on the base asset where the overlay's center will be positioned. + * It also accepts arithmetic expressions such as `bh_mul_0.4` or `bh_sub_ch`. Maps to `lyc` in + * the URL. Cannot be used together with `y`, but can be used with `x`. Learn about + * [Arithmetic expressions](https://imagekit.io/docs/arithmetic-expressions-in-transformations). + */ + @JsonDeserialize(using = YCenter.Deserializer::class) + @JsonSerialize(using = YCenter.Serializer::class) + class YCenter + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): YCenter = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is YCenter && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "YCenter{number=$number}" + string != null -> "YCenter{string=$string}" + _json != null -> "YCenter{_unknown=$_json}" + else -> throw IllegalStateException("Invalid YCenter") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = YCenter(number = number) + + @JvmStatic fun ofString(string: String) = YCenter(string = string) + } + + /** + * An interface that defines how to map each variant of [YCenter] to a value of type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [YCenter] to a value of type [T]. + * + * An instance of [YCenter] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown YCenter: $json") + } + } + + internal class Deserializer : BaseDeserializer(YCenter::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): YCenter { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + YCenter(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + YCenter(number = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> YCenter(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(YCenter::class) { + + override fun serialize( + value: YCenter, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid YCenter") + } + } + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } return other is OverlayPosition && + anchorPoint == other.anchorPoint && focus == other.focus && x == other.x && + xCenter == other.xCenter && y == other.y && + yCenter == other.yCenter && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(focus, x, y, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(anchorPoint, focus, x, xCenter, y, yCenter, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "OverlayPosition{focus=$focus, x=$x, y=$y, additionalProperties=$additionalProperties}" + "OverlayPosition{anchorPoint=$anchorPoint, focus=$focus, x=$x, xCenter=$xCenter, y=$y, yCenter=$yCenter, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt index 9e52f25b..43895867 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt @@ -3811,8 +3811,10 @@ private constructor( minSelections.getOptional("min_selections") /** - * Array of possible tag values. Combined length of all strings must not exceed - * 500 characters. Cannot contain the `%` character. + * Array of possible tag values. The combined length of all strings must not + * exceed 500 characters, and values cannot include the `%` character. When + * providing large vocabularies (more than 30 items), the AI may not follow the + * list strictly. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -3965,8 +3967,10 @@ private constructor( } /** - * Array of possible tag values. Combined length of all strings must not - * exceed 500 characters. Cannot contain the `%` character. + * Array of possible tag values. The combined length of all strings must not + * exceed 500 characters, and values cannot include the `%` character. When + * providing large vocabularies (more than 30 items), the AI may not follow + * the list strictly. */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) @@ -4163,7 +4167,10 @@ private constructor( minSelections.getOptional("min_selections") /** - * Array of possible values matching the custom metadata field type. + * An array of possible values matching the custom metadata field type. If not + * provided for SingleSelect or MultiSelect field types, all values from the + * custom metadata field definition will be used. When providing large + * vocabularies (above 30 items), the AI may not strictly adhere to the list. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -4344,7 +4351,13 @@ private constructor( this.minSelections = minSelections } - /** Array of possible values matching the custom metadata field type. */ + /** + * An array of possible values matching the custom metadata field type. If + * not provided for SingleSelect or MultiSelect field types, all values from + * the custom metadata field definition will be used. When providing large + * vocabularies (above 30 items), the AI may not strictly adhere to the + * list. + */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt index a188bdb5..7d9abc94 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -4077,8 +4077,10 @@ private constructor( minSelections.getOptional("min_selections") /** - * Array of possible tag values. Combined length of all strings must not exceed - * 500 characters. Cannot contain the `%` character. + * Array of possible tag values. The combined length of all strings must not + * exceed 500 characters, and values cannot include the `%` character. When + * providing large vocabularies (more than 30 items), the AI may not follow the + * list strictly. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -4231,8 +4233,10 @@ private constructor( } /** - * Array of possible tag values. Combined length of all strings must not - * exceed 500 characters. Cannot contain the `%` character. + * Array of possible tag values. The combined length of all strings must not + * exceed 500 characters, and values cannot include the `%` character. When + * providing large vocabularies (more than 30 items), the AI may not follow + * the list strictly. */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) @@ -4429,7 +4433,10 @@ private constructor( minSelections.getOptional("min_selections") /** - * Array of possible values matching the custom metadata field type. + * An array of possible values matching the custom metadata field type. If not + * provided for SingleSelect or MultiSelect field types, all values from the + * custom metadata field definition will be used. When providing large + * vocabularies (above 30 items), the AI may not strictly adhere to the list. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -4610,7 +4617,13 @@ private constructor( this.minSelections = minSelections } - /** Array of possible values matching the custom metadata field type. */ + /** + * An array of possible values matching the custom metadata field type. If + * not provided for SingleSelect or MultiSelect field types, all values from + * the custom metadata field definition will be used. When providing large + * vocabularies (above 30 items), the AI may not strictly adhere to the + * list. + */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt index 888c2852..b61f39f0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt @@ -2558,8 +2558,10 @@ private constructor( minSelections.getOptional("min_selections") /** - * Array of possible tag values. Combined length of all strings must not - * exceed 500 characters. Cannot contain the `%` character. + * Array of possible tag values. The combined length of all strings must not + * exceed 500 characters, and values cannot include the `%` character. When + * providing large vocabularies (more than 30 items), the AI may not follow + * the list strictly. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). @@ -2715,8 +2717,10 @@ private constructor( } /** - * Array of possible tag values. Combined length of all strings must not - * exceed 500 characters. Cannot contain the `%` character. + * Array of possible tag values. The combined length of all strings must + * not exceed 500 characters, and values cannot include the `%` + * character. When providing large vocabularies (more than 30 items), + * the AI may not follow the list strictly. */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) @@ -2959,7 +2963,11 @@ private constructor( minSelections.getOptional("min_selections") /** - * Array of possible values matching the custom metadata field type. + * An array of possible values matching the custom metadata field type. If + * not provided for SingleSelect or MultiSelect field types, all values from + * the custom metadata field definition will be used. When providing large + * vocabularies (above 30 items), the AI may not strictly adhere to the + * list. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). @@ -3142,7 +3150,13 @@ private constructor( this.minSelections = minSelections } - /** Array of possible values matching the custom metadata field type. */ + /** + * An array of possible values matching the custom metadata field type. + * If not provided for SingleSelect or MultiSelect field types, all + * values from the custom metadata field definition will be used. When + * providing large vocabularies (above 30 items), the AI may not + * strictly adhere to the list. + */ fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt index 062380b7..4955f427 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt @@ -16,9 +16,12 @@ internal class BaseOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -27,7 +30,14 @@ internal class BaseOverlayTest { assertThat(baseOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(baseOverlay.position()) .contains( - OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .build() ) assertThat(baseOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -41,9 +51,12 @@ internal class BaseOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt index 161d626e..71e02e02 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt @@ -65,9 +65,12 @@ internal class GetImageAttributesOptionsTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -182,9 +185,12 @@ internal class GetImageAttributesOptionsTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -297,9 +303,12 @@ internal class GetImageAttributesOptionsTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt index ea386f83..f6866ef5 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt @@ -17,9 +17,12 @@ internal class ImageOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -66,9 +69,12 @@ internal class ImageOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -127,7 +133,14 @@ internal class ImageOverlayTest { assertThat(imageOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(imageOverlay.position()) .contains( - OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .build() ) assertThat(imageOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -175,9 +188,12 @@ internal class ImageOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -235,9 +251,12 @@ internal class ImageOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -284,9 +303,12 @@ internal class ImageOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayPositionTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayPositionTest.kt index a39aa652..3d474c62 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayPositionTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayPositionTest.kt @@ -12,18 +12,35 @@ internal class OverlayPositionTest { @Test fun create() { val overlayPosition = - OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() - + OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .build() + + assertThat(overlayPosition.anchorPoint()).contains(OverlayPosition.AnchorPoint.TOP) assertThat(overlayPosition.focus()).contains(OverlayPosition.Focus.CENTER) assertThat(overlayPosition.x()).contains(OverlayPosition.X.ofNumber(0.0)) + assertThat(overlayPosition.xCenter()).contains(OverlayPosition.XCenter.ofNumber(0.0)) assertThat(overlayPosition.y()).contains(OverlayPosition.Y.ofNumber(0.0)) + assertThat(overlayPosition.yCenter()).contains(OverlayPosition.YCenter.ofNumber(0.0)) } @Test fun roundtrip() { val jsonMapper = jsonMapper() val overlayPosition = - OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .build() val roundtrippedOverlayPosition = jsonMapper.readValue( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt index 47c32e03..cc0a81b5 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt @@ -21,9 +21,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -66,9 +69,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -107,9 +113,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -156,9 +165,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -232,9 +244,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -283,9 +298,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -355,9 +373,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -404,9 +425,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -480,9 +504,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -531,9 +558,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -603,9 +633,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -642,9 +675,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -677,9 +713,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -714,9 +753,12 @@ internal class OverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt index 27cae13f..a53b4de6 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt @@ -17,9 +17,12 @@ internal class SolidColorOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -39,7 +42,14 @@ internal class SolidColorOverlayTest { assertThat(solidColorOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(solidColorOverlay.position()) .contains( - OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .build() ) assertThat(solidColorOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -65,9 +75,12 @@ internal class SolidColorOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt index 4589be89..5e6f2a29 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt @@ -65,9 +65,12 @@ internal class SrcOptionsTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -176,9 +179,12 @@ internal class SrcOptionsTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -284,9 +290,12 @@ internal class SrcOptionsTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt index 35aea254..be605a48 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt @@ -17,9 +17,12 @@ internal class SubtitleOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -41,7 +44,14 @@ internal class SubtitleOverlayTest { assertThat(subtitleOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(subtitleOverlay.position()) .contains( - OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .build() ) assertThat(subtitleOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -69,9 +79,12 @@ internal class SubtitleOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt index 841a72dd..8227d262 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt @@ -17,9 +17,12 @@ internal class TextOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -47,7 +50,14 @@ internal class TextOverlayTest { assertThat(textOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(textOverlay.position()) .contains( - OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .build() ) assertThat(textOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -81,9 +91,12 @@ internal class TextOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt index 09bf721f..b27f75bd 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt @@ -53,9 +53,12 @@ internal class TransformationTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -145,9 +148,12 @@ internal class TransformationTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -239,9 +245,12 @@ internal class TransformationTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt index 19e48b9d..50cb287d 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt @@ -17,9 +17,12 @@ internal class VideoOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -66,9 +69,12 @@ internal class VideoOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -127,7 +133,14 @@ internal class VideoOverlayTest { assertThat(videoOverlay.layerMode()).contains(BaseOverlay.LayerMode.MULTIPLY) assertThat(videoOverlay.position()) .contains( - OverlayPosition.builder().focus(OverlayPosition.Focus.CENTER).x(0.0).y(0.0).build() + OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) + .focus(OverlayPosition.Focus.CENTER) + .x(0.0) + .xCenter(0.0) + .y(0.0) + .yCenter(0.0) + .build() ) assertThat(videoOverlay.timing()) .contains(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -175,9 +188,12 @@ internal class VideoOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( @@ -235,9 +251,12 @@ internal class VideoOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing(OverlayTiming.builder().duration(0.0).end(0.0).start(0.0).build()) @@ -284,9 +303,12 @@ internal class VideoOverlayTest { .layerMode(BaseOverlay.LayerMode.MULTIPLY) .position( OverlayPosition.builder() + .anchorPoint(OverlayPosition.AnchorPoint.TOP) .focus(OverlayPosition.Focus.CENTER) .x(0.0) + .xCenter(0.0) .y(0.0) + .yCenter(0.0) .build() ) .timing( From 0cbbc63ad53db27fae27e4b0f470b3242d8bdaeb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 06:54:51 +0000 Subject: [PATCH 127/142] feat(api): update webhook event names and remove DAM prefix --- .stats.yml | 4 +- ...ateEvent.kt => FileCreatedWebhookEvent.kt} | 30 +-- ...eteEvent.kt => FileDeletedWebhookEvent.kt} | 30 +-- ...ateEvent.kt => FileUpdatedWebhookEvent.kt} | 30 +-- ...t.kt => FileVersionCreatedWebhookEvent.kt} | 32 +-- ...t.kt => FileVersionDeletedWebhookEvent.kt} | 32 +-- .../webhooks/UnsafeUnwrapWebhookEvent.kt | 208 +++++++++--------- .../api/models/webhooks/UnwrapWebhookEvent.kt | 204 +++++++++-------- .../models/webhooks/DamFileDeleteEventTest.kt | 50 ----- ...Test.kt => FileCreatedWebhookEventTest.kt} | 26 +-- .../webhooks/FileDeletedWebhookEventTest.kt | 50 +++++ ...Test.kt => FileUpdatedWebhookEventTest.kt} | 26 +-- ... => FileVersionCreatedWebhookEventTest.kt} | 27 +-- ... => FileVersionDeletedWebhookEventTest.kt} | 33 +-- .../webhooks/UnsafeUnwrapWebhookEventTest.kt | 198 ++++++++--------- .../models/webhooks/UnwrapWebhookEventTest.kt | 198 ++++++++--------- 16 files changed, 590 insertions(+), 588 deletions(-) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{DamFileCreateEvent.kt => FileCreatedWebhookEvent.kt} (91%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{DamFileDeleteEvent.kt => FileDeletedWebhookEvent.kt} (94%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{DamFileUpdateEvent.kt => FileUpdatedWebhookEvent.kt} (91%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{DamFileVersionCreateEvent.kt => FileVersionCreatedWebhookEvent.kt} (90%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{DamFileVersionDeleteEvent.kt => FileVersionDeletedWebhookEvent.kt} (94%) delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileDeleteEventTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/{DamFileCreateEventTest.kt => FileCreatedWebhookEventTest.kt} (93%) create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileDeletedWebhookEventTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/{DamFileUpdateEventTest.kt => FileUpdatedWebhookEventTest.kt} (93%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/{DamFileVersionCreateEventTest.kt => FileVersionCreatedWebhookEventTest.kt} (92%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/{DamFileVersionDeleteEventTest.kt => FileVersionDeletedWebhookEventTest.kt} (56%) diff --git a/.stats.yml b/.stats.yml index 0898c6b1..4bc5fef0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-18b46cb8c1dd5cd0eea8559fa9671600540c5c4bee32f2d74f932416b7a1aee0.yml -openapi_spec_hash: 539770659847d04a92ef965a5313adde +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d73a37dc3426586109bd153f02c6a605036b6a7396bba5173d013468c5291ce6.yml +openapi_spec_hash: c193c6e557ff477481ec8d5ac8a0c96e config_hash: 17e408231b0b01676298010c7405f483 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileCreateEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileCreatedWebhookEvent.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileCreateEvent.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileCreatedWebhookEvent.kt index d8c15c8d..4b5d0c33 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileCreateEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileCreatedWebhookEvent.kt @@ -19,7 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull /** Triggered when a file is created. */ -class DamFileCreateEvent +class FileCreatedWebhookEvent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -119,7 +119,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [DamFileCreateEvent]. + * Returns a mutable builder for constructing an instance of [FileCreatedWebhookEvent]. * * The following fields are required: * ```java @@ -132,7 +132,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [DamFileCreateEvent]. */ + /** A builder for [FileCreatedWebhookEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -142,12 +142,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(damFileCreateEvent: DamFileCreateEvent) = apply { - id = damFileCreateEvent.id - type = damFileCreateEvent.type - createdAt = damFileCreateEvent.createdAt - data = damFileCreateEvent.data - additionalProperties = damFileCreateEvent.additionalProperties.toMutableMap() + internal fun from(fileCreatedWebhookEvent: FileCreatedWebhookEvent) = apply { + id = fileCreatedWebhookEvent.id + type = fileCreatedWebhookEvent.type + createdAt = fileCreatedWebhookEvent.createdAt + data = fileCreatedWebhookEvent.data + additionalProperties = fileCreatedWebhookEvent.additionalProperties.toMutableMap() } /** Unique identifier for the event. */ @@ -215,7 +215,7 @@ private constructor( } /** - * Returns an immutable instance of [DamFileCreateEvent]. + * Returns an immutable instance of [FileCreatedWebhookEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -229,8 +229,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): DamFileCreateEvent = - DamFileCreateEvent( + fun build(): FileCreatedWebhookEvent = + FileCreatedWebhookEvent( checkRequired("id", id), checkRequired("type", type), checkRequired("createdAt", createdAt), @@ -241,7 +241,7 @@ private constructor( private var validated: Boolean = false - fun validate(): DamFileCreateEvent = apply { + fun validate(): FileCreatedWebhookEvent = apply { if (validated) { return@apply } @@ -278,7 +278,7 @@ private constructor( return true } - return other is DamFileCreateEvent && + return other is FileCreatedWebhookEvent && id == other.id && type == other.type && createdAt == other.createdAt && @@ -293,5 +293,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DamFileCreateEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" + "FileCreatedWebhookEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileDeleteEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileDeletedWebhookEvent.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileDeleteEvent.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileDeletedWebhookEvent.kt index ae5f73cb..4c951bbf 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileDeleteEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileDeletedWebhookEvent.kt @@ -18,7 +18,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull /** Triggered when a file is deleted. */ -class DamFileDeleteEvent +class FileDeletedWebhookEvent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -116,7 +116,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [DamFileDeleteEvent]. + * Returns a mutable builder for constructing an instance of [FileDeletedWebhookEvent]. * * The following fields are required: * ```java @@ -129,7 +129,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [DamFileDeleteEvent]. */ + /** A builder for [FileDeletedWebhookEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -139,12 +139,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(damFileDeleteEvent: DamFileDeleteEvent) = apply { - id = damFileDeleteEvent.id - type = damFileDeleteEvent.type - createdAt = damFileDeleteEvent.createdAt - data = damFileDeleteEvent.data - additionalProperties = damFileDeleteEvent.additionalProperties.toMutableMap() + internal fun from(fileDeletedWebhookEvent: FileDeletedWebhookEvent) = apply { + id = fileDeletedWebhookEvent.id + type = fileDeletedWebhookEvent.type + createdAt = fileDeletedWebhookEvent.createdAt + data = fileDeletedWebhookEvent.data + additionalProperties = fileDeletedWebhookEvent.additionalProperties.toMutableMap() } /** Unique identifier for the event. */ @@ -211,7 +211,7 @@ private constructor( } /** - * Returns an immutable instance of [DamFileDeleteEvent]. + * Returns an immutable instance of [FileDeletedWebhookEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -225,8 +225,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): DamFileDeleteEvent = - DamFileDeleteEvent( + fun build(): FileDeletedWebhookEvent = + FileDeletedWebhookEvent( checkRequired("id", id), checkRequired("type", type), checkRequired("createdAt", createdAt), @@ -237,7 +237,7 @@ private constructor( private var validated: Boolean = false - fun validate(): DamFileDeleteEvent = apply { + fun validate(): FileDeletedWebhookEvent = apply { if (validated) { return@apply } @@ -429,7 +429,7 @@ private constructor( return true } - return other is DamFileDeleteEvent && + return other is FileDeletedWebhookEvent && id == other.id && type == other.type && createdAt == other.createdAt && @@ -444,5 +444,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DamFileDeleteEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" + "FileDeletedWebhookEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileUpdateEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileUpdatedWebhookEvent.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileUpdateEvent.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileUpdatedWebhookEvent.kt index 2f6770c5..92b40a0a 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileUpdateEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileUpdatedWebhookEvent.kt @@ -19,7 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull /** Triggered when a file is updated. */ -class DamFileUpdateEvent +class FileUpdatedWebhookEvent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -119,7 +119,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [DamFileUpdateEvent]. + * Returns a mutable builder for constructing an instance of [FileUpdatedWebhookEvent]. * * The following fields are required: * ```java @@ -132,7 +132,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [DamFileUpdateEvent]. */ + /** A builder for [FileUpdatedWebhookEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -142,12 +142,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(damFileUpdateEvent: DamFileUpdateEvent) = apply { - id = damFileUpdateEvent.id - type = damFileUpdateEvent.type - createdAt = damFileUpdateEvent.createdAt - data = damFileUpdateEvent.data - additionalProperties = damFileUpdateEvent.additionalProperties.toMutableMap() + internal fun from(fileUpdatedWebhookEvent: FileUpdatedWebhookEvent) = apply { + id = fileUpdatedWebhookEvent.id + type = fileUpdatedWebhookEvent.type + createdAt = fileUpdatedWebhookEvent.createdAt + data = fileUpdatedWebhookEvent.data + additionalProperties = fileUpdatedWebhookEvent.additionalProperties.toMutableMap() } /** Unique identifier for the event. */ @@ -215,7 +215,7 @@ private constructor( } /** - * Returns an immutable instance of [DamFileUpdateEvent]. + * Returns an immutable instance of [FileUpdatedWebhookEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -229,8 +229,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): DamFileUpdateEvent = - DamFileUpdateEvent( + fun build(): FileUpdatedWebhookEvent = + FileUpdatedWebhookEvent( checkRequired("id", id), checkRequired("type", type), checkRequired("createdAt", createdAt), @@ -241,7 +241,7 @@ private constructor( private var validated: Boolean = false - fun validate(): DamFileUpdateEvent = apply { + fun validate(): FileUpdatedWebhookEvent = apply { if (validated) { return@apply } @@ -278,7 +278,7 @@ private constructor( return true } - return other is DamFileUpdateEvent && + return other is FileUpdatedWebhookEvent && id == other.id && type == other.type && createdAt == other.createdAt && @@ -293,5 +293,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DamFileUpdateEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" + "FileUpdatedWebhookEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionCreatedWebhookEvent.kt similarity index 90% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEvent.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionCreatedWebhookEvent.kt index 10663dd1..50f21c9f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionCreatedWebhookEvent.kt @@ -19,7 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull /** Triggered when a file version is created. */ -class DamFileVersionCreateEvent +class FileVersionCreatedWebhookEvent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -119,7 +119,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [DamFileVersionCreateEvent]. + * Returns a mutable builder for constructing an instance of + * [FileVersionCreatedWebhookEvent]. * * The following fields are required: * ```java @@ -132,7 +133,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [DamFileVersionCreateEvent]. */ + /** A builder for [FileVersionCreatedWebhookEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -142,12 +143,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(damFileVersionCreateEvent: DamFileVersionCreateEvent) = apply { - id = damFileVersionCreateEvent.id - type = damFileVersionCreateEvent.type - createdAt = damFileVersionCreateEvent.createdAt - data = damFileVersionCreateEvent.data - additionalProperties = damFileVersionCreateEvent.additionalProperties.toMutableMap() + internal fun from(fileVersionCreatedWebhookEvent: FileVersionCreatedWebhookEvent) = apply { + id = fileVersionCreatedWebhookEvent.id + type = fileVersionCreatedWebhookEvent.type + createdAt = fileVersionCreatedWebhookEvent.createdAt + data = fileVersionCreatedWebhookEvent.data + additionalProperties = + fileVersionCreatedWebhookEvent.additionalProperties.toMutableMap() } /** Unique identifier for the event. */ @@ -215,7 +217,7 @@ private constructor( } /** - * Returns an immutable instance of [DamFileVersionCreateEvent]. + * Returns an immutable instance of [FileVersionCreatedWebhookEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -229,8 +231,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): DamFileVersionCreateEvent = - DamFileVersionCreateEvent( + fun build(): FileVersionCreatedWebhookEvent = + FileVersionCreatedWebhookEvent( checkRequired("id", id), checkRequired("type", type), checkRequired("createdAt", createdAt), @@ -241,7 +243,7 @@ private constructor( private var validated: Boolean = false - fun validate(): DamFileVersionCreateEvent = apply { + fun validate(): FileVersionCreatedWebhookEvent = apply { if (validated) { return@apply } @@ -278,7 +280,7 @@ private constructor( return true } - return other is DamFileVersionCreateEvent && + return other is FileVersionCreatedWebhookEvent && id == other.id && type == other.type && createdAt == other.createdAt && @@ -293,5 +295,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DamFileVersionCreateEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" + "FileVersionCreatedWebhookEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileVersionDeleteEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionDeletedWebhookEvent.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileVersionDeleteEvent.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionDeletedWebhookEvent.kt index 7da1a908..21354c10 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/DamFileVersionDeleteEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionDeletedWebhookEvent.kt @@ -18,7 +18,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull /** Triggered when a file version is deleted. */ -class DamFileVersionDeleteEvent +class FileVersionDeletedWebhookEvent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -116,7 +116,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [DamFileVersionDeleteEvent]. + * Returns a mutable builder for constructing an instance of + * [FileVersionDeletedWebhookEvent]. * * The following fields are required: * ```java @@ -129,7 +130,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [DamFileVersionDeleteEvent]. */ + /** A builder for [FileVersionDeletedWebhookEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -139,12 +140,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(damFileVersionDeleteEvent: DamFileVersionDeleteEvent) = apply { - id = damFileVersionDeleteEvent.id - type = damFileVersionDeleteEvent.type - createdAt = damFileVersionDeleteEvent.createdAt - data = damFileVersionDeleteEvent.data - additionalProperties = damFileVersionDeleteEvent.additionalProperties.toMutableMap() + internal fun from(fileVersionDeletedWebhookEvent: FileVersionDeletedWebhookEvent) = apply { + id = fileVersionDeletedWebhookEvent.id + type = fileVersionDeletedWebhookEvent.type + createdAt = fileVersionDeletedWebhookEvent.createdAt + data = fileVersionDeletedWebhookEvent.data + additionalProperties = + fileVersionDeletedWebhookEvent.additionalProperties.toMutableMap() } /** Unique identifier for the event. */ @@ -211,7 +213,7 @@ private constructor( } /** - * Returns an immutable instance of [DamFileVersionDeleteEvent]. + * Returns an immutable instance of [FileVersionDeletedWebhookEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -225,8 +227,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): DamFileVersionDeleteEvent = - DamFileVersionDeleteEvent( + fun build(): FileVersionDeletedWebhookEvent = + FileVersionDeletedWebhookEvent( checkRequired("id", id), checkRequired("type", type), checkRequired("createdAt", createdAt), @@ -237,7 +239,7 @@ private constructor( private var validated: Boolean = false - fun validate(): DamFileVersionDeleteEvent = apply { + fun validate(): FileVersionDeletedWebhookEvent = apply { if (validated) { return@apply } @@ -474,7 +476,7 @@ private constructor( return true } - return other is DamFileVersionDeleteEvent && + return other is FileVersionDeletedWebhookEvent && id == other.id && type == other.type && createdAt == other.createdAt && @@ -489,5 +491,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DamFileVersionDeleteEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" + "FileVersionDeletedWebhookEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt index 8f42bb62..d5cb3514 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt @@ -35,11 +35,11 @@ private constructor( private val uploadPreTransformError: UploadPreTransformErrorEvent? = null, private val uploadPostTransformSuccess: UploadPostTransformSuccessEvent? = null, private val uploadPostTransformError: UploadPostTransformErrorEvent? = null, - private val damFileCreate: DamFileCreateEvent? = null, - private val damFileUpdate: DamFileUpdateEvent? = null, - private val damFileDelete: DamFileDeleteEvent? = null, - private val damFileVersionCreate: DamFileVersionCreateEvent? = null, - private val damFileVersionDelete: DamFileVersionDeleteEvent? = null, + private val fileCreated: FileCreatedWebhookEvent? = null, + private val fileUpdated: FileUpdatedWebhookEvent? = null, + private val fileDeleted: FileDeletedWebhookEvent? = null, + private val fileVersionCreated: FileVersionCreatedWebhookEvent? = null, + private val fileVersionDeleted: FileVersionDeletedWebhookEvent? = null, private val _json: JsonValue? = null, ) { @@ -97,21 +97,21 @@ private constructor( Optional.ofNullable(uploadPostTransformError) /** Triggered when a file is created. */ - fun damFileCreate(): Optional = Optional.ofNullable(damFileCreate) + fun fileCreated(): Optional = Optional.ofNullable(fileCreated) /** Triggered when a file is updated. */ - fun damFileUpdate(): Optional = Optional.ofNullable(damFileUpdate) + fun fileUpdated(): Optional = Optional.ofNullable(fileUpdated) /** Triggered when a file is deleted. */ - fun damFileDelete(): Optional = Optional.ofNullable(damFileDelete) + fun fileDeleted(): Optional = Optional.ofNullable(fileDeleted) /** Triggered when a file version is created. */ - fun damFileVersionCreate(): Optional = - Optional.ofNullable(damFileVersionCreate) + fun fileVersionCreated(): Optional = + Optional.ofNullable(fileVersionCreated) /** Triggered when a file version is deleted. */ - fun damFileVersionDelete(): Optional = - Optional.ofNullable(damFileVersionDelete) + fun fileVersionDeleted(): Optional = + Optional.ofNullable(fileVersionDeleted) fun isVideoTransformationAccepted(): Boolean = videoTransformationAccepted != null @@ -127,15 +127,15 @@ private constructor( fun isUploadPostTransformError(): Boolean = uploadPostTransformError != null - fun isDamFileCreate(): Boolean = damFileCreate != null + fun isFileCreated(): Boolean = fileCreated != null - fun isDamFileUpdate(): Boolean = damFileUpdate != null + fun isFileUpdated(): Boolean = fileUpdated != null - fun isDamFileDelete(): Boolean = damFileDelete != null + fun isFileDeleted(): Boolean = fileDeleted != null - fun isDamFileVersionCreate(): Boolean = damFileVersionCreate != null + fun isFileVersionCreated(): Boolean = fileVersionCreated != null - fun isDamFileVersionDelete(): Boolean = damFileVersionDelete != null + fun isFileVersionDeleted(): Boolean = fileVersionDeleted != null /** * Triggered when a new video transformation request is accepted for processing. This event @@ -191,21 +191,21 @@ private constructor( uploadPostTransformError.getOrThrow("uploadPostTransformError") /** Triggered when a file is created. */ - fun asDamFileCreate(): DamFileCreateEvent = damFileCreate.getOrThrow("damFileCreate") + fun asFileCreated(): FileCreatedWebhookEvent = fileCreated.getOrThrow("fileCreated") /** Triggered when a file is updated. */ - fun asDamFileUpdate(): DamFileUpdateEvent = damFileUpdate.getOrThrow("damFileUpdate") + fun asFileUpdated(): FileUpdatedWebhookEvent = fileUpdated.getOrThrow("fileUpdated") /** Triggered when a file is deleted. */ - fun asDamFileDelete(): DamFileDeleteEvent = damFileDelete.getOrThrow("damFileDelete") + fun asFileDeleted(): FileDeletedWebhookEvent = fileDeleted.getOrThrow("fileDeleted") /** Triggered when a file version is created. */ - fun asDamFileVersionCreate(): DamFileVersionCreateEvent = - damFileVersionCreate.getOrThrow("damFileVersionCreate") + fun asFileVersionCreated(): FileVersionCreatedWebhookEvent = + fileVersionCreated.getOrThrow("fileVersionCreated") /** Triggered when a file version is deleted. */ - fun asDamFileVersionDelete(): DamFileVersionDeleteEvent = - damFileVersionDelete.getOrThrow("damFileVersionDelete") + fun asFileVersionDeleted(): FileVersionDeletedWebhookEvent = + fileVersionDeleted.getOrThrow("fileVersionDeleted") fun _json(): Optional = Optional.ofNullable(_json) @@ -225,11 +225,11 @@ private constructor( visitor.visitUploadPostTransformSuccess(uploadPostTransformSuccess) uploadPostTransformError != null -> visitor.visitUploadPostTransformError(uploadPostTransformError) - damFileCreate != null -> visitor.visitDamFileCreate(damFileCreate) - damFileUpdate != null -> visitor.visitDamFileUpdate(damFileUpdate) - damFileDelete != null -> visitor.visitDamFileDelete(damFileDelete) - damFileVersionCreate != null -> visitor.visitDamFileVersionCreate(damFileVersionCreate) - damFileVersionDelete != null -> visitor.visitDamFileVersionDelete(damFileVersionDelete) + fileCreated != null -> visitor.visitFileCreated(fileCreated) + fileUpdated != null -> visitor.visitFileUpdated(fileUpdated) + fileDeleted != null -> visitor.visitFileDeleted(fileDeleted) + fileVersionCreated != null -> visitor.visitFileVersionCreated(fileVersionCreated) + fileVersionDeleted != null -> visitor.visitFileVersionDeleted(fileVersionDeleted) else -> visitor.unknown(_json) } @@ -284,28 +284,28 @@ private constructor( uploadPostTransformError.validate() } - override fun visitDamFileCreate(damFileCreate: DamFileCreateEvent) { - damFileCreate.validate() + override fun visitFileCreated(fileCreated: FileCreatedWebhookEvent) { + fileCreated.validate() } - override fun visitDamFileUpdate(damFileUpdate: DamFileUpdateEvent) { - damFileUpdate.validate() + override fun visitFileUpdated(fileUpdated: FileUpdatedWebhookEvent) { + fileUpdated.validate() } - override fun visitDamFileDelete(damFileDelete: DamFileDeleteEvent) { - damFileDelete.validate() + override fun visitFileDeleted(fileDeleted: FileDeletedWebhookEvent) { + fileDeleted.validate() } - override fun visitDamFileVersionCreate( - damFileVersionCreate: DamFileVersionCreateEvent + override fun visitFileVersionCreated( + fileVersionCreated: FileVersionCreatedWebhookEvent ) { - damFileVersionCreate.validate() + fileVersionCreated.validate() } - override fun visitDamFileVersionDelete( - damFileVersionDelete: DamFileVersionDeleteEvent + override fun visitFileVersionDeleted( + fileVersionDeleted: FileVersionDeletedWebhookEvent ) { - damFileVersionDelete.validate() + fileVersionDeleted.validate() } } ) @@ -357,22 +357,22 @@ private constructor( uploadPostTransformError: UploadPostTransformErrorEvent ) = uploadPostTransformError.validity() - override fun visitDamFileCreate(damFileCreate: DamFileCreateEvent) = - damFileCreate.validity() + override fun visitFileCreated(fileCreated: FileCreatedWebhookEvent) = + fileCreated.validity() - override fun visitDamFileUpdate(damFileUpdate: DamFileUpdateEvent) = - damFileUpdate.validity() + override fun visitFileUpdated(fileUpdated: FileUpdatedWebhookEvent) = + fileUpdated.validity() - override fun visitDamFileDelete(damFileDelete: DamFileDeleteEvent) = - damFileDelete.validity() + override fun visitFileDeleted(fileDeleted: FileDeletedWebhookEvent) = + fileDeleted.validity() - override fun visitDamFileVersionCreate( - damFileVersionCreate: DamFileVersionCreateEvent - ) = damFileVersionCreate.validity() + override fun visitFileVersionCreated( + fileVersionCreated: FileVersionCreatedWebhookEvent + ) = fileVersionCreated.validity() - override fun visitDamFileVersionDelete( - damFileVersionDelete: DamFileVersionDeleteEvent - ) = damFileVersionDelete.validity() + override fun visitFileVersionDeleted( + fileVersionDeleted: FileVersionDeletedWebhookEvent + ) = fileVersionDeleted.validity() override fun unknown(json: JsonValue?) = 0 } @@ -391,11 +391,11 @@ private constructor( uploadPreTransformError == other.uploadPreTransformError && uploadPostTransformSuccess == other.uploadPostTransformSuccess && uploadPostTransformError == other.uploadPostTransformError && - damFileCreate == other.damFileCreate && - damFileUpdate == other.damFileUpdate && - damFileDelete == other.damFileDelete && - damFileVersionCreate == other.damFileVersionCreate && - damFileVersionDelete == other.damFileVersionDelete + fileCreated == other.fileCreated && + fileUpdated == other.fileUpdated && + fileDeleted == other.fileDeleted && + fileVersionCreated == other.fileVersionCreated && + fileVersionDeleted == other.fileVersionDeleted } override fun hashCode(): Int = @@ -407,11 +407,11 @@ private constructor( uploadPreTransformError, uploadPostTransformSuccess, uploadPostTransformError, - damFileCreate, - damFileUpdate, - damFileDelete, - damFileVersionCreate, - damFileVersionDelete, + fileCreated, + fileUpdated, + fileDeleted, + fileVersionCreated, + fileVersionDeleted, ) override fun toString(): String = @@ -430,13 +430,13 @@ private constructor( "UnsafeUnwrapWebhookEvent{uploadPostTransformSuccess=$uploadPostTransformSuccess}" uploadPostTransformError != null -> "UnsafeUnwrapWebhookEvent{uploadPostTransformError=$uploadPostTransformError}" - damFileCreate != null -> "UnsafeUnwrapWebhookEvent{damFileCreate=$damFileCreate}" - damFileUpdate != null -> "UnsafeUnwrapWebhookEvent{damFileUpdate=$damFileUpdate}" - damFileDelete != null -> "UnsafeUnwrapWebhookEvent{damFileDelete=$damFileDelete}" - damFileVersionCreate != null -> - "UnsafeUnwrapWebhookEvent{damFileVersionCreate=$damFileVersionCreate}" - damFileVersionDelete != null -> - "UnsafeUnwrapWebhookEvent{damFileVersionDelete=$damFileVersionDelete}" + fileCreated != null -> "UnsafeUnwrapWebhookEvent{fileCreated=$fileCreated}" + fileUpdated != null -> "UnsafeUnwrapWebhookEvent{fileUpdated=$fileUpdated}" + fileDeleted != null -> "UnsafeUnwrapWebhookEvent{fileDeleted=$fileDeleted}" + fileVersionCreated != null -> + "UnsafeUnwrapWebhookEvent{fileVersionCreated=$fileVersionCreated}" + fileVersionDeleted != null -> + "UnsafeUnwrapWebhookEvent{fileVersionDeleted=$fileVersionDeleted}" _json != null -> "UnsafeUnwrapWebhookEvent{_unknown=$_json}" else -> throw IllegalStateException("Invalid UnsafeUnwrapWebhookEvent") } @@ -507,28 +507,28 @@ private constructor( /** Triggered when a file is created. */ @JvmStatic - fun ofDamFileCreate(damFileCreate: DamFileCreateEvent) = - UnsafeUnwrapWebhookEvent(damFileCreate = damFileCreate) + fun ofFileCreated(fileCreated: FileCreatedWebhookEvent) = + UnsafeUnwrapWebhookEvent(fileCreated = fileCreated) /** Triggered when a file is updated. */ @JvmStatic - fun ofDamFileUpdate(damFileUpdate: DamFileUpdateEvent) = - UnsafeUnwrapWebhookEvent(damFileUpdate = damFileUpdate) + fun ofFileUpdated(fileUpdated: FileUpdatedWebhookEvent) = + UnsafeUnwrapWebhookEvent(fileUpdated = fileUpdated) /** Triggered when a file is deleted. */ @JvmStatic - fun ofDamFileDelete(damFileDelete: DamFileDeleteEvent) = - UnsafeUnwrapWebhookEvent(damFileDelete = damFileDelete) + fun ofFileDeleted(fileDeleted: FileDeletedWebhookEvent) = + UnsafeUnwrapWebhookEvent(fileDeleted = fileDeleted) /** Triggered when a file version is created. */ @JvmStatic - fun ofDamFileVersionCreate(damFileVersionCreate: DamFileVersionCreateEvent) = - UnsafeUnwrapWebhookEvent(damFileVersionCreate = damFileVersionCreate) + fun ofFileVersionCreated(fileVersionCreated: FileVersionCreatedWebhookEvent) = + UnsafeUnwrapWebhookEvent(fileVersionCreated = fileVersionCreated) /** Triggered when a file version is deleted. */ @JvmStatic - fun ofDamFileVersionDelete(damFileVersionDelete: DamFileVersionDeleteEvent) = - UnsafeUnwrapWebhookEvent(damFileVersionDelete = damFileVersionDelete) + fun ofFileVersionDeleted(fileVersionDeleted: FileVersionDeletedWebhookEvent) = + UnsafeUnwrapWebhookEvent(fileVersionDeleted = fileVersionDeleted) } /** @@ -596,19 +596,19 @@ private constructor( ): T /** Triggered when a file is created. */ - fun visitDamFileCreate(damFileCreate: DamFileCreateEvent): T + fun visitFileCreated(fileCreated: FileCreatedWebhookEvent): T /** Triggered when a file is updated. */ - fun visitDamFileUpdate(damFileUpdate: DamFileUpdateEvent): T + fun visitFileUpdated(fileUpdated: FileUpdatedWebhookEvent): T /** Triggered when a file is deleted. */ - fun visitDamFileDelete(damFileDelete: DamFileDeleteEvent): T + fun visitFileDeleted(fileDeleted: FileDeletedWebhookEvent): T /** Triggered when a file version is created. */ - fun visitDamFileVersionCreate(damFileVersionCreate: DamFileVersionCreateEvent): T + fun visitFileVersionCreated(fileVersionCreated: FileVersionCreatedWebhookEvent): T /** Triggered when a file version is deleted. */ - fun visitDamFileVersionDelete(damFileVersionDelete: DamFileVersionDeleteEvent): T + fun visitFileVersionDeleted(fileVersionDeleted: FileVersionDeletedWebhookEvent): T /** * Maps an unknown variant of [UnsafeUnwrapWebhookEvent] to a value of type [T]. @@ -669,21 +669,23 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { UnsafeUnwrapWebhookEvent(uploadPostTransformError = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnsafeUnwrapWebhookEvent(damFileCreate = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + UnsafeUnwrapWebhookEvent(fileCreated = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnsafeUnwrapWebhookEvent(damFileUpdate = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + UnsafeUnwrapWebhookEvent(fileUpdated = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnsafeUnwrapWebhookEvent(damFileDelete = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnsafeUnwrapWebhookEvent(damFileVersionCreate = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnsafeUnwrapWebhookEvent(damFileVersionDelete = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + UnsafeUnwrapWebhookEvent(fileDeleted = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnsafeUnwrapWebhookEvent(fileVersionCreated = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + UnsafeUnwrapWebhookEvent(fileVersionDeleted = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -723,13 +725,11 @@ private constructor( generator.writeObject(value.uploadPostTransformSuccess) value.uploadPostTransformError != null -> generator.writeObject(value.uploadPostTransformError) - value.damFileCreate != null -> generator.writeObject(value.damFileCreate) - value.damFileUpdate != null -> generator.writeObject(value.damFileUpdate) - value.damFileDelete != null -> generator.writeObject(value.damFileDelete) - value.damFileVersionCreate != null -> - generator.writeObject(value.damFileVersionCreate) - value.damFileVersionDelete != null -> - generator.writeObject(value.damFileVersionDelete) + value.fileCreated != null -> generator.writeObject(value.fileCreated) + value.fileUpdated != null -> generator.writeObject(value.fileUpdated) + value.fileDeleted != null -> generator.writeObject(value.fileDeleted) + value.fileVersionCreated != null -> generator.writeObject(value.fileVersionCreated) + value.fileVersionDeleted != null -> generator.writeObject(value.fileVersionDeleted) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid UnsafeUnwrapWebhookEvent") } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt index 949f6694..bb9046cb 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt @@ -35,11 +35,11 @@ private constructor( private val uploadPreTransformError: UploadPreTransformErrorEvent? = null, private val uploadPostTransformSuccess: UploadPostTransformSuccessEvent? = null, private val uploadPostTransformError: UploadPostTransformErrorEvent? = null, - private val damFileCreate: DamFileCreateEvent? = null, - private val damFileUpdate: DamFileUpdateEvent? = null, - private val damFileDelete: DamFileDeleteEvent? = null, - private val damFileVersionCreate: DamFileVersionCreateEvent? = null, - private val damFileVersionDelete: DamFileVersionDeleteEvent? = null, + private val fileCreated: FileCreatedWebhookEvent? = null, + private val fileUpdated: FileUpdatedWebhookEvent? = null, + private val fileDeleted: FileDeletedWebhookEvent? = null, + private val fileVersionCreated: FileVersionCreatedWebhookEvent? = null, + private val fileVersionDeleted: FileVersionDeletedWebhookEvent? = null, private val _json: JsonValue? = null, ) { @@ -97,21 +97,21 @@ private constructor( Optional.ofNullable(uploadPostTransformError) /** Triggered when a file is created. */ - fun damFileCreate(): Optional = Optional.ofNullable(damFileCreate) + fun fileCreated(): Optional = Optional.ofNullable(fileCreated) /** Triggered when a file is updated. */ - fun damFileUpdate(): Optional = Optional.ofNullable(damFileUpdate) + fun fileUpdated(): Optional = Optional.ofNullable(fileUpdated) /** Triggered when a file is deleted. */ - fun damFileDelete(): Optional = Optional.ofNullable(damFileDelete) + fun fileDeleted(): Optional = Optional.ofNullable(fileDeleted) /** Triggered when a file version is created. */ - fun damFileVersionCreate(): Optional = - Optional.ofNullable(damFileVersionCreate) + fun fileVersionCreated(): Optional = + Optional.ofNullable(fileVersionCreated) /** Triggered when a file version is deleted. */ - fun damFileVersionDelete(): Optional = - Optional.ofNullable(damFileVersionDelete) + fun fileVersionDeleted(): Optional = + Optional.ofNullable(fileVersionDeleted) fun isVideoTransformationAccepted(): Boolean = videoTransformationAccepted != null @@ -127,15 +127,15 @@ private constructor( fun isUploadPostTransformError(): Boolean = uploadPostTransformError != null - fun isDamFileCreate(): Boolean = damFileCreate != null + fun isFileCreated(): Boolean = fileCreated != null - fun isDamFileUpdate(): Boolean = damFileUpdate != null + fun isFileUpdated(): Boolean = fileUpdated != null - fun isDamFileDelete(): Boolean = damFileDelete != null + fun isFileDeleted(): Boolean = fileDeleted != null - fun isDamFileVersionCreate(): Boolean = damFileVersionCreate != null + fun isFileVersionCreated(): Boolean = fileVersionCreated != null - fun isDamFileVersionDelete(): Boolean = damFileVersionDelete != null + fun isFileVersionDeleted(): Boolean = fileVersionDeleted != null /** * Triggered when a new video transformation request is accepted for processing. This event @@ -191,21 +191,21 @@ private constructor( uploadPostTransformError.getOrThrow("uploadPostTransformError") /** Triggered when a file is created. */ - fun asDamFileCreate(): DamFileCreateEvent = damFileCreate.getOrThrow("damFileCreate") + fun asFileCreated(): FileCreatedWebhookEvent = fileCreated.getOrThrow("fileCreated") /** Triggered when a file is updated. */ - fun asDamFileUpdate(): DamFileUpdateEvent = damFileUpdate.getOrThrow("damFileUpdate") + fun asFileUpdated(): FileUpdatedWebhookEvent = fileUpdated.getOrThrow("fileUpdated") /** Triggered when a file is deleted. */ - fun asDamFileDelete(): DamFileDeleteEvent = damFileDelete.getOrThrow("damFileDelete") + fun asFileDeleted(): FileDeletedWebhookEvent = fileDeleted.getOrThrow("fileDeleted") /** Triggered when a file version is created. */ - fun asDamFileVersionCreate(): DamFileVersionCreateEvent = - damFileVersionCreate.getOrThrow("damFileVersionCreate") + fun asFileVersionCreated(): FileVersionCreatedWebhookEvent = + fileVersionCreated.getOrThrow("fileVersionCreated") /** Triggered when a file version is deleted. */ - fun asDamFileVersionDelete(): DamFileVersionDeleteEvent = - damFileVersionDelete.getOrThrow("damFileVersionDelete") + fun asFileVersionDeleted(): FileVersionDeletedWebhookEvent = + fileVersionDeleted.getOrThrow("fileVersionDeleted") fun _json(): Optional = Optional.ofNullable(_json) @@ -225,11 +225,11 @@ private constructor( visitor.visitUploadPostTransformSuccess(uploadPostTransformSuccess) uploadPostTransformError != null -> visitor.visitUploadPostTransformError(uploadPostTransformError) - damFileCreate != null -> visitor.visitDamFileCreate(damFileCreate) - damFileUpdate != null -> visitor.visitDamFileUpdate(damFileUpdate) - damFileDelete != null -> visitor.visitDamFileDelete(damFileDelete) - damFileVersionCreate != null -> visitor.visitDamFileVersionCreate(damFileVersionCreate) - damFileVersionDelete != null -> visitor.visitDamFileVersionDelete(damFileVersionDelete) + fileCreated != null -> visitor.visitFileCreated(fileCreated) + fileUpdated != null -> visitor.visitFileUpdated(fileUpdated) + fileDeleted != null -> visitor.visitFileDeleted(fileDeleted) + fileVersionCreated != null -> visitor.visitFileVersionCreated(fileVersionCreated) + fileVersionDeleted != null -> visitor.visitFileVersionDeleted(fileVersionDeleted) else -> visitor.unknown(_json) } @@ -284,28 +284,28 @@ private constructor( uploadPostTransformError.validate() } - override fun visitDamFileCreate(damFileCreate: DamFileCreateEvent) { - damFileCreate.validate() + override fun visitFileCreated(fileCreated: FileCreatedWebhookEvent) { + fileCreated.validate() } - override fun visitDamFileUpdate(damFileUpdate: DamFileUpdateEvent) { - damFileUpdate.validate() + override fun visitFileUpdated(fileUpdated: FileUpdatedWebhookEvent) { + fileUpdated.validate() } - override fun visitDamFileDelete(damFileDelete: DamFileDeleteEvent) { - damFileDelete.validate() + override fun visitFileDeleted(fileDeleted: FileDeletedWebhookEvent) { + fileDeleted.validate() } - override fun visitDamFileVersionCreate( - damFileVersionCreate: DamFileVersionCreateEvent + override fun visitFileVersionCreated( + fileVersionCreated: FileVersionCreatedWebhookEvent ) { - damFileVersionCreate.validate() + fileVersionCreated.validate() } - override fun visitDamFileVersionDelete( - damFileVersionDelete: DamFileVersionDeleteEvent + override fun visitFileVersionDeleted( + fileVersionDeleted: FileVersionDeletedWebhookEvent ) { - damFileVersionDelete.validate() + fileVersionDeleted.validate() } } ) @@ -357,22 +357,22 @@ private constructor( uploadPostTransformError: UploadPostTransformErrorEvent ) = uploadPostTransformError.validity() - override fun visitDamFileCreate(damFileCreate: DamFileCreateEvent) = - damFileCreate.validity() + override fun visitFileCreated(fileCreated: FileCreatedWebhookEvent) = + fileCreated.validity() - override fun visitDamFileUpdate(damFileUpdate: DamFileUpdateEvent) = - damFileUpdate.validity() + override fun visitFileUpdated(fileUpdated: FileUpdatedWebhookEvent) = + fileUpdated.validity() - override fun visitDamFileDelete(damFileDelete: DamFileDeleteEvent) = - damFileDelete.validity() + override fun visitFileDeleted(fileDeleted: FileDeletedWebhookEvent) = + fileDeleted.validity() - override fun visitDamFileVersionCreate( - damFileVersionCreate: DamFileVersionCreateEvent - ) = damFileVersionCreate.validity() + override fun visitFileVersionCreated( + fileVersionCreated: FileVersionCreatedWebhookEvent + ) = fileVersionCreated.validity() - override fun visitDamFileVersionDelete( - damFileVersionDelete: DamFileVersionDeleteEvent - ) = damFileVersionDelete.validity() + override fun visitFileVersionDeleted( + fileVersionDeleted: FileVersionDeletedWebhookEvent + ) = fileVersionDeleted.validity() override fun unknown(json: JsonValue?) = 0 } @@ -391,11 +391,11 @@ private constructor( uploadPreTransformError == other.uploadPreTransformError && uploadPostTransformSuccess == other.uploadPostTransformSuccess && uploadPostTransformError == other.uploadPostTransformError && - damFileCreate == other.damFileCreate && - damFileUpdate == other.damFileUpdate && - damFileDelete == other.damFileDelete && - damFileVersionCreate == other.damFileVersionCreate && - damFileVersionDelete == other.damFileVersionDelete + fileCreated == other.fileCreated && + fileUpdated == other.fileUpdated && + fileDeleted == other.fileDeleted && + fileVersionCreated == other.fileVersionCreated && + fileVersionDeleted == other.fileVersionDeleted } override fun hashCode(): Int = @@ -407,11 +407,11 @@ private constructor( uploadPreTransformError, uploadPostTransformSuccess, uploadPostTransformError, - damFileCreate, - damFileUpdate, - damFileDelete, - damFileVersionCreate, - damFileVersionDelete, + fileCreated, + fileUpdated, + fileDeleted, + fileVersionCreated, + fileVersionDeleted, ) override fun toString(): String = @@ -430,13 +430,13 @@ private constructor( "UnwrapWebhookEvent{uploadPostTransformSuccess=$uploadPostTransformSuccess}" uploadPostTransformError != null -> "UnwrapWebhookEvent{uploadPostTransformError=$uploadPostTransformError}" - damFileCreate != null -> "UnwrapWebhookEvent{damFileCreate=$damFileCreate}" - damFileUpdate != null -> "UnwrapWebhookEvent{damFileUpdate=$damFileUpdate}" - damFileDelete != null -> "UnwrapWebhookEvent{damFileDelete=$damFileDelete}" - damFileVersionCreate != null -> - "UnwrapWebhookEvent{damFileVersionCreate=$damFileVersionCreate}" - damFileVersionDelete != null -> - "UnwrapWebhookEvent{damFileVersionDelete=$damFileVersionDelete}" + fileCreated != null -> "UnwrapWebhookEvent{fileCreated=$fileCreated}" + fileUpdated != null -> "UnwrapWebhookEvent{fileUpdated=$fileUpdated}" + fileDeleted != null -> "UnwrapWebhookEvent{fileDeleted=$fileDeleted}" + fileVersionCreated != null -> + "UnwrapWebhookEvent{fileVersionCreated=$fileVersionCreated}" + fileVersionDeleted != null -> + "UnwrapWebhookEvent{fileVersionDeleted=$fileVersionDeleted}" _json != null -> "UnwrapWebhookEvent{_unknown=$_json}" else -> throw IllegalStateException("Invalid UnwrapWebhookEvent") } @@ -507,28 +507,28 @@ private constructor( /** Triggered when a file is created. */ @JvmStatic - fun ofDamFileCreate(damFileCreate: DamFileCreateEvent) = - UnwrapWebhookEvent(damFileCreate = damFileCreate) + fun ofFileCreated(fileCreated: FileCreatedWebhookEvent) = + UnwrapWebhookEvent(fileCreated = fileCreated) /** Triggered when a file is updated. */ @JvmStatic - fun ofDamFileUpdate(damFileUpdate: DamFileUpdateEvent) = - UnwrapWebhookEvent(damFileUpdate = damFileUpdate) + fun ofFileUpdated(fileUpdated: FileUpdatedWebhookEvent) = + UnwrapWebhookEvent(fileUpdated = fileUpdated) /** Triggered when a file is deleted. */ @JvmStatic - fun ofDamFileDelete(damFileDelete: DamFileDeleteEvent) = - UnwrapWebhookEvent(damFileDelete = damFileDelete) + fun ofFileDeleted(fileDeleted: FileDeletedWebhookEvent) = + UnwrapWebhookEvent(fileDeleted = fileDeleted) /** Triggered when a file version is created. */ @JvmStatic - fun ofDamFileVersionCreate(damFileVersionCreate: DamFileVersionCreateEvent) = - UnwrapWebhookEvent(damFileVersionCreate = damFileVersionCreate) + fun ofFileVersionCreated(fileVersionCreated: FileVersionCreatedWebhookEvent) = + UnwrapWebhookEvent(fileVersionCreated = fileVersionCreated) /** Triggered when a file version is deleted. */ @JvmStatic - fun ofDamFileVersionDelete(damFileVersionDelete: DamFileVersionDeleteEvent) = - UnwrapWebhookEvent(damFileVersionDelete = damFileVersionDelete) + fun ofFileVersionDeleted(fileVersionDeleted: FileVersionDeletedWebhookEvent) = + UnwrapWebhookEvent(fileVersionDeleted = fileVersionDeleted) } /** @@ -596,19 +596,19 @@ private constructor( ): T /** Triggered when a file is created. */ - fun visitDamFileCreate(damFileCreate: DamFileCreateEvent): T + fun visitFileCreated(fileCreated: FileCreatedWebhookEvent): T /** Triggered when a file is updated. */ - fun visitDamFileUpdate(damFileUpdate: DamFileUpdateEvent): T + fun visitFileUpdated(fileUpdated: FileUpdatedWebhookEvent): T /** Triggered when a file is deleted. */ - fun visitDamFileDelete(damFileDelete: DamFileDeleteEvent): T + fun visitFileDeleted(fileDeleted: FileDeletedWebhookEvent): T /** Triggered when a file version is created. */ - fun visitDamFileVersionCreate(damFileVersionCreate: DamFileVersionCreateEvent): T + fun visitFileVersionCreated(fileVersionCreated: FileVersionCreatedWebhookEvent): T /** Triggered when a file version is deleted. */ - fun visitDamFileVersionDelete(damFileVersionDelete: DamFileVersionDeleteEvent): T + fun visitFileVersionDeleted(fileVersionDeleted: FileVersionDeletedWebhookEvent): T /** * Maps an unknown variant of [UnwrapWebhookEvent] to a value of type [T]. @@ -659,21 +659,19 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { UnwrapWebhookEvent(uploadPostTransformError = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnwrapWebhookEvent(damFileCreate = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + UnwrapWebhookEvent(fileCreated = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnwrapWebhookEvent(damFileUpdate = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + UnwrapWebhookEvent(fileUpdated = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnwrapWebhookEvent(damFileDelete = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnwrapWebhookEvent(damFileVersionCreate = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnwrapWebhookEvent(damFileVersionDelete = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + UnwrapWebhookEvent(fileDeleted = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { UnwrapWebhookEvent(fileVersionCreated = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { UnwrapWebhookEvent(fileVersionDeleted = it, _json = json) }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -712,13 +710,11 @@ private constructor( generator.writeObject(value.uploadPostTransformSuccess) value.uploadPostTransformError != null -> generator.writeObject(value.uploadPostTransformError) - value.damFileCreate != null -> generator.writeObject(value.damFileCreate) - value.damFileUpdate != null -> generator.writeObject(value.damFileUpdate) - value.damFileDelete != null -> generator.writeObject(value.damFileDelete) - value.damFileVersionCreate != null -> - generator.writeObject(value.damFileVersionCreate) - value.damFileVersionDelete != null -> - generator.writeObject(value.damFileVersionDelete) + value.fileCreated != null -> generator.writeObject(value.fileCreated) + value.fileUpdated != null -> generator.writeObject(value.fileUpdated) + value.fileDeleted != null -> generator.writeObject(value.fileDeleted) + value.fileVersionCreated != null -> generator.writeObject(value.fileVersionCreated) + value.fileVersionDeleted != null -> generator.writeObject(value.fileVersionDeleted) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid UnwrapWebhookEvent") } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileDeleteEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileDeleteEventTest.kt deleted file mode 100644 index b8905e08..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileDeleteEventTest.kt +++ /dev/null @@ -1,50 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.imagekit.api.models.webhooks - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class DamFileDeleteEventTest { - - @Test - fun create() { - val damFileDeleteEvent = - DamFileDeleteEvent.builder() - .id("id") - .type("file.deleted") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .data(DamFileDeleteEvent.Data.builder().fileId("fileId").build()) - .build() - - assertThat(damFileDeleteEvent.id()).isEqualTo("id") - assertThat(damFileDeleteEvent.type()).isEqualTo("file.deleted") - assertThat(damFileDeleteEvent.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(damFileDeleteEvent.data()) - .isEqualTo(DamFileDeleteEvent.Data.builder().fileId("fileId").build()) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val damFileDeleteEvent = - DamFileDeleteEvent.builder() - .id("id") - .type("file.deleted") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .data(DamFileDeleteEvent.Data.builder().fileId("fileId").build()) - .build() - - val roundtrippedDamFileDeleteEvent = - jsonMapper.readValue( - jsonMapper.writeValueAsString(damFileDeleteEvent), - jacksonTypeRef(), - ) - - assertThat(roundtrippedDamFileDeleteEvent).isEqualTo(damFileDeleteEvent) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileCreateEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileCreatedWebhookEventTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileCreateEventTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileCreatedWebhookEventTest.kt index 869912af..ffb45d14 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileCreateEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileCreatedWebhookEventTest.kt @@ -10,12 +10,12 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class DamFileCreateEventTest { +internal class FileCreatedWebhookEventTest { @Test fun create() { - val damFileCreateEvent = - DamFileCreateEvent.builder() + val fileCreatedWebhookEvent = + FileCreatedWebhookEvent.builder() .id("id") .type("file.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -88,11 +88,11 @@ internal class DamFileCreateEventTest { ) .build() - assertThat(damFileCreateEvent.id()).isEqualTo("id") - assertThat(damFileCreateEvent.type()).isEqualTo("file.created") - assertThat(damFileCreateEvent.createdAt()) + assertThat(fileCreatedWebhookEvent.id()).isEqualTo("id") + assertThat(fileCreatedWebhookEvent.type()).isEqualTo("file.created") + assertThat(fileCreatedWebhookEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(damFileCreateEvent.data()) + assertThat(fileCreatedWebhookEvent.data()) .isEqualTo( File.builder() .addAiTag( @@ -161,8 +161,8 @@ internal class DamFileCreateEventTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val damFileCreateEvent = - DamFileCreateEvent.builder() + val fileCreatedWebhookEvent = + FileCreatedWebhookEvent.builder() .id("id") .type("file.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -235,12 +235,12 @@ internal class DamFileCreateEventTest { ) .build() - val roundtrippedDamFileCreateEvent = + val roundtrippedFileCreatedWebhookEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(damFileCreateEvent), - jacksonTypeRef(), + jsonMapper.writeValueAsString(fileCreatedWebhookEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedDamFileCreateEvent).isEqualTo(damFileCreateEvent) + assertThat(roundtrippedFileCreatedWebhookEvent).isEqualTo(fileCreatedWebhookEvent) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileDeletedWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileDeletedWebhookEventTest.kt new file mode 100644 index 00000000..88693b2b --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileDeletedWebhookEventTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileDeletedWebhookEventTest { + + @Test + fun create() { + val fileDeletedWebhookEvent = + FileDeletedWebhookEvent.builder() + .id("id") + .type("file.deleted") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data(FileDeletedWebhookEvent.Data.builder().fileId("fileId").build()) + .build() + + assertThat(fileDeletedWebhookEvent.id()).isEqualTo("id") + assertThat(fileDeletedWebhookEvent.type()).isEqualTo("file.deleted") + assertThat(fileDeletedWebhookEvent.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(fileDeletedWebhookEvent.data()) + .isEqualTo(FileDeletedWebhookEvent.Data.builder().fileId("fileId").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fileDeletedWebhookEvent = + FileDeletedWebhookEvent.builder() + .id("id") + .type("file.deleted") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data(FileDeletedWebhookEvent.Data.builder().fileId("fileId").build()) + .build() + + val roundtrippedFileDeletedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fileDeletedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFileDeletedWebhookEvent).isEqualTo(fileDeletedWebhookEvent) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileUpdateEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileUpdatedWebhookEventTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileUpdateEventTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileUpdatedWebhookEventTest.kt index a6c8f0e2..1d31abd7 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileUpdateEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileUpdatedWebhookEventTest.kt @@ -10,12 +10,12 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class DamFileUpdateEventTest { +internal class FileUpdatedWebhookEventTest { @Test fun create() { - val damFileUpdateEvent = - DamFileUpdateEvent.builder() + val fileUpdatedWebhookEvent = + FileUpdatedWebhookEvent.builder() .id("id") .type("file.updated") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -88,11 +88,11 @@ internal class DamFileUpdateEventTest { ) .build() - assertThat(damFileUpdateEvent.id()).isEqualTo("id") - assertThat(damFileUpdateEvent.type()).isEqualTo("file.updated") - assertThat(damFileUpdateEvent.createdAt()) + assertThat(fileUpdatedWebhookEvent.id()).isEqualTo("id") + assertThat(fileUpdatedWebhookEvent.type()).isEqualTo("file.updated") + assertThat(fileUpdatedWebhookEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(damFileUpdateEvent.data()) + assertThat(fileUpdatedWebhookEvent.data()) .isEqualTo( File.builder() .addAiTag( @@ -161,8 +161,8 @@ internal class DamFileUpdateEventTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val damFileUpdateEvent = - DamFileUpdateEvent.builder() + val fileUpdatedWebhookEvent = + FileUpdatedWebhookEvent.builder() .id("id") .type("file.updated") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -235,12 +235,12 @@ internal class DamFileUpdateEventTest { ) .build() - val roundtrippedDamFileUpdateEvent = + val roundtrippedFileUpdatedWebhookEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(damFileUpdateEvent), - jacksonTypeRef(), + jsonMapper.writeValueAsString(fileUpdatedWebhookEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedDamFileUpdateEvent).isEqualTo(damFileUpdateEvent) + assertThat(roundtrippedFileUpdatedWebhookEvent).isEqualTo(fileUpdatedWebhookEvent) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionCreatedWebhookEventTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEventTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionCreatedWebhookEventTest.kt index 57ac1f9c..2f4b7fee 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileVersionCreateEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionCreatedWebhookEventTest.kt @@ -10,12 +10,12 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class DamFileVersionCreateEventTest { +internal class FileVersionCreatedWebhookEventTest { @Test fun create() { - val damFileVersionCreateEvent = - DamFileVersionCreateEvent.builder() + val fileVersionCreatedWebhookEvent = + FileVersionCreatedWebhookEvent.builder() .id("id") .type("file-version.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -88,11 +88,11 @@ internal class DamFileVersionCreateEventTest { ) .build() - assertThat(damFileVersionCreateEvent.id()).isEqualTo("id") - assertThat(damFileVersionCreateEvent.type()).isEqualTo("file-version.created") - assertThat(damFileVersionCreateEvent.createdAt()) + assertThat(fileVersionCreatedWebhookEvent.id()).isEqualTo("id") + assertThat(fileVersionCreatedWebhookEvent.type()).isEqualTo("file-version.created") + assertThat(fileVersionCreatedWebhookEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(damFileVersionCreateEvent.data()) + assertThat(fileVersionCreatedWebhookEvent.data()) .isEqualTo( File.builder() .addAiTag( @@ -161,8 +161,8 @@ internal class DamFileVersionCreateEventTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val damFileVersionCreateEvent = - DamFileVersionCreateEvent.builder() + val fileVersionCreatedWebhookEvent = + FileVersionCreatedWebhookEvent.builder() .id("id") .type("file-version.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -235,12 +235,13 @@ internal class DamFileVersionCreateEventTest { ) .build() - val roundtrippedDamFileVersionCreateEvent = + val roundtrippedFileVersionCreatedWebhookEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(damFileVersionCreateEvent), - jacksonTypeRef(), + jsonMapper.writeValueAsString(fileVersionCreatedWebhookEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedDamFileVersionCreateEvent).isEqualTo(damFileVersionCreateEvent) + assertThat(roundtrippedFileVersionCreatedWebhookEvent) + .isEqualTo(fileVersionCreatedWebhookEvent) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileVersionDeleteEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionDeletedWebhookEventTest.kt similarity index 56% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileVersionDeleteEventTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionDeletedWebhookEventTest.kt index ecee651b..77fcd368 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/DamFileVersionDeleteEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionDeletedWebhookEventTest.kt @@ -8,30 +8,30 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class DamFileVersionDeleteEventTest { +internal class FileVersionDeletedWebhookEventTest { @Test fun create() { - val damFileVersionDeleteEvent = - DamFileVersionDeleteEvent.builder() + val fileVersionDeletedWebhookEvent = + FileVersionDeletedWebhookEvent.builder() .id("id") .type("file-version.deleted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - DamFileVersionDeleteEvent.Data.builder() + FileVersionDeletedWebhookEvent.Data.builder() .fileId("fileId") .versionId("versionId") .build() ) .build() - assertThat(damFileVersionDeleteEvent.id()).isEqualTo("id") - assertThat(damFileVersionDeleteEvent.type()).isEqualTo("file-version.deleted") - assertThat(damFileVersionDeleteEvent.createdAt()) + assertThat(fileVersionDeletedWebhookEvent.id()).isEqualTo("id") + assertThat(fileVersionDeletedWebhookEvent.type()).isEqualTo("file-version.deleted") + assertThat(fileVersionDeletedWebhookEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(damFileVersionDeleteEvent.data()) + assertThat(fileVersionDeletedWebhookEvent.data()) .isEqualTo( - DamFileVersionDeleteEvent.Data.builder() + FileVersionDeletedWebhookEvent.Data.builder() .fileId("fileId") .versionId("versionId") .build() @@ -41,25 +41,26 @@ internal class DamFileVersionDeleteEventTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val damFileVersionDeleteEvent = - DamFileVersionDeleteEvent.builder() + val fileVersionDeletedWebhookEvent = + FileVersionDeletedWebhookEvent.builder() .id("id") .type("file-version.deleted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - DamFileVersionDeleteEvent.Data.builder() + FileVersionDeletedWebhookEvent.Data.builder() .fileId("fileId") .versionId("versionId") .build() ) .build() - val roundtrippedDamFileVersionDeleteEvent = + val roundtrippedFileVersionDeletedWebhookEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(damFileVersionDeleteEvent), - jacksonTypeRef(), + jsonMapper.writeValueAsString(fileVersionDeletedWebhookEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedDamFileVersionDeleteEvent).isEqualTo(damFileVersionDeleteEvent) + assertThat(roundtrippedFileVersionDeletedWebhookEvent) + .isEqualTo(fileVersionDeletedWebhookEvent) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt index 05850b5b..dbdd920a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt @@ -93,11 +93,11 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test @@ -275,11 +275,11 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test @@ -468,11 +468,11 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test @@ -773,11 +773,11 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test @@ -1044,11 +1044,11 @@ internal class UnsafeUnwrapWebhookEventTest { .contains(uploadPreTransformError) assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test @@ -1139,11 +1139,11 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()) .contains(uploadPostTransformSuccess) assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test @@ -1249,11 +1249,11 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()) .contains(uploadPostTransformError) - assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test @@ -1315,9 +1315,9 @@ internal class UnsafeUnwrapWebhookEventTest { } @Test - fun ofDamFileCreate() { - val damFileCreate = - DamFileCreateEvent.builder() + fun ofFileCreated() { + val fileCreated = + FileCreatedWebhookEvent.builder() .id("id") .type("file.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1390,7 +1390,7 @@ internal class UnsafeUnwrapWebhookEventTest { ) .build() - val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofDamFileCreate(damFileCreate) + val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofFileCreated(fileCreated) assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty @@ -1399,19 +1399,19 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).contains(damFileCreate) - assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreated()).contains(fileCreated) + assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test - fun ofDamFileCreateRoundtrip() { + fun ofFileCreatedRoundtrip() { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = - UnsafeUnwrapWebhookEvent.ofDamFileCreate( - DamFileCreateEvent.builder() + UnsafeUnwrapWebhookEvent.ofFileCreated( + FileCreatedWebhookEvent.builder() .id("id") .type("file.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1502,9 +1502,9 @@ internal class UnsafeUnwrapWebhookEventTest { } @Test - fun ofDamFileUpdate() { - val damFileUpdate = - DamFileUpdateEvent.builder() + fun ofFileUpdated() { + val fileUpdated = + FileUpdatedWebhookEvent.builder() .id("id") .type("file.updated") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1577,7 +1577,7 @@ internal class UnsafeUnwrapWebhookEventTest { ) .build() - val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofDamFileUpdate(damFileUpdate) + val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofFileUpdated(fileUpdated) assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty @@ -1586,19 +1586,19 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).contains(damFileUpdate) - assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).contains(fileUpdated) + assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test - fun ofDamFileUpdateRoundtrip() { + fun ofFileUpdatedRoundtrip() { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = - UnsafeUnwrapWebhookEvent.ofDamFileUpdate( - DamFileUpdateEvent.builder() + UnsafeUnwrapWebhookEvent.ofFileUpdated( + FileUpdatedWebhookEvent.builder() .id("id") .type("file.updated") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1689,16 +1689,16 @@ internal class UnsafeUnwrapWebhookEventTest { } @Test - fun ofDamFileDelete() { - val damFileDelete = - DamFileDeleteEvent.builder() + fun ofFileDeleted() { + val fileDeleted = + FileDeletedWebhookEvent.builder() .id("id") .type("file.deleted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .data(DamFileDeleteEvent.Data.builder().fileId("fileId").build()) + .data(FileDeletedWebhookEvent.Data.builder().fileId("fileId").build()) .build() - val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofDamFileDelete(damFileDelete) + val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofFileDeleted(fileDeleted) assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty @@ -1707,23 +1707,23 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).contains(damFileDelete) - assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).contains(fileDeleted) + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test - fun ofDamFileDeleteRoundtrip() { + fun ofFileDeletedRoundtrip() { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = - UnsafeUnwrapWebhookEvent.ofDamFileDelete( - DamFileDeleteEvent.builder() + UnsafeUnwrapWebhookEvent.ofFileDeleted( + FileDeletedWebhookEvent.builder() .id("id") .type("file.deleted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .data(DamFileDeleteEvent.Data.builder().fileId("fileId").build()) + .data(FileDeletedWebhookEvent.Data.builder().fileId("fileId").build()) .build() ) @@ -1737,9 +1737,9 @@ internal class UnsafeUnwrapWebhookEventTest { } @Test - fun ofDamFileVersionCreate() { - val damFileVersionCreate = - DamFileVersionCreateEvent.builder() + fun ofFileVersionCreated() { + val fileVersionCreated = + FileVersionCreatedWebhookEvent.builder() .id("id") .type("file-version.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1813,7 +1813,7 @@ internal class UnsafeUnwrapWebhookEventTest { .build() val unsafeUnwrapWebhookEvent = - UnsafeUnwrapWebhookEvent.ofDamFileVersionCreate(damFileVersionCreate) + UnsafeUnwrapWebhookEvent.ofFileVersionCreated(fileVersionCreated) assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty @@ -1822,19 +1822,19 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).contains(damFileVersionCreate) - assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).contains(fileVersionCreated) + assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test - fun ofDamFileVersionCreateRoundtrip() { + fun ofFileVersionCreatedRoundtrip() { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = - UnsafeUnwrapWebhookEvent.ofDamFileVersionCreate( - DamFileVersionCreateEvent.builder() + UnsafeUnwrapWebhookEvent.ofFileVersionCreated( + FileVersionCreatedWebhookEvent.builder() .id("id") .type("file-version.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1925,14 +1925,14 @@ internal class UnsafeUnwrapWebhookEventTest { } @Test - fun ofDamFileVersionDelete() { - val damFileVersionDelete = - DamFileVersionDeleteEvent.builder() + fun ofFileVersionDeleted() { + val fileVersionDeleted = + FileVersionDeletedWebhookEvent.builder() .id("id") .type("file-version.deleted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - DamFileVersionDeleteEvent.Data.builder() + FileVersionDeletedWebhookEvent.Data.builder() .fileId("fileId") .versionId("versionId") .build() @@ -1940,7 +1940,7 @@ internal class UnsafeUnwrapWebhookEventTest { .build() val unsafeUnwrapWebhookEvent = - UnsafeUnwrapWebhookEvent.ofDamFileVersionDelete(damFileVersionDelete) + UnsafeUnwrapWebhookEvent.ofFileVersionDeleted(fileVersionDeleted) assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty @@ -1949,24 +1949,24 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.damFileVersionDelete()).contains(damFileVersionDelete) + assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).contains(fileVersionDeleted) } @Test - fun ofDamFileVersionDeleteRoundtrip() { + fun ofFileVersionDeletedRoundtrip() { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = - UnsafeUnwrapWebhookEvent.ofDamFileVersionDelete( - DamFileVersionDeleteEvent.builder() + UnsafeUnwrapWebhookEvent.ofFileVersionDeleted( + FileVersionDeletedWebhookEvent.builder() .id("id") .type("file-version.deleted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - DamFileVersionDeleteEvent.Data.builder() + FileVersionDeletedWebhookEvent.Data.builder() .fileId("fileId") .versionId("versionId") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt index 3cf50400..f5630092 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt @@ -93,11 +93,11 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test @@ -274,11 +274,11 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test @@ -466,11 +466,11 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test @@ -771,11 +771,11 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test @@ -1041,11 +1041,11 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).contains(uploadPreTransformError) assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test @@ -1136,11 +1136,11 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()) .contains(uploadPostTransformSuccess) assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test @@ -1245,11 +1245,11 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).contains(uploadPostTransformError) - assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test @@ -1311,9 +1311,9 @@ internal class UnwrapWebhookEventTest { } @Test - fun ofDamFileCreate() { - val damFileCreate = - DamFileCreateEvent.builder() + fun ofFileCreated() { + val fileCreated = + FileCreatedWebhookEvent.builder() .id("id") .type("file.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1386,7 +1386,7 @@ internal class UnwrapWebhookEventTest { ) .build() - val unwrapWebhookEvent = UnwrapWebhookEvent.ofDamFileCreate(damFileCreate) + val unwrapWebhookEvent = UnwrapWebhookEvent.ofFileCreated(fileCreated) assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty @@ -1395,19 +1395,19 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.damFileCreate()).contains(damFileCreate) - assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileCreated()).contains(fileCreated) + assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test - fun ofDamFileCreateRoundtrip() { + fun ofFileCreatedRoundtrip() { val jsonMapper = jsonMapper() val unwrapWebhookEvent = - UnwrapWebhookEvent.ofDamFileCreate( - DamFileCreateEvent.builder() + UnwrapWebhookEvent.ofFileCreated( + FileCreatedWebhookEvent.builder() .id("id") .type("file.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1498,9 +1498,9 @@ internal class UnwrapWebhookEventTest { } @Test - fun ofDamFileUpdate() { - val damFileUpdate = - DamFileUpdateEvent.builder() + fun ofFileUpdated() { + val fileUpdated = + FileUpdatedWebhookEvent.builder() .id("id") .type("file.updated") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1573,7 +1573,7 @@ internal class UnwrapWebhookEventTest { ) .build() - val unwrapWebhookEvent = UnwrapWebhookEvent.ofDamFileUpdate(damFileUpdate) + val unwrapWebhookEvent = UnwrapWebhookEvent.ofFileUpdated(fileUpdated) assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty @@ -1582,19 +1582,19 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileUpdate()).contains(damFileUpdate) - assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdated()).contains(fileUpdated) + assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test - fun ofDamFileUpdateRoundtrip() { + fun ofFileUpdatedRoundtrip() { val jsonMapper = jsonMapper() val unwrapWebhookEvent = - UnwrapWebhookEvent.ofDamFileUpdate( - DamFileUpdateEvent.builder() + UnwrapWebhookEvent.ofFileUpdated( + FileUpdatedWebhookEvent.builder() .id("id") .type("file.updated") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1685,16 +1685,16 @@ internal class UnwrapWebhookEventTest { } @Test - fun ofDamFileDelete() { - val damFileDelete = - DamFileDeleteEvent.builder() + fun ofFileDeleted() { + val fileDeleted = + FileDeletedWebhookEvent.builder() .id("id") .type("file.deleted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .data(DamFileDeleteEvent.Data.builder().fileId("fileId").build()) + .data(FileDeletedWebhookEvent.Data.builder().fileId("fileId").build()) .build() - val unwrapWebhookEvent = UnwrapWebhookEvent.ofDamFileDelete(damFileDelete) + val unwrapWebhookEvent = UnwrapWebhookEvent.ofFileDeleted(fileDeleted) assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty @@ -1703,23 +1703,23 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unwrapWebhookEvent.damFileDelete()).contains(damFileDelete) - assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unwrapWebhookEvent.fileDeleted()).contains(fileDeleted) + assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test - fun ofDamFileDeleteRoundtrip() { + fun ofFileDeletedRoundtrip() { val jsonMapper = jsonMapper() val unwrapWebhookEvent = - UnwrapWebhookEvent.ofDamFileDelete( - DamFileDeleteEvent.builder() + UnwrapWebhookEvent.ofFileDeleted( + FileDeletedWebhookEvent.builder() .id("id") .type("file.deleted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .data(DamFileDeleteEvent.Data.builder().fileId("fileId").build()) + .data(FileDeletedWebhookEvent.Data.builder().fileId("fileId").build()) .build() ) @@ -1733,9 +1733,9 @@ internal class UnwrapWebhookEventTest { } @Test - fun ofDamFileVersionCreate() { - val damFileVersionCreate = - DamFileVersionCreateEvent.builder() + fun ofFileVersionCreated() { + val fileVersionCreated = + FileVersionCreatedWebhookEvent.builder() .id("id") .type("file-version.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1808,7 +1808,7 @@ internal class UnwrapWebhookEventTest { ) .build() - val unwrapWebhookEvent = UnwrapWebhookEvent.ofDamFileVersionCreate(damFileVersionCreate) + val unwrapWebhookEvent = UnwrapWebhookEvent.ofFileVersionCreated(fileVersionCreated) assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty @@ -1817,19 +1817,19 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionCreate()).contains(damFileVersionCreate) - assertThat(unwrapWebhookEvent.damFileVersionDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreated()).contains(fileVersionCreated) + assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty } @Test - fun ofDamFileVersionCreateRoundtrip() { + fun ofFileVersionCreatedRoundtrip() { val jsonMapper = jsonMapper() val unwrapWebhookEvent = - UnwrapWebhookEvent.ofDamFileVersionCreate( - DamFileVersionCreateEvent.builder() + UnwrapWebhookEvent.ofFileVersionCreated( + FileVersionCreatedWebhookEvent.builder() .id("id") .type("file-version.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1920,21 +1920,21 @@ internal class UnwrapWebhookEventTest { } @Test - fun ofDamFileVersionDelete() { - val damFileVersionDelete = - DamFileVersionDeleteEvent.builder() + fun ofFileVersionDeleted() { + val fileVersionDeleted = + FileVersionDeletedWebhookEvent.builder() .id("id") .type("file-version.deleted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - DamFileVersionDeleteEvent.Data.builder() + FileVersionDeletedWebhookEvent.Data.builder() .fileId("fileId") .versionId("versionId") .build() ) .build() - val unwrapWebhookEvent = UnwrapWebhookEvent.ofDamFileVersionDelete(damFileVersionDelete) + val unwrapWebhookEvent = UnwrapWebhookEvent.ofFileVersionDeleted(fileVersionDeleted) assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty @@ -1943,24 +1943,24 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.damFileCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileUpdate()).isEmpty - assertThat(unwrapWebhookEvent.damFileDelete()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionCreate()).isEmpty - assertThat(unwrapWebhookEvent.damFileVersionDelete()).contains(damFileVersionDelete) + assertThat(unwrapWebhookEvent.fileCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty + assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDeleted()).contains(fileVersionDeleted) } @Test - fun ofDamFileVersionDeleteRoundtrip() { + fun ofFileVersionDeletedRoundtrip() { val jsonMapper = jsonMapper() val unwrapWebhookEvent = - UnwrapWebhookEvent.ofDamFileVersionDelete( - DamFileVersionDeleteEvent.builder() + UnwrapWebhookEvent.ofFileVersionDeleted( + FileVersionDeletedWebhookEvent.builder() .id("id") .type("file-version.deleted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - DamFileVersionDeleteEvent.Data.builder() + FileVersionDeletedWebhookEvent.Data.builder() .fileId("fileId") .versionId("versionId") .build() From f18e22be52528874c7adb453bc360b0e511001c3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 06:59:03 +0000 Subject: [PATCH 128/142] fix(api): rename DamFile events to File for consistency --- .stats.yml | 2 +- ...atedWebhookEvent.kt => FileCreateEvent.kt} | 30 +-- ...etedWebhookEvent.kt => FileDeleteEvent.kt} | 30 +-- ...atedWebhookEvent.kt => FileUpdateEvent.kt} | 30 +-- ...hookEvent.kt => FileVersionCreateEvent.kt} | 32 ++- ...hookEvent.kt => FileVersionDeleteEvent.kt} | 32 ++- .../webhooks/UnsafeUnwrapWebhookEvent.kt | 201 +++++++++--------- .../api/models/webhooks/UnwrapWebhookEvent.kt | 192 ++++++++--------- ...ookEventTest.kt => FileCreateEventTest.kt} | 26 +-- .../models/webhooks/FileDeleteEventTest.kt | 50 +++++ .../webhooks/FileDeletedWebhookEventTest.kt | 50 ----- ...ookEventTest.kt => FileUpdateEventTest.kt} | 26 +-- ...tTest.kt => FileVersionCreateEventTest.kt} | 27 ++- ...tTest.kt => FileVersionDeleteEventTest.kt} | 33 ++- .../webhooks/UnsafeUnwrapWebhookEventTest.kt | 198 ++++++++--------- .../models/webhooks/UnwrapWebhookEventTest.kt | 198 ++++++++--------- 16 files changed, 564 insertions(+), 593 deletions(-) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{FileCreatedWebhookEvent.kt => FileCreateEvent.kt} (91%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{FileDeletedWebhookEvent.kt => FileDeleteEvent.kt} (94%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{FileUpdatedWebhookEvent.kt => FileUpdateEvent.kt} (91%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{FileVersionCreatedWebhookEvent.kt => FileVersionCreateEvent.kt} (90%) rename image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/{FileVersionDeletedWebhookEvent.kt => FileVersionDeleteEvent.kt} (94%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/{FileCreatedWebhookEventTest.kt => FileCreateEventTest.kt} (93%) create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileDeleteEventTest.kt delete mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileDeletedWebhookEventTest.kt rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/{FileUpdatedWebhookEventTest.kt => FileUpdateEventTest.kt} (93%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/{FileVersionCreatedWebhookEventTest.kt => FileVersionCreateEventTest.kt} (92%) rename image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/{FileVersionDeletedWebhookEventTest.kt => FileVersionDeleteEventTest.kt} (56%) diff --git a/.stats.yml b/.stats.yml index 4bc5fef0..aae6cba6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d73a37dc3426586109bd153f02c6a605036b6a7396bba5173d013468c5291ce6.yml openapi_spec_hash: c193c6e557ff477481ec8d5ac8a0c96e -config_hash: 17e408231b0b01676298010c7405f483 +config_hash: 32b155378f65c234d3abeb18519fb3cd diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileCreatedWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileCreateEvent.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileCreatedWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileCreateEvent.kt index 4b5d0c33..4ea563a0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileCreatedWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileCreateEvent.kt @@ -19,7 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull /** Triggered when a file is created. */ -class FileCreatedWebhookEvent +class FileCreateEvent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -119,7 +119,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [FileCreatedWebhookEvent]. + * Returns a mutable builder for constructing an instance of [FileCreateEvent]. * * The following fields are required: * ```java @@ -132,7 +132,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [FileCreatedWebhookEvent]. */ + /** A builder for [FileCreateEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -142,12 +142,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fileCreatedWebhookEvent: FileCreatedWebhookEvent) = apply { - id = fileCreatedWebhookEvent.id - type = fileCreatedWebhookEvent.type - createdAt = fileCreatedWebhookEvent.createdAt - data = fileCreatedWebhookEvent.data - additionalProperties = fileCreatedWebhookEvent.additionalProperties.toMutableMap() + internal fun from(fileCreateEvent: FileCreateEvent) = apply { + id = fileCreateEvent.id + type = fileCreateEvent.type + createdAt = fileCreateEvent.createdAt + data = fileCreateEvent.data + additionalProperties = fileCreateEvent.additionalProperties.toMutableMap() } /** Unique identifier for the event. */ @@ -215,7 +215,7 @@ private constructor( } /** - * Returns an immutable instance of [FileCreatedWebhookEvent]. + * Returns an immutable instance of [FileCreateEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -229,8 +229,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): FileCreatedWebhookEvent = - FileCreatedWebhookEvent( + fun build(): FileCreateEvent = + FileCreateEvent( checkRequired("id", id), checkRequired("type", type), checkRequired("createdAt", createdAt), @@ -241,7 +241,7 @@ private constructor( private var validated: Boolean = false - fun validate(): FileCreatedWebhookEvent = apply { + fun validate(): FileCreateEvent = apply { if (validated) { return@apply } @@ -278,7 +278,7 @@ private constructor( return true } - return other is FileCreatedWebhookEvent && + return other is FileCreateEvent && id == other.id && type == other.type && createdAt == other.createdAt && @@ -293,5 +293,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FileCreatedWebhookEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" + "FileCreateEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileDeletedWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileDeleteEvent.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileDeletedWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileDeleteEvent.kt index 4c951bbf..d7e6177f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileDeletedWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileDeleteEvent.kt @@ -18,7 +18,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull /** Triggered when a file is deleted. */ -class FileDeletedWebhookEvent +class FileDeleteEvent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -116,7 +116,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [FileDeletedWebhookEvent]. + * Returns a mutable builder for constructing an instance of [FileDeleteEvent]. * * The following fields are required: * ```java @@ -129,7 +129,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [FileDeletedWebhookEvent]. */ + /** A builder for [FileDeleteEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -139,12 +139,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fileDeletedWebhookEvent: FileDeletedWebhookEvent) = apply { - id = fileDeletedWebhookEvent.id - type = fileDeletedWebhookEvent.type - createdAt = fileDeletedWebhookEvent.createdAt - data = fileDeletedWebhookEvent.data - additionalProperties = fileDeletedWebhookEvent.additionalProperties.toMutableMap() + internal fun from(fileDeleteEvent: FileDeleteEvent) = apply { + id = fileDeleteEvent.id + type = fileDeleteEvent.type + createdAt = fileDeleteEvent.createdAt + data = fileDeleteEvent.data + additionalProperties = fileDeleteEvent.additionalProperties.toMutableMap() } /** Unique identifier for the event. */ @@ -211,7 +211,7 @@ private constructor( } /** - * Returns an immutable instance of [FileDeletedWebhookEvent]. + * Returns an immutable instance of [FileDeleteEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -225,8 +225,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): FileDeletedWebhookEvent = - FileDeletedWebhookEvent( + fun build(): FileDeleteEvent = + FileDeleteEvent( checkRequired("id", id), checkRequired("type", type), checkRequired("createdAt", createdAt), @@ -237,7 +237,7 @@ private constructor( private var validated: Boolean = false - fun validate(): FileDeletedWebhookEvent = apply { + fun validate(): FileDeleteEvent = apply { if (validated) { return@apply } @@ -429,7 +429,7 @@ private constructor( return true } - return other is FileDeletedWebhookEvent && + return other is FileDeleteEvent && id == other.id && type == other.type && createdAt == other.createdAt && @@ -444,5 +444,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FileDeletedWebhookEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" + "FileDeleteEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileUpdatedWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileUpdateEvent.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileUpdatedWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileUpdateEvent.kt index 92b40a0a..aa0a2c51 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileUpdatedWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileUpdateEvent.kt @@ -19,7 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull /** Triggered when a file is updated. */ -class FileUpdatedWebhookEvent +class FileUpdateEvent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -119,7 +119,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [FileUpdatedWebhookEvent]. + * Returns a mutable builder for constructing an instance of [FileUpdateEvent]. * * The following fields are required: * ```java @@ -132,7 +132,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [FileUpdatedWebhookEvent]. */ + /** A builder for [FileUpdateEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -142,12 +142,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fileUpdatedWebhookEvent: FileUpdatedWebhookEvent) = apply { - id = fileUpdatedWebhookEvent.id - type = fileUpdatedWebhookEvent.type - createdAt = fileUpdatedWebhookEvent.createdAt - data = fileUpdatedWebhookEvent.data - additionalProperties = fileUpdatedWebhookEvent.additionalProperties.toMutableMap() + internal fun from(fileUpdateEvent: FileUpdateEvent) = apply { + id = fileUpdateEvent.id + type = fileUpdateEvent.type + createdAt = fileUpdateEvent.createdAt + data = fileUpdateEvent.data + additionalProperties = fileUpdateEvent.additionalProperties.toMutableMap() } /** Unique identifier for the event. */ @@ -215,7 +215,7 @@ private constructor( } /** - * Returns an immutable instance of [FileUpdatedWebhookEvent]. + * Returns an immutable instance of [FileUpdateEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -229,8 +229,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): FileUpdatedWebhookEvent = - FileUpdatedWebhookEvent( + fun build(): FileUpdateEvent = + FileUpdateEvent( checkRequired("id", id), checkRequired("type", type), checkRequired("createdAt", createdAt), @@ -241,7 +241,7 @@ private constructor( private var validated: Boolean = false - fun validate(): FileUpdatedWebhookEvent = apply { + fun validate(): FileUpdateEvent = apply { if (validated) { return@apply } @@ -278,7 +278,7 @@ private constructor( return true } - return other is FileUpdatedWebhookEvent && + return other is FileUpdateEvent && id == other.id && type == other.type && createdAt == other.createdAt && @@ -293,5 +293,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FileUpdatedWebhookEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" + "FileUpdateEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionCreatedWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionCreateEvent.kt similarity index 90% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionCreatedWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionCreateEvent.kt index 50f21c9f..c86abcce 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionCreatedWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionCreateEvent.kt @@ -19,7 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull /** Triggered when a file version is created. */ -class FileVersionCreatedWebhookEvent +class FileVersionCreateEvent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -119,8 +119,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [FileVersionCreatedWebhookEvent]. + * Returns a mutable builder for constructing an instance of [FileVersionCreateEvent]. * * The following fields are required: * ```java @@ -133,7 +132,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [FileVersionCreatedWebhookEvent]. */ + /** A builder for [FileVersionCreateEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -143,13 +142,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fileVersionCreatedWebhookEvent: FileVersionCreatedWebhookEvent) = apply { - id = fileVersionCreatedWebhookEvent.id - type = fileVersionCreatedWebhookEvent.type - createdAt = fileVersionCreatedWebhookEvent.createdAt - data = fileVersionCreatedWebhookEvent.data - additionalProperties = - fileVersionCreatedWebhookEvent.additionalProperties.toMutableMap() + internal fun from(fileVersionCreateEvent: FileVersionCreateEvent) = apply { + id = fileVersionCreateEvent.id + type = fileVersionCreateEvent.type + createdAt = fileVersionCreateEvent.createdAt + data = fileVersionCreateEvent.data + additionalProperties = fileVersionCreateEvent.additionalProperties.toMutableMap() } /** Unique identifier for the event. */ @@ -217,7 +215,7 @@ private constructor( } /** - * Returns an immutable instance of [FileVersionCreatedWebhookEvent]. + * Returns an immutable instance of [FileVersionCreateEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -231,8 +229,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): FileVersionCreatedWebhookEvent = - FileVersionCreatedWebhookEvent( + fun build(): FileVersionCreateEvent = + FileVersionCreateEvent( checkRequired("id", id), checkRequired("type", type), checkRequired("createdAt", createdAt), @@ -243,7 +241,7 @@ private constructor( private var validated: Boolean = false - fun validate(): FileVersionCreatedWebhookEvent = apply { + fun validate(): FileVersionCreateEvent = apply { if (validated) { return@apply } @@ -280,7 +278,7 @@ private constructor( return true } - return other is FileVersionCreatedWebhookEvent && + return other is FileVersionCreateEvent && id == other.id && type == other.type && createdAt == other.createdAt && @@ -295,5 +293,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FileVersionCreatedWebhookEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" + "FileVersionCreateEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionDeletedWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionDeleteEvent.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionDeletedWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionDeleteEvent.kt index 21354c10..9b9219bb 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionDeletedWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionDeleteEvent.kt @@ -18,7 +18,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull /** Triggered when a file version is deleted. */ -class FileVersionDeletedWebhookEvent +class FileVersionDeleteEvent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -116,8 +116,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [FileVersionDeletedWebhookEvent]. + * Returns a mutable builder for constructing an instance of [FileVersionDeleteEvent]. * * The following fields are required: * ```java @@ -130,7 +129,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [FileVersionDeletedWebhookEvent]. */ + /** A builder for [FileVersionDeleteEvent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -140,13 +139,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fileVersionDeletedWebhookEvent: FileVersionDeletedWebhookEvent) = apply { - id = fileVersionDeletedWebhookEvent.id - type = fileVersionDeletedWebhookEvent.type - createdAt = fileVersionDeletedWebhookEvent.createdAt - data = fileVersionDeletedWebhookEvent.data - additionalProperties = - fileVersionDeletedWebhookEvent.additionalProperties.toMutableMap() + internal fun from(fileVersionDeleteEvent: FileVersionDeleteEvent) = apply { + id = fileVersionDeleteEvent.id + type = fileVersionDeleteEvent.type + createdAt = fileVersionDeleteEvent.createdAt + data = fileVersionDeleteEvent.data + additionalProperties = fileVersionDeleteEvent.additionalProperties.toMutableMap() } /** Unique identifier for the event. */ @@ -213,7 +211,7 @@ private constructor( } /** - * Returns an immutable instance of [FileVersionDeletedWebhookEvent]. + * Returns an immutable instance of [FileVersionDeleteEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -227,8 +225,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): FileVersionDeletedWebhookEvent = - FileVersionDeletedWebhookEvent( + fun build(): FileVersionDeleteEvent = + FileVersionDeleteEvent( checkRequired("id", id), checkRequired("type", type), checkRequired("createdAt", createdAt), @@ -239,7 +237,7 @@ private constructor( private var validated: Boolean = false - fun validate(): FileVersionDeletedWebhookEvent = apply { + fun validate(): FileVersionDeleteEvent = apply { if (validated) { return@apply } @@ -476,7 +474,7 @@ private constructor( return true } - return other is FileVersionDeletedWebhookEvent && + return other is FileVersionDeleteEvent && id == other.id && type == other.type && createdAt == other.createdAt && @@ -491,5 +489,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FileVersionDeletedWebhookEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" + "FileVersionDeleteEvent{id=$id, type=$type, createdAt=$createdAt, data=$data, additionalProperties=$additionalProperties}" } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt index d5cb3514..1e6d8516 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt @@ -35,11 +35,11 @@ private constructor( private val uploadPreTransformError: UploadPreTransformErrorEvent? = null, private val uploadPostTransformSuccess: UploadPostTransformSuccessEvent? = null, private val uploadPostTransformError: UploadPostTransformErrorEvent? = null, - private val fileCreated: FileCreatedWebhookEvent? = null, - private val fileUpdated: FileUpdatedWebhookEvent? = null, - private val fileDeleted: FileDeletedWebhookEvent? = null, - private val fileVersionCreated: FileVersionCreatedWebhookEvent? = null, - private val fileVersionDeleted: FileVersionDeletedWebhookEvent? = null, + private val fileCreate: FileCreateEvent? = null, + private val fileUpdate: FileUpdateEvent? = null, + private val fileDelete: FileDeleteEvent? = null, + private val fileVersionCreate: FileVersionCreateEvent? = null, + private val fileVersionDelete: FileVersionDeleteEvent? = null, private val _json: JsonValue? = null, ) { @@ -97,21 +97,21 @@ private constructor( Optional.ofNullable(uploadPostTransformError) /** Triggered when a file is created. */ - fun fileCreated(): Optional = Optional.ofNullable(fileCreated) + fun fileCreate(): Optional = Optional.ofNullable(fileCreate) /** Triggered when a file is updated. */ - fun fileUpdated(): Optional = Optional.ofNullable(fileUpdated) + fun fileUpdate(): Optional = Optional.ofNullable(fileUpdate) /** Triggered when a file is deleted. */ - fun fileDeleted(): Optional = Optional.ofNullable(fileDeleted) + fun fileDelete(): Optional = Optional.ofNullable(fileDelete) /** Triggered when a file version is created. */ - fun fileVersionCreated(): Optional = - Optional.ofNullable(fileVersionCreated) + fun fileVersionCreate(): Optional = + Optional.ofNullable(fileVersionCreate) /** Triggered when a file version is deleted. */ - fun fileVersionDeleted(): Optional = - Optional.ofNullable(fileVersionDeleted) + fun fileVersionDelete(): Optional = + Optional.ofNullable(fileVersionDelete) fun isVideoTransformationAccepted(): Boolean = videoTransformationAccepted != null @@ -127,15 +127,15 @@ private constructor( fun isUploadPostTransformError(): Boolean = uploadPostTransformError != null - fun isFileCreated(): Boolean = fileCreated != null + fun isFileCreate(): Boolean = fileCreate != null - fun isFileUpdated(): Boolean = fileUpdated != null + fun isFileUpdate(): Boolean = fileUpdate != null - fun isFileDeleted(): Boolean = fileDeleted != null + fun isFileDelete(): Boolean = fileDelete != null - fun isFileVersionCreated(): Boolean = fileVersionCreated != null + fun isFileVersionCreate(): Boolean = fileVersionCreate != null - fun isFileVersionDeleted(): Boolean = fileVersionDeleted != null + fun isFileVersionDelete(): Boolean = fileVersionDelete != null /** * Triggered when a new video transformation request is accepted for processing. This event @@ -191,21 +191,21 @@ private constructor( uploadPostTransformError.getOrThrow("uploadPostTransformError") /** Triggered when a file is created. */ - fun asFileCreated(): FileCreatedWebhookEvent = fileCreated.getOrThrow("fileCreated") + fun asFileCreate(): FileCreateEvent = fileCreate.getOrThrow("fileCreate") /** Triggered when a file is updated. */ - fun asFileUpdated(): FileUpdatedWebhookEvent = fileUpdated.getOrThrow("fileUpdated") + fun asFileUpdate(): FileUpdateEvent = fileUpdate.getOrThrow("fileUpdate") /** Triggered when a file is deleted. */ - fun asFileDeleted(): FileDeletedWebhookEvent = fileDeleted.getOrThrow("fileDeleted") + fun asFileDelete(): FileDeleteEvent = fileDelete.getOrThrow("fileDelete") /** Triggered when a file version is created. */ - fun asFileVersionCreated(): FileVersionCreatedWebhookEvent = - fileVersionCreated.getOrThrow("fileVersionCreated") + fun asFileVersionCreate(): FileVersionCreateEvent = + fileVersionCreate.getOrThrow("fileVersionCreate") /** Triggered when a file version is deleted. */ - fun asFileVersionDeleted(): FileVersionDeletedWebhookEvent = - fileVersionDeleted.getOrThrow("fileVersionDeleted") + fun asFileVersionDelete(): FileVersionDeleteEvent = + fileVersionDelete.getOrThrow("fileVersionDelete") fun _json(): Optional = Optional.ofNullable(_json) @@ -225,11 +225,11 @@ private constructor( visitor.visitUploadPostTransformSuccess(uploadPostTransformSuccess) uploadPostTransformError != null -> visitor.visitUploadPostTransformError(uploadPostTransformError) - fileCreated != null -> visitor.visitFileCreated(fileCreated) - fileUpdated != null -> visitor.visitFileUpdated(fileUpdated) - fileDeleted != null -> visitor.visitFileDeleted(fileDeleted) - fileVersionCreated != null -> visitor.visitFileVersionCreated(fileVersionCreated) - fileVersionDeleted != null -> visitor.visitFileVersionDeleted(fileVersionDeleted) + fileCreate != null -> visitor.visitFileCreate(fileCreate) + fileUpdate != null -> visitor.visitFileUpdate(fileUpdate) + fileDelete != null -> visitor.visitFileDelete(fileDelete) + fileVersionCreate != null -> visitor.visitFileVersionCreate(fileVersionCreate) + fileVersionDelete != null -> visitor.visitFileVersionDelete(fileVersionDelete) else -> visitor.unknown(_json) } @@ -284,28 +284,24 @@ private constructor( uploadPostTransformError.validate() } - override fun visitFileCreated(fileCreated: FileCreatedWebhookEvent) { - fileCreated.validate() + override fun visitFileCreate(fileCreate: FileCreateEvent) { + fileCreate.validate() } - override fun visitFileUpdated(fileUpdated: FileUpdatedWebhookEvent) { - fileUpdated.validate() + override fun visitFileUpdate(fileUpdate: FileUpdateEvent) { + fileUpdate.validate() } - override fun visitFileDeleted(fileDeleted: FileDeletedWebhookEvent) { - fileDeleted.validate() + override fun visitFileDelete(fileDelete: FileDeleteEvent) { + fileDelete.validate() } - override fun visitFileVersionCreated( - fileVersionCreated: FileVersionCreatedWebhookEvent - ) { - fileVersionCreated.validate() + override fun visitFileVersionCreate(fileVersionCreate: FileVersionCreateEvent) { + fileVersionCreate.validate() } - override fun visitFileVersionDeleted( - fileVersionDeleted: FileVersionDeletedWebhookEvent - ) { - fileVersionDeleted.validate() + override fun visitFileVersionDelete(fileVersionDelete: FileVersionDeleteEvent) { + fileVersionDelete.validate() } } ) @@ -357,22 +353,17 @@ private constructor( uploadPostTransformError: UploadPostTransformErrorEvent ) = uploadPostTransformError.validity() - override fun visitFileCreated(fileCreated: FileCreatedWebhookEvent) = - fileCreated.validity() + override fun visitFileCreate(fileCreate: FileCreateEvent) = fileCreate.validity() - override fun visitFileUpdated(fileUpdated: FileUpdatedWebhookEvent) = - fileUpdated.validity() + override fun visitFileUpdate(fileUpdate: FileUpdateEvent) = fileUpdate.validity() - override fun visitFileDeleted(fileDeleted: FileDeletedWebhookEvent) = - fileDeleted.validity() + override fun visitFileDelete(fileDelete: FileDeleteEvent) = fileDelete.validity() - override fun visitFileVersionCreated( - fileVersionCreated: FileVersionCreatedWebhookEvent - ) = fileVersionCreated.validity() + override fun visitFileVersionCreate(fileVersionCreate: FileVersionCreateEvent) = + fileVersionCreate.validity() - override fun visitFileVersionDeleted( - fileVersionDeleted: FileVersionDeletedWebhookEvent - ) = fileVersionDeleted.validity() + override fun visitFileVersionDelete(fileVersionDelete: FileVersionDeleteEvent) = + fileVersionDelete.validity() override fun unknown(json: JsonValue?) = 0 } @@ -391,11 +382,11 @@ private constructor( uploadPreTransformError == other.uploadPreTransformError && uploadPostTransformSuccess == other.uploadPostTransformSuccess && uploadPostTransformError == other.uploadPostTransformError && - fileCreated == other.fileCreated && - fileUpdated == other.fileUpdated && - fileDeleted == other.fileDeleted && - fileVersionCreated == other.fileVersionCreated && - fileVersionDeleted == other.fileVersionDeleted + fileCreate == other.fileCreate && + fileUpdate == other.fileUpdate && + fileDelete == other.fileDelete && + fileVersionCreate == other.fileVersionCreate && + fileVersionDelete == other.fileVersionDelete } override fun hashCode(): Int = @@ -407,11 +398,11 @@ private constructor( uploadPreTransformError, uploadPostTransformSuccess, uploadPostTransformError, - fileCreated, - fileUpdated, - fileDeleted, - fileVersionCreated, - fileVersionDeleted, + fileCreate, + fileUpdate, + fileDelete, + fileVersionCreate, + fileVersionDelete, ) override fun toString(): String = @@ -430,13 +421,13 @@ private constructor( "UnsafeUnwrapWebhookEvent{uploadPostTransformSuccess=$uploadPostTransformSuccess}" uploadPostTransformError != null -> "UnsafeUnwrapWebhookEvent{uploadPostTransformError=$uploadPostTransformError}" - fileCreated != null -> "UnsafeUnwrapWebhookEvent{fileCreated=$fileCreated}" - fileUpdated != null -> "UnsafeUnwrapWebhookEvent{fileUpdated=$fileUpdated}" - fileDeleted != null -> "UnsafeUnwrapWebhookEvent{fileDeleted=$fileDeleted}" - fileVersionCreated != null -> - "UnsafeUnwrapWebhookEvent{fileVersionCreated=$fileVersionCreated}" - fileVersionDeleted != null -> - "UnsafeUnwrapWebhookEvent{fileVersionDeleted=$fileVersionDeleted}" + fileCreate != null -> "UnsafeUnwrapWebhookEvent{fileCreate=$fileCreate}" + fileUpdate != null -> "UnsafeUnwrapWebhookEvent{fileUpdate=$fileUpdate}" + fileDelete != null -> "UnsafeUnwrapWebhookEvent{fileDelete=$fileDelete}" + fileVersionCreate != null -> + "UnsafeUnwrapWebhookEvent{fileVersionCreate=$fileVersionCreate}" + fileVersionDelete != null -> + "UnsafeUnwrapWebhookEvent{fileVersionDelete=$fileVersionDelete}" _json != null -> "UnsafeUnwrapWebhookEvent{_unknown=$_json}" else -> throw IllegalStateException("Invalid UnsafeUnwrapWebhookEvent") } @@ -507,28 +498,28 @@ private constructor( /** Triggered when a file is created. */ @JvmStatic - fun ofFileCreated(fileCreated: FileCreatedWebhookEvent) = - UnsafeUnwrapWebhookEvent(fileCreated = fileCreated) + fun ofFileCreate(fileCreate: FileCreateEvent) = + UnsafeUnwrapWebhookEvent(fileCreate = fileCreate) /** Triggered when a file is updated. */ @JvmStatic - fun ofFileUpdated(fileUpdated: FileUpdatedWebhookEvent) = - UnsafeUnwrapWebhookEvent(fileUpdated = fileUpdated) + fun ofFileUpdate(fileUpdate: FileUpdateEvent) = + UnsafeUnwrapWebhookEvent(fileUpdate = fileUpdate) /** Triggered when a file is deleted. */ @JvmStatic - fun ofFileDeleted(fileDeleted: FileDeletedWebhookEvent) = - UnsafeUnwrapWebhookEvent(fileDeleted = fileDeleted) + fun ofFileDelete(fileDelete: FileDeleteEvent) = + UnsafeUnwrapWebhookEvent(fileDelete = fileDelete) /** Triggered when a file version is created. */ @JvmStatic - fun ofFileVersionCreated(fileVersionCreated: FileVersionCreatedWebhookEvent) = - UnsafeUnwrapWebhookEvent(fileVersionCreated = fileVersionCreated) + fun ofFileVersionCreate(fileVersionCreate: FileVersionCreateEvent) = + UnsafeUnwrapWebhookEvent(fileVersionCreate = fileVersionCreate) /** Triggered when a file version is deleted. */ @JvmStatic - fun ofFileVersionDeleted(fileVersionDeleted: FileVersionDeletedWebhookEvent) = - UnsafeUnwrapWebhookEvent(fileVersionDeleted = fileVersionDeleted) + fun ofFileVersionDelete(fileVersionDelete: FileVersionDeleteEvent) = + UnsafeUnwrapWebhookEvent(fileVersionDelete = fileVersionDelete) } /** @@ -596,19 +587,19 @@ private constructor( ): T /** Triggered when a file is created. */ - fun visitFileCreated(fileCreated: FileCreatedWebhookEvent): T + fun visitFileCreate(fileCreate: FileCreateEvent): T /** Triggered when a file is updated. */ - fun visitFileUpdated(fileUpdated: FileUpdatedWebhookEvent): T + fun visitFileUpdate(fileUpdate: FileUpdateEvent): T /** Triggered when a file is deleted. */ - fun visitFileDeleted(fileDeleted: FileDeletedWebhookEvent): T + fun visitFileDelete(fileDelete: FileDeleteEvent): T /** Triggered when a file version is created. */ - fun visitFileVersionCreated(fileVersionCreated: FileVersionCreatedWebhookEvent): T + fun visitFileVersionCreate(fileVersionCreate: FileVersionCreateEvent): T /** Triggered when a file version is deleted. */ - fun visitFileVersionDeleted(fileVersionDeleted: FileVersionDeletedWebhookEvent): T + fun visitFileVersionDelete(fileVersionDelete: FileVersionDeleteEvent): T /** * Maps an unknown variant of [UnsafeUnwrapWebhookEvent] to a value of type [T]. @@ -669,23 +660,21 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { UnsafeUnwrapWebhookEvent(uploadPostTransformError = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnsafeUnwrapWebhookEvent(fileCreated = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + UnsafeUnwrapWebhookEvent(fileCreate = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnsafeUnwrapWebhookEvent(fileUpdated = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + UnsafeUnwrapWebhookEvent(fileUpdate = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnsafeUnwrapWebhookEvent(fileDeleted = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + UnsafeUnwrapWebhookEvent(fileDelete = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnsafeUnwrapWebhookEvent(fileVersionCreate = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnsafeUnwrapWebhookEvent(fileVersionDelete = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { - UnsafeUnwrapWebhookEvent(fileVersionCreated = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { - UnsafeUnwrapWebhookEvent(fileVersionDeleted = it, _json = json) - }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -725,11 +714,11 @@ private constructor( generator.writeObject(value.uploadPostTransformSuccess) value.uploadPostTransformError != null -> generator.writeObject(value.uploadPostTransformError) - value.fileCreated != null -> generator.writeObject(value.fileCreated) - value.fileUpdated != null -> generator.writeObject(value.fileUpdated) - value.fileDeleted != null -> generator.writeObject(value.fileDeleted) - value.fileVersionCreated != null -> generator.writeObject(value.fileVersionCreated) - value.fileVersionDeleted != null -> generator.writeObject(value.fileVersionDeleted) + value.fileCreate != null -> generator.writeObject(value.fileCreate) + value.fileUpdate != null -> generator.writeObject(value.fileUpdate) + value.fileDelete != null -> generator.writeObject(value.fileDelete) + value.fileVersionCreate != null -> generator.writeObject(value.fileVersionCreate) + value.fileVersionDelete != null -> generator.writeObject(value.fileVersionDelete) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid UnsafeUnwrapWebhookEvent") } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt index bb9046cb..70c27e7a 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt @@ -35,11 +35,11 @@ private constructor( private val uploadPreTransformError: UploadPreTransformErrorEvent? = null, private val uploadPostTransformSuccess: UploadPostTransformSuccessEvent? = null, private val uploadPostTransformError: UploadPostTransformErrorEvent? = null, - private val fileCreated: FileCreatedWebhookEvent? = null, - private val fileUpdated: FileUpdatedWebhookEvent? = null, - private val fileDeleted: FileDeletedWebhookEvent? = null, - private val fileVersionCreated: FileVersionCreatedWebhookEvent? = null, - private val fileVersionDeleted: FileVersionDeletedWebhookEvent? = null, + private val fileCreate: FileCreateEvent? = null, + private val fileUpdate: FileUpdateEvent? = null, + private val fileDelete: FileDeleteEvent? = null, + private val fileVersionCreate: FileVersionCreateEvent? = null, + private val fileVersionDelete: FileVersionDeleteEvent? = null, private val _json: JsonValue? = null, ) { @@ -97,21 +97,21 @@ private constructor( Optional.ofNullable(uploadPostTransformError) /** Triggered when a file is created. */ - fun fileCreated(): Optional = Optional.ofNullable(fileCreated) + fun fileCreate(): Optional = Optional.ofNullable(fileCreate) /** Triggered when a file is updated. */ - fun fileUpdated(): Optional = Optional.ofNullable(fileUpdated) + fun fileUpdate(): Optional = Optional.ofNullable(fileUpdate) /** Triggered when a file is deleted. */ - fun fileDeleted(): Optional = Optional.ofNullable(fileDeleted) + fun fileDelete(): Optional = Optional.ofNullable(fileDelete) /** Triggered when a file version is created. */ - fun fileVersionCreated(): Optional = - Optional.ofNullable(fileVersionCreated) + fun fileVersionCreate(): Optional = + Optional.ofNullable(fileVersionCreate) /** Triggered when a file version is deleted. */ - fun fileVersionDeleted(): Optional = - Optional.ofNullable(fileVersionDeleted) + fun fileVersionDelete(): Optional = + Optional.ofNullable(fileVersionDelete) fun isVideoTransformationAccepted(): Boolean = videoTransformationAccepted != null @@ -127,15 +127,15 @@ private constructor( fun isUploadPostTransformError(): Boolean = uploadPostTransformError != null - fun isFileCreated(): Boolean = fileCreated != null + fun isFileCreate(): Boolean = fileCreate != null - fun isFileUpdated(): Boolean = fileUpdated != null + fun isFileUpdate(): Boolean = fileUpdate != null - fun isFileDeleted(): Boolean = fileDeleted != null + fun isFileDelete(): Boolean = fileDelete != null - fun isFileVersionCreated(): Boolean = fileVersionCreated != null + fun isFileVersionCreate(): Boolean = fileVersionCreate != null - fun isFileVersionDeleted(): Boolean = fileVersionDeleted != null + fun isFileVersionDelete(): Boolean = fileVersionDelete != null /** * Triggered when a new video transformation request is accepted for processing. This event @@ -191,21 +191,21 @@ private constructor( uploadPostTransformError.getOrThrow("uploadPostTransformError") /** Triggered when a file is created. */ - fun asFileCreated(): FileCreatedWebhookEvent = fileCreated.getOrThrow("fileCreated") + fun asFileCreate(): FileCreateEvent = fileCreate.getOrThrow("fileCreate") /** Triggered when a file is updated. */ - fun asFileUpdated(): FileUpdatedWebhookEvent = fileUpdated.getOrThrow("fileUpdated") + fun asFileUpdate(): FileUpdateEvent = fileUpdate.getOrThrow("fileUpdate") /** Triggered when a file is deleted. */ - fun asFileDeleted(): FileDeletedWebhookEvent = fileDeleted.getOrThrow("fileDeleted") + fun asFileDelete(): FileDeleteEvent = fileDelete.getOrThrow("fileDelete") /** Triggered when a file version is created. */ - fun asFileVersionCreated(): FileVersionCreatedWebhookEvent = - fileVersionCreated.getOrThrow("fileVersionCreated") + fun asFileVersionCreate(): FileVersionCreateEvent = + fileVersionCreate.getOrThrow("fileVersionCreate") /** Triggered when a file version is deleted. */ - fun asFileVersionDeleted(): FileVersionDeletedWebhookEvent = - fileVersionDeleted.getOrThrow("fileVersionDeleted") + fun asFileVersionDelete(): FileVersionDeleteEvent = + fileVersionDelete.getOrThrow("fileVersionDelete") fun _json(): Optional = Optional.ofNullable(_json) @@ -225,11 +225,11 @@ private constructor( visitor.visitUploadPostTransformSuccess(uploadPostTransformSuccess) uploadPostTransformError != null -> visitor.visitUploadPostTransformError(uploadPostTransformError) - fileCreated != null -> visitor.visitFileCreated(fileCreated) - fileUpdated != null -> visitor.visitFileUpdated(fileUpdated) - fileDeleted != null -> visitor.visitFileDeleted(fileDeleted) - fileVersionCreated != null -> visitor.visitFileVersionCreated(fileVersionCreated) - fileVersionDeleted != null -> visitor.visitFileVersionDeleted(fileVersionDeleted) + fileCreate != null -> visitor.visitFileCreate(fileCreate) + fileUpdate != null -> visitor.visitFileUpdate(fileUpdate) + fileDelete != null -> visitor.visitFileDelete(fileDelete) + fileVersionCreate != null -> visitor.visitFileVersionCreate(fileVersionCreate) + fileVersionDelete != null -> visitor.visitFileVersionDelete(fileVersionDelete) else -> visitor.unknown(_json) } @@ -284,28 +284,24 @@ private constructor( uploadPostTransformError.validate() } - override fun visitFileCreated(fileCreated: FileCreatedWebhookEvent) { - fileCreated.validate() + override fun visitFileCreate(fileCreate: FileCreateEvent) { + fileCreate.validate() } - override fun visitFileUpdated(fileUpdated: FileUpdatedWebhookEvent) { - fileUpdated.validate() + override fun visitFileUpdate(fileUpdate: FileUpdateEvent) { + fileUpdate.validate() } - override fun visitFileDeleted(fileDeleted: FileDeletedWebhookEvent) { - fileDeleted.validate() + override fun visitFileDelete(fileDelete: FileDeleteEvent) { + fileDelete.validate() } - override fun visitFileVersionCreated( - fileVersionCreated: FileVersionCreatedWebhookEvent - ) { - fileVersionCreated.validate() + override fun visitFileVersionCreate(fileVersionCreate: FileVersionCreateEvent) { + fileVersionCreate.validate() } - override fun visitFileVersionDeleted( - fileVersionDeleted: FileVersionDeletedWebhookEvent - ) { - fileVersionDeleted.validate() + override fun visitFileVersionDelete(fileVersionDelete: FileVersionDeleteEvent) { + fileVersionDelete.validate() } } ) @@ -357,22 +353,17 @@ private constructor( uploadPostTransformError: UploadPostTransformErrorEvent ) = uploadPostTransformError.validity() - override fun visitFileCreated(fileCreated: FileCreatedWebhookEvent) = - fileCreated.validity() + override fun visitFileCreate(fileCreate: FileCreateEvent) = fileCreate.validity() - override fun visitFileUpdated(fileUpdated: FileUpdatedWebhookEvent) = - fileUpdated.validity() + override fun visitFileUpdate(fileUpdate: FileUpdateEvent) = fileUpdate.validity() - override fun visitFileDeleted(fileDeleted: FileDeletedWebhookEvent) = - fileDeleted.validity() + override fun visitFileDelete(fileDelete: FileDeleteEvent) = fileDelete.validity() - override fun visitFileVersionCreated( - fileVersionCreated: FileVersionCreatedWebhookEvent - ) = fileVersionCreated.validity() + override fun visitFileVersionCreate(fileVersionCreate: FileVersionCreateEvent) = + fileVersionCreate.validity() - override fun visitFileVersionDeleted( - fileVersionDeleted: FileVersionDeletedWebhookEvent - ) = fileVersionDeleted.validity() + override fun visitFileVersionDelete(fileVersionDelete: FileVersionDeleteEvent) = + fileVersionDelete.validity() override fun unknown(json: JsonValue?) = 0 } @@ -391,11 +382,11 @@ private constructor( uploadPreTransformError == other.uploadPreTransformError && uploadPostTransformSuccess == other.uploadPostTransformSuccess && uploadPostTransformError == other.uploadPostTransformError && - fileCreated == other.fileCreated && - fileUpdated == other.fileUpdated && - fileDeleted == other.fileDeleted && - fileVersionCreated == other.fileVersionCreated && - fileVersionDeleted == other.fileVersionDeleted + fileCreate == other.fileCreate && + fileUpdate == other.fileUpdate && + fileDelete == other.fileDelete && + fileVersionCreate == other.fileVersionCreate && + fileVersionDelete == other.fileVersionDelete } override fun hashCode(): Int = @@ -407,11 +398,11 @@ private constructor( uploadPreTransformError, uploadPostTransformSuccess, uploadPostTransformError, - fileCreated, - fileUpdated, - fileDeleted, - fileVersionCreated, - fileVersionDeleted, + fileCreate, + fileUpdate, + fileDelete, + fileVersionCreate, + fileVersionDelete, ) override fun toString(): String = @@ -430,13 +421,11 @@ private constructor( "UnwrapWebhookEvent{uploadPostTransformSuccess=$uploadPostTransformSuccess}" uploadPostTransformError != null -> "UnwrapWebhookEvent{uploadPostTransformError=$uploadPostTransformError}" - fileCreated != null -> "UnwrapWebhookEvent{fileCreated=$fileCreated}" - fileUpdated != null -> "UnwrapWebhookEvent{fileUpdated=$fileUpdated}" - fileDeleted != null -> "UnwrapWebhookEvent{fileDeleted=$fileDeleted}" - fileVersionCreated != null -> - "UnwrapWebhookEvent{fileVersionCreated=$fileVersionCreated}" - fileVersionDeleted != null -> - "UnwrapWebhookEvent{fileVersionDeleted=$fileVersionDeleted}" + fileCreate != null -> "UnwrapWebhookEvent{fileCreate=$fileCreate}" + fileUpdate != null -> "UnwrapWebhookEvent{fileUpdate=$fileUpdate}" + fileDelete != null -> "UnwrapWebhookEvent{fileDelete=$fileDelete}" + fileVersionCreate != null -> "UnwrapWebhookEvent{fileVersionCreate=$fileVersionCreate}" + fileVersionDelete != null -> "UnwrapWebhookEvent{fileVersionDelete=$fileVersionDelete}" _json != null -> "UnwrapWebhookEvent{_unknown=$_json}" else -> throw IllegalStateException("Invalid UnwrapWebhookEvent") } @@ -507,28 +496,25 @@ private constructor( /** Triggered when a file is created. */ @JvmStatic - fun ofFileCreated(fileCreated: FileCreatedWebhookEvent) = - UnwrapWebhookEvent(fileCreated = fileCreated) + fun ofFileCreate(fileCreate: FileCreateEvent) = UnwrapWebhookEvent(fileCreate = fileCreate) /** Triggered when a file is updated. */ @JvmStatic - fun ofFileUpdated(fileUpdated: FileUpdatedWebhookEvent) = - UnwrapWebhookEvent(fileUpdated = fileUpdated) + fun ofFileUpdate(fileUpdate: FileUpdateEvent) = UnwrapWebhookEvent(fileUpdate = fileUpdate) /** Triggered when a file is deleted. */ @JvmStatic - fun ofFileDeleted(fileDeleted: FileDeletedWebhookEvent) = - UnwrapWebhookEvent(fileDeleted = fileDeleted) + fun ofFileDelete(fileDelete: FileDeleteEvent) = UnwrapWebhookEvent(fileDelete = fileDelete) /** Triggered when a file version is created. */ @JvmStatic - fun ofFileVersionCreated(fileVersionCreated: FileVersionCreatedWebhookEvent) = - UnwrapWebhookEvent(fileVersionCreated = fileVersionCreated) + fun ofFileVersionCreate(fileVersionCreate: FileVersionCreateEvent) = + UnwrapWebhookEvent(fileVersionCreate = fileVersionCreate) /** Triggered when a file version is deleted. */ @JvmStatic - fun ofFileVersionDeleted(fileVersionDeleted: FileVersionDeletedWebhookEvent) = - UnwrapWebhookEvent(fileVersionDeleted = fileVersionDeleted) + fun ofFileVersionDelete(fileVersionDelete: FileVersionDeleteEvent) = + UnwrapWebhookEvent(fileVersionDelete = fileVersionDelete) } /** @@ -596,19 +582,19 @@ private constructor( ): T /** Triggered when a file is created. */ - fun visitFileCreated(fileCreated: FileCreatedWebhookEvent): T + fun visitFileCreate(fileCreate: FileCreateEvent): T /** Triggered when a file is updated. */ - fun visitFileUpdated(fileUpdated: FileUpdatedWebhookEvent): T + fun visitFileUpdate(fileUpdate: FileUpdateEvent): T /** Triggered when a file is deleted. */ - fun visitFileDeleted(fileDeleted: FileDeletedWebhookEvent): T + fun visitFileDelete(fileDelete: FileDeleteEvent): T /** Triggered when a file version is created. */ - fun visitFileVersionCreated(fileVersionCreated: FileVersionCreatedWebhookEvent): T + fun visitFileVersionCreate(fileVersionCreate: FileVersionCreateEvent): T /** Triggered when a file version is deleted. */ - fun visitFileVersionDeleted(fileVersionDeleted: FileVersionDeletedWebhookEvent): T + fun visitFileVersionDelete(fileVersionDelete: FileVersionDeleteEvent): T /** * Maps an unknown variant of [UnwrapWebhookEvent] to a value of type [T]. @@ -659,19 +645,21 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { UnwrapWebhookEvent(uploadPostTransformError = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnwrapWebhookEvent(fileCreated = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + UnwrapWebhookEvent(fileCreate = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnwrapWebhookEvent(fileUpdate = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnwrapWebhookEvent(fileDelete = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnwrapWebhookEvent(fileUpdated = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + UnwrapWebhookEvent(fileVersionCreate = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - UnwrapWebhookEvent(fileDeleted = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + UnwrapWebhookEvent(fileVersionDelete = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { UnwrapWebhookEvent(fileVersionCreated = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { UnwrapWebhookEvent(fileVersionDeleted = it, _json = json) }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -710,11 +698,11 @@ private constructor( generator.writeObject(value.uploadPostTransformSuccess) value.uploadPostTransformError != null -> generator.writeObject(value.uploadPostTransformError) - value.fileCreated != null -> generator.writeObject(value.fileCreated) - value.fileUpdated != null -> generator.writeObject(value.fileUpdated) - value.fileDeleted != null -> generator.writeObject(value.fileDeleted) - value.fileVersionCreated != null -> generator.writeObject(value.fileVersionCreated) - value.fileVersionDeleted != null -> generator.writeObject(value.fileVersionDeleted) + value.fileCreate != null -> generator.writeObject(value.fileCreate) + value.fileUpdate != null -> generator.writeObject(value.fileUpdate) + value.fileDelete != null -> generator.writeObject(value.fileDelete) + value.fileVersionCreate != null -> generator.writeObject(value.fileVersionCreate) + value.fileVersionDelete != null -> generator.writeObject(value.fileVersionDelete) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid UnwrapWebhookEvent") } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileCreatedWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileCreateEventTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileCreatedWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileCreateEventTest.kt index ffb45d14..339516ba 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileCreatedWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileCreateEventTest.kt @@ -10,12 +10,12 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class FileCreatedWebhookEventTest { +internal class FileCreateEventTest { @Test fun create() { - val fileCreatedWebhookEvent = - FileCreatedWebhookEvent.builder() + val fileCreateEvent = + FileCreateEvent.builder() .id("id") .type("file.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -88,11 +88,11 @@ internal class FileCreatedWebhookEventTest { ) .build() - assertThat(fileCreatedWebhookEvent.id()).isEqualTo("id") - assertThat(fileCreatedWebhookEvent.type()).isEqualTo("file.created") - assertThat(fileCreatedWebhookEvent.createdAt()) + assertThat(fileCreateEvent.id()).isEqualTo("id") + assertThat(fileCreateEvent.type()).isEqualTo("file.created") + assertThat(fileCreateEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(fileCreatedWebhookEvent.data()) + assertThat(fileCreateEvent.data()) .isEqualTo( File.builder() .addAiTag( @@ -161,8 +161,8 @@ internal class FileCreatedWebhookEventTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val fileCreatedWebhookEvent = - FileCreatedWebhookEvent.builder() + val fileCreateEvent = + FileCreateEvent.builder() .id("id") .type("file.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -235,12 +235,12 @@ internal class FileCreatedWebhookEventTest { ) .build() - val roundtrippedFileCreatedWebhookEvent = + val roundtrippedFileCreateEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(fileCreatedWebhookEvent), - jacksonTypeRef(), + jsonMapper.writeValueAsString(fileCreateEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedFileCreatedWebhookEvent).isEqualTo(fileCreatedWebhookEvent) + assertThat(roundtrippedFileCreateEvent).isEqualTo(fileCreateEvent) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileDeleteEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileDeleteEventTest.kt new file mode 100644 index 00000000..01ba34cd --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileDeleteEventTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models.webhooks + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileDeleteEventTest { + + @Test + fun create() { + val fileDeleteEvent = + FileDeleteEvent.builder() + .id("id") + .type("file.deleted") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data(FileDeleteEvent.Data.builder().fileId("fileId").build()) + .build() + + assertThat(fileDeleteEvent.id()).isEqualTo("id") + assertThat(fileDeleteEvent.type()).isEqualTo("file.deleted") + assertThat(fileDeleteEvent.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(fileDeleteEvent.data()) + .isEqualTo(FileDeleteEvent.Data.builder().fileId("fileId").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fileDeleteEvent = + FileDeleteEvent.builder() + .id("id") + .type("file.deleted") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data(FileDeleteEvent.Data.builder().fileId("fileId").build()) + .build() + + val roundtrippedFileDeleteEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fileDeleteEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFileDeleteEvent).isEqualTo(fileDeleteEvent) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileDeletedWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileDeletedWebhookEventTest.kt deleted file mode 100644 index 88693b2b..00000000 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileDeletedWebhookEventTest.kt +++ /dev/null @@ -1,50 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.imagekit.api.models.webhooks - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class FileDeletedWebhookEventTest { - - @Test - fun create() { - val fileDeletedWebhookEvent = - FileDeletedWebhookEvent.builder() - .id("id") - .type("file.deleted") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .data(FileDeletedWebhookEvent.Data.builder().fileId("fileId").build()) - .build() - - assertThat(fileDeletedWebhookEvent.id()).isEqualTo("id") - assertThat(fileDeletedWebhookEvent.type()).isEqualTo("file.deleted") - assertThat(fileDeletedWebhookEvent.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(fileDeletedWebhookEvent.data()) - .isEqualTo(FileDeletedWebhookEvent.Data.builder().fileId("fileId").build()) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val fileDeletedWebhookEvent = - FileDeletedWebhookEvent.builder() - .id("id") - .type("file.deleted") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .data(FileDeletedWebhookEvent.Data.builder().fileId("fileId").build()) - .build() - - val roundtrippedFileDeletedWebhookEvent = - jsonMapper.readValue( - jsonMapper.writeValueAsString(fileDeletedWebhookEvent), - jacksonTypeRef(), - ) - - assertThat(roundtrippedFileDeletedWebhookEvent).isEqualTo(fileDeletedWebhookEvent) - } -} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileUpdatedWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileUpdateEventTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileUpdatedWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileUpdateEventTest.kt index 1d31abd7..7d783230 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileUpdatedWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileUpdateEventTest.kt @@ -10,12 +10,12 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class FileUpdatedWebhookEventTest { +internal class FileUpdateEventTest { @Test fun create() { - val fileUpdatedWebhookEvent = - FileUpdatedWebhookEvent.builder() + val fileUpdateEvent = + FileUpdateEvent.builder() .id("id") .type("file.updated") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -88,11 +88,11 @@ internal class FileUpdatedWebhookEventTest { ) .build() - assertThat(fileUpdatedWebhookEvent.id()).isEqualTo("id") - assertThat(fileUpdatedWebhookEvent.type()).isEqualTo("file.updated") - assertThat(fileUpdatedWebhookEvent.createdAt()) + assertThat(fileUpdateEvent.id()).isEqualTo("id") + assertThat(fileUpdateEvent.type()).isEqualTo("file.updated") + assertThat(fileUpdateEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(fileUpdatedWebhookEvent.data()) + assertThat(fileUpdateEvent.data()) .isEqualTo( File.builder() .addAiTag( @@ -161,8 +161,8 @@ internal class FileUpdatedWebhookEventTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val fileUpdatedWebhookEvent = - FileUpdatedWebhookEvent.builder() + val fileUpdateEvent = + FileUpdateEvent.builder() .id("id") .type("file.updated") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -235,12 +235,12 @@ internal class FileUpdatedWebhookEventTest { ) .build() - val roundtrippedFileUpdatedWebhookEvent = + val roundtrippedFileUpdateEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(fileUpdatedWebhookEvent), - jacksonTypeRef(), + jsonMapper.writeValueAsString(fileUpdateEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedFileUpdatedWebhookEvent).isEqualTo(fileUpdatedWebhookEvent) + assertThat(roundtrippedFileUpdateEvent).isEqualTo(fileUpdateEvent) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionCreatedWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionCreateEventTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionCreatedWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionCreateEventTest.kt index 2f4b7fee..87b8ef6e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionCreatedWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionCreateEventTest.kt @@ -10,12 +10,12 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class FileVersionCreatedWebhookEventTest { +internal class FileVersionCreateEventTest { @Test fun create() { - val fileVersionCreatedWebhookEvent = - FileVersionCreatedWebhookEvent.builder() + val fileVersionCreateEvent = + FileVersionCreateEvent.builder() .id("id") .type("file-version.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -88,11 +88,11 @@ internal class FileVersionCreatedWebhookEventTest { ) .build() - assertThat(fileVersionCreatedWebhookEvent.id()).isEqualTo("id") - assertThat(fileVersionCreatedWebhookEvent.type()).isEqualTo("file-version.created") - assertThat(fileVersionCreatedWebhookEvent.createdAt()) + assertThat(fileVersionCreateEvent.id()).isEqualTo("id") + assertThat(fileVersionCreateEvent.type()).isEqualTo("file-version.created") + assertThat(fileVersionCreateEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(fileVersionCreatedWebhookEvent.data()) + assertThat(fileVersionCreateEvent.data()) .isEqualTo( File.builder() .addAiTag( @@ -161,8 +161,8 @@ internal class FileVersionCreatedWebhookEventTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val fileVersionCreatedWebhookEvent = - FileVersionCreatedWebhookEvent.builder() + val fileVersionCreateEvent = + FileVersionCreateEvent.builder() .id("id") .type("file-version.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -235,13 +235,12 @@ internal class FileVersionCreatedWebhookEventTest { ) .build() - val roundtrippedFileVersionCreatedWebhookEvent = + val roundtrippedFileVersionCreateEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(fileVersionCreatedWebhookEvent), - jacksonTypeRef(), + jsonMapper.writeValueAsString(fileVersionCreateEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedFileVersionCreatedWebhookEvent) - .isEqualTo(fileVersionCreatedWebhookEvent) + assertThat(roundtrippedFileVersionCreateEvent).isEqualTo(fileVersionCreateEvent) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionDeletedWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionDeleteEventTest.kt similarity index 56% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionDeletedWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionDeleteEventTest.kt index 77fcd368..07077d96 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionDeletedWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionDeleteEventTest.kt @@ -8,30 +8,30 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class FileVersionDeletedWebhookEventTest { +internal class FileVersionDeleteEventTest { @Test fun create() { - val fileVersionDeletedWebhookEvent = - FileVersionDeletedWebhookEvent.builder() + val fileVersionDeleteEvent = + FileVersionDeleteEvent.builder() .id("id") .type("file-version.deleted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - FileVersionDeletedWebhookEvent.Data.builder() + FileVersionDeleteEvent.Data.builder() .fileId("fileId") .versionId("versionId") .build() ) .build() - assertThat(fileVersionDeletedWebhookEvent.id()).isEqualTo("id") - assertThat(fileVersionDeletedWebhookEvent.type()).isEqualTo("file-version.deleted") - assertThat(fileVersionDeletedWebhookEvent.createdAt()) + assertThat(fileVersionDeleteEvent.id()).isEqualTo("id") + assertThat(fileVersionDeleteEvent.type()).isEqualTo("file-version.deleted") + assertThat(fileVersionDeleteEvent.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(fileVersionDeletedWebhookEvent.data()) + assertThat(fileVersionDeleteEvent.data()) .isEqualTo( - FileVersionDeletedWebhookEvent.Data.builder() + FileVersionDeleteEvent.Data.builder() .fileId("fileId") .versionId("versionId") .build() @@ -41,26 +41,25 @@ internal class FileVersionDeletedWebhookEventTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val fileVersionDeletedWebhookEvent = - FileVersionDeletedWebhookEvent.builder() + val fileVersionDeleteEvent = + FileVersionDeleteEvent.builder() .id("id") .type("file-version.deleted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - FileVersionDeletedWebhookEvent.Data.builder() + FileVersionDeleteEvent.Data.builder() .fileId("fileId") .versionId("versionId") .build() ) .build() - val roundtrippedFileVersionDeletedWebhookEvent = + val roundtrippedFileVersionDeleteEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(fileVersionDeletedWebhookEvent), - jacksonTypeRef(), + jsonMapper.writeValueAsString(fileVersionDeleteEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedFileVersionDeletedWebhookEvent) - .isEqualTo(fileVersionDeletedWebhookEvent) + assertThat(roundtrippedFileVersionDeleteEvent).isEqualTo(fileVersionDeleteEvent) } } diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt index dbdd920a..5dc6f19f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt @@ -93,11 +93,11 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test @@ -275,11 +275,11 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test @@ -468,11 +468,11 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test @@ -773,11 +773,11 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test @@ -1044,11 +1044,11 @@ internal class UnsafeUnwrapWebhookEventTest { .contains(uploadPreTransformError) assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test @@ -1139,11 +1139,11 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()) .contains(uploadPostTransformSuccess) assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test @@ -1249,11 +1249,11 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()) .contains(uploadPostTransformError) - assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test @@ -1315,9 +1315,9 @@ internal class UnsafeUnwrapWebhookEventTest { } @Test - fun ofFileCreated() { - val fileCreated = - FileCreatedWebhookEvent.builder() + fun ofFileCreate() { + val fileCreate = + FileCreateEvent.builder() .id("id") .type("file.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1390,7 +1390,7 @@ internal class UnsafeUnwrapWebhookEventTest { ) .build() - val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofFileCreated(fileCreated) + val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofFileCreate(fileCreate) assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty @@ -1399,19 +1399,19 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileCreated()).contains(fileCreated) - assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreate()).contains(fileCreate) + assertThat(unsafeUnwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test - fun ofFileCreatedRoundtrip() { + fun ofFileCreateRoundtrip() { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = - UnsafeUnwrapWebhookEvent.ofFileCreated( - FileCreatedWebhookEvent.builder() + UnsafeUnwrapWebhookEvent.ofFileCreate( + FileCreateEvent.builder() .id("id") .type("file.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1502,9 +1502,9 @@ internal class UnsafeUnwrapWebhookEventTest { } @Test - fun ofFileUpdated() { - val fileUpdated = - FileUpdatedWebhookEvent.builder() + fun ofFileUpdate() { + val fileUpdate = + FileUpdateEvent.builder() .id("id") .type("file.updated") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1577,7 +1577,7 @@ internal class UnsafeUnwrapWebhookEventTest { ) .build() - val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofFileUpdated(fileUpdated) + val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofFileUpdate(fileUpdate) assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty @@ -1586,19 +1586,19 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).contains(fileUpdated) - assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdate()).contains(fileUpdate) + assertThat(unsafeUnwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test - fun ofFileUpdatedRoundtrip() { + fun ofFileUpdateRoundtrip() { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = - UnsafeUnwrapWebhookEvent.ofFileUpdated( - FileUpdatedWebhookEvent.builder() + UnsafeUnwrapWebhookEvent.ofFileUpdate( + FileUpdateEvent.builder() .id("id") .type("file.updated") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1689,16 +1689,16 @@ internal class UnsafeUnwrapWebhookEventTest { } @Test - fun ofFileDeleted() { - val fileDeleted = - FileDeletedWebhookEvent.builder() + fun ofFileDelete() { + val fileDelete = + FileDeleteEvent.builder() .id("id") .type("file.deleted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .data(FileDeletedWebhookEvent.Data.builder().fileId("fileId").build()) + .data(FileDeleteEvent.Data.builder().fileId("fileId").build()) .build() - val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofFileDeleted(fileDeleted) + val unsafeUnwrapWebhookEvent = UnsafeUnwrapWebhookEvent.ofFileDelete(fileDelete) assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty @@ -1707,23 +1707,23 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).contains(fileDeleted) - assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDelete()).contains(fileDelete) + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test - fun ofFileDeletedRoundtrip() { + fun ofFileDeleteRoundtrip() { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = - UnsafeUnwrapWebhookEvent.ofFileDeleted( - FileDeletedWebhookEvent.builder() + UnsafeUnwrapWebhookEvent.ofFileDelete( + FileDeleteEvent.builder() .id("id") .type("file.deleted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .data(FileDeletedWebhookEvent.Data.builder().fileId("fileId").build()) + .data(FileDeleteEvent.Data.builder().fileId("fileId").build()) .build() ) @@ -1737,9 +1737,9 @@ internal class UnsafeUnwrapWebhookEventTest { } @Test - fun ofFileVersionCreated() { - val fileVersionCreated = - FileVersionCreatedWebhookEvent.builder() + fun ofFileVersionCreate() { + val fileVersionCreate = + FileVersionCreateEvent.builder() .id("id") .type("file-version.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1813,7 +1813,7 @@ internal class UnsafeUnwrapWebhookEventTest { .build() val unsafeUnwrapWebhookEvent = - UnsafeUnwrapWebhookEvent.ofFileVersionCreated(fileVersionCreated) + UnsafeUnwrapWebhookEvent.ofFileVersionCreate(fileVersionCreate) assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty @@ -1822,19 +1822,19 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).contains(fileVersionCreated) - assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreate()).contains(fileVersionCreate) + assertThat(unsafeUnwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test - fun ofFileVersionCreatedRoundtrip() { + fun ofFileVersionCreateRoundtrip() { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = - UnsafeUnwrapWebhookEvent.ofFileVersionCreated( - FileVersionCreatedWebhookEvent.builder() + UnsafeUnwrapWebhookEvent.ofFileVersionCreate( + FileVersionCreateEvent.builder() .id("id") .type("file-version.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1925,14 +1925,14 @@ internal class UnsafeUnwrapWebhookEventTest { } @Test - fun ofFileVersionDeleted() { - val fileVersionDeleted = - FileVersionDeletedWebhookEvent.builder() + fun ofFileVersionDelete() { + val fileVersionDelete = + FileVersionDeleteEvent.builder() .id("id") .type("file-version.deleted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - FileVersionDeletedWebhookEvent.Data.builder() + FileVersionDeleteEvent.Data.builder() .fileId("fileId") .versionId("versionId") .build() @@ -1940,7 +1940,7 @@ internal class UnsafeUnwrapWebhookEventTest { .build() val unsafeUnwrapWebhookEvent = - UnsafeUnwrapWebhookEvent.ofFileVersionDeleted(fileVersionDeleted) + UnsafeUnwrapWebhookEvent.ofFileVersionDelete(fileVersionDelete) assertThat(unsafeUnwrapWebhookEvent.videoTransformationAccepted()).isEmpty assertThat(unsafeUnwrapWebhookEvent.videoTransformationReady()).isEmpty @@ -1949,24 +1949,24 @@ internal class UnsafeUnwrapWebhookEventTest { assertThat(unsafeUnwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unsafeUnwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unsafeUnwrapWebhookEvent.fileVersionDeleted()).contains(fileVersionDeleted) + assertThat(unsafeUnwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unsafeUnwrapWebhookEvent.fileVersionDelete()).contains(fileVersionDelete) } @Test - fun ofFileVersionDeletedRoundtrip() { + fun ofFileVersionDeleteRoundtrip() { val jsonMapper = jsonMapper() val unsafeUnwrapWebhookEvent = - UnsafeUnwrapWebhookEvent.ofFileVersionDeleted( - FileVersionDeletedWebhookEvent.builder() + UnsafeUnwrapWebhookEvent.ofFileVersionDelete( + FileVersionDeleteEvent.builder() .id("id") .type("file-version.deleted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - FileVersionDeletedWebhookEvent.Data.builder() + FileVersionDeleteEvent.Data.builder() .fileId("fileId") .versionId("versionId") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt index f5630092..7c783365 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt @@ -93,11 +93,11 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test @@ -274,11 +274,11 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test @@ -466,11 +466,11 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test @@ -771,11 +771,11 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test @@ -1041,11 +1041,11 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).contains(uploadPreTransformError) assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test @@ -1136,11 +1136,11 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()) .contains(uploadPostTransformSuccess) assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test @@ -1245,11 +1245,11 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).contains(uploadPostTransformError) - assertThat(unwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test @@ -1311,9 +1311,9 @@ internal class UnwrapWebhookEventTest { } @Test - fun ofFileCreated() { - val fileCreated = - FileCreatedWebhookEvent.builder() + fun ofFileCreate() { + val fileCreate = + FileCreateEvent.builder() .id("id") .type("file.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1386,7 +1386,7 @@ internal class UnwrapWebhookEventTest { ) .build() - val unwrapWebhookEvent = UnwrapWebhookEvent.ofFileCreated(fileCreated) + val unwrapWebhookEvent = UnwrapWebhookEvent.ofFileCreate(fileCreate) assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty @@ -1395,19 +1395,19 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.fileCreated()).contains(fileCreated) - assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileCreate()).contains(fileCreate) + assertThat(unwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test - fun ofFileCreatedRoundtrip() { + fun ofFileCreateRoundtrip() { val jsonMapper = jsonMapper() val unwrapWebhookEvent = - UnwrapWebhookEvent.ofFileCreated( - FileCreatedWebhookEvent.builder() + UnwrapWebhookEvent.ofFileCreate( + FileCreateEvent.builder() .id("id") .type("file.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1498,9 +1498,9 @@ internal class UnwrapWebhookEventTest { } @Test - fun ofFileUpdated() { - val fileUpdated = - FileUpdatedWebhookEvent.builder() + fun ofFileUpdate() { + val fileUpdate = + FileUpdateEvent.builder() .id("id") .type("file.updated") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1573,7 +1573,7 @@ internal class UnwrapWebhookEventTest { ) .build() - val unwrapWebhookEvent = UnwrapWebhookEvent.ofFileUpdated(fileUpdated) + val unwrapWebhookEvent = UnwrapWebhookEvent.ofFileUpdate(fileUpdate) assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty @@ -1582,19 +1582,19 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileUpdated()).contains(fileUpdated) - assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdate()).contains(fileUpdate) + assertThat(unwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test - fun ofFileUpdatedRoundtrip() { + fun ofFileUpdateRoundtrip() { val jsonMapper = jsonMapper() val unwrapWebhookEvent = - UnwrapWebhookEvent.ofFileUpdated( - FileUpdatedWebhookEvent.builder() + UnwrapWebhookEvent.ofFileUpdate( + FileUpdateEvent.builder() .id("id") .type("file.updated") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1685,16 +1685,16 @@ internal class UnwrapWebhookEventTest { } @Test - fun ofFileDeleted() { - val fileDeleted = - FileDeletedWebhookEvent.builder() + fun ofFileDelete() { + val fileDelete = + FileDeleteEvent.builder() .id("id") .type("file.deleted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .data(FileDeletedWebhookEvent.Data.builder().fileId("fileId").build()) + .data(FileDeleteEvent.Data.builder().fileId("fileId").build()) .build() - val unwrapWebhookEvent = UnwrapWebhookEvent.ofFileDeleted(fileDeleted) + val unwrapWebhookEvent = UnwrapWebhookEvent.ofFileDelete(fileDelete) assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty @@ -1703,23 +1703,23 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unwrapWebhookEvent.fileDeleted()).contains(fileDeleted) - assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.fileDelete()).contains(fileDelete) + assertThat(unwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test - fun ofFileDeletedRoundtrip() { + fun ofFileDeleteRoundtrip() { val jsonMapper = jsonMapper() val unwrapWebhookEvent = - UnwrapWebhookEvent.ofFileDeleted( - FileDeletedWebhookEvent.builder() + UnwrapWebhookEvent.ofFileDelete( + FileDeleteEvent.builder() .id("id") .type("file.deleted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .data(FileDeletedWebhookEvent.Data.builder().fileId("fileId").build()) + .data(FileDeleteEvent.Data.builder().fileId("fileId").build()) .build() ) @@ -1733,9 +1733,9 @@ internal class UnwrapWebhookEventTest { } @Test - fun ofFileVersionCreated() { - val fileVersionCreated = - FileVersionCreatedWebhookEvent.builder() + fun ofFileVersionCreate() { + val fileVersionCreate = + FileVersionCreateEvent.builder() .id("id") .type("file-version.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1808,7 +1808,7 @@ internal class UnwrapWebhookEventTest { ) .build() - val unwrapWebhookEvent = UnwrapWebhookEvent.ofFileVersionCreated(fileVersionCreated) + val unwrapWebhookEvent = UnwrapWebhookEvent.ofFileVersionCreate(fileVersionCreate) assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty @@ -1817,19 +1817,19 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionCreated()).contains(fileVersionCreated) - assertThat(unwrapWebhookEvent.fileVersionDeleted()).isEmpty + assertThat(unwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreate()).contains(fileVersionCreate) + assertThat(unwrapWebhookEvent.fileVersionDelete()).isEmpty } @Test - fun ofFileVersionCreatedRoundtrip() { + fun ofFileVersionCreateRoundtrip() { val jsonMapper = jsonMapper() val unwrapWebhookEvent = - UnwrapWebhookEvent.ofFileVersionCreated( - FileVersionCreatedWebhookEvent.builder() + UnwrapWebhookEvent.ofFileVersionCreate( + FileVersionCreateEvent.builder() .id("id") .type("file-version.created") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -1920,21 +1920,21 @@ internal class UnwrapWebhookEventTest { } @Test - fun ofFileVersionDeleted() { - val fileVersionDeleted = - FileVersionDeletedWebhookEvent.builder() + fun ofFileVersionDelete() { + val fileVersionDelete = + FileVersionDeleteEvent.builder() .id("id") .type("file-version.deleted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - FileVersionDeletedWebhookEvent.Data.builder() + FileVersionDeleteEvent.Data.builder() .fileId("fileId") .versionId("versionId") .build() ) .build() - val unwrapWebhookEvent = UnwrapWebhookEvent.ofFileVersionDeleted(fileVersionDeleted) + val unwrapWebhookEvent = UnwrapWebhookEvent.ofFileVersionDelete(fileVersionDelete) assertThat(unwrapWebhookEvent.videoTransformationAccepted()).isEmpty assertThat(unwrapWebhookEvent.videoTransformationReady()).isEmpty @@ -1943,24 +1943,24 @@ internal class UnwrapWebhookEventTest { assertThat(unwrapWebhookEvent.uploadPreTransformError()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformSuccess()).isEmpty assertThat(unwrapWebhookEvent.uploadPostTransformError()).isEmpty - assertThat(unwrapWebhookEvent.fileCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileUpdated()).isEmpty - assertThat(unwrapWebhookEvent.fileDeleted()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionCreated()).isEmpty - assertThat(unwrapWebhookEvent.fileVersionDeleted()).contains(fileVersionDeleted) + assertThat(unwrapWebhookEvent.fileCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileUpdate()).isEmpty + assertThat(unwrapWebhookEvent.fileDelete()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionCreate()).isEmpty + assertThat(unwrapWebhookEvent.fileVersionDelete()).contains(fileVersionDelete) } @Test - fun ofFileVersionDeletedRoundtrip() { + fun ofFileVersionDeleteRoundtrip() { val jsonMapper = jsonMapper() val unwrapWebhookEvent = - UnwrapWebhookEvent.ofFileVersionDeleted( - FileVersionDeletedWebhookEvent.builder() + UnwrapWebhookEvent.ofFileVersionDelete( + FileVersionDeleteEvent.builder() .id("id") .type("file-version.deleted") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .data( - FileVersionDeletedWebhookEvent.Data.builder() + FileVersionDeleteEvent.Data.builder() .fileId("fileId") .versionId("versionId") .build() From f9a78b0fd65f309da64d400d91665696ebfb67eb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 18:07:06 +0000 Subject: [PATCH 129/142] docs: improve examples --- .../models/GetImageAttributesOptionsTest.kt | 6 +-- .../imagekit/api/models/ImageOverlayTest.kt | 6 +-- .../com/imagekit/api/models/OverlayTest.kt | 16 +++---- .../api/models/SolidColorOverlayTest.kt | 6 +-- .../SolidColorOverlayTransformationTest.kt | 6 +-- .../com/imagekit/api/models/SrcOptionsTest.kt | 6 +-- .../imagekit/api/models/TextOverlayTest.kt | 6 +-- .../models/TextOverlayTransformationTest.kt | 6 +-- .../imagekit/api/models/TransformationTest.kt | 6 +-- .../imagekit/api/models/VideoOverlayTest.kt | 6 +-- .../models/assets/AssetListResponseTest.kt | 4 +- .../beta/v2/files/FileUploadResponseTest.kt | 6 +-- .../CustomMetadataFieldCreateParamsTest.kt | 42 +++++++++++++++++-- .../CustomMetadataFieldTest.kt | 39 +++++++++++++++-- .../CustomMetadataFieldUpdateParamsTest.kt | 42 +++++++++++++++++-- .../com/imagekit/api/models/files/FileTest.kt | 6 +-- .../models/files/FileUpdateResponseTest.kt | 6 +-- .../models/files/FileUploadResponseTest.kt | 6 +-- .../api/models/files/UpdateFileRequestTest.kt | 4 +- .../models/webhooks/FileCreateEventTest.kt | 6 +-- .../models/webhooks/FileUpdateEventTest.kt | 6 +-- .../webhooks/FileVersionCreateEventTest.kt | 6 +-- .../webhooks/UnsafeUnwrapWebhookEventTest.kt | 16 +++---- .../models/webhooks/UnwrapWebhookEventTest.kt | 16 +++---- .../UploadPreTransformSuccessEventTest.kt | 6 +-- .../CustomMetadataFieldServiceAsyncTest.kt | 28 ++++++++++++- .../CustomMetadataFieldServiceTest.kt | 28 ++++++++++++- .../api/proguard/ProGuardCompatibilityTest.kt | 2 +- 28 files changed, 246 insertions(+), 93 deletions(-) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt index 71e02e02..dc36825f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt @@ -95,7 +95,7 @@ internal class GetImageAttributesOptionsTest { ) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) @@ -209,7 +209,7 @@ internal class GetImageAttributesOptionsTest { .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) @@ -333,7 +333,7 @@ internal class GetImageAttributesOptionsTest { ) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt index f6866ef5..75e60ec0 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt @@ -99,7 +99,7 @@ internal class ImageOverlayTest { ) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) @@ -212,7 +212,7 @@ internal class ImageOverlayTest { .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) @@ -333,7 +333,7 @@ internal class ImageOverlayTest { ) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt index cc0a81b5..d244bc3b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt @@ -43,7 +43,7 @@ internal class OverlayTest { .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) @@ -91,7 +91,7 @@ internal class OverlayTest { .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) @@ -195,7 +195,7 @@ internal class OverlayTest { ) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) @@ -328,7 +328,7 @@ internal class OverlayTest { ) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) @@ -455,7 +455,7 @@ internal class OverlayTest { ) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) @@ -588,7 +588,7 @@ internal class OverlayTest { ) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) @@ -729,7 +729,7 @@ internal class OverlayTest { .background("background") .gradientTrue() .height(0.0) - .radius(0.0) + .radiusMax() .width(0.0) .build() ) @@ -769,7 +769,7 @@ internal class OverlayTest { .background("background") .gradientTrue() .height(0.0) - .radius(0.0) + .radiusMax() .width(0.0) .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt index a53b4de6..fb8980b0 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt @@ -33,7 +33,7 @@ internal class SolidColorOverlayTest { .background("background") .gradientTrue() .height(0.0) - .radius(0.0) + .radiusMax() .width(0.0) .build() ) @@ -61,7 +61,7 @@ internal class SolidColorOverlayTest { .background("background") .gradientTrue() .height(0.0) - .radius(0.0) + .radiusMax() .width(0.0) .build() ) @@ -91,7 +91,7 @@ internal class SolidColorOverlayTest { .background("background") .gradientTrue() .height(0.0) - .radius(0.0) + .radiusMax() .width(0.0) .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTransformationTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTransformationTest.kt index d5802c92..ad8ef85a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTransformationTest.kt @@ -17,7 +17,7 @@ internal class SolidColorOverlayTransformationTest { .background("background") .gradientTrue() .height(0.0) - .radius(0.0) + .radiusMax() .width(0.0) .build() @@ -28,7 +28,7 @@ internal class SolidColorOverlayTransformationTest { assertThat(solidColorOverlayTransformation.height()) .contains(SolidColorOverlayTransformation.Height.ofNumber(0.0)) assertThat(solidColorOverlayTransformation.radius()) - .contains(SolidColorOverlayTransformation.Radius.ofNumber(0.0)) + .contains(SolidColorOverlayTransformation.Radius.ofMax()) assertThat(solidColorOverlayTransformation.width()) .contains(SolidColorOverlayTransformation.Width.ofNumber(0.0)) } @@ -42,7 +42,7 @@ internal class SolidColorOverlayTransformationTest { .background("background") .gradientTrue() .height(0.0) - .radius(0.0) + .radiusMax() .width(0.0) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt index 5e6f2a29..47f231d1 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt @@ -95,7 +95,7 @@ internal class SrcOptionsTest { ) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) @@ -203,7 +203,7 @@ internal class SrcOptionsTest { .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) @@ -320,7 +320,7 @@ internal class SrcOptionsTest { ) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt index 8227d262..65a652f3 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt @@ -39,7 +39,7 @@ internal class TextOverlayTest { .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) @@ -75,7 +75,7 @@ internal class TextOverlayTest { .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) @@ -113,7 +113,7 @@ internal class TextOverlayTest { .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTransformationTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTransformationTest.kt index f07cd592..00f631fd 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTransformationTest.kt @@ -22,7 +22,7 @@ internal class TextOverlayTransformationTest { .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) @@ -42,7 +42,7 @@ internal class TextOverlayTransformationTest { assertThat(textOverlayTransformation.padding()) .contains(TextOverlayTransformation.Padding.ofNumber(0.0)) assertThat(textOverlayTransformation.radius()) - .contains(TextOverlayTransformation.Radius.ofNumber(0.0)) + .contains(TextOverlayTransformation.Radius.ofMax()) assertThat(textOverlayTransformation.rotation()) .contains(TextOverlayTransformation.Rotation.ofNumber(0.0)) assertThat(textOverlayTransformation.typography()).contains("typography") @@ -64,7 +64,7 @@ internal class TextOverlayTransformationTest { .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt index b27f75bd..1b468cd5 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt @@ -75,7 +75,7 @@ internal class TransformationTest { .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) @@ -170,7 +170,7 @@ internal class TransformationTest { .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) @@ -267,7 +267,7 @@ internal class TransformationTest { .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt index 50cb287d..840d8b42 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt @@ -99,7 +99,7 @@ internal class VideoOverlayTest { ) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) @@ -212,7 +212,7 @@ internal class VideoOverlayTest { .innerAlignment(TextOverlayTransformation.InnerAlignment.LEFT) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) @@ -333,7 +333,7 @@ internal class VideoOverlayTest { ) .lineHeight(0.0) .padding(0.0) - .radius(0.0) + .radiusMax() .rotation(0.0) .typography("typography") .width(0.0) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt index cc8f4deb..038c8128 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt @@ -56,7 +56,7 @@ internal class AssetListResponseTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -129,7 +129,7 @@ internal class AssetListResponseTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt index b01ab273..141cd730 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt @@ -153,7 +153,7 @@ internal class FileUploadResponseTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -316,7 +316,7 @@ internal class FileUploadResponseTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -482,7 +482,7 @@ internal class FileUploadResponseTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt index 018fb8c6..009962ae 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt @@ -15,7 +15,19 @@ internal class CustomMetadataFieldCreateParamsTest { .schema( CustomMetadataFieldCreateParams.Schema.builder() .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) - .defaultValue("string") + .defaultValueOfMixed( + listOf( + CustomMetadataFieldCreateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent8 + .ofBool(true), + CustomMetadataFieldCreateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent8 + .ofNumber(10.0), + CustomMetadataFieldCreateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent8 + .ofString("Hello"), + ) + ) .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) @@ -45,7 +57,19 @@ internal class CustomMetadataFieldCreateParamsTest { .schema( CustomMetadataFieldCreateParams.Schema.builder() .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) - .defaultValue("string") + .defaultValueOfMixed( + listOf( + CustomMetadataFieldCreateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent8 + .ofBool(true), + CustomMetadataFieldCreateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent8 + .ofNumber(10.0), + CustomMetadataFieldCreateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent8 + .ofString("Hello"), + ) + ) .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) @@ -79,7 +103,19 @@ internal class CustomMetadataFieldCreateParamsTest { .isEqualTo( CustomMetadataFieldCreateParams.Schema.builder() .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) - .defaultValue("string") + .defaultValueOfMixed( + listOf( + CustomMetadataFieldCreateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent8 + .ofBool(true), + CustomMetadataFieldCreateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent8 + .ofNumber(10.0), + CustomMetadataFieldCreateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent8 + .ofString("Hello"), + ) + ) .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt index 14455b92..670f7f8c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt @@ -19,7 +19,19 @@ internal class CustomMetadataFieldTest { .schema( CustomMetadataField.Schema.builder() .type(CustomMetadataField.Schema.Type.TEXT) - .defaultValue("string") + .defaultValueOfMixed( + listOf( + CustomMetadataField.Schema.DefaultValue + .UnnamedSchemaWithArrayParent3 + .ofBool(true), + CustomMetadataField.Schema.DefaultValue + .UnnamedSchemaWithArrayParent3 + .ofNumber(10.0), + CustomMetadataField.Schema.DefaultValue + .UnnamedSchemaWithArrayParent3 + .ofString("Hello"), + ) + ) .isValueRequired(true) .maxLength(0.0) .maxValue("string") @@ -46,7 +58,16 @@ internal class CustomMetadataFieldTest { .isEqualTo( CustomMetadataField.Schema.builder() .type(CustomMetadataField.Schema.Type.TEXT) - .defaultValue("string") + .defaultValueOfMixed( + listOf( + CustomMetadataField.Schema.DefaultValue.UnnamedSchemaWithArrayParent3 + .ofBool(true), + CustomMetadataField.Schema.DefaultValue.UnnamedSchemaWithArrayParent3 + .ofNumber(10.0), + CustomMetadataField.Schema.DefaultValue.UnnamedSchemaWithArrayParent3 + .ofString("Hello"), + ) + ) .isValueRequired(true) .maxLength(0.0) .maxValue("string") @@ -77,7 +98,19 @@ internal class CustomMetadataFieldTest { .schema( CustomMetadataField.Schema.builder() .type(CustomMetadataField.Schema.Type.TEXT) - .defaultValue("string") + .defaultValueOfMixed( + listOf( + CustomMetadataField.Schema.DefaultValue + .UnnamedSchemaWithArrayParent3 + .ofBool(true), + CustomMetadataField.Schema.DefaultValue + .UnnamedSchemaWithArrayParent3 + .ofNumber(10.0), + CustomMetadataField.Schema.DefaultValue + .UnnamedSchemaWithArrayParent3 + .ofString("Hello"), + ) + ) .isValueRequired(true) .maxLength(0.0) .maxValue("string") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt index 5611af8d..c950a4ae 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt @@ -14,7 +14,19 @@ internal class CustomMetadataFieldUpdateParamsTest { .label("price") .schema( CustomMetadataFieldUpdateParams.Schema.builder() - .defaultValue("string") + .defaultValueOfMixed( + listOf( + CustomMetadataFieldUpdateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent9 + .ofBool(true), + CustomMetadataFieldUpdateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent9 + .ofNumber(10.0), + CustomMetadataFieldUpdateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent9 + .ofString("Hello"), + ) + ) .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) @@ -52,7 +64,19 @@ internal class CustomMetadataFieldUpdateParamsTest { .label("price") .schema( CustomMetadataFieldUpdateParams.Schema.builder() - .defaultValue("string") + .defaultValueOfMixed( + listOf( + CustomMetadataFieldUpdateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent9 + .ofBool(true), + CustomMetadataFieldUpdateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent9 + .ofNumber(10.0), + CustomMetadataFieldUpdateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent9 + .ofString("Hello"), + ) + ) .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) @@ -84,7 +108,19 @@ internal class CustomMetadataFieldUpdateParamsTest { assertThat(body.schema()) .contains( CustomMetadataFieldUpdateParams.Schema.builder() - .defaultValue("string") + .defaultValueOfMixed( + listOf( + CustomMetadataFieldUpdateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent9 + .ofBool(true), + CustomMetadataFieldUpdateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent9 + .ofNumber(10.0), + CustomMetadataFieldUpdateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent9 + .ofString("Hello"), + ) + ) .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt index 01ec117a..f5cfff0e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt @@ -51,7 +51,7 @@ internal class FileTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -116,7 +116,7 @@ internal class FileTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -182,7 +182,7 @@ internal class FileTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt index c098e695..29185f54 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt @@ -51,7 +51,7 @@ internal class FileUpdateResponseTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -130,7 +130,7 @@ internal class FileUpdateResponseTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -207,7 +207,7 @@ internal class FileUpdateResponseTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt index 5a7ea647..abeaf46d 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt @@ -152,7 +152,7 @@ internal class FileUploadResponseTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -315,7 +315,7 @@ internal class FileUploadResponseTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -481,7 +481,7 @@ internal class FileUploadResponseTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt index be849e19..db1fe903 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt @@ -158,7 +158,7 @@ internal class UpdateFileRequestTest { ), ) ) - .removeAiTagsOfStrings(listOf("string")) + .removeAiTagsAll() .addTag("tag1") .addTag("tag2") .webhookUrl("https://example.com") @@ -332,7 +332,7 @@ internal class UpdateFileRequestTest { ), ) ) - .removeAiTagsOfStrings(listOf("string")) + .removeAiTagsAll() .addTag("tag1") .addTag("tag2") .webhookUrl("https://example.com") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileCreateEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileCreateEventTest.kt index 339516ba..b64071b7 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileCreateEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileCreateEventTest.kt @@ -60,7 +60,7 @@ internal class FileCreateEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -130,7 +130,7 @@ internal class FileCreateEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -207,7 +207,7 @@ internal class FileCreateEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileUpdateEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileUpdateEventTest.kt index 7d783230..44862f99 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileUpdateEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileUpdateEventTest.kt @@ -60,7 +60,7 @@ internal class FileUpdateEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -130,7 +130,7 @@ internal class FileUpdateEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -207,7 +207,7 @@ internal class FileUpdateEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionCreateEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionCreateEventTest.kt index 87b8ef6e..29ff3fbb 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionCreateEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionCreateEventTest.kt @@ -60,7 +60,7 @@ internal class FileVersionCreateEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -130,7 +130,7 @@ internal class FileVersionCreateEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -207,7 +207,7 @@ internal class FileVersionCreateEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt index 5dc6f19f..754e106d 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt @@ -725,7 +725,7 @@ internal class UnsafeUnwrapWebhookEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -949,7 +949,7 @@ internal class UnsafeUnwrapWebhookEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -1362,7 +1362,7 @@ internal class UnsafeUnwrapWebhookEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -1456,7 +1456,7 @@ internal class UnsafeUnwrapWebhookEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -1549,7 +1549,7 @@ internal class UnsafeUnwrapWebhookEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -1643,7 +1643,7 @@ internal class UnsafeUnwrapWebhookEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -1784,7 +1784,7 @@ internal class UnsafeUnwrapWebhookEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -1879,7 +1879,7 @@ internal class UnsafeUnwrapWebhookEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt index 7c783365..2891f29f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt @@ -723,7 +723,7 @@ internal class UnwrapWebhookEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -947,7 +947,7 @@ internal class UnwrapWebhookEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -1358,7 +1358,7 @@ internal class UnwrapWebhookEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -1452,7 +1452,7 @@ internal class UnwrapWebhookEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -1545,7 +1545,7 @@ internal class UnwrapWebhookEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -1639,7 +1639,7 @@ internal class UnwrapWebhookEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -1780,7 +1780,7 @@ internal class UnwrapWebhookEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -1874,7 +1874,7 @@ internal class UnwrapWebhookEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt index 1230eaf9..c30f3f49 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt @@ -174,7 +174,7 @@ internal class UploadPreTransformSuccessEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -366,7 +366,7 @@ internal class UploadPreTransformSuccessEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", @@ -567,7 +567,7 @@ internal class UploadPreTransformSuccessEventTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt index 05126f0d..e7ab6ff2 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt @@ -29,7 +29,19 @@ internal class CustomMetadataFieldServiceAsyncTest { .schema( CustomMetadataFieldCreateParams.Schema.builder() .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) - .defaultValue("string") + .defaultValueOfMixed( + listOf( + CustomMetadataFieldCreateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent8 + .ofBool(true), + CustomMetadataFieldCreateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent8 + .ofNumber(10.0), + CustomMetadataFieldCreateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent8 + .ofString("Hello"), + ) + ) .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) @@ -81,7 +93,19 @@ internal class CustomMetadataFieldServiceAsyncTest { .label("price") .schema( CustomMetadataFieldUpdateParams.Schema.builder() - .defaultValue("string") + .defaultValueOfMixed( + listOf( + CustomMetadataFieldUpdateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent9 + .ofBool(true), + CustomMetadataFieldUpdateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent9 + .ofNumber(10.0), + CustomMetadataFieldUpdateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent9 + .ofString("Hello"), + ) + ) .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt index a88b8c8b..1b11abc7 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt @@ -29,7 +29,19 @@ internal class CustomMetadataFieldServiceTest { .schema( CustomMetadataFieldCreateParams.Schema.builder() .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) - .defaultValue("string") + .defaultValueOfMixed( + listOf( + CustomMetadataFieldCreateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent8 + .ofBool(true), + CustomMetadataFieldCreateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent8 + .ofNumber(10.0), + CustomMetadataFieldCreateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent8 + .ofString("Hello"), + ) + ) .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) @@ -80,7 +92,19 @@ internal class CustomMetadataFieldServiceTest { .label("price") .schema( CustomMetadataFieldUpdateParams.Schema.builder() - .defaultValue("string") + .defaultValueOfMixed( + listOf( + CustomMetadataFieldUpdateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent9 + .ofBool(true), + CustomMetadataFieldUpdateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent9 + .ofNumber(10.0), + CustomMetadataFieldUpdateParams.Schema.DefaultValue + .UnnamedSchemaWithArrayParent9 + .ofString("Hello"), + ) + ) .isValueRequired(true) .maxLength(0.0) .maxValue(3000.0) diff --git a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt index a1ecd8d3..4a743bae 100644 --- a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt +++ b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt @@ -107,7 +107,7 @@ internal class ProGuardCompatibilityTest { JsonValue.from( mapOf( "type" to "Text", - "defaultValue" to "string", + "defaultValue" to listOf(true, 10, "Hello"), "isValueRequired" to true, "maxLength" to 0, "maxValue" to "string", From f5fdf8fd7cc5a0f70fef28fd8b1fc23ebda05c8c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 Apr 2026 00:58:17 +0000 Subject: [PATCH 130/142] fix(api): extract shared schemas to prevent Go webhook union breaking changes --- .stats.yml | 6 +-- .../beta/v2/files/FileUploadResponse.kt | 15 +++---- .../com/imagekit/api/models/files/File.kt | 42 ++++++++++++++----- .../api/models/files/FileUpdateResponse.kt | 30 +++++++++---- .../api/models/files/FileUploadResponse.kt | 15 +++---- .../UploadPreTransformSuccessEvent.kt | 18 ++++---- 6 files changed, 82 insertions(+), 44 deletions(-) diff --git a/.stats.yml b/.stats.yml index aae6cba6..92aebe1f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-d73a37dc3426586109bd153f02c6a605036b6a7396bba5173d013468c5291ce6.yml -openapi_spec_hash: c193c6e557ff477481ec8d5ac8a0c96e -config_hash: 32b155378f65c234d3abeb18519fb3cd +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-7c4c23556be689ded6bcafd05e1645b82239521c9c841c0f7e76336e2eefcffa.yml +openapi_spec_hash: eca5b039a0066c6536296248c3a80854 +config_hash: e3c2679d25f6235381dfb11962fbf3d9 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt index 311e5191..9bda2aec 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt @@ -133,7 +133,8 @@ private constructor( ) /** - * An array of tags assigned to the uploaded file by auto tagging. + * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. These + * tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -635,7 +636,10 @@ private constructor( additionalProperties = fileUploadResponse.additionalProperties.toMutableMap() } - /** An array of tags assigned to the uploaded file by auto tagging. */ + /** + * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. + * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + */ fun aiTags(aiTags: List?) = aiTags(JsonField.ofNullable(aiTags)) /** Alias for calling [Builder.aiTags] with `aiTags.orElse(null)`. */ @@ -1199,8 +1203,7 @@ private constructor( fun name(): Optional = name.getOptional("name") /** - * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. - * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -1289,9 +1292,7 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** - * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. - * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` - * extensions. + * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. */ fun source(source: String) = source(JsonField.of(source)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt index bbd0b1ac..c8b3d53b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt @@ -142,7 +142,8 @@ private constructor( ) /** - * An array of tags assigned to the file by auto tagging. + * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. These + * tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -182,7 +183,10 @@ private constructor( fun customCoordinates(): Optional = customCoordinates.getOptional("customCoordinates") /** - * An object with custom metadata for the file. + * A key-value data associated with the asset. Use `responseField` in API request to get + * `customMetadata` in the upload API response. Before setting any custom metadata on an asset, + * you have to create the field using custom metadata fields API. Send `customMetadata` in + * `responseFields` in API request to get the value of this field. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -208,7 +212,8 @@ private constructor( /** * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp - * data. + * data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata in + * the upload API response. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -355,7 +360,7 @@ private constructor( fun url(): Optional = url.getOptional("url") /** - * An object with details of the file version. + * An object containing the file or file version's `id` (versionId) and `name`. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -679,7 +684,10 @@ private constructor( additionalProperties = file.additionalProperties.toMutableMap() } - /** An array of tags assigned to the file by auto tagging. */ + /** + * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. + * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + */ fun aiTags(aiTags: List?) = aiTags(JsonField.ofNullable(aiTags)) /** Alias for calling [Builder.aiTags] with `aiTags.orElse(null)`. */ @@ -762,7 +770,12 @@ private constructor( this.customCoordinates = customCoordinates } - /** An object with custom metadata for the file. */ + /** + * A key-value data associated with the asset. Use `responseField` in API request to get + * `customMetadata` in the upload API response. Before setting any custom metadata on an + * asset, you have to create the field using custom metadata fields API. Send + * `customMetadata` in `responseFields` in API request to get the value of this field. + */ fun customMetadata(customMetadata: CustomMetadata) = customMetadata(JsonField.of(customMetadata)) @@ -805,7 +818,8 @@ private constructor( /** * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp - * data. + * data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata + * in the upload API response. */ fun embeddedMetadata(embeddedMetadata: EmbeddedMetadata) = embeddedMetadata(JsonField.of(embeddedMetadata)) @@ -1041,7 +1055,7 @@ private constructor( */ fun url(url: JsonField) = apply { this.url = url } - /** An object with details of the file version. */ + /** An object containing the file or file version's `id` (versionId) and `name`. */ fun versionInfo(versionInfo: VersionInfo) = versionInfo(JsonField.of(versionInfo)) /** @@ -1438,7 +1452,12 @@ private constructor( "AiTag{confidence=$confidence, name=$name, source=$source, additionalProperties=$additionalProperties}" } - /** An object with custom metadata for the file. */ + /** + * A key-value data associated with the asset. Use `responseField` in API request to get + * `customMetadata` in the upload API response. Before setting any custom metadata on an asset, + * you have to create the field using custom metadata fields API. Send `customMetadata` in + * `responseFields` in API request to get the value of this field. + */ class CustomMetadata @JsonCreator private constructor( @@ -1540,7 +1559,8 @@ private constructor( /** * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp - * data. + * data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata in + * the upload API response. */ class EmbeddedMetadata @JsonCreator @@ -1879,7 +1899,7 @@ private constructor( override fun toString() = value.toString() } - /** An object with details of the file version. */ + /** An object containing the file or file version's `id` (versionId) and `name`. */ class VersionInfo @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt index 5758fe5e..2d1fda48 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt @@ -181,7 +181,8 @@ private constructor( .build() /** - * An array of tags assigned to the file by auto tagging. + * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. These + * tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -221,7 +222,10 @@ private constructor( fun customCoordinates(): Optional = customCoordinates.getOptional("customCoordinates") /** - * An object with custom metadata for the file. + * A key-value data associated with the asset. Use `responseField` in API request to get + * `customMetadata` in the upload API response. Before setting any custom metadata on an asset, + * you have to create the field using custom metadata fields API. Send `customMetadata` in + * `responseFields` in API request to get the value of this field. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -248,7 +252,8 @@ private constructor( /** * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp - * data. + * data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata in + * the upload API response. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -395,7 +400,7 @@ private constructor( fun url(): Optional = url.getOptional("url") /** - * An object with details of the file version. + * An object containing the file or file version's `id` (versionId) and `name`. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -737,7 +742,10 @@ private constructor( additionalProperties = fileUpdateResponse.additionalProperties.toMutableMap() } - /** An array of tags assigned to the file by auto tagging. */ + /** + * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. + * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + */ fun aiTags(aiTags: List?) = aiTags(JsonField.ofNullable(aiTags)) /** Alias for calling [Builder.aiTags] with `aiTags.orElse(null)`. */ @@ -820,7 +828,12 @@ private constructor( this.customCoordinates = customCoordinates } - /** An object with custom metadata for the file. */ + /** + * A key-value data associated with the asset. Use `responseField` in API request to get + * `customMetadata` in the upload API response. Before setting any custom metadata on an + * asset, you have to create the field using custom metadata fields API. Send + * `customMetadata` in `responseFields` in API request to get the value of this field. + */ fun customMetadata(customMetadata: File.CustomMetadata) = customMetadata(JsonField.of(customMetadata)) @@ -863,7 +876,8 @@ private constructor( /** * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp - * data. + * data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata + * in the upload API response. */ fun embeddedMetadata(embeddedMetadata: File.EmbeddedMetadata) = embeddedMetadata(JsonField.of(embeddedMetadata)) @@ -1100,7 +1114,7 @@ private constructor( */ fun url(url: JsonField) = apply { this.url = url } - /** An object with details of the file version. */ + /** An object containing the file or file version's `id` (versionId) and `name`. */ fun versionInfo(versionInfo: File.VersionInfo) = versionInfo(JsonField.of(versionInfo)) /** diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt index 436475a2..da953ea8 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt @@ -132,7 +132,8 @@ private constructor( ) /** - * An array of tags assigned to the uploaded file by auto tagging. + * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. These + * tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -634,7 +635,10 @@ private constructor( additionalProperties = fileUploadResponse.additionalProperties.toMutableMap() } - /** An array of tags assigned to the uploaded file by auto tagging. */ + /** + * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. + * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + */ fun aiTags(aiTags: List?) = aiTags(JsonField.ofNullable(aiTags)) /** Alias for calling [Builder.aiTags] with `aiTags.orElse(null)`. */ @@ -1198,8 +1202,7 @@ private constructor( fun name(): Optional = name.getOptional("name") /** - * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. - * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -1288,9 +1291,7 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** - * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. - * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` - * extensions. + * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. */ fun source(source: String) = source(JsonField.of(source)) diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt index 2a0dc788..a2783103 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt @@ -435,7 +435,8 @@ private constructor( ) /** - * An array of tags assigned to the uploaded file by auto tagging. + * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. + * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -951,7 +952,11 @@ private constructor( additionalProperties = data.additionalProperties.toMutableMap() } - /** An array of tags assigned to the uploaded file by auto tagging. */ + /** + * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. + * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` + * extensions. + */ fun aiTags(aiTags: List?) = aiTags(JsonField.ofNullable(aiTags)) /** Alias for calling [Builder.aiTags] with `aiTags.orElse(null)`. */ @@ -1535,9 +1540,7 @@ private constructor( fun name(): Optional = name.getOptional("name") /** - * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. - * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` - * extensions. + * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -1629,9 +1632,8 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** - * Array of `AITags` associated with the image. If no `AITags` are set, it will be - * null. These tags can be added using the `google-auto-tagging` or - * `aws-auto-tagging` extensions. + * Source of the tag. Possible values are `google-auto-tagging` and + * `aws-auto-tagging`. */ fun source(source: String) = source(JsonField.of(source)) From dc76ed551fea469c210e7cfc236c5ae9cd27e282 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 Apr 2026 00:59:53 +0000 Subject: [PATCH 131/142] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 92aebe1f..c4bde9f0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-7c4c23556be689ded6bcafd05e1645b82239521c9c841c0f7e76336e2eefcffa.yml openapi_spec_hash: eca5b039a0066c6536296248c3a80854 -config_hash: e3c2679d25f6235381dfb11962fbf3d9 +config_hash: f914ebc9670f6e7c7751660caa4e5556 From e71dfe138309b105b1eb38d5622e21f147446571 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 Apr 2026 01:32:55 +0000 Subject: [PATCH 132/142] refactor: AITags to singular AITag schema with array items pattern --- .stats.yml | 6 +-- .../beta/v2/files/FileUploadResponse.kt | 22 ++++------ .../com/imagekit/api/models/files/File.kt | 43 +++++++------------ .../api/models/files/FileUpdateResponse.kt | 29 ++++--------- .../api/models/files/FileUploadResponse.kt | 22 ++++------ .../UploadPreTransformSuccessEvent.kt | 23 ++++------ 6 files changed, 51 insertions(+), 94 deletions(-) diff --git a/.stats.yml b/.stats.yml index c4bde9f0..3d19128a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-7c4c23556be689ded6bcafd05e1645b82239521c9c841c0f7e76336e2eefcffa.yml -openapi_spec_hash: eca5b039a0066c6536296248c3a80854 -config_hash: f914ebc9670f6e7c7751660caa4e5556 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-70c42eda2bee929830b2537f758400a58dded1f1ef5686a286e2469c35a041a0.yml +openapi_spec_hash: cdaeed824e91657b45092765cf55eb42 +config_hash: e3c2679d25f6235381dfb11962fbf3d9 diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt index 9bda2aec..e66283d8 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt @@ -133,8 +133,7 @@ private constructor( ) /** - * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. These - * tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + * An array of tags assigned to the uploaded file by auto tagging. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -636,10 +635,7 @@ private constructor( additionalProperties = fileUploadResponse.additionalProperties.toMutableMap() } - /** - * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. - * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. - */ + /** An array of tags assigned to the uploaded file by auto tagging. */ fun aiTags(aiTags: List?) = aiTags(JsonField.ofNullable(aiTags)) /** Alias for calling [Builder.aiTags] with `aiTags.orElse(null)`. */ @@ -1168,6 +1164,10 @@ private constructor( (if (videoCodec.asKnown().isPresent) 1 else 0) + (if (width.asKnown().isPresent) 1 else 0) + /** + * AI-generated tag associated with an image. These tags can be added using the + * `google-auto-tagging` or `aws-auto-tagging` extensions. + */ class AiTag @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -1388,12 +1388,7 @@ private constructor( "AiTag{confidence=$confidence, name=$name, source=$source, additionalProperties=$additionalProperties}" } - /** - * A key-value data associated with the asset. Use `responseField` in API request to get - * `customMetadata` in the upload API response. Before setting any custom metadata on an asset, - * you have to create the field using custom metadata fields API. Send `customMetadata` in - * `responseFields` in API request to get the value of this field. - */ + /** A key-value data associated with the asset. */ class CustomMetadata @JsonCreator private constructor( @@ -1495,8 +1490,7 @@ private constructor( /** * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp - * data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata in - * the upload API response. + * data. */ class EmbeddedMetadata @JsonCreator diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt index c8b3d53b..878b2277 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt @@ -142,8 +142,7 @@ private constructor( ) /** - * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. These - * tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + * Array of AI-generated tags associated with the image. If no AITags are set, it will be null. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -183,10 +182,7 @@ private constructor( fun customCoordinates(): Optional = customCoordinates.getOptional("customCoordinates") /** - * A key-value data associated with the asset. Use `responseField` in API request to get - * `customMetadata` in the upload API response. Before setting any custom metadata on an asset, - * you have to create the field using custom metadata fields API. Send `customMetadata` in - * `responseFields` in API request to get the value of this field. + * An object with custom metadata for the file. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -212,8 +208,7 @@ private constructor( /** * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp - * data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata in - * the upload API response. + * data. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -360,7 +355,7 @@ private constructor( fun url(): Optional = url.getOptional("url") /** - * An object containing the file or file version's `id` (versionId) and `name`. + * An object with details of the file version. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -685,8 +680,8 @@ private constructor( } /** - * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. - * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + * Array of AI-generated tags associated with the image. If no AITags are set, it will be + * null. */ fun aiTags(aiTags: List?) = aiTags(JsonField.ofNullable(aiTags)) @@ -770,12 +765,7 @@ private constructor( this.customCoordinates = customCoordinates } - /** - * A key-value data associated with the asset. Use `responseField` in API request to get - * `customMetadata` in the upload API response. Before setting any custom metadata on an - * asset, you have to create the field using custom metadata fields API. Send - * `customMetadata` in `responseFields` in API request to get the value of this field. - */ + /** An object with custom metadata for the file. */ fun customMetadata(customMetadata: CustomMetadata) = customMetadata(JsonField.of(customMetadata)) @@ -818,8 +808,7 @@ private constructor( /** * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp - * data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata - * in the upload API response. + * data. */ fun embeddedMetadata(embeddedMetadata: EmbeddedMetadata) = embeddedMetadata(JsonField.of(embeddedMetadata)) @@ -1055,7 +1044,7 @@ private constructor( */ fun url(url: JsonField) = apply { this.url = url } - /** An object containing the file or file version's `id` (versionId) and `name`. */ + /** An object with details of the file version. */ fun versionInfo(versionInfo: VersionInfo) = versionInfo(JsonField.of(versionInfo)) /** @@ -1232,6 +1221,10 @@ private constructor( (if (videoCodec.asKnown().isPresent) 1 else 0) + (if (width.asKnown().isPresent) 1 else 0) + /** + * AI-generated tag associated with an image. These tags can be added using the + * `google-auto-tagging` or `aws-auto-tagging` extensions. + */ class AiTag @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -1452,12 +1445,7 @@ private constructor( "AiTag{confidence=$confidence, name=$name, source=$source, additionalProperties=$additionalProperties}" } - /** - * A key-value data associated with the asset. Use `responseField` in API request to get - * `customMetadata` in the upload API response. Before setting any custom metadata on an asset, - * you have to create the field using custom metadata fields API. Send `customMetadata` in - * `responseFields` in API request to get the value of this field. - */ + /** A key-value data associated with the asset. */ class CustomMetadata @JsonCreator private constructor( @@ -1559,8 +1547,7 @@ private constructor( /** * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp - * data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata in - * the upload API response. + * data. */ class EmbeddedMetadata @JsonCreator diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt index 2d1fda48..d1c08278 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt @@ -181,8 +181,7 @@ private constructor( .build() /** - * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. These - * tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + * Array of AI-generated tags associated with the image. If no AITags are set, it will be null. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -222,10 +221,7 @@ private constructor( fun customCoordinates(): Optional = customCoordinates.getOptional("customCoordinates") /** - * A key-value data associated with the asset. Use `responseField` in API request to get - * `customMetadata` in the upload API response. Before setting any custom metadata on an asset, - * you have to create the field using custom metadata fields API. Send `customMetadata` in - * `responseFields` in API request to get the value of this field. + * An object with custom metadata for the file. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -252,8 +248,7 @@ private constructor( /** * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp - * data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata in - * the upload API response. + * data. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -400,7 +395,7 @@ private constructor( fun url(): Optional = url.getOptional("url") /** - * An object containing the file or file version's `id` (versionId) and `name`. + * An object with details of the file version. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -743,8 +738,8 @@ private constructor( } /** - * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. - * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + * Array of AI-generated tags associated with the image. If no AITags are set, it will be + * null. */ fun aiTags(aiTags: List?) = aiTags(JsonField.ofNullable(aiTags)) @@ -828,12 +823,7 @@ private constructor( this.customCoordinates = customCoordinates } - /** - * A key-value data associated with the asset. Use `responseField` in API request to get - * `customMetadata` in the upload API response. Before setting any custom metadata on an - * asset, you have to create the field using custom metadata fields API. Send - * `customMetadata` in `responseFields` in API request to get the value of this field. - */ + /** An object with custom metadata for the file. */ fun customMetadata(customMetadata: File.CustomMetadata) = customMetadata(JsonField.of(customMetadata)) @@ -876,8 +866,7 @@ private constructor( /** * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp - * data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata - * in the upload API response. + * data. */ fun embeddedMetadata(embeddedMetadata: File.EmbeddedMetadata) = embeddedMetadata(JsonField.of(embeddedMetadata)) @@ -1114,7 +1103,7 @@ private constructor( */ fun url(url: JsonField) = apply { this.url = url } - /** An object containing the file or file version's `id` (versionId) and `name`. */ + /** An object with details of the file version. */ fun versionInfo(versionInfo: File.VersionInfo) = versionInfo(JsonField.of(versionInfo)) /** diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt index da953ea8..d503343e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt @@ -132,8 +132,7 @@ private constructor( ) /** - * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. These - * tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + * An array of tags assigned to the uploaded file by auto tagging. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -635,10 +634,7 @@ private constructor( additionalProperties = fileUploadResponse.additionalProperties.toMutableMap() } - /** - * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. - * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. - */ + /** An array of tags assigned to the uploaded file by auto tagging. */ fun aiTags(aiTags: List?) = aiTags(JsonField.ofNullable(aiTags)) /** Alias for calling [Builder.aiTags] with `aiTags.orElse(null)`. */ @@ -1167,6 +1163,10 @@ private constructor( (if (videoCodec.asKnown().isPresent) 1 else 0) + (if (width.asKnown().isPresent) 1 else 0) + /** + * AI-generated tag associated with an image. These tags can be added using the + * `google-auto-tagging` or `aws-auto-tagging` extensions. + */ class AiTag @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -1387,12 +1387,7 @@ private constructor( "AiTag{confidence=$confidence, name=$name, source=$source, additionalProperties=$additionalProperties}" } - /** - * A key-value data associated with the asset. Use `responseField` in API request to get - * `customMetadata` in the upload API response. Before setting any custom metadata on an asset, - * you have to create the field using custom metadata fields API. Send `customMetadata` in - * `responseFields` in API request to get the value of this field. - */ + /** A key-value data associated with the asset. */ class CustomMetadata @JsonCreator private constructor( @@ -1494,8 +1489,7 @@ private constructor( /** * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp - * data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata in - * the upload API response. + * data. */ class EmbeddedMetadata @JsonCreator diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt index a2783103..30e5b4d4 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt @@ -435,8 +435,7 @@ private constructor( ) /** - * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. - * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` extensions. + * An array of tags assigned to the uploaded file by auto tagging. * * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -952,11 +951,7 @@ private constructor( additionalProperties = data.additionalProperties.toMutableMap() } - /** - * Array of `AITags` associated with the image. If no `AITags` are set, it will be null. - * These tags can be added using the `google-auto-tagging` or `aws-auto-tagging` - * extensions. - */ + /** An array of tags assigned to the uploaded file by auto tagging. */ fun aiTags(aiTags: List?) = aiTags(JsonField.ofNullable(aiTags)) /** Alias for calling [Builder.aiTags] with `aiTags.orElse(null)`. */ @@ -1505,6 +1500,10 @@ private constructor( (if (videoCodec.asKnown().isPresent) 1 else 0) + (if (width.asKnown().isPresent) 1 else 0) + /** + * AI-generated tag associated with an image. These tags can be added using the + * `google-auto-tagging` or `aws-auto-tagging` extensions. + */ class AiTag @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -1732,12 +1731,7 @@ private constructor( "AiTag{confidence=$confidence, name=$name, source=$source, additionalProperties=$additionalProperties}" } - /** - * A key-value data associated with the asset. Use `responseField` in API request to get - * `customMetadata` in the upload API response. Before setting any custom metadata on an - * asset, you have to create the field using custom metadata fields API. Send - * `customMetadata` in `responseFields` in API request to get the value of this field. - */ + /** A key-value data associated with the asset. */ class CustomMetadata @JsonCreator private constructor( @@ -1842,8 +1836,7 @@ private constructor( /** * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp - * data. Send `embeddedMetadata` in `responseFields` in API request to get embeddedMetadata - * in the upload API response. + * data. */ class EmbeddedMetadata @JsonCreator From e98e22e176622beb3a4f92c40d10977925faeefa Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 13 Apr 2026 02:08:37 +0000 Subject: [PATCH 133/142] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 3d19128a..1ee5069c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-70c42eda2bee929830b2537f758400a58dded1f1ef5686a286e2469c35a041a0.yml openapi_spec_hash: cdaeed824e91657b45092765cf55eb42 -config_hash: e3c2679d25f6235381dfb11962fbf3d9 +config_hash: 83967503e501e4199b4042d0d0f2b615 From 4c0fdb3884cf537b504527a651790546eb645210 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 18 Apr 2026 06:45:35 +0000 Subject: [PATCH 134/142] chore: configure new SDK language --- .stats.yml | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 1ee5069c..3aa7595d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-70c42eda2bee929830b2537f758400a58dded1f1ef5686a286e2469c35a041a0.yml openapi_spec_hash: cdaeed824e91657b45092765cf55eb42 -config_hash: 83967503e501e4199b4042d0d0f2b615 +config_hash: 2a6f67c966b8b3db6f986be4ac23a507 diff --git a/README.md b/README.md index a7b10f6c..b2967b53 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ The Image Kit Java SDK provides convenient access to the [Image Kit REST API](ht Use the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application. -[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19) -[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D) +[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fnodejs-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9ub2RlanMtbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19) +[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fnodejs-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fnodejs-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D) > Note: You may need to set environment variables in your MCP client. From f8cb896fbe5291188e819abe9cf85871e96e7fe9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 04:52:03 +0000 Subject: [PATCH 135/142] Java dev --- .gitignore | 4 + .stats.yml | 6 +- README.md | 415 +- .../src/main/kotlin/image-kit.java.gradle.kts | 2 +- .../main/kotlin/image-kit.kotlin.gradle.kts | 2 +- .../com/imagekit/api/client/ImageKitClient.kt | 3 + .../api/client/ImageKitClientAsync.kt | 3 + .../api/client/ImageKitClientAsyncImpl.kt | 6 + .../imagekit/api/client/ImageKitClientImpl.kt | 6 + .../kotlin/com/imagekit/api/lib/Helper.kt | 970 +++ .../com/imagekit/api/lib/HelperService.kt | 26 + .../kotlin/com/imagekit/api/models/AiTag.kt | 232 + .../com/imagekit/api/models/CustomMetadata.kt | 110 + .../imagekit/api/models/EmbeddedMetadata.kt | 112 + .../imagekit/api/models/ExtensionConfig.kt | 294 +- .../com/imagekit/api/models/ExtensionItem.kt | 6785 +++++++++++++++ .../api/models/SelectedFieldsSchema.kt | 117 + .../com/imagekit/api/models/VersionInfo.kt | 190 + .../models/beta/v2/files/FileUploadParams.kt | 6215 +------------- .../beta/v2/files/FileUploadResponse.kt | 719 +- .../CustomMetadataField.kt | 94 +- .../CustomMetadataFieldCreateParams.kt | 94 +- .../CustomMetadataFieldUpdateParams.kt | 94 +- .../com/imagekit/api/models/files/File.kt | 719 +- .../api/models/files/FileUpdateResponse.kt | 113 +- .../api/models/files/FileUploadParams.kt | 6215 +------------- .../api/models/files/FileUploadResponse.kt | 719 +- .../com/imagekit/api/models/files/Metadata.kt | 90 +- .../api/models/files/UpdateFileRequest.kt | 7347 +---------------- .../UploadPreTransformSuccessEvent.kt | 743 +- .../services/blocking/WebhookServiceImpl.kt | 4 +- .../com/imagekit/api/models/AiTagTest.kt | 31 + .../imagekit/api/models/CustomMetadataTest.kt | 33 + .../api/models/EmbeddedMetadataTest.kt | 33 + .../imagekit/api/models/ExtensionItemTest.kt | 227 + .../api/models/SelectedFieldsSchemaTest.kt | 69 + .../imagekit/api/models/VersionInfoTest.kt | 33 + .../models/assets/AssetListResponseTest.kt | 29 +- .../beta/v2/files/FileUploadParamsTest.kt | 224 +- .../beta/v2/files/FileUploadResponseTest.kt | 61 +- .../CustomMetadataFieldCreateParamsTest.kt | 27 +- .../CustomMetadataFieldTest.kt | 47 +- .../CustomMetadataFieldUpdateParamsTest.kt | 27 +- .../com/imagekit/api/models/files/FileTest.kt | 44 +- .../api/models/files/FileUpdateParamsTest.kt | 107 +- .../models/files/FileUpdateResponseTest.kt | 43 +- .../api/models/files/FileUploadParamsTest.kt | 224 +- .../models/files/FileUploadResponseTest.kt | 61 +- .../imagekit/api/models/files/MetadataTest.kt | 6 +- .../api/models/files/UpdateFileRequestTest.kt | 127 +- .../models/webhooks/FileCreateEventTest.kt | 45 +- .../models/webhooks/FileUpdateEventTest.kt | 45 +- .../webhooks/FileVersionCreateEventTest.kt | 45 +- .../webhooks/UnsafeUnwrapWebhookEventTest.kt | 115 +- .../models/webhooks/UnwrapWebhookEventTest.kt | 115 +- .../UploadPreTransformSuccessEventTest.kt | 70 +- .../api/services/ErrorHandlingTest.kt | 1328 ++- .../api/services/ServiceParamsTest.kt | 71 +- .../CustomMetadataFieldServiceAsyncTest.kt | 12 +- .../services/async/FileServiceAsyncTest.kt | 111 +- .../async/beta/v2/FileServiceAsyncTest.kt | 76 +- .../CustomMetadataFieldServiceTest.kt | 12 +- .../api/services/blocking/FileServiceTest.kt | 111 +- .../blocking/beta/v2/FileServiceTest.kt | 76 +- .../java/com/imagekit/api/example/Main.java | 117 + image-kit-java-lib/build.gradle.kts | 13 + .../lib/HelperAdvancedTransformationsTest.kt | 516 ++ .../api/lib/HelperAuthenticationTest.kt | 101 + .../imagekit/api/lib/HelperBuildUrlTest.kt | 433 + .../com/imagekit/api/lib/HelperOverlayTest.kt | 1564 ++++ .../com/imagekit/api/lib/HelperSigningTest.kt | 279 + .../api/lib/HelperTransformationTest.kt | 108 + .../api/proguard/ProGuardCompatibilityTest.kt | 56 +- 73 files changed, 14407 insertions(+), 24914 deletions(-) create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/lib/Helper.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/lib/HelperService.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AiTag.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/CustomMetadata.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/EmbeddedMetadata.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionItem.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SelectedFieldsSchema.kt create mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VersionInfo.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AiTagTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/CustomMetadataTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/EmbeddedMetadataTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExtensionItemTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SelectedFieldsSchemaTest.kt create mode 100644 image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VersionInfoTest.kt create mode 100644 image-kit-java-example/src/main/java/com/imagekit/api/example/Main.java create mode 100644 image-kit-java-lib/build.gradle.kts create mode 100644 image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperAdvancedTransformationsTest.kt create mode 100644 image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperAuthenticationTest.kt create mode 100644 image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperBuildUrlTest.kt create mode 100644 image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperOverlayTest.kt create mode 100644 image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperSigningTest.kt create mode 100644 image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperTransformationTest.kt diff --git a/.gitignore b/.gitignore index 90b85e94..3b66adc5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,7 @@ build/ codegen.log kls_database.db + +image-kit-java-example/resources +image-kit-java-example/src/main/resources/ +temp \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 3aa7595d..779aaa91 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-70c42eda2bee929830b2537f758400a58dded1f1ef5686a286e2469c35a041a0.yml -openapi_spec_hash: cdaeed824e91657b45092765cf55eb42 -config_hash: 2a6f67c966b8b3db6f986be4ac23a507 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml +openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 +config_hash: dd05bc22f655304a173260e96c9588b2 diff --git a/README.md b/README.md index b2967b53..6c3bdf64 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,37 @@ -# Image Kit Java API Library +# ImageKit.io Java SDK [![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-java)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-java/0.0.1) [![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1) -The Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java. - -## MCP Server - -Use the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application. - -[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fnodejs-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9ub2RlanMtbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19) -[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fnodejs-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fnodejs-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D) - -> Note: You may need to set environment variables in your MCP client. - -The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1). +The ImageKit Java SDK is a comprehensive library designed to simplify the integration of ImageKit into your server-side applications. It provides powerful tools for working with the ImageKit REST API, including building and transforming URLs, generating signed URLs for secure content delivery, verifying webhooks, and handling file uploads. + +The full API of this library can be found in [api.md](api.md). + +For additional details, refer to the [ImageKit REST API documentation](https://imagekit.io/docs/api-reference) or the [javadoc](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1). + +## Table of Contents + +- [Installation](#installation) +- [Requirements](#requirements) +- [Usage](#usage) +- [URL generation](#url-generation) + - [Basic URL generation](#basic-url-generation) + - [URL generation with transformations](#url-generation-with-transformations) + - [URL generation with image overlay](#url-generation-with-image-overlay) + - [URL generation with text overlay](#url-generation-with-text-overlay) + - [URL generation with multiple overlays](#url-generation-with-multiple-overlays) + - [Signed URLs for secure delivery](#signed-urls-for-secure-delivery) +- [Authentication parameters for client-side uploads](#authentication-parameters-for-client-side-uploads) +- [Webhook verification](#webhook-verification) +- [Advanced Usage](#advanced-usage) + - [Client configuration](#client-configuration) + - [File uploads](#file-uploads) + - [Error handling](#error-handling) + - [Retries](#retries) + - [Timeouts](#timeouts) + - [Proxies](#proxies) + - [Logging](#logging) +- [Semantic versioning](#semantic-versioning) ## Installation @@ -45,29 +62,29 @@ import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; -import java.io.ByteArrayInputStream; +import java.io.FileInputStream; -// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables -ImageKitClient client = ImageKitOkHttpClient.fromEnv(); +ImageKitClient client = ImageKitOkHttpClient.builder() + .privateKey("private_key_xxx") // defaults to IMAGEKIT_PRIVATE_KEY env var + .build(); FileUploadParams params = FileUploadParams.builder() - .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) - .fileName("file-name.jpg") + .file(new FileInputStream("/path/to/your/image.jpg")) + .fileName("uploaded-image.jpg") .build(); FileUploadResponse response = client.files().upload(params); +System.out.println(response); ``` ## Client configuration -Configure the client using system properties or environment variables: +Configure the client using environment variables: ```java import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; -// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables +// Configures using the `IMAGEKIT_PRIVATE_KEY` and `IMAGEKIT_WEBHOOK_SECRET` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); ``` @@ -78,8 +95,7 @@ import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; ImageKitClient client = ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") + .privateKey("private_key_xxx") .build(); ``` @@ -90,23 +106,18 @@ import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; ImageKitClient client = ImageKitOkHttpClient.builder() - // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties - // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables .fromEnv() - .privateKey("My Private Key") + .privateKey("private_key_xxx") .build(); ``` See this table for the available options: -| Setter | System property | Environment variable | Required | Default value | -| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- | -| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - | -| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` | -| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - | -| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` | - -System properties take precedence over environment variables. +| Setter | Environment variable | Required | Default value | +| --------------- | -------------------------------- | -------- | --------------------------- | +| `privateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - | +| `webhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - | +| `baseUrl` | `IMAGE_KIT_BASE_URL` | false | `"https://api.imagekit.io"` | > [!TIP] > Don't create more than one client in the same application. Each client has a connection pool and @@ -127,6 +138,284 @@ ImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> { The `withOptions()` method does not affect the original client or service. +## URL generation + +The ImageKit SDK provides a powerful `client.helper().buildUrl()` method for generating optimized image and video URLs with transformations. + +### Basic URL generation + +Generate a simple URL without any transformations: + +```java +import com.imagekit.api.client.ImageKitClient; +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import com.imagekit.api.models.SrcOptions; + +ImageKitClient client = ImageKitOkHttpClient.builder() + .privateKey("private_key_xxx") + .build(); + +String url = client.helper().buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") + .src("/path/to/image.jpg") + .build() +); +System.out.println(url); +// Result: https://ik.imagekit.io/your_imagekit_id/path/to/image.jpg +``` + +### URL generation with transformations + +Apply common transformations like resizing, quality, and format conversion: + +```java +import com.imagekit.api.models.SrcOptions; +import com.imagekit.api.models.Transformation; + +String url = client.helper().buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") + .src("/path/to/image.jpg") + .addTransformation( + Transformation.builder() + .width(400.0) + .height(300.0) + .crop(Transformation.Crop.MAINTAIN_RATIO) + .quality(80.0) + .format(Transformation.Format.WEBP) + .build() + ) + .build() +); +System.out.println(url); +// Result: https://ik.imagekit.io/your_imagekit_id/path/to/image.jpg?tr=w-400,h-300,c-maintain_ratio,q-80,f-webp +``` + +### URL generation with image overlay + +Add image overlays to your base image: + +```java +import com.imagekit.api.models.ImageOverlay; +import com.imagekit.api.models.Overlay; +import com.imagekit.api.models.OverlayPosition; +import com.imagekit.api.models.SrcOptions; +import com.imagekit.api.models.Transformation; + +String url = client.helper().buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") + .src("/path/to/base-image.jpg") + .addTransformation( + Transformation.builder() + .width(500.0) + .height(400.0) + .overlay(Overlay.ofImage( + ImageOverlay.builder() + .input("/path/to/overlay-logo.png") + .position(OverlayPosition.builder() + .x(10.0) + .y(10.0) + .build()) + .addTransformation( + Transformation.builder() + .width(100.0) + .height(50.0) + .build() + ) + .build() + )) + .build() + ) + .build() +); +System.out.println(url); +// Result: URL with image overlay positioned at x:10, y:10 +``` + +### URL generation with text overlay + +Add customized text overlays: + +```java +import com.imagekit.api.models.Overlay; +import com.imagekit.api.models.OverlayPosition; +import com.imagekit.api.models.SrcOptions; +import com.imagekit.api.models.TextOverlay; +import com.imagekit.api.models.TextOverlayTransformation; +import com.imagekit.api.models.Transformation; + +String url = client.helper().buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") + .src("/path/to/base-image.jpg") + .addTransformation( + Transformation.builder() + .width(600.0) + .height(400.0) + .overlay(Overlay.ofText( + TextOverlay.builder() + .text("Sample Text Overlay") + .position(OverlayPosition.builder() + .x(50.0) + .y(50.0) + .focus(OverlayPosition.Focus.CENTER) + .build()) + .addTransformation( + TextOverlayTransformation.builder() + .fontSize(40.0) + .fontFamily("Arial") + .fontColor("FFFFFF") + .build() + ) + .build() + )) + .build() + ) + .build() +); +System.out.println(url); +// Result: URL with white Arial text overlay at center position +``` + +### URL generation with multiple overlays + +Combine multiple overlays for complex compositions: + +```java +import com.imagekit.api.models.ImageOverlay; +import com.imagekit.api.models.Overlay; +import com.imagekit.api.models.OverlayPosition; +import com.imagekit.api.models.SrcOptions; +import com.imagekit.api.models.TextOverlay; +import com.imagekit.api.models.TextOverlayTransformation; +import com.imagekit.api.models.Transformation; +import java.util.Arrays; + +String url = client.helper().buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") + .src("/path/to/base-image.jpg") + .addTransformation( + // First transformation step: text overlay + Transformation.builder() + .width(800.0) + .height(600.0) + .overlay(Overlay.ofText( + TextOverlay.builder() + .text("Header Text") + .position(OverlayPosition.builder() + .x(20.0) + .y(20.0) + .build()) + .addTransformation( + TextOverlayTransformation.builder() + .fontSize(30.0) + .fontColor("000000") + .build() + ) + .build() + )) + .build() + ) + .addTransformation( + // Second transformation step: image watermark overlay + Transformation.builder() + .overlay(Overlay.ofImage( + ImageOverlay.builder() + .input("/watermark.png") + .position(OverlayPosition.builder() + .focus(OverlayPosition.Focus.BOTTOM_RIGHT) + .build()) + .addTransformation( + Transformation.builder() + .width(100.0) + .opacity(70.0) + .build() + ) + .build() + )) + .build() + ) + .build() +); +System.out.println(url); +// Result: URL with text overlay at top-left and semi-transparent watermark at bottom-right +``` + +### Signed URLs for secure delivery + +Generate signed URLs that expire after a specified time for secure content delivery: + +```java +import com.imagekit.api.models.SrcOptions; +import com.imagekit.api.models.Transformation; + +// Generate a signed URL that expires in 1 hour (3600 seconds) +String url = client.helper().buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") + .src("/private/secure-image.jpg") + .addTransformation( + Transformation.builder() + .width(400.0) + .height(300.0) + .quality(90.0) + .build() + ) + .signed(true) + .expiresIn(3600.0) // URL expires in 1 hour + .build() +); +System.out.println(url); +// Result: URL with signature parameters (?ik-t=timestamp&ik-s=signature) + +// Generate a signed URL that doesn't expire +String permanentSignedUrl = client.helper().buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") + .src("/private/secure-image.jpg") + .signed(true) + // No expiresIn means the URL won't expire + .build() +); +System.out.println(permanentSignedUrl); +// Result: URL with signature parameter (?ik-s=signature) +``` + +## Authentication parameters for client-side uploads + +Generate authentication parameters for secure client-side file uploads: + +```java +import com.imagekit.api.client.ImageKitClient; +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import java.util.Map; + +ImageKitClient client = ImageKitOkHttpClient.builder() + .privateKey("private_key_xxx") + .build(); + +// Generate authentication parameters with auto-generated token and default expiry +Map authParams = client.helper().getAuthenticationParameters(null, null); +System.out.println(authParams); +// Result: {token=, expire=, signature=} + +// Generate with custom token and expiry +Map customAuthParams = client.helper().getAuthenticationParameters("my-custom-token", 1800L); +System.out.println(customAuthParams); +// Result: {token=my-custom-token, expire=1800, signature=} +``` + +These authentication parameters can be used in client-side upload forms to securely upload files without exposing your private API key. + +## Webhook verification + +The ImageKit SDK provides utilities to verify webhook signatures for secure event handling. This ensures that webhook requests are actually coming from ImageKit and haven't been tampered with. + +For detailed information about webhook setup, signature verification, and handling different webhook events, refer to the [ImageKit webhook documentation](https://imagekit.io/docs/webhooks#verify-webhook-signature). + ## Requests and responses To send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. @@ -150,16 +439,16 @@ import com.imagekit.api.client.ImageKitClient; import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; -import java.io.ByteArrayInputStream; +import java.io.FileInputStream; import java.util.concurrent.CompletableFuture; -// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables -ImageKitClient client = ImageKitOkHttpClient.fromEnv(); +ImageKitClient client = ImageKitOkHttpClient.builder() + .privateKey("private_key_xxx") + .build(); FileUploadParams params = FileUploadParams.builder() - .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) - .fileName("file-name.jpg") + .file(new FileInputStream("/path/to/your/image.jpg")) + .fileName("uploaded-image.jpg") .build(); CompletableFuture response = client.async().files().upload(params); ``` @@ -171,16 +460,16 @@ import com.imagekit.api.client.ImageKitClientAsync; import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; -import java.io.ByteArrayInputStream; +import java.io.FileInputStream; import java.util.concurrent.CompletableFuture; -// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables -ImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv(); +ImageKitClientAsync client = ImageKitOkHttpClientAsync.builder() + .privateKey("private_key_xxx") + .build(); FileUploadParams params = FileUploadParams.builder() - .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) - .fileName("file-name.jpg") + .file(new FileInputStream("/path/to/your/image.jpg")) + .fileName("uploaded-image.jpg") .build(); CompletableFuture response = client.files().upload(params); ``` @@ -199,8 +488,8 @@ import com.imagekit.api.models.files.FileUploadResponse; import java.nio.file.Paths; FileUploadParams params = FileUploadParams.builder() - .fileName("fileName") - .file(Paths.get("/path/to/file")) + .fileName("uploaded-image.jpg") + .file(Paths.get("/path/to/your/image.jpg")) .build(); FileUploadResponse response = client.files().upload(params); ``` @@ -210,11 +499,11 @@ Or an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/i ```java import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; -import java.net.URL; +import java.io.FileInputStream; FileUploadParams params = FileUploadParams.builder() - .fileName("fileName") - .file(new URL("https://example.com//path/to/file").openStream()) + .fileName("uploaded-image.jpg") + .file(new FileInputStream("/path/to/your/image.jpg")) .build(); FileUploadResponse response = client.files().upload(params); ``` @@ -225,9 +514,10 @@ Or a `byte[]` array: import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; +byte[] imageData = /* your binary data */; FileUploadParams params = FileUploadParams.builder() - .fileName("fileName") - .file("content".getBytes()) + .fileName("binary-upload.jpg") + .file(imageData) .build(); FileUploadResponse response = client.files().upload(params); ``` @@ -238,14 +528,15 @@ Note that when passing a non-`Path` its filename is unknown so it will not be in import com.imagekit.api.core.MultipartField; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; +import java.io.FileInputStream; import java.io.InputStream; -import java.net.URL; FileUploadParams params = FileUploadParams.builder() - .fileName("fileName") + .fileName("custom-upload.jpg") .file(MultipartField.builder() - .value(new URL("https://example.com//path/to/file").openStream()) - .filename("/path/to/file") + .value(new FileInputStream("/path/to/your/image.jpg")) + .filename("image.jpg") + .contentType("image/jpeg") .build()) .build(); FileUploadResponse response = client.files().upload(params); @@ -262,11 +553,11 @@ import com.imagekit.api.core.http.Headers; import com.imagekit.api.core.http.HttpResponseFor; import com.imagekit.api.models.files.FileUploadParams; import com.imagekit.api.models.files.FileUploadResponse; -import java.io.ByteArrayInputStream; +import java.io.FileInputStream; FileUploadParams params = FileUploadParams.builder() - .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) - .fileName("file-name.jpg") + .file(new FileInputStream("/path/to/your/image.jpg")) + .fileName("uploaded-image.jpg") .build(); HttpResponseFor response = client.files().withRawResponse().upload(params); @@ -521,7 +812,7 @@ import com.imagekit.api.core.JsonValue; import com.imagekit.api.models.files.FileUploadParams; FileUploadParams params = FileUploadParams.builder() - .transformation(FileUploadParams.Transformation.builder() + .transformation(FileUploadParams.UploadTransformation.builder() .putAdditionalProperty("secretProperty", JsonValue.from("42")) .build()) .build(); diff --git a/buildSrc/src/main/kotlin/image-kit.java.gradle.kts b/buildSrc/src/main/kotlin/image-kit.java.gradle.kts index a3cfe28e..d3ef265d 100644 --- a/buildSrc/src/main/kotlin/image-kit.java.gradle.kts +++ b/buildSrc/src/main/kotlin/image-kit.java.gradle.kts @@ -15,7 +15,7 @@ configure { java { toolchain { - languageVersion.set(JavaLanguageVersion.of(21)) + languageVersion.set(JavaLanguageVersion.of(17)) } sourceCompatibility = JavaVersion.VERSION_1_8 diff --git a/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts b/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts index dd476783..ffb5e8d6 100644 --- a/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts @@ -12,7 +12,7 @@ repositories { kotlin { jvmToolchain { - languageVersion.set(JavaLanguageVersion.of(21)) + languageVersion.set(JavaLanguageVersion.of(17)) } compilerOptions { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt index 6b222fca..020c96db 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt @@ -3,6 +3,7 @@ package com.imagekit.api.client import com.imagekit.api.core.ClientOptions +import com.imagekit.api.lib.HelperService import com.imagekit.api.services.blocking.AccountService import com.imagekit.api.services.blocking.AssetService import com.imagekit.api.services.blocking.BetaService @@ -68,6 +69,8 @@ interface ImageKitClient { fun webhooks(): WebhookService + fun helper(): HelperService + /** * Closes this client, relinquishing any underlying resources. * diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt index b070668e..efacb147 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt @@ -3,6 +3,7 @@ package com.imagekit.api.client import com.imagekit.api.core.ClientOptions +import com.imagekit.api.lib.HelperService import com.imagekit.api.services.async.AccountServiceAsync import com.imagekit.api.services.async.AssetServiceAsync import com.imagekit.api.services.async.BetaServiceAsync @@ -68,6 +69,8 @@ interface ImageKitClientAsync { fun webhooks(): WebhookServiceAsync + fun helper(): HelperService + /** * Closes this client, relinquishing any underlying resources. * diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt index 9fe9056f..48d3a864 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt @@ -4,6 +4,8 @@ package com.imagekit.api.client import com.imagekit.api.core.ClientOptions import com.imagekit.api.core.getPackageVersion +import com.imagekit.api.lib.Helper +import com.imagekit.api.lib.HelperService import com.imagekit.api.services.async.AccountServiceAsync import com.imagekit.api.services.async.AccountServiceAsyncImpl import com.imagekit.api.services.async.AssetServiceAsync @@ -73,6 +75,8 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK WebhookServiceAsyncImpl(clientOptionsWithUserAgent) } + private val helper: Helper by lazy { Helper.create(clientOptions) } + override fun sync(): ImageKitClient = sync override fun withRawResponse(): ImageKitClientAsync.WithRawResponse = withRawResponse @@ -98,6 +102,8 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK override fun webhooks(): WebhookServiceAsync = webhooks + override fun helper(): HelperService = helper + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt index a9b47abf..c47a5db0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt @@ -4,6 +4,8 @@ package com.imagekit.api.client import com.imagekit.api.core.ClientOptions import com.imagekit.api.core.getPackageVersion +import com.imagekit.api.lib.Helper +import com.imagekit.api.lib.HelperService import com.imagekit.api.services.blocking.AccountService import com.imagekit.api.services.blocking.AccountServiceImpl import com.imagekit.api.services.blocking.AssetService @@ -63,6 +65,8 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli private val webhooks: WebhookService by lazy { WebhookServiceImpl(clientOptionsWithUserAgent) } + private val helper: Helper by lazy { Helper.create(clientOptions) } + override fun async(): ImageKitClientAsync = async override fun withRawResponse(): ImageKitClient.WithRawResponse = withRawResponse @@ -88,6 +92,8 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli override fun webhooks(): WebhookService = webhooks + override fun helper(): HelperService = helper + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/lib/Helper.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/lib/Helper.kt new file mode 100644 index 00000000..3829d852 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/lib/Helper.kt @@ -0,0 +1,970 @@ +// Package lib provides helper utilities for ImageKit SDK +// This file contains custom helper functions - not generated + +package com.imagekit.api.lib + +import com.imagekit.api.core.ClientOptions +import com.imagekit.api.models.SrcOptions +import com.imagekit.api.models.Transformation +import com.imagekit.api.models.TransformationPosition +import java.security.SecureRandom +import java.time.Instant +import javax.crypto.Mac +import javax.crypto.spec.SecretKeySpec + +/** + * Helper service containing utility methods for ImageKit SDK operations like URL building, + * transformation string generation, and authentication parameter generation. + */ +class Helper(private val privateKey: String) : HelperService { + + companion object { + private const val DEFAULT_TIMESTAMP = 9999999999L + + /** + * Creates a new Helper instance with the given private key. + * + * @param privateKey The private API key from ImageKit dashboard + * @return A new Helper instance + */ + @JvmStatic fun create(privateKey: String): Helper = Helper(privateKey) + + /** + * Creates a new Helper instance from ClientOptions. + * + * @param options The client options containing the private key + * @return A new Helper instance + */ + @JvmStatic fun create(options: ClientOptions): Helper = Helper(options.privateKey) + } + + /** + * Builds a URL with the given options including transformations. + * + * @param options The source options for URL generation + * @return The generated URL string + */ + override fun buildUrl(options: SrcOptions): String { + val urlEndpoint = options.urlEndpoint() + val src = options.src() + + if (src.isEmpty()) { + return "" + } + + val transformationPosition = + options.transformationPosition().orElse(TransformationPosition.QUERY) + + val isAbsoluteURL = src.startsWith("http://") || src.startsWith("https://") + + val urlObj: java.net.URL + val isSrcParameterUsedForURL: Boolean + + try { + if (!isAbsoluteURL) { + urlObj = java.net.URL(urlEndpoint) + isSrcParameterUsedForURL = false + } else { + urlObj = java.net.URL(src) + isSrcParameterUsedForURL = true + } + } catch (e: Exception) { + return "" + } + + // Extract existing query parameters from URL if present + val existingQuery = + if (isSrcParameterUsedForURL && urlObj.query != null) { + urlObj.query + } else { + "" + } + + // Build query parameters + val queryParts = mutableListOf() + + // Add existing query parameters first + if (existingQuery.isNotEmpty()) { + queryParts.add(existingQuery) + } + + // Add new query parameters (sorted alphabetically for consistent signing) + options.queryParameters().ifPresent { queryParams -> + val params = queryParams._additionalProperties() + if (params.isNotEmpty()) { + val newQuery = + params.entries + .sortedBy { it.key } // Sort alphabetically by key + .joinToString("&") { (key, value) -> + val valueStr = + value.asString().orElseGet { + value + .asNumber() + .map { it.toString() } + .orElseGet { + value + .asBoolean() + .map { it.toString() } + .orElse(value.toString()) + } + } + "${java.net.URLEncoder.encode(key, "UTF-8")}=${java.net.URLEncoder.encode(valueStr, "UTF-8")}" + } + queryParts.add(newQuery) + } + } + + val query = queryParts.joinToString("&") + + // Build transformation string + val transformationString = + options.transformation().map { buildTransformationString(it) }.orElse("") + + // Determine if transformation will be in query params + val addAsQuery = + transformationPosition == TransformationPosition.QUERY || isSrcParameterUsedForURL + + // Transformation placeholder to avoid URL encoding issues + val transformationPlaceholder = "PLEASEREPLACEJUSTBEFORESIGN" + + // Build the URL path + var path = "" + if (!isAbsoluteURL) { + // For non-absolute URLs, construct: endpoint_path + transformations + src + val endpointPath = urlObj.path.ifEmpty { "/" } + val pathParts = mutableListOf() + pathParts.add(endpointPath) + + if (transformationString.isNotEmpty() && !addAsQuery) { + pathParts.add("tr:$transformationPlaceholder") + } + pathParts.add(src) + + path = pathParts.joinToString("/") { it.trim('/') }.replace(Regex("/+"), "/") + if (!path.startsWith("/")) { + path = "/$path" + } + } else { + path = urlObj.path + } + + // Build the complete URL using URI to properly encode the path + val uriString = + try { + java.net + .URI( + urlObj.protocol, + null, // user info + urlObj.host, + if (urlObj.port != -1 && urlObj.port != urlObj.defaultPort) urlObj.port + else -1, + path, + null, // query will be added later + null, // fragment + ) + .toASCIIString() + } catch (e: Exception) { + // Fallback to manual construction + "${urlObj.protocol}://${urlObj.host}${if (urlObj.port != -1 && urlObj.port != urlObj.defaultPort) ":${urlObj.port}" else ""}$path" + } + + var finalURL = uriString + + // Add query parameters + if (query.isNotEmpty()) { + finalURL += "?$query" + } + + // Add transformation parameter to query if needed + if (transformationString.isNotEmpty() && addAsQuery) { + val separator = if (query.isEmpty()) "?" else "&" + finalURL += "${separator}tr=$transformationPlaceholder" + } + + // Replace the placeholder with actual transformation string + if (transformationString.isNotEmpty()) { + finalURL = finalURL.replace(transformationPlaceholder, transformationString) + } + + // Sign the URL if needed + val shouldSign = options.signed().orElse(false) || (options.expiresIn().orElse(0.0) > 0) + if (shouldSign) { + val expiryTimestamp = getSignatureTimestamp(options.expiresIn().orElse(0.0)) + val urlSignature = getSignature(finalURL, urlEndpoint, expiryTimestamp) + + val hasExistingParams = finalURL.contains("?") + val separator = if (hasExistingParams) "&" else "?" + + if (expiryTimestamp != DEFAULT_TIMESTAMP) { + finalURL += "${separator}ik-t=$expiryTimestamp&ik-s=$urlSignature" + } else { + finalURL += "${separator}ik-s=$urlSignature" + } + } + + return finalURL + } + + private fun getSignatureTimestamp(expiresIn: Double): Long { + return if (expiresIn > 0) { + Instant.now().epochSecond + expiresIn.toLong() + } else { + DEFAULT_TIMESTAMP + } + } + + private fun getSignature(finalURL: String, urlEndpoint: String, expiryTimestamp: Long): String { + if (privateKey.isEmpty() || finalURL.isEmpty() || urlEndpoint.isEmpty()) { + return "" + } + + // Create the string to sign: relative path + expiry timestamp + val urlEndpointWithSlash = if (urlEndpoint.endsWith("/")) urlEndpoint else "$urlEndpoint/" + val stringToSign = + finalURL.replaceFirst(urlEndpointWithSlash, "") + expiryTimestamp.toString() + + val mac = Mac.getInstance("HmacSHA1") + val secretKey = SecretKeySpec(privateKey.toByteArray(), "HmacSHA1") + mac.init(secretKey) + val hash = mac.doFinal(stringToSign.toByteArray()) + + return hash.joinToString("") { "%02x".format(it) } + } + + /** + * Builds a transformation string from the given transformations. + * + * @param transformations The list of transformations + * @return The transformation string + */ + override fun buildTransformationString(transformations: List?): String { + if (transformations.isNullOrEmpty()) { + return "" + } + + val parsedTransforms = mutableListOf() + + for (transform in transformations) { + val parts = mutableListOf() + + // Basic transformations (in order from Go SDK) + + // Width + transform.width().ifPresent { w -> + when { + w.isNumber() -> parts.add("w-${formatNumber(w.asNumber())}") + w.isString() -> parts.add("w-${w.asString()}") + } + } + + // Height + transform.height().ifPresent { h -> + when { + h.isNumber() -> parts.add("h-${formatNumber(h.asNumber())}") + h.isString() -> parts.add("h-${h.asString()}") + } + } + + // Quality + transform.quality().ifPresent { q -> parts.add("q-${formatNumber(q)}") } + + // Aspect Ratio + transform.aspectRatio().ifPresent { ar -> + when { + ar.isNumber() -> parts.add("ar-${formatNumber(ar.asNumber())}") + ar.isString() -> parts.add("ar-${ar.asString()}") + } + } + + // Crop + transform.crop().ifPresent { c -> if (c.toString().isNotEmpty()) parts.add("c-$c") } + + // Crop Mode + transform.cropMode().ifPresent { cm -> + if (cm.toString().isNotEmpty()) parts.add("cm-$cm") + } + + // Focus + transform.focus().ifPresent { fo -> parts.add("fo-$fo") } + + // Format + transform.format().ifPresent { f -> if (f.toString().isNotEmpty()) parts.add("f-$f") } + + // Radius + transform.radius().ifPresent { r -> + when { + r.isMax() -> parts.add("r-max") + r.isNumber() -> parts.add("r-${formatNumber(r.asNumber())}") + r.isString() -> parts.add("r-${r.asString()}") + } + } + + // Background + transform.background().ifPresent { bg -> parts.add("bg-$bg") } + + // Border + transform.border().ifPresent { b -> parts.add("b-$b") } + + // Color Replace + transform.colorReplace().ifPresent { cr -> parts.add("cr-$cr") } + + // Default Image + transform.defaultImage().ifPresent { di -> + if (di.isNotEmpty()) { + val value = di.removePrefix("/").removeSuffix("/").replace("/", "@@") + parts.add("di-$value") + } + } + + // DPR + transform.dpr().ifPresent { dpr -> parts.add("dpr-${formatNumber(dpr)}") } + + // X position + transform.x().ifPresent { x -> + when { + x.isNumber() -> parts.add("x-${formatNumber(x.asNumber())}") + x.isString() -> parts.add("x-${x.asString()}") + } + } + + // Y position + transform.y().ifPresent { y -> + when { + y.isNumber() -> parts.add("y-${formatNumber(y.asNumber())}") + y.isString() -> parts.add("y-${y.asString()}") + } + } + + // X Center + transform.xCenter().ifPresent { xc -> + when { + xc.isNumber() -> parts.add("xc-${formatNumber(xc.asNumber())}") + xc.isString() -> parts.add("xc-${xc.asString()}") + } + } + + // Y Center + transform.yCenter().ifPresent { yc -> + when { + yc.isNumber() -> parts.add("yc-${formatNumber(yc.asNumber())}") + yc.isString() -> parts.add("yc-${yc.asString()}") + } + } + + // Opacity + transform.opacity().ifPresent { o -> parts.add("o-${formatNumber(o)}") } + + // Zoom + transform.zoom().ifPresent { z -> parts.add("z-${formatNumber(z)}") } + + // Rotation + transform.rotation().ifPresent { rt -> + when { + rt.isNumber() -> parts.add("rt-${formatNumber(rt.asNumber())}") + rt.isString() -> parts.add("rt-${rt.asString()}") + } + } + + // Blur + transform.blur().ifPresent { bl -> parts.add("bl-${formatNumber(bl)}") } + + // Named + transform.named().ifPresent { n -> parts.add("n-$n") } + + // Progressive + transform.progressive().ifPresent { pr -> parts.add("pr-$pr") } + + // Lossless + transform.lossless().ifPresent { lo -> parts.add("lo-$lo") } + + // Flip + transform.flip().ifPresent { fl -> if (fl.toString().isNotEmpty()) parts.add("fl-$fl") } + + // Trim + transform.trim().ifPresent { t -> + when { + t.isTrue() -> parts.add("t-true") + t.isNumber() -> parts.add("t-${formatNumber(t.asNumber())}") + } + } + + // Metadata + transform.metadata().ifPresent { md -> parts.add("md-$md") } + + // Color Profile + transform.colorProfile().ifPresent { cp -> parts.add("cp-$cp") } + + // Video Codec + transform.videoCodec().ifPresent { vc -> + if (vc.toString().isNotEmpty()) parts.add("vc-$vc") + } + + // Audio Codec + transform.audioCodec().ifPresent { ac -> + if (ac.toString().isNotEmpty()) parts.add("ac-$ac") + } + + // Start Offset + transform.startOffset().ifPresent { so -> + when { + so.isNumber() -> parts.add("so-${formatNumber(so.asNumber())}") + so.isString() -> parts.add("so-${so.asString()}") + } + } + + // End Offset + transform.endOffset().ifPresent { eo -> + when { + eo.isNumber() -> parts.add("eo-${formatNumber(eo.asNumber())}") + eo.isString() -> parts.add("eo-${eo.asString()}") + } + } + + // Duration + transform.duration().ifPresent { du -> + when { + du.isNumber() -> parts.add("du-${formatNumber(du.asNumber())}") + du.isString() -> parts.add("du-${du.asString()}") + } + } + + // Streaming Resolutions + transform.streamingResolutions().ifPresent { resolutions -> + if (resolutions.isNotEmpty()) { + val sr = resolutions.joinToString("_") + parts.add("sr-$sr") + } + } + + // AI transformations (boolean flags) + transform.grayscale().ifPresent { gs -> if (gs.asBoolean()) parts.add("e-grayscale") } + transform.aiUpscale().ifPresent { au -> if (au.asBoolean()) parts.add("e-upscale") } + transform.aiRetouch().ifPresent { ar -> if (ar.asBoolean()) parts.add("e-retouch") } + transform.aiVariation().ifPresent { av -> if (av.asBoolean()) parts.add("e-genvar") } + transform.aiRemoveBackground().ifPresent { rb -> + if (rb.asBoolean()) parts.add("e-bgremove") + } + transform.aiRemoveBackgroundExternal().ifPresent { re -> + if (re.asBoolean()) parts.add("e-removedotbg") + } + transform.contrastStretch().ifPresent { cs -> + if (cs.asBoolean()) parts.add("e-contrast") + } + + // AI Drop Shadow + transform.aiDropShadow().ifPresent { ds -> + when { + ds.isTrue() -> parts.add("e-dropshadow") + ds.isString() -> parts.add("e-dropshadow-${ds.asString()}") + } + } + + // AI Change Background + transform.aiChangeBackground().ifPresent { bg -> parts.add("e-changebg-$bg") } + + // AI Edit + transform.aiEdit().ifPresent { edit -> parts.add("e-edit-$edit") } + + // Effects + transform.shadow().ifPresent { s -> + when { + s.isTrue() -> parts.add("e-shadow") + s.isString() -> parts.add("e-shadow-${s.asString()}") + } + } + + transform.sharpen().ifPresent { sh -> + when { + sh.isTrue() -> parts.add("e-sharpen") + sh.isNumber() -> parts.add("e-sharpen-${formatNumber(sh.asNumber())}") + } + } + + transform.unsharpMask().ifPresent { usm -> + when { + usm.isTrue() -> parts.add("e-usm") + usm.isString() -> parts.add("e-usm-${usm.asString()}") + } + } + + transform.gradient().ifPresent { gr -> + when { + gr.isTrue() -> parts.add("e-gradient") + gr.isString() -> parts.add("e-gradient-${gr.asString()}") + } + } + + transform.distort().ifPresent { d -> parts.add("e-distort-$d") } + + // Original + transform.original().ifPresent { orig -> if (orig) parts.add("orig-true") } + + // Page + transform.page().ifPresent { pg -> + when { + pg.isNumber() -> parts.add("pg-${formatNumber(pg.asNumber())}") + pg.isString() -> parts.add("pg-${pg.asString()}") + } + } + + // Overlay + transform.overlay().ifPresent { overlay -> + val overlayStr = processOverlay(overlay) + if (overlayStr.isNotEmpty()) { + parts.add(overlayStr) + } + } + + // Raw parameter (added last) + transform.raw().ifPresent { raw -> + if (raw.isNotEmpty()) { + parts.add(raw) + } + } + + if (parts.isNotEmpty()) { + parsedTransforms.add(parts.joinToString(",")) + } + } + + return parsedTransforms.joinToString(":") + } + + private fun formatNumber(value: Double): String { + return if (value == value.toLong().toDouble()) { + value.toLong().toString() + } else { + value.toString() + } + } + + private val simpleOverlayPathRegex = Regex("^[a-zA-Z0-9\\-._/ ]*$") + private val simpleOverlayTextRegex = Regex("^[a-zA-Z0-9\\-._ ]*$") + + private fun processOverlay(overlay: com.imagekit.api.models.Overlay): String { + val entries = mutableListOf() + var transformationString = "" + + // Each branch: add layer type + input, extract base overlay fields, build transformation + // string + var layerMode: String? = null + var position: com.imagekit.api.models.OverlayPosition? = null + var timing: com.imagekit.api.models.OverlayTiming? = null + + when { + overlay.isText() -> { + val textOverlay = overlay.asText() + if (textOverlay.text().isEmpty()) return "" + + val encoding = + textOverlay.encoding().orElse(null)?.toString()?.lowercase() ?: "auto" + entries.add("l-text") + entries.add(processText(textOverlay.text(), encoding)) + + textOverlay.layerMode().ifPresent { layerMode = it.toString().lowercase() } + textOverlay.position().ifPresent { position = it } + textOverlay.timing().ifPresent { timing = it } + + textOverlay.transformation().ifPresent { transformations -> + if (transformations.isNotEmpty()) { + transformationString = buildTextOverlayTransformation(transformations) + } + } + } + + overlay.isImage() -> { + val imageOverlay = overlay.asImage() + if (imageOverlay.input().isEmpty()) return "" + + val encoding = + imageOverlay.encoding().orElse(null)?.toString()?.lowercase() ?: "auto" + entries.add("l-image") + entries.add(processInputPath(imageOverlay.input(), encoding)) + + imageOverlay.layerMode().ifPresent { layerMode = it.toString().lowercase() } + imageOverlay.position().ifPresent { position = it } + imageOverlay.timing().ifPresent { timing = it } + + imageOverlay.transformation().ifPresent { transformations -> + if (transformations.isNotEmpty()) { + transformationString = buildTransformationString(transformations) + } + } + } + + overlay.isVideo() -> { + val videoOverlay = overlay.asVideo() + if (videoOverlay.input().isEmpty()) return "" + + val encoding = + videoOverlay.encoding().orElse(null)?.toString()?.lowercase() ?: "auto" + entries.add("l-video") + entries.add(processInputPath(videoOverlay.input(), encoding)) + + videoOverlay.layerMode().ifPresent { layerMode = it.toString().lowercase() } + videoOverlay.position().ifPresent { position = it } + videoOverlay.timing().ifPresent { timing = it } + + videoOverlay.transformation().ifPresent { transformations -> + if (transformations.isNotEmpty()) { + transformationString = buildTransformationString(transformations) + } + } + } + + overlay.isSubtitle() -> { + val subtitleOverlay = overlay.asSubtitle() + if (subtitleOverlay.input().isEmpty()) return "" + + val encoding = + subtitleOverlay.encoding().orElse(null)?.toString()?.lowercase() ?: "auto" + entries.add("l-subtitles") + entries.add(processInputPath(subtitleOverlay.input(), encoding)) + + subtitleOverlay.layerMode().ifPresent { layerMode = it.toString().lowercase() } + subtitleOverlay.position().ifPresent { position = it } + subtitleOverlay.timing().ifPresent { timing = it } + + subtitleOverlay.transformation().ifPresent { transformations -> + if (transformations.isNotEmpty()) { + transformationString = buildSubtitleOverlayTransformation(transformations) + } + } + } + + overlay.isSolidColor() -> { + val solidColorOverlay = overlay.asSolidColor() + if (solidColorOverlay.color().isEmpty()) return "" + + entries.add("l-image") + entries.add("i-ik_canvas") + entries.add("bg-${solidColorOverlay.color()}") + + solidColorOverlay.layerMode().ifPresent { layerMode = it.toString().lowercase() } + solidColorOverlay.position().ifPresent { position = it } + solidColorOverlay.timing().ifPresent { timing = it } + + solidColorOverlay.transformation().ifPresent { transformations -> + if (transformations.isNotEmpty()) { + transformationString = buildSolidColorOverlayTransformation(transformations) + } + } + } + } + + if (entries.isEmpty()) return "" + + // Shared base overlay processing (matches Go's order) + // LayerMode + if (!layerMode.isNullOrEmpty()) { + entries.add("lm-$layerMode") + } + + // Position + if (position != null) { + processOverlayPosition(position!!, entries) + } + + // Timing + if (timing != null) { + processOverlayTiming(timing!!, entries) + } + + // Transformation string + if (transformationString.isNotEmpty()) { + entries.add(transformationString) + } + + // Close layer + entries.add("l-end") + return entries.joinToString(",") + } + + private fun processInputPath(str: String, encoding: String): String { + val cleaned = str.removePrefix("/").removeSuffix("/") + + if (encoding == "plain") { + return "i-${cleaned.replace("/", "@@")}" + } + + if (encoding == "base64") { + val base64 = java.util.Base64.getEncoder().encodeToString(cleaned.toByteArray()) + return "ie-${java.net.URLEncoder.encode(base64, "UTF-8")}" + } + + // Auto-detect + if (simpleOverlayPathRegex.matches(cleaned)) { + return "i-${cleaned.replace("/", "@@")}" + } + + val base64 = java.util.Base64.getEncoder().encodeToString(cleaned.toByteArray()) + return "ie-${java.net.URLEncoder.encode(base64, "UTF-8")}" + } + + private fun processText(str: String, encoding: String): String { + if (encoding == "plain") { + return "i-${pathEscape(str)}" + } + + if (encoding == "base64") { + val base64 = java.util.Base64.getEncoder().encodeToString(str.toByteArray()) + return "ie-${java.net.URLEncoder.encode(base64, "UTF-8")}" + } + + // Auto-detect + if (simpleOverlayTextRegex.matches(str)) { + return "i-${pathEscape(str)}" + } + + val base64 = java.util.Base64.getEncoder().encodeToString(str.toByteArray()) + return "ie-${java.net.URLEncoder.encode(base64, "UTF-8")}" + } + + /** Equivalent to Go's url.PathEscape — encodes for use in URL path segments */ + private fun pathEscape(str: String): String { + return java.net.URI(null, null, "/$str", null).toASCIIString().removePrefix("/") + } + + private fun buildTextOverlayTransformation( + transformations: List + ): String { + val entries = mutableListOf() + for (transform in transformations) { + processTextOverlayTransformation(transform, entries) + } + return entries.joinToString(",") + } + + private fun buildSubtitleOverlayTransformation( + transformations: List + ): String { + val entries = mutableListOf() + for (transform in transformations) { + processSubtitleOverlayTransformation(transform, entries) + } + return entries.joinToString(",") + } + + private fun buildSolidColorOverlayTransformation( + transformations: List + ): String { + val entries = mutableListOf() + for (transform in transformations) { + processSolidColorOverlayTransformation(transform, entries) + } + return entries.joinToString(",") + } + + private fun processTextOverlayTransformation( + transform: com.imagekit.api.models.TextOverlayTransformation, + parts: MutableList, + ) { + transform.width().ifPresent { w -> + when { + w.isNumber() -> parts.add("w-${formatNumber(w.asNumber())}") + w.isString() -> parts.add("w-${w.asString()}") + } + } + transform.fontSize().ifPresent { fs -> + when { + fs.isNumber() -> parts.add("fs-${formatNumber(fs.asNumber())}") + fs.isString() -> parts.add("fs-${fs.asString()}") + } + } + transform.fontFamily().ifPresent { ff -> + val cleaned = ff.removePrefix("/").removeSuffix("/").replace("/", "@@") + parts.add("ff-$cleaned") + } + transform.fontColor().ifPresent { fc -> parts.add("co-$fc") } + transform.innerAlignment().ifPresent { ia -> parts.add("ia-${ia.toString().lowercase()}") } + transform.padding().ifPresent { p -> + when { + p.isNumber() -> parts.add("pa-${formatNumber(p.asNumber())}") + p.isString() -> parts.add("pa-${p.asString()}") + } + } + transform.alpha().ifPresent { a -> parts.add("al-${formatNumber(a)}") } + transform.typography().ifPresent { t -> parts.add("tg-$t") } + transform.background().ifPresent { bg -> parts.add("bg-$bg") } + transform.radius().ifPresent { r -> + when { + r.isMax() -> parts.add("r-max") + r.isNumber() -> parts.add("r-${formatNumber(r.asNumber())}") + r.isString() -> parts.add("r-${r.asString()}") + } + } + transform.rotation().ifPresent { rt -> + when { + rt.isNumber() -> parts.add("rt-${formatNumber(rt.asNumber())}") + rt.isString() -> parts.add("rt-${rt.asString()}") + } + } + transform.flip().ifPresent { fl -> parts.add("fl-${fl.toString().lowercase()}") } + transform.lineHeight().ifPresent { lh -> + when { + lh.isNumber() -> parts.add("lh-${formatNumber(lh.asNumber())}") + lh.isString() -> parts.add("lh-${lh.asString()}") + } + } + } + + private fun processSolidColorOverlayTransformation( + transform: com.imagekit.api.models.SolidColorOverlayTransformation, + parts: MutableList, + ) { + transform.width().ifPresent { w -> + when { + w.isNumber() -> parts.add("w-${formatNumber(w.asNumber())}") + w.isString() -> parts.add("w-${w.asString()}") + } + } + transform.height().ifPresent { h -> + when { + h.isNumber() -> parts.add("h-${formatNumber(h.asNumber())}") + h.isString() -> parts.add("h-${h.asString()}") + } + } + transform.alpha().ifPresent { a -> parts.add("al-${formatNumber(a)}") } + transform.background().ifPresent { bg -> parts.add("bg-$bg") } + transform.gradient().ifPresent { g -> + when { + g.isTrue() -> parts.add("e-gradient") + g.isString() -> parts.add("e-gradient-${g.asString()}") + } + } + transform.radius().ifPresent { r -> + when { + r.isMax() -> parts.add("r-max") + r.isNumber() -> parts.add("r-${formatNumber(r.asNumber())}") + r.isString() -> parts.add("r-${r.asString()}") + } + } + } + + private fun processSubtitleOverlayTransformation( + transform: com.imagekit.api.models.SubtitleOverlayTransformation, + parts: MutableList, + ) { + transform.background().ifPresent { bg -> parts.add("bg-$bg") } + transform.color().ifPresent { c -> parts.add("co-$c") } + transform.fontSize().ifPresent { fs -> parts.add("fs-${formatNumber(fs)}") } + transform.fontFamily().ifPresent { ff -> parts.add("ff-$ff") } + transform.fontOutline().ifPresent { fo -> parts.add("fol-$fo") } + transform.fontShadow().ifPresent { fs -> parts.add("fsh-$fs") } + transform.typography().ifPresent { tg -> parts.add("tg-$tg") } + } + + private fun processOverlayPosition( + position: com.imagekit.api.models.OverlayPosition, + parts: MutableList, + ) { + position.x().ifPresent { x -> + when { + x.isNumber() -> parts.add("lx-${formatNumber(x.asNumber())}") + x.isString() -> parts.add("lx-${x.asString()}") + } + } + position.y().ifPresent { y -> + when { + y.isNumber() -> parts.add("ly-${formatNumber(y.asNumber())}") + y.isString() -> parts.add("ly-${y.asString()}") + } + } + position.xCenter().ifPresent { xc -> + when { + xc.isNumber() -> parts.add("lxc-${formatNumber(xc.asNumber())}") + xc.isString() -> parts.add("lxc-${xc.asString()}") + } + } + position.yCenter().ifPresent { yc -> + when { + yc.isNumber() -> parts.add("lyc-${formatNumber(yc.asNumber())}") + yc.isString() -> parts.add("lyc-${yc.asString()}") + } + } + position.anchorPoint().ifPresent { ap -> parts.add("lap-${ap.toString().lowercase()}") } + position.focus().ifPresent { f -> parts.add("lfo-${f.toString().lowercase()}") } + } + + private fun processOverlayTiming( + timing: com.imagekit.api.models.OverlayTiming, + parts: MutableList, + ) { + timing.start().ifPresent { s -> + when { + s.isNumber() -> parts.add("lso-${formatNumber(s.asNumber())}") + s.isString() -> parts.add("lso-${s.asString()}") + } + } + timing.end().ifPresent { e -> + when { + e.isNumber() -> parts.add("leo-${formatNumber(e.asNumber())}") + e.isString() -> parts.add("leo-${e.asString()}") + } + } + timing.duration().ifPresent { d -> + when { + d.isNumber() -> parts.add("ldu-${formatNumber(d.asNumber())}") + d.isString() -> parts.add("ldu-${d.asString()}") + } + } + } + + /** + * Generates authentication parameters for client-side file uploads. + * + * @param token Optional custom token. If null or empty, a random token will be generated. + * @param expire Optional expiration timestamp in seconds. If 0 or null, defaults to 30 minutes + * from now. + * @return Map containing token, expire, and signature + */ + override fun getAuthenticationParameters(token: String?, expire: Long?): Map { + if (privateKey.isEmpty()) { + throw IllegalStateException( + "private API key is required for authentication parameters generation" + ) + } + + val defaultExpire = Instant.now().epochSecond + (60 * 30) // 30 minutes + val finalToken = + if (token.isNullOrEmpty()) { + generateToken() + } else { + token + } + + val finalExpire = + if (expire == null || expire == 0L) { + defaultExpire + } else { + expire + } + + val signature = getAuthenticationSignature(finalToken, finalExpire, privateKey) + + return mapOf("token" to finalToken, "expire" to finalExpire, "signature" to signature) + } + + // Private helper methods + + private fun getAuthenticationSignature( + token: String, + expire: Long, + privateKey: String, + ): String { + val signatureString = "$token$expire" + val mac = Mac.getInstance("HmacSHA1") + val secretKey = SecretKeySpec(privateKey.toByteArray(), "HmacSHA1") + mac.init(secretKey) + val hash = mac.doFinal(signatureString.toByteArray()) + + return hash.joinToString("") { "%02x".format(it) } + } + + private fun generateToken(): String { + val random = SecureRandom() + val bytes = ByteArray(16) + random.nextBytes(bytes) + return bytes.joinToString("") { "%02x".format(it) } + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/lib/HelperService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/lib/HelperService.kt new file mode 100644 index 00000000..93ab4792 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/lib/HelperService.kt @@ -0,0 +1,26 @@ +package com.imagekit.api.lib + +import com.imagekit.api.models.SrcOptions +import com.imagekit.api.models.Transformation + +/** + * Helper service interface for ImageKit SDK operations like URL building, transformation string + * generation, and authentication parameter generation. + * + * You should not instantiate this service directly, and instead use it via the client: + * ```java + * ImageKitClient client = ImageKitOkHttpClient.builder() + * .privateKey("private_key_xxx") + * .build(); + * + * String url = client.helper().buildUrl(srcOptions); + * ``` + */ +interface HelperService { + + fun buildUrl(options: SrcOptions): String + + fun buildTransformationString(transformations: List?): String + + fun getAuthenticationParameters(token: String? = null, expire: Long? = null): Map +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AiTag.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AiTag.kt new file mode 100644 index 00000000..59067439 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AiTag.kt @@ -0,0 +1,232 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * AI-generated tag associated with an image. These tags can be added using the + * `google-auto-tagging` or `aws-auto-tagging` extensions. + */ +class AiTag +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val confidence: JsonField, + private val name: JsonField, + private val source: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("confidence") + @ExcludeMissing + confidence: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + ) : this(confidence, name, source, mutableMapOf()) + + /** + * Confidence score of the tag. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun confidence(): Optional = confidence.getOptional("confidence") + + /** + * Name of the tag. + * + * @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") + + /** + * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * Returns the raw JSON value of [confidence]. + * + * Unlike [confidence], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("confidence") @ExcludeMissing fun _confidence(): JsonField = confidence + + /** + * 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 [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AiTag]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AiTag]. */ + class Builder internal constructor() { + + private var confidence: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var source: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(aiTag: AiTag) = apply { + confidence = aiTag.confidence + name = aiTag.name + source = aiTag.source + additionalProperties = aiTag.additionalProperties.toMutableMap() + } + + /** Confidence score of the tag. */ + fun confidence(confidence: Double) = confidence(JsonField.of(confidence)) + + /** + * Sets [Builder.confidence] to an arbitrary JSON value. + * + * You should usually call [Builder.confidence] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun confidence(confidence: JsonField) = apply { this.confidence = confidence } + + /** Name of the tag. */ + 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 } + + /** Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. */ + fun source(source: String) = source(JsonField.of(source)) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AiTag]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AiTag = AiTag(confidence, name, source, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): AiTag = apply { + if (validated) { + return@apply + } + + confidence() + name() + source() + 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 (confidence.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (source.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiTag && + confidence == other.confidence && + name == other.name && + source == other.source && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(confidence, name, source, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AiTag{confidence=$confidence, name=$name, source=$source, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/CustomMetadata.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/CustomMetadata.kt new file mode 100644 index 00000000..d9cbf73b --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/CustomMetadata.kt @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Objects + +/** A key-value data associated with the asset. */ +class CustomMetadata +@JsonCreator +private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map +) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CustomMetadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customMetadata: CustomMetadata) = apply { + additionalProperties = customMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CustomMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): CustomMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CustomMetadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/EmbeddedMetadata.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/EmbeddedMetadata.kt new file mode 100644 index 00000000..24ff0de0 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/EmbeddedMetadata.kt @@ -0,0 +1,112 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Objects + +/** + * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp data. + */ +class EmbeddedMetadata +@JsonCreator +private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map +) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [EmbeddedMetadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EmbeddedMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(embeddedMetadata: EmbeddedMetadata) = apply { + additionalProperties = embeddedMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EmbeddedMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): EmbeddedMetadata = EmbeddedMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): EmbeddedMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EmbeddedMetadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "EmbeddedMetadata{additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt index fce20326..f4f659d1 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt @@ -3306,7 +3306,7 @@ private constructor( fun value(bool: Boolean) = value(Value.ofBool(bool)) /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ - fun valueOfMixed(mixed: List) = + fun valueOfMixed(mixed: List) = value(Value.ofMixed(mixed)) fun additionalProperties(additionalProperties: Map) = @@ -3395,7 +3395,7 @@ private constructor( private val string: String? = null, private val number: Double? = null, private val bool: Boolean? = null, - private val mixed: List? = null, + private val mixed: List? = null, private val _json: JsonValue? = null, ) { @@ -3405,7 +3405,7 @@ private constructor( fun bool(): Optional = Optional.ofNullable(bool) - fun mixed(): Optional> = + fun mixed(): Optional> = Optional.ofNullable(mixed) fun isString(): Boolean = string != null @@ -3422,8 +3422,7 @@ private constructor( fun asBool(): Boolean = bool.getOrThrow("bool") - fun asMixed(): List = - mixed.getOrThrow("mixed") + fun asMixed(): List = mixed.getOrThrow("mixed") fun _json(): Optional = Optional.ofNullable(_json) @@ -3451,9 +3450,7 @@ private constructor( override fun visitBool(bool: Boolean) {} - override fun visitMixed( - mixed: List - ) { + override fun visitMixed(mixed: List) { mixed.forEach { it.validate() } } } @@ -3485,9 +3482,8 @@ private constructor( override fun visitBool(bool: Boolean) = 1 - override fun visitMixed( - mixed: List - ) = mixed.sumOf { it.validity().toInt() } + override fun visitMixed(mixed: List) = + mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -3526,7 +3522,7 @@ private constructor( @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) @JvmStatic - fun ofMixed(mixed: List) = + fun ofMixed(mixed: List) = Value(mixed = mixed.toImmutable()) } @@ -3542,7 +3538,7 @@ private constructor( fun visitBool(bool: Boolean): T - fun visitMixed(mixed: List): T + fun visitMixed(mixed: List): T /** * Maps an unknown variant of [Value] to a value of type [T]. @@ -3575,9 +3571,7 @@ private constructor( ?.let { Value(bool = it, _json = json) }, tryDeserialize( node, - jacksonTypeRef< - List - >(), + jacksonTypeRef>(), ) ?.let { Value(mixed = it, _json = json) }, ) @@ -3618,11 +3612,9 @@ private constructor( } } - @JsonDeserialize( - using = UnnamedSchemaWithArrayParent0.Deserializer::class - ) - @JsonSerialize(using = UnnamedSchemaWithArrayParent0.Serializer::class) - class UnnamedSchemaWithArrayParent0 + @JsonDeserialize(using = MetadataValueItem.Deserializer::class) + @JsonSerialize(using = MetadataValueItem.Serializer::class) + class MetadataValueItem private constructor( private val string: String? = null, private val number: Double? = null, @@ -3660,7 +3652,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent0 = apply { + fun validate(): MetadataValueItem = apply { if (validated) { return@apply } @@ -3710,7 +3702,7 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent0 && + return other is MetadataValueItem && string == other.string && number == other.number && bool == other.bool @@ -3720,37 +3712,31 @@ private constructor( override fun toString(): String = when { - string != null -> - "UnnamedSchemaWithArrayParent0{string=$string}" - number != null -> - "UnnamedSchemaWithArrayParent0{number=$number}" - bool != null -> "UnnamedSchemaWithArrayParent0{bool=$bool}" - _json != null -> - "UnnamedSchemaWithArrayParent0{_unknown=$_json}" + string != null -> "MetadataValueItem{string=$string}" + number != null -> "MetadataValueItem{number=$number}" + bool != null -> "MetadataValueItem{bool=$bool}" + _json != null -> "MetadataValueItem{_unknown=$_json}" else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent0" - ) + throw IllegalStateException("Invalid MetadataValueItem") } companion object { @JvmStatic fun ofString(string: String) = - UnnamedSchemaWithArrayParent0(string = string) + MetadataValueItem(string = string) @JvmStatic fun ofNumber(number: Double) = - UnnamedSchemaWithArrayParent0(number = number) + MetadataValueItem(number = number) @JvmStatic - fun ofBool(bool: Boolean) = - UnnamedSchemaWithArrayParent0(bool = bool) + fun ofBool(bool: Boolean) = MetadataValueItem(bool = bool) } /** * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent0] to a value of type [T]. + * [MetadataValueItem] to a value of type [T]. */ interface Visitor { @@ -3761,13 +3747,13 @@ private constructor( fun visitBool(bool: Boolean): T /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent0] to - * a value of type [T]. + * Maps an unknown variant of [MetadataValueItem] to a value of + * type [T]. * - * An instance of [UnnamedSchemaWithArrayParent0] can contain an - * unknown variant if it was deserialized from data that doesn't - * match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new + * An instance of [MetadataValueItem] can contain an unknown + * variant if it was deserialized from data that doesn't match + * any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new * variants that the SDK is unaware of. * * @throws ImageKitInvalidDataException in the default @@ -3775,40 +3761,38 @@ private constructor( */ fun unknown(json: JsonValue?): T { throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent0: $json" + "Unknown MetadataValueItem: $json" ) } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent0::class - ) { + BaseDeserializer(MetadataValueItem::class) { override fun ObjectCodec.deserialize( node: JsonNode - ): UnnamedSchemaWithArrayParent0 { + ): MetadataValueItem { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef()) ?.let { - UnnamedSchemaWithArrayParent0( + MetadataValueItem( string = it, _json = json, ) }, tryDeserialize(node, jacksonTypeRef()) ?.let { - UnnamedSchemaWithArrayParent0( + MetadataValueItem( number = it, _json = json, ) }, tryDeserialize(node, jacksonTypeRef()) ?.let { - UnnamedSchemaWithArrayParent0( + MetadataValueItem( bool = it, _json = json, ) @@ -3821,7 +3805,7 @@ private constructor( // This can happen if what we're deserializing is // completely incompatible with all the possible // variants (e.g. deserializing from object). - 0 -> UnnamedSchemaWithArrayParent0(_json = json) + 0 -> MetadataValueItem(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest // validity, then use the first completely valid match, @@ -3835,12 +3819,10 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent0::class - ) { + BaseSerializer(MetadataValueItem::class) { override fun serialize( - value: UnnamedSchemaWithArrayParent0, + value: MetadataValueItem, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -3854,7 +3836,7 @@ private constructor( generator.writeObject(value._json) else -> throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent0" + "Invalid MetadataValueItem" ) } } @@ -4549,7 +4531,7 @@ private constructor( fun value(bool: Boolean) = value(Value.ofBool(bool)) /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ - fun valueOfMixed(mixed: List) = + fun valueOfMixed(mixed: List) = value(Value.ofMixed(mixed)) fun additionalProperties(additionalProperties: Map) = @@ -4638,7 +4620,7 @@ private constructor( private val string: String? = null, private val number: Double? = null, private val bool: Boolean? = null, - private val mixed: List? = null, + private val mixed: List? = null, private val _json: JsonValue? = null, ) { @@ -4648,7 +4630,7 @@ private constructor( fun bool(): Optional = Optional.ofNullable(bool) - fun mixed(): Optional> = + fun mixed(): Optional> = Optional.ofNullable(mixed) fun isString(): Boolean = string != null @@ -4665,8 +4647,7 @@ private constructor( fun asBool(): Boolean = bool.getOrThrow("bool") - fun asMixed(): List = - mixed.getOrThrow("mixed") + fun asMixed(): List = mixed.getOrThrow("mixed") fun _json(): Optional = Optional.ofNullable(_json) @@ -4694,9 +4675,7 @@ private constructor( override fun visitBool(bool: Boolean) {} - override fun visitMixed( - mixed: List - ) { + override fun visitMixed(mixed: List) { mixed.forEach { it.validate() } } } @@ -4728,9 +4707,8 @@ private constructor( override fun visitBool(bool: Boolean) = 1 - override fun visitMixed( - mixed: List - ) = mixed.sumOf { it.validity().toInt() } + override fun visitMixed(mixed: List) = + mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -4769,7 +4747,7 @@ private constructor( @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) @JvmStatic - fun ofMixed(mixed: List) = + fun ofMixed(mixed: List) = Value(mixed = mixed.toImmutable()) } @@ -4785,7 +4763,7 @@ private constructor( fun visitBool(bool: Boolean): T - fun visitMixed(mixed: List): T + fun visitMixed(mixed: List): T /** * Maps an unknown variant of [Value] to a value of type [T]. @@ -4818,9 +4796,7 @@ private constructor( ?.let { Value(bool = it, _json = json) }, tryDeserialize( node, - jacksonTypeRef< - List - >(), + jacksonTypeRef>(), ) ?.let { Value(mixed = it, _json = json) }, ) @@ -4861,11 +4837,9 @@ private constructor( } } - @JsonDeserialize( - using = UnnamedSchemaWithArrayParent1.Deserializer::class - ) - @JsonSerialize(using = UnnamedSchemaWithArrayParent1.Serializer::class) - class UnnamedSchemaWithArrayParent1 + @JsonDeserialize(using = MetadataValueItem.Deserializer::class) + @JsonSerialize(using = MetadataValueItem.Serializer::class) + class MetadataValueItem private constructor( private val string: String? = null, private val number: Double? = null, @@ -4903,7 +4877,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent1 = apply { + fun validate(): MetadataValueItem = apply { if (validated) { return@apply } @@ -4953,7 +4927,7 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent1 && + return other is MetadataValueItem && string == other.string && number == other.number && bool == other.bool @@ -4963,37 +4937,31 @@ private constructor( override fun toString(): String = when { - string != null -> - "UnnamedSchemaWithArrayParent1{string=$string}" - number != null -> - "UnnamedSchemaWithArrayParent1{number=$number}" - bool != null -> "UnnamedSchemaWithArrayParent1{bool=$bool}" - _json != null -> - "UnnamedSchemaWithArrayParent1{_unknown=$_json}" + string != null -> "MetadataValueItem{string=$string}" + number != null -> "MetadataValueItem{number=$number}" + bool != null -> "MetadataValueItem{bool=$bool}" + _json != null -> "MetadataValueItem{_unknown=$_json}" else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent1" - ) + throw IllegalStateException("Invalid MetadataValueItem") } companion object { @JvmStatic fun ofString(string: String) = - UnnamedSchemaWithArrayParent1(string = string) + MetadataValueItem(string = string) @JvmStatic fun ofNumber(number: Double) = - UnnamedSchemaWithArrayParent1(number = number) + MetadataValueItem(number = number) @JvmStatic - fun ofBool(bool: Boolean) = - UnnamedSchemaWithArrayParent1(bool = bool) + fun ofBool(bool: Boolean) = MetadataValueItem(bool = bool) } /** * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent1] to a value of type [T]. + * [MetadataValueItem] to a value of type [T]. */ interface Visitor { @@ -5004,13 +4972,13 @@ private constructor( fun visitBool(bool: Boolean): T /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent1] to - * a value of type [T]. + * Maps an unknown variant of [MetadataValueItem] to a value of + * type [T]. * - * An instance of [UnnamedSchemaWithArrayParent1] can contain an - * unknown variant if it was deserialized from data that doesn't - * match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new + * An instance of [MetadataValueItem] can contain an unknown + * variant if it was deserialized from data that doesn't match + * any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new * variants that the SDK is unaware of. * * @throws ImageKitInvalidDataException in the default @@ -5018,40 +4986,38 @@ private constructor( */ fun unknown(json: JsonValue?): T { throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent1: $json" + "Unknown MetadataValueItem: $json" ) } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent1::class - ) { + BaseDeserializer(MetadataValueItem::class) { override fun ObjectCodec.deserialize( node: JsonNode - ): UnnamedSchemaWithArrayParent1 { + ): MetadataValueItem { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef()) ?.let { - UnnamedSchemaWithArrayParent1( + MetadataValueItem( string = it, _json = json, ) }, tryDeserialize(node, jacksonTypeRef()) ?.let { - UnnamedSchemaWithArrayParent1( + MetadataValueItem( number = it, _json = json, ) }, tryDeserialize(node, jacksonTypeRef()) ?.let { - UnnamedSchemaWithArrayParent1( + MetadataValueItem( bool = it, _json = json, ) @@ -5064,7 +5030,7 @@ private constructor( // This can happen if what we're deserializing is // completely incompatible with all the possible // variants (e.g. deserializing from object). - 0 -> UnnamedSchemaWithArrayParent1(_json = json) + 0 -> MetadataValueItem(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest // validity, then use the first completely valid match, @@ -5078,12 +5044,10 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent1::class - ) { + BaseSerializer(MetadataValueItem::class) { override fun serialize( - value: UnnamedSchemaWithArrayParent1, + value: MetadataValueItem, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -5097,7 +5061,7 @@ private constructor( generator.writeObject(value._json) else -> throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent1" + "Invalid MetadataValueItem" ) } } @@ -5790,7 +5754,7 @@ private constructor( fun value(bool: Boolean) = value(Value.ofBool(bool)) /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ - fun valueOfMixed(mixed: List) = + fun valueOfMixed(mixed: List) = value(Value.ofMixed(mixed)) fun additionalProperties(additionalProperties: Map) = @@ -5879,7 +5843,7 @@ private constructor( private val string: String? = null, private val number: Double? = null, private val bool: Boolean? = null, - private val mixed: List? = null, + private val mixed: List? = null, private val _json: JsonValue? = null, ) { @@ -5889,7 +5853,7 @@ private constructor( fun bool(): Optional = Optional.ofNullable(bool) - fun mixed(): Optional> = + fun mixed(): Optional> = Optional.ofNullable(mixed) fun isString(): Boolean = string != null @@ -5906,8 +5870,7 @@ private constructor( fun asBool(): Boolean = bool.getOrThrow("bool") - fun asMixed(): List = - mixed.getOrThrow("mixed") + fun asMixed(): List = mixed.getOrThrow("mixed") fun _json(): Optional = Optional.ofNullable(_json) @@ -5935,9 +5898,7 @@ private constructor( override fun visitBool(bool: Boolean) {} - override fun visitMixed( - mixed: List - ) { + override fun visitMixed(mixed: List) { mixed.forEach { it.validate() } } } @@ -5969,9 +5930,8 @@ private constructor( override fun visitBool(bool: Boolean) = 1 - override fun visitMixed( - mixed: List - ) = mixed.sumOf { it.validity().toInt() } + override fun visitMixed(mixed: List) = + mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 } @@ -6010,7 +5970,7 @@ private constructor( @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) @JvmStatic - fun ofMixed(mixed: List) = + fun ofMixed(mixed: List) = Value(mixed = mixed.toImmutable()) } @@ -6026,7 +5986,7 @@ private constructor( fun visitBool(bool: Boolean): T - fun visitMixed(mixed: List): T + fun visitMixed(mixed: List): T /** * Maps an unknown variant of [Value] to a value of type [T]. @@ -6059,9 +6019,7 @@ private constructor( ?.let { Value(bool = it, _json = json) }, tryDeserialize( node, - jacksonTypeRef< - List - >(), + jacksonTypeRef>(), ) ?.let { Value(mixed = it, _json = json) }, ) @@ -6102,11 +6060,9 @@ private constructor( } } - @JsonDeserialize( - using = UnnamedSchemaWithArrayParent2.Deserializer::class - ) - @JsonSerialize(using = UnnamedSchemaWithArrayParent2.Serializer::class) - class UnnamedSchemaWithArrayParent2 + @JsonDeserialize(using = MetadataValueItem.Deserializer::class) + @JsonSerialize(using = MetadataValueItem.Serializer::class) + class MetadataValueItem private constructor( private val string: String? = null, private val number: Double? = null, @@ -6144,7 +6100,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent2 = apply { + fun validate(): MetadataValueItem = apply { if (validated) { return@apply } @@ -6194,7 +6150,7 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent2 && + return other is MetadataValueItem && string == other.string && number == other.number && bool == other.bool @@ -6204,37 +6160,31 @@ private constructor( override fun toString(): String = when { - string != null -> - "UnnamedSchemaWithArrayParent2{string=$string}" - number != null -> - "UnnamedSchemaWithArrayParent2{number=$number}" - bool != null -> "UnnamedSchemaWithArrayParent2{bool=$bool}" - _json != null -> - "UnnamedSchemaWithArrayParent2{_unknown=$_json}" + string != null -> "MetadataValueItem{string=$string}" + number != null -> "MetadataValueItem{number=$number}" + bool != null -> "MetadataValueItem{bool=$bool}" + _json != null -> "MetadataValueItem{_unknown=$_json}" else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent2" - ) + throw IllegalStateException("Invalid MetadataValueItem") } companion object { @JvmStatic fun ofString(string: String) = - UnnamedSchemaWithArrayParent2(string = string) + MetadataValueItem(string = string) @JvmStatic fun ofNumber(number: Double) = - UnnamedSchemaWithArrayParent2(number = number) + MetadataValueItem(number = number) @JvmStatic - fun ofBool(bool: Boolean) = - UnnamedSchemaWithArrayParent2(bool = bool) + fun ofBool(bool: Boolean) = MetadataValueItem(bool = bool) } /** * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent2] to a value of type [T]. + * [MetadataValueItem] to a value of type [T]. */ interface Visitor { @@ -6245,13 +6195,13 @@ private constructor( fun visitBool(bool: Boolean): T /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent2] to - * a value of type [T]. + * Maps an unknown variant of [MetadataValueItem] to a value of + * type [T]. * - * An instance of [UnnamedSchemaWithArrayParent2] can contain an - * unknown variant if it was deserialized from data that doesn't - * match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new + * An instance of [MetadataValueItem] can contain an unknown + * variant if it was deserialized from data that doesn't match + * any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new * variants that the SDK is unaware of. * * @throws ImageKitInvalidDataException in the default @@ -6259,40 +6209,38 @@ private constructor( */ fun unknown(json: JsonValue?): T { throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent2: $json" + "Unknown MetadataValueItem: $json" ) } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent2::class - ) { + BaseDeserializer(MetadataValueItem::class) { override fun ObjectCodec.deserialize( node: JsonNode - ): UnnamedSchemaWithArrayParent2 { + ): MetadataValueItem { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef()) ?.let { - UnnamedSchemaWithArrayParent2( + MetadataValueItem( string = it, _json = json, ) }, tryDeserialize(node, jacksonTypeRef()) ?.let { - UnnamedSchemaWithArrayParent2( + MetadataValueItem( number = it, _json = json, ) }, tryDeserialize(node, jacksonTypeRef()) ?.let { - UnnamedSchemaWithArrayParent2( + MetadataValueItem( bool = it, _json = json, ) @@ -6305,7 +6253,7 @@ private constructor( // This can happen if what we're deserializing is // completely incompatible with all the possible // variants (e.g. deserializing from object). - 0 -> UnnamedSchemaWithArrayParent2(_json = json) + 0 -> MetadataValueItem(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest // validity, then use the first completely valid match, @@ -6319,12 +6267,10 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent2::class - ) { + BaseSerializer(MetadataValueItem::class) { override fun serialize( - value: UnnamedSchemaWithArrayParent2, + value: MetadataValueItem, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -6338,7 +6284,7 @@ private constructor( generator.writeObject(value._json) else -> throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent2" + "Invalid MetadataValueItem" ) } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionItem.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionItem.kt new file mode 100644 index 00000000..190388c3 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionItem.kt @@ -0,0 +1,6785 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.BaseDeserializer +import com.imagekit.api.core.BaseSerializer +import com.imagekit.api.core.Enum +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.allMaxBy +import com.imagekit.api.core.checkKnown +import com.imagekit.api.core.checkRequired +import com.imagekit.api.core.getOrThrow +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +@JsonDeserialize(using = ExtensionItem.Deserializer::class) +@JsonSerialize(using = ExtensionItem.Serializer::class) +class ExtensionItem +private constructor( + private val removeBg: RemoveBg? = null, + private val autoTaggingExtension: AutoTaggingExtension? = null, + private val aiAutoDescription: JsonValue? = null, + private val aiTasks: AiTasks? = null, + private val savedExtension: SavedExtension? = null, + private val _json: JsonValue? = null, +) { + + fun removeBg(): Optional = Optional.ofNullable(removeBg) + + fun autoTaggingExtension(): Optional = + Optional.ofNullable(autoTaggingExtension) + + fun aiAutoDescription(): Optional = Optional.ofNullable(aiAutoDescription) + + fun aiTasks(): Optional = Optional.ofNullable(aiTasks) + + fun savedExtension(): Optional = Optional.ofNullable(savedExtension) + + fun isRemoveBg(): Boolean = removeBg != null + + fun isAutoTaggingExtension(): Boolean = autoTaggingExtension != null + + fun isAiAutoDescription(): Boolean = aiAutoDescription != null + + fun isAiTasks(): Boolean = aiTasks != null + + fun isSavedExtension(): Boolean = savedExtension != null + + fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") + + fun asAutoTaggingExtension(): AutoTaggingExtension = + autoTaggingExtension.getOrThrow("autoTaggingExtension") + + fun asAiAutoDescription(): JsonValue = aiAutoDescription.getOrThrow("aiAutoDescription") + + fun asAiTasks(): AiTasks = aiTasks.getOrThrow("aiTasks") + + fun asSavedExtension(): SavedExtension = savedExtension.getOrThrow("savedExtension") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + removeBg != null -> visitor.visitRemoveBg(removeBg) + autoTaggingExtension != null -> visitor.visitAutoTaggingExtension(autoTaggingExtension) + aiAutoDescription != null -> visitor.visitAiAutoDescription(aiAutoDescription) + aiTasks != null -> visitor.visitAiTasks(aiTasks) + savedExtension != null -> visitor.visitSavedExtension(savedExtension) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ExtensionItem = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) { + removeBg.validate() + } + + override fun visitAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension) { + autoTaggingExtension.validate() + } + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { + aiAutoDescription.let { + if (it != JsonValue.from(mapOf("name" to "ai-auto-description"))) { + throw ImageKitInvalidDataException( + "'aiAutoDescription' is invalid, received $it" + ) + } + } + } + + override fun visitAiTasks(aiTasks: AiTasks) { + aiTasks.validate() + } + + override fun visitSavedExtension(savedExtension: SavedExtension) { + savedExtension.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() + + override fun visitAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension) = + autoTaggingExtension.validity() + + override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = + aiAutoDescription.let { + if (it == JsonValue.from(mapOf("name" to "ai-auto-description"))) 1 else 0 + } + + override fun visitAiTasks(aiTasks: AiTasks) = aiTasks.validity() + + override fun visitSavedExtension(savedExtension: SavedExtension) = + savedExtension.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExtensionItem && + removeBg == other.removeBg && + autoTaggingExtension == other.autoTaggingExtension && + aiAutoDescription == other.aiAutoDescription && + aiTasks == other.aiTasks && + savedExtension == other.savedExtension + } + + override fun hashCode(): Int = + Objects.hash(removeBg, autoTaggingExtension, aiAutoDescription, aiTasks, savedExtension) + + override fun toString(): String = + when { + removeBg != null -> "ExtensionItem{removeBg=$removeBg}" + autoTaggingExtension != null -> + "ExtensionItem{autoTaggingExtension=$autoTaggingExtension}" + aiAutoDescription != null -> "ExtensionItem{aiAutoDescription=$aiAutoDescription}" + aiTasks != null -> "ExtensionItem{aiTasks=$aiTasks}" + savedExtension != null -> "ExtensionItem{savedExtension=$savedExtension}" + _json != null -> "ExtensionItem{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ExtensionItem") + } + + companion object { + + @JvmStatic fun ofRemoveBg(removeBg: RemoveBg) = ExtensionItem(removeBg = removeBg) + + @JvmStatic + fun ofAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension) = + ExtensionItem(autoTaggingExtension = autoTaggingExtension) + + @JvmStatic + fun ofAiAutoDescription() = + ExtensionItem( + aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) + ) + + @JvmStatic fun ofAiTasks(aiTasks: AiTasks) = ExtensionItem(aiTasks = aiTasks) + + @JvmStatic + fun ofSavedExtension(savedExtension: SavedExtension) = + ExtensionItem(savedExtension = savedExtension) + } + + /** + * An interface that defines how to map each variant of [ExtensionItem] to a value of type [T]. + */ + interface Visitor { + + fun visitRemoveBg(removeBg: RemoveBg): T + + fun visitAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension): T + + fun visitAiAutoDescription(aiAutoDescription: JsonValue): T + + fun visitAiTasks(aiTasks: AiTasks): T + + fun visitSavedExtension(savedExtension: SavedExtension): T + + /** + * Maps an unknown variant of [ExtensionItem] to a value of type [T]. + * + * An instance of [ExtensionItem] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown ExtensionItem: $json") + } + } + + internal class Deserializer : BaseDeserializer(ExtensionItem::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ExtensionItem { + val json = JsonValue.fromJsonNode(node) + val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() + + when (name) { + "remove-bg" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + ExtensionItem(removeBg = it, _json = json) + } ?: ExtensionItem(_json = json) + } + "ai-auto-description" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { ExtensionItem(aiAutoDescription = it, _json = json) } + ?.takeIf { it.isValid() } ?: ExtensionItem(_json = json) + } + "ai-tasks" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + ExtensionItem(aiTasks = it, _json = json) + } ?: ExtensionItem(_json = json) + } + "saved-extension" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + ExtensionItem(savedExtension = it, _json = json) + } ?: ExtensionItem(_json = json) + } + } + + return tryDeserialize(node, jacksonTypeRef())?.let { + ExtensionItem(autoTaggingExtension = it, _json = json) + } ?: ExtensionItem(_json = json) + } + } + + internal class Serializer : BaseSerializer(ExtensionItem::class) { + + override fun serialize( + value: ExtensionItem, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.removeBg != null -> generator.writeObject(value.removeBg) + value.autoTaggingExtension != null -> + generator.writeObject(value.autoTaggingExtension) + value.aiAutoDescription != null -> generator.writeObject(value.aiAutoDescription) + value.aiTasks != null -> generator.writeObject(value.aiTasks) + value.savedExtension != null -> generator.writeObject(value.savedExtension) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ExtensionItem") + } + } + } + + class RemoveBg + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonValue, + private val options: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("options") @ExcludeMissing options: JsonField = JsonMissing.of(), + ) : this(name, options, mutableMapOf()) + + /** + * Specifies the background removal extension. + * + * Expected to always return the following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun options(): Optional = options.getOptional("options") + + /** + * Returns the raw JSON value of [options]. + * + * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveBg]. */ + class Builder internal constructor() { + + private var name: JsonValue = JsonValue.from("remove-bg") + private var options: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removeBg: RemoveBg) = apply { + name = removeBg.name + options = removeBg.options + additionalProperties = removeBg.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("remove-bg") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + fun options(options: Options) = options(JsonField.of(options)) + + /** + * Sets [Builder.options] to an arbitrary JSON value. + * + * You should usually call [Builder.options] with a well-typed [Options] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun options(options: JsonField) = apply { this.options = options } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RemoveBg]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RemoveBg = RemoveBg(name, options, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): RemoveBg = apply { + if (validated) { + return@apply + } + + _name().let { + if (it != JsonValue.from("remove-bg")) { + throw ImageKitInvalidDataException("'name' is invalid, received $it") + } + } + options().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + name.let { if (it == JsonValue.from("remove-bg")) 1 else 0 } + + (options.asKnown().getOrNull()?.validity() ?: 0) + + class Options + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val addShadow: JsonField, + private val bgColor: JsonField, + private val bgImageUrl: JsonField, + private val semitransparency: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("add_shadow") + @ExcludeMissing + addShadow: JsonField = JsonMissing.of(), + @JsonProperty("bg_color") + @ExcludeMissing + bgColor: JsonField = JsonMissing.of(), + @JsonProperty("bg_image_url") + @ExcludeMissing + bgImageUrl: JsonField = JsonMissing.of(), + @JsonProperty("semitransparency") + @ExcludeMissing + semitransparency: JsonField = JsonMissing.of(), + ) : this(addShadow, bgColor, bgImageUrl, semitransparency, mutableMapOf()) + + /** + * Whether to add an artificial shadow to the result. Default is false. Note: Adding + * shadows is currently only supported for car photos. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun addShadow(): Optional = addShadow.getOptional("add_shadow") + + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or color + * name (e.g., "green"). If this parameter is set, `bg_image_url` must be empty. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun bgColor(): Optional = bgColor.getOptional("bg_color") + + /** + * Sets a background image from a URL. If this parameter is set, `bg_color` must be + * empty. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun bgImageUrl(): Optional = bgImageUrl.getOptional("bg_image_url") + + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun semitransparency(): Optional = + semitransparency.getOptional("semitransparency") + + /** + * Returns the raw JSON value of [addShadow]. + * + * Unlike [addShadow], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("add_shadow") + @ExcludeMissing + fun _addShadow(): JsonField = addShadow + + /** + * Returns the raw JSON value of [bgColor]. + * + * Unlike [bgColor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bg_color") @ExcludeMissing fun _bgColor(): JsonField = bgColor + + /** + * Returns the raw JSON value of [bgImageUrl]. + * + * Unlike [bgImageUrl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("bg_image_url") + @ExcludeMissing + fun _bgImageUrl(): JsonField = bgImageUrl + + /** + * Returns the raw JSON value of [semitransparency]. + * + * Unlike [semitransparency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("semitransparency") + @ExcludeMissing + fun _semitransparency(): JsonField = semitransparency + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Options]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Options]. */ + class Builder internal constructor() { + + private var addShadow: JsonField = JsonMissing.of() + private var bgColor: JsonField = JsonMissing.of() + private var bgImageUrl: JsonField = JsonMissing.of() + private var semitransparency: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(options: Options) = apply { + addShadow = options.addShadow + bgColor = options.bgColor + bgImageUrl = options.bgImageUrl + semitransparency = options.semitransparency + additionalProperties = options.additionalProperties.toMutableMap() + } + + /** + * Whether to add an artificial shadow to the result. Default is false. Note: Adding + * shadows is currently only supported for car photos. + */ + fun addShadow(addShadow: Boolean) = addShadow(JsonField.of(addShadow)) + + /** + * Sets [Builder.addShadow] to an arbitrary JSON value. + * + * You should usually call [Builder.addShadow] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun addShadow(addShadow: JsonField) = apply { this.addShadow = addShadow } + + /** + * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or + * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be + * empty. + */ + fun bgColor(bgColor: String) = bgColor(JsonField.of(bgColor)) + + /** + * Sets [Builder.bgColor] to an arbitrary JSON value. + * + * You should usually call [Builder.bgColor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bgColor(bgColor: JsonField) = apply { this.bgColor = bgColor } + + /** + * Sets a background image from a URL. If this parameter is set, `bg_color` must be + * empty. + */ + fun bgImageUrl(bgImageUrl: String) = bgImageUrl(JsonField.of(bgImageUrl)) + + /** + * Sets [Builder.bgImageUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.bgImageUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bgImageUrl(bgImageUrl: JsonField) = apply { + this.bgImageUrl = bgImageUrl + } + + /** + * Allows semi-transparent regions in the result. Default is true. Note: + * Semitransparency is currently only supported for car windows. + */ + fun semitransparency(semitransparency: Boolean) = + semitransparency(JsonField.of(semitransparency)) + + /** + * Sets [Builder.semitransparency] to an arbitrary JSON value. + * + * You should usually call [Builder.semitransparency] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun semitransparency(semitransparency: JsonField) = apply { + this.semitransparency = semitransparency + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Options]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Options = + Options( + addShadow, + bgColor, + bgImageUrl, + semitransparency, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Options = apply { + if (validated) { + return@apply + } + + addShadow() + bgColor() + bgImageUrl() + semitransparency() + 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 (addShadow.asKnown().isPresent) 1 else 0) + + (if (bgColor.asKnown().isPresent) 1 else 0) + + (if (bgImageUrl.asKnown().isPresent) 1 else 0) + + (if (semitransparency.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Options && + addShadow == other.addShadow && + bgColor == other.bgColor && + bgImageUrl == other.bgImageUrl && + semitransparency == other.semitransparency && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(addShadow, bgColor, bgImageUrl, semitransparency, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RemoveBg && + name == other.name && + options == other.options && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, options, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" + } + + class AutoTaggingExtension + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val maxTags: JsonField, + private val minConfidence: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("maxTags") @ExcludeMissing maxTags: JsonField = JsonMissing.of(), + @JsonProperty("minConfidence") + @ExcludeMissing + minConfidence: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(maxTags, minConfidence, name, mutableMapOf()) + + /** + * Maximum number of tags to attach to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun maxTags(): Long = maxTags.getRequired("maxTags") + + /** + * Minimum confidence level for tags to be considered valid. + * + * @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 minConfidence(): Long = minConfidence.getRequired("minConfidence") + + /** + * Specifies the auto-tagging extension used. + * + * @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(): Name = name.getRequired("name") + + /** + * Returns the raw JSON value of [maxTags]. + * + * Unlike [maxTags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("maxTags") @ExcludeMissing fun _maxTags(): JsonField = maxTags + + /** + * Returns the raw JSON value of [minConfidence]. + * + * Unlike [minConfidence], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minConfidence") + @ExcludeMissing + fun _minConfidence(): JsonField = minConfidence + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AutoTaggingExtension]. + * + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutoTaggingExtension]. */ + class Builder internal constructor() { + + private var maxTags: JsonField? = null + private var minConfidence: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { + maxTags = autoTaggingExtension.maxTags + minConfidence = autoTaggingExtension.minConfidence + name = autoTaggingExtension.name + additionalProperties = autoTaggingExtension.additionalProperties.toMutableMap() + } + + /** Maximum number of tags to attach to the asset. */ + fun maxTags(maxTags: Long) = maxTags(JsonField.of(maxTags)) + + /** + * Sets [Builder.maxTags] to an arbitrary JSON value. + * + * You should usually call [Builder.maxTags] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxTags(maxTags: JsonField) = apply { this.maxTags = maxTags } + + /** Minimum confidence level for tags to be considered valid. */ + fun minConfidence(minConfidence: Long) = minConfidence(JsonField.of(minConfidence)) + + /** + * Sets [Builder.minConfidence] to an arbitrary JSON value. + * + * You should usually call [Builder.minConfidence] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun minConfidence(minConfidence: JsonField) = apply { + this.minConfidence = minConfidence + } + + /** Specifies the auto-tagging extension used. */ + fun name(name: Name) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [Name] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutoTaggingExtension]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .maxTags() + * .minConfidence() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutoTaggingExtension = + AutoTaggingExtension( + checkRequired("maxTags", maxTags), + checkRequired("minConfidence", minConfidence), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutoTaggingExtension = apply { + if (validated) { + return@apply + } + + maxTags() + minConfidence() + name().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (maxTags.asKnown().isPresent) 1 else 0) + + (if (minConfidence.asKnown().isPresent) 1 else 0) + + (name.asKnown().getOrNull()?.validity() ?: 0) + + /** Specifies the auto-tagging extension used. */ + class Name @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") + + @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + } + + /** + * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Name] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GOOGLE_AUTO_TAGGING, + AWS_AUTO_TAGGING, + /** An enum member indicating that [Name] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws ImageKitInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING + AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING + else -> throw ImageKitInvalidDataException("Unknown Name: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws ImageKitInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + ImageKitInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Name = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Name && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutoTaggingExtension && + maxTags == other.maxTags && + minConfidence == other.minConfidence && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(maxTags, minConfidence, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" + } + + class AiTasks + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonValue, + private val tasks: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("tasks") @ExcludeMissing tasks: JsonField> = JsonMissing.of(), + ) : this(name, tasks, mutableMapOf()) + + /** + * Specifies the AI tasks extension for automated image analysis using AI models. + * + * Expected to always return the following: + * ```java + * JsonValue.from("ai-tasks") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Array of task objects defining AI operations to perform on the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tasks(): List = tasks.getRequired("tasks") + + /** + * Returns the raw JSON value of [tasks]. + * + * Unlike [tasks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tasks") @ExcludeMissing fun _tasks(): JsonField> = tasks + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AiTasks]. + * + * The following fields are required: + * ```java + * .tasks() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AiTasks]. */ + class Builder internal constructor() { + + private var name: JsonValue = JsonValue.from("ai-tasks") + private var tasks: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(aiTasks: AiTasks) = apply { + name = aiTasks.name + tasks = aiTasks.tasks.map { it.toMutableList() } + additionalProperties = aiTasks.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("ai-tasks") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** Array of task objects defining AI operations to perform on the asset. */ + fun tasks(tasks: List) = tasks(JsonField.of(tasks)) + + /** + * Sets [Builder.tasks] to an arbitrary JSON value. + * + * You should usually call [Builder.tasks] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tasks(tasks: JsonField>) = apply { + this.tasks = tasks.map { it.toMutableList() } + } + + /** + * Adds a single [Task] to [tasks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTask(task: Task) = apply { + tasks = + (tasks ?: JsonField.of(mutableListOf())).also { + checkKnown("tasks", it).add(task) + } + } + + /** Alias for calling [addTask] with `Task.ofSelectTags(selectTags)`. */ + fun addTask(selectTags: Task.SelectTags) = addTask(Task.ofSelectTags(selectTags)) + + /** + * Alias for calling [addTask] with the following: + * ```java + * Task.SelectTags.builder() + * .instruction(instruction) + * .build() + * ``` + */ + fun addSelectTagsTask(instruction: String) = + addTask(Task.SelectTags.builder().instruction(instruction).build()) + + /** Alias for calling [addTask] with `Task.ofSelectMetadata(selectMetadata)`. */ + fun addTask(selectMetadata: Task.SelectMetadata) = + addTask(Task.ofSelectMetadata(selectMetadata)) + + /** Alias for calling [addTask] with `Task.ofYesNo(yesNo)`. */ + fun addTask(yesNo: Task.YesNo) = addTask(Task.ofYesNo(yesNo)) + + /** + * Alias for calling [addTask] with the following: + * ```java + * Task.YesNo.builder() + * .instruction(instruction) + * .build() + * ``` + */ + fun addYesNoTask(instruction: String) = + addTask(Task.YesNo.builder().instruction(instruction).build()) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AiTasks]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tasks() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AiTasks = + AiTasks( + name, + checkRequired("tasks", tasks).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AiTasks = apply { + if (validated) { + return@apply + } + + _name().let { + if (it != JsonValue.from("ai-tasks")) { + throw ImageKitInvalidDataException("'name' is invalid, received $it") + } + } + tasks().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + name.let { if (it == JsonValue.from("ai-tasks")) 1 else 0 } + + (tasks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + @JsonDeserialize(using = Task.Deserializer::class) + @JsonSerialize(using = Task.Serializer::class) + class Task + private constructor( + private val selectTags: SelectTags? = null, + private val selectMetadata: SelectMetadata? = null, + private val yesNo: YesNo? = null, + private val _json: JsonValue? = null, + ) { + + fun selectTags(): Optional = Optional.ofNullable(selectTags) + + fun selectMetadata(): Optional = Optional.ofNullable(selectMetadata) + + fun yesNo(): Optional = Optional.ofNullable(yesNo) + + fun isSelectTags(): Boolean = selectTags != null + + fun isSelectMetadata(): Boolean = selectMetadata != null + + fun isYesNo(): Boolean = yesNo != null + + fun asSelectTags(): SelectTags = selectTags.getOrThrow("selectTags") + + fun asSelectMetadata(): SelectMetadata = selectMetadata.getOrThrow("selectMetadata") + + fun asYesNo(): YesNo = yesNo.getOrThrow("yesNo") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + selectTags != null -> visitor.visitSelectTags(selectTags) + selectMetadata != null -> visitor.visitSelectMetadata(selectMetadata) + yesNo != null -> visitor.visitYesNo(yesNo) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Task = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitSelectTags(selectTags: SelectTags) { + selectTags.validate() + } + + override fun visitSelectMetadata(selectMetadata: SelectMetadata) { + selectMetadata.validate() + } + + override fun visitYesNo(yesNo: YesNo) { + yesNo.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitSelectTags(selectTags: SelectTags) = selectTags.validity() + + override fun visitSelectMetadata(selectMetadata: SelectMetadata) = + selectMetadata.validity() + + override fun visitYesNo(yesNo: YesNo) = yesNo.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Task && + selectTags == other.selectTags && + selectMetadata == other.selectMetadata && + yesNo == other.yesNo + } + + override fun hashCode(): Int = Objects.hash(selectTags, selectMetadata, yesNo) + + override fun toString(): String = + when { + selectTags != null -> "Task{selectTags=$selectTags}" + selectMetadata != null -> "Task{selectMetadata=$selectMetadata}" + yesNo != null -> "Task{yesNo=$yesNo}" + _json != null -> "Task{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Task") + } + + companion object { + + @JvmStatic fun ofSelectTags(selectTags: SelectTags) = Task(selectTags = selectTags) + + @JvmStatic + fun ofSelectMetadata(selectMetadata: SelectMetadata) = + Task(selectMetadata = selectMetadata) + + @JvmStatic fun ofYesNo(yesNo: YesNo) = Task(yesNo = yesNo) + } + + /** + * An interface that defines how to map each variant of [Task] to a value of type [T]. + */ + interface Visitor { + + fun visitSelectTags(selectTags: SelectTags): T + + fun visitSelectMetadata(selectMetadata: SelectMetadata): T + + fun visitYesNo(yesNo: YesNo): T + + /** + * Maps an unknown variant of [Task] to a value of type [T]. + * + * An instance of [Task] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Task: $json") + } + } + + internal class Deserializer : BaseDeserializer(Task::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Task { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "select_tags" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Task(selectTags = it, _json = json) + } ?: Task(_json = json) + } + "select_metadata" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Task(selectMetadata = it, _json = json) + } ?: Task(_json = json) + } + "yes_no" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Task(yesNo = it, _json = json) + } ?: Task(_json = json) + } + } + + return Task(_json = json) + } + } + + internal class Serializer : BaseSerializer(Task::class) { + + override fun serialize( + value: Task, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.selectTags != null -> generator.writeObject(value.selectTags) + value.selectMetadata != null -> generator.writeObject(value.selectMetadata) + value.yesNo != null -> generator.writeObject(value.yesNo) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Task") + } + } + } + + class SelectTags + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val instruction: JsonField, + private val type: JsonValue, + private val maxSelections: JsonField, + private val minSelections: JsonField, + private val vocabulary: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("instruction") + @ExcludeMissing + instruction: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("max_selections") + @ExcludeMissing + maxSelections: JsonField = JsonMissing.of(), + @JsonProperty("min_selections") + @ExcludeMissing + minSelections: JsonField = JsonMissing.of(), + @JsonProperty("vocabulary") + @ExcludeMissing + vocabulary: JsonField> = JsonMissing.of(), + ) : this( + instruction, + type, + maxSelections, + minSelections, + vocabulary, + mutableMapOf(), + ) + + /** + * The question or instruction for the AI to analyze the image. + * + * @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 instruction(): String = instruction.getRequired("instruction") + + /** + * Task type that analyzes the image and adds matching tags from a vocabulary. + * + * Expected to always return the following: + * ```java + * JsonValue.from("select_tags") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Maximum number of tags to select from the vocabulary. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun maxSelections(): Optional = maxSelections.getOptional("max_selections") + + /** + * Minimum number of tags to select from the vocabulary. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun minSelections(): Optional = minSelections.getOptional("min_selections") + + /** + * Array of possible tag values. The combined length of all strings must not exceed + * 500 characters, and values cannot include the `%` character. When providing large + * vocabularies (more than 30 items), the AI may not follow the list strictly. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun vocabulary(): Optional> = vocabulary.getOptional("vocabulary") + + /** + * Returns the raw JSON value of [instruction]. + * + * Unlike [instruction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("instruction") + @ExcludeMissing + fun _instruction(): JsonField = instruction + + /** + * Returns the raw JSON value of [maxSelections]. + * + * Unlike [maxSelections], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("max_selections") + @ExcludeMissing + fun _maxSelections(): JsonField = maxSelections + + /** + * Returns the raw JSON value of [minSelections]. + * + * Unlike [minSelections], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("min_selections") + @ExcludeMissing + fun _minSelections(): JsonField = minSelections + + /** + * Returns the raw JSON value of [vocabulary]. + * + * Unlike [vocabulary], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("vocabulary") + @ExcludeMissing + fun _vocabulary(): JsonField> = vocabulary + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SelectTags]. + * + * The following fields are required: + * ```java + * .instruction() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SelectTags]. */ + class Builder internal constructor() { + + private var instruction: JsonField? = null + private var type: JsonValue = JsonValue.from("select_tags") + private var maxSelections: JsonField = JsonMissing.of() + private var minSelections: JsonField = JsonMissing.of() + private var vocabulary: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(selectTags: SelectTags) = apply { + instruction = selectTags.instruction + type = selectTags.type + maxSelections = selectTags.maxSelections + minSelections = selectTags.minSelections + vocabulary = selectTags.vocabulary.map { it.toMutableList() } + additionalProperties = selectTags.additionalProperties.toMutableMap() + } + + /** The question or instruction for the AI to analyze the image. */ + fun instruction(instruction: String) = instruction(JsonField.of(instruction)) + + /** + * Sets [Builder.instruction] to an arbitrary JSON value. + * + * You should usually call [Builder.instruction] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun instruction(instruction: JsonField) = apply { + this.instruction = instruction + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("select_tags") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Maximum number of tags to select from the vocabulary. */ + fun maxSelections(maxSelections: Long) = + maxSelections(JsonField.of(maxSelections)) + + /** + * Sets [Builder.maxSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.maxSelections] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun maxSelections(maxSelections: JsonField) = apply { + this.maxSelections = maxSelections + } + + /** Minimum number of tags to select from the vocabulary. */ + fun minSelections(minSelections: Long) = + minSelections(JsonField.of(minSelections)) + + /** + * Sets [Builder.minSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.minSelections] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minSelections(minSelections: JsonField) = apply { + this.minSelections = minSelections + } + + /** + * Array of possible tag values. The combined length of all strings must not + * exceed 500 characters, and values cannot include the `%` character. When + * providing large vocabularies (more than 30 items), the AI may not follow the + * list strictly. + */ + fun vocabulary(vocabulary: List) = vocabulary(JsonField.of(vocabulary)) + + /** + * Sets [Builder.vocabulary] to an arbitrary JSON value. + * + * You should usually call [Builder.vocabulary] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun vocabulary(vocabulary: JsonField>) = apply { + this.vocabulary = vocabulary.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.vocabulary]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVocabulary(vocabulary: String) = apply { + this.vocabulary = + (this.vocabulary ?: JsonField.of(mutableListOf())).also { + checkKnown("vocabulary", it).add(vocabulary) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SelectTags]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .instruction() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SelectTags = + SelectTags( + checkRequired("instruction", instruction), + type, + maxSelections, + minSelections, + (vocabulary ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SelectTags = apply { + if (validated) { + return@apply + } + + instruction() + _type().let { + if (it != JsonValue.from("select_tags")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + maxSelections() + minSelections() + vocabulary() + 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 (instruction.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("select_tags")) 1 else 0 } + + (if (maxSelections.asKnown().isPresent) 1 else 0) + + (if (minSelections.asKnown().isPresent) 1 else 0) + + (vocabulary.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SelectTags && + instruction == other.instruction && + type == other.type && + maxSelections == other.maxSelections && + minSelections == other.minSelections && + vocabulary == other.vocabulary && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + instruction, + type, + maxSelections, + minSelections, + vocabulary, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SelectTags{instruction=$instruction, type=$type, maxSelections=$maxSelections, minSelections=$minSelections, vocabulary=$vocabulary, additionalProperties=$additionalProperties}" + } + + class SelectMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val instruction: JsonField, + private val type: JsonValue, + private val maxSelections: JsonField, + private val minSelections: JsonField, + private val vocabulary: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of(), + @JsonProperty("instruction") + @ExcludeMissing + instruction: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("max_selections") + @ExcludeMissing + maxSelections: JsonField = JsonMissing.of(), + @JsonProperty("min_selections") + @ExcludeMissing + minSelections: JsonField = JsonMissing.of(), + @JsonProperty("vocabulary") + @ExcludeMissing + vocabulary: JsonField> = JsonMissing.of(), + ) : this( + field, + instruction, + type, + maxSelections, + minSelections, + vocabulary, + mutableMapOf(), + ) + + /** + * Name of the custom metadata field to set. The field must exist in 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 field(): String = field.getRequired("field") + + /** + * The question or instruction for the AI to analyze the image. + * + * @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 instruction(): String = instruction.getRequired("instruction") + + /** + * Task type that analyzes the image and sets a custom metadata field value from a + * vocabulary. + * + * Expected to always return the following: + * ```java + * JsonValue.from("select_metadata") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Maximum number of values to select from the vocabulary. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun maxSelections(): Optional = maxSelections.getOptional("max_selections") + + /** + * Minimum number of values to select from the vocabulary. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun minSelections(): Optional = minSelections.getOptional("min_selections") + + /** + * An array of possible values matching the custom metadata field type. If not + * provided for SingleSelect or MultiSelect field types, all values from the custom + * metadata field definition will be used. When providing large vocabularies (above + * 30 items), the AI may not strictly adhere to the list. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun vocabulary(): Optional> = vocabulary.getOptional("vocabulary") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [instruction]. + * + * Unlike [instruction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("instruction") + @ExcludeMissing + fun _instruction(): JsonField = instruction + + /** + * Returns the raw JSON value of [maxSelections]. + * + * Unlike [maxSelections], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("max_selections") + @ExcludeMissing + fun _maxSelections(): JsonField = maxSelections + + /** + * Returns the raw JSON value of [minSelections]. + * + * Unlike [minSelections], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("min_selections") + @ExcludeMissing + fun _minSelections(): JsonField = minSelections + + /** + * Returns the raw JSON value of [vocabulary]. + * + * Unlike [vocabulary], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("vocabulary") + @ExcludeMissing + fun _vocabulary(): JsonField> = vocabulary + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SelectMetadata]. + * + * The following fields are required: + * ```java + * .field() + * .instruction() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SelectMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var instruction: JsonField? = null + private var type: JsonValue = JsonValue.from("select_metadata") + private var maxSelections: JsonField = JsonMissing.of() + private var minSelections: JsonField = JsonMissing.of() + private var vocabulary: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(selectMetadata: SelectMetadata) = apply { + field = selectMetadata.field + instruction = selectMetadata.instruction + type = selectMetadata.type + maxSelections = selectMetadata.maxSelections + minSelections = selectMetadata.minSelections + vocabulary = selectMetadata.vocabulary.map { it.toMutableList() } + additionalProperties = selectMetadata.additionalProperties.toMutableMap() + } + + /** + * Name of the custom metadata field to set. The field must exist in your + * account. + */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** The question or instruction for the AI to analyze the image. */ + fun instruction(instruction: String) = instruction(JsonField.of(instruction)) + + /** + * Sets [Builder.instruction] to an arbitrary JSON value. + * + * You should usually call [Builder.instruction] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun instruction(instruction: JsonField) = apply { + this.instruction = instruction + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("select_metadata") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Maximum number of values to select from the vocabulary. */ + fun maxSelections(maxSelections: Long) = + maxSelections(JsonField.of(maxSelections)) + + /** + * Sets [Builder.maxSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.maxSelections] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun maxSelections(maxSelections: JsonField) = apply { + this.maxSelections = maxSelections + } + + /** Minimum number of values to select from the vocabulary. */ + fun minSelections(minSelections: Long) = + minSelections(JsonField.of(minSelections)) + + /** + * Sets [Builder.minSelections] to an arbitrary JSON value. + * + * You should usually call [Builder.minSelections] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun minSelections(minSelections: JsonField) = apply { + this.minSelections = minSelections + } + + /** + * An array of possible values matching the custom metadata field type. If not + * provided for SingleSelect or MultiSelect field types, all values from the + * custom metadata field definition will be used. When providing large + * vocabularies (above 30 items), the AI may not strictly adhere to the list. + */ + fun vocabulary(vocabulary: List) = + vocabulary(JsonField.of(vocabulary)) + + /** + * Sets [Builder.vocabulary] to an arbitrary JSON value. + * + * You should usually call [Builder.vocabulary] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun vocabulary(vocabulary: JsonField>) = apply { + this.vocabulary = vocabulary.map { it.toMutableList() } + } + + /** + * Adds a single [Vocabulary] to [Builder.vocabulary]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addVocabulary(vocabulary: Vocabulary) = apply { + this.vocabulary = + (this.vocabulary ?: JsonField.of(mutableListOf())).also { + checkKnown("vocabulary", it).add(vocabulary) + } + } + + /** Alias for calling [addVocabulary] with `Vocabulary.ofString(string)`. */ + fun addVocabulary(string: String) = addVocabulary(Vocabulary.ofString(string)) + + /** Alias for calling [addVocabulary] with `Vocabulary.ofNumber(number)`. */ + fun addVocabulary(number: Double) = addVocabulary(Vocabulary.ofNumber(number)) + + /** Alias for calling [addVocabulary] with `Vocabulary.ofBool(bool)`. */ + fun addVocabulary(bool: Boolean) = addVocabulary(Vocabulary.ofBool(bool)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SelectMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .field() + * .instruction() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SelectMetadata = + SelectMetadata( + checkRequired("field", field), + checkRequired("instruction", instruction), + type, + maxSelections, + minSelections, + (vocabulary ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SelectMetadata = apply { + if (validated) { + return@apply + } + + field() + instruction() + _type().let { + if (it != JsonValue.from("select_metadata")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + maxSelections() + minSelections() + vocabulary().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (field.asKnown().isPresent) 1 else 0) + + (if (instruction.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("select_metadata")) 1 else 0 } + + (if (maxSelections.asKnown().isPresent) 1 else 0) + + (if (minSelections.asKnown().isPresent) 1 else 0) + + (vocabulary.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + @JsonDeserialize(using = Vocabulary.Deserializer::class) + @JsonSerialize(using = Vocabulary.Serializer::class) + class Vocabulary + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Vocabulary = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Vocabulary && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> "Vocabulary{string=$string}" + number != null -> "Vocabulary{number=$number}" + bool != null -> "Vocabulary{bool=$bool}" + _json != null -> "Vocabulary{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Vocabulary") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Vocabulary(string = string) + + @JvmStatic fun ofNumber(number: Double) = Vocabulary(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Vocabulary(bool = bool) + } + + /** + * An interface that defines how to map each variant of [Vocabulary] to a value + * of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [Vocabulary] to a value of type [T]. + * + * An instance of [Vocabulary] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the API may respond + * with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Vocabulary: $json") + } + } + + internal class Deserializer : BaseDeserializer(Vocabulary::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Vocabulary { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Vocabulary(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Vocabulary(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Vocabulary(bool = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing + // from object). + 0 -> Vocabulary(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Vocabulary::class) { + + override fun serialize( + value: Vocabulary, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Vocabulary") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SelectMetadata && + field == other.field && + instruction == other.instruction && + type == other.type && + maxSelections == other.maxSelections && + minSelections == other.minSelections && + vocabulary == other.vocabulary && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + field, + instruction, + type, + maxSelections, + minSelections, + vocabulary, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SelectMetadata{field=$field, instruction=$instruction, type=$type, maxSelections=$maxSelections, minSelections=$minSelections, vocabulary=$vocabulary, additionalProperties=$additionalProperties}" + } + + class YesNo + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val instruction: JsonField, + private val type: JsonValue, + private val onNo: JsonField, + private val onUnknown: JsonField, + private val onYes: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("instruction") + @ExcludeMissing + instruction: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("on_no") @ExcludeMissing onNo: JsonField = JsonMissing.of(), + @JsonProperty("on_unknown") + @ExcludeMissing + onUnknown: JsonField = JsonMissing.of(), + @JsonProperty("on_yes") + @ExcludeMissing + onYes: JsonField = JsonMissing.of(), + ) : this(instruction, type, onNo, onUnknown, onYes, mutableMapOf()) + + /** + * The yes/no question for the AI to answer about the image. + * + * @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 instruction(): String = instruction.getRequired("instruction") + + /** + * Task type that asks a yes/no question and executes actions based on the answer. + * + * Expected to always return the following: + * ```java + * JsonValue.from("yes_no") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Actions to execute if the AI answers no. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun onNo(): Optional = onNo.getOptional("on_no") + + /** + * Actions to execute if the AI cannot determine the answer. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun onUnknown(): Optional = onUnknown.getOptional("on_unknown") + + /** + * Actions to execute if the AI answers yes. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun onYes(): Optional = onYes.getOptional("on_yes") + + /** + * Returns the raw JSON value of [instruction]. + * + * Unlike [instruction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("instruction") + @ExcludeMissing + fun _instruction(): JsonField = instruction + + /** + * Returns the raw JSON value of [onNo]. + * + * Unlike [onNo], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("on_no") @ExcludeMissing fun _onNo(): JsonField = onNo + + /** + * Returns the raw JSON value of [onUnknown]. + * + * Unlike [onUnknown], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("on_unknown") + @ExcludeMissing + fun _onUnknown(): JsonField = onUnknown + + /** + * Returns the raw JSON value of [onYes]. + * + * Unlike [onYes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("on_yes") @ExcludeMissing fun _onYes(): JsonField = onYes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [YesNo]. + * + * The following fields are required: + * ```java + * .instruction() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [YesNo]. */ + class Builder internal constructor() { + + private var instruction: JsonField? = null + private var type: JsonValue = JsonValue.from("yes_no") + private var onNo: JsonField = JsonMissing.of() + private var onUnknown: JsonField = JsonMissing.of() + private var onYes: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(yesNo: YesNo) = apply { + instruction = yesNo.instruction + type = yesNo.type + onNo = yesNo.onNo + onUnknown = yesNo.onUnknown + onYes = yesNo.onYes + additionalProperties = yesNo.additionalProperties.toMutableMap() + } + + /** The yes/no question for the AI to answer about the image. */ + fun instruction(instruction: String) = instruction(JsonField.of(instruction)) + + /** + * Sets [Builder.instruction] to an arbitrary JSON value. + * + * You should usually call [Builder.instruction] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun instruction(instruction: JsonField) = apply { + this.instruction = instruction + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("yes_no") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Actions to execute if the AI answers no. */ + fun onNo(onNo: OnNo) = onNo(JsonField.of(onNo)) + + /** + * Sets [Builder.onNo] to an arbitrary JSON value. + * + * You should usually call [Builder.onNo] with a well-typed [OnNo] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun onNo(onNo: JsonField) = apply { this.onNo = onNo } + + /** Actions to execute if the AI cannot determine the answer. */ + fun onUnknown(onUnknown: OnUnknown) = onUnknown(JsonField.of(onUnknown)) + + /** + * Sets [Builder.onUnknown] to an arbitrary JSON value. + * + * You should usually call [Builder.onUnknown] with a well-typed [OnUnknown] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun onUnknown(onUnknown: JsonField) = apply { + this.onUnknown = onUnknown + } + + /** Actions to execute if the AI answers yes. */ + fun onYes(onYes: OnYes) = onYes(JsonField.of(onYes)) + + /** + * Sets [Builder.onYes] to an arbitrary JSON value. + * + * You should usually call [Builder.onYes] with a well-typed [OnYes] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun onYes(onYes: JsonField) = apply { this.onYes = onYes } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [YesNo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .instruction() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): YesNo = + YesNo( + checkRequired("instruction", instruction), + type, + onNo, + onUnknown, + onYes, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): YesNo = apply { + if (validated) { + return@apply + } + + instruction() + _type().let { + if (it != JsonValue.from("yes_no")) { + throw ImageKitInvalidDataException("'type' is invalid, received $it") + } + } + onNo().ifPresent { it.validate() } + onUnknown().ifPresent { it.validate() } + onYes().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (instruction.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("yes_no")) 1 else 0 } + + (onNo.asKnown().getOrNull()?.validity() ?: 0) + + (onUnknown.asKnown().getOrNull()?.validity() ?: 0) + + (onYes.asKnown().getOrNull()?.validity() ?: 0) + + /** Actions to execute if the AI answers no. */ + class OnNo + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val addTags: JsonField>, + private val removeTags: JsonField>, + private val setMetadata: JsonField>, + private val unsetMetadata: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("add_tags") + @ExcludeMissing + addTags: JsonField> = JsonMissing.of(), + @JsonProperty("remove_tags") + @ExcludeMissing + removeTags: JsonField> = JsonMissing.of(), + @JsonProperty("set_metadata") + @ExcludeMissing + setMetadata: JsonField> = JsonMissing.of(), + @JsonProperty("unset_metadata") + @ExcludeMissing + unsetMetadata: JsonField> = JsonMissing.of(), + ) : this(addTags, removeTags, setMetadata, unsetMetadata, mutableMapOf()) + + /** + * Array of tag strings to add to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun addTags(): Optional> = addTags.getOptional("add_tags") + + /** + * Array of tag strings to remove from the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun removeTags(): Optional> = removeTags.getOptional("remove_tags") + + /** + * Array of custom metadata field updates. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun setMetadata(): Optional> = + setMetadata.getOptional("set_metadata") + + /** + * Array of custom metadata fields to remove. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun unsetMetadata(): Optional> = + unsetMetadata.getOptional("unset_metadata") + + /** + * Returns the raw JSON value of [addTags]. + * + * Unlike [addTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_tags") + @ExcludeMissing + fun _addTags(): JsonField> = addTags + + /** + * Returns the raw JSON value of [removeTags]. + * + * Unlike [removeTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("remove_tags") + @ExcludeMissing + fun _removeTags(): JsonField> = removeTags + + /** + * Returns the raw JSON value of [setMetadata]. + * + * Unlike [setMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("set_metadata") + @ExcludeMissing + fun _setMetadata(): JsonField> = setMetadata + + /** + * Returns the raw JSON value of [unsetMetadata]. + * + * Unlike [unsetMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unset_metadata") + @ExcludeMissing + fun _unsetMetadata(): JsonField> = unsetMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [OnNo]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OnNo]. */ + class Builder internal constructor() { + + private var addTags: JsonField>? = null + private var removeTags: JsonField>? = null + private var setMetadata: JsonField>? = null + private var unsetMetadata: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(onNo: OnNo) = apply { + addTags = onNo.addTags.map { it.toMutableList() } + removeTags = onNo.removeTags.map { it.toMutableList() } + setMetadata = onNo.setMetadata.map { it.toMutableList() } + unsetMetadata = onNo.unsetMetadata.map { it.toMutableList() } + additionalProperties = onNo.additionalProperties.toMutableMap() + } + + /** Array of tag strings to add to the asset. */ + fun addTags(addTags: List) = addTags(JsonField.of(addTags)) + + /** + * Sets [Builder.addTags] to an arbitrary JSON value. + * + * You should usually call [Builder.addTags] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun addTags(addTags: JsonField>) = apply { + this.addTags = addTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [addTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAddTag(addTag: String) = apply { + addTags = + (addTags ?: JsonField.of(mutableListOf())).also { + checkKnown("addTags", it).add(addTag) + } + } + + /** Array of tag strings to remove from the asset. */ + fun removeTags(removeTags: List) = + removeTags(JsonField.of(removeTags)) + + /** + * Sets [Builder.removeTags] to an arbitrary JSON value. + * + * You should usually call [Builder.removeTags] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun removeTags(removeTags: JsonField>) = apply { + this.removeTags = removeTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [removeTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addRemoveTag(removeTag: String) = apply { + removeTags = + (removeTags ?: JsonField.of(mutableListOf())).also { + checkKnown("removeTags", it).add(removeTag) + } + } + + /** Array of custom metadata field updates. */ + fun setMetadata(setMetadata: List) = + setMetadata(JsonField.of(setMetadata)) + + /** + * Sets [Builder.setMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.setMetadata] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun setMetadata(setMetadata: JsonField>) = apply { + this.setMetadata = setMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [SetMetadata] to [Builder.setMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addSetMetadata(setMetadata: SetMetadata) = apply { + this.setMetadata = + (this.setMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("setMetadata", it).add(setMetadata) + } + } + + /** Array of custom metadata fields to remove. */ + fun unsetMetadata(unsetMetadata: List) = + unsetMetadata(JsonField.of(unsetMetadata)) + + /** + * Sets [Builder.unsetMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.unsetMetadata] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unsetMetadata(unsetMetadata: JsonField>) = apply { + this.unsetMetadata = unsetMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { + this.unsetMetadata = + (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("unsetMetadata", it).add(unsetMetadata) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OnNo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OnNo = + OnNo( + (addTags ?: JsonMissing.of()).map { it.toImmutable() }, + (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, + (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + (unsetMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OnNo = apply { + if (validated) { + return@apply + } + + addTags() + removeTags() + setMetadata().ifPresent { it.forEach { it.validate() } } + unsetMetadata().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (addTags.asKnown().getOrNull()?.size ?: 0) + + (removeTags.asKnown().getOrNull()?.size ?: 0) + + (setMetadata.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (unsetMetadata.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + class SetMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this(field, value, mutableMapOf()) + + /** + * Name of the custom metadata field to set. + * + * @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 field(): String = field.getRequired("field") + + /** + * Value to set for the custom metadata field. The value type should match + * the custom metadata field type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun value(): Value = value.getRequired("value") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(setMetadata: SetMetadata) = apply { + field = setMetadata.field + value = setMetadata.value + additionalProperties = + setMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to set. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + */ + fun value(value: Value) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ + fun valueOfMixed(mixed: List) = + value(Value.ofMixed(mixed)) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SetMetadata = + SetMetadata( + checkRequired("field", field), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SetMetadata = apply { + if (validated) { + return@apply + } + + field() + value().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (field.asKnown().isPresent) 1 else 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Value to set for the custom metadata field. The value type should match + * the custom metadata field type. + */ + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val mixed: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun mixed(): Optional> = + Optional.ofNullable(mixed) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isMixed(): Boolean = mixed != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asMixed(): List = mixed.getOrThrow("mixed") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + mixed != null -> visitor.visitMixed(mixed) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitMixed(mixed: List) { + mixed.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitMixed(mixed: List) = + mixed.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + string == other.string && + number == other.number && + bool == other.bool && + mixed == other.mixed + } + + override fun hashCode(): Int = Objects.hash(string, number, bool, mixed) + + override fun toString(): String = + when { + string != null -> "Value{string=$string}" + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + mixed != null -> "Value{mixed=$mixed}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic + fun ofMixed(mixed: List) = + Value(mixed = mixed.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Value] to a + * value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitMixed(mixed: List): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the + * API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Value: $json") + } + } + + internal class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Value(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Value(number = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Value(bool = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef>(), + ) + ?.let { Value(mixed = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. + // deserializing from object). + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, + // then use the first completely valid match, or simply the + // first match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.mixed != null -> generator.writeObject(value.mixed) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + + @JsonDeserialize(using = MetadataValueItem.Deserializer::class) + @JsonSerialize(using = MetadataValueItem.Serializer::class) + class MetadataValueItem + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): MetadataValueItem = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetadataValueItem && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> "MetadataValueItem{string=$string}" + number != null -> "MetadataValueItem{number=$number}" + bool != null -> "MetadataValueItem{bool=$bool}" + _json != null -> "MetadataValueItem{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid MetadataValueItem") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + MetadataValueItem(string = string) + + @JvmStatic + fun ofNumber(number: Double) = + MetadataValueItem(number = number) + + @JvmStatic + fun ofBool(bool: Boolean) = MetadataValueItem(bool = bool) + } + + /** + * An interface that defines how to map each variant of + * [MetadataValueItem] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [MetadataValueItem] to a value of + * type [T]. + * + * An instance of [MetadataValueItem] can contain an unknown + * variant if it was deserialized from data that doesn't match + * any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown MetadataValueItem: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer(MetadataValueItem::class) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): MetadataValueItem { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { + MetadataValueItem( + string = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + MetadataValueItem( + number = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + MetadataValueItem( + bool = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is + // completely incompatible with all the possible + // variants (e.g. deserializing from object). + 0 -> MetadataValueItem(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest + // validity, then use the first completely valid match, + // or simply the first match if none are completely + // valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(MetadataValueItem::class) { + + override fun serialize( + value: MetadataValueItem, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid MetadataValueItem" + ) + } + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SetMetadata && + field == other.field && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" + } + + class UnsetMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of() + ) : this(field, mutableMapOf()) + + /** + * Name of the custom metadata field to remove. + * + * @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 field(): String = field.getRequired("field") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnsetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnsetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unsetMetadata: UnsetMetadata) = apply { + field = unsetMetadata.field + additionalProperties = + unsetMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to remove. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnsetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnsetMetadata = + UnsetMetadata( + checkRequired("field", field), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnsetMetadata = apply { + if (validated) { + return@apply + } + + field() + 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 (field.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnsetMetadata && + field == other.field && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OnNo && + addTags == other.addTags && + removeTags == other.removeTags && + setMetadata == other.setMetadata && + unsetMetadata == other.unsetMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addTags, + removeTags, + setMetadata, + unsetMetadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OnNo{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" + } + + /** Actions to execute if the AI cannot determine the answer. */ + class OnUnknown + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val addTags: JsonField>, + private val removeTags: JsonField>, + private val setMetadata: JsonField>, + private val unsetMetadata: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("add_tags") + @ExcludeMissing + addTags: JsonField> = JsonMissing.of(), + @JsonProperty("remove_tags") + @ExcludeMissing + removeTags: JsonField> = JsonMissing.of(), + @JsonProperty("set_metadata") + @ExcludeMissing + setMetadata: JsonField> = JsonMissing.of(), + @JsonProperty("unset_metadata") + @ExcludeMissing + unsetMetadata: JsonField> = JsonMissing.of(), + ) : this(addTags, removeTags, setMetadata, unsetMetadata, mutableMapOf()) + + /** + * Array of tag strings to add to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun addTags(): Optional> = addTags.getOptional("add_tags") + + /** + * Array of tag strings to remove from the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun removeTags(): Optional> = removeTags.getOptional("remove_tags") + + /** + * Array of custom metadata field updates. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun setMetadata(): Optional> = + setMetadata.getOptional("set_metadata") + + /** + * Array of custom metadata fields to remove. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun unsetMetadata(): Optional> = + unsetMetadata.getOptional("unset_metadata") + + /** + * Returns the raw JSON value of [addTags]. + * + * Unlike [addTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_tags") + @ExcludeMissing + fun _addTags(): JsonField> = addTags + + /** + * Returns the raw JSON value of [removeTags]. + * + * Unlike [removeTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("remove_tags") + @ExcludeMissing + fun _removeTags(): JsonField> = removeTags + + /** + * Returns the raw JSON value of [setMetadata]. + * + * Unlike [setMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("set_metadata") + @ExcludeMissing + fun _setMetadata(): JsonField> = setMetadata + + /** + * Returns the raw JSON value of [unsetMetadata]. + * + * Unlike [unsetMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unset_metadata") + @ExcludeMissing + fun _unsetMetadata(): JsonField> = unsetMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OnUnknown]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OnUnknown]. */ + class Builder internal constructor() { + + private var addTags: JsonField>? = null + private var removeTags: JsonField>? = null + private var setMetadata: JsonField>? = null + private var unsetMetadata: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(onUnknown: OnUnknown) = apply { + addTags = onUnknown.addTags.map { it.toMutableList() } + removeTags = onUnknown.removeTags.map { it.toMutableList() } + setMetadata = onUnknown.setMetadata.map { it.toMutableList() } + unsetMetadata = onUnknown.unsetMetadata.map { it.toMutableList() } + additionalProperties = onUnknown.additionalProperties.toMutableMap() + } + + /** Array of tag strings to add to the asset. */ + fun addTags(addTags: List) = addTags(JsonField.of(addTags)) + + /** + * Sets [Builder.addTags] to an arbitrary JSON value. + * + * You should usually call [Builder.addTags] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun addTags(addTags: JsonField>) = apply { + this.addTags = addTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [addTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAddTag(addTag: String) = apply { + addTags = + (addTags ?: JsonField.of(mutableListOf())).also { + checkKnown("addTags", it).add(addTag) + } + } + + /** Array of tag strings to remove from the asset. */ + fun removeTags(removeTags: List) = + removeTags(JsonField.of(removeTags)) + + /** + * Sets [Builder.removeTags] to an arbitrary JSON value. + * + * You should usually call [Builder.removeTags] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun removeTags(removeTags: JsonField>) = apply { + this.removeTags = removeTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [removeTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addRemoveTag(removeTag: String) = apply { + removeTags = + (removeTags ?: JsonField.of(mutableListOf())).also { + checkKnown("removeTags", it).add(removeTag) + } + } + + /** Array of custom metadata field updates. */ + fun setMetadata(setMetadata: List) = + setMetadata(JsonField.of(setMetadata)) + + /** + * Sets [Builder.setMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.setMetadata] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun setMetadata(setMetadata: JsonField>) = apply { + this.setMetadata = setMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [SetMetadata] to [Builder.setMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addSetMetadata(setMetadata: SetMetadata) = apply { + this.setMetadata = + (this.setMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("setMetadata", it).add(setMetadata) + } + } + + /** Array of custom metadata fields to remove. */ + fun unsetMetadata(unsetMetadata: List) = + unsetMetadata(JsonField.of(unsetMetadata)) + + /** + * Sets [Builder.unsetMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.unsetMetadata] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unsetMetadata(unsetMetadata: JsonField>) = apply { + this.unsetMetadata = unsetMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { + this.unsetMetadata = + (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("unsetMetadata", it).add(unsetMetadata) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OnUnknown]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OnUnknown = + OnUnknown( + (addTags ?: JsonMissing.of()).map { it.toImmutable() }, + (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, + (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + (unsetMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OnUnknown = apply { + if (validated) { + return@apply + } + + addTags() + removeTags() + setMetadata().ifPresent { it.forEach { it.validate() } } + unsetMetadata().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (addTags.asKnown().getOrNull()?.size ?: 0) + + (removeTags.asKnown().getOrNull()?.size ?: 0) + + (setMetadata.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (unsetMetadata.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + class SetMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this(field, value, mutableMapOf()) + + /** + * Name of the custom metadata field to set. + * + * @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 field(): String = field.getRequired("field") + + /** + * Value to set for the custom metadata field. The value type should match + * the custom metadata field type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun value(): Value = value.getRequired("value") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(setMetadata: SetMetadata) = apply { + field = setMetadata.field + value = setMetadata.value + additionalProperties = + setMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to set. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + */ + fun value(value: Value) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ + fun valueOfMixed(mixed: List) = + value(Value.ofMixed(mixed)) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SetMetadata = + SetMetadata( + checkRequired("field", field), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SetMetadata = apply { + if (validated) { + return@apply + } + + field() + value().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (field.asKnown().isPresent) 1 else 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Value to set for the custom metadata field. The value type should match + * the custom metadata field type. + */ + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val mixed: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun mixed(): Optional> = + Optional.ofNullable(mixed) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isMixed(): Boolean = mixed != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asMixed(): List = mixed.getOrThrow("mixed") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + mixed != null -> visitor.visitMixed(mixed) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitMixed(mixed: List) { + mixed.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitMixed(mixed: List) = + mixed.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + string == other.string && + number == other.number && + bool == other.bool && + mixed == other.mixed + } + + override fun hashCode(): Int = Objects.hash(string, number, bool, mixed) + + override fun toString(): String = + when { + string != null -> "Value{string=$string}" + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + mixed != null -> "Value{mixed=$mixed}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic + fun ofMixed(mixed: List) = + Value(mixed = mixed.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Value] to a + * value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitMixed(mixed: List): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the + * API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Value: $json") + } + } + + internal class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Value(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Value(number = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Value(bool = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef>(), + ) + ?.let { Value(mixed = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. + // deserializing from object). + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, + // then use the first completely valid match, or simply the + // first match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.mixed != null -> generator.writeObject(value.mixed) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + + @JsonDeserialize(using = MetadataValueItem.Deserializer::class) + @JsonSerialize(using = MetadataValueItem.Serializer::class) + class MetadataValueItem + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): MetadataValueItem = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetadataValueItem && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> "MetadataValueItem{string=$string}" + number != null -> "MetadataValueItem{number=$number}" + bool != null -> "MetadataValueItem{bool=$bool}" + _json != null -> "MetadataValueItem{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid MetadataValueItem") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + MetadataValueItem(string = string) + + @JvmStatic + fun ofNumber(number: Double) = + MetadataValueItem(number = number) + + @JvmStatic + fun ofBool(bool: Boolean) = MetadataValueItem(bool = bool) + } + + /** + * An interface that defines how to map each variant of + * [MetadataValueItem] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [MetadataValueItem] to a value of + * type [T]. + * + * An instance of [MetadataValueItem] can contain an unknown + * variant if it was deserialized from data that doesn't match + * any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown MetadataValueItem: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer(MetadataValueItem::class) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): MetadataValueItem { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { + MetadataValueItem( + string = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + MetadataValueItem( + number = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + MetadataValueItem( + bool = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is + // completely incompatible with all the possible + // variants (e.g. deserializing from object). + 0 -> MetadataValueItem(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest + // validity, then use the first completely valid match, + // or simply the first match if none are completely + // valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(MetadataValueItem::class) { + + override fun serialize( + value: MetadataValueItem, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid MetadataValueItem" + ) + } + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SetMetadata && + field == other.field && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" + } + + class UnsetMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of() + ) : this(field, mutableMapOf()) + + /** + * Name of the custom metadata field to remove. + * + * @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 field(): String = field.getRequired("field") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnsetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnsetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unsetMetadata: UnsetMetadata) = apply { + field = unsetMetadata.field + additionalProperties = + unsetMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to remove. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnsetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnsetMetadata = + UnsetMetadata( + checkRequired("field", field), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnsetMetadata = apply { + if (validated) { + return@apply + } + + field() + 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 (field.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnsetMetadata && + field == other.field && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OnUnknown && + addTags == other.addTags && + removeTags == other.removeTags && + setMetadata == other.setMetadata && + unsetMetadata == other.unsetMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addTags, + removeTags, + setMetadata, + unsetMetadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OnUnknown{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" + } + + /** Actions to execute if the AI answers yes. */ + class OnYes + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val addTags: JsonField>, + private val removeTags: JsonField>, + private val setMetadata: JsonField>, + private val unsetMetadata: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("add_tags") + @ExcludeMissing + addTags: JsonField> = JsonMissing.of(), + @JsonProperty("remove_tags") + @ExcludeMissing + removeTags: JsonField> = JsonMissing.of(), + @JsonProperty("set_metadata") + @ExcludeMissing + setMetadata: JsonField> = JsonMissing.of(), + @JsonProperty("unset_metadata") + @ExcludeMissing + unsetMetadata: JsonField> = JsonMissing.of(), + ) : this(addTags, removeTags, setMetadata, unsetMetadata, mutableMapOf()) + + /** + * Array of tag strings to add to the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun addTags(): Optional> = addTags.getOptional("add_tags") + + /** + * Array of tag strings to remove from the asset. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun removeTags(): Optional> = removeTags.getOptional("remove_tags") + + /** + * Array of custom metadata field updates. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun setMetadata(): Optional> = + setMetadata.getOptional("set_metadata") + + /** + * Array of custom metadata fields to remove. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun unsetMetadata(): Optional> = + unsetMetadata.getOptional("unset_metadata") + + /** + * Returns the raw JSON value of [addTags]. + * + * Unlike [addTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("add_tags") + @ExcludeMissing + fun _addTags(): JsonField> = addTags + + /** + * Returns the raw JSON value of [removeTags]. + * + * Unlike [removeTags], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("remove_tags") + @ExcludeMissing + fun _removeTags(): JsonField> = removeTags + + /** + * Returns the raw JSON value of [setMetadata]. + * + * Unlike [setMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("set_metadata") + @ExcludeMissing + fun _setMetadata(): JsonField> = setMetadata + + /** + * Returns the raw JSON value of [unsetMetadata]. + * + * Unlike [unsetMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("unset_metadata") + @ExcludeMissing + fun _unsetMetadata(): JsonField> = unsetMetadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [OnYes]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OnYes]. */ + class Builder internal constructor() { + + private var addTags: JsonField>? = null + private var removeTags: JsonField>? = null + private var setMetadata: JsonField>? = null + private var unsetMetadata: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(onYes: OnYes) = apply { + addTags = onYes.addTags.map { it.toMutableList() } + removeTags = onYes.removeTags.map { it.toMutableList() } + setMetadata = onYes.setMetadata.map { it.toMutableList() } + unsetMetadata = onYes.unsetMetadata.map { it.toMutableList() } + additionalProperties = onYes.additionalProperties.toMutableMap() + } + + /** Array of tag strings to add to the asset. */ + fun addTags(addTags: List) = addTags(JsonField.of(addTags)) + + /** + * Sets [Builder.addTags] to an arbitrary JSON value. + * + * You should usually call [Builder.addTags] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun addTags(addTags: JsonField>) = apply { + this.addTags = addTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [addTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addAddTag(addTag: String) = apply { + addTags = + (addTags ?: JsonField.of(mutableListOf())).also { + checkKnown("addTags", it).add(addTag) + } + } + + /** Array of tag strings to remove from the asset. */ + fun removeTags(removeTags: List) = + removeTags(JsonField.of(removeTags)) + + /** + * Sets [Builder.removeTags] to an arbitrary JSON value. + * + * You should usually call [Builder.removeTags] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun removeTags(removeTags: JsonField>) = apply { + this.removeTags = removeTags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [removeTags]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addRemoveTag(removeTag: String) = apply { + removeTags = + (removeTags ?: JsonField.of(mutableListOf())).also { + checkKnown("removeTags", it).add(removeTag) + } + } + + /** Array of custom metadata field updates. */ + fun setMetadata(setMetadata: List) = + setMetadata(JsonField.of(setMetadata)) + + /** + * Sets [Builder.setMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.setMetadata] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun setMetadata(setMetadata: JsonField>) = apply { + this.setMetadata = setMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [SetMetadata] to [Builder.setMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addSetMetadata(setMetadata: SetMetadata) = apply { + this.setMetadata = + (this.setMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("setMetadata", it).add(setMetadata) + } + } + + /** Array of custom metadata fields to remove. */ + fun unsetMetadata(unsetMetadata: List) = + unsetMetadata(JsonField.of(unsetMetadata)) + + /** + * Sets [Builder.unsetMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.unsetMetadata] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun unsetMetadata(unsetMetadata: JsonField>) = apply { + this.unsetMetadata = unsetMetadata.map { it.toMutableList() } + } + + /** + * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { + this.unsetMetadata = + (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { + checkKnown("unsetMetadata", it).add(unsetMetadata) + } + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OnYes]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): OnYes = + OnYes( + (addTags ?: JsonMissing.of()).map { it.toImmutable() }, + (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, + (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + (unsetMetadata ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OnYes = apply { + if (validated) { + return@apply + } + + addTags() + removeTags() + setMetadata().ifPresent { it.forEach { it.validate() } } + unsetMetadata().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (addTags.asKnown().getOrNull()?.size ?: 0) + + (removeTags.asKnown().getOrNull()?.size ?: 0) + + (setMetadata.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (unsetMetadata.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + class SetMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this(field, value, mutableMapOf()) + + /** + * Name of the custom metadata field to set. + * + * @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 field(): String = field.getRequired("field") + + /** + * Value to set for the custom metadata field. The value type should match + * the custom metadata field type. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun value(): Value = value.getRequired("value") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(setMetadata: SetMetadata) = apply { + field = setMetadata.field + value = setMetadata.value + additionalProperties = + setMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to set. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + /** + * Value to set for the custom metadata field. The value type should + * match the custom metadata field type. + */ + fun value(value: Value) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ + fun valueOfMixed(mixed: List) = + value(Value.ofMixed(mixed)) + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SetMetadata = + SetMetadata( + checkRequired("field", field), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SetMetadata = apply { + if (validated) { + return@apply + } + + field() + value().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (field.asKnown().isPresent) 1 else 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Value to set for the custom metadata field. The value type should match + * the custom metadata field type. + */ + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val mixed: List? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun mixed(): Optional> = + Optional.ofNullable(mixed) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isMixed(): Boolean = mixed != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asMixed(): List = mixed.getOrThrow("mixed") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + mixed != null -> visitor.visitMixed(mixed) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitMixed(mixed: List) { + mixed.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitMixed(mixed: List) = + mixed.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + string == other.string && + number == other.number && + bool == other.bool && + mixed == other.mixed + } + + override fun hashCode(): Int = Objects.hash(string, number, bool, mixed) + + override fun toString(): String = + when { + string != null -> "Value{string=$string}" + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + mixed != null -> "Value{mixed=$mixed}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic + fun ofMixed(mixed: List) = + Value(mixed = mixed.toImmutable()) + } + + /** + * An interface that defines how to map each variant of [Value] to a + * value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitMixed(mixed: List): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For + * example, if the SDK is on an older version than the API, then the + * API may respond with new variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException("Unknown Value: $json") + } + } + + internal class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Value(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Value(number = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Value(bool = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef>(), + ) + ?.let { Value(mixed = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. + // deserializing from object). + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, + // then use the first completely valid match, or simply the + // first match if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.mixed != null -> generator.writeObject(value.mixed) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + + @JsonDeserialize(using = MetadataValueItem.Deserializer::class) + @JsonSerialize(using = MetadataValueItem.Serializer::class) + class MetadataValueItem + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): MetadataValueItem = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MetadataValueItem && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> "MetadataValueItem{string=$string}" + number != null -> "MetadataValueItem{number=$number}" + bool != null -> "MetadataValueItem{bool=$bool}" + _json != null -> "MetadataValueItem{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid MetadataValueItem") + } + + companion object { + + @JvmStatic + fun ofString(string: String) = + MetadataValueItem(string = string) + + @JvmStatic + fun ofNumber(number: Double) = + MetadataValueItem(number = number) + + @JvmStatic + fun ofBool(bool: Boolean) = MetadataValueItem(bool = bool) + } + + /** + * An interface that defines how to map each variant of + * [MetadataValueItem] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [MetadataValueItem] to a value of + * type [T]. + * + * An instance of [MetadataValueItem] can contain an unknown + * variant if it was deserialized from data that doesn't match + * any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws ImageKitInvalidDataException in the default + * implementation. + */ + fun unknown(json: JsonValue?): T { + throw ImageKitInvalidDataException( + "Unknown MetadataValueItem: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer(MetadataValueItem::class) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): MetadataValueItem { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { + MetadataValueItem( + string = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + MetadataValueItem( + number = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + MetadataValueItem( + bool = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is + // completely incompatible with all the possible + // variants (e.g. deserializing from object). + 0 -> MetadataValueItem(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest + // validity, then use the first completely valid match, + // or simply the first match if none are completely + // valid. + else -> + bestMatches.firstOrNull { it.isValid() } + ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(MetadataValueItem::class) { + + override fun serialize( + value: MetadataValueItem, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> + generator.writeObject(value.string) + value.number != null -> + generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> + generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid MetadataValueItem" + ) + } + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SetMetadata && + field == other.field && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" + } + + class UnsetMetadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val field: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("field") + @ExcludeMissing + field: JsonField = JsonMissing.of() + ) : this(field, mutableMapOf()) + + /** + * Name of the custom metadata field to remove. + * + * @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 field(): String = field.getRequired("field") + + /** + * Returns the raw JSON value of [field]. + * + * Unlike [field], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("field") + @ExcludeMissing + fun _field(): JsonField = field + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnsetMetadata]. + * + * The following fields are required: + * ```java + * .field() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnsetMetadata]. */ + class Builder internal constructor() { + + private var field: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(unsetMetadata: UnsetMetadata) = apply { + field = unsetMetadata.field + additionalProperties = + unsetMetadata.additionalProperties.toMutableMap() + } + + /** Name of the custom metadata field to remove. */ + fun field(field: String) = field(JsonField.of(field)) + + /** + * Sets [Builder.field] to an arbitrary JSON value. + * + * You should usually call [Builder.field] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun field(field: JsonField) = apply { this.field = field } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnsetMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .field() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnsetMetadata = + UnsetMetadata( + checkRequired("field", field), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnsetMetadata = apply { + if (validated) { + return@apply + } + + field() + 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 (field.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnsetMetadata && + field == other.field && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(field, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OnYes && + addTags == other.addTags && + removeTags == other.removeTags && + setMetadata == other.setMetadata && + unsetMetadata == other.unsetMetadata && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addTags, + removeTags, + setMetadata, + unsetMetadata, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OnYes{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is YesNo && + instruction == other.instruction && + type == other.type && + onNo == other.onNo && + onUnknown == other.onUnknown && + onYes == other.onYes && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(instruction, type, onNo, onUnknown, onYes, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "YesNo{instruction=$instruction, type=$type, onNo=$onNo, onUnknown=$onUnknown, onYes=$onYes, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AiTasks && + name == other.name && + tasks == other.tasks && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, tasks, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AiTasks{name=$name, tasks=$tasks, additionalProperties=$additionalProperties}" + } + + class SavedExtension + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val name: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + ) : this(id, name, mutableMapOf()) + + /** + * The unique ID of the saved extension to apply. + * + * @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") + + /** + * Indicates this is a reference to a saved extension. + * + * Expected to always return the following: + * ```java + * JsonValue.from("saved-extension") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SavedExtension]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SavedExtension]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var name: JsonValue = JsonValue.from("saved-extension") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(savedExtension: SavedExtension) = apply { + id = savedExtension.id + name = savedExtension.name + additionalProperties = savedExtension.additionalProperties.toMutableMap() + } + + /** The unique ID of the saved extension to apply. */ + 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 } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("saved-extension") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SavedExtension]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SavedExtension = + SavedExtension(checkRequired("id", id), name, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): SavedExtension = apply { + if (validated) { + return@apply + } + + id() + _name().let { + if (it != JsonValue.from("saved-extension")) { + throw ImageKitInvalidDataException("'name' is invalid, received $it") + } + } + 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) + + name.let { if (it == JsonValue.from("saved-extension")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SavedExtension && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SavedExtension{id=$id, name=$name, additionalProperties=$additionalProperties}" + } +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SelectedFieldsSchema.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SelectedFieldsSchema.kt new file mode 100644 index 00000000..5e3b22bd --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SelectedFieldsSchema.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.toImmutable +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Objects + +/** + * This field is included in the response only if the Path policy feature is available in the plan. + * It contains schema definitions for the custom metadata fields selected for the specified file + * path. Field selection can only be done when the Path policy feature is enabled. + * + * Keys are the names of the custom metadata fields; the value object has details about the custom + * metadata schema. + */ +class SelectedFieldsSchema +@JsonCreator +private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map +) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [SelectedFieldsSchema]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SelectedFieldsSchema]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(selectedFieldsSchema: SelectedFieldsSchema) = apply { + additionalProperties = selectedFieldsSchema.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SelectedFieldsSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SelectedFieldsSchema = SelectedFieldsSchema(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): SelectedFieldsSchema = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SelectedFieldsSchema && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "SelectedFieldsSchema{additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VersionInfo.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VersionInfo.kt new file mode 100644 index 00000000..c912f75d --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VersionInfo.kt @@ -0,0 +1,190 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.imagekit.api.core.ExcludeMissing +import com.imagekit.api.core.JsonField +import com.imagekit.api.core.JsonMissing +import com.imagekit.api.core.JsonValue +import com.imagekit.api.errors.ImageKitInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** An object containing the file or file version's `id` (versionId) and `name`. */ +class VersionInfo +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, name, mutableMapOf()) + + /** + * Unique identifier of the file version. + * + * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * Name of the file version. + * + * @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") + + /** + * 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 [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [VersionInfo]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VersionInfo]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(versionInfo: VersionInfo) = apply { + id = versionInfo.id + name = versionInfo.name + additionalProperties = versionInfo.additionalProperties.toMutableMap() + } + + /** Unique identifier of the file version. */ + 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 } + + /** Name of the file version. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [VersionInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VersionInfo = VersionInfo(id, name, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): VersionInfo = apply { + if (validated) { + return@apply + } + + id() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: ImageKitInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VersionInfo && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VersionInfo{id=$id, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt index 43895867..a752cdf1 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt @@ -7,13 +7,13 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.imagekit.api.core.BaseSerializer import com.imagekit.api.core.Enum import com.imagekit.api.core.ExcludeMissing import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField import com.imagekit.api.core.Params @@ -22,9 +22,10 @@ import com.imagekit.api.core.checkRequired import com.imagekit.api.core.getOrThrow import com.imagekit.api.core.http.Headers import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.core.jsonMapper import com.imagekit.api.core.toImmutable import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 +import com.imagekit.api.models.ExtensionItem import java.io.InputStream import java.nio.file.Path import java.util.Collections @@ -149,7 +150,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun extensions(): Optional> = body.extensions() + fun extensions(): Optional> = body.extensions() /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, @@ -252,7 +253,7 @@ private constructor( * @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() + fun transformation(): Optional = body.transformation() /** * Whether to use a unique filename for this file or not. @@ -336,7 +337,7 @@ private constructor( * * Unlike [extensions], this method doesn't throw if the multipart field has an unexpected type. */ - fun _extensions(): MultipartField> = body._extensions() + fun _extensions(): MultipartField> = body._extensions() /** * Returns the raw multipart value of [folder]. @@ -414,7 +415,7 @@ private constructor( * Unlike [transformation], this method doesn't throw if the multipart field has an unexpected * type. */ - fun _transformation(): MultipartField = body._transformation() + fun _transformation(): MultipartField = body._transformation() /** * Returns the raw multipart value of [useUniqueFileName]. @@ -634,84 +635,66 @@ private constructor( * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ - fun extensions(extensions: List) = apply { - body.extensions(extensions) - } + fun extensions(extensions: List) = apply { body.extensions(extensions) } /** * Sets [Builder.extensions] to an arbitrary multipart value. * - * You should usually call [Builder.extensions] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * You should usually call [Builder.extensions] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun extensions(extensions: MultipartField>) = apply { + fun extensions(extensions: MultipartField>) = apply { body.extensions(extensions) } /** - * Adds a single [UnnamedSchemaWithArrayParent4] to [extensions]. + * Adds a single [ExtensionItem] to [extensions]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addExtension(extension: UnnamedSchemaWithArrayParent4) = apply { - body.addExtension(extension) - } + fun addExtension(extension: ExtensionItem) = apply { body.addExtension(extension) } - /** - * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofRemoveBg(removeBg)`. - */ - fun addExtension(removeBg: UnnamedSchemaWithArrayParent4.RemoveBg) = apply { - body.addExtension(removeBg) - } + /** Alias for calling [addExtension] with `ExtensionItem.ofRemoveBg(removeBg)`. */ + fun addExtension(removeBg: ExtensionItem.RemoveBg) = apply { body.addExtension(removeBg) } /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension(autoTaggingExtension)`. + * `ExtensionItem.ofAutoTaggingExtension(autoTaggingExtension)`. */ - fun addExtension(autoTaggingExtension: UnnamedSchemaWithArrayParent4.AutoTaggingExtension) = - apply { - body.addExtension(autoTaggingExtension) - } + fun addExtension(autoTaggingExtension: ExtensionItem.AutoTaggingExtension) = apply { + body.addExtension(autoTaggingExtension) + } - /** - * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofAiAutoDescription()`. - */ + /** Alias for calling [addExtension] with `ExtensionItem.ofAiAutoDescription()`. */ fun addExtensionAiAutoDescription() = apply { body.addExtensionAiAutoDescription() } - /** - * Alias for calling [addExtension] with `UnnamedSchemaWithArrayParent4.ofAiTasks(aiTasks)`. - */ - fun addExtension(aiTasks: UnnamedSchemaWithArrayParent4.AiTasks) = apply { - body.addExtension(aiTasks) - } + /** Alias for calling [addExtension] with `ExtensionItem.ofAiTasks(aiTasks)`. */ + fun addExtension(aiTasks: ExtensionItem.AiTasks) = apply { body.addExtension(aiTasks) } /** * Alias for calling [addExtension] with the following: * ```java - * UnnamedSchemaWithArrayParent4.AiTasks.builder() + * ExtensionItem.AiTasks.builder() * .tasks(tasks) * .build() * ``` */ - fun addAiTasksExtension(tasks: List) = apply { + fun addAiTasksExtension(tasks: List) = apply { body.addAiTasksExtension(tasks) } /** - * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofSavedExtension(savedExtension)`. + * Alias for calling [addExtension] with `ExtensionItem.ofSavedExtension(savedExtension)`. */ - fun addExtension(savedExtension: UnnamedSchemaWithArrayParent4.SavedExtension) = apply { + fun addExtension(savedExtension: ExtensionItem.SavedExtension) = apply { body.addExtension(savedExtension) } /** * Alias for calling [addExtension] with the following: * ```java - * UnnamedSchemaWithArrayParent4.SavedExtension.builder() + * ExtensionItem.SavedExtension.builder() * .id(id) * .build() * ``` @@ -904,18 +887,18 @@ private constructor( * * You can mix and match any combination of post-processing types. */ - fun transformation(transformation: Transformation) = apply { + fun transformation(transformation: UploadTransformation) = apply { body.transformation(transformation) } /** * Sets [Builder.transformation] to an arbitrary multipart value. * - * You should usually call [Builder.transformation] with a well-typed [Transformation] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.transformation] with a well-typed [UploadTransformation] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun transformation(transformation: MultipartField) = apply { + fun transformation(transformation: MultipartField) = apply { body.transformation(transformation) } @@ -1101,9 +1084,9 @@ private constructor( "token" to _token(), "checks" to _checks(), "customCoordinates" to _customCoordinates(), - "customMetadata" to _customMetadata(), + "customMetadata" to _toJsonString(_customMetadata()), "description" to _description(), - "extensions" to _extensions(), + "extensions" to _toJsonString(_extensions()), "folder" to _folder(), "isPrivateFile" to _isPrivateFile(), "isPublished" to _isPublished(), @@ -1111,14 +1094,44 @@ private constructor( "overwriteCustomMetadata" to _overwriteCustomMetadata(), "overwriteFile" to _overwriteFile(), "overwriteTags" to _overwriteTags(), - "responseFields" to _responseFields(), - "tags" to _tags(), - "transformation" to _transformation(), + "responseFields" to _toCommaSeparated(_responseFields()), + "tags" to _toCommaSeparated(_tags()), + "transformation" to _toJsonString(_transformation()), "useUniqueFileName" to _useUniqueFileName(), "webhookUrl" to _webhookUrl(), ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) .toImmutable() + private fun _toJsonString(field: MultipartField<*>): MultipartField { + if (field.value.isMissing() || field.value.isNull()) { + @Suppress("UNCHECKED_CAST") + return field as MultipartField + } + val jsonString = jsonMapper().writeValueAsString(field.value) + return MultipartField.of(jsonString) + } + + private fun _toCommaSeparated(field: MultipartField<*>): MultipartField { + if (field.value.isMissing() || field.value.isNull()) { + @Suppress("UNCHECKED_CAST") + return field as MultipartField + } + val mapper = jsonMapper() + val node = mapper.valueToTree(field.value) + if (!node.isArray) { + @Suppress("UNCHECKED_CAST") + return field as MultipartField + } + val csv = + node + .elements() + .asSequence() + .filter { !it.isNull && !it.isMissingNode } + .map { it.asText() } + .joinToString(",") + return MultipartField.of(csv) + } + override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @@ -1132,7 +1145,7 @@ private constructor( private val customCoordinates: MultipartField, private val customMetadata: MultipartField, private val description: MultipartField, - private val extensions: MultipartField>, + private val extensions: MultipartField>, private val folder: MultipartField, private val isPrivateFile: MultipartField, private val isPublished: MultipartField, @@ -1142,7 +1155,7 @@ private constructor( private val overwriteTags: MultipartField, private val responseFields: MultipartField>, private val tags: MultipartField>, - private val transformation: MultipartField, + private val transformation: MultipartField, private val useUniqueFileName: MultipartField, private val webhookUrl: MultipartField, private val additionalProperties: MutableMap, @@ -1237,8 +1250,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun extensions(): Optional> = - extensions.value.getOptional("extensions") + fun extensions(): Optional> = extensions.value.getOptional("extensions") /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist @@ -1345,7 +1357,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun transformation(): Optional = + fun transformation(): Optional = transformation.value.getOptional("transformation") /** @@ -1441,7 +1453,7 @@ private constructor( */ @JsonProperty("extensions") @ExcludeMissing - fun _extensions(): MultipartField> = extensions + fun _extensions(): MultipartField> = extensions /** * Returns the raw multipart value of [folder]. @@ -1535,7 +1547,7 @@ private constructor( */ @JsonProperty("transformation") @ExcludeMissing - fun _transformation(): MultipartField = transformation + fun _transformation(): MultipartField = transformation /** * Returns the raw multipart value of [useUniqueFileName]. @@ -1593,8 +1605,7 @@ private constructor( private var customCoordinates: MultipartField = MultipartField.of(null) private var customMetadata: MultipartField = MultipartField.of(null) private var description: MultipartField = MultipartField.of(null) - private var extensions: MultipartField>? = - null + private var extensions: MultipartField>? = null private var folder: MultipartField = MultipartField.of(null) private var isPrivateFile: MultipartField = MultipartField.of(null) private var isPublished: MultipartField = MultipartField.of(null) @@ -1604,7 +1615,8 @@ private constructor( private var overwriteTags: MultipartField = MultipartField.of(null) private var responseFields: MultipartField>? = null private var tags: MultipartField>? = null - private var transformation: MultipartField = MultipartField.of(null) + private var transformation: MultipartField = + MultipartField.of(null) private var useUniqueFileName: MultipartField = MultipartField.of(null) private var webhookUrl: MultipartField = MultipartField.of(null) private var additionalProperties: MutableMap = mutableMapOf() @@ -1794,93 +1806,78 @@ private constructor( * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ - fun extensions(extensions: List) = + fun extensions(extensions: List) = extensions(MultipartField.of(extensions)) /** * Sets [Builder.extensions] to an arbitrary multipart value. * - * You should usually call [Builder.extensions] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.extensions] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun extensions(extensions: MultipartField>) = - apply { - this.extensions = extensions.map { it.toMutableList() } - } + fun extensions(extensions: MultipartField>) = apply { + this.extensions = extensions.map { it.toMutableList() } + } /** - * Adds a single [UnnamedSchemaWithArrayParent4] to [extensions]. + * Adds a single [ExtensionItem] to [extensions]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addExtension(extension: UnnamedSchemaWithArrayParent4) = apply { + fun addExtension(extension: ExtensionItem) = apply { extensions = (extensions ?: MultipartField.of(mutableListOf())).also { checkKnown("extensions", it).add(extension) } } - /** - * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofRemoveBg(removeBg)`. - */ - fun addExtension(removeBg: UnnamedSchemaWithArrayParent4.RemoveBg) = - addExtension(UnnamedSchemaWithArrayParent4.ofRemoveBg(removeBg)) + /** Alias for calling [addExtension] with `ExtensionItem.ofRemoveBg(removeBg)`. */ + fun addExtension(removeBg: ExtensionItem.RemoveBg) = + addExtension(ExtensionItem.ofRemoveBg(removeBg)) /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension(autoTaggingExtension)`. + * `ExtensionItem.ofAutoTaggingExtension(autoTaggingExtension)`. */ - fun addExtension( - autoTaggingExtension: UnnamedSchemaWithArrayParent4.AutoTaggingExtension - ) = - addExtension( - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension(autoTaggingExtension) - ) + fun addExtension(autoTaggingExtension: ExtensionItem.AutoTaggingExtension) = + addExtension(ExtensionItem.ofAutoTaggingExtension(autoTaggingExtension)) - /** - * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofAiAutoDescription()`. - */ - fun addExtensionAiAutoDescription() = - addExtension(UnnamedSchemaWithArrayParent4.ofAiAutoDescription()) + /** Alias for calling [addExtension] with `ExtensionItem.ofAiAutoDescription()`. */ + fun addExtensionAiAutoDescription() = addExtension(ExtensionItem.ofAiAutoDescription()) - /** - * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofAiTasks(aiTasks)`. - */ - fun addExtension(aiTasks: UnnamedSchemaWithArrayParent4.AiTasks) = - addExtension(UnnamedSchemaWithArrayParent4.ofAiTasks(aiTasks)) + /** Alias for calling [addExtension] with `ExtensionItem.ofAiTasks(aiTasks)`. */ + fun addExtension(aiTasks: ExtensionItem.AiTasks) = + addExtension(ExtensionItem.ofAiTasks(aiTasks)) /** * Alias for calling [addExtension] with the following: * ```java - * UnnamedSchemaWithArrayParent4.AiTasks.builder() + * ExtensionItem.AiTasks.builder() * .tasks(tasks) * .build() * ``` */ - fun addAiTasksExtension(tasks: List) = - addExtension(UnnamedSchemaWithArrayParent4.AiTasks.builder().tasks(tasks).build()) + fun addAiTasksExtension(tasks: List) = + addExtension(ExtensionItem.AiTasks.builder().tasks(tasks).build()) /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofSavedExtension(savedExtension)`. + * `ExtensionItem.ofSavedExtension(savedExtension)`. */ - fun addExtension(savedExtension: UnnamedSchemaWithArrayParent4.SavedExtension) = - addExtension(UnnamedSchemaWithArrayParent4.ofSavedExtension(savedExtension)) + fun addExtension(savedExtension: ExtensionItem.SavedExtension) = + addExtension(ExtensionItem.ofSavedExtension(savedExtension)) /** * Alias for calling [addExtension] with the following: * ```java - * UnnamedSchemaWithArrayParent4.SavedExtension.builder() + * ExtensionItem.SavedExtension.builder() * .id(id) * .build() * ``` */ fun addSavedExtensionExtension(id: String) = - addExtension(UnnamedSchemaWithArrayParent4.SavedExtension.builder().id(id).build()) + addExtension(ExtensionItem.SavedExtension.builder().id(id).build()) /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist @@ -2081,17 +2078,17 @@ private constructor( * * You can mix and match any combination of post-processing types. */ - fun transformation(transformation: Transformation) = + fun transformation(transformation: UploadTransformation) = transformation(MultipartField.of(transformation)) /** * Sets [Builder.transformation] to an arbitrary multipart value. * - * You should usually call [Builder.transformation] with a well-typed [Transformation] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.transformation] with a well-typed + * [UploadTransformation] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun transformation(transformation: MultipartField) = apply { + fun transformation(transformation: MultipartField) = apply { this.transformation = transformation } @@ -2386,5924 +2383,6 @@ private constructor( override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" } - @JsonSerialize(using = UnnamedSchemaWithArrayParent4.Serializer::class) - class UnnamedSchemaWithArrayParent4 - private constructor( - private val removeBg: RemoveBg? = null, - private val autoTaggingExtension: AutoTaggingExtension? = null, - private val aiAutoDescription: JsonValue? = null, - private val aiTasks: AiTasks? = null, - private val savedExtension: SavedExtension? = null, - private val _json: JsonValue? = null, - ) { - - fun removeBg(): Optional = Optional.ofNullable(removeBg) - - fun autoTaggingExtension(): Optional = - Optional.ofNullable(autoTaggingExtension) - - fun aiAutoDescription(): Optional = Optional.ofNullable(aiAutoDescription) - - fun aiTasks(): Optional = Optional.ofNullable(aiTasks) - - fun savedExtension(): Optional = Optional.ofNullable(savedExtension) - - fun isRemoveBg(): Boolean = removeBg != null - - fun isAutoTaggingExtension(): Boolean = autoTaggingExtension != null - - fun isAiAutoDescription(): Boolean = aiAutoDescription != null - - fun isAiTasks(): Boolean = aiTasks != null - - fun isSavedExtension(): Boolean = savedExtension != null - - fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") - - fun asAutoTaggingExtension(): AutoTaggingExtension = - autoTaggingExtension.getOrThrow("autoTaggingExtension") - - fun asAiAutoDescription(): JsonValue = aiAutoDescription.getOrThrow("aiAutoDescription") - - fun asAiTasks(): AiTasks = aiTasks.getOrThrow("aiTasks") - - fun asSavedExtension(): SavedExtension = savedExtension.getOrThrow("savedExtension") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - removeBg != null -> visitor.visitRemoveBg(removeBg) - autoTaggingExtension != null -> - visitor.visitAutoTaggingExtension(autoTaggingExtension) - aiAutoDescription != null -> visitor.visitAiAutoDescription(aiAutoDescription) - aiTasks != null -> visitor.visitAiTasks(aiTasks) - savedExtension != null -> visitor.visitSavedExtension(savedExtension) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): UnnamedSchemaWithArrayParent4 = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitRemoveBg(removeBg: RemoveBg) { - removeBg.validate() - } - - override fun visitAutoTaggingExtension( - autoTaggingExtension: AutoTaggingExtension - ) { - autoTaggingExtension.validate() - } - - override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { - aiAutoDescription.let { - if (it != JsonValue.from(mapOf("name" to "ai-auto-description"))) { - throw ImageKitInvalidDataException( - "'aiAutoDescription' is invalid, received $it" - ) - } - } - } - - override fun visitAiTasks(aiTasks: AiTasks) { - aiTasks.validate() - } - - override fun visitSavedExtension(savedExtension: SavedExtension) { - savedExtension.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnnamedSchemaWithArrayParent4 && - removeBg == other.removeBg && - autoTaggingExtension == other.autoTaggingExtension && - aiAutoDescription == other.aiAutoDescription && - aiTasks == other.aiTasks && - savedExtension == other.savedExtension - } - - override fun hashCode(): Int = - Objects.hash(removeBg, autoTaggingExtension, aiAutoDescription, aiTasks, savedExtension) - - override fun toString(): String = - when { - removeBg != null -> "UnnamedSchemaWithArrayParent4{removeBg=$removeBg}" - autoTaggingExtension != null -> - "UnnamedSchemaWithArrayParent4{autoTaggingExtension=$autoTaggingExtension}" - aiAutoDescription != null -> - "UnnamedSchemaWithArrayParent4{aiAutoDescription=$aiAutoDescription}" - aiTasks != null -> "UnnamedSchemaWithArrayParent4{aiTasks=$aiTasks}" - savedExtension != null -> - "UnnamedSchemaWithArrayParent4{savedExtension=$savedExtension}" - _json != null -> "UnnamedSchemaWithArrayParent4{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent4") - } - - companion object { - - @JvmStatic - fun ofRemoveBg(removeBg: RemoveBg) = UnnamedSchemaWithArrayParent4(removeBg = removeBg) - - @JvmStatic - fun ofAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension) = - UnnamedSchemaWithArrayParent4(autoTaggingExtension = autoTaggingExtension) - - @JvmStatic - fun ofAiAutoDescription() = - UnnamedSchemaWithArrayParent4( - aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) - ) - - @JvmStatic - fun ofAiTasks(aiTasks: AiTasks) = UnnamedSchemaWithArrayParent4(aiTasks = aiTasks) - - @JvmStatic - fun ofSavedExtension(savedExtension: SavedExtension) = - UnnamedSchemaWithArrayParent4(savedExtension = savedExtension) - } - - /** - * An interface that defines how to map each variant of [UnnamedSchemaWithArrayParent4] to a - * value of type [T]. - */ - interface Visitor { - - fun visitRemoveBg(removeBg: RemoveBg): T - - fun visitAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension): T - - fun visitAiAutoDescription(aiAutoDescription: JsonValue): T - - fun visitAiTasks(aiTasks: AiTasks): T - - fun visitSavedExtension(savedExtension: SavedExtension): T - - /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent4] to a value of type [T]. - * - * An instance of [UnnamedSchemaWithArrayParent4] can contain an unknown variant if it - * was deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new variants - * that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown UnnamedSchemaWithArrayParent4: $json") - } - } - - internal class Serializer : - BaseSerializer(UnnamedSchemaWithArrayParent4::class) { - - override fun serialize( - value: UnnamedSchemaWithArrayParent4, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.removeBg != null -> generator.writeObject(value.removeBg) - value.autoTaggingExtension != null -> - generator.writeObject(value.autoTaggingExtension) - value.aiAutoDescription != null -> - generator.writeObject(value.aiAutoDescription) - value.aiTasks != null -> generator.writeObject(value.aiTasks) - value.savedExtension != null -> generator.writeObject(value.savedExtension) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent4") - } - } - } - - class RemoveBg - private constructor( - private val name: JsonValue, - private val options: JsonField, - private val additionalProperties: MutableMap, - ) { - - /** - * Specifies the background removal extension. - * - * Expected to always return the following: - * ```java - * JsonValue.from("remove-bg") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun options(): Optional = options.getOptional("options") - - /** - * Returns the raw JSON value of [options]. - * - * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RemoveBg]. */ - class Builder internal constructor() { - - private var name: JsonValue = JsonValue.from("remove-bg") - private var options: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(removeBg: RemoveBg) = apply { - name = removeBg.name - options = removeBg.options - additionalProperties = removeBg.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from("remove-bg") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonValue) = apply { this.name = name } - - fun options(options: Options) = options(JsonField.of(options)) - - /** - * Sets [Builder.options] to an arbitrary JSON value. - * - * You should usually call [Builder.options] with a well-typed [Options] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun options(options: JsonField) = apply { this.options = options } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [RemoveBg]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemoveBg = RemoveBg(name, options, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): RemoveBg = apply { - if (validated) { - return@apply - } - - _name().let { - if (it != JsonValue.from("remove-bg")) { - throw ImageKitInvalidDataException("'name' is invalid, received $it") - } - } - options().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - class Options - private constructor( - private val addShadow: JsonField, - private val bgColor: JsonField, - private val bgImageUrl: JsonField, - private val semitransparency: JsonField, - private val additionalProperties: MutableMap, - ) { - - /** - * Whether to add an artificial shadow to the result. Default is false. Note: Adding - * shadows is currently only supported for car photos. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun addShadow(): Optional = addShadow.getOptional("add_shadow") - - /** - * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or - * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be - * empty. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun bgColor(): Optional = bgColor.getOptional("bg_color") - - /** - * Sets a background image from a URL. If this parameter is set, `bg_color` must be - * empty. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun bgImageUrl(): Optional = bgImageUrl.getOptional("bg_image_url") - - /** - * Allows semi-transparent regions in the result. Default is true. Note: - * Semitransparency is currently only supported for car windows. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun semitransparency(): Optional = - semitransparency.getOptional("semitransparency") - - /** - * Returns the raw JSON value of [addShadow]. - * - * Unlike [addShadow], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("add_shadow") - @ExcludeMissing - fun _addShadow(): JsonField = addShadow - - /** - * Returns the raw JSON value of [bgColor]. - * - * Unlike [bgColor], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("bg_color") - @ExcludeMissing - fun _bgColor(): JsonField = bgColor - - /** - * Returns the raw JSON value of [bgImageUrl]. - * - * Unlike [bgImageUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("bg_image_url") - @ExcludeMissing - fun _bgImageUrl(): JsonField = bgImageUrl - - /** - * Returns the raw JSON value of [semitransparency]. - * - * Unlike [semitransparency], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("semitransparency") - @ExcludeMissing - fun _semitransparency(): JsonField = semitransparency - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Options]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Options]. */ - class Builder internal constructor() { - - private var addShadow: JsonField = JsonMissing.of() - private var bgColor: JsonField = JsonMissing.of() - private var bgImageUrl: JsonField = JsonMissing.of() - private var semitransparency: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(options: Options) = apply { - addShadow = options.addShadow - bgColor = options.bgColor - bgImageUrl = options.bgImageUrl - semitransparency = options.semitransparency - additionalProperties = options.additionalProperties.toMutableMap() - } - - /** - * Whether to add an artificial shadow to the result. Default is false. Note: - * Adding shadows is currently only supported for car photos. - */ - fun addShadow(addShadow: Boolean) = addShadow(JsonField.of(addShadow)) - - /** - * Sets [Builder.addShadow] to an arbitrary JSON value. - * - * You should usually call [Builder.addShadow] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun addShadow(addShadow: JsonField) = apply { - this.addShadow = addShadow - } - - /** - * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or - * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be - * empty. - */ - fun bgColor(bgColor: String) = bgColor(JsonField.of(bgColor)) - - /** - * Sets [Builder.bgColor] to an arbitrary JSON value. - * - * You should usually call [Builder.bgColor] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun bgColor(bgColor: JsonField) = apply { this.bgColor = bgColor } - - /** - * Sets a background image from a URL. If this parameter is set, `bg_color` must - * be empty. - */ - fun bgImageUrl(bgImageUrl: String) = bgImageUrl(JsonField.of(bgImageUrl)) - - /** - * Sets [Builder.bgImageUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.bgImageUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun bgImageUrl(bgImageUrl: JsonField) = apply { - this.bgImageUrl = bgImageUrl - } - - /** - * Allows semi-transparent regions in the result. Default is true. Note: - * Semitransparency is currently only supported for car windows. - */ - fun semitransparency(semitransparency: Boolean) = - semitransparency(JsonField.of(semitransparency)) - - /** - * Sets [Builder.semitransparency] to an arbitrary JSON value. - * - * You should usually call [Builder.semitransparency] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun semitransparency(semitransparency: JsonField) = apply { - this.semitransparency = semitransparency - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Options]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Options = - Options( - addShadow, - bgColor, - bgImageUrl, - semitransparency, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Options = apply { - if (validated) { - return@apply - } - - addShadow() - bgColor() - bgImageUrl() - semitransparency() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - addShadow == other.addShadow && - bgColor == other.bgColor && - bgImageUrl == other.bgImageUrl && - semitransparency == other.semitransparency && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - addShadow, - bgColor, - bgImageUrl, - semitransparency, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemoveBg && - name == other.name && - options == other.options && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(name, options, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" - } - - class AutoTaggingExtension - private constructor( - private val maxTags: JsonField, - private val minConfidence: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - /** - * Maximum number of tags to attach to the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun maxTags(): Long = maxTags.getRequired("maxTags") - - /** - * Minimum confidence level for tags to be considered valid. - * - * @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 minConfidence(): Long = minConfidence.getRequired("minConfidence") - - /** - * Specifies the auto-tagging extension used. - * - * @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(): Name = name.getRequired("name") - - /** - * Returns the raw JSON value of [maxTags]. - * - * Unlike [maxTags], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("maxTags") @ExcludeMissing fun _maxTags(): JsonField = maxTags - - /** - * Returns the raw JSON value of [minConfidence]. - * - * Unlike [minConfidence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("minConfidence") - @ExcludeMissing - fun _minConfidence(): JsonField = minConfidence - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [AutoTaggingExtension]. - * - * The following fields are required: - * ```java - * .maxTags() - * .minConfidence() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutoTaggingExtension]. */ - class Builder internal constructor() { - - private var maxTags: JsonField? = null - private var minConfidence: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { - maxTags = autoTaggingExtension.maxTags - minConfidence = autoTaggingExtension.minConfidence - name = autoTaggingExtension.name - additionalProperties = autoTaggingExtension.additionalProperties.toMutableMap() - } - - /** Maximum number of tags to attach to the asset. */ - fun maxTags(maxTags: Long) = maxTags(JsonField.of(maxTags)) - - /** - * Sets [Builder.maxTags] to an arbitrary JSON value. - * - * You should usually call [Builder.maxTags] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun maxTags(maxTags: JsonField) = apply { this.maxTags = maxTags } - - /** Minimum confidence level for tags to be considered valid. */ - fun minConfidence(minConfidence: Long) = minConfidence(JsonField.of(minConfidence)) - - /** - * Sets [Builder.minConfidence] to an arbitrary JSON value. - * - * You should usually call [Builder.minConfidence] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun minConfidence(minConfidence: JsonField) = apply { - this.minConfidence = minConfidence - } - - /** Specifies the auto-tagging extension used. */ - fun name(name: Name) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [Name] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AutoTaggingExtension]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .maxTags() - * .minConfidence() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AutoTaggingExtension = - AutoTaggingExtension( - checkRequired("maxTags", maxTags), - checkRequired("minConfidence", minConfidence), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutoTaggingExtension = apply { - if (validated) { - return@apply - } - - maxTags() - minConfidence() - name().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** Specifies the auto-tagging extension used. */ - class Name @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") - - @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") - - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } - - /** An enum containing [Name]'s known values. */ - enum class Known { - GOOGLE_AUTO_TAGGING, - AWS_AUTO_TAGGING, - } - - /** - * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Name] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GOOGLE_AUTO_TAGGING, - AWS_AUTO_TAGGING, - /** - * An enum member indicating that [Name] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING - AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING - AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING - else -> throw ImageKitInvalidDataException("Unknown Name: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Name = apply { - if (validated) { - return@apply - } - - known() - 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 (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Name && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AutoTaggingExtension && - maxTags == other.maxTags && - minConfidence == other.minConfidence && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(maxTags, minConfidence, name, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" - } - - class AiTasks - private constructor( - private val name: JsonValue, - private val tasks: JsonField>, - private val additionalProperties: MutableMap, - ) { - - /** - * Specifies the AI tasks extension for automated image analysis using AI models. - * - * Expected to always return the following: - * ```java - * JsonValue.from("ai-tasks") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name - - /** - * Array of task objects defining AI operations to perform on the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tasks(): List = tasks.getRequired("tasks") - - /** - * Returns the raw JSON value of [tasks]. - * - * Unlike [tasks], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tasks") @ExcludeMissing fun _tasks(): JsonField> = tasks - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [AiTasks]. - * - * The following fields are required: - * ```java - * .tasks() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AiTasks]. */ - class Builder internal constructor() { - - private var name: JsonValue = JsonValue.from("ai-tasks") - private var tasks: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(aiTasks: AiTasks) = apply { - name = aiTasks.name - tasks = aiTasks.tasks.map { it.toMutableList() } - additionalProperties = aiTasks.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from("ai-tasks") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonValue) = apply { this.name = name } - - /** Array of task objects defining AI operations to perform on the asset. */ - fun tasks(tasks: List) = tasks(JsonField.of(tasks)) - - /** - * Sets [Builder.tasks] to an arbitrary JSON value. - * - * You should usually call [Builder.tasks] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun tasks(tasks: JsonField>) = apply { - this.tasks = tasks.map { it.toMutableList() } - } - - /** - * Adds a single [Task] to [tasks]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTask(task: Task) = apply { - tasks = - (tasks ?: JsonField.of(mutableListOf())).also { - checkKnown("tasks", it).add(task) - } - } - - /** Alias for calling [addTask] with `Task.ofSelectTags(selectTags)`. */ - fun addTask(selectTags: Task.SelectTags) = addTask(Task.ofSelectTags(selectTags)) - - /** - * Alias for calling [addTask] with the following: - * ```java - * Task.SelectTags.builder() - * .instruction(instruction) - * .build() - * ``` - */ - fun addSelectTagsTask(instruction: String) = - addTask(Task.SelectTags.builder().instruction(instruction).build()) - - /** Alias for calling [addTask] with `Task.ofSelectMetadata(selectMetadata)`. */ - fun addTask(selectMetadata: Task.SelectMetadata) = - addTask(Task.ofSelectMetadata(selectMetadata)) - - /** Alias for calling [addTask] with `Task.ofYesNo(yesNo)`. */ - fun addTask(yesNo: Task.YesNo) = addTask(Task.ofYesNo(yesNo)) - - /** - * Alias for calling [addTask] with the following: - * ```java - * Task.YesNo.builder() - * .instruction(instruction) - * .build() - * ``` - */ - fun addYesNoTask(instruction: String) = - addTask(Task.YesNo.builder().instruction(instruction).build()) - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AiTasks]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .tasks() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AiTasks = - AiTasks( - name, - checkRequired("tasks", tasks).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AiTasks = apply { - if (validated) { - return@apply - } - - _name().let { - if (it != JsonValue.from("ai-tasks")) { - throw ImageKitInvalidDataException("'name' is invalid, received $it") - } - } - tasks().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - @JsonSerialize(using = Task.Serializer::class) - class Task - private constructor( - private val selectTags: SelectTags? = null, - private val selectMetadata: SelectMetadata? = null, - private val yesNo: YesNo? = null, - private val _json: JsonValue? = null, - ) { - - fun selectTags(): Optional = Optional.ofNullable(selectTags) - - fun selectMetadata(): Optional = Optional.ofNullable(selectMetadata) - - fun yesNo(): Optional = Optional.ofNullable(yesNo) - - fun isSelectTags(): Boolean = selectTags != null - - fun isSelectMetadata(): Boolean = selectMetadata != null - - fun isYesNo(): Boolean = yesNo != null - - fun asSelectTags(): SelectTags = selectTags.getOrThrow("selectTags") - - fun asSelectMetadata(): SelectMetadata = selectMetadata.getOrThrow("selectMetadata") - - fun asYesNo(): YesNo = yesNo.getOrThrow("yesNo") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - selectTags != null -> visitor.visitSelectTags(selectTags) - selectMetadata != null -> visitor.visitSelectMetadata(selectMetadata) - yesNo != null -> visitor.visitYesNo(yesNo) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Task = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitSelectTags(selectTags: SelectTags) { - selectTags.validate() - } - - override fun visitSelectMetadata(selectMetadata: SelectMetadata) { - selectMetadata.validate() - } - - override fun visitYesNo(yesNo: YesNo) { - yesNo.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Task && - selectTags == other.selectTags && - selectMetadata == other.selectMetadata && - yesNo == other.yesNo - } - - override fun hashCode(): Int = Objects.hash(selectTags, selectMetadata, yesNo) - - override fun toString(): String = - when { - selectTags != null -> "Task{selectTags=$selectTags}" - selectMetadata != null -> "Task{selectMetadata=$selectMetadata}" - yesNo != null -> "Task{yesNo=$yesNo}" - _json != null -> "Task{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Task") - } - - companion object { - - @JvmStatic - fun ofSelectTags(selectTags: SelectTags) = Task(selectTags = selectTags) - - @JvmStatic - fun ofSelectMetadata(selectMetadata: SelectMetadata) = - Task(selectMetadata = selectMetadata) - - @JvmStatic fun ofYesNo(yesNo: YesNo) = Task(yesNo = yesNo) - } - - /** - * An interface that defines how to map each variant of [Task] to a value of type - * [T]. - */ - interface Visitor { - - fun visitSelectTags(selectTags: SelectTags): T - - fun visitSelectMetadata(selectMetadata: SelectMetadata): T - - fun visitYesNo(yesNo: YesNo): T - - /** - * Maps an unknown variant of [Task] to a value of type [T]. - * - * An instance of [Task] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on - * an older version than the API, then the API may respond with new variants - * that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Task: $json") - } - } - - internal class Serializer : BaseSerializer(Task::class) { - - override fun serialize( - value: Task, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.selectTags != null -> generator.writeObject(value.selectTags) - value.selectMetadata != null -> - generator.writeObject(value.selectMetadata) - value.yesNo != null -> generator.writeObject(value.yesNo) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Task") - } - } - } - - class SelectTags - private constructor( - private val instruction: JsonField, - private val type: JsonValue, - private val maxSelections: JsonField, - private val minSelections: JsonField, - private val vocabulary: JsonField>, - private val additionalProperties: MutableMap, - ) { - - /** - * The question or instruction for the AI to analyze the image. - * - * @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 instruction(): String = instruction.getRequired("instruction") - - /** - * Task type that analyzes the image and adds matching tags from a vocabulary. - * - * Expected to always return the following: - * ```java - * JsonValue.from("select_tags") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Maximum number of tags to select from the vocabulary. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun maxSelections(): Optional = - maxSelections.getOptional("max_selections") - - /** - * Minimum number of tags to select from the vocabulary. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun minSelections(): Optional = - minSelections.getOptional("min_selections") - - /** - * Array of possible tag values. The combined length of all strings must not - * exceed 500 characters, and values cannot include the `%` character. When - * providing large vocabularies (more than 30 items), the AI may not follow the - * list strictly. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun vocabulary(): Optional> = vocabulary.getOptional("vocabulary") - - /** - * Returns the raw JSON value of [instruction]. - * - * Unlike [instruction], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("instruction") - @ExcludeMissing - fun _instruction(): JsonField = instruction - - /** - * Returns the raw JSON value of [maxSelections]. - * - * Unlike [maxSelections], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("max_selections") - @ExcludeMissing - fun _maxSelections(): JsonField = maxSelections - - /** - * Returns the raw JSON value of [minSelections]. - * - * Unlike [minSelections], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("min_selections") - @ExcludeMissing - fun _minSelections(): JsonField = minSelections - - /** - * Returns the raw JSON value of [vocabulary]. - * - * Unlike [vocabulary], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("vocabulary") - @ExcludeMissing - fun _vocabulary(): JsonField> = vocabulary - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [SelectTags]. - * - * The following fields are required: - * ```java - * .instruction() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SelectTags]. */ - class Builder internal constructor() { - - private var instruction: JsonField? = null - private var type: JsonValue = JsonValue.from("select_tags") - private var maxSelections: JsonField = JsonMissing.of() - private var minSelections: JsonField = JsonMissing.of() - private var vocabulary: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(selectTags: SelectTags) = apply { - instruction = selectTags.instruction - type = selectTags.type - maxSelections = selectTags.maxSelections - minSelections = selectTags.minSelections - vocabulary = selectTags.vocabulary.map { it.toMutableList() } - additionalProperties = selectTags.additionalProperties.toMutableMap() - } - - /** The question or instruction for the AI to analyze the image. */ - fun instruction(instruction: String) = - instruction(JsonField.of(instruction)) - - /** - * Sets [Builder.instruction] to an arbitrary JSON value. - * - * You should usually call [Builder.instruction] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun instruction(instruction: JsonField) = apply { - this.instruction = instruction - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults - * to the following: - * ```java - * JsonValue.from("select_tags") - * ``` - * - * This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** Maximum number of tags to select from the vocabulary. */ - fun maxSelections(maxSelections: Long) = - maxSelections(JsonField.of(maxSelections)) - - /** - * Sets [Builder.maxSelections] to an arbitrary JSON value. - * - * You should usually call [Builder.maxSelections] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun maxSelections(maxSelections: JsonField) = apply { - this.maxSelections = maxSelections - } - - /** Minimum number of tags to select from the vocabulary. */ - fun minSelections(minSelections: Long) = - minSelections(JsonField.of(minSelections)) - - /** - * Sets [Builder.minSelections] to an arbitrary JSON value. - * - * You should usually call [Builder.minSelections] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun minSelections(minSelections: JsonField) = apply { - this.minSelections = minSelections - } - - /** - * Array of possible tag values. The combined length of all strings must not - * exceed 500 characters, and values cannot include the `%` character. When - * providing large vocabularies (more than 30 items), the AI may not follow - * the list strictly. - */ - fun vocabulary(vocabulary: List) = - vocabulary(JsonField.of(vocabulary)) - - /** - * Sets [Builder.vocabulary] to an arbitrary JSON value. - * - * You should usually call [Builder.vocabulary] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun vocabulary(vocabulary: JsonField>) = apply { - this.vocabulary = vocabulary.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.vocabulary]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addVocabulary(vocabulary: String) = apply { - this.vocabulary = - (this.vocabulary ?: JsonField.of(mutableListOf())).also { - checkKnown("vocabulary", it).add(vocabulary) - } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SelectTags]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .instruction() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SelectTags = - SelectTags( - checkRequired("instruction", instruction), - type, - maxSelections, - minSelections, - (vocabulary ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SelectTags = apply { - if (validated) { - return@apply - } - - instruction() - _type().let { - if (it != JsonValue.from("select_tags")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - maxSelections() - minSelections() - vocabulary() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SelectTags && - instruction == other.instruction && - type == other.type && - maxSelections == other.maxSelections && - minSelections == other.minSelections && - vocabulary == other.vocabulary && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - instruction, - type, - maxSelections, - minSelections, - vocabulary, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SelectTags{instruction=$instruction, type=$type, maxSelections=$maxSelections, minSelections=$minSelections, vocabulary=$vocabulary, additionalProperties=$additionalProperties}" - } - - class SelectMetadata - private constructor( - private val field: JsonField, - private val instruction: JsonField, - private val type: JsonValue, - private val maxSelections: JsonField, - private val minSelections: JsonField, - private val vocabulary: JsonField>, - private val additionalProperties: MutableMap, - ) { - - /** - * Name of the custom metadata field to set. The field must exist in 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 field(): String = field.getRequired("field") - - /** - * The question or instruction for the AI to analyze the image. - * - * @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 instruction(): String = instruction.getRequired("instruction") - - /** - * Task type that analyzes the image and sets a custom metadata field value from - * a vocabulary. - * - * Expected to always return the following: - * ```java - * JsonValue.from("select_metadata") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Maximum number of values to select from the vocabulary. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun maxSelections(): Optional = - maxSelections.getOptional("max_selections") - - /** - * Minimum number of values to select from the vocabulary. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun minSelections(): Optional = - minSelections.getOptional("min_selections") - - /** - * An array of possible values matching the custom metadata field type. If not - * provided for SingleSelect or MultiSelect field types, all values from the - * custom metadata field definition will be used. When providing large - * vocabularies (above 30 items), the AI may not strictly adhere to the list. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun vocabulary(): Optional> = - vocabulary.getOptional("vocabulary") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field - - /** - * Returns the raw JSON value of [instruction]. - * - * Unlike [instruction], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("instruction") - @ExcludeMissing - fun _instruction(): JsonField = instruction - - /** - * Returns the raw JSON value of [maxSelections]. - * - * Unlike [maxSelections], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("max_selections") - @ExcludeMissing - fun _maxSelections(): JsonField = maxSelections - - /** - * Returns the raw JSON value of [minSelections]. - * - * Unlike [minSelections], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("min_selections") - @ExcludeMissing - fun _minSelections(): JsonField = minSelections - - /** - * Returns the raw JSON value of [vocabulary]. - * - * Unlike [vocabulary], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("vocabulary") - @ExcludeMissing - fun _vocabulary(): JsonField> = vocabulary - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SelectMetadata]. - * - * The following fields are required: - * ```java - * .field() - * .instruction() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SelectMetadata]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var instruction: JsonField? = null - private var type: JsonValue = JsonValue.from("select_metadata") - private var maxSelections: JsonField = JsonMissing.of() - private var minSelections: JsonField = JsonMissing.of() - private var vocabulary: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(selectMetadata: SelectMetadata) = apply { - field = selectMetadata.field - instruction = selectMetadata.instruction - type = selectMetadata.type - maxSelections = selectMetadata.maxSelections - minSelections = selectMetadata.minSelections - vocabulary = selectMetadata.vocabulary.map { it.toMutableList() } - additionalProperties = - selectMetadata.additionalProperties.toMutableMap() - } - - /** - * Name of the custom metadata field to set. The field must exist in your - * account. - */ - fun field(field: String) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { this.field = field } - - /** The question or instruction for the AI to analyze the image. */ - fun instruction(instruction: String) = - instruction(JsonField.of(instruction)) - - /** - * Sets [Builder.instruction] to an arbitrary JSON value. - * - * You should usually call [Builder.instruction] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun instruction(instruction: JsonField) = apply { - this.instruction = instruction - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults - * to the following: - * ```java - * JsonValue.from("select_metadata") - * ``` - * - * This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** Maximum number of values to select from the vocabulary. */ - fun maxSelections(maxSelections: Long) = - maxSelections(JsonField.of(maxSelections)) - - /** - * Sets [Builder.maxSelections] to an arbitrary JSON value. - * - * You should usually call [Builder.maxSelections] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun maxSelections(maxSelections: JsonField) = apply { - this.maxSelections = maxSelections - } - - /** Minimum number of values to select from the vocabulary. */ - fun minSelections(minSelections: Long) = - minSelections(JsonField.of(minSelections)) - - /** - * Sets [Builder.minSelections] to an arbitrary JSON value. - * - * You should usually call [Builder.minSelections] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun minSelections(minSelections: JsonField) = apply { - this.minSelections = minSelections - } - - /** - * An array of possible values matching the custom metadata field type. If - * not provided for SingleSelect or MultiSelect field types, all values from - * the custom metadata field definition will be used. When providing large - * vocabularies (above 30 items), the AI may not strictly adhere to the - * list. - */ - fun vocabulary(vocabulary: List) = - vocabulary(JsonField.of(vocabulary)) - - /** - * Sets [Builder.vocabulary] to an arbitrary JSON value. - * - * You should usually call [Builder.vocabulary] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun vocabulary(vocabulary: JsonField>) = apply { - this.vocabulary = vocabulary.map { it.toMutableList() } - } - - /** - * Adds a single [Vocabulary] to [Builder.vocabulary]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addVocabulary(vocabulary: Vocabulary) = apply { - this.vocabulary = - (this.vocabulary ?: JsonField.of(mutableListOf())).also { - checkKnown("vocabulary", it).add(vocabulary) - } - } - - /** Alias for calling [addVocabulary] with `Vocabulary.ofString(string)`. */ - fun addVocabulary(string: String) = - addVocabulary(Vocabulary.ofString(string)) - - /** Alias for calling [addVocabulary] with `Vocabulary.ofNumber(number)`. */ - fun addVocabulary(number: Double) = - addVocabulary(Vocabulary.ofNumber(number)) - - /** Alias for calling [addVocabulary] with `Vocabulary.ofBool(bool)`. */ - fun addVocabulary(bool: Boolean) = addVocabulary(Vocabulary.ofBool(bool)) - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SelectMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .field() - * .instruction() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SelectMetadata = - SelectMetadata( - checkRequired("field", field), - checkRequired("instruction", instruction), - type, - maxSelections, - minSelections, - (vocabulary ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SelectMetadata = apply { - if (validated) { - return@apply - } - - field() - instruction() - _type().let { - if (it != JsonValue.from("select_metadata")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - maxSelections() - minSelections() - vocabulary().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - @JsonSerialize(using = Vocabulary.Serializer::class) - class Vocabulary - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Vocabulary = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Vocabulary && - string == other.string && - number == other.number && - bool == other.bool - } - - override fun hashCode(): Int = Objects.hash(string, number, bool) - - override fun toString(): String = - when { - string != null -> "Vocabulary{string=$string}" - number != null -> "Vocabulary{number=$number}" - bool != null -> "Vocabulary{bool=$bool}" - _json != null -> "Vocabulary{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Vocabulary") - } - - companion object { - - @JvmStatic fun ofString(string: String) = Vocabulary(string = string) - - @JvmStatic fun ofNumber(number: Double) = Vocabulary(number = number) - - @JvmStatic fun ofBool(bool: Boolean) = Vocabulary(bool = bool) - } - - /** - * An interface that defines how to map each variant of [Vocabulary] to a - * value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - /** - * Maps an unknown variant of [Vocabulary] to a value of type [T]. - * - * An instance of [Vocabulary] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Vocabulary: $json") - } - } - - internal class Serializer : BaseSerializer(Vocabulary::class) { - - override fun serialize( - value: Vocabulary, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.number != null -> generator.writeObject(value.number) - value.bool != null -> generator.writeObject(value.bool) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Vocabulary") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SelectMetadata && - field == other.field && - instruction == other.instruction && - type == other.type && - maxSelections == other.maxSelections && - minSelections == other.minSelections && - vocabulary == other.vocabulary && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - field, - instruction, - type, - maxSelections, - minSelections, - vocabulary, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SelectMetadata{field=$field, instruction=$instruction, type=$type, maxSelections=$maxSelections, minSelections=$minSelections, vocabulary=$vocabulary, additionalProperties=$additionalProperties}" - } - - class YesNo - private constructor( - private val instruction: JsonField, - private val type: JsonValue, - private val onNo: JsonField, - private val onUnknown: JsonField, - private val onYes: JsonField, - private val additionalProperties: MutableMap, - ) { - - /** - * The yes/no question for the AI to answer about the image. - * - * @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 instruction(): String = instruction.getRequired("instruction") - - /** - * Task type that asks a yes/no question and executes actions based on the - * answer. - * - * Expected to always return the following: - * ```java - * JsonValue.from("yes_no") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Actions to execute if the AI answers no. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun onNo(): Optional = onNo.getOptional("on_no") - - /** - * Actions to execute if the AI cannot determine the answer. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun onUnknown(): Optional = onUnknown.getOptional("on_unknown") - - /** - * Actions to execute if the AI answers yes. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun onYes(): Optional = onYes.getOptional("on_yes") - - /** - * Returns the raw JSON value of [instruction]. - * - * Unlike [instruction], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("instruction") - @ExcludeMissing - fun _instruction(): JsonField = instruction - - /** - * Returns the raw JSON value of [onNo]. - * - * Unlike [onNo], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("on_no") @ExcludeMissing fun _onNo(): JsonField = onNo - - /** - * Returns the raw JSON value of [onUnknown]. - * - * Unlike [onUnknown], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("on_unknown") - @ExcludeMissing - fun _onUnknown(): JsonField = onUnknown - - /** - * Returns the raw JSON value of [onYes]. - * - * Unlike [onYes], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("on_yes") @ExcludeMissing fun _onYes(): JsonField = onYes - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [YesNo]. - * - * The following fields are required: - * ```java - * .instruction() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [YesNo]. */ - class Builder internal constructor() { - - private var instruction: JsonField? = null - private var type: JsonValue = JsonValue.from("yes_no") - private var onNo: JsonField = JsonMissing.of() - private var onUnknown: JsonField = JsonMissing.of() - private var onYes: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(yesNo: YesNo) = apply { - instruction = yesNo.instruction - type = yesNo.type - onNo = yesNo.onNo - onUnknown = yesNo.onUnknown - onYes = yesNo.onYes - additionalProperties = yesNo.additionalProperties.toMutableMap() - } - - /** The yes/no question for the AI to answer about the image. */ - fun instruction(instruction: String) = - instruction(JsonField.of(instruction)) - - /** - * Sets [Builder.instruction] to an arbitrary JSON value. - * - * You should usually call [Builder.instruction] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun instruction(instruction: JsonField) = apply { - this.instruction = instruction - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults - * to the following: - * ```java - * JsonValue.from("yes_no") - * ``` - * - * This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** Actions to execute if the AI answers no. */ - fun onNo(onNo: OnNo) = onNo(JsonField.of(onNo)) - - /** - * Sets [Builder.onNo] to an arbitrary JSON value. - * - * You should usually call [Builder.onNo] with a well-typed [OnNo] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun onNo(onNo: JsonField) = apply { this.onNo = onNo } - - /** Actions to execute if the AI cannot determine the answer. */ - fun onUnknown(onUnknown: OnUnknown) = onUnknown(JsonField.of(onUnknown)) - - /** - * Sets [Builder.onUnknown] to an arbitrary JSON value. - * - * You should usually call [Builder.onUnknown] with a well-typed [OnUnknown] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun onUnknown(onUnknown: JsonField) = apply { - this.onUnknown = onUnknown - } - - /** Actions to execute if the AI answers yes. */ - fun onYes(onYes: OnYes) = onYes(JsonField.of(onYes)) - - /** - * Sets [Builder.onYes] to an arbitrary JSON value. - * - * You should usually call [Builder.onYes] with a well-typed [OnYes] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun onYes(onYes: JsonField) = apply { this.onYes = onYes } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [YesNo]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .instruction() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): YesNo = - YesNo( - checkRequired("instruction", instruction), - type, - onNo, - onUnknown, - onYes, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): YesNo = apply { - if (validated) { - return@apply - } - - instruction() - _type().let { - if (it != JsonValue.from("yes_no")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - onNo().ifPresent { it.validate() } - onUnknown().ifPresent { it.validate() } - onYes().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** Actions to execute if the AI answers no. */ - class OnNo - private constructor( - private val addTags: JsonField>, - private val removeTags: JsonField>, - private val setMetadata: JsonField>, - private val unsetMetadata: JsonField>, - private val additionalProperties: MutableMap, - ) { - - /** - * Array of tag strings to add to the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun addTags(): Optional> = addTags.getOptional("add_tags") - - /** - * Array of tag strings to remove from the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun removeTags(): Optional> = - removeTags.getOptional("remove_tags") - - /** - * Array of custom metadata field updates. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun setMetadata(): Optional> = - setMetadata.getOptional("set_metadata") - - /** - * Array of custom metadata fields to remove. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun unsetMetadata(): Optional> = - unsetMetadata.getOptional("unset_metadata") - - /** - * Returns the raw JSON value of [addTags]. - * - * Unlike [addTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("add_tags") - @ExcludeMissing - fun _addTags(): JsonField> = addTags - - /** - * Returns the raw JSON value of [removeTags]. - * - * Unlike [removeTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("remove_tags") - @ExcludeMissing - fun _removeTags(): JsonField> = removeTags - - /** - * Returns the raw JSON value of [setMetadata]. - * - * Unlike [setMetadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("set_metadata") - @ExcludeMissing - fun _setMetadata(): JsonField> = setMetadata - - /** - * Returns the raw JSON value of [unsetMetadata]. - * - * Unlike [unsetMetadata], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("unset_metadata") - @ExcludeMissing - fun _unsetMetadata(): JsonField> = unsetMetadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [OnNo]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OnNo]. */ - class Builder internal constructor() { - - private var addTags: JsonField>? = null - private var removeTags: JsonField>? = null - private var setMetadata: JsonField>? = null - private var unsetMetadata: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(onNo: OnNo) = apply { - addTags = onNo.addTags.map { it.toMutableList() } - removeTags = onNo.removeTags.map { it.toMutableList() } - setMetadata = onNo.setMetadata.map { it.toMutableList() } - unsetMetadata = onNo.unsetMetadata.map { it.toMutableList() } - additionalProperties = onNo.additionalProperties.toMutableMap() - } - - /** Array of tag strings to add to the asset. */ - fun addTags(addTags: List) = addTags(JsonField.of(addTags)) - - /** - * Sets [Builder.addTags] to an arbitrary JSON value. - * - * You should usually call [Builder.addTags] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun addTags(addTags: JsonField>) = apply { - this.addTags = addTags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [addTags]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addAddTag(addTag: String) = apply { - addTags = - (addTags ?: JsonField.of(mutableListOf())).also { - checkKnown("addTags", it).add(addTag) - } - } - - /** Array of tag strings to remove from the asset. */ - fun removeTags(removeTags: List) = - removeTags(JsonField.of(removeTags)) - - /** - * Sets [Builder.removeTags] to an arbitrary JSON value. - * - * You should usually call [Builder.removeTags] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun removeTags(removeTags: JsonField>) = apply { - this.removeTags = removeTags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [removeTags]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addRemoveTag(removeTag: String) = apply { - removeTags = - (removeTags ?: JsonField.of(mutableListOf())).also { - checkKnown("removeTags", it).add(removeTag) - } - } - - /** Array of custom metadata field updates. */ - fun setMetadata(setMetadata: List) = - setMetadata(JsonField.of(setMetadata)) - - /** - * Sets [Builder.setMetadata] to an arbitrary JSON value. - * - * You should usually call [Builder.setMetadata] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun setMetadata(setMetadata: JsonField>) = apply { - this.setMetadata = setMetadata.map { it.toMutableList() } - } - - /** - * Adds a single [SetMetadata] to [Builder.setMetadata]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addSetMetadata(setMetadata: SetMetadata) = apply { - this.setMetadata = - (this.setMetadata ?: JsonField.of(mutableListOf())).also { - checkKnown("setMetadata", it).add(setMetadata) - } - } - - /** Array of custom metadata fields to remove. */ - fun unsetMetadata(unsetMetadata: List) = - unsetMetadata(JsonField.of(unsetMetadata)) - - /** - * Sets [Builder.unsetMetadata] to an arbitrary JSON value. - * - * You should usually call [Builder.unsetMetadata] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun unsetMetadata(unsetMetadata: JsonField>) = - apply { - this.unsetMetadata = unsetMetadata.map { it.toMutableList() } - } - - /** - * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { - this.unsetMetadata = - (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { - checkKnown("unsetMetadata", it).add(unsetMetadata) - } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [OnNo]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): OnNo = - OnNo( - (addTags ?: JsonMissing.of()).map { it.toImmutable() }, - (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, - (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, - (unsetMetadata ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): OnNo = apply { - if (validated) { - return@apply - } - - addTags() - removeTags() - setMetadata().ifPresent { it.forEach { it.validate() } } - unsetMetadata().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - class SetMetadata - private constructor( - private val field: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - /** - * Name of the custom metadata field to set. - * - * @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 field(): String = field.getRequired("field") - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - * - * @throws ImageKitInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the - * server responded with an unexpected value). - */ - fun value(): Value = value.getRequired("value") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("field") - @ExcludeMissing - fun _field(): JsonField = field - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SetMetadata]. - * - * The following fields are required: - * ```java - * .field() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SetMetadata]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(setMetadata: SetMetadata) = apply { - field = setMetadata.field - value = setMetadata.value - additionalProperties = - setMetadata.additionalProperties.toMutableMap() - } - - /** Name of the custom metadata field to set. */ - fun field(field: String) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { this.field = field } - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - */ - fun value(value: Value) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [Value] - * value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - /** Alias for calling [value] with `Value.ofString(string)`. */ - fun value(string: String) = value(Value.ofString(string)) - - /** Alias for calling [value] with `Value.ofNumber(number)`. */ - fun value(number: Double) = value(Value.ofNumber(number)) - - /** Alias for calling [value] with `Value.ofBool(bool)`. */ - fun value(bool: Boolean) = value(Value.ofBool(bool)) - - /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ - fun valueOfMixed(mixed: List) = - value(Value.ofMixed(mixed)) - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SetMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .field() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SetMetadata = - SetMetadata( - checkRequired("field", field), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SetMetadata = apply { - if (validated) { - return@apply - } - - field() - value().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - */ - @JsonSerialize(using = Value.Serializer::class) - class Value - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val mixed: List? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun mixed(): Optional> = - Optional.ofNullable(mixed) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun isMixed(): Boolean = mixed != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun asMixed(): List = - mixed.getOrThrow("mixed") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - mixed != null -> visitor.visitMixed(mixed) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Value = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} - - override fun visitMixed( - mixed: List - ) { - mixed.forEach { it.validate() } - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Value && - string == other.string && - number == other.number && - bool == other.bool && - mixed == other.mixed - } - - override fun hashCode(): Int = - Objects.hash(string, number, bool, mixed) - - override fun toString(): String = - when { - string != null -> "Value{string=$string}" - number != null -> "Value{number=$number}" - bool != null -> "Value{bool=$bool}" - mixed != null -> "Value{mixed=$mixed}" - _json != null -> "Value{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Value") - } - - companion object { - - @JvmStatic fun ofString(string: String) = Value(string = string) - - @JvmStatic fun ofNumber(number: Double) = Value(number = number) - - @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) - - @JvmStatic - fun ofMixed(mixed: List) = - Value(mixed = mixed.toImmutable()) - } - - /** - * An interface that defines how to map each variant of [Value] to a - * value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - fun visitMixed(mixed: List): T - - /** - * Maps an unknown variant of [Value] to a value of type [T]. - * - * An instance of [Value] can contain an unknown variant if it - * was deserialized from data that doesn't match any known - * variant. For example, if the SDK is on an older version than - * the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Value: $json") - } - } - - internal class Serializer : BaseSerializer(Value::class) { - - override fun serialize( - value: Value, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> - generator.writeObject(value.string) - value.number != null -> - generator.writeObject(value.number) - value.bool != null -> generator.writeObject(value.bool) - value.mixed != null -> - generator.writeObject(value.mixed) - value._json != null -> - generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Value") - } - } - } - - @JsonSerialize( - using = UnnamedSchemaWithArrayParent5.Serializer::class - ) - class UnnamedSchemaWithArrayParent5 - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): UnnamedSchemaWithArrayParent5 = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnnamedSchemaWithArrayParent5 && - string == other.string && - number == other.number && - bool == other.bool - } - - override fun hashCode(): Int = - Objects.hash(string, number, bool) - - override fun toString(): String = - when { - string != null -> - "UnnamedSchemaWithArrayParent5{string=$string}" - number != null -> - "UnnamedSchemaWithArrayParent5{number=$number}" - bool != null -> - "UnnamedSchemaWithArrayParent5{bool=$bool}" - _json != null -> - "UnnamedSchemaWithArrayParent5{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent5" - ) - } - - companion object { - - @JvmStatic - fun ofString(string: String) = - UnnamedSchemaWithArrayParent5(string = string) - - @JvmStatic - fun ofNumber(number: Double) = - UnnamedSchemaWithArrayParent5(number = number) - - @JvmStatic - fun ofBool(bool: Boolean) = - UnnamedSchemaWithArrayParent5(bool = bool) - } - - /** - * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent5] to a value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - /** - * Maps an unknown variant of - * [UnnamedSchemaWithArrayParent5] to a value of type [T]. - * - * An instance of [UnnamedSchemaWithArrayParent5] can - * contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, - * if the SDK is on an older version than the API, then the - * API may respond with new variants that the SDK is unaware - * of. - * - * @throws ImageKitInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent5: $json" - ) - } - } - - internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent5::class - ) { - - override fun serialize( - value: UnnamedSchemaWithArrayParent5, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> - generator.writeObject(value.string) - value.number != null -> - generator.writeObject(value.number) - value.bool != null -> - generator.writeObject(value.bool) - value._json != null -> - generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent5" - ) - } - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SetMetadata && - field == other.field && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, value, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" - } - - class UnsetMetadata - private constructor( - private val field: JsonField, - private val additionalProperties: MutableMap, - ) { - - /** - * Name of the custom metadata field to remove. - * - * @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 field(): String = field.getRequired("field") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("field") - @ExcludeMissing - fun _field(): JsonField = field - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [UnsetMetadata]. - * - * The following fields are required: - * ```java - * .field() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnsetMetadata]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unsetMetadata: UnsetMetadata) = apply { - field = unsetMetadata.field - additionalProperties = - unsetMetadata.additionalProperties.toMutableMap() - } - - /** Name of the custom metadata field to remove. */ - fun field(field: String) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { this.field = field } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnsetMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .field() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UnsetMetadata = - UnsetMetadata( - checkRequired("field", field), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnsetMetadata = apply { - if (validated) { - return@apply - } - - field() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnsetMetadata && - field == other.field && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OnNo && - addTags == other.addTags && - removeTags == other.removeTags && - setMetadata == other.setMetadata && - unsetMetadata == other.unsetMetadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - addTags, - removeTags, - setMetadata, - unsetMetadata, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OnNo{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" - } - - /** Actions to execute if the AI cannot determine the answer. */ - class OnUnknown - private constructor( - private val addTags: JsonField>, - private val removeTags: JsonField>, - private val setMetadata: JsonField>, - private val unsetMetadata: JsonField>, - private val additionalProperties: MutableMap, - ) { - - /** - * Array of tag strings to add to the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun addTags(): Optional> = addTags.getOptional("add_tags") - - /** - * Array of tag strings to remove from the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun removeTags(): Optional> = - removeTags.getOptional("remove_tags") - - /** - * Array of custom metadata field updates. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun setMetadata(): Optional> = - setMetadata.getOptional("set_metadata") - - /** - * Array of custom metadata fields to remove. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun unsetMetadata(): Optional> = - unsetMetadata.getOptional("unset_metadata") - - /** - * Returns the raw JSON value of [addTags]. - * - * Unlike [addTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("add_tags") - @ExcludeMissing - fun _addTags(): JsonField> = addTags - - /** - * Returns the raw JSON value of [removeTags]. - * - * Unlike [removeTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("remove_tags") - @ExcludeMissing - fun _removeTags(): JsonField> = removeTags - - /** - * Returns the raw JSON value of [setMetadata]. - * - * Unlike [setMetadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("set_metadata") - @ExcludeMissing - fun _setMetadata(): JsonField> = setMetadata - - /** - * Returns the raw JSON value of [unsetMetadata]. - * - * Unlike [unsetMetadata], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("unset_metadata") - @ExcludeMissing - fun _unsetMetadata(): JsonField> = unsetMetadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [OnUnknown]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OnUnknown]. */ - class Builder internal constructor() { - - private var addTags: JsonField>? = null - private var removeTags: JsonField>? = null - private var setMetadata: JsonField>? = null - private var unsetMetadata: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(onUnknown: OnUnknown) = apply { - addTags = onUnknown.addTags.map { it.toMutableList() } - removeTags = onUnknown.removeTags.map { it.toMutableList() } - setMetadata = onUnknown.setMetadata.map { it.toMutableList() } - unsetMetadata = onUnknown.unsetMetadata.map { it.toMutableList() } - additionalProperties = onUnknown.additionalProperties.toMutableMap() - } - - /** Array of tag strings to add to the asset. */ - fun addTags(addTags: List) = addTags(JsonField.of(addTags)) - - /** - * Sets [Builder.addTags] to an arbitrary JSON value. - * - * You should usually call [Builder.addTags] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun addTags(addTags: JsonField>) = apply { - this.addTags = addTags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [addTags]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addAddTag(addTag: String) = apply { - addTags = - (addTags ?: JsonField.of(mutableListOf())).also { - checkKnown("addTags", it).add(addTag) - } - } - - /** Array of tag strings to remove from the asset. */ - fun removeTags(removeTags: List) = - removeTags(JsonField.of(removeTags)) - - /** - * Sets [Builder.removeTags] to an arbitrary JSON value. - * - * You should usually call [Builder.removeTags] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun removeTags(removeTags: JsonField>) = apply { - this.removeTags = removeTags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [removeTags]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addRemoveTag(removeTag: String) = apply { - removeTags = - (removeTags ?: JsonField.of(mutableListOf())).also { - checkKnown("removeTags", it).add(removeTag) - } - } - - /** Array of custom metadata field updates. */ - fun setMetadata(setMetadata: List) = - setMetadata(JsonField.of(setMetadata)) - - /** - * Sets [Builder.setMetadata] to an arbitrary JSON value. - * - * You should usually call [Builder.setMetadata] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun setMetadata(setMetadata: JsonField>) = apply { - this.setMetadata = setMetadata.map { it.toMutableList() } - } - - /** - * Adds a single [SetMetadata] to [Builder.setMetadata]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addSetMetadata(setMetadata: SetMetadata) = apply { - this.setMetadata = - (this.setMetadata ?: JsonField.of(mutableListOf())).also { - checkKnown("setMetadata", it).add(setMetadata) - } - } - - /** Array of custom metadata fields to remove. */ - fun unsetMetadata(unsetMetadata: List) = - unsetMetadata(JsonField.of(unsetMetadata)) - - /** - * Sets [Builder.unsetMetadata] to an arbitrary JSON value. - * - * You should usually call [Builder.unsetMetadata] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun unsetMetadata(unsetMetadata: JsonField>) = - apply { - this.unsetMetadata = unsetMetadata.map { it.toMutableList() } - } - - /** - * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { - this.unsetMetadata = - (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { - checkKnown("unsetMetadata", it).add(unsetMetadata) - } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [OnUnknown]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): OnUnknown = - OnUnknown( - (addTags ?: JsonMissing.of()).map { it.toImmutable() }, - (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, - (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, - (unsetMetadata ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): OnUnknown = apply { - if (validated) { - return@apply - } - - addTags() - removeTags() - setMetadata().ifPresent { it.forEach { it.validate() } } - unsetMetadata().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - class SetMetadata - private constructor( - private val field: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - /** - * Name of the custom metadata field to set. - * - * @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 field(): String = field.getRequired("field") - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - * - * @throws ImageKitInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the - * server responded with an unexpected value). - */ - fun value(): Value = value.getRequired("value") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("field") - @ExcludeMissing - fun _field(): JsonField = field - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SetMetadata]. - * - * The following fields are required: - * ```java - * .field() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SetMetadata]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(setMetadata: SetMetadata) = apply { - field = setMetadata.field - value = setMetadata.value - additionalProperties = - setMetadata.additionalProperties.toMutableMap() - } - - /** Name of the custom metadata field to set. */ - fun field(field: String) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { this.field = field } - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - */ - fun value(value: Value) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [Value] - * value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - /** Alias for calling [value] with `Value.ofString(string)`. */ - fun value(string: String) = value(Value.ofString(string)) - - /** Alias for calling [value] with `Value.ofNumber(number)`. */ - fun value(number: Double) = value(Value.ofNumber(number)) - - /** Alias for calling [value] with `Value.ofBool(bool)`. */ - fun value(bool: Boolean) = value(Value.ofBool(bool)) - - /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ - fun valueOfMixed(mixed: List) = - value(Value.ofMixed(mixed)) - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SetMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .field() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SetMetadata = - SetMetadata( - checkRequired("field", field), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SetMetadata = apply { - if (validated) { - return@apply - } - - field() - value().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - */ - @JsonSerialize(using = Value.Serializer::class) - class Value - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val mixed: List? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun mixed(): Optional> = - Optional.ofNullable(mixed) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun isMixed(): Boolean = mixed != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun asMixed(): List = - mixed.getOrThrow("mixed") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - mixed != null -> visitor.visitMixed(mixed) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Value = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} - - override fun visitMixed( - mixed: List - ) { - mixed.forEach { it.validate() } - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Value && - string == other.string && - number == other.number && - bool == other.bool && - mixed == other.mixed - } - - override fun hashCode(): Int = - Objects.hash(string, number, bool, mixed) - - override fun toString(): String = - when { - string != null -> "Value{string=$string}" - number != null -> "Value{number=$number}" - bool != null -> "Value{bool=$bool}" - mixed != null -> "Value{mixed=$mixed}" - _json != null -> "Value{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Value") - } - - companion object { - - @JvmStatic fun ofString(string: String) = Value(string = string) - - @JvmStatic fun ofNumber(number: Double) = Value(number = number) - - @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) - - @JvmStatic - fun ofMixed(mixed: List) = - Value(mixed = mixed.toImmutable()) - } - - /** - * An interface that defines how to map each variant of [Value] to a - * value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - fun visitMixed(mixed: List): T - - /** - * Maps an unknown variant of [Value] to a value of type [T]. - * - * An instance of [Value] can contain an unknown variant if it - * was deserialized from data that doesn't match any known - * variant. For example, if the SDK is on an older version than - * the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Value: $json") - } - } - - internal class Serializer : BaseSerializer(Value::class) { - - override fun serialize( - value: Value, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> - generator.writeObject(value.string) - value.number != null -> - generator.writeObject(value.number) - value.bool != null -> generator.writeObject(value.bool) - value.mixed != null -> - generator.writeObject(value.mixed) - value._json != null -> - generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Value") - } - } - } - - @JsonSerialize( - using = UnnamedSchemaWithArrayParent6.Serializer::class - ) - class UnnamedSchemaWithArrayParent6 - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): UnnamedSchemaWithArrayParent6 = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnnamedSchemaWithArrayParent6 && - string == other.string && - number == other.number && - bool == other.bool - } - - override fun hashCode(): Int = - Objects.hash(string, number, bool) - - override fun toString(): String = - when { - string != null -> - "UnnamedSchemaWithArrayParent6{string=$string}" - number != null -> - "UnnamedSchemaWithArrayParent6{number=$number}" - bool != null -> - "UnnamedSchemaWithArrayParent6{bool=$bool}" - _json != null -> - "UnnamedSchemaWithArrayParent6{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent6" - ) - } - - companion object { - - @JvmStatic - fun ofString(string: String) = - UnnamedSchemaWithArrayParent6(string = string) - - @JvmStatic - fun ofNumber(number: Double) = - UnnamedSchemaWithArrayParent6(number = number) - - @JvmStatic - fun ofBool(bool: Boolean) = - UnnamedSchemaWithArrayParent6(bool = bool) - } - - /** - * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent6] to a value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - /** - * Maps an unknown variant of - * [UnnamedSchemaWithArrayParent6] to a value of type [T]. - * - * An instance of [UnnamedSchemaWithArrayParent6] can - * contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, - * if the SDK is on an older version than the API, then the - * API may respond with new variants that the SDK is unaware - * of. - * - * @throws ImageKitInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent6: $json" - ) - } - } - - internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent6::class - ) { - - override fun serialize( - value: UnnamedSchemaWithArrayParent6, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> - generator.writeObject(value.string) - value.number != null -> - generator.writeObject(value.number) - value.bool != null -> - generator.writeObject(value.bool) - value._json != null -> - generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent6" - ) - } - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SetMetadata && - field == other.field && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, value, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" - } - - class UnsetMetadata - private constructor( - private val field: JsonField, - private val additionalProperties: MutableMap, - ) { - - /** - * Name of the custom metadata field to remove. - * - * @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 field(): String = field.getRequired("field") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("field") - @ExcludeMissing - fun _field(): JsonField = field - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [UnsetMetadata]. - * - * The following fields are required: - * ```java - * .field() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnsetMetadata]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unsetMetadata: UnsetMetadata) = apply { - field = unsetMetadata.field - additionalProperties = - unsetMetadata.additionalProperties.toMutableMap() - } - - /** Name of the custom metadata field to remove. */ - fun field(field: String) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { this.field = field } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnsetMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .field() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UnsetMetadata = - UnsetMetadata( - checkRequired("field", field), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnsetMetadata = apply { - if (validated) { - return@apply - } - - field() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnsetMetadata && - field == other.field && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OnUnknown && - addTags == other.addTags && - removeTags == other.removeTags && - setMetadata == other.setMetadata && - unsetMetadata == other.unsetMetadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - addTags, - removeTags, - setMetadata, - unsetMetadata, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OnUnknown{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" - } - - /** Actions to execute if the AI answers yes. */ - class OnYes - private constructor( - private val addTags: JsonField>, - private val removeTags: JsonField>, - private val setMetadata: JsonField>, - private val unsetMetadata: JsonField>, - private val additionalProperties: MutableMap, - ) { - - /** - * Array of tag strings to add to the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun addTags(): Optional> = addTags.getOptional("add_tags") - - /** - * Array of tag strings to remove from the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun removeTags(): Optional> = - removeTags.getOptional("remove_tags") - - /** - * Array of custom metadata field updates. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun setMetadata(): Optional> = - setMetadata.getOptional("set_metadata") - - /** - * Array of custom metadata fields to remove. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun unsetMetadata(): Optional> = - unsetMetadata.getOptional("unset_metadata") - - /** - * Returns the raw JSON value of [addTags]. - * - * Unlike [addTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("add_tags") - @ExcludeMissing - fun _addTags(): JsonField> = addTags - - /** - * Returns the raw JSON value of [removeTags]. - * - * Unlike [removeTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("remove_tags") - @ExcludeMissing - fun _removeTags(): JsonField> = removeTags - - /** - * Returns the raw JSON value of [setMetadata]. - * - * Unlike [setMetadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("set_metadata") - @ExcludeMissing - fun _setMetadata(): JsonField> = setMetadata - - /** - * Returns the raw JSON value of [unsetMetadata]. - * - * Unlike [unsetMetadata], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("unset_metadata") - @ExcludeMissing - fun _unsetMetadata(): JsonField> = unsetMetadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [OnYes]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OnYes]. */ - class Builder internal constructor() { - - private var addTags: JsonField>? = null - private var removeTags: JsonField>? = null - private var setMetadata: JsonField>? = null - private var unsetMetadata: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(onYes: OnYes) = apply { - addTags = onYes.addTags.map { it.toMutableList() } - removeTags = onYes.removeTags.map { it.toMutableList() } - setMetadata = onYes.setMetadata.map { it.toMutableList() } - unsetMetadata = onYes.unsetMetadata.map { it.toMutableList() } - additionalProperties = onYes.additionalProperties.toMutableMap() - } - - /** Array of tag strings to add to the asset. */ - fun addTags(addTags: List) = addTags(JsonField.of(addTags)) - - /** - * Sets [Builder.addTags] to an arbitrary JSON value. - * - * You should usually call [Builder.addTags] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun addTags(addTags: JsonField>) = apply { - this.addTags = addTags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [addTags]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addAddTag(addTag: String) = apply { - addTags = - (addTags ?: JsonField.of(mutableListOf())).also { - checkKnown("addTags", it).add(addTag) - } - } - - /** Array of tag strings to remove from the asset. */ - fun removeTags(removeTags: List) = - removeTags(JsonField.of(removeTags)) - - /** - * Sets [Builder.removeTags] to an arbitrary JSON value. - * - * You should usually call [Builder.removeTags] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun removeTags(removeTags: JsonField>) = apply { - this.removeTags = removeTags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [removeTags]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addRemoveTag(removeTag: String) = apply { - removeTags = - (removeTags ?: JsonField.of(mutableListOf())).also { - checkKnown("removeTags", it).add(removeTag) - } - } - - /** Array of custom metadata field updates. */ - fun setMetadata(setMetadata: List) = - setMetadata(JsonField.of(setMetadata)) - - /** - * Sets [Builder.setMetadata] to an arbitrary JSON value. - * - * You should usually call [Builder.setMetadata] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun setMetadata(setMetadata: JsonField>) = apply { - this.setMetadata = setMetadata.map { it.toMutableList() } - } - - /** - * Adds a single [SetMetadata] to [Builder.setMetadata]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addSetMetadata(setMetadata: SetMetadata) = apply { - this.setMetadata = - (this.setMetadata ?: JsonField.of(mutableListOf())).also { - checkKnown("setMetadata", it).add(setMetadata) - } - } - - /** Array of custom metadata fields to remove. */ - fun unsetMetadata(unsetMetadata: List) = - unsetMetadata(JsonField.of(unsetMetadata)) - - /** - * Sets [Builder.unsetMetadata] to an arbitrary JSON value. - * - * You should usually call [Builder.unsetMetadata] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun unsetMetadata(unsetMetadata: JsonField>) = - apply { - this.unsetMetadata = unsetMetadata.map { it.toMutableList() } - } - - /** - * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { - this.unsetMetadata = - (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { - checkKnown("unsetMetadata", it).add(unsetMetadata) - } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [OnYes]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): OnYes = - OnYes( - (addTags ?: JsonMissing.of()).map { it.toImmutable() }, - (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, - (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, - (unsetMetadata ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): OnYes = apply { - if (validated) { - return@apply - } - - addTags() - removeTags() - setMetadata().ifPresent { it.forEach { it.validate() } } - unsetMetadata().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - class SetMetadata - private constructor( - private val field: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - /** - * Name of the custom metadata field to set. - * - * @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 field(): String = field.getRequired("field") - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - * - * @throws ImageKitInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the - * server responded with an unexpected value). - */ - fun value(): Value = value.getRequired("value") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("field") - @ExcludeMissing - fun _field(): JsonField = field - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SetMetadata]. - * - * The following fields are required: - * ```java - * .field() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SetMetadata]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(setMetadata: SetMetadata) = apply { - field = setMetadata.field - value = setMetadata.value - additionalProperties = - setMetadata.additionalProperties.toMutableMap() - } - - /** Name of the custom metadata field to set. */ - fun field(field: String) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { this.field = field } - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - */ - fun value(value: Value) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [Value] - * value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - /** Alias for calling [value] with `Value.ofString(string)`. */ - fun value(string: String) = value(Value.ofString(string)) - - /** Alias for calling [value] with `Value.ofNumber(number)`. */ - fun value(number: Double) = value(Value.ofNumber(number)) - - /** Alias for calling [value] with `Value.ofBool(bool)`. */ - fun value(bool: Boolean) = value(Value.ofBool(bool)) - - /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ - fun valueOfMixed(mixed: List) = - value(Value.ofMixed(mixed)) - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SetMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .field() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SetMetadata = - SetMetadata( - checkRequired("field", field), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SetMetadata = apply { - if (validated) { - return@apply - } - - field() - value().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - */ - @JsonSerialize(using = Value.Serializer::class) - class Value - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val mixed: List? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun mixed(): Optional> = - Optional.ofNullable(mixed) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun isMixed(): Boolean = mixed != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun asMixed(): List = - mixed.getOrThrow("mixed") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - mixed != null -> visitor.visitMixed(mixed) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Value = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} - - override fun visitMixed( - mixed: List - ) { - mixed.forEach { it.validate() } - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Value && - string == other.string && - number == other.number && - bool == other.bool && - mixed == other.mixed - } - - override fun hashCode(): Int = - Objects.hash(string, number, bool, mixed) - - override fun toString(): String = - when { - string != null -> "Value{string=$string}" - number != null -> "Value{number=$number}" - bool != null -> "Value{bool=$bool}" - mixed != null -> "Value{mixed=$mixed}" - _json != null -> "Value{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Value") - } - - companion object { - - @JvmStatic fun ofString(string: String) = Value(string = string) - - @JvmStatic fun ofNumber(number: Double) = Value(number = number) - - @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) - - @JvmStatic - fun ofMixed(mixed: List) = - Value(mixed = mixed.toImmutable()) - } - - /** - * An interface that defines how to map each variant of [Value] to a - * value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - fun visitMixed(mixed: List): T - - /** - * Maps an unknown variant of [Value] to a value of type [T]. - * - * An instance of [Value] can contain an unknown variant if it - * was deserialized from data that doesn't match any known - * variant. For example, if the SDK is on an older version than - * the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Value: $json") - } - } - - internal class Serializer : BaseSerializer(Value::class) { - - override fun serialize( - value: Value, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> - generator.writeObject(value.string) - value.number != null -> - generator.writeObject(value.number) - value.bool != null -> generator.writeObject(value.bool) - value.mixed != null -> - generator.writeObject(value.mixed) - value._json != null -> - generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Value") - } - } - } - - @JsonSerialize( - using = UnnamedSchemaWithArrayParent7.Serializer::class - ) - class UnnamedSchemaWithArrayParent7 - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): UnnamedSchemaWithArrayParent7 = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnnamedSchemaWithArrayParent7 && - string == other.string && - number == other.number && - bool == other.bool - } - - override fun hashCode(): Int = - Objects.hash(string, number, bool) - - override fun toString(): String = - when { - string != null -> - "UnnamedSchemaWithArrayParent7{string=$string}" - number != null -> - "UnnamedSchemaWithArrayParent7{number=$number}" - bool != null -> - "UnnamedSchemaWithArrayParent7{bool=$bool}" - _json != null -> - "UnnamedSchemaWithArrayParent7{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent7" - ) - } - - companion object { - - @JvmStatic - fun ofString(string: String) = - UnnamedSchemaWithArrayParent7(string = string) - - @JvmStatic - fun ofNumber(number: Double) = - UnnamedSchemaWithArrayParent7(number = number) - - @JvmStatic - fun ofBool(bool: Boolean) = - UnnamedSchemaWithArrayParent7(bool = bool) - } - - /** - * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent7] to a value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - /** - * Maps an unknown variant of - * [UnnamedSchemaWithArrayParent7] to a value of type [T]. - * - * An instance of [UnnamedSchemaWithArrayParent7] can - * contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, - * if the SDK is on an older version than the API, then the - * API may respond with new variants that the SDK is unaware - * of. - * - * @throws ImageKitInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent7: $json" - ) - } - } - - internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent7::class - ) { - - override fun serialize( - value: UnnamedSchemaWithArrayParent7, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> - generator.writeObject(value.string) - value.number != null -> - generator.writeObject(value.number) - value.bool != null -> - generator.writeObject(value.bool) - value._json != null -> - generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent7" - ) - } - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SetMetadata && - field == other.field && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, value, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" - } - - class UnsetMetadata - private constructor( - private val field: JsonField, - private val additionalProperties: MutableMap, - ) { - - /** - * Name of the custom metadata field to remove. - * - * @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 field(): String = field.getRequired("field") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("field") - @ExcludeMissing - fun _field(): JsonField = field - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [UnsetMetadata]. - * - * The following fields are required: - * ```java - * .field() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnsetMetadata]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unsetMetadata: UnsetMetadata) = apply { - field = unsetMetadata.field - additionalProperties = - unsetMetadata.additionalProperties.toMutableMap() - } - - /** Name of the custom metadata field to remove. */ - fun field(field: String) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { this.field = field } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnsetMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .field() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UnsetMetadata = - UnsetMetadata( - checkRequired("field", field), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnsetMetadata = apply { - if (validated) { - return@apply - } - - field() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnsetMetadata && - field == other.field && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OnYes && - addTags == other.addTags && - removeTags == other.removeTags && - setMetadata == other.setMetadata && - unsetMetadata == other.unsetMetadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - addTags, - removeTags, - setMetadata, - unsetMetadata, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OnYes{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is YesNo && - instruction == other.instruction && - type == other.type && - onNo == other.onNo && - onUnknown == other.onUnknown && - onYes == other.onYes && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - instruction, - type, - onNo, - onUnknown, - onYes, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "YesNo{instruction=$instruction, type=$type, onNo=$onNo, onUnknown=$onUnknown, onYes=$onYes, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AiTasks && - name == other.name && - tasks == other.tasks && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(name, tasks, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AiTasks{name=$name, tasks=$tasks, additionalProperties=$additionalProperties}" - } - - class SavedExtension - private constructor( - private val id: JsonField, - private val name: JsonValue, - private val additionalProperties: MutableMap, - ) { - - /** - * The unique ID of the saved extension to apply. - * - * @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") - - /** - * Indicates this is a reference to a saved extension. - * - * Expected to always return the following: - * ```java - * JsonValue.from("saved-extension") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [SavedExtension]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SavedExtension]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonValue = JsonValue.from("saved-extension") - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(savedExtension: SavedExtension) = apply { - id = savedExtension.id - name = savedExtension.name - additionalProperties = savedExtension.additionalProperties.toMutableMap() - } - - /** The unique ID of the saved extension to apply. */ - 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 } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from("saved-extension") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonValue) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SavedExtension]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SavedExtension = - SavedExtension( - checkRequired("id", id), - name, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SavedExtension = apply { - if (validated) { - return@apply - } - - id() - _name().let { - if (it != JsonValue.from("saved-extension")) { - throw ImageKitInvalidDataException("'name' is invalid, received $it") - } - } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SavedExtension && - id == other.id && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SavedExtension{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - } - class ResponseField @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -8480,7 +2559,7 @@ private constructor( * * You can mix and match any combination of post-processing types. */ - class Transformation + class UploadTransformation private constructor( private val post: MultipartField>, private val pre: MultipartField, @@ -8533,11 +2612,11 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Transformation]. */ + /** Returns a mutable builder for constructing an instance of [UploadTransformation]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Transformation]. */ + /** A builder for [UploadTransformation]. */ class Builder internal constructor() { private var post: MultipartField>? = null @@ -8545,10 +2624,10 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(transformation: Transformation) = apply { - post = transformation.post.map { it.toMutableList() } - pre = transformation.pre - additionalProperties = transformation.additionalProperties.toMutableMap() + internal fun from(uploadTransformation: UploadTransformation) = apply { + post = uploadTransformation.post.map { it.toMutableList() } + pre = uploadTransformation.pre + additionalProperties = uploadTransformation.additionalProperties.toMutableMap() } /** @@ -8581,19 +2660,19 @@ private constructor( } /** Alias for calling [addPost] with `Post.ofTransformation(transformation)`. */ - fun addPost(transformation: Post.InnerTransformation) = + fun addPost(transformation: Post.Transformation) = addPost(Post.ofTransformation(transformation)) /** * Alias for calling [addPost] with the following: * ```java - * Post.InnerTransformation.builder() + * Post.Transformation.builder() * .value(value) * .build() * ``` */ fun addTransformationPost(value: String) = - addPost(Post.InnerTransformation.builder().value(value).build()) + addPost(Post.Transformation.builder().value(value).build()) /** Alias for calling [addPost] with `Post.ofGifToVideo(gifToVideo)`. */ fun addPost(gifToVideo: Post.GifToVideo) = addPost(Post.ofGifToVideo(gifToVideo)) @@ -8639,12 +2718,12 @@ private constructor( } /** - * Returns an immutable instance of [Transformation]. + * Returns an immutable instance of [UploadTransformation]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Transformation = - Transformation( + fun build(): UploadTransformation = + UploadTransformation( (post ?: MultipartField.of(null)).map { it.toImmutable() }, pre, additionalProperties.toMutableMap(), @@ -8653,7 +2732,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Transformation = apply { + fun validate(): UploadTransformation = apply { if (validated) { return@apply } @@ -8674,15 +2753,14 @@ private constructor( @JsonSerialize(using = Post.Serializer::class) class Post private constructor( - private val transformation: InnerTransformation? = null, + private val transformation: Transformation? = null, private val gifToVideo: GifToVideo? = null, private val thumbnail: Thumbnail? = null, private val abs: Abs? = null, private val _json: JsonValue? = null, ) { - fun transformation(): Optional = - Optional.ofNullable(transformation) + fun transformation(): Optional = Optional.ofNullable(transformation) fun gifToVideo(): Optional = Optional.ofNullable(gifToVideo) @@ -8698,8 +2776,7 @@ private constructor( fun isAbs(): Boolean = abs != null - fun asTransformation(): InnerTransformation = - transformation.getOrThrow("transformation") + fun asTransformation(): Transformation = transformation.getOrThrow("transformation") fun asGifToVideo(): GifToVideo = gifToVideo.getOrThrow("gifToVideo") @@ -8727,7 +2804,7 @@ private constructor( accept( object : Visitor { - override fun visitTransformation(transformation: InnerTransformation) { + override fun visitTransformation(transformation: Transformation) { transformation.validate() } @@ -8782,7 +2859,7 @@ private constructor( companion object { @JvmStatic - fun ofTransformation(transformation: InnerTransformation) = + fun ofTransformation(transformation: Transformation) = Post(transformation = transformation) @JvmStatic fun ofGifToVideo(gifToVideo: GifToVideo) = Post(gifToVideo = gifToVideo) @@ -8797,7 +2874,7 @@ private constructor( */ interface Visitor { - fun visitTransformation(transformation: InnerTransformation): T + fun visitTransformation(transformation: Transformation): T fun visitGifToVideo(gifToVideo: GifToVideo): T @@ -8838,7 +2915,7 @@ private constructor( } } - class InnerTransformation + class Transformation private constructor( private val type: JsonValue, private val value: MultipartField, @@ -8891,8 +2968,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [InnerTransformation]. + * Returns a mutable builder for constructing an instance of [Transformation]. * * The following fields are required: * ```java @@ -8902,7 +2978,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [InnerTransformation]. */ + /** A builder for [Transformation]. */ class Builder internal constructor() { private var type: JsonValue = JsonValue.from("transformation") @@ -8910,11 +2986,10 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(innerTransformation: InnerTransformation) = apply { - type = innerTransformation.type - value = innerTransformation.value - additionalProperties = - innerTransformation.additionalProperties.toMutableMap() + internal fun from(transformation: Transformation) = apply { + type = transformation.type + value = transformation.value + additionalProperties = transformation.additionalProperties.toMutableMap() } /** @@ -8969,7 +3044,7 @@ private constructor( } /** - * Returns an immutable instance of [InnerTransformation]. + * Returns an immutable instance of [Transformation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -8980,8 +3055,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): InnerTransformation = - InnerTransformation( + fun build(): Transformation = + Transformation( type, checkRequired("value", value), additionalProperties.toMutableMap(), @@ -8990,7 +3065,7 @@ private constructor( private var validated: Boolean = false - fun validate(): InnerTransformation = apply { + fun validate(): Transformation = apply { if (validated) { return@apply } @@ -9017,7 +3092,7 @@ private constructor( return true } - return other is InnerTransformation && + return other is Transformation && type == other.type && value == other.value && additionalProperties == other.additionalProperties @@ -9030,7 +3105,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InnerTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" + "Transformation{type=$type, value=$value, additionalProperties=$additionalProperties}" } class GifToVideo @@ -9751,7 +3826,7 @@ private constructor( return true } - return other is Transformation && + return other is UploadTransformation && post == other.post && pre == other.pre && additionalProperties == other.additionalProperties @@ -9762,7 +3837,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Transformation{post=$post, pre=$pre, additionalProperties=$additionalProperties}" + "UploadTransformation{post=$post, pre=$pre, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt index e66283d8..2cd0297c 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt @@ -14,6 +14,11 @@ import com.imagekit.api.core.JsonValue import com.imagekit.api.core.checkKnown import com.imagekit.api.core.toImmutable import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.AiTag +import com.imagekit.api.models.CustomMetadata +import com.imagekit.api.models.EmbeddedMetadata +import com.imagekit.api.models.SelectedFieldsSchema +import com.imagekit.api.models.VersionInfo import com.imagekit.api.models.files.Metadata import java.util.Collections import java.util.Objects @@ -1164,433 +1169,6 @@ private constructor( (if (videoCodec.asKnown().isPresent) 1 else 0) + (if (width.asKnown().isPresent) 1 else 0) - /** - * AI-generated tag associated with an image. These tags can be added using the - * `google-auto-tagging` or `aws-auto-tagging` extensions. - */ - class AiTag - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val confidence: JsonField, - private val name: JsonField, - private val source: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("confidence") - @ExcludeMissing - confidence: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), - ) : this(confidence, name, source, mutableMapOf()) - - /** - * Confidence score of the tag. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun confidence(): Optional = confidence.getOptional("confidence") - - /** - * Name of the tag. - * - * @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") - - /** - * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun source(): Optional = source.getOptional("source") - - /** - * Returns the raw JSON value of [confidence]. - * - * Unlike [confidence], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("confidence") - @ExcludeMissing - fun _confidence(): JsonField = confidence - - /** - * 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 [source]. - * - * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [AiTag]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AiTag]. */ - class Builder internal constructor() { - - private var confidence: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var source: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(aiTag: AiTag) = apply { - confidence = aiTag.confidence - name = aiTag.name - source = aiTag.source - additionalProperties = aiTag.additionalProperties.toMutableMap() - } - - /** Confidence score of the tag. */ - fun confidence(confidence: Double) = confidence(JsonField.of(confidence)) - - /** - * Sets [Builder.confidence] to an arbitrary JSON value. - * - * You should usually call [Builder.confidence] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun confidence(confidence: JsonField) = apply { this.confidence = confidence } - - /** Name of the tag. */ - 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 } - - /** - * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. - */ - fun source(source: String) = source(JsonField.of(source)) - - /** - * Sets [Builder.source] to an arbitrary JSON value. - * - * You should usually call [Builder.source] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun source(source: JsonField) = apply { this.source = source } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AiTag]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AiTag = - AiTag(confidence, name, source, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): AiTag = apply { - if (validated) { - return@apply - } - - confidence() - name() - source() - 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 (confidence.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (source.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AiTag && - confidence == other.confidence && - name == other.name && - source == other.source && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(confidence, name, source, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AiTag{confidence=$confidence, name=$name, source=$source, additionalProperties=$additionalProperties}" - } - - /** A key-value data associated with the asset. */ - class CustomMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [CustomMetadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customMetadata: CustomMetadata) = apply { - additionalProperties = customMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [CustomMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): CustomMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CustomMetadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" - } - - /** - * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp - * data. - */ - class EmbeddedMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [EmbeddedMetadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EmbeddedMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(embeddedMetadata: EmbeddedMetadata) = apply { - additionalProperties = embeddedMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [EmbeddedMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): EmbeddedMetadata = EmbeddedMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): EmbeddedMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EmbeddedMetadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "EmbeddedMetadata{additionalProperties=$additionalProperties}" - } - /** * Extension names with their processing status at the time of completion of the request. It * could have one of the following status values: @@ -2608,293 +2186,6 @@ private constructor( "ExtensionStatus{aiAutoDescription=$aiAutoDescription, aiTasks=$aiTasks, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" } - /** - * This field is included in the response only if the Path policy feature is available in the - * plan. It contains schema definitions for the custom metadata fields selected for the - * specified file path. Field selection can only be done when the Path policy feature is - * enabled. - * - * Keys are the names of the custom metadata fields; the value object has details about the - * custom metadata schema. - */ - class SelectedFieldsSchema - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [SelectedFieldsSchema]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SelectedFieldsSchema]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(selectedFieldsSchema: SelectedFieldsSchema) = apply { - additionalProperties = selectedFieldsSchema.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SelectedFieldsSchema]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): SelectedFieldsSchema = - SelectedFieldsSchema(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): SelectedFieldsSchema = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SelectedFieldsSchema && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "SelectedFieldsSchema{additionalProperties=$additionalProperties}" - } - - /** An object containing the file or file version's `id` (versionId) and `name`. */ - class VersionInfo - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(id, name, mutableMapOf()) - - /** - * Unique identifier of the file version. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") - - /** - * Name of the file version. - * - * @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") - - /** - * 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 [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [VersionInfo]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [VersionInfo]. */ - class Builder internal constructor() { - - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(versionInfo: VersionInfo) = apply { - id = versionInfo.id - name = versionInfo.name - additionalProperties = versionInfo.additionalProperties.toMutableMap() - } - - /** Unique identifier of the file version. */ - 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 } - - /** Name of the file version. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [VersionInfo]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): VersionInfo = VersionInfo(id, name, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): VersionInfo = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is VersionInfo && - id == other.id && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "VersionInfo{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt index d5d717ea..a9c08142 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt @@ -562,7 +562,7 @@ private constructor( fun defaultValue(bool: Boolean) = defaultValue(DefaultValue.ofBool(bool)) /** Alias for calling [defaultValue] with `DefaultValue.ofMixed(mixed)`. */ - fun defaultValueOfMixed(mixed: List) = + fun defaultValueOfMixed(mixed: List) = defaultValue(DefaultValue.ofMixed(mixed)) /** Specifies if the this custom metadata field is required or not. */ @@ -941,7 +941,7 @@ private constructor( private val string: String? = null, private val number: Double? = null, private val bool: Boolean? = null, - private val mixed: List? = null, + private val mixed: List? = null, private val _json: JsonValue? = null, ) { @@ -955,7 +955,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun mixed(): Optional> = Optional.ofNullable(mixed) + fun mixed(): Optional> = Optional.ofNullable(mixed) fun isString(): Boolean = string != null @@ -975,7 +975,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun asMixed(): List = mixed.getOrThrow("mixed") + fun asMixed(): List = mixed.getOrThrow("mixed") fun _json(): Optional = Optional.ofNullable(_json) @@ -1003,7 +1003,7 @@ private constructor( override fun visitBool(bool: Boolean) {} - override fun visitMixed(mixed: List) { + override fun visitMixed(mixed: List) { mixed.forEach { it.validate() } } } @@ -1035,7 +1035,7 @@ private constructor( override fun visitBool(bool: Boolean) = 1 - override fun visitMixed(mixed: List) = + override fun visitMixed(mixed: List) = mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 @@ -1079,7 +1079,7 @@ private constructor( * `MultiSelect`. */ @JvmStatic - fun ofMixed(mixed: List) = + fun ofMixed(mixed: List) = DefaultValue(mixed = mixed.toImmutable()) } @@ -1099,7 +1099,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun visitMixed(mixed: List): T + fun visitMixed(mixed: List): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1132,10 +1132,7 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { DefaultValue(bool = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef>(), - ) + tryDeserialize(node, jacksonTypeRef>()) ?.let { DefaultValue(mixed = it, _json = json) }, ) .filterNotNull() @@ -1172,9 +1169,9 @@ private constructor( } } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent3.Deserializer::class) - @JsonSerialize(using = UnnamedSchemaWithArrayParent3.Serializer::class) - class UnnamedSchemaWithArrayParent3 + @JsonDeserialize(using = DefaultValueItem.Deserializer::class) + @JsonSerialize(using = DefaultValueItem.Serializer::class) + class DefaultValueItem private constructor( private val string: String? = null, private val number: Double? = null, @@ -1212,7 +1209,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent3 = apply { + fun validate(): DefaultValueItem = apply { if (validated) { return@apply } @@ -1262,7 +1259,7 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent3 && + return other is DefaultValueItem && string == other.string && number == other.number && bool == other.bool @@ -1272,28 +1269,25 @@ private constructor( override fun toString(): String = when { - string != null -> "UnnamedSchemaWithArrayParent3{string=$string}" - number != null -> "UnnamedSchemaWithArrayParent3{number=$number}" - bool != null -> "UnnamedSchemaWithArrayParent3{bool=$bool}" - _json != null -> "UnnamedSchemaWithArrayParent3{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") + string != null -> "DefaultValueItem{string=$string}" + number != null -> "DefaultValueItem{number=$number}" + bool != null -> "DefaultValueItem{bool=$bool}" + _json != null -> "DefaultValueItem{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DefaultValueItem") } companion object { - @JvmStatic - fun ofString(string: String) = UnnamedSchemaWithArrayParent3(string = string) + @JvmStatic fun ofString(string: String) = DefaultValueItem(string = string) - @JvmStatic - fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent3(number = number) + @JvmStatic fun ofNumber(number: Double) = DefaultValueItem(number = number) - @JvmStatic - fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent3(bool = bool) + @JvmStatic fun ofBool(bool: Boolean) = DefaultValueItem(bool = bool) } /** - * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent3] to a value of type [T]. + * An interface that defines how to map each variant of [DefaultValueItem] to a + * value of type [T]. */ interface Visitor { @@ -1304,43 +1298,36 @@ private constructor( fun visitBool(bool: Boolean): T /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent3] to a value of type - * [T]. + * Maps an unknown variant of [DefaultValueItem] to a value of type [T]. * - * An instance of [UnnamedSchemaWithArrayParent3] can contain an unknown variant - * if it was deserialized from data that doesn't match any known variant. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new variants that the SDK is unaware of. + * An instance of [DefaultValueItem] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. * * @throws ImageKitInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent3: $json" - ) + throw ImageKitInvalidDataException("Unknown DefaultValueItem: $json") } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent3::class - ) { + BaseDeserializer(DefaultValueItem::class) { - override fun ObjectCodec.deserialize( - node: JsonNode - ): UnnamedSchemaWithArrayParent3 { + override fun ObjectCodec.deserialize(node: JsonNode): DefaultValueItem { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent3(string = it, _json = json) + DefaultValueItem(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent3(number = it, _json = json) + DefaultValueItem(number = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent3(bool = it, _json = json) + DefaultValueItem(bool = it, _json = json) }, ) .filterNotNull() @@ -1350,7 +1337,7 @@ private constructor( // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from // object). - 0 -> UnnamedSchemaWithArrayParent3(_json = json) + 0 -> DefaultValueItem(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use // the first completely valid match, or simply the first match if none @@ -1361,12 +1348,10 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent3::class - ) { + BaseSerializer(DefaultValueItem::class) { override fun serialize( - value: UnnamedSchemaWithArrayParent3, + value: DefaultValueItem, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -1375,8 +1360,7 @@ private constructor( value.number != null -> generator.writeObject(value.number) value.bool != null -> generator.writeObject(value.bool) value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent3") + else -> throw IllegalStateException("Invalid DefaultValueItem") } } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt index 81b0ae90..3878c620 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt @@ -856,7 +856,7 @@ private constructor( fun defaultValue(bool: Boolean) = defaultValue(DefaultValue.ofBool(bool)) /** Alias for calling [defaultValue] with `DefaultValue.ofMixed(mixed)`. */ - fun defaultValueOfMixed(mixed: List) = + fun defaultValueOfMixed(mixed: List) = defaultValue(DefaultValue.ofMixed(mixed)) /** @@ -1249,7 +1249,7 @@ private constructor( private val string: String? = null, private val number: Double? = null, private val bool: Boolean? = null, - private val mixed: List? = null, + private val mixed: List? = null, private val _json: JsonValue? = null, ) { @@ -1263,7 +1263,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun mixed(): Optional> = Optional.ofNullable(mixed) + fun mixed(): Optional> = Optional.ofNullable(mixed) fun isString(): Boolean = string != null @@ -1283,7 +1283,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun asMixed(): List = mixed.getOrThrow("mixed") + fun asMixed(): List = mixed.getOrThrow("mixed") fun _json(): Optional = Optional.ofNullable(_json) @@ -1311,7 +1311,7 @@ private constructor( override fun visitBool(bool: Boolean) {} - override fun visitMixed(mixed: List) { + override fun visitMixed(mixed: List) { mixed.forEach { it.validate() } } } @@ -1343,7 +1343,7 @@ private constructor( override fun visitBool(bool: Boolean) = 1 - override fun visitMixed(mixed: List) = + override fun visitMixed(mixed: List) = mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 @@ -1387,7 +1387,7 @@ private constructor( * `MultiSelect`. */ @JvmStatic - fun ofMixed(mixed: List) = + fun ofMixed(mixed: List) = DefaultValue(mixed = mixed.toImmutable()) } @@ -1407,7 +1407,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun visitMixed(mixed: List): T + fun visitMixed(mixed: List): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1440,10 +1440,7 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { DefaultValue(bool = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef>(), - ) + tryDeserialize(node, jacksonTypeRef>()) ?.let { DefaultValue(mixed = it, _json = json) }, ) .filterNotNull() @@ -1480,9 +1477,9 @@ private constructor( } } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent8.Deserializer::class) - @JsonSerialize(using = UnnamedSchemaWithArrayParent8.Serializer::class) - class UnnamedSchemaWithArrayParent8 + @JsonDeserialize(using = DefaultValueItem.Deserializer::class) + @JsonSerialize(using = DefaultValueItem.Serializer::class) + class DefaultValueItem private constructor( private val string: String? = null, private val number: Double? = null, @@ -1520,7 +1517,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent8 = apply { + fun validate(): DefaultValueItem = apply { if (validated) { return@apply } @@ -1570,7 +1567,7 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent8 && + return other is DefaultValueItem && string == other.string && number == other.number && bool == other.bool @@ -1580,28 +1577,25 @@ private constructor( override fun toString(): String = when { - string != null -> "UnnamedSchemaWithArrayParent8{string=$string}" - number != null -> "UnnamedSchemaWithArrayParent8{number=$number}" - bool != null -> "UnnamedSchemaWithArrayParent8{bool=$bool}" - _json != null -> "UnnamedSchemaWithArrayParent8{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent8") + string != null -> "DefaultValueItem{string=$string}" + number != null -> "DefaultValueItem{number=$number}" + bool != null -> "DefaultValueItem{bool=$bool}" + _json != null -> "DefaultValueItem{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DefaultValueItem") } companion object { - @JvmStatic - fun ofString(string: String) = UnnamedSchemaWithArrayParent8(string = string) + @JvmStatic fun ofString(string: String) = DefaultValueItem(string = string) - @JvmStatic - fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent8(number = number) + @JvmStatic fun ofNumber(number: Double) = DefaultValueItem(number = number) - @JvmStatic - fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent8(bool = bool) + @JvmStatic fun ofBool(bool: Boolean) = DefaultValueItem(bool = bool) } /** - * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent8] to a value of type [T]. + * An interface that defines how to map each variant of [DefaultValueItem] to a + * value of type [T]. */ interface Visitor { @@ -1612,43 +1606,36 @@ private constructor( fun visitBool(bool: Boolean): T /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent8] to a value of type - * [T]. + * Maps an unknown variant of [DefaultValueItem] to a value of type [T]. * - * An instance of [UnnamedSchemaWithArrayParent8] can contain an unknown variant - * if it was deserialized from data that doesn't match any known variant. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new variants that the SDK is unaware of. + * An instance of [DefaultValueItem] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. * * @throws ImageKitInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent8: $json" - ) + throw ImageKitInvalidDataException("Unknown DefaultValueItem: $json") } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent8::class - ) { + BaseDeserializer(DefaultValueItem::class) { - override fun ObjectCodec.deserialize( - node: JsonNode - ): UnnamedSchemaWithArrayParent8 { + override fun ObjectCodec.deserialize(node: JsonNode): DefaultValueItem { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent8(string = it, _json = json) + DefaultValueItem(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent8(number = it, _json = json) + DefaultValueItem(number = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent8(bool = it, _json = json) + DefaultValueItem(bool = it, _json = json) }, ) .filterNotNull() @@ -1658,7 +1645,7 @@ private constructor( // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from // object). - 0 -> UnnamedSchemaWithArrayParent8(_json = json) + 0 -> DefaultValueItem(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use // the first completely valid match, or simply the first match if none @@ -1669,12 +1656,10 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent8::class - ) { + BaseSerializer(DefaultValueItem::class) { override fun serialize( - value: UnnamedSchemaWithArrayParent8, + value: DefaultValueItem, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -1683,8 +1668,7 @@ private constructor( value.number != null -> generator.writeObject(value.number) value.bool != null -> generator.writeObject(value.bool) value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent8") + else -> throw IllegalStateException("Invalid DefaultValueItem") } } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt index 5454e40b..156b402e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt @@ -746,7 +746,7 @@ private constructor( fun defaultValue(bool: Boolean) = defaultValue(DefaultValue.ofBool(bool)) /** Alias for calling [defaultValue] with `DefaultValue.ofMixed(mixed)`. */ - fun defaultValueOfMixed(mixed: List) = + fun defaultValueOfMixed(mixed: List) = defaultValue(DefaultValue.ofMixed(mixed)) /** @@ -971,7 +971,7 @@ private constructor( private val string: String? = null, private val number: Double? = null, private val bool: Boolean? = null, - private val mixed: List? = null, + private val mixed: List? = null, private val _json: JsonValue? = null, ) { @@ -985,7 +985,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun mixed(): Optional> = Optional.ofNullable(mixed) + fun mixed(): Optional> = Optional.ofNullable(mixed) fun isString(): Boolean = string != null @@ -1005,7 +1005,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun asMixed(): List = mixed.getOrThrow("mixed") + fun asMixed(): List = mixed.getOrThrow("mixed") fun _json(): Optional = Optional.ofNullable(_json) @@ -1033,7 +1033,7 @@ private constructor( override fun visitBool(bool: Boolean) {} - override fun visitMixed(mixed: List) { + override fun visitMixed(mixed: List) { mixed.forEach { it.validate() } } } @@ -1065,7 +1065,7 @@ private constructor( override fun visitBool(bool: Boolean) = 1 - override fun visitMixed(mixed: List) = + override fun visitMixed(mixed: List) = mixed.sumOf { it.validity().toInt() } override fun unknown(json: JsonValue?) = 0 @@ -1109,7 +1109,7 @@ private constructor( * `MultiSelect`. */ @JvmStatic - fun ofMixed(mixed: List) = + fun ofMixed(mixed: List) = DefaultValue(mixed = mixed.toImmutable()) } @@ -1129,7 +1129,7 @@ private constructor( * Default value should be of type array when custom metadata field type is set to * `MultiSelect`. */ - fun visitMixed(mixed: List): T + fun visitMixed(mixed: List): T /** * Maps an unknown variant of [DefaultValue] to a value of type [T]. @@ -1162,10 +1162,7 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { DefaultValue(bool = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef>(), - ) + tryDeserialize(node, jacksonTypeRef>()) ?.let { DefaultValue(mixed = it, _json = json) }, ) .filterNotNull() @@ -1202,9 +1199,9 @@ private constructor( } } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent9.Deserializer::class) - @JsonSerialize(using = UnnamedSchemaWithArrayParent9.Serializer::class) - class UnnamedSchemaWithArrayParent9 + @JsonDeserialize(using = DefaultValueItem.Deserializer::class) + @JsonSerialize(using = DefaultValueItem.Serializer::class) + class DefaultValueItem private constructor( private val string: String? = null, private val number: Double? = null, @@ -1242,7 +1239,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnnamedSchemaWithArrayParent9 = apply { + fun validate(): DefaultValueItem = apply { if (validated) { return@apply } @@ -1292,7 +1289,7 @@ private constructor( return true } - return other is UnnamedSchemaWithArrayParent9 && + return other is DefaultValueItem && string == other.string && number == other.number && bool == other.bool @@ -1302,28 +1299,25 @@ private constructor( override fun toString(): String = when { - string != null -> "UnnamedSchemaWithArrayParent9{string=$string}" - number != null -> "UnnamedSchemaWithArrayParent9{number=$number}" - bool != null -> "UnnamedSchemaWithArrayParent9{bool=$bool}" - _json != null -> "UnnamedSchemaWithArrayParent9{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent9") + string != null -> "DefaultValueItem{string=$string}" + number != null -> "DefaultValueItem{number=$number}" + bool != null -> "DefaultValueItem{bool=$bool}" + _json != null -> "DefaultValueItem{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DefaultValueItem") } companion object { - @JvmStatic - fun ofString(string: String) = UnnamedSchemaWithArrayParent9(string = string) + @JvmStatic fun ofString(string: String) = DefaultValueItem(string = string) - @JvmStatic - fun ofNumber(number: Double) = UnnamedSchemaWithArrayParent9(number = number) + @JvmStatic fun ofNumber(number: Double) = DefaultValueItem(number = number) - @JvmStatic - fun ofBool(bool: Boolean) = UnnamedSchemaWithArrayParent9(bool = bool) + @JvmStatic fun ofBool(bool: Boolean) = DefaultValueItem(bool = bool) } /** - * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent9] to a value of type [T]. + * An interface that defines how to map each variant of [DefaultValueItem] to a + * value of type [T]. */ interface Visitor { @@ -1334,43 +1328,36 @@ private constructor( fun visitBool(bool: Boolean): T /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent9] to a value of type - * [T]. + * Maps an unknown variant of [DefaultValueItem] to a value of type [T]. * - * An instance of [UnnamedSchemaWithArrayParent9] can contain an unknown variant - * if it was deserialized from data that doesn't match any known variant. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new variants that the SDK is unaware of. + * An instance of [DefaultValueItem] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. * * @throws ImageKitInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent9: $json" - ) + throw ImageKitInvalidDataException("Unknown DefaultValueItem: $json") } } internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent9::class - ) { + BaseDeserializer(DefaultValueItem::class) { - override fun ObjectCodec.deserialize( - node: JsonNode - ): UnnamedSchemaWithArrayParent9 { + override fun ObjectCodec.deserialize(node: JsonNode): DefaultValueItem { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent9(string = it, _json = json) + DefaultValueItem(string = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent9(number = it, _json = json) + DefaultValueItem(number = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent9(bool = it, _json = json) + DefaultValueItem(bool = it, _json = json) }, ) .filterNotNull() @@ -1380,7 +1367,7 @@ private constructor( // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from // object). - 0 -> UnnamedSchemaWithArrayParent9(_json = json) + 0 -> DefaultValueItem(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use // the first completely valid match, or simply the first match if none @@ -1391,12 +1378,10 @@ private constructor( } internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent9::class - ) { + BaseSerializer(DefaultValueItem::class) { override fun serialize( - value: UnnamedSchemaWithArrayParent9, + value: DefaultValueItem, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -1405,8 +1390,7 @@ private constructor( value.number != null -> generator.writeObject(value.number) value.bool != null -> generator.writeObject(value.bool) value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent9") + else -> throw IllegalStateException("Invalid DefaultValueItem") } } } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt index 878b2277..b07ce3ff 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt @@ -14,6 +14,11 @@ import com.imagekit.api.core.JsonValue import com.imagekit.api.core.checkKnown import com.imagekit.api.core.toImmutable import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.AiTag +import com.imagekit.api.models.CustomMetadata +import com.imagekit.api.models.EmbeddedMetadata +import com.imagekit.api.models.SelectedFieldsSchema +import com.imagekit.api.models.VersionInfo import java.time.OffsetDateTime import java.util.Collections import java.util.Objects @@ -1221,543 +1226,6 @@ private constructor( (if (videoCodec.asKnown().isPresent) 1 else 0) + (if (width.asKnown().isPresent) 1 else 0) - /** - * AI-generated tag associated with an image. These tags can be added using the - * `google-auto-tagging` or `aws-auto-tagging` extensions. - */ - class AiTag - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val confidence: JsonField, - private val name: JsonField, - private val source: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("confidence") - @ExcludeMissing - confidence: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), - ) : this(confidence, name, source, mutableMapOf()) - - /** - * Confidence score of the tag. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun confidence(): Optional = confidence.getOptional("confidence") - - /** - * Name of the tag. - * - * @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") - - /** - * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun source(): Optional = source.getOptional("source") - - /** - * Returns the raw JSON value of [confidence]. - * - * Unlike [confidence], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("confidence") - @ExcludeMissing - fun _confidence(): JsonField = confidence - - /** - * 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 [source]. - * - * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [AiTag]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AiTag]. */ - class Builder internal constructor() { - - private var confidence: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var source: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(aiTag: AiTag) = apply { - confidence = aiTag.confidence - name = aiTag.name - source = aiTag.source - additionalProperties = aiTag.additionalProperties.toMutableMap() - } - - /** Confidence score of the tag. */ - fun confidence(confidence: Double) = confidence(JsonField.of(confidence)) - - /** - * Sets [Builder.confidence] to an arbitrary JSON value. - * - * You should usually call [Builder.confidence] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun confidence(confidence: JsonField) = apply { this.confidence = confidence } - - /** Name of the tag. */ - 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 } - - /** - * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. - */ - fun source(source: String) = source(JsonField.of(source)) - - /** - * Sets [Builder.source] to an arbitrary JSON value. - * - * You should usually call [Builder.source] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun source(source: JsonField) = apply { this.source = source } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AiTag]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AiTag = - AiTag(confidence, name, source, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): AiTag = apply { - if (validated) { - return@apply - } - - confidence() - name() - source() - 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 (confidence.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (source.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AiTag && - confidence == other.confidence && - name == other.name && - source == other.source && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(confidence, name, source, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AiTag{confidence=$confidence, name=$name, source=$source, additionalProperties=$additionalProperties}" - } - - /** A key-value data associated with the asset. */ - class CustomMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [CustomMetadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customMetadata: CustomMetadata) = apply { - additionalProperties = customMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [CustomMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): CustomMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CustomMetadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" - } - - /** - * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp - * data. - */ - class EmbeddedMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [EmbeddedMetadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EmbeddedMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(embeddedMetadata: EmbeddedMetadata) = apply { - additionalProperties = embeddedMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [EmbeddedMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): EmbeddedMetadata = EmbeddedMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): EmbeddedMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EmbeddedMetadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "EmbeddedMetadata{additionalProperties=$additionalProperties}" - } - - /** - * This field is included in the response only if the Path policy feature is available in the - * plan. It contains schema definitions for the custom metadata fields selected for the - * specified file path. Field selection can only be done when the Path policy feature is - * enabled. - * - * Keys are the names of the custom metadata fields; the value object has details about the - * custom metadata schema. - */ - class SelectedFieldsSchema - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [SelectedFieldsSchema]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SelectedFieldsSchema]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(selectedFieldsSchema: SelectedFieldsSchema) = apply { - additionalProperties = selectedFieldsSchema.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SelectedFieldsSchema]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): SelectedFieldsSchema = - SelectedFieldsSchema(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): SelectedFieldsSchema = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SelectedFieldsSchema && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "SelectedFieldsSchema{additionalProperties=$additionalProperties}" - } - /** Type of the asset. */ class Type @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1886,183 +1354,6 @@ private constructor( override fun toString() = value.toString() } - /** An object containing the file or file version's `id` (versionId) and `name`. */ - class VersionInfo - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(id, name, mutableMapOf()) - - /** - * Unique identifier of the file version. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") - - /** - * Name of the file version. - * - * @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") - - /** - * 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 [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [VersionInfo]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [VersionInfo]. */ - class Builder internal constructor() { - - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(versionInfo: VersionInfo) = apply { - id = versionInfo.id - name = versionInfo.name - additionalProperties = versionInfo.additionalProperties.toMutableMap() - } - - /** Unique identifier of the file version. */ - 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 } - - /** Name of the file version. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [VersionInfo]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): VersionInfo = VersionInfo(id, name, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): VersionInfo = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is VersionInfo && - id == other.id && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "VersionInfo{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt index d1c08278..34e1f146 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt @@ -14,6 +14,11 @@ import com.imagekit.api.core.JsonValue import com.imagekit.api.core.checkKnown import com.imagekit.api.core.toImmutable import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.AiTag +import com.imagekit.api.models.CustomMetadata +import com.imagekit.api.models.EmbeddedMetadata +import com.imagekit.api.models.SelectedFieldsSchema +import com.imagekit.api.models.VersionInfo import java.time.OffsetDateTime import java.util.Collections import java.util.Objects @@ -24,15 +29,15 @@ import kotlin.jvm.optionals.getOrNull class FileUpdateResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val aiTags: JsonField>, + private val aiTags: JsonField>, private val audioCodec: JsonField, private val bitRate: JsonField, private val createdAt: JsonField, private val customCoordinates: JsonField, - private val customMetadata: JsonField, + private val customMetadata: JsonField, private val description: JsonField, private val duration: JsonField, - private val embeddedMetadata: JsonField, + private val embeddedMetadata: JsonField, private val fileId: JsonField, private val filePath: JsonField, private val fileType: JsonField, @@ -42,14 +47,14 @@ private constructor( private val isPublished: JsonField, private val mime: JsonField, private val name: JsonField, - private val selectedFieldsSchema: JsonField, + private val selectedFieldsSchema: JsonField, private val size: JsonField, private val tags: JsonField>, private val thumbnail: JsonField, private val type: JsonField, private val updatedAt: JsonField, private val url: JsonField, - private val versionInfo: JsonField, + private val versionInfo: JsonField, private val videoCodec: JsonField, private val width: JsonField, private val extensionStatus: JsonField, @@ -58,9 +63,7 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("AITags") - @ExcludeMissing - aiTags: JsonField> = JsonMissing.of(), + @JsonProperty("AITags") @ExcludeMissing aiTags: JsonField> = JsonMissing.of(), @JsonProperty("audioCodec") @ExcludeMissing audioCodec: JsonField = JsonMissing.of(), @@ -73,14 +76,14 @@ private constructor( customCoordinates: JsonField = JsonMissing.of(), @JsonProperty("customMetadata") @ExcludeMissing - customMetadata: JsonField = JsonMissing.of(), + customMetadata: JsonField = JsonMissing.of(), @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), @JsonProperty("embeddedMetadata") @ExcludeMissing - embeddedMetadata: JsonField = JsonMissing.of(), + embeddedMetadata: JsonField = JsonMissing.of(), @JsonProperty("fileId") @ExcludeMissing fileId: JsonField = JsonMissing.of(), @JsonProperty("filePath") @ExcludeMissing filePath: JsonField = JsonMissing.of(), @JsonProperty("fileType") @ExcludeMissing fileType: JsonField = JsonMissing.of(), @@ -96,7 +99,7 @@ private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("selectedFieldsSchema") @ExcludeMissing - selectedFieldsSchema: JsonField = JsonMissing.of(), + selectedFieldsSchema: JsonField = JsonMissing.of(), @JsonProperty("size") @ExcludeMissing size: JsonField = JsonMissing.of(), @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), @JsonProperty("thumbnail") @ExcludeMissing thumbnail: JsonField = JsonMissing.of(), @@ -107,7 +110,7 @@ private constructor( @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), @JsonProperty("versionInfo") @ExcludeMissing - versionInfo: JsonField = JsonMissing.of(), + versionInfo: JsonField = JsonMissing.of(), @JsonProperty("videoCodec") @ExcludeMissing videoCodec: JsonField = JsonMissing.of(), @@ -186,7 +189,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun aiTags(): Optional> = aiTags.getOptional("AITags") + fun aiTags(): Optional> = aiTags.getOptional("AITags") /** * The audio codec used in the video (only for video/audio). @@ -226,8 +229,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun customMetadata(): Optional = - customMetadata.getOptional("customMetadata") + fun customMetadata(): Optional = customMetadata.getOptional("customMetadata") /** * Optional text to describe the contents of the file. Can be set by the user or the @@ -253,7 +255,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun embeddedMetadata(): Optional = + fun embeddedMetadata(): Optional = embeddedMetadata.getOptional("embeddedMetadata") /** @@ -342,7 +344,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun selectedFieldsSchema(): Optional = + fun selectedFieldsSchema(): Optional = selectedFieldsSchema.getOptional("selectedFieldsSchema") /** @@ -400,7 +402,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun versionInfo(): Optional = versionInfo.getOptional("versionInfo") + fun versionInfo(): Optional = versionInfo.getOptional("versionInfo") /** * The video codec used in the video (only for video). @@ -430,7 +432,7 @@ private constructor( * * Unlike [aiTags], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("AITags") @ExcludeMissing fun _aiTags(): JsonField> = aiTags + @JsonProperty("AITags") @ExcludeMissing fun _aiTags(): JsonField> = aiTags /** * Returns the raw JSON value of [audioCodec]. @@ -472,7 +474,7 @@ private constructor( */ @JsonProperty("customMetadata") @ExcludeMissing - fun _customMetadata(): JsonField = customMetadata + fun _customMetadata(): JsonField = customMetadata /** * Returns the raw JSON value of [description]. @@ -496,7 +498,7 @@ private constructor( */ @JsonProperty("embeddedMetadata") @ExcludeMissing - fun _embeddedMetadata(): JsonField = embeddedMetadata + fun _embeddedMetadata(): JsonField = embeddedMetadata /** * Returns the raw JSON value of [fileId]. @@ -573,7 +575,7 @@ private constructor( */ @JsonProperty("selectedFieldsSchema") @ExcludeMissing - fun _selectedFieldsSchema(): JsonField = selectedFieldsSchema + fun _selectedFieldsSchema(): JsonField = selectedFieldsSchema /** * Returns the raw JSON value of [size]. @@ -626,7 +628,7 @@ private constructor( */ @JsonProperty("versionInfo") @ExcludeMissing - fun _versionInfo(): JsonField = versionInfo + fun _versionInfo(): JsonField = versionInfo /** * Returns the raw JSON value of [videoCodec]. @@ -672,15 +674,15 @@ private constructor( /** A builder for [FileUpdateResponse]. */ class Builder internal constructor() { - private var aiTags: JsonField>? = null + private var aiTags: JsonField>? = null private var audioCodec: JsonField = JsonMissing.of() private var bitRate: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() private var customCoordinates: JsonField = JsonMissing.of() - private var customMetadata: JsonField = JsonMissing.of() + private var customMetadata: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var duration: JsonField = JsonMissing.of() - private var embeddedMetadata: JsonField = JsonMissing.of() + private var embeddedMetadata: JsonField = JsonMissing.of() private var fileId: JsonField = JsonMissing.of() private var filePath: JsonField = JsonMissing.of() private var fileType: JsonField = JsonMissing.of() @@ -690,14 +692,14 @@ private constructor( private var isPublished: JsonField = JsonMissing.of() private var mime: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var selectedFieldsSchema: JsonField = JsonMissing.of() + private var selectedFieldsSchema: JsonField = JsonMissing.of() private var size: JsonField = JsonMissing.of() private var tags: JsonField>? = null private var thumbnail: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() private var updatedAt: JsonField = JsonMissing.of() private var url: JsonField = JsonMissing.of() - private var versionInfo: JsonField = JsonMissing.of() + private var versionInfo: JsonField = JsonMissing.of() private var videoCodec: JsonField = JsonMissing.of() private var width: JsonField = JsonMissing.of() private var extensionStatus: JsonField = JsonMissing.of() @@ -741,28 +743,28 @@ private constructor( * Array of AI-generated tags associated with the image. If no AITags are set, it will be * null. */ - fun aiTags(aiTags: List?) = aiTags(JsonField.ofNullable(aiTags)) + fun aiTags(aiTags: List?) = aiTags(JsonField.ofNullable(aiTags)) /** Alias for calling [Builder.aiTags] with `aiTags.orElse(null)`. */ - fun aiTags(aiTags: Optional>) = aiTags(aiTags.getOrNull()) + fun aiTags(aiTags: Optional>) = aiTags(aiTags.getOrNull()) /** * Sets [Builder.aiTags] to an arbitrary JSON value. * - * You should usually call [Builder.aiTags] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.aiTags] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun aiTags(aiTags: JsonField>) = apply { + fun aiTags(aiTags: JsonField>) = apply { this.aiTags = aiTags.map { it.toMutableList() } } /** - * Adds a single [File.AiTag] to [aiTags]. + * Adds a single [AiTag] to [aiTags]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addAiTag(aiTag: File.AiTag) = apply { + fun addAiTag(aiTag: AiTag) = apply { aiTags = (aiTags ?: JsonField.of(mutableListOf())).also { checkKnown("aiTags", it).add(aiTag) @@ -824,17 +826,17 @@ private constructor( } /** An object with custom metadata for the file. */ - fun customMetadata(customMetadata: File.CustomMetadata) = + fun customMetadata(customMetadata: CustomMetadata) = customMetadata(JsonField.of(customMetadata)) /** * Sets [Builder.customMetadata] to an arbitrary JSON value. * - * You should usually call [Builder.customMetadata] with a well-typed [File.CustomMetadata] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.customMetadata] with a well-typed [CustomMetadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun customMetadata(customMetadata: JsonField) = apply { + fun customMetadata(customMetadata: JsonField) = apply { this.customMetadata = customMetadata } @@ -868,17 +870,17 @@ private constructor( * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp * data. */ - fun embeddedMetadata(embeddedMetadata: File.EmbeddedMetadata) = + fun embeddedMetadata(embeddedMetadata: EmbeddedMetadata) = embeddedMetadata(JsonField.of(embeddedMetadata)) /** * Sets [Builder.embeddedMetadata] to an arbitrary JSON value. * - * You should usually call [Builder.embeddedMetadata] with a well-typed - * [File.EmbeddedMetadata] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.embeddedMetadata] with a well-typed [EmbeddedMetadata] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun embeddedMetadata(embeddedMetadata: JsonField) = apply { + fun embeddedMetadata(embeddedMetadata: JsonField) = apply { this.embeddedMetadata = embeddedMetadata } @@ -999,20 +1001,19 @@ private constructor( * Keys are the names of the custom metadata fields; the value object has details about the * custom metadata schema. */ - fun selectedFieldsSchema(selectedFieldsSchema: File.SelectedFieldsSchema) = + fun selectedFieldsSchema(selectedFieldsSchema: SelectedFieldsSchema) = selectedFieldsSchema(JsonField.of(selectedFieldsSchema)) /** * Sets [Builder.selectedFieldsSchema] to an arbitrary JSON value. * * You should usually call [Builder.selectedFieldsSchema] with a well-typed - * [File.SelectedFieldsSchema] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * [SelectedFieldsSchema] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun selectedFieldsSchema(selectedFieldsSchema: JsonField) = - apply { - this.selectedFieldsSchema = selectedFieldsSchema - } + fun selectedFieldsSchema(selectedFieldsSchema: JsonField) = apply { + this.selectedFieldsSchema = selectedFieldsSchema + } /** Size of the file in bytes. */ fun size(size: Double) = size(JsonField.of(size)) @@ -1104,16 +1105,16 @@ private constructor( fun url(url: JsonField) = apply { this.url = url } /** An object with details of the file version. */ - fun versionInfo(versionInfo: File.VersionInfo) = versionInfo(JsonField.of(versionInfo)) + fun versionInfo(versionInfo: VersionInfo) = versionInfo(JsonField.of(versionInfo)) /** * Sets [Builder.versionInfo] to an arbitrary JSON value. * - * You should usually call [Builder.versionInfo] with a well-typed [File.VersionInfo] value + * You should usually call [Builder.versionInfo] with a well-typed [VersionInfo] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun versionInfo(versionInfo: JsonField) = apply { + fun versionInfo(versionInfo: JsonField) = apply { this.versionInfo = versionInfo } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt index 7d9abc94..11f8f8b2 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt @@ -7,13 +7,13 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.imagekit.api.core.BaseSerializer import com.imagekit.api.core.Enum import com.imagekit.api.core.ExcludeMissing import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField import com.imagekit.api.core.Params @@ -22,9 +22,10 @@ import com.imagekit.api.core.checkRequired import com.imagekit.api.core.getOrThrow import com.imagekit.api.core.http.Headers import com.imagekit.api.core.http.QueryParams +import com.imagekit.api.core.jsonMapper import com.imagekit.api.core.toImmutable import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 +import com.imagekit.api.models.ExtensionItem import java.io.InputStream import java.nio.file.Path import java.util.Collections @@ -162,7 +163,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun extensions(): Optional> = body.extensions() + fun extensions(): Optional> = body.extensions() /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist before, @@ -292,7 +293,7 @@ private constructor( * @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() + fun transformation(): Optional = body.transformation() /** * Whether to use a unique filename for this file or not. @@ -383,7 +384,7 @@ private constructor( * * Unlike [extensions], this method doesn't throw if the multipart field has an unexpected type. */ - fun _extensions(): MultipartField> = body._extensions() + fun _extensions(): MultipartField> = body._extensions() /** * Returns the raw multipart value of [folder]. @@ -475,7 +476,7 @@ private constructor( * Unlike [transformation], this method doesn't throw if the multipart field has an unexpected * type. */ - fun _transformation(): MultipartField = body._transformation() + fun _transformation(): MultipartField = body._transformation() /** * Returns the raw multipart value of [useUniqueFileName]. @@ -714,84 +715,66 @@ private constructor( * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ - fun extensions(extensions: List) = apply { - body.extensions(extensions) - } + fun extensions(extensions: List) = apply { body.extensions(extensions) } /** * Sets [Builder.extensions] to an arbitrary multipart value. * - * You should usually call [Builder.extensions] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. + * You should usually call [Builder.extensions] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun extensions(extensions: MultipartField>) = apply { + fun extensions(extensions: MultipartField>) = apply { body.extensions(extensions) } /** - * Adds a single [UnnamedSchemaWithArrayParent4] to [extensions]. + * Adds a single [ExtensionItem] to [extensions]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addExtension(extension: UnnamedSchemaWithArrayParent4) = apply { - body.addExtension(extension) - } + fun addExtension(extension: ExtensionItem) = apply { body.addExtension(extension) } - /** - * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofRemoveBg(removeBg)`. - */ - fun addExtension(removeBg: UnnamedSchemaWithArrayParent4.RemoveBg) = apply { - body.addExtension(removeBg) - } + /** Alias for calling [addExtension] with `ExtensionItem.ofRemoveBg(removeBg)`. */ + fun addExtension(removeBg: ExtensionItem.RemoveBg) = apply { body.addExtension(removeBg) } /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension(autoTaggingExtension)`. + * `ExtensionItem.ofAutoTaggingExtension(autoTaggingExtension)`. */ - fun addExtension(autoTaggingExtension: UnnamedSchemaWithArrayParent4.AutoTaggingExtension) = - apply { - body.addExtension(autoTaggingExtension) - } + fun addExtension(autoTaggingExtension: ExtensionItem.AutoTaggingExtension) = apply { + body.addExtension(autoTaggingExtension) + } - /** - * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofAiAutoDescription()`. - */ + /** Alias for calling [addExtension] with `ExtensionItem.ofAiAutoDescription()`. */ fun addExtensionAiAutoDescription() = apply { body.addExtensionAiAutoDescription() } - /** - * Alias for calling [addExtension] with `UnnamedSchemaWithArrayParent4.ofAiTasks(aiTasks)`. - */ - fun addExtension(aiTasks: UnnamedSchemaWithArrayParent4.AiTasks) = apply { - body.addExtension(aiTasks) - } + /** Alias for calling [addExtension] with `ExtensionItem.ofAiTasks(aiTasks)`. */ + fun addExtension(aiTasks: ExtensionItem.AiTasks) = apply { body.addExtension(aiTasks) } /** * Alias for calling [addExtension] with the following: * ```java - * UnnamedSchemaWithArrayParent4.AiTasks.builder() + * ExtensionItem.AiTasks.builder() * .tasks(tasks) * .build() * ``` */ - fun addAiTasksExtension(tasks: List) = apply { + fun addAiTasksExtension(tasks: List) = apply { body.addAiTasksExtension(tasks) } /** - * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofSavedExtension(savedExtension)`. + * Alias for calling [addExtension] with `ExtensionItem.ofSavedExtension(savedExtension)`. */ - fun addExtension(savedExtension: UnnamedSchemaWithArrayParent4.SavedExtension) = apply { + fun addExtension(savedExtension: ExtensionItem.SavedExtension) = apply { body.addExtension(savedExtension) } /** * Alias for calling [addExtension] with the following: * ```java - * UnnamedSchemaWithArrayParent4.SavedExtension.builder() + * ExtensionItem.SavedExtension.builder() * .id(id) * .build() * ``` @@ -1023,18 +1006,18 @@ private constructor( * * You can mix and match any combination of post-processing types. */ - fun transformation(transformation: Transformation) = apply { + fun transformation(transformation: UploadTransformation) = apply { body.transformation(transformation) } /** * Sets [Builder.transformation] to an arbitrary multipart value. * - * You should usually call [Builder.transformation] with a well-typed [Transformation] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.transformation] with a well-typed [UploadTransformation] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun transformation(transformation: MultipartField) = apply { + fun transformation(transformation: MultipartField) = apply { body.transformation(transformation) } @@ -1220,10 +1203,10 @@ private constructor( "token" to _token(), "checks" to _checks(), "customCoordinates" to _customCoordinates(), - "customMetadata" to _customMetadata(), + "customMetadata" to _toJsonString(_customMetadata()), "description" to _description(), "expire" to _expire(), - "extensions" to _extensions(), + "extensions" to _toJsonString(_extensions()), "folder" to _folder(), "isPrivateFile" to _isPrivateFile(), "isPublished" to _isPublished(), @@ -1232,15 +1215,45 @@ private constructor( "overwriteFile" to _overwriteFile(), "overwriteTags" to _overwriteTags(), "publicKey" to _publicKey(), - "responseFields" to _responseFields(), + "responseFields" to _toCommaSeparated(_responseFields()), "signature" to _signature(), - "tags" to _tags(), - "transformation" to _transformation(), + "tags" to _toCommaSeparated(_tags()), + "transformation" to _toJsonString(_transformation()), "useUniqueFileName" to _useUniqueFileName(), "webhookUrl" to _webhookUrl(), ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) .toImmutable() + private fun _toJsonString(field: MultipartField<*>): MultipartField { + if (field.value.isMissing() || field.value.isNull()) { + @Suppress("UNCHECKED_CAST") + return field as MultipartField + } + val jsonString = jsonMapper().writeValueAsString(field.value) + return MultipartField.of(jsonString) + } + + private fun _toCommaSeparated(field: MultipartField<*>): MultipartField { + if (field.value.isMissing() || field.value.isNull()) { + @Suppress("UNCHECKED_CAST") + return field as MultipartField + } + val mapper = jsonMapper() + val node = mapper.valueToTree(field.value) + if (!node.isArray) { + @Suppress("UNCHECKED_CAST") + return field as MultipartField + } + val csv = + node + .elements() + .asSequence() + .filter { !it.isNull && !it.isMissingNode } + .map { it.asText() } + .joinToString(",") + return MultipartField.of(csv) + } + override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams @@ -1255,7 +1268,7 @@ private constructor( private val customMetadata: MultipartField, private val description: MultipartField, private val expire: MultipartField, - private val extensions: MultipartField>, + private val extensions: MultipartField>, private val folder: MultipartField, private val isPrivateFile: MultipartField, private val isPublished: MultipartField, @@ -1267,7 +1280,7 @@ private constructor( private val responseFields: MultipartField>, private val signature: MultipartField, private val tags: MultipartField>, - private val transformation: MultipartField, + private val transformation: MultipartField, private val useUniqueFileName: MultipartField, private val webhookUrl: MultipartField, private val additionalProperties: MutableMap, @@ -1374,8 +1387,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun extensions(): Optional> = - extensions.value.getOptional("extensions") + fun extensions(): Optional> = extensions.value.getOptional("extensions") /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist @@ -1509,7 +1521,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun transformation(): Optional = + fun transformation(): Optional = transformation.value.getOptional("transformation") /** @@ -1612,7 +1624,7 @@ private constructor( */ @JsonProperty("extensions") @ExcludeMissing - fun _extensions(): MultipartField> = extensions + fun _extensions(): MultipartField> = extensions /** * Returns the raw multipart value of [folder]. @@ -1726,7 +1738,7 @@ private constructor( */ @JsonProperty("transformation") @ExcludeMissing - fun _transformation(): MultipartField = transformation + fun _transformation(): MultipartField = transformation /** * Returns the raw multipart value of [useUniqueFileName]. @@ -1785,8 +1797,7 @@ private constructor( private var customMetadata: MultipartField = MultipartField.of(null) private var description: MultipartField = MultipartField.of(null) private var expire: MultipartField = MultipartField.of(null) - private var extensions: MultipartField>? = - null + private var extensions: MultipartField>? = null private var folder: MultipartField = MultipartField.of(null) private var isPrivateFile: MultipartField = MultipartField.of(null) private var isPublished: MultipartField = MultipartField.of(null) @@ -1798,7 +1809,8 @@ private constructor( private var responseFields: MultipartField>? = null private var signature: MultipartField = MultipartField.of(null) private var tags: MultipartField>? = null - private var transformation: MultipartField = MultipartField.of(null) + private var transformation: MultipartField = + MultipartField.of(null) private var useUniqueFileName: MultipartField = MultipartField.of(null) private var webhookUrl: MultipartField = MultipartField.of(null) private var additionalProperties: MutableMap = mutableMapOf() @@ -2009,93 +2021,78 @@ private constructor( * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ - fun extensions(extensions: List) = + fun extensions(extensions: List) = extensions(MultipartField.of(extensions)) /** * Sets [Builder.extensions] to an arbitrary multipart value. * - * You should usually call [Builder.extensions] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.extensions] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun extensions(extensions: MultipartField>) = - apply { - this.extensions = extensions.map { it.toMutableList() } - } + fun extensions(extensions: MultipartField>) = apply { + this.extensions = extensions.map { it.toMutableList() } + } /** - * Adds a single [UnnamedSchemaWithArrayParent4] to [extensions]. + * Adds a single [ExtensionItem] to [extensions]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addExtension(extension: UnnamedSchemaWithArrayParent4) = apply { + fun addExtension(extension: ExtensionItem) = apply { extensions = (extensions ?: MultipartField.of(mutableListOf())).also { checkKnown("extensions", it).add(extension) } } - /** - * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofRemoveBg(removeBg)`. - */ - fun addExtension(removeBg: UnnamedSchemaWithArrayParent4.RemoveBg) = - addExtension(UnnamedSchemaWithArrayParent4.ofRemoveBg(removeBg)) + /** Alias for calling [addExtension] with `ExtensionItem.ofRemoveBg(removeBg)`. */ + fun addExtension(removeBg: ExtensionItem.RemoveBg) = + addExtension(ExtensionItem.ofRemoveBg(removeBg)) /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension(autoTaggingExtension)`. + * `ExtensionItem.ofAutoTaggingExtension(autoTaggingExtension)`. */ - fun addExtension( - autoTaggingExtension: UnnamedSchemaWithArrayParent4.AutoTaggingExtension - ) = - addExtension( - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension(autoTaggingExtension) - ) + fun addExtension(autoTaggingExtension: ExtensionItem.AutoTaggingExtension) = + addExtension(ExtensionItem.ofAutoTaggingExtension(autoTaggingExtension)) - /** - * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofAiAutoDescription()`. - */ - fun addExtensionAiAutoDescription() = - addExtension(UnnamedSchemaWithArrayParent4.ofAiAutoDescription()) + /** Alias for calling [addExtension] with `ExtensionItem.ofAiAutoDescription()`. */ + fun addExtensionAiAutoDescription() = addExtension(ExtensionItem.ofAiAutoDescription()) - /** - * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofAiTasks(aiTasks)`. - */ - fun addExtension(aiTasks: UnnamedSchemaWithArrayParent4.AiTasks) = - addExtension(UnnamedSchemaWithArrayParent4.ofAiTasks(aiTasks)) + /** Alias for calling [addExtension] with `ExtensionItem.ofAiTasks(aiTasks)`. */ + fun addExtension(aiTasks: ExtensionItem.AiTasks) = + addExtension(ExtensionItem.ofAiTasks(aiTasks)) /** * Alias for calling [addExtension] with the following: * ```java - * UnnamedSchemaWithArrayParent4.AiTasks.builder() + * ExtensionItem.AiTasks.builder() * .tasks(tasks) * .build() * ``` */ - fun addAiTasksExtension(tasks: List) = - addExtension(UnnamedSchemaWithArrayParent4.AiTasks.builder().tasks(tasks).build()) + fun addAiTasksExtension(tasks: List) = + addExtension(ExtensionItem.AiTasks.builder().tasks(tasks).build()) /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofSavedExtension(savedExtension)`. + * `ExtensionItem.ofSavedExtension(savedExtension)`. */ - fun addExtension(savedExtension: UnnamedSchemaWithArrayParent4.SavedExtension) = - addExtension(UnnamedSchemaWithArrayParent4.ofSavedExtension(savedExtension)) + fun addExtension(savedExtension: ExtensionItem.SavedExtension) = + addExtension(ExtensionItem.ofSavedExtension(savedExtension)) /** * Alias for calling [addExtension] with the following: * ```java - * UnnamedSchemaWithArrayParent4.SavedExtension.builder() + * ExtensionItem.SavedExtension.builder() * .id(id) * .build() * ``` */ fun addSavedExtensionExtension(id: String) = - addExtension(UnnamedSchemaWithArrayParent4.SavedExtension.builder().id(id).build()) + addExtension(ExtensionItem.SavedExtension.builder().id(id).build()) /** * The folder path in which the image has to be uploaded. If the folder(s) didn't exist @@ -2335,17 +2332,17 @@ private constructor( * * You can mix and match any combination of post-processing types. */ - fun transformation(transformation: Transformation) = + fun transformation(transformation: UploadTransformation) = transformation(MultipartField.of(transformation)) /** * Sets [Builder.transformation] to an arbitrary multipart value. * - * You should usually call [Builder.transformation] with a well-typed [Transformation] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.transformation] with a well-typed + * [UploadTransformation] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun transformation(transformation: MultipartField) = apply { + fun transformation(transformation: MultipartField) = apply { this.transformation = transformation } @@ -2652,5924 +2649,6 @@ private constructor( override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" } - @JsonSerialize(using = UnnamedSchemaWithArrayParent4.Serializer::class) - class UnnamedSchemaWithArrayParent4 - private constructor( - private val removeBg: RemoveBg? = null, - private val autoTaggingExtension: AutoTaggingExtension? = null, - private val aiAutoDescription: JsonValue? = null, - private val aiTasks: AiTasks? = null, - private val savedExtension: SavedExtension? = null, - private val _json: JsonValue? = null, - ) { - - fun removeBg(): Optional = Optional.ofNullable(removeBg) - - fun autoTaggingExtension(): Optional = - Optional.ofNullable(autoTaggingExtension) - - fun aiAutoDescription(): Optional = Optional.ofNullable(aiAutoDescription) - - fun aiTasks(): Optional = Optional.ofNullable(aiTasks) - - fun savedExtension(): Optional = Optional.ofNullable(savedExtension) - - fun isRemoveBg(): Boolean = removeBg != null - - fun isAutoTaggingExtension(): Boolean = autoTaggingExtension != null - - fun isAiAutoDescription(): Boolean = aiAutoDescription != null - - fun isAiTasks(): Boolean = aiTasks != null - - fun isSavedExtension(): Boolean = savedExtension != null - - fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") - - fun asAutoTaggingExtension(): AutoTaggingExtension = - autoTaggingExtension.getOrThrow("autoTaggingExtension") - - fun asAiAutoDescription(): JsonValue = aiAutoDescription.getOrThrow("aiAutoDescription") - - fun asAiTasks(): AiTasks = aiTasks.getOrThrow("aiTasks") - - fun asSavedExtension(): SavedExtension = savedExtension.getOrThrow("savedExtension") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - removeBg != null -> visitor.visitRemoveBg(removeBg) - autoTaggingExtension != null -> - visitor.visitAutoTaggingExtension(autoTaggingExtension) - aiAutoDescription != null -> visitor.visitAiAutoDescription(aiAutoDescription) - aiTasks != null -> visitor.visitAiTasks(aiTasks) - savedExtension != null -> visitor.visitSavedExtension(savedExtension) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): UnnamedSchemaWithArrayParent4 = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitRemoveBg(removeBg: RemoveBg) { - removeBg.validate() - } - - override fun visitAutoTaggingExtension( - autoTaggingExtension: AutoTaggingExtension - ) { - autoTaggingExtension.validate() - } - - override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { - aiAutoDescription.let { - if (it != JsonValue.from(mapOf("name" to "ai-auto-description"))) { - throw ImageKitInvalidDataException( - "'aiAutoDescription' is invalid, received $it" - ) - } - } - } - - override fun visitAiTasks(aiTasks: AiTasks) { - aiTasks.validate() - } - - override fun visitSavedExtension(savedExtension: SavedExtension) { - savedExtension.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnnamedSchemaWithArrayParent4 && - removeBg == other.removeBg && - autoTaggingExtension == other.autoTaggingExtension && - aiAutoDescription == other.aiAutoDescription && - aiTasks == other.aiTasks && - savedExtension == other.savedExtension - } - - override fun hashCode(): Int = - Objects.hash(removeBg, autoTaggingExtension, aiAutoDescription, aiTasks, savedExtension) - - override fun toString(): String = - when { - removeBg != null -> "UnnamedSchemaWithArrayParent4{removeBg=$removeBg}" - autoTaggingExtension != null -> - "UnnamedSchemaWithArrayParent4{autoTaggingExtension=$autoTaggingExtension}" - aiAutoDescription != null -> - "UnnamedSchemaWithArrayParent4{aiAutoDescription=$aiAutoDescription}" - aiTasks != null -> "UnnamedSchemaWithArrayParent4{aiTasks=$aiTasks}" - savedExtension != null -> - "UnnamedSchemaWithArrayParent4{savedExtension=$savedExtension}" - _json != null -> "UnnamedSchemaWithArrayParent4{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent4") - } - - companion object { - - @JvmStatic - fun ofRemoveBg(removeBg: RemoveBg) = UnnamedSchemaWithArrayParent4(removeBg = removeBg) - - @JvmStatic - fun ofAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension) = - UnnamedSchemaWithArrayParent4(autoTaggingExtension = autoTaggingExtension) - - @JvmStatic - fun ofAiAutoDescription() = - UnnamedSchemaWithArrayParent4( - aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) - ) - - @JvmStatic - fun ofAiTasks(aiTasks: AiTasks) = UnnamedSchemaWithArrayParent4(aiTasks = aiTasks) - - @JvmStatic - fun ofSavedExtension(savedExtension: SavedExtension) = - UnnamedSchemaWithArrayParent4(savedExtension = savedExtension) - } - - /** - * An interface that defines how to map each variant of [UnnamedSchemaWithArrayParent4] to a - * value of type [T]. - */ - interface Visitor { - - fun visitRemoveBg(removeBg: RemoveBg): T - - fun visitAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension): T - - fun visitAiAutoDescription(aiAutoDescription: JsonValue): T - - fun visitAiTasks(aiTasks: AiTasks): T - - fun visitSavedExtension(savedExtension: SavedExtension): T - - /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent4] to a value of type [T]. - * - * An instance of [UnnamedSchemaWithArrayParent4] can contain an unknown variant if it - * was deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new variants - * that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown UnnamedSchemaWithArrayParent4: $json") - } - } - - internal class Serializer : - BaseSerializer(UnnamedSchemaWithArrayParent4::class) { - - override fun serialize( - value: UnnamedSchemaWithArrayParent4, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.removeBg != null -> generator.writeObject(value.removeBg) - value.autoTaggingExtension != null -> - generator.writeObject(value.autoTaggingExtension) - value.aiAutoDescription != null -> - generator.writeObject(value.aiAutoDescription) - value.aiTasks != null -> generator.writeObject(value.aiTasks) - value.savedExtension != null -> generator.writeObject(value.savedExtension) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent4") - } - } - } - - class RemoveBg - private constructor( - private val name: JsonValue, - private val options: JsonField, - private val additionalProperties: MutableMap, - ) { - - /** - * Specifies the background removal extension. - * - * Expected to always return the following: - * ```java - * JsonValue.from("remove-bg") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun options(): Optional = options.getOptional("options") - - /** - * Returns the raw JSON value of [options]. - * - * Unlike [options], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RemoveBg]. */ - class Builder internal constructor() { - - private var name: JsonValue = JsonValue.from("remove-bg") - private var options: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(removeBg: RemoveBg) = apply { - name = removeBg.name - options = removeBg.options - additionalProperties = removeBg.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from("remove-bg") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonValue) = apply { this.name = name } - - fun options(options: Options) = options(JsonField.of(options)) - - /** - * Sets [Builder.options] to an arbitrary JSON value. - * - * You should usually call [Builder.options] with a well-typed [Options] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun options(options: JsonField) = apply { this.options = options } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [RemoveBg]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemoveBg = RemoveBg(name, options, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): RemoveBg = apply { - if (validated) { - return@apply - } - - _name().let { - if (it != JsonValue.from("remove-bg")) { - throw ImageKitInvalidDataException("'name' is invalid, received $it") - } - } - options().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - class Options - private constructor( - private val addShadow: JsonField, - private val bgColor: JsonField, - private val bgImageUrl: JsonField, - private val semitransparency: JsonField, - private val additionalProperties: MutableMap, - ) { - - /** - * Whether to add an artificial shadow to the result. Default is false. Note: Adding - * shadows is currently only supported for car photos. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun addShadow(): Optional = addShadow.getOptional("add_shadow") - - /** - * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or - * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be - * empty. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun bgColor(): Optional = bgColor.getOptional("bg_color") - - /** - * Sets a background image from a URL. If this parameter is set, `bg_color` must be - * empty. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun bgImageUrl(): Optional = bgImageUrl.getOptional("bg_image_url") - - /** - * Allows semi-transparent regions in the result. Default is true. Note: - * Semitransparency is currently only supported for car windows. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun semitransparency(): Optional = - semitransparency.getOptional("semitransparency") - - /** - * Returns the raw JSON value of [addShadow]. - * - * Unlike [addShadow], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("add_shadow") - @ExcludeMissing - fun _addShadow(): JsonField = addShadow - - /** - * Returns the raw JSON value of [bgColor]. - * - * Unlike [bgColor], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("bg_color") - @ExcludeMissing - fun _bgColor(): JsonField = bgColor - - /** - * Returns the raw JSON value of [bgImageUrl]. - * - * Unlike [bgImageUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("bg_image_url") - @ExcludeMissing - fun _bgImageUrl(): JsonField = bgImageUrl - - /** - * Returns the raw JSON value of [semitransparency]. - * - * Unlike [semitransparency], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("semitransparency") - @ExcludeMissing - fun _semitransparency(): JsonField = semitransparency - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Options]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Options]. */ - class Builder internal constructor() { - - private var addShadow: JsonField = JsonMissing.of() - private var bgColor: JsonField = JsonMissing.of() - private var bgImageUrl: JsonField = JsonMissing.of() - private var semitransparency: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(options: Options) = apply { - addShadow = options.addShadow - bgColor = options.bgColor - bgImageUrl = options.bgImageUrl - semitransparency = options.semitransparency - additionalProperties = options.additionalProperties.toMutableMap() - } - - /** - * Whether to add an artificial shadow to the result. Default is false. Note: - * Adding shadows is currently only supported for car photos. - */ - fun addShadow(addShadow: Boolean) = addShadow(JsonField.of(addShadow)) - - /** - * Sets [Builder.addShadow] to an arbitrary JSON value. - * - * You should usually call [Builder.addShadow] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun addShadow(addShadow: JsonField) = apply { - this.addShadow = addShadow - } - - /** - * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or - * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be - * empty. - */ - fun bgColor(bgColor: String) = bgColor(JsonField.of(bgColor)) - - /** - * Sets [Builder.bgColor] to an arbitrary JSON value. - * - * You should usually call [Builder.bgColor] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun bgColor(bgColor: JsonField) = apply { this.bgColor = bgColor } - - /** - * Sets a background image from a URL. If this parameter is set, `bg_color` must - * be empty. - */ - fun bgImageUrl(bgImageUrl: String) = bgImageUrl(JsonField.of(bgImageUrl)) - - /** - * Sets [Builder.bgImageUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.bgImageUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun bgImageUrl(bgImageUrl: JsonField) = apply { - this.bgImageUrl = bgImageUrl - } - - /** - * Allows semi-transparent regions in the result. Default is true. Note: - * Semitransparency is currently only supported for car windows. - */ - fun semitransparency(semitransparency: Boolean) = - semitransparency(JsonField.of(semitransparency)) - - /** - * Sets [Builder.semitransparency] to an arbitrary JSON value. - * - * You should usually call [Builder.semitransparency] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun semitransparency(semitransparency: JsonField) = apply { - this.semitransparency = semitransparency - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Options]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Options = - Options( - addShadow, - bgColor, - bgImageUrl, - semitransparency, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Options = apply { - if (validated) { - return@apply - } - - addShadow() - bgColor() - bgImageUrl() - semitransparency() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - addShadow == other.addShadow && - bgColor == other.bgColor && - bgImageUrl == other.bgImageUrl && - semitransparency == other.semitransparency && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - addShadow, - bgColor, - bgImageUrl, - semitransparency, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemoveBg && - name == other.name && - options == other.options && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(name, options, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" - } - - class AutoTaggingExtension - private constructor( - private val maxTags: JsonField, - private val minConfidence: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - /** - * Maximum number of tags to attach to the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun maxTags(): Long = maxTags.getRequired("maxTags") - - /** - * Minimum confidence level for tags to be considered valid. - * - * @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 minConfidence(): Long = minConfidence.getRequired("minConfidence") - - /** - * Specifies the auto-tagging extension used. - * - * @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(): Name = name.getRequired("name") - - /** - * Returns the raw JSON value of [maxTags]. - * - * Unlike [maxTags], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("maxTags") @ExcludeMissing fun _maxTags(): JsonField = maxTags - - /** - * Returns the raw JSON value of [minConfidence]. - * - * Unlike [minConfidence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("minConfidence") - @ExcludeMissing - fun _minConfidence(): JsonField = minConfidence - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [AutoTaggingExtension]. - * - * The following fields are required: - * ```java - * .maxTags() - * .minConfidence() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutoTaggingExtension]. */ - class Builder internal constructor() { - - private var maxTags: JsonField? = null - private var minConfidence: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { - maxTags = autoTaggingExtension.maxTags - minConfidence = autoTaggingExtension.minConfidence - name = autoTaggingExtension.name - additionalProperties = autoTaggingExtension.additionalProperties.toMutableMap() - } - - /** Maximum number of tags to attach to the asset. */ - fun maxTags(maxTags: Long) = maxTags(JsonField.of(maxTags)) - - /** - * Sets [Builder.maxTags] to an arbitrary JSON value. - * - * You should usually call [Builder.maxTags] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun maxTags(maxTags: JsonField) = apply { this.maxTags = maxTags } - - /** Minimum confidence level for tags to be considered valid. */ - fun minConfidence(minConfidence: Long) = minConfidence(JsonField.of(minConfidence)) - - /** - * Sets [Builder.minConfidence] to an arbitrary JSON value. - * - * You should usually call [Builder.minConfidence] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun minConfidence(minConfidence: JsonField) = apply { - this.minConfidence = minConfidence - } - - /** Specifies the auto-tagging extension used. */ - fun name(name: Name) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [Name] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AutoTaggingExtension]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .maxTags() - * .minConfidence() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AutoTaggingExtension = - AutoTaggingExtension( - checkRequired("maxTags", maxTags), - checkRequired("minConfidence", minConfidence), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutoTaggingExtension = apply { - if (validated) { - return@apply - } - - maxTags() - minConfidence() - name().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** Specifies the auto-tagging extension used. */ - class Name @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") - - @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") - - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } - - /** An enum containing [Name]'s known values. */ - enum class Known { - GOOGLE_AUTO_TAGGING, - AWS_AUTO_TAGGING, - } - - /** - * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Name] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GOOGLE_AUTO_TAGGING, - AWS_AUTO_TAGGING, - /** - * An enum member indicating that [Name] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING - AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING - AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING - else -> throw ImageKitInvalidDataException("Unknown Name: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Name = apply { - if (validated) { - return@apply - } - - known() - 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 (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Name && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AutoTaggingExtension && - maxTags == other.maxTags && - minConfidence == other.minConfidence && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(maxTags, minConfidence, name, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" - } - - class AiTasks - private constructor( - private val name: JsonValue, - private val tasks: JsonField>, - private val additionalProperties: MutableMap, - ) { - - /** - * Specifies the AI tasks extension for automated image analysis using AI models. - * - * Expected to always return the following: - * ```java - * JsonValue.from("ai-tasks") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name - - /** - * Array of task objects defining AI operations to perform on the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun tasks(): List = tasks.getRequired("tasks") - - /** - * Returns the raw JSON value of [tasks]. - * - * Unlike [tasks], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tasks") @ExcludeMissing fun _tasks(): JsonField> = tasks - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [AiTasks]. - * - * The following fields are required: - * ```java - * .tasks() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AiTasks]. */ - class Builder internal constructor() { - - private var name: JsonValue = JsonValue.from("ai-tasks") - private var tasks: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(aiTasks: AiTasks) = apply { - name = aiTasks.name - tasks = aiTasks.tasks.map { it.toMutableList() } - additionalProperties = aiTasks.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from("ai-tasks") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonValue) = apply { this.name = name } - - /** Array of task objects defining AI operations to perform on the asset. */ - fun tasks(tasks: List) = tasks(JsonField.of(tasks)) - - /** - * Sets [Builder.tasks] to an arbitrary JSON value. - * - * You should usually call [Builder.tasks] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun tasks(tasks: JsonField>) = apply { - this.tasks = tasks.map { it.toMutableList() } - } - - /** - * Adds a single [Task] to [tasks]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTask(task: Task) = apply { - tasks = - (tasks ?: JsonField.of(mutableListOf())).also { - checkKnown("tasks", it).add(task) - } - } - - /** Alias for calling [addTask] with `Task.ofSelectTags(selectTags)`. */ - fun addTask(selectTags: Task.SelectTags) = addTask(Task.ofSelectTags(selectTags)) - - /** - * Alias for calling [addTask] with the following: - * ```java - * Task.SelectTags.builder() - * .instruction(instruction) - * .build() - * ``` - */ - fun addSelectTagsTask(instruction: String) = - addTask(Task.SelectTags.builder().instruction(instruction).build()) - - /** Alias for calling [addTask] with `Task.ofSelectMetadata(selectMetadata)`. */ - fun addTask(selectMetadata: Task.SelectMetadata) = - addTask(Task.ofSelectMetadata(selectMetadata)) - - /** Alias for calling [addTask] with `Task.ofYesNo(yesNo)`. */ - fun addTask(yesNo: Task.YesNo) = addTask(Task.ofYesNo(yesNo)) - - /** - * Alias for calling [addTask] with the following: - * ```java - * Task.YesNo.builder() - * .instruction(instruction) - * .build() - * ``` - */ - fun addYesNoTask(instruction: String) = - addTask(Task.YesNo.builder().instruction(instruction).build()) - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AiTasks]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .tasks() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AiTasks = - AiTasks( - name, - checkRequired("tasks", tasks).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AiTasks = apply { - if (validated) { - return@apply - } - - _name().let { - if (it != JsonValue.from("ai-tasks")) { - throw ImageKitInvalidDataException("'name' is invalid, received $it") - } - } - tasks().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - @JsonSerialize(using = Task.Serializer::class) - class Task - private constructor( - private val selectTags: SelectTags? = null, - private val selectMetadata: SelectMetadata? = null, - private val yesNo: YesNo? = null, - private val _json: JsonValue? = null, - ) { - - fun selectTags(): Optional = Optional.ofNullable(selectTags) - - fun selectMetadata(): Optional = Optional.ofNullable(selectMetadata) - - fun yesNo(): Optional = Optional.ofNullable(yesNo) - - fun isSelectTags(): Boolean = selectTags != null - - fun isSelectMetadata(): Boolean = selectMetadata != null - - fun isYesNo(): Boolean = yesNo != null - - fun asSelectTags(): SelectTags = selectTags.getOrThrow("selectTags") - - fun asSelectMetadata(): SelectMetadata = selectMetadata.getOrThrow("selectMetadata") - - fun asYesNo(): YesNo = yesNo.getOrThrow("yesNo") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - selectTags != null -> visitor.visitSelectTags(selectTags) - selectMetadata != null -> visitor.visitSelectMetadata(selectMetadata) - yesNo != null -> visitor.visitYesNo(yesNo) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Task = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitSelectTags(selectTags: SelectTags) { - selectTags.validate() - } - - override fun visitSelectMetadata(selectMetadata: SelectMetadata) { - selectMetadata.validate() - } - - override fun visitYesNo(yesNo: YesNo) { - yesNo.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Task && - selectTags == other.selectTags && - selectMetadata == other.selectMetadata && - yesNo == other.yesNo - } - - override fun hashCode(): Int = Objects.hash(selectTags, selectMetadata, yesNo) - - override fun toString(): String = - when { - selectTags != null -> "Task{selectTags=$selectTags}" - selectMetadata != null -> "Task{selectMetadata=$selectMetadata}" - yesNo != null -> "Task{yesNo=$yesNo}" - _json != null -> "Task{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Task") - } - - companion object { - - @JvmStatic - fun ofSelectTags(selectTags: SelectTags) = Task(selectTags = selectTags) - - @JvmStatic - fun ofSelectMetadata(selectMetadata: SelectMetadata) = - Task(selectMetadata = selectMetadata) - - @JvmStatic fun ofYesNo(yesNo: YesNo) = Task(yesNo = yesNo) - } - - /** - * An interface that defines how to map each variant of [Task] to a value of type - * [T]. - */ - interface Visitor { - - fun visitSelectTags(selectTags: SelectTags): T - - fun visitSelectMetadata(selectMetadata: SelectMetadata): T - - fun visitYesNo(yesNo: YesNo): T - - /** - * Maps an unknown variant of [Task] to a value of type [T]. - * - * An instance of [Task] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on - * an older version than the API, then the API may respond with new variants - * that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Task: $json") - } - } - - internal class Serializer : BaseSerializer(Task::class) { - - override fun serialize( - value: Task, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.selectTags != null -> generator.writeObject(value.selectTags) - value.selectMetadata != null -> - generator.writeObject(value.selectMetadata) - value.yesNo != null -> generator.writeObject(value.yesNo) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Task") - } - } - } - - class SelectTags - private constructor( - private val instruction: JsonField, - private val type: JsonValue, - private val maxSelections: JsonField, - private val minSelections: JsonField, - private val vocabulary: JsonField>, - private val additionalProperties: MutableMap, - ) { - - /** - * The question or instruction for the AI to analyze the image. - * - * @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 instruction(): String = instruction.getRequired("instruction") - - /** - * Task type that analyzes the image and adds matching tags from a vocabulary. - * - * Expected to always return the following: - * ```java - * JsonValue.from("select_tags") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Maximum number of tags to select from the vocabulary. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun maxSelections(): Optional = - maxSelections.getOptional("max_selections") - - /** - * Minimum number of tags to select from the vocabulary. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun minSelections(): Optional = - minSelections.getOptional("min_selections") - - /** - * Array of possible tag values. The combined length of all strings must not - * exceed 500 characters, and values cannot include the `%` character. When - * providing large vocabularies (more than 30 items), the AI may not follow the - * list strictly. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun vocabulary(): Optional> = vocabulary.getOptional("vocabulary") - - /** - * Returns the raw JSON value of [instruction]. - * - * Unlike [instruction], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("instruction") - @ExcludeMissing - fun _instruction(): JsonField = instruction - - /** - * Returns the raw JSON value of [maxSelections]. - * - * Unlike [maxSelections], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("max_selections") - @ExcludeMissing - fun _maxSelections(): JsonField = maxSelections - - /** - * Returns the raw JSON value of [minSelections]. - * - * Unlike [minSelections], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("min_selections") - @ExcludeMissing - fun _minSelections(): JsonField = minSelections - - /** - * Returns the raw JSON value of [vocabulary]. - * - * Unlike [vocabulary], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("vocabulary") - @ExcludeMissing - fun _vocabulary(): JsonField> = vocabulary - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [SelectTags]. - * - * The following fields are required: - * ```java - * .instruction() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SelectTags]. */ - class Builder internal constructor() { - - private var instruction: JsonField? = null - private var type: JsonValue = JsonValue.from("select_tags") - private var maxSelections: JsonField = JsonMissing.of() - private var minSelections: JsonField = JsonMissing.of() - private var vocabulary: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(selectTags: SelectTags) = apply { - instruction = selectTags.instruction - type = selectTags.type - maxSelections = selectTags.maxSelections - minSelections = selectTags.minSelections - vocabulary = selectTags.vocabulary.map { it.toMutableList() } - additionalProperties = selectTags.additionalProperties.toMutableMap() - } - - /** The question or instruction for the AI to analyze the image. */ - fun instruction(instruction: String) = - instruction(JsonField.of(instruction)) - - /** - * Sets [Builder.instruction] to an arbitrary JSON value. - * - * You should usually call [Builder.instruction] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun instruction(instruction: JsonField) = apply { - this.instruction = instruction - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults - * to the following: - * ```java - * JsonValue.from("select_tags") - * ``` - * - * This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** Maximum number of tags to select from the vocabulary. */ - fun maxSelections(maxSelections: Long) = - maxSelections(JsonField.of(maxSelections)) - - /** - * Sets [Builder.maxSelections] to an arbitrary JSON value. - * - * You should usually call [Builder.maxSelections] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun maxSelections(maxSelections: JsonField) = apply { - this.maxSelections = maxSelections - } - - /** Minimum number of tags to select from the vocabulary. */ - fun minSelections(minSelections: Long) = - minSelections(JsonField.of(minSelections)) - - /** - * Sets [Builder.minSelections] to an arbitrary JSON value. - * - * You should usually call [Builder.minSelections] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun minSelections(minSelections: JsonField) = apply { - this.minSelections = minSelections - } - - /** - * Array of possible tag values. The combined length of all strings must not - * exceed 500 characters, and values cannot include the `%` character. When - * providing large vocabularies (more than 30 items), the AI may not follow - * the list strictly. - */ - fun vocabulary(vocabulary: List) = - vocabulary(JsonField.of(vocabulary)) - - /** - * Sets [Builder.vocabulary] to an arbitrary JSON value. - * - * You should usually call [Builder.vocabulary] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun vocabulary(vocabulary: JsonField>) = apply { - this.vocabulary = vocabulary.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.vocabulary]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addVocabulary(vocabulary: String) = apply { - this.vocabulary = - (this.vocabulary ?: JsonField.of(mutableListOf())).also { - checkKnown("vocabulary", it).add(vocabulary) - } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SelectTags]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .instruction() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SelectTags = - SelectTags( - checkRequired("instruction", instruction), - type, - maxSelections, - minSelections, - (vocabulary ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SelectTags = apply { - if (validated) { - return@apply - } - - instruction() - _type().let { - if (it != JsonValue.from("select_tags")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - maxSelections() - minSelections() - vocabulary() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SelectTags && - instruction == other.instruction && - type == other.type && - maxSelections == other.maxSelections && - minSelections == other.minSelections && - vocabulary == other.vocabulary && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - instruction, - type, - maxSelections, - minSelections, - vocabulary, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SelectTags{instruction=$instruction, type=$type, maxSelections=$maxSelections, minSelections=$minSelections, vocabulary=$vocabulary, additionalProperties=$additionalProperties}" - } - - class SelectMetadata - private constructor( - private val field: JsonField, - private val instruction: JsonField, - private val type: JsonValue, - private val maxSelections: JsonField, - private val minSelections: JsonField, - private val vocabulary: JsonField>, - private val additionalProperties: MutableMap, - ) { - - /** - * Name of the custom metadata field to set. The field must exist in 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 field(): String = field.getRequired("field") - - /** - * The question or instruction for the AI to analyze the image. - * - * @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 instruction(): String = instruction.getRequired("instruction") - - /** - * Task type that analyzes the image and sets a custom metadata field value from - * a vocabulary. - * - * Expected to always return the following: - * ```java - * JsonValue.from("select_metadata") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Maximum number of values to select from the vocabulary. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun maxSelections(): Optional = - maxSelections.getOptional("max_selections") - - /** - * Minimum number of values to select from the vocabulary. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun minSelections(): Optional = - minSelections.getOptional("min_selections") - - /** - * An array of possible values matching the custom metadata field type. If not - * provided for SingleSelect or MultiSelect field types, all values from the - * custom metadata field definition will be used. When providing large - * vocabularies (above 30 items), the AI may not strictly adhere to the list. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun vocabulary(): Optional> = - vocabulary.getOptional("vocabulary") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("field") @ExcludeMissing fun _field(): JsonField = field - - /** - * Returns the raw JSON value of [instruction]. - * - * Unlike [instruction], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("instruction") - @ExcludeMissing - fun _instruction(): JsonField = instruction - - /** - * Returns the raw JSON value of [maxSelections]. - * - * Unlike [maxSelections], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("max_selections") - @ExcludeMissing - fun _maxSelections(): JsonField = maxSelections - - /** - * Returns the raw JSON value of [minSelections]. - * - * Unlike [minSelections], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("min_selections") - @ExcludeMissing - fun _minSelections(): JsonField = minSelections - - /** - * Returns the raw JSON value of [vocabulary]. - * - * Unlike [vocabulary], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("vocabulary") - @ExcludeMissing - fun _vocabulary(): JsonField> = vocabulary - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SelectMetadata]. - * - * The following fields are required: - * ```java - * .field() - * .instruction() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SelectMetadata]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var instruction: JsonField? = null - private var type: JsonValue = JsonValue.from("select_metadata") - private var maxSelections: JsonField = JsonMissing.of() - private var minSelections: JsonField = JsonMissing.of() - private var vocabulary: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(selectMetadata: SelectMetadata) = apply { - field = selectMetadata.field - instruction = selectMetadata.instruction - type = selectMetadata.type - maxSelections = selectMetadata.maxSelections - minSelections = selectMetadata.minSelections - vocabulary = selectMetadata.vocabulary.map { it.toMutableList() } - additionalProperties = - selectMetadata.additionalProperties.toMutableMap() - } - - /** - * Name of the custom metadata field to set. The field must exist in your - * account. - */ - fun field(field: String) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { this.field = field } - - /** The question or instruction for the AI to analyze the image. */ - fun instruction(instruction: String) = - instruction(JsonField.of(instruction)) - - /** - * Sets [Builder.instruction] to an arbitrary JSON value. - * - * You should usually call [Builder.instruction] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun instruction(instruction: JsonField) = apply { - this.instruction = instruction - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults - * to the following: - * ```java - * JsonValue.from("select_metadata") - * ``` - * - * This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** Maximum number of values to select from the vocabulary. */ - fun maxSelections(maxSelections: Long) = - maxSelections(JsonField.of(maxSelections)) - - /** - * Sets [Builder.maxSelections] to an arbitrary JSON value. - * - * You should usually call [Builder.maxSelections] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun maxSelections(maxSelections: JsonField) = apply { - this.maxSelections = maxSelections - } - - /** Minimum number of values to select from the vocabulary. */ - fun minSelections(minSelections: Long) = - minSelections(JsonField.of(minSelections)) - - /** - * Sets [Builder.minSelections] to an arbitrary JSON value. - * - * You should usually call [Builder.minSelections] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun minSelections(minSelections: JsonField) = apply { - this.minSelections = minSelections - } - - /** - * An array of possible values matching the custom metadata field type. If - * not provided for SingleSelect or MultiSelect field types, all values from - * the custom metadata field definition will be used. When providing large - * vocabularies (above 30 items), the AI may not strictly adhere to the - * list. - */ - fun vocabulary(vocabulary: List) = - vocabulary(JsonField.of(vocabulary)) - - /** - * Sets [Builder.vocabulary] to an arbitrary JSON value. - * - * You should usually call [Builder.vocabulary] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun vocabulary(vocabulary: JsonField>) = apply { - this.vocabulary = vocabulary.map { it.toMutableList() } - } - - /** - * Adds a single [Vocabulary] to [Builder.vocabulary]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addVocabulary(vocabulary: Vocabulary) = apply { - this.vocabulary = - (this.vocabulary ?: JsonField.of(mutableListOf())).also { - checkKnown("vocabulary", it).add(vocabulary) - } - } - - /** Alias for calling [addVocabulary] with `Vocabulary.ofString(string)`. */ - fun addVocabulary(string: String) = - addVocabulary(Vocabulary.ofString(string)) - - /** Alias for calling [addVocabulary] with `Vocabulary.ofNumber(number)`. */ - fun addVocabulary(number: Double) = - addVocabulary(Vocabulary.ofNumber(number)) - - /** Alias for calling [addVocabulary] with `Vocabulary.ofBool(bool)`. */ - fun addVocabulary(bool: Boolean) = addVocabulary(Vocabulary.ofBool(bool)) - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SelectMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .field() - * .instruction() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SelectMetadata = - SelectMetadata( - checkRequired("field", field), - checkRequired("instruction", instruction), - type, - maxSelections, - minSelections, - (vocabulary ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SelectMetadata = apply { - if (validated) { - return@apply - } - - field() - instruction() - _type().let { - if (it != JsonValue.from("select_metadata")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - maxSelections() - minSelections() - vocabulary().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - @JsonSerialize(using = Vocabulary.Serializer::class) - class Vocabulary - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Vocabulary = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Vocabulary && - string == other.string && - number == other.number && - bool == other.bool - } - - override fun hashCode(): Int = Objects.hash(string, number, bool) - - override fun toString(): String = - when { - string != null -> "Vocabulary{string=$string}" - number != null -> "Vocabulary{number=$number}" - bool != null -> "Vocabulary{bool=$bool}" - _json != null -> "Vocabulary{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Vocabulary") - } - - companion object { - - @JvmStatic fun ofString(string: String) = Vocabulary(string = string) - - @JvmStatic fun ofNumber(number: Double) = Vocabulary(number = number) - - @JvmStatic fun ofBool(bool: Boolean) = Vocabulary(bool = bool) - } - - /** - * An interface that defines how to map each variant of [Vocabulary] to a - * value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - /** - * Maps an unknown variant of [Vocabulary] to a value of type [T]. - * - * An instance of [Vocabulary] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Vocabulary: $json") - } - } - - internal class Serializer : BaseSerializer(Vocabulary::class) { - - override fun serialize( - value: Vocabulary, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.number != null -> generator.writeObject(value.number) - value.bool != null -> generator.writeObject(value.bool) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Vocabulary") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SelectMetadata && - field == other.field && - instruction == other.instruction && - type == other.type && - maxSelections == other.maxSelections && - minSelections == other.minSelections && - vocabulary == other.vocabulary && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - field, - instruction, - type, - maxSelections, - minSelections, - vocabulary, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SelectMetadata{field=$field, instruction=$instruction, type=$type, maxSelections=$maxSelections, minSelections=$minSelections, vocabulary=$vocabulary, additionalProperties=$additionalProperties}" - } - - class YesNo - private constructor( - private val instruction: JsonField, - private val type: JsonValue, - private val onNo: JsonField, - private val onUnknown: JsonField, - private val onYes: JsonField, - private val additionalProperties: MutableMap, - ) { - - /** - * The yes/no question for the AI to answer about the image. - * - * @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 instruction(): String = instruction.getRequired("instruction") - - /** - * Task type that asks a yes/no question and executes actions based on the - * answer. - * - * Expected to always return the following: - * ```java - * JsonValue.from("yes_no") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Actions to execute if the AI answers no. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun onNo(): Optional = onNo.getOptional("on_no") - - /** - * Actions to execute if the AI cannot determine the answer. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun onUnknown(): Optional = onUnknown.getOptional("on_unknown") - - /** - * Actions to execute if the AI answers yes. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun onYes(): Optional = onYes.getOptional("on_yes") - - /** - * Returns the raw JSON value of [instruction]. - * - * Unlike [instruction], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("instruction") - @ExcludeMissing - fun _instruction(): JsonField = instruction - - /** - * Returns the raw JSON value of [onNo]. - * - * Unlike [onNo], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("on_no") @ExcludeMissing fun _onNo(): JsonField = onNo - - /** - * Returns the raw JSON value of [onUnknown]. - * - * Unlike [onUnknown], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("on_unknown") - @ExcludeMissing - fun _onUnknown(): JsonField = onUnknown - - /** - * Returns the raw JSON value of [onYes]. - * - * Unlike [onYes], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("on_yes") @ExcludeMissing fun _onYes(): JsonField = onYes - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [YesNo]. - * - * The following fields are required: - * ```java - * .instruction() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [YesNo]. */ - class Builder internal constructor() { - - private var instruction: JsonField? = null - private var type: JsonValue = JsonValue.from("yes_no") - private var onNo: JsonField = JsonMissing.of() - private var onUnknown: JsonField = JsonMissing.of() - private var onYes: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(yesNo: YesNo) = apply { - instruction = yesNo.instruction - type = yesNo.type - onNo = yesNo.onNo - onUnknown = yesNo.onUnknown - onYes = yesNo.onYes - additionalProperties = yesNo.additionalProperties.toMutableMap() - } - - /** The yes/no question for the AI to answer about the image. */ - fun instruction(instruction: String) = - instruction(JsonField.of(instruction)) - - /** - * Sets [Builder.instruction] to an arbitrary JSON value. - * - * You should usually call [Builder.instruction] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun instruction(instruction: JsonField) = apply { - this.instruction = instruction - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults - * to the following: - * ```java - * JsonValue.from("yes_no") - * ``` - * - * This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** Actions to execute if the AI answers no. */ - fun onNo(onNo: OnNo) = onNo(JsonField.of(onNo)) - - /** - * Sets [Builder.onNo] to an arbitrary JSON value. - * - * You should usually call [Builder.onNo] with a well-typed [OnNo] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun onNo(onNo: JsonField) = apply { this.onNo = onNo } - - /** Actions to execute if the AI cannot determine the answer. */ - fun onUnknown(onUnknown: OnUnknown) = onUnknown(JsonField.of(onUnknown)) - - /** - * Sets [Builder.onUnknown] to an arbitrary JSON value. - * - * You should usually call [Builder.onUnknown] with a well-typed [OnUnknown] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun onUnknown(onUnknown: JsonField) = apply { - this.onUnknown = onUnknown - } - - /** Actions to execute if the AI answers yes. */ - fun onYes(onYes: OnYes) = onYes(JsonField.of(onYes)) - - /** - * Sets [Builder.onYes] to an arbitrary JSON value. - * - * You should usually call [Builder.onYes] with a well-typed [OnYes] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun onYes(onYes: JsonField) = apply { this.onYes = onYes } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [YesNo]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .instruction() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): YesNo = - YesNo( - checkRequired("instruction", instruction), - type, - onNo, - onUnknown, - onYes, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): YesNo = apply { - if (validated) { - return@apply - } - - instruction() - _type().let { - if (it != JsonValue.from("yes_no")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - onNo().ifPresent { it.validate() } - onUnknown().ifPresent { it.validate() } - onYes().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** Actions to execute if the AI answers no. */ - class OnNo - private constructor( - private val addTags: JsonField>, - private val removeTags: JsonField>, - private val setMetadata: JsonField>, - private val unsetMetadata: JsonField>, - private val additionalProperties: MutableMap, - ) { - - /** - * Array of tag strings to add to the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun addTags(): Optional> = addTags.getOptional("add_tags") - - /** - * Array of tag strings to remove from the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun removeTags(): Optional> = - removeTags.getOptional("remove_tags") - - /** - * Array of custom metadata field updates. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun setMetadata(): Optional> = - setMetadata.getOptional("set_metadata") - - /** - * Array of custom metadata fields to remove. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun unsetMetadata(): Optional> = - unsetMetadata.getOptional("unset_metadata") - - /** - * Returns the raw JSON value of [addTags]. - * - * Unlike [addTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("add_tags") - @ExcludeMissing - fun _addTags(): JsonField> = addTags - - /** - * Returns the raw JSON value of [removeTags]. - * - * Unlike [removeTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("remove_tags") - @ExcludeMissing - fun _removeTags(): JsonField> = removeTags - - /** - * Returns the raw JSON value of [setMetadata]. - * - * Unlike [setMetadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("set_metadata") - @ExcludeMissing - fun _setMetadata(): JsonField> = setMetadata - - /** - * Returns the raw JSON value of [unsetMetadata]. - * - * Unlike [unsetMetadata], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("unset_metadata") - @ExcludeMissing - fun _unsetMetadata(): JsonField> = unsetMetadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [OnNo]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OnNo]. */ - class Builder internal constructor() { - - private var addTags: JsonField>? = null - private var removeTags: JsonField>? = null - private var setMetadata: JsonField>? = null - private var unsetMetadata: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(onNo: OnNo) = apply { - addTags = onNo.addTags.map { it.toMutableList() } - removeTags = onNo.removeTags.map { it.toMutableList() } - setMetadata = onNo.setMetadata.map { it.toMutableList() } - unsetMetadata = onNo.unsetMetadata.map { it.toMutableList() } - additionalProperties = onNo.additionalProperties.toMutableMap() - } - - /** Array of tag strings to add to the asset. */ - fun addTags(addTags: List) = addTags(JsonField.of(addTags)) - - /** - * Sets [Builder.addTags] to an arbitrary JSON value. - * - * You should usually call [Builder.addTags] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun addTags(addTags: JsonField>) = apply { - this.addTags = addTags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [addTags]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addAddTag(addTag: String) = apply { - addTags = - (addTags ?: JsonField.of(mutableListOf())).also { - checkKnown("addTags", it).add(addTag) - } - } - - /** Array of tag strings to remove from the asset. */ - fun removeTags(removeTags: List) = - removeTags(JsonField.of(removeTags)) - - /** - * Sets [Builder.removeTags] to an arbitrary JSON value. - * - * You should usually call [Builder.removeTags] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun removeTags(removeTags: JsonField>) = apply { - this.removeTags = removeTags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [removeTags]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addRemoveTag(removeTag: String) = apply { - removeTags = - (removeTags ?: JsonField.of(mutableListOf())).also { - checkKnown("removeTags", it).add(removeTag) - } - } - - /** Array of custom metadata field updates. */ - fun setMetadata(setMetadata: List) = - setMetadata(JsonField.of(setMetadata)) - - /** - * Sets [Builder.setMetadata] to an arbitrary JSON value. - * - * You should usually call [Builder.setMetadata] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun setMetadata(setMetadata: JsonField>) = apply { - this.setMetadata = setMetadata.map { it.toMutableList() } - } - - /** - * Adds a single [SetMetadata] to [Builder.setMetadata]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addSetMetadata(setMetadata: SetMetadata) = apply { - this.setMetadata = - (this.setMetadata ?: JsonField.of(mutableListOf())).also { - checkKnown("setMetadata", it).add(setMetadata) - } - } - - /** Array of custom metadata fields to remove. */ - fun unsetMetadata(unsetMetadata: List) = - unsetMetadata(JsonField.of(unsetMetadata)) - - /** - * Sets [Builder.unsetMetadata] to an arbitrary JSON value. - * - * You should usually call [Builder.unsetMetadata] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun unsetMetadata(unsetMetadata: JsonField>) = - apply { - this.unsetMetadata = unsetMetadata.map { it.toMutableList() } - } - - /** - * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { - this.unsetMetadata = - (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { - checkKnown("unsetMetadata", it).add(unsetMetadata) - } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [OnNo]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): OnNo = - OnNo( - (addTags ?: JsonMissing.of()).map { it.toImmutable() }, - (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, - (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, - (unsetMetadata ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): OnNo = apply { - if (validated) { - return@apply - } - - addTags() - removeTags() - setMetadata().ifPresent { it.forEach { it.validate() } } - unsetMetadata().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - class SetMetadata - private constructor( - private val field: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - /** - * Name of the custom metadata field to set. - * - * @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 field(): String = field.getRequired("field") - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - * - * @throws ImageKitInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the - * server responded with an unexpected value). - */ - fun value(): Value = value.getRequired("value") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("field") - @ExcludeMissing - fun _field(): JsonField = field - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SetMetadata]. - * - * The following fields are required: - * ```java - * .field() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SetMetadata]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(setMetadata: SetMetadata) = apply { - field = setMetadata.field - value = setMetadata.value - additionalProperties = - setMetadata.additionalProperties.toMutableMap() - } - - /** Name of the custom metadata field to set. */ - fun field(field: String) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { this.field = field } - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - */ - fun value(value: Value) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [Value] - * value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - /** Alias for calling [value] with `Value.ofString(string)`. */ - fun value(string: String) = value(Value.ofString(string)) - - /** Alias for calling [value] with `Value.ofNumber(number)`. */ - fun value(number: Double) = value(Value.ofNumber(number)) - - /** Alias for calling [value] with `Value.ofBool(bool)`. */ - fun value(bool: Boolean) = value(Value.ofBool(bool)) - - /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ - fun valueOfMixed(mixed: List) = - value(Value.ofMixed(mixed)) - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SetMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .field() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SetMetadata = - SetMetadata( - checkRequired("field", field), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SetMetadata = apply { - if (validated) { - return@apply - } - - field() - value().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - */ - @JsonSerialize(using = Value.Serializer::class) - class Value - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val mixed: List? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun mixed(): Optional> = - Optional.ofNullable(mixed) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun isMixed(): Boolean = mixed != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun asMixed(): List = - mixed.getOrThrow("mixed") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - mixed != null -> visitor.visitMixed(mixed) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Value = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} - - override fun visitMixed( - mixed: List - ) { - mixed.forEach { it.validate() } - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Value && - string == other.string && - number == other.number && - bool == other.bool && - mixed == other.mixed - } - - override fun hashCode(): Int = - Objects.hash(string, number, bool, mixed) - - override fun toString(): String = - when { - string != null -> "Value{string=$string}" - number != null -> "Value{number=$number}" - bool != null -> "Value{bool=$bool}" - mixed != null -> "Value{mixed=$mixed}" - _json != null -> "Value{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Value") - } - - companion object { - - @JvmStatic fun ofString(string: String) = Value(string = string) - - @JvmStatic fun ofNumber(number: Double) = Value(number = number) - - @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) - - @JvmStatic - fun ofMixed(mixed: List) = - Value(mixed = mixed.toImmutable()) - } - - /** - * An interface that defines how to map each variant of [Value] to a - * value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - fun visitMixed(mixed: List): T - - /** - * Maps an unknown variant of [Value] to a value of type [T]. - * - * An instance of [Value] can contain an unknown variant if it - * was deserialized from data that doesn't match any known - * variant. For example, if the SDK is on an older version than - * the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Value: $json") - } - } - - internal class Serializer : BaseSerializer(Value::class) { - - override fun serialize( - value: Value, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> - generator.writeObject(value.string) - value.number != null -> - generator.writeObject(value.number) - value.bool != null -> generator.writeObject(value.bool) - value.mixed != null -> - generator.writeObject(value.mixed) - value._json != null -> - generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Value") - } - } - } - - @JsonSerialize( - using = UnnamedSchemaWithArrayParent5.Serializer::class - ) - class UnnamedSchemaWithArrayParent5 - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): UnnamedSchemaWithArrayParent5 = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnnamedSchemaWithArrayParent5 && - string == other.string && - number == other.number && - bool == other.bool - } - - override fun hashCode(): Int = - Objects.hash(string, number, bool) - - override fun toString(): String = - when { - string != null -> - "UnnamedSchemaWithArrayParent5{string=$string}" - number != null -> - "UnnamedSchemaWithArrayParent5{number=$number}" - bool != null -> - "UnnamedSchemaWithArrayParent5{bool=$bool}" - _json != null -> - "UnnamedSchemaWithArrayParent5{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent5" - ) - } - - companion object { - - @JvmStatic - fun ofString(string: String) = - UnnamedSchemaWithArrayParent5(string = string) - - @JvmStatic - fun ofNumber(number: Double) = - UnnamedSchemaWithArrayParent5(number = number) - - @JvmStatic - fun ofBool(bool: Boolean) = - UnnamedSchemaWithArrayParent5(bool = bool) - } - - /** - * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent5] to a value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - /** - * Maps an unknown variant of - * [UnnamedSchemaWithArrayParent5] to a value of type [T]. - * - * An instance of [UnnamedSchemaWithArrayParent5] can - * contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, - * if the SDK is on an older version than the API, then the - * API may respond with new variants that the SDK is unaware - * of. - * - * @throws ImageKitInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent5: $json" - ) - } - } - - internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent5::class - ) { - - override fun serialize( - value: UnnamedSchemaWithArrayParent5, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> - generator.writeObject(value.string) - value.number != null -> - generator.writeObject(value.number) - value.bool != null -> - generator.writeObject(value.bool) - value._json != null -> - generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent5" - ) - } - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SetMetadata && - field == other.field && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, value, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" - } - - class UnsetMetadata - private constructor( - private val field: JsonField, - private val additionalProperties: MutableMap, - ) { - - /** - * Name of the custom metadata field to remove. - * - * @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 field(): String = field.getRequired("field") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("field") - @ExcludeMissing - fun _field(): JsonField = field - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [UnsetMetadata]. - * - * The following fields are required: - * ```java - * .field() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnsetMetadata]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unsetMetadata: UnsetMetadata) = apply { - field = unsetMetadata.field - additionalProperties = - unsetMetadata.additionalProperties.toMutableMap() - } - - /** Name of the custom metadata field to remove. */ - fun field(field: String) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { this.field = field } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnsetMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .field() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UnsetMetadata = - UnsetMetadata( - checkRequired("field", field), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnsetMetadata = apply { - if (validated) { - return@apply - } - - field() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnsetMetadata && - field == other.field && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OnNo && - addTags == other.addTags && - removeTags == other.removeTags && - setMetadata == other.setMetadata && - unsetMetadata == other.unsetMetadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - addTags, - removeTags, - setMetadata, - unsetMetadata, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OnNo{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" - } - - /** Actions to execute if the AI cannot determine the answer. */ - class OnUnknown - private constructor( - private val addTags: JsonField>, - private val removeTags: JsonField>, - private val setMetadata: JsonField>, - private val unsetMetadata: JsonField>, - private val additionalProperties: MutableMap, - ) { - - /** - * Array of tag strings to add to the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun addTags(): Optional> = addTags.getOptional("add_tags") - - /** - * Array of tag strings to remove from the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun removeTags(): Optional> = - removeTags.getOptional("remove_tags") - - /** - * Array of custom metadata field updates. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun setMetadata(): Optional> = - setMetadata.getOptional("set_metadata") - - /** - * Array of custom metadata fields to remove. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun unsetMetadata(): Optional> = - unsetMetadata.getOptional("unset_metadata") - - /** - * Returns the raw JSON value of [addTags]. - * - * Unlike [addTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("add_tags") - @ExcludeMissing - fun _addTags(): JsonField> = addTags - - /** - * Returns the raw JSON value of [removeTags]. - * - * Unlike [removeTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("remove_tags") - @ExcludeMissing - fun _removeTags(): JsonField> = removeTags - - /** - * Returns the raw JSON value of [setMetadata]. - * - * Unlike [setMetadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("set_metadata") - @ExcludeMissing - fun _setMetadata(): JsonField> = setMetadata - - /** - * Returns the raw JSON value of [unsetMetadata]. - * - * Unlike [unsetMetadata], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("unset_metadata") - @ExcludeMissing - fun _unsetMetadata(): JsonField> = unsetMetadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [OnUnknown]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OnUnknown]. */ - class Builder internal constructor() { - - private var addTags: JsonField>? = null - private var removeTags: JsonField>? = null - private var setMetadata: JsonField>? = null - private var unsetMetadata: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(onUnknown: OnUnknown) = apply { - addTags = onUnknown.addTags.map { it.toMutableList() } - removeTags = onUnknown.removeTags.map { it.toMutableList() } - setMetadata = onUnknown.setMetadata.map { it.toMutableList() } - unsetMetadata = onUnknown.unsetMetadata.map { it.toMutableList() } - additionalProperties = onUnknown.additionalProperties.toMutableMap() - } - - /** Array of tag strings to add to the asset. */ - fun addTags(addTags: List) = addTags(JsonField.of(addTags)) - - /** - * Sets [Builder.addTags] to an arbitrary JSON value. - * - * You should usually call [Builder.addTags] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun addTags(addTags: JsonField>) = apply { - this.addTags = addTags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [addTags]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addAddTag(addTag: String) = apply { - addTags = - (addTags ?: JsonField.of(mutableListOf())).also { - checkKnown("addTags", it).add(addTag) - } - } - - /** Array of tag strings to remove from the asset. */ - fun removeTags(removeTags: List) = - removeTags(JsonField.of(removeTags)) - - /** - * Sets [Builder.removeTags] to an arbitrary JSON value. - * - * You should usually call [Builder.removeTags] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun removeTags(removeTags: JsonField>) = apply { - this.removeTags = removeTags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [removeTags]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addRemoveTag(removeTag: String) = apply { - removeTags = - (removeTags ?: JsonField.of(mutableListOf())).also { - checkKnown("removeTags", it).add(removeTag) - } - } - - /** Array of custom metadata field updates. */ - fun setMetadata(setMetadata: List) = - setMetadata(JsonField.of(setMetadata)) - - /** - * Sets [Builder.setMetadata] to an arbitrary JSON value. - * - * You should usually call [Builder.setMetadata] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun setMetadata(setMetadata: JsonField>) = apply { - this.setMetadata = setMetadata.map { it.toMutableList() } - } - - /** - * Adds a single [SetMetadata] to [Builder.setMetadata]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addSetMetadata(setMetadata: SetMetadata) = apply { - this.setMetadata = - (this.setMetadata ?: JsonField.of(mutableListOf())).also { - checkKnown("setMetadata", it).add(setMetadata) - } - } - - /** Array of custom metadata fields to remove. */ - fun unsetMetadata(unsetMetadata: List) = - unsetMetadata(JsonField.of(unsetMetadata)) - - /** - * Sets [Builder.unsetMetadata] to an arbitrary JSON value. - * - * You should usually call [Builder.unsetMetadata] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun unsetMetadata(unsetMetadata: JsonField>) = - apply { - this.unsetMetadata = unsetMetadata.map { it.toMutableList() } - } - - /** - * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { - this.unsetMetadata = - (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { - checkKnown("unsetMetadata", it).add(unsetMetadata) - } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [OnUnknown]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): OnUnknown = - OnUnknown( - (addTags ?: JsonMissing.of()).map { it.toImmutable() }, - (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, - (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, - (unsetMetadata ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): OnUnknown = apply { - if (validated) { - return@apply - } - - addTags() - removeTags() - setMetadata().ifPresent { it.forEach { it.validate() } } - unsetMetadata().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - class SetMetadata - private constructor( - private val field: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - /** - * Name of the custom metadata field to set. - * - * @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 field(): String = field.getRequired("field") - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - * - * @throws ImageKitInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the - * server responded with an unexpected value). - */ - fun value(): Value = value.getRequired("value") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("field") - @ExcludeMissing - fun _field(): JsonField = field - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SetMetadata]. - * - * The following fields are required: - * ```java - * .field() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SetMetadata]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(setMetadata: SetMetadata) = apply { - field = setMetadata.field - value = setMetadata.value - additionalProperties = - setMetadata.additionalProperties.toMutableMap() - } - - /** Name of the custom metadata field to set. */ - fun field(field: String) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { this.field = field } - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - */ - fun value(value: Value) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [Value] - * value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - /** Alias for calling [value] with `Value.ofString(string)`. */ - fun value(string: String) = value(Value.ofString(string)) - - /** Alias for calling [value] with `Value.ofNumber(number)`. */ - fun value(number: Double) = value(Value.ofNumber(number)) - - /** Alias for calling [value] with `Value.ofBool(bool)`. */ - fun value(bool: Boolean) = value(Value.ofBool(bool)) - - /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ - fun valueOfMixed(mixed: List) = - value(Value.ofMixed(mixed)) - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SetMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .field() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SetMetadata = - SetMetadata( - checkRequired("field", field), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SetMetadata = apply { - if (validated) { - return@apply - } - - field() - value().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - */ - @JsonSerialize(using = Value.Serializer::class) - class Value - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val mixed: List? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun mixed(): Optional> = - Optional.ofNullable(mixed) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun isMixed(): Boolean = mixed != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun asMixed(): List = - mixed.getOrThrow("mixed") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - mixed != null -> visitor.visitMixed(mixed) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Value = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} - - override fun visitMixed( - mixed: List - ) { - mixed.forEach { it.validate() } - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Value && - string == other.string && - number == other.number && - bool == other.bool && - mixed == other.mixed - } - - override fun hashCode(): Int = - Objects.hash(string, number, bool, mixed) - - override fun toString(): String = - when { - string != null -> "Value{string=$string}" - number != null -> "Value{number=$number}" - bool != null -> "Value{bool=$bool}" - mixed != null -> "Value{mixed=$mixed}" - _json != null -> "Value{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Value") - } - - companion object { - - @JvmStatic fun ofString(string: String) = Value(string = string) - - @JvmStatic fun ofNumber(number: Double) = Value(number = number) - - @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) - - @JvmStatic - fun ofMixed(mixed: List) = - Value(mixed = mixed.toImmutable()) - } - - /** - * An interface that defines how to map each variant of [Value] to a - * value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - fun visitMixed(mixed: List): T - - /** - * Maps an unknown variant of [Value] to a value of type [T]. - * - * An instance of [Value] can contain an unknown variant if it - * was deserialized from data that doesn't match any known - * variant. For example, if the SDK is on an older version than - * the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Value: $json") - } - } - - internal class Serializer : BaseSerializer(Value::class) { - - override fun serialize( - value: Value, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> - generator.writeObject(value.string) - value.number != null -> - generator.writeObject(value.number) - value.bool != null -> generator.writeObject(value.bool) - value.mixed != null -> - generator.writeObject(value.mixed) - value._json != null -> - generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Value") - } - } - } - - @JsonSerialize( - using = UnnamedSchemaWithArrayParent6.Serializer::class - ) - class UnnamedSchemaWithArrayParent6 - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): UnnamedSchemaWithArrayParent6 = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnnamedSchemaWithArrayParent6 && - string == other.string && - number == other.number && - bool == other.bool - } - - override fun hashCode(): Int = - Objects.hash(string, number, bool) - - override fun toString(): String = - when { - string != null -> - "UnnamedSchemaWithArrayParent6{string=$string}" - number != null -> - "UnnamedSchemaWithArrayParent6{number=$number}" - bool != null -> - "UnnamedSchemaWithArrayParent6{bool=$bool}" - _json != null -> - "UnnamedSchemaWithArrayParent6{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent6" - ) - } - - companion object { - - @JvmStatic - fun ofString(string: String) = - UnnamedSchemaWithArrayParent6(string = string) - - @JvmStatic - fun ofNumber(number: Double) = - UnnamedSchemaWithArrayParent6(number = number) - - @JvmStatic - fun ofBool(bool: Boolean) = - UnnamedSchemaWithArrayParent6(bool = bool) - } - - /** - * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent6] to a value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - /** - * Maps an unknown variant of - * [UnnamedSchemaWithArrayParent6] to a value of type [T]. - * - * An instance of [UnnamedSchemaWithArrayParent6] can - * contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, - * if the SDK is on an older version than the API, then the - * API may respond with new variants that the SDK is unaware - * of. - * - * @throws ImageKitInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent6: $json" - ) - } - } - - internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent6::class - ) { - - override fun serialize( - value: UnnamedSchemaWithArrayParent6, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> - generator.writeObject(value.string) - value.number != null -> - generator.writeObject(value.number) - value.bool != null -> - generator.writeObject(value.bool) - value._json != null -> - generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent6" - ) - } - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SetMetadata && - field == other.field && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, value, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" - } - - class UnsetMetadata - private constructor( - private val field: JsonField, - private val additionalProperties: MutableMap, - ) { - - /** - * Name of the custom metadata field to remove. - * - * @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 field(): String = field.getRequired("field") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("field") - @ExcludeMissing - fun _field(): JsonField = field - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [UnsetMetadata]. - * - * The following fields are required: - * ```java - * .field() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnsetMetadata]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unsetMetadata: UnsetMetadata) = apply { - field = unsetMetadata.field - additionalProperties = - unsetMetadata.additionalProperties.toMutableMap() - } - - /** Name of the custom metadata field to remove. */ - fun field(field: String) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { this.field = field } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnsetMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .field() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UnsetMetadata = - UnsetMetadata( - checkRequired("field", field), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnsetMetadata = apply { - if (validated) { - return@apply - } - - field() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnsetMetadata && - field == other.field && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OnUnknown && - addTags == other.addTags && - removeTags == other.removeTags && - setMetadata == other.setMetadata && - unsetMetadata == other.unsetMetadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - addTags, - removeTags, - setMetadata, - unsetMetadata, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OnUnknown{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" - } - - /** Actions to execute if the AI answers yes. */ - class OnYes - private constructor( - private val addTags: JsonField>, - private val removeTags: JsonField>, - private val setMetadata: JsonField>, - private val unsetMetadata: JsonField>, - private val additionalProperties: MutableMap, - ) { - - /** - * Array of tag strings to add to the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun addTags(): Optional> = addTags.getOptional("add_tags") - - /** - * Array of tag strings to remove from the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun removeTags(): Optional> = - removeTags.getOptional("remove_tags") - - /** - * Array of custom metadata field updates. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun setMetadata(): Optional> = - setMetadata.getOptional("set_metadata") - - /** - * Array of custom metadata fields to remove. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun unsetMetadata(): Optional> = - unsetMetadata.getOptional("unset_metadata") - - /** - * Returns the raw JSON value of [addTags]. - * - * Unlike [addTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("add_tags") - @ExcludeMissing - fun _addTags(): JsonField> = addTags - - /** - * Returns the raw JSON value of [removeTags]. - * - * Unlike [removeTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("remove_tags") - @ExcludeMissing - fun _removeTags(): JsonField> = removeTags - - /** - * Returns the raw JSON value of [setMetadata]. - * - * Unlike [setMetadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("set_metadata") - @ExcludeMissing - fun _setMetadata(): JsonField> = setMetadata - - /** - * Returns the raw JSON value of [unsetMetadata]. - * - * Unlike [unsetMetadata], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("unset_metadata") - @ExcludeMissing - fun _unsetMetadata(): JsonField> = unsetMetadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [OnYes]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OnYes]. */ - class Builder internal constructor() { - - private var addTags: JsonField>? = null - private var removeTags: JsonField>? = null - private var setMetadata: JsonField>? = null - private var unsetMetadata: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(onYes: OnYes) = apply { - addTags = onYes.addTags.map { it.toMutableList() } - removeTags = onYes.removeTags.map { it.toMutableList() } - setMetadata = onYes.setMetadata.map { it.toMutableList() } - unsetMetadata = onYes.unsetMetadata.map { it.toMutableList() } - additionalProperties = onYes.additionalProperties.toMutableMap() - } - - /** Array of tag strings to add to the asset. */ - fun addTags(addTags: List) = addTags(JsonField.of(addTags)) - - /** - * Sets [Builder.addTags] to an arbitrary JSON value. - * - * You should usually call [Builder.addTags] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun addTags(addTags: JsonField>) = apply { - this.addTags = addTags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [addTags]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addAddTag(addTag: String) = apply { - addTags = - (addTags ?: JsonField.of(mutableListOf())).also { - checkKnown("addTags", it).add(addTag) - } - } - - /** Array of tag strings to remove from the asset. */ - fun removeTags(removeTags: List) = - removeTags(JsonField.of(removeTags)) - - /** - * Sets [Builder.removeTags] to an arbitrary JSON value. - * - * You should usually call [Builder.removeTags] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun removeTags(removeTags: JsonField>) = apply { - this.removeTags = removeTags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [removeTags]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addRemoveTag(removeTag: String) = apply { - removeTags = - (removeTags ?: JsonField.of(mutableListOf())).also { - checkKnown("removeTags", it).add(removeTag) - } - } - - /** Array of custom metadata field updates. */ - fun setMetadata(setMetadata: List) = - setMetadata(JsonField.of(setMetadata)) - - /** - * Sets [Builder.setMetadata] to an arbitrary JSON value. - * - * You should usually call [Builder.setMetadata] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun setMetadata(setMetadata: JsonField>) = apply { - this.setMetadata = setMetadata.map { it.toMutableList() } - } - - /** - * Adds a single [SetMetadata] to [Builder.setMetadata]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addSetMetadata(setMetadata: SetMetadata) = apply { - this.setMetadata = - (this.setMetadata ?: JsonField.of(mutableListOf())).also { - checkKnown("setMetadata", it).add(setMetadata) - } - } - - /** Array of custom metadata fields to remove. */ - fun unsetMetadata(unsetMetadata: List) = - unsetMetadata(JsonField.of(unsetMetadata)) - - /** - * Sets [Builder.unsetMetadata] to an arbitrary JSON value. - * - * You should usually call [Builder.unsetMetadata] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun unsetMetadata(unsetMetadata: JsonField>) = - apply { - this.unsetMetadata = unsetMetadata.map { it.toMutableList() } - } - - /** - * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { - this.unsetMetadata = - (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { - checkKnown("unsetMetadata", it).add(unsetMetadata) - } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [OnYes]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): OnYes = - OnYes( - (addTags ?: JsonMissing.of()).map { it.toImmutable() }, - (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, - (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, - (unsetMetadata ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): OnYes = apply { - if (validated) { - return@apply - } - - addTags() - removeTags() - setMetadata().ifPresent { it.forEach { it.validate() } } - unsetMetadata().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - class SetMetadata - private constructor( - private val field: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - /** - * Name of the custom metadata field to set. - * - * @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 field(): String = field.getRequired("field") - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - * - * @throws ImageKitInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the - * server responded with an unexpected value). - */ - fun value(): Value = value.getRequired("value") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("field") - @ExcludeMissing - fun _field(): JsonField = field - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SetMetadata]. - * - * The following fields are required: - * ```java - * .field() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SetMetadata]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(setMetadata: SetMetadata) = apply { - field = setMetadata.field - value = setMetadata.value - additionalProperties = - setMetadata.additionalProperties.toMutableMap() - } - - /** Name of the custom metadata field to set. */ - fun field(field: String) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { this.field = field } - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - */ - fun value(value: Value) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [Value] - * value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - /** Alias for calling [value] with `Value.ofString(string)`. */ - fun value(string: String) = value(Value.ofString(string)) - - /** Alias for calling [value] with `Value.ofNumber(number)`. */ - fun value(number: Double) = value(Value.ofNumber(number)) - - /** Alias for calling [value] with `Value.ofBool(bool)`. */ - fun value(bool: Boolean) = value(Value.ofBool(bool)) - - /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ - fun valueOfMixed(mixed: List) = - value(Value.ofMixed(mixed)) - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SetMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .field() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SetMetadata = - SetMetadata( - checkRequired("field", field), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SetMetadata = apply { - if (validated) { - return@apply - } - - field() - value().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - */ - @JsonSerialize(using = Value.Serializer::class) - class Value - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val mixed: List? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun mixed(): Optional> = - Optional.ofNullable(mixed) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun isMixed(): Boolean = mixed != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun asMixed(): List = - mixed.getOrThrow("mixed") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - mixed != null -> visitor.visitMixed(mixed) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Value = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} - - override fun visitMixed( - mixed: List - ) { - mixed.forEach { it.validate() } - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Value && - string == other.string && - number == other.number && - bool == other.bool && - mixed == other.mixed - } - - override fun hashCode(): Int = - Objects.hash(string, number, bool, mixed) - - override fun toString(): String = - when { - string != null -> "Value{string=$string}" - number != null -> "Value{number=$number}" - bool != null -> "Value{bool=$bool}" - mixed != null -> "Value{mixed=$mixed}" - _json != null -> "Value{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Value") - } - - companion object { - - @JvmStatic fun ofString(string: String) = Value(string = string) - - @JvmStatic fun ofNumber(number: Double) = Value(number = number) - - @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) - - @JvmStatic - fun ofMixed(mixed: List) = - Value(mixed = mixed.toImmutable()) - } - - /** - * An interface that defines how to map each variant of [Value] to a - * value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - fun visitMixed(mixed: List): T - - /** - * Maps an unknown variant of [Value] to a value of type [T]. - * - * An instance of [Value] can contain an unknown variant if it - * was deserialized from data that doesn't match any known - * variant. For example, if the SDK is on an older version than - * the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Value: $json") - } - } - - internal class Serializer : BaseSerializer(Value::class) { - - override fun serialize( - value: Value, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> - generator.writeObject(value.string) - value.number != null -> - generator.writeObject(value.number) - value.bool != null -> generator.writeObject(value.bool) - value.mixed != null -> - generator.writeObject(value.mixed) - value._json != null -> - generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Value") - } - } - } - - @JsonSerialize( - using = UnnamedSchemaWithArrayParent7.Serializer::class - ) - class UnnamedSchemaWithArrayParent7 - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): UnnamedSchemaWithArrayParent7 = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnnamedSchemaWithArrayParent7 && - string == other.string && - number == other.number && - bool == other.bool - } - - override fun hashCode(): Int = - Objects.hash(string, number, bool) - - override fun toString(): String = - when { - string != null -> - "UnnamedSchemaWithArrayParent7{string=$string}" - number != null -> - "UnnamedSchemaWithArrayParent7{number=$number}" - bool != null -> - "UnnamedSchemaWithArrayParent7{bool=$bool}" - _json != null -> - "UnnamedSchemaWithArrayParent7{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent7" - ) - } - - companion object { - - @JvmStatic - fun ofString(string: String) = - UnnamedSchemaWithArrayParent7(string = string) - - @JvmStatic - fun ofNumber(number: Double) = - UnnamedSchemaWithArrayParent7(number = number) - - @JvmStatic - fun ofBool(bool: Boolean) = - UnnamedSchemaWithArrayParent7(bool = bool) - } - - /** - * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent7] to a value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - /** - * Maps an unknown variant of - * [UnnamedSchemaWithArrayParent7] to a value of type [T]. - * - * An instance of [UnnamedSchemaWithArrayParent7] can - * contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, - * if the SDK is on an older version than the API, then the - * API may respond with new variants that the SDK is unaware - * of. - * - * @throws ImageKitInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent7: $json" - ) - } - } - - internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent7::class - ) { - - override fun serialize( - value: UnnamedSchemaWithArrayParent7, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> - generator.writeObject(value.string) - value.number != null -> - generator.writeObject(value.number) - value.bool != null -> - generator.writeObject(value.bool) - value._json != null -> - generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent7" - ) - } - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SetMetadata && - field == other.field && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, value, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" - } - - class UnsetMetadata - private constructor( - private val field: JsonField, - private val additionalProperties: MutableMap, - ) { - - /** - * Name of the custom metadata field to remove. - * - * @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 field(): String = field.getRequired("field") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("field") - @ExcludeMissing - fun _field(): JsonField = field - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [UnsetMetadata]. - * - * The following fields are required: - * ```java - * .field() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnsetMetadata]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unsetMetadata: UnsetMetadata) = apply { - field = unsetMetadata.field - additionalProperties = - unsetMetadata.additionalProperties.toMutableMap() - } - - /** Name of the custom metadata field to remove. */ - fun field(field: String) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { this.field = field } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnsetMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .field() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UnsetMetadata = - UnsetMetadata( - checkRequired("field", field), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnsetMetadata = apply { - if (validated) { - return@apply - } - - field() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnsetMetadata && - field == other.field && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OnYes && - addTags == other.addTags && - removeTags == other.removeTags && - setMetadata == other.setMetadata && - unsetMetadata == other.unsetMetadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - addTags, - removeTags, - setMetadata, - unsetMetadata, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OnYes{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is YesNo && - instruction == other.instruction && - type == other.type && - onNo == other.onNo && - onUnknown == other.onUnknown && - onYes == other.onYes && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - instruction, - type, - onNo, - onUnknown, - onYes, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "YesNo{instruction=$instruction, type=$type, onNo=$onNo, onUnknown=$onUnknown, onYes=$onYes, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AiTasks && - name == other.name && - tasks == other.tasks && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(name, tasks, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AiTasks{name=$name, tasks=$tasks, additionalProperties=$additionalProperties}" - } - - class SavedExtension - private constructor( - private val id: JsonField, - private val name: JsonValue, - private val additionalProperties: MutableMap, - ) { - - /** - * The unique ID of the saved extension to apply. - * - * @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") - - /** - * Indicates this is a reference to a saved extension. - * - * Expected to always return the following: - * ```java - * JsonValue.from("saved-extension") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [SavedExtension]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SavedExtension]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonValue = JsonValue.from("saved-extension") - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(savedExtension: SavedExtension) = apply { - id = savedExtension.id - name = savedExtension.name - additionalProperties = savedExtension.additionalProperties.toMutableMap() - } - - /** The unique ID of the saved extension to apply. */ - 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 } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from("saved-extension") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonValue) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SavedExtension]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SavedExtension = - SavedExtension( - checkRequired("id", id), - name, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SavedExtension = apply { - if (validated) { - return@apply - } - - id() - _name().let { - if (it != JsonValue.from("saved-extension")) { - throw ImageKitInvalidDataException("'name' is invalid, received $it") - } - } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SavedExtension && - id == other.id && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SavedExtension{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - } - class ResponseField @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -8746,7 +2825,7 @@ private constructor( * * You can mix and match any combination of post-processing types. */ - class Transformation + class UploadTransformation private constructor( private val post: MultipartField>, private val pre: MultipartField, @@ -8799,11 +2878,11 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Transformation]. */ + /** Returns a mutable builder for constructing an instance of [UploadTransformation]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Transformation]. */ + /** A builder for [UploadTransformation]. */ class Builder internal constructor() { private var post: MultipartField>? = null @@ -8811,10 +2890,10 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(transformation: Transformation) = apply { - post = transformation.post.map { it.toMutableList() } - pre = transformation.pre - additionalProperties = transformation.additionalProperties.toMutableMap() + internal fun from(uploadTransformation: UploadTransformation) = apply { + post = uploadTransformation.post.map { it.toMutableList() } + pre = uploadTransformation.pre + additionalProperties = uploadTransformation.additionalProperties.toMutableMap() } /** @@ -8847,19 +2926,19 @@ private constructor( } /** Alias for calling [addPost] with `Post.ofTransformation(transformation)`. */ - fun addPost(transformation: Post.InnerTransformation) = + fun addPost(transformation: Post.Transformation) = addPost(Post.ofTransformation(transformation)) /** * Alias for calling [addPost] with the following: * ```java - * Post.InnerTransformation.builder() + * Post.Transformation.builder() * .value(value) * .build() * ``` */ fun addTransformationPost(value: String) = - addPost(Post.InnerTransformation.builder().value(value).build()) + addPost(Post.Transformation.builder().value(value).build()) /** Alias for calling [addPost] with `Post.ofGifToVideo(gifToVideo)`. */ fun addPost(gifToVideo: Post.GifToVideo) = addPost(Post.ofGifToVideo(gifToVideo)) @@ -8905,12 +2984,12 @@ private constructor( } /** - * Returns an immutable instance of [Transformation]. + * Returns an immutable instance of [UploadTransformation]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Transformation = - Transformation( + fun build(): UploadTransformation = + UploadTransformation( (post ?: MultipartField.of(null)).map { it.toImmutable() }, pre, additionalProperties.toMutableMap(), @@ -8919,7 +2998,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Transformation = apply { + fun validate(): UploadTransformation = apply { if (validated) { return@apply } @@ -8940,15 +3019,14 @@ private constructor( @JsonSerialize(using = Post.Serializer::class) class Post private constructor( - private val transformation: InnerTransformation? = null, + private val transformation: Transformation? = null, private val gifToVideo: GifToVideo? = null, private val thumbnail: Thumbnail? = null, private val abs: Abs? = null, private val _json: JsonValue? = null, ) { - fun transformation(): Optional = - Optional.ofNullable(transformation) + fun transformation(): Optional = Optional.ofNullable(transformation) fun gifToVideo(): Optional = Optional.ofNullable(gifToVideo) @@ -8964,8 +3042,7 @@ private constructor( fun isAbs(): Boolean = abs != null - fun asTransformation(): InnerTransformation = - transformation.getOrThrow("transformation") + fun asTransformation(): Transformation = transformation.getOrThrow("transformation") fun asGifToVideo(): GifToVideo = gifToVideo.getOrThrow("gifToVideo") @@ -8993,7 +3070,7 @@ private constructor( accept( object : Visitor { - override fun visitTransformation(transformation: InnerTransformation) { + override fun visitTransformation(transformation: Transformation) { transformation.validate() } @@ -9048,7 +3125,7 @@ private constructor( companion object { @JvmStatic - fun ofTransformation(transformation: InnerTransformation) = + fun ofTransformation(transformation: Transformation) = Post(transformation = transformation) @JvmStatic fun ofGifToVideo(gifToVideo: GifToVideo) = Post(gifToVideo = gifToVideo) @@ -9063,7 +3140,7 @@ private constructor( */ interface Visitor { - fun visitTransformation(transformation: InnerTransformation): T + fun visitTransformation(transformation: Transformation): T fun visitGifToVideo(gifToVideo: GifToVideo): T @@ -9104,7 +3181,7 @@ private constructor( } } - class InnerTransformation + class Transformation private constructor( private val type: JsonValue, private val value: MultipartField, @@ -9157,8 +3234,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [InnerTransformation]. + * Returns a mutable builder for constructing an instance of [Transformation]. * * The following fields are required: * ```java @@ -9168,7 +3244,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [InnerTransformation]. */ + /** A builder for [Transformation]. */ class Builder internal constructor() { private var type: JsonValue = JsonValue.from("transformation") @@ -9176,11 +3252,10 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(innerTransformation: InnerTransformation) = apply { - type = innerTransformation.type - value = innerTransformation.value - additionalProperties = - innerTransformation.additionalProperties.toMutableMap() + internal fun from(transformation: Transformation) = apply { + type = transformation.type + value = transformation.value + additionalProperties = transformation.additionalProperties.toMutableMap() } /** @@ -9235,7 +3310,7 @@ private constructor( } /** - * Returns an immutable instance of [InnerTransformation]. + * Returns an immutable instance of [Transformation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -9246,8 +3321,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): InnerTransformation = - InnerTransformation( + fun build(): Transformation = + Transformation( type, checkRequired("value", value), additionalProperties.toMutableMap(), @@ -9256,7 +3331,7 @@ private constructor( private var validated: Boolean = false - fun validate(): InnerTransformation = apply { + fun validate(): Transformation = apply { if (validated) { return@apply } @@ -9283,7 +3358,7 @@ private constructor( return true } - return other is InnerTransformation && + return other is Transformation && type == other.type && value == other.value && additionalProperties == other.additionalProperties @@ -9296,7 +3371,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InnerTransformation{type=$type, value=$value, additionalProperties=$additionalProperties}" + "Transformation{type=$type, value=$value, additionalProperties=$additionalProperties}" } class GifToVideo @@ -10017,7 +4092,7 @@ private constructor( return true } - return other is Transformation && + return other is UploadTransformation && post == other.post && pre == other.pre && additionalProperties == other.additionalProperties @@ -10028,7 +4103,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Transformation{post=$post, pre=$pre, additionalProperties=$additionalProperties}" + "UploadTransformation{post=$post, pre=$pre, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt index d503343e..8db21cc4 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt @@ -14,6 +14,11 @@ import com.imagekit.api.core.JsonValue import com.imagekit.api.core.checkKnown import com.imagekit.api.core.toImmutable import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.AiTag +import com.imagekit.api.models.CustomMetadata +import com.imagekit.api.models.EmbeddedMetadata +import com.imagekit.api.models.SelectedFieldsSchema +import com.imagekit.api.models.VersionInfo import java.util.Collections import java.util.Objects import java.util.Optional @@ -1163,433 +1168,6 @@ private constructor( (if (videoCodec.asKnown().isPresent) 1 else 0) + (if (width.asKnown().isPresent) 1 else 0) - /** - * AI-generated tag associated with an image. These tags can be added using the - * `google-auto-tagging` or `aws-auto-tagging` extensions. - */ - class AiTag - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val confidence: JsonField, - private val name: JsonField, - private val source: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("confidence") - @ExcludeMissing - confidence: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), - ) : this(confidence, name, source, mutableMapOf()) - - /** - * Confidence score of the tag. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun confidence(): Optional = confidence.getOptional("confidence") - - /** - * Name of the tag. - * - * @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") - - /** - * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun source(): Optional = source.getOptional("source") - - /** - * Returns the raw JSON value of [confidence]. - * - * Unlike [confidence], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("confidence") - @ExcludeMissing - fun _confidence(): JsonField = confidence - - /** - * 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 [source]. - * - * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [AiTag]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AiTag]. */ - class Builder internal constructor() { - - private var confidence: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var source: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(aiTag: AiTag) = apply { - confidence = aiTag.confidence - name = aiTag.name - source = aiTag.source - additionalProperties = aiTag.additionalProperties.toMutableMap() - } - - /** Confidence score of the tag. */ - fun confidence(confidence: Double) = confidence(JsonField.of(confidence)) - - /** - * Sets [Builder.confidence] to an arbitrary JSON value. - * - * You should usually call [Builder.confidence] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun confidence(confidence: JsonField) = apply { this.confidence = confidence } - - /** Name of the tag. */ - 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 } - - /** - * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. - */ - fun source(source: String) = source(JsonField.of(source)) - - /** - * Sets [Builder.source] to an arbitrary JSON value. - * - * You should usually call [Builder.source] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun source(source: JsonField) = apply { this.source = source } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AiTag]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AiTag = - AiTag(confidence, name, source, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): AiTag = apply { - if (validated) { - return@apply - } - - confidence() - name() - source() - 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 (confidence.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (source.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AiTag && - confidence == other.confidence && - name == other.name && - source == other.source && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(confidence, name, source, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AiTag{confidence=$confidence, name=$name, source=$source, additionalProperties=$additionalProperties}" - } - - /** A key-value data associated with the asset. */ - class CustomMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [CustomMetadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customMetadata: CustomMetadata) = apply { - additionalProperties = customMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [CustomMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): CustomMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CustomMetadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" - } - - /** - * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp - * data. - */ - class EmbeddedMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [EmbeddedMetadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EmbeddedMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(embeddedMetadata: EmbeddedMetadata) = apply { - additionalProperties = embeddedMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [EmbeddedMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): EmbeddedMetadata = EmbeddedMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): EmbeddedMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EmbeddedMetadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "EmbeddedMetadata{additionalProperties=$additionalProperties}" - } - /** * Extension names with their processing status at the time of completion of the request. It * could have one of the following status values: @@ -2607,293 +2185,6 @@ private constructor( "ExtensionStatus{aiAutoDescription=$aiAutoDescription, aiTasks=$aiTasks, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" } - /** - * This field is included in the response only if the Path policy feature is available in the - * plan. It contains schema definitions for the custom metadata fields selected for the - * specified file path. Field selection can only be done when the Path policy feature is - * enabled. - * - * Keys are the names of the custom metadata fields; the value object has details about the - * custom metadata schema. - */ - class SelectedFieldsSchema - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [SelectedFieldsSchema]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SelectedFieldsSchema]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(selectedFieldsSchema: SelectedFieldsSchema) = apply { - additionalProperties = selectedFieldsSchema.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SelectedFieldsSchema]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): SelectedFieldsSchema = - SelectedFieldsSchema(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): SelectedFieldsSchema = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SelectedFieldsSchema && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "SelectedFieldsSchema{additionalProperties=$additionalProperties}" - } - - /** An object containing the file or file version's `id` (versionId) and `name`. */ - class VersionInfo - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(id, name, mutableMapOf()) - - /** - * Unique identifier of the file version. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") - - /** - * Name of the file version. - * - * @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") - - /** - * 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 [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [VersionInfo]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [VersionInfo]. */ - class Builder internal constructor() { - - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(versionInfo: VersionInfo) = apply { - id = versionInfo.id - name = versionInfo.name - additionalProperties = versionInfo.additionalProperties.toMutableMap() - } - - /** Unique identifier of the file version. */ - 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 } - - /** Name of the file version. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [VersionInfo]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): VersionInfo = VersionInfo(id, name, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): VersionInfo = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is VersionInfo && - id == other.id && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "VersionInfo{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Metadata.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Metadata.kt index ea625eaa..5e27752b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Metadata.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Metadata.kt @@ -613,7 +613,7 @@ private constructor( class Exif @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val exif: JsonField, + private val exif: JsonField, private val gps: JsonField, private val image: JsonField, private val interoperability: JsonField, @@ -624,7 +624,7 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("exif") @ExcludeMissing exif: JsonField = JsonMissing.of(), + @JsonProperty("exif") @ExcludeMissing exif: JsonField = JsonMissing.of(), @JsonProperty("gps") @ExcludeMissing gps: JsonField = JsonMissing.of(), @JsonProperty("image") @ExcludeMissing image: JsonField = JsonMissing.of(), @JsonProperty("interoperability") @@ -644,7 +644,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun exif(): Optional = exif.getOptional("exif") + fun exif(): Optional = exif.getOptional("exif") /** * Object containing GPS information. @@ -690,7 +690,7 @@ private constructor( * * Unlike [exif], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("exif") @ExcludeMissing fun _exif(): JsonField = exif + @JsonProperty("exif") @ExcludeMissing fun _exif(): JsonField = exif /** * Returns the raw JSON value of [gps]. @@ -755,7 +755,7 @@ private constructor( /** A builder for [Exif]. */ class Builder internal constructor() { - private var exif: JsonField = JsonMissing.of() + private var exif: JsonField = JsonMissing.of() private var gps: JsonField = JsonMissing.of() private var image: JsonField = JsonMissing.of() private var interoperability: JsonField = JsonMissing.of() @@ -775,16 +775,16 @@ private constructor( } /** Object containing Exif details. */ - fun exif(exif: InnerExif) = exif(JsonField.of(exif)) + fun exif(exif: ExifDetails) = exif(JsonField.of(exif)) /** * Sets [Builder.exif] to an arbitrary JSON value. * - * You should usually call [Builder.exif] with a well-typed [InnerExif] value instead. + * You should usually call [Builder.exif] with a well-typed [ExifDetails] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun exif(exif: JsonField) = apply { this.exif = exif } + fun exif(exif: JsonField) = apply { this.exif = exif } /** Object containing GPS information. */ fun gps(gps: Gps) = gps(JsonField.of(gps)) @@ -924,7 +924,7 @@ private constructor( (thumbnail.asKnown().getOrNull()?.validity() ?: 0) /** Object containing Exif details. */ - class InnerExif + class ExifDetails @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val apertureValue: JsonField, @@ -1490,11 +1490,11 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [InnerExif]. */ + /** Returns a mutable builder for constructing an instance of [ExifDetails]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [InnerExif]. */ + /** A builder for [ExifDetails]. */ class Builder internal constructor() { private var apertureValue: JsonField = JsonMissing.of() @@ -1526,34 +1526,34 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(innerExif: InnerExif) = apply { - apertureValue = innerExif.apertureValue - colorSpace = innerExif.colorSpace - createDate = innerExif.createDate - customRendered = innerExif.customRendered - dateTimeOriginal = innerExif.dateTimeOriginal - exifImageHeight = innerExif.exifImageHeight - exifImageWidth = innerExif.exifImageWidth - exifVersion = innerExif.exifVersion - exposureCompensation = innerExif.exposureCompensation - exposureMode = innerExif.exposureMode - exposureProgram = innerExif.exposureProgram - exposureTime = innerExif.exposureTime - flash = innerExif.flash - flashpixVersion = innerExif.flashpixVersion - fNumber = innerExif.fNumber - focalLength = innerExif.focalLength - focalPlaneResolutionUnit = innerExif.focalPlaneResolutionUnit - focalPlaneXResolution = innerExif.focalPlaneXResolution - focalPlaneYResolution = innerExif.focalPlaneYResolution - interopOffset = innerExif.interopOffset - iso = innerExif.iso - meteringMode = innerExif.meteringMode - sceneCaptureType = innerExif.sceneCaptureType - shutterSpeedValue = innerExif.shutterSpeedValue - subSecTime = innerExif.subSecTime - whiteBalance = innerExif.whiteBalance - additionalProperties = innerExif.additionalProperties.toMutableMap() + internal fun from(exifDetails: ExifDetails) = apply { + apertureValue = exifDetails.apertureValue + colorSpace = exifDetails.colorSpace + createDate = exifDetails.createDate + customRendered = exifDetails.customRendered + dateTimeOriginal = exifDetails.dateTimeOriginal + exifImageHeight = exifDetails.exifImageHeight + exifImageWidth = exifDetails.exifImageWidth + exifVersion = exifDetails.exifVersion + exposureCompensation = exifDetails.exposureCompensation + exposureMode = exifDetails.exposureMode + exposureProgram = exifDetails.exposureProgram + exposureTime = exifDetails.exposureTime + flash = exifDetails.flash + flashpixVersion = exifDetails.flashpixVersion + fNumber = exifDetails.fNumber + focalLength = exifDetails.focalLength + focalPlaneResolutionUnit = exifDetails.focalPlaneResolutionUnit + focalPlaneXResolution = exifDetails.focalPlaneXResolution + focalPlaneYResolution = exifDetails.focalPlaneYResolution + interopOffset = exifDetails.interopOffset + iso = exifDetails.iso + meteringMode = exifDetails.meteringMode + sceneCaptureType = exifDetails.sceneCaptureType + shutterSpeedValue = exifDetails.shutterSpeedValue + subSecTime = exifDetails.subSecTime + whiteBalance = exifDetails.whiteBalance + additionalProperties = exifDetails.additionalProperties.toMutableMap() } fun apertureValue(apertureValue: Double) = @@ -1922,12 +1922,12 @@ private constructor( } /** - * Returns an immutable instance of [InnerExif]. + * Returns an immutable instance of [ExifDetails]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): InnerExif = - InnerExif( + fun build(): ExifDetails = + ExifDetails( apertureValue, colorSpace, createDate, @@ -1960,7 +1960,7 @@ private constructor( private var validated: Boolean = false - fun validate(): InnerExif = apply { + fun validate(): ExifDetails = apply { if (validated) { return@apply } @@ -2042,7 +2042,7 @@ private constructor( return true } - return other is InnerExif && + return other is ExifDetails && apertureValue == other.apertureValue && colorSpace == other.colorSpace && createDate == other.createDate && @@ -2107,7 +2107,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InnerExif{apertureValue=$apertureValue, colorSpace=$colorSpace, createDate=$createDate, customRendered=$customRendered, dateTimeOriginal=$dateTimeOriginal, exifImageHeight=$exifImageHeight, exifImageWidth=$exifImageWidth, exifVersion=$exifVersion, exposureCompensation=$exposureCompensation, exposureMode=$exposureMode, exposureProgram=$exposureProgram, exposureTime=$exposureTime, flash=$flash, flashpixVersion=$flashpixVersion, fNumber=$fNumber, focalLength=$focalLength, focalPlaneResolutionUnit=$focalPlaneResolutionUnit, focalPlaneXResolution=$focalPlaneXResolution, focalPlaneYResolution=$focalPlaneYResolution, interopOffset=$interopOffset, iso=$iso, meteringMode=$meteringMode, sceneCaptureType=$sceneCaptureType, shutterSpeedValue=$shutterSpeedValue, subSecTime=$subSecTime, whiteBalance=$whiteBalance, additionalProperties=$additionalProperties}" + "ExifDetails{apertureValue=$apertureValue, colorSpace=$colorSpace, createDate=$createDate, customRendered=$customRendered, dateTimeOriginal=$dateTimeOriginal, exifImageHeight=$exifImageHeight, exifImageWidth=$exifImageWidth, exifVersion=$exifVersion, exposureCompensation=$exposureCompensation, exposureMode=$exposureMode, exposureProgram=$exposureProgram, exposureTime=$exposureTime, flash=$flash, flashpixVersion=$flashpixVersion, fNumber=$fNumber, focalLength=$focalLength, focalPlaneResolutionUnit=$focalPlaneResolutionUnit, focalPlaneXResolution=$focalPlaneXResolution, focalPlaneYResolution=$focalPlaneYResolution, interopOffset=$interopOffset, iso=$iso, meteringMode=$meteringMode, sceneCaptureType=$sceneCaptureType, shutterSpeedValue=$shutterSpeedValue, subSecTime=$subSecTime, whiteBalance=$whiteBalance, additionalProperties=$additionalProperties}" } /** Object containing GPS information. */ diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt index b61f39f0..618f5e92 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt @@ -15,7 +15,6 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.BaseDeserializer import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.Enum import com.imagekit.api.core.ExcludeMissing import com.imagekit.api.core.JsonField import com.imagekit.api.core.JsonMissing @@ -26,7 +25,7 @@ import com.imagekit.api.core.checkRequired import com.imagekit.api.core.getOrThrow import com.imagekit.api.core.toImmutable import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 +import com.imagekit.api.models.ExtensionItem import java.util.Collections import java.util.Objects import java.util.Optional @@ -223,7 +222,7 @@ private constructor( private val customCoordinates: JsonField, private val customMetadata: JsonField, private val description: JsonField, - private val extensions: JsonField>, + private val extensions: JsonField>, private val removeAiTags: JsonField, private val tags: JsonField>, private val webhookUrl: JsonField, @@ -243,7 +242,7 @@ private constructor( description: JsonField = JsonMissing.of(), @JsonProperty("extensions") @ExcludeMissing - extensions: JsonField> = JsonMissing.of(), + extensions: JsonField> = JsonMissing.of(), @JsonProperty("removeAITags") @ExcludeMissing removeAiTags: JsonField = JsonMissing.of(), @@ -298,8 +297,7 @@ private constructor( * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun extensions(): Optional> = - extensions.getOptional("extensions") + fun extensions(): Optional> = extensions.getOptional("extensions") /** * An array of AITags associated with the file that you want to remove, e.g. `["car", @@ -371,7 +369,7 @@ private constructor( */ @JsonProperty("extensions") @ExcludeMissing - fun _extensions(): JsonField> = extensions + fun _extensions(): JsonField> = extensions /** * Returns the raw JSON value of [removeAiTags]. @@ -423,7 +421,7 @@ private constructor( private var customCoordinates: JsonField = JsonMissing.of() private var customMetadata: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() - private var extensions: JsonField>? = null + private var extensions: JsonField>? = null private var removeAiTags: JsonField = JsonMissing.of() private var tags: JsonField>? = null private var webhookUrl: JsonField = JsonMissing.of() @@ -502,92 +500,77 @@ private constructor( * Array of extensions to be applied to the asset. Each extension can be configured with * specific parameters based on the extension type. */ - fun extensions(extensions: List) = - extensions(JsonField.of(extensions)) + fun extensions(extensions: List) = extensions(JsonField.of(extensions)) /** * Sets [Builder.extensions] to an arbitrary JSON value. * - * You should usually call [Builder.extensions] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.extensions] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun extensions(extensions: JsonField>) = apply { + fun extensions(extensions: JsonField>) = apply { this.extensions = extensions.map { it.toMutableList() } } /** - * Adds a single [UnnamedSchemaWithArrayParent4] to [extensions]. + * Adds a single [ExtensionItem] to [extensions]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addExtension(extension: UnnamedSchemaWithArrayParent4) = apply { + fun addExtension(extension: ExtensionItem) = apply { extensions = (extensions ?: JsonField.of(mutableListOf())).also { checkKnown("extensions", it).add(extension) } } - /** - * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofRemoveBg(removeBg)`. - */ - fun addExtension(removeBg: UnnamedSchemaWithArrayParent4.RemoveBg) = - addExtension(UnnamedSchemaWithArrayParent4.ofRemoveBg(removeBg)) + /** Alias for calling [addExtension] with `ExtensionItem.ofRemoveBg(removeBg)`. */ + fun addExtension(removeBg: ExtensionItem.RemoveBg) = + addExtension(ExtensionItem.ofRemoveBg(removeBg)) /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension(autoTaggingExtension)`. + * `ExtensionItem.ofAutoTaggingExtension(autoTaggingExtension)`. */ - fun addExtension( - autoTaggingExtension: UnnamedSchemaWithArrayParent4.AutoTaggingExtension - ) = - addExtension( - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension(autoTaggingExtension) - ) + fun addExtension(autoTaggingExtension: ExtensionItem.AutoTaggingExtension) = + addExtension(ExtensionItem.ofAutoTaggingExtension(autoTaggingExtension)) - /** - * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofAiAutoDescription()`. - */ - fun addExtensionAiAutoDescription() = - addExtension(UnnamedSchemaWithArrayParent4.ofAiAutoDescription()) + /** Alias for calling [addExtension] with `ExtensionItem.ofAiAutoDescription()`. */ + fun addExtensionAiAutoDescription() = addExtension(ExtensionItem.ofAiAutoDescription()) - /** - * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofAiTasks(aiTasks)`. - */ - fun addExtension(aiTasks: UnnamedSchemaWithArrayParent4.AiTasks) = - addExtension(UnnamedSchemaWithArrayParent4.ofAiTasks(aiTasks)) + /** Alias for calling [addExtension] with `ExtensionItem.ofAiTasks(aiTasks)`. */ + fun addExtension(aiTasks: ExtensionItem.AiTasks) = + addExtension(ExtensionItem.ofAiTasks(aiTasks)) /** * Alias for calling [addExtension] with the following: * ```java - * UnnamedSchemaWithArrayParent4.AiTasks.builder() + * ExtensionItem.AiTasks.builder() * .tasks(tasks) * .build() * ``` */ - fun addAiTasksExtension(tasks: List) = - addExtension(UnnamedSchemaWithArrayParent4.AiTasks.builder().tasks(tasks).build()) + fun addAiTasksExtension(tasks: List) = + addExtension(ExtensionItem.AiTasks.builder().tasks(tasks).build()) /** * Alias for calling [addExtension] with - * `UnnamedSchemaWithArrayParent4.ofSavedExtension(savedExtension)`. + * `ExtensionItem.ofSavedExtension(savedExtension)`. */ - fun addExtension(savedExtension: UnnamedSchemaWithArrayParent4.SavedExtension) = - addExtension(UnnamedSchemaWithArrayParent4.ofSavedExtension(savedExtension)) + fun addExtension(savedExtension: ExtensionItem.SavedExtension) = + addExtension(ExtensionItem.ofSavedExtension(savedExtension)) /** * Alias for calling [addExtension] with the following: * ```java - * UnnamedSchemaWithArrayParent4.SavedExtension.builder() + * ExtensionItem.SavedExtension.builder() * .id(id) * .build() * ``` */ fun addSavedExtensionExtension(id: String) = - addExtension(UnnamedSchemaWithArrayParent4.SavedExtension.builder().id(id).build()) + addExtension(ExtensionItem.SavedExtension.builder().id(id).build()) /** * An array of AITags associated with the file that you want to remove, e.g. `["car", @@ -850,7272 +833,6 @@ private constructor( override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" } - @JsonDeserialize(using = UnnamedSchemaWithArrayParent4.Deserializer::class) - @JsonSerialize(using = UnnamedSchemaWithArrayParent4.Serializer::class) - class UnnamedSchemaWithArrayParent4 - private constructor( - private val removeBg: RemoveBg? = null, - private val autoTaggingExtension: AutoTaggingExtension? = null, - private val aiAutoDescription: JsonValue? = null, - private val aiTasks: AiTasks? = null, - private val savedExtension: SavedExtension? = null, - private val _json: JsonValue? = null, - ) { - - fun removeBg(): Optional = Optional.ofNullable(removeBg) - - fun autoTaggingExtension(): Optional = - Optional.ofNullable(autoTaggingExtension) - - fun aiAutoDescription(): Optional = Optional.ofNullable(aiAutoDescription) - - fun aiTasks(): Optional = Optional.ofNullable(aiTasks) - - fun savedExtension(): Optional = Optional.ofNullable(savedExtension) - - fun isRemoveBg(): Boolean = removeBg != null - - fun isAutoTaggingExtension(): Boolean = autoTaggingExtension != null - - fun isAiAutoDescription(): Boolean = aiAutoDescription != null - - fun isAiTasks(): Boolean = aiTasks != null - - fun isSavedExtension(): Boolean = savedExtension != null - - fun asRemoveBg(): RemoveBg = removeBg.getOrThrow("removeBg") - - fun asAutoTaggingExtension(): AutoTaggingExtension = - autoTaggingExtension.getOrThrow("autoTaggingExtension") - - fun asAiAutoDescription(): JsonValue = aiAutoDescription.getOrThrow("aiAutoDescription") - - fun asAiTasks(): AiTasks = aiTasks.getOrThrow("aiTasks") - - fun asSavedExtension(): SavedExtension = savedExtension.getOrThrow("savedExtension") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - removeBg != null -> visitor.visitRemoveBg(removeBg) - autoTaggingExtension != null -> - visitor.visitAutoTaggingExtension(autoTaggingExtension) - aiAutoDescription != null -> visitor.visitAiAutoDescription(aiAutoDescription) - aiTasks != null -> visitor.visitAiTasks(aiTasks) - savedExtension != null -> visitor.visitSavedExtension(savedExtension) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): UnnamedSchemaWithArrayParent4 = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitRemoveBg(removeBg: RemoveBg) { - removeBg.validate() - } - - override fun visitAutoTaggingExtension( - autoTaggingExtension: AutoTaggingExtension - ) { - autoTaggingExtension.validate() - } - - override fun visitAiAutoDescription(aiAutoDescription: JsonValue) { - aiAutoDescription.let { - if (it != JsonValue.from(mapOf("name" to "ai-auto-description"))) { - throw ImageKitInvalidDataException( - "'aiAutoDescription' is invalid, received $it" - ) - } - } - } - - override fun visitAiTasks(aiTasks: AiTasks) { - aiTasks.validate() - } - - override fun visitSavedExtension(savedExtension: SavedExtension) { - savedExtension.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitRemoveBg(removeBg: RemoveBg) = removeBg.validity() - - override fun visitAutoTaggingExtension( - autoTaggingExtension: AutoTaggingExtension - ) = autoTaggingExtension.validity() - - override fun visitAiAutoDescription(aiAutoDescription: JsonValue) = - aiAutoDescription.let { - if (it == JsonValue.from(mapOf("name" to "ai-auto-description"))) 1 - else 0 - } - - override fun visitAiTasks(aiTasks: AiTasks) = aiTasks.validity() - - override fun visitSavedExtension(savedExtension: SavedExtension) = - savedExtension.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnnamedSchemaWithArrayParent4 && - removeBg == other.removeBg && - autoTaggingExtension == other.autoTaggingExtension && - aiAutoDescription == other.aiAutoDescription && - aiTasks == other.aiTasks && - savedExtension == other.savedExtension - } - - override fun hashCode(): Int = - Objects.hash( - removeBg, - autoTaggingExtension, - aiAutoDescription, - aiTasks, - savedExtension, - ) - - override fun toString(): String = - when { - removeBg != null -> "UnnamedSchemaWithArrayParent4{removeBg=$removeBg}" - autoTaggingExtension != null -> - "UnnamedSchemaWithArrayParent4{autoTaggingExtension=$autoTaggingExtension}" - aiAutoDescription != null -> - "UnnamedSchemaWithArrayParent4{aiAutoDescription=$aiAutoDescription}" - aiTasks != null -> "UnnamedSchemaWithArrayParent4{aiTasks=$aiTasks}" - savedExtension != null -> - "UnnamedSchemaWithArrayParent4{savedExtension=$savedExtension}" - _json != null -> "UnnamedSchemaWithArrayParent4{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent4") - } - - companion object { - - @JvmStatic - fun ofRemoveBg(removeBg: RemoveBg) = - UnnamedSchemaWithArrayParent4(removeBg = removeBg) - - @JvmStatic - fun ofAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension) = - UnnamedSchemaWithArrayParent4(autoTaggingExtension = autoTaggingExtension) - - @JvmStatic - fun ofAiAutoDescription() = - UnnamedSchemaWithArrayParent4( - aiAutoDescription = JsonValue.from(mapOf("name" to "ai-auto-description")) - ) - - @JvmStatic - fun ofAiTasks(aiTasks: AiTasks) = UnnamedSchemaWithArrayParent4(aiTasks = aiTasks) - - @JvmStatic - fun ofSavedExtension(savedExtension: SavedExtension) = - UnnamedSchemaWithArrayParent4(savedExtension = savedExtension) - } - - /** - * An interface that defines how to map each variant of [UnnamedSchemaWithArrayParent4] - * to a value of type [T]. - */ - interface Visitor { - - fun visitRemoveBg(removeBg: RemoveBg): T - - fun visitAutoTaggingExtension(autoTaggingExtension: AutoTaggingExtension): T - - fun visitAiAutoDescription(aiAutoDescription: JsonValue): T - - fun visitAiTasks(aiTasks: AiTasks): T - - fun visitSavedExtension(savedExtension: SavedExtension): T - - /** - * Maps an unknown variant of [UnnamedSchemaWithArrayParent4] to a value of type - * [T]. - * - * An instance of [UnnamedSchemaWithArrayParent4] can contain an unknown variant if - * it was deserialized from data that doesn't match any known variant. For example, - * if the SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent4: $json" - ) - } - } - - internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent4::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): UnnamedSchemaWithArrayParent4 { - val json = JsonValue.fromJsonNode(node) - val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() - - when (name) { - "remove-bg" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent4(removeBg = it, _json = json) - } ?: UnnamedSchemaWithArrayParent4(_json = json) - } - "ai-auto-description" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { - UnnamedSchemaWithArrayParent4( - aiAutoDescription = it, - _json = json, - ) - } - ?.takeIf { it.isValid() } - ?: UnnamedSchemaWithArrayParent4(_json = json) - } - "ai-tasks" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent4(aiTasks = it, _json = json) - } ?: UnnamedSchemaWithArrayParent4(_json = json) - } - "saved-extension" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent4(savedExtension = it, _json = json) - } ?: UnnamedSchemaWithArrayParent4(_json = json) - } - } - - return tryDeserialize(node, jacksonTypeRef())?.let { - UnnamedSchemaWithArrayParent4(autoTaggingExtension = it, _json = json) - } ?: UnnamedSchemaWithArrayParent4(_json = json) - } - } - - internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent4::class - ) { - - override fun serialize( - value: UnnamedSchemaWithArrayParent4, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.removeBg != null -> generator.writeObject(value.removeBg) - value.autoTaggingExtension != null -> - generator.writeObject(value.autoTaggingExtension) - value.aiAutoDescription != null -> - generator.writeObject(value.aiAutoDescription) - value.aiTasks != null -> generator.writeObject(value.aiTasks) - value.savedExtension != null -> generator.writeObject(value.savedExtension) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent4") - } - } - } - - class RemoveBg - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val name: JsonValue, - private val options: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), - @JsonProperty("options") - @ExcludeMissing - options: JsonField = JsonMissing.of(), - ) : this(name, options, mutableMapOf()) - - /** - * Specifies the background removal extension. - * - * Expected to always return the following: - * ```java - * JsonValue.from("remove-bg") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name - - /** - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun options(): Optional = options.getOptional("options") - - /** - * Returns the raw JSON value of [options]. - * - * Unlike [options], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("options") - @ExcludeMissing - fun _options(): JsonField = options - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [RemoveBg]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RemoveBg]. */ - class Builder internal constructor() { - - private var name: JsonValue = JsonValue.from("remove-bg") - private var options: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(removeBg: RemoveBg) = apply { - name = removeBg.name - options = removeBg.options - additionalProperties = removeBg.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```java - * JsonValue.from("remove-bg") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonValue) = apply { this.name = name } - - fun options(options: Options) = options(JsonField.of(options)) - - /** - * Sets [Builder.options] to an arbitrary JSON value. - * - * You should usually call [Builder.options] with a well-typed [Options] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun options(options: JsonField) = apply { this.options = options } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [RemoveBg]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RemoveBg = - RemoveBg(name, options, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): RemoveBg = apply { - if (validated) { - return@apply - } - - _name().let { - if (it != JsonValue.from("remove-bg")) { - throw ImageKitInvalidDataException("'name' is invalid, received $it") - } - } - options().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - name.let { if (it == JsonValue.from("remove-bg")) 1 else 0 } + - (options.asKnown().getOrNull()?.validity() ?: 0) - - class Options - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val addShadow: JsonField, - private val bgColor: JsonField, - private val bgImageUrl: JsonField, - private val semitransparency: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("add_shadow") - @ExcludeMissing - addShadow: JsonField = JsonMissing.of(), - @JsonProperty("bg_color") - @ExcludeMissing - bgColor: JsonField = JsonMissing.of(), - @JsonProperty("bg_image_url") - @ExcludeMissing - bgImageUrl: JsonField = JsonMissing.of(), - @JsonProperty("semitransparency") - @ExcludeMissing - semitransparency: JsonField = JsonMissing.of(), - ) : this(addShadow, bgColor, bgImageUrl, semitransparency, mutableMapOf()) - - /** - * Whether to add an artificial shadow to the result. Default is false. Note: - * Adding shadows is currently only supported for car photos. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun addShadow(): Optional = addShadow.getOptional("add_shadow") - - /** - * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") or - * color name (e.g., "green"). If this parameter is set, `bg_image_url` must be - * empty. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun bgColor(): Optional = bgColor.getOptional("bg_color") - - /** - * Sets a background image from a URL. If this parameter is set, `bg_color` must - * be empty. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun bgImageUrl(): Optional = bgImageUrl.getOptional("bg_image_url") - - /** - * Allows semi-transparent regions in the result. Default is true. Note: - * Semitransparency is currently only supported for car windows. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun semitransparency(): Optional = - semitransparency.getOptional("semitransparency") - - /** - * Returns the raw JSON value of [addShadow]. - * - * Unlike [addShadow], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("add_shadow") - @ExcludeMissing - fun _addShadow(): JsonField = addShadow - - /** - * Returns the raw JSON value of [bgColor]. - * - * Unlike [bgColor], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("bg_color") - @ExcludeMissing - fun _bgColor(): JsonField = bgColor - - /** - * Returns the raw JSON value of [bgImageUrl]. - * - * Unlike [bgImageUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("bg_image_url") - @ExcludeMissing - fun _bgImageUrl(): JsonField = bgImageUrl - - /** - * Returns the raw JSON value of [semitransparency]. - * - * Unlike [semitransparency], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("semitransparency") - @ExcludeMissing - fun _semitransparency(): JsonField = semitransparency - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Options]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Options]. */ - class Builder internal constructor() { - - private var addShadow: JsonField = JsonMissing.of() - private var bgColor: JsonField = JsonMissing.of() - private var bgImageUrl: JsonField = JsonMissing.of() - private var semitransparency: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(options: Options) = apply { - addShadow = options.addShadow - bgColor = options.bgColor - bgImageUrl = options.bgImageUrl - semitransparency = options.semitransparency - additionalProperties = options.additionalProperties.toMutableMap() - } - - /** - * Whether to add an artificial shadow to the result. Default is false. - * Note: Adding shadows is currently only supported for car photos. - */ - fun addShadow(addShadow: Boolean) = addShadow(JsonField.of(addShadow)) - - /** - * Sets [Builder.addShadow] to an arbitrary JSON value. - * - * You should usually call [Builder.addShadow] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun addShadow(addShadow: JsonField) = apply { - this.addShadow = addShadow - } - - /** - * Specifies a solid color background using hex code (e.g., "81d4fa", "fff") - * or color name (e.g., "green"). If this parameter is set, `bg_image_url` - * must be empty. - */ - fun bgColor(bgColor: String) = bgColor(JsonField.of(bgColor)) - - /** - * Sets [Builder.bgColor] to an arbitrary JSON value. - * - * You should usually call [Builder.bgColor] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun bgColor(bgColor: JsonField) = apply { this.bgColor = bgColor } - - /** - * Sets a background image from a URL. If this parameter is set, `bg_color` - * must be empty. - */ - fun bgImageUrl(bgImageUrl: String) = bgImageUrl(JsonField.of(bgImageUrl)) - - /** - * Sets [Builder.bgImageUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.bgImageUrl] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun bgImageUrl(bgImageUrl: JsonField) = apply { - this.bgImageUrl = bgImageUrl - } - - /** - * Allows semi-transparent regions in the result. Default is true. Note: - * Semitransparency is currently only supported for car windows. - */ - fun semitransparency(semitransparency: Boolean) = - semitransparency(JsonField.of(semitransparency)) - - /** - * Sets [Builder.semitransparency] to an arbitrary JSON value. - * - * You should usually call [Builder.semitransparency] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun semitransparency(semitransparency: JsonField) = apply { - this.semitransparency = semitransparency - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Options]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Options = - Options( - addShadow, - bgColor, - bgImageUrl, - semitransparency, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Options = apply { - if (validated) { - return@apply - } - - addShadow() - bgColor() - bgImageUrl() - semitransparency() - 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 (addShadow.asKnown().isPresent) 1 else 0) + - (if (bgColor.asKnown().isPresent) 1 else 0) + - (if (bgImageUrl.asKnown().isPresent) 1 else 0) + - (if (semitransparency.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - addShadow == other.addShadow && - bgColor == other.bgColor && - bgImageUrl == other.bgImageUrl && - semitransparency == other.semitransparency && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - addShadow, - bgColor, - bgImageUrl, - semitransparency, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Options{addShadow=$addShadow, bgColor=$bgColor, bgImageUrl=$bgImageUrl, semitransparency=$semitransparency, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemoveBg && - name == other.name && - options == other.options && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(name, options, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemoveBg{name=$name, options=$options, additionalProperties=$additionalProperties}" - } - - class AutoTaggingExtension - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val maxTags: JsonField, - private val minConfidence: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("maxTags") - @ExcludeMissing - maxTags: JsonField = JsonMissing.of(), - @JsonProperty("minConfidence") - @ExcludeMissing - minConfidence: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(maxTags, minConfidence, name, mutableMapOf()) - - /** - * Maximum number of tags to attach to the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun maxTags(): Long = maxTags.getRequired("maxTags") - - /** - * Minimum confidence level for tags to be considered valid. - * - * @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 minConfidence(): Long = minConfidence.getRequired("minConfidence") - - /** - * Specifies the auto-tagging extension used. - * - * @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(): Name = name.getRequired("name") - - /** - * Returns the raw JSON value of [maxTags]. - * - * Unlike [maxTags], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("maxTags") @ExcludeMissing fun _maxTags(): JsonField = maxTags - - /** - * Returns the raw JSON value of [minConfidence]. - * - * Unlike [minConfidence], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("minConfidence") - @ExcludeMissing - fun _minConfidence(): JsonField = minConfidence - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AutoTaggingExtension]. - * - * The following fields are required: - * ```java - * .maxTags() - * .minConfidence() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutoTaggingExtension]. */ - class Builder internal constructor() { - - private var maxTags: JsonField? = null - private var minConfidence: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(autoTaggingExtension: AutoTaggingExtension) = apply { - maxTags = autoTaggingExtension.maxTags - minConfidence = autoTaggingExtension.minConfidence - name = autoTaggingExtension.name - additionalProperties = - autoTaggingExtension.additionalProperties.toMutableMap() - } - - /** Maximum number of tags to attach to the asset. */ - fun maxTags(maxTags: Long) = maxTags(JsonField.of(maxTags)) - - /** - * Sets [Builder.maxTags] to an arbitrary JSON value. - * - * You should usually call [Builder.maxTags] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun maxTags(maxTags: JsonField) = apply { this.maxTags = maxTags } - - /** Minimum confidence level for tags to be considered valid. */ - fun minConfidence(minConfidence: Long) = - minConfidence(JsonField.of(minConfidence)) - - /** - * Sets [Builder.minConfidence] to an arbitrary JSON value. - * - * You should usually call [Builder.minConfidence] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun minConfidence(minConfidence: JsonField) = apply { - this.minConfidence = minConfidence - } - - /** Specifies the auto-tagging extension used. */ - fun name(name: Name) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [Name] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AutoTaggingExtension]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .maxTags() - * .minConfidence() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AutoTaggingExtension = - AutoTaggingExtension( - checkRequired("maxTags", maxTags), - checkRequired("minConfidence", minConfidence), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutoTaggingExtension = apply { - if (validated) { - return@apply - } - - maxTags() - minConfidence() - name().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (maxTags.asKnown().isPresent) 1 else 0) + - (if (minConfidence.asKnown().isPresent) 1 else 0) + - (name.asKnown().getOrNull()?.validity() ?: 0) - - /** Specifies the auto-tagging extension used. */ - class Name @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GOOGLE_AUTO_TAGGING = of("google-auto-tagging") - - @JvmField val AWS_AUTO_TAGGING = of("aws-auto-tagging") - - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } - - /** An enum containing [Name]'s known values. */ - enum class Known { - GOOGLE_AUTO_TAGGING, - AWS_AUTO_TAGGING, - } - - /** - * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Name] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GOOGLE_AUTO_TAGGING, - AWS_AUTO_TAGGING, - /** - * An enum member indicating that [Name] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GOOGLE_AUTO_TAGGING -> Value.GOOGLE_AUTO_TAGGING - AWS_AUTO_TAGGING -> Value.AWS_AUTO_TAGGING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws ImageKitInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - GOOGLE_AUTO_TAGGING -> Known.GOOGLE_AUTO_TAGGING - AWS_AUTO_TAGGING -> Known.AWS_AUTO_TAGGING - else -> throw ImageKitInvalidDataException("Unknown Name: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws ImageKitInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - ImageKitInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Name = apply { - if (validated) { - return@apply - } - - known() - 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 (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Name && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AutoTaggingExtension && - maxTags == other.maxTags && - minConfidence == other.minConfidence && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(maxTags, minConfidence, name, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutoTaggingExtension{maxTags=$maxTags, minConfidence=$minConfidence, name=$name, additionalProperties=$additionalProperties}" - } - - class AiTasks - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val name: JsonValue, - private val tasks: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), - @JsonProperty("tasks") - @ExcludeMissing - tasks: JsonField> = JsonMissing.of(), - ) : this(name, tasks, mutableMapOf()) - - /** - * Specifies the AI tasks extension for automated image analysis using AI models. - * - * Expected to always return the following: - * ```java - * JsonValue.from("ai-tasks") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name - - /** - * Array of task objects defining AI operations to perform on the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tasks(): List = tasks.getRequired("tasks") - - /** - * Returns the raw JSON value of [tasks]. - * - * Unlike [tasks], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tasks") @ExcludeMissing fun _tasks(): JsonField> = tasks - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [AiTasks]. - * - * The following fields are required: - * ```java - * .tasks() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AiTasks]. */ - class Builder internal constructor() { - - private var name: JsonValue = JsonValue.from("ai-tasks") - private var tasks: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(aiTasks: AiTasks) = apply { - name = aiTasks.name - tasks = aiTasks.tasks.map { it.toMutableList() } - additionalProperties = aiTasks.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```java - * JsonValue.from("ai-tasks") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonValue) = apply { this.name = name } - - /** Array of task objects defining AI operations to perform on the asset. */ - fun tasks(tasks: List) = tasks(JsonField.of(tasks)) - - /** - * Sets [Builder.tasks] to an arbitrary JSON value. - * - * You should usually call [Builder.tasks] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun tasks(tasks: JsonField>) = apply { - this.tasks = tasks.map { it.toMutableList() } - } - - /** - * Adds a single [Task] to [tasks]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTask(task: Task) = apply { - tasks = - (tasks ?: JsonField.of(mutableListOf())).also { - checkKnown("tasks", it).add(task) - } - } - - /** Alias for calling [addTask] with `Task.ofSelectTags(selectTags)`. */ - fun addTask(selectTags: Task.SelectTags) = - addTask(Task.ofSelectTags(selectTags)) - - /** - * Alias for calling [addTask] with the following: - * ```java - * Task.SelectTags.builder() - * .instruction(instruction) - * .build() - * ``` - */ - fun addSelectTagsTask(instruction: String) = - addTask(Task.SelectTags.builder().instruction(instruction).build()) - - /** Alias for calling [addTask] with `Task.ofSelectMetadata(selectMetadata)`. */ - fun addTask(selectMetadata: Task.SelectMetadata) = - addTask(Task.ofSelectMetadata(selectMetadata)) - - /** Alias for calling [addTask] with `Task.ofYesNo(yesNo)`. */ - fun addTask(yesNo: Task.YesNo) = addTask(Task.ofYesNo(yesNo)) - - /** - * Alias for calling [addTask] with the following: - * ```java - * Task.YesNo.builder() - * .instruction(instruction) - * .build() - * ``` - */ - fun addYesNoTask(instruction: String) = - addTask(Task.YesNo.builder().instruction(instruction).build()) - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AiTasks]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .tasks() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AiTasks = - AiTasks( - name, - checkRequired("tasks", tasks).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AiTasks = apply { - if (validated) { - return@apply - } - - _name().let { - if (it != JsonValue.from("ai-tasks")) { - throw ImageKitInvalidDataException("'name' is invalid, received $it") - } - } - tasks().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - name.let { if (it == JsonValue.from("ai-tasks")) 1 else 0 } + - (tasks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - @JsonDeserialize(using = Task.Deserializer::class) - @JsonSerialize(using = Task.Serializer::class) - class Task - private constructor( - private val selectTags: SelectTags? = null, - private val selectMetadata: SelectMetadata? = null, - private val yesNo: YesNo? = null, - private val _json: JsonValue? = null, - ) { - - fun selectTags(): Optional = Optional.ofNullable(selectTags) - - fun selectMetadata(): Optional = - Optional.ofNullable(selectMetadata) - - fun yesNo(): Optional = Optional.ofNullable(yesNo) - - fun isSelectTags(): Boolean = selectTags != null - - fun isSelectMetadata(): Boolean = selectMetadata != null - - fun isYesNo(): Boolean = yesNo != null - - fun asSelectTags(): SelectTags = selectTags.getOrThrow("selectTags") - - fun asSelectMetadata(): SelectMetadata = - selectMetadata.getOrThrow("selectMetadata") - - fun asYesNo(): YesNo = yesNo.getOrThrow("yesNo") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - selectTags != null -> visitor.visitSelectTags(selectTags) - selectMetadata != null -> visitor.visitSelectMetadata(selectMetadata) - yesNo != null -> visitor.visitYesNo(yesNo) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Task = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitSelectTags(selectTags: SelectTags) { - selectTags.validate() - } - - override fun visitSelectMetadata(selectMetadata: SelectMetadata) { - selectMetadata.validate() - } - - override fun visitYesNo(yesNo: YesNo) { - yesNo.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitSelectTags(selectTags: SelectTags) = - selectTags.validity() - - override fun visitSelectMetadata(selectMetadata: SelectMetadata) = - selectMetadata.validity() - - override fun visitYesNo(yesNo: YesNo) = yesNo.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Task && - selectTags == other.selectTags && - selectMetadata == other.selectMetadata && - yesNo == other.yesNo - } - - override fun hashCode(): Int = Objects.hash(selectTags, selectMetadata, yesNo) - - override fun toString(): String = - when { - selectTags != null -> "Task{selectTags=$selectTags}" - selectMetadata != null -> "Task{selectMetadata=$selectMetadata}" - yesNo != null -> "Task{yesNo=$yesNo}" - _json != null -> "Task{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Task") - } - - companion object { - - @JvmStatic - fun ofSelectTags(selectTags: SelectTags) = Task(selectTags = selectTags) - - @JvmStatic - fun ofSelectMetadata(selectMetadata: SelectMetadata) = - Task(selectMetadata = selectMetadata) - - @JvmStatic fun ofYesNo(yesNo: YesNo) = Task(yesNo = yesNo) - } - - /** - * An interface that defines how to map each variant of [Task] to a value of - * type [T]. - */ - interface Visitor { - - fun visitSelectTags(selectTags: SelectTags): T - - fun visitSelectMetadata(selectMetadata: SelectMetadata): T - - fun visitYesNo(yesNo: YesNo): T - - /** - * Maps an unknown variant of [Task] to a value of type [T]. - * - * An instance of [Task] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, - * if the SDK is on an older version than the API, then the API may respond - * with new variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Task: $json") - } - } - - internal class Deserializer : BaseDeserializer(Task::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Task { - val json = JsonValue.fromJsonNode(node) - val type = - json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - - when (type) { - "select_tags" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Task(selectTags = it, _json = json) - } ?: Task(_json = json) - } - "select_metadata" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Task(selectMetadata = it, _json = json) } - ?: Task(_json = json) - } - "yes_no" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Task(yesNo = it, _json = json) - } ?: Task(_json = json) - } - } - - return Task(_json = json) - } - } - - internal class Serializer : BaseSerializer(Task::class) { - - override fun serialize( - value: Task, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.selectTags != null -> generator.writeObject(value.selectTags) - value.selectMetadata != null -> - generator.writeObject(value.selectMetadata) - value.yesNo != null -> generator.writeObject(value.yesNo) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Task") - } - } - } - - class SelectTags - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val instruction: JsonField, - private val type: JsonValue, - private val maxSelections: JsonField, - private val minSelections: JsonField, - private val vocabulary: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("instruction") - @ExcludeMissing - instruction: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonValue = JsonMissing.of(), - @JsonProperty("max_selections") - @ExcludeMissing - maxSelections: JsonField = JsonMissing.of(), - @JsonProperty("min_selections") - @ExcludeMissing - minSelections: JsonField = JsonMissing.of(), - @JsonProperty("vocabulary") - @ExcludeMissing - vocabulary: JsonField> = JsonMissing.of(), - ) : this( - instruction, - type, - maxSelections, - minSelections, - vocabulary, - mutableMapOf(), - ) - - /** - * The question or instruction for the AI to analyze the image. - * - * @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 instruction(): String = instruction.getRequired("instruction") - - /** - * Task type that analyzes the image and adds matching tags from a - * vocabulary. - * - * Expected to always return the following: - * ```java - * JsonValue.from("select_tags") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Maximum number of tags to select from the vocabulary. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun maxSelections(): Optional = - maxSelections.getOptional("max_selections") - - /** - * Minimum number of tags to select from the vocabulary. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun minSelections(): Optional = - minSelections.getOptional("min_selections") - - /** - * Array of possible tag values. The combined length of all strings must not - * exceed 500 characters, and values cannot include the `%` character. When - * providing large vocabularies (more than 30 items), the AI may not follow - * the list strictly. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun vocabulary(): Optional> = - vocabulary.getOptional("vocabulary") - - /** - * Returns the raw JSON value of [instruction]. - * - * Unlike [instruction], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("instruction") - @ExcludeMissing - fun _instruction(): JsonField = instruction - - /** - * Returns the raw JSON value of [maxSelections]. - * - * Unlike [maxSelections], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("max_selections") - @ExcludeMissing - fun _maxSelections(): JsonField = maxSelections - - /** - * Returns the raw JSON value of [minSelections]. - * - * Unlike [minSelections], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("min_selections") - @ExcludeMissing - fun _minSelections(): JsonField = minSelections - - /** - * Returns the raw JSON value of [vocabulary]. - * - * Unlike [vocabulary], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("vocabulary") - @ExcludeMissing - fun _vocabulary(): JsonField> = vocabulary - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SelectTags]. - * - * The following fields are required: - * ```java - * .instruction() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SelectTags]. */ - class Builder internal constructor() { - - private var instruction: JsonField? = null - private var type: JsonValue = JsonValue.from("select_tags") - private var maxSelections: JsonField = JsonMissing.of() - private var minSelections: JsonField = JsonMissing.of() - private var vocabulary: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(selectTags: SelectTags) = apply { - instruction = selectTags.instruction - type = selectTags.type - maxSelections = selectTags.maxSelections - minSelections = selectTags.minSelections - vocabulary = selectTags.vocabulary.map { it.toMutableList() } - additionalProperties = - selectTags.additionalProperties.toMutableMap() - } - - /** The question or instruction for the AI to analyze the image. */ - fun instruction(instruction: String) = - instruction(JsonField.of(instruction)) - - /** - * Sets [Builder.instruction] to an arbitrary JSON value. - * - * You should usually call [Builder.instruction] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun instruction(instruction: JsonField) = apply { - this.instruction = instruction - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field - * defaults to the following: - * ```java - * JsonValue.from("select_tags") - * ``` - * - * This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** Maximum number of tags to select from the vocabulary. */ - fun maxSelections(maxSelections: Long) = - maxSelections(JsonField.of(maxSelections)) - - /** - * Sets [Builder.maxSelections] to an arbitrary JSON value. - * - * You should usually call [Builder.maxSelections] with a well-typed - * [Long] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun maxSelections(maxSelections: JsonField) = apply { - this.maxSelections = maxSelections - } - - /** Minimum number of tags to select from the vocabulary. */ - fun minSelections(minSelections: Long) = - minSelections(JsonField.of(minSelections)) - - /** - * Sets [Builder.minSelections] to an arbitrary JSON value. - * - * You should usually call [Builder.minSelections] with a well-typed - * [Long] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun minSelections(minSelections: JsonField) = apply { - this.minSelections = minSelections - } - - /** - * Array of possible tag values. The combined length of all strings must - * not exceed 500 characters, and values cannot include the `%` - * character. When providing large vocabularies (more than 30 items), - * the AI may not follow the list strictly. - */ - fun vocabulary(vocabulary: List) = - vocabulary(JsonField.of(vocabulary)) - - /** - * Sets [Builder.vocabulary] to an arbitrary JSON value. - * - * You should usually call [Builder.vocabulary] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun vocabulary(vocabulary: JsonField>) = apply { - this.vocabulary = vocabulary.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [Builder.vocabulary]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addVocabulary(vocabulary: String) = apply { - this.vocabulary = - (this.vocabulary ?: JsonField.of(mutableListOf())).also { - checkKnown("vocabulary", it).add(vocabulary) - } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SelectTags]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .instruction() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SelectTags = - SelectTags( - checkRequired("instruction", instruction), - type, - maxSelections, - minSelections, - (vocabulary ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SelectTags = apply { - if (validated) { - return@apply - } - - instruction() - _type().let { - if (it != JsonValue.from("select_tags")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - maxSelections() - minSelections() - vocabulary() - 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 (instruction.asKnown().isPresent) 1 else 0) + - type.let { if (it == JsonValue.from("select_tags")) 1 else 0 } + - (if (maxSelections.asKnown().isPresent) 1 else 0) + - (if (minSelections.asKnown().isPresent) 1 else 0) + - (vocabulary.asKnown().getOrNull()?.size ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SelectTags && - instruction == other.instruction && - type == other.type && - maxSelections == other.maxSelections && - minSelections == other.minSelections && - vocabulary == other.vocabulary && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - instruction, - type, - maxSelections, - minSelections, - vocabulary, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SelectTags{instruction=$instruction, type=$type, maxSelections=$maxSelections, minSelections=$minSelections, vocabulary=$vocabulary, additionalProperties=$additionalProperties}" - } - - class SelectMetadata - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val field: JsonField, - private val instruction: JsonField, - private val type: JsonValue, - private val maxSelections: JsonField, - private val minSelections: JsonField, - private val vocabulary: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("field") - @ExcludeMissing - field: JsonField = JsonMissing.of(), - @JsonProperty("instruction") - @ExcludeMissing - instruction: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonValue = JsonMissing.of(), - @JsonProperty("max_selections") - @ExcludeMissing - maxSelections: JsonField = JsonMissing.of(), - @JsonProperty("min_selections") - @ExcludeMissing - minSelections: JsonField = JsonMissing.of(), - @JsonProperty("vocabulary") - @ExcludeMissing - vocabulary: JsonField> = JsonMissing.of(), - ) : this( - field, - instruction, - type, - maxSelections, - minSelections, - vocabulary, - mutableMapOf(), - ) - - /** - * Name of the custom metadata field to set. The field must exist in 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 field(): String = field.getRequired("field") - - /** - * The question or instruction for the AI to analyze the image. - * - * @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 instruction(): String = instruction.getRequired("instruction") - - /** - * Task type that analyzes the image and sets a custom metadata field value - * from a vocabulary. - * - * Expected to always return the following: - * ```java - * JsonValue.from("select_metadata") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Maximum number of values to select from the vocabulary. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun maxSelections(): Optional = - maxSelections.getOptional("max_selections") - - /** - * Minimum number of values to select from the vocabulary. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun minSelections(): Optional = - minSelections.getOptional("min_selections") - - /** - * An array of possible values matching the custom metadata field type. If - * not provided for SingleSelect or MultiSelect field types, all values from - * the custom metadata field definition will be used. When providing large - * vocabularies (above 30 items), the AI may not strictly adhere to the - * list. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun vocabulary(): Optional> = - vocabulary.getOptional("vocabulary") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("field") - @ExcludeMissing - fun _field(): JsonField = field - - /** - * Returns the raw JSON value of [instruction]. - * - * Unlike [instruction], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("instruction") - @ExcludeMissing - fun _instruction(): JsonField = instruction - - /** - * Returns the raw JSON value of [maxSelections]. - * - * Unlike [maxSelections], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("max_selections") - @ExcludeMissing - fun _maxSelections(): JsonField = maxSelections - - /** - * Returns the raw JSON value of [minSelections]. - * - * Unlike [minSelections], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("min_selections") - @ExcludeMissing - fun _minSelections(): JsonField = minSelections - - /** - * Returns the raw JSON value of [vocabulary]. - * - * Unlike [vocabulary], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("vocabulary") - @ExcludeMissing - fun _vocabulary(): JsonField> = vocabulary - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SelectMetadata]. - * - * The following fields are required: - * ```java - * .field() - * .instruction() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SelectMetadata]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var instruction: JsonField? = null - private var type: JsonValue = JsonValue.from("select_metadata") - private var maxSelections: JsonField = JsonMissing.of() - private var minSelections: JsonField = JsonMissing.of() - private var vocabulary: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(selectMetadata: SelectMetadata) = apply { - field = selectMetadata.field - instruction = selectMetadata.instruction - type = selectMetadata.type - maxSelections = selectMetadata.maxSelections - minSelections = selectMetadata.minSelections - vocabulary = selectMetadata.vocabulary.map { it.toMutableList() } - additionalProperties = - selectMetadata.additionalProperties.toMutableMap() - } - - /** - * Name of the custom metadata field to set. The field must exist in - * your account. - */ - fun field(field: String) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { this.field = field } - - /** The question or instruction for the AI to analyze the image. */ - fun instruction(instruction: String) = - instruction(JsonField.of(instruction)) - - /** - * Sets [Builder.instruction] to an arbitrary JSON value. - * - * You should usually call [Builder.instruction] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun instruction(instruction: JsonField) = apply { - this.instruction = instruction - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field - * defaults to the following: - * ```java - * JsonValue.from("select_metadata") - * ``` - * - * This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** Maximum number of values to select from the vocabulary. */ - fun maxSelections(maxSelections: Long) = - maxSelections(JsonField.of(maxSelections)) - - /** - * Sets [Builder.maxSelections] to an arbitrary JSON value. - * - * You should usually call [Builder.maxSelections] with a well-typed - * [Long] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun maxSelections(maxSelections: JsonField) = apply { - this.maxSelections = maxSelections - } - - /** Minimum number of values to select from the vocabulary. */ - fun minSelections(minSelections: Long) = - minSelections(JsonField.of(minSelections)) - - /** - * Sets [Builder.minSelections] to an arbitrary JSON value. - * - * You should usually call [Builder.minSelections] with a well-typed - * [Long] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun minSelections(minSelections: JsonField) = apply { - this.minSelections = minSelections - } - - /** - * An array of possible values matching the custom metadata field type. - * If not provided for SingleSelect or MultiSelect field types, all - * values from the custom metadata field definition will be used. When - * providing large vocabularies (above 30 items), the AI may not - * strictly adhere to the list. - */ - fun vocabulary(vocabulary: List) = - vocabulary(JsonField.of(vocabulary)) - - /** - * Sets [Builder.vocabulary] to an arbitrary JSON value. - * - * You should usually call [Builder.vocabulary] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun vocabulary(vocabulary: JsonField>) = apply { - this.vocabulary = vocabulary.map { it.toMutableList() } - } - - /** - * Adds a single [Vocabulary] to [Builder.vocabulary]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addVocabulary(vocabulary: Vocabulary) = apply { - this.vocabulary = - (this.vocabulary ?: JsonField.of(mutableListOf())).also { - checkKnown("vocabulary", it).add(vocabulary) - } - } - - /** - * Alias for calling [addVocabulary] with `Vocabulary.ofString(string)`. - */ - fun addVocabulary(string: String) = - addVocabulary(Vocabulary.ofString(string)) - - /** - * Alias for calling [addVocabulary] with `Vocabulary.ofNumber(number)`. - */ - fun addVocabulary(number: Double) = - addVocabulary(Vocabulary.ofNumber(number)) - - /** Alias for calling [addVocabulary] with `Vocabulary.ofBool(bool)`. */ - fun addVocabulary(bool: Boolean) = - addVocabulary(Vocabulary.ofBool(bool)) - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SelectMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .field() - * .instruction() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SelectMetadata = - SelectMetadata( - checkRequired("field", field), - checkRequired("instruction", instruction), - type, - maxSelections, - minSelections, - (vocabulary ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SelectMetadata = apply { - if (validated) { - return@apply - } - - field() - instruction() - _type().let { - if (it != JsonValue.from("select_metadata")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - maxSelections() - minSelections() - vocabulary().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (field.asKnown().isPresent) 1 else 0) + - (if (instruction.asKnown().isPresent) 1 else 0) + - type.let { if (it == JsonValue.from("select_metadata")) 1 else 0 } + - (if (maxSelections.asKnown().isPresent) 1 else 0) + - (if (minSelections.asKnown().isPresent) 1 else 0) + - (vocabulary.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) - - @JsonDeserialize(using = Vocabulary.Deserializer::class) - @JsonSerialize(using = Vocabulary.Serializer::class) - class Vocabulary - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Vocabulary = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} - } - ) - 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 = - accept( - object : Visitor { - override fun visitString(string: String) = 1 - - override fun visitNumber(number: Double) = 1 - - override fun visitBool(bool: Boolean) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Vocabulary && - string == other.string && - number == other.number && - bool == other.bool - } - - override fun hashCode(): Int = Objects.hash(string, number, bool) - - override fun toString(): String = - when { - string != null -> "Vocabulary{string=$string}" - number != null -> "Vocabulary{number=$number}" - bool != null -> "Vocabulary{bool=$bool}" - _json != null -> "Vocabulary{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Vocabulary") - } - - companion object { - - @JvmStatic - fun ofString(string: String) = Vocabulary(string = string) - - @JvmStatic - fun ofNumber(number: Double) = Vocabulary(number = number) - - @JvmStatic fun ofBool(bool: Boolean) = Vocabulary(bool = bool) - } - - /** - * An interface that defines how to map each variant of [Vocabulary] to - * a value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - /** - * Maps an unknown variant of [Vocabulary] to a value of type [T]. - * - * An instance of [Vocabulary] can contain an unknown variant if it - * was deserialized from data that doesn't match any known variant. - * For example, if the SDK is on an older version than the API, then - * the API may respond with new variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException("Unknown Vocabulary: $json") - } - } - - internal class Deserializer : - BaseDeserializer(Vocabulary::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Vocabulary { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { Vocabulary(string = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Vocabulary(number = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Vocabulary(bool = it, _json = json) }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely - // incompatible with all the possible variants (e.g. - // deserializing from object). - 0 -> Vocabulary(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, - // then use the first completely valid match, or simply the - // first match if none are completely valid. - else -> - bestMatches.firstOrNull { it.isValid() } - ?: bestMatches.first() - } - } - } - - internal class Serializer : - BaseSerializer(Vocabulary::class) { - - override fun serialize( - value: Vocabulary, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.number != null -> generator.writeObject(value.number) - value.bool != null -> generator.writeObject(value.bool) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Vocabulary") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SelectMetadata && - field == other.field && - instruction == other.instruction && - type == other.type && - maxSelections == other.maxSelections && - minSelections == other.minSelections && - vocabulary == other.vocabulary && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - field, - instruction, - type, - maxSelections, - minSelections, - vocabulary, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SelectMetadata{field=$field, instruction=$instruction, type=$type, maxSelections=$maxSelections, minSelections=$minSelections, vocabulary=$vocabulary, additionalProperties=$additionalProperties}" - } - - class YesNo - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val instruction: JsonField, - private val type: JsonValue, - private val onNo: JsonField, - private val onUnknown: JsonField, - private val onYes: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("instruction") - @ExcludeMissing - instruction: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonValue = JsonMissing.of(), - @JsonProperty("on_no") - @ExcludeMissing - onNo: JsonField = JsonMissing.of(), - @JsonProperty("on_unknown") - @ExcludeMissing - onUnknown: JsonField = JsonMissing.of(), - @JsonProperty("on_yes") - @ExcludeMissing - onYes: JsonField = JsonMissing.of(), - ) : this(instruction, type, onNo, onUnknown, onYes, mutableMapOf()) - - /** - * The yes/no question for the AI to answer about the image. - * - * @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 instruction(): String = instruction.getRequired("instruction") - - /** - * Task type that asks a yes/no question and executes actions based on the - * answer. - * - * Expected to always return the following: - * ```java - * JsonValue.from("yes_no") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the - * server responded with an unexpected value). - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type - - /** - * Actions to execute if the AI answers no. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun onNo(): Optional = onNo.getOptional("on_no") - - /** - * Actions to execute if the AI cannot determine the answer. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun onUnknown(): Optional = onUnknown.getOptional("on_unknown") - - /** - * Actions to execute if the AI answers yes. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun onYes(): Optional = onYes.getOptional("on_yes") - - /** - * Returns the raw JSON value of [instruction]. - * - * Unlike [instruction], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("instruction") - @ExcludeMissing - fun _instruction(): JsonField = instruction - - /** - * Returns the raw JSON value of [onNo]. - * - * Unlike [onNo], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("on_no") @ExcludeMissing fun _onNo(): JsonField = onNo - - /** - * Returns the raw JSON value of [onUnknown]. - * - * Unlike [onUnknown], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("on_unknown") - @ExcludeMissing - fun _onUnknown(): JsonField = onUnknown - - /** - * Returns the raw JSON value of [onYes]. - * - * Unlike [onYes], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("on_yes") - @ExcludeMissing - fun _onYes(): JsonField = onYes - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [YesNo]. - * - * The following fields are required: - * ```java - * .instruction() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [YesNo]. */ - class Builder internal constructor() { - - private var instruction: JsonField? = null - private var type: JsonValue = JsonValue.from("yes_no") - private var onNo: JsonField = JsonMissing.of() - private var onUnknown: JsonField = JsonMissing.of() - private var onYes: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(yesNo: YesNo) = apply { - instruction = yesNo.instruction - type = yesNo.type - onNo = yesNo.onNo - onUnknown = yesNo.onUnknown - onYes = yesNo.onYes - additionalProperties = yesNo.additionalProperties.toMutableMap() - } - - /** The yes/no question for the AI to answer about the image. */ - fun instruction(instruction: String) = - instruction(JsonField.of(instruction)) - - /** - * Sets [Builder.instruction] to an arbitrary JSON value. - * - * You should usually call [Builder.instruction] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun instruction(instruction: JsonField) = apply { - this.instruction = instruction - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field - * defaults to the following: - * ```java - * JsonValue.from("yes_no") - * ``` - * - * This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonValue) = apply { this.type = type } - - /** Actions to execute if the AI answers no. */ - fun onNo(onNo: OnNo) = onNo(JsonField.of(onNo)) - - /** - * Sets [Builder.onNo] to an arbitrary JSON value. - * - * You should usually call [Builder.onNo] with a well-typed [OnNo] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun onNo(onNo: JsonField) = apply { this.onNo = onNo } - - /** Actions to execute if the AI cannot determine the answer. */ - fun onUnknown(onUnknown: OnUnknown) = onUnknown(JsonField.of(onUnknown)) - - /** - * Sets [Builder.onUnknown] to an arbitrary JSON value. - * - * You should usually call [Builder.onUnknown] with a well-typed - * [OnUnknown] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun onUnknown(onUnknown: JsonField) = apply { - this.onUnknown = onUnknown - } - - /** Actions to execute if the AI answers yes. */ - fun onYes(onYes: OnYes) = onYes(JsonField.of(onYes)) - - /** - * Sets [Builder.onYes] to an arbitrary JSON value. - * - * You should usually call [Builder.onYes] with a well-typed [OnYes] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun onYes(onYes: JsonField) = apply { this.onYes = onYes } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [YesNo]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .instruction() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): YesNo = - YesNo( - checkRequired("instruction", instruction), - type, - onNo, - onUnknown, - onYes, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): YesNo = apply { - if (validated) { - return@apply - } - - instruction() - _type().let { - if (it != JsonValue.from("yes_no")) { - throw ImageKitInvalidDataException( - "'type' is invalid, received $it" - ) - } - } - onNo().ifPresent { it.validate() } - onUnknown().ifPresent { it.validate() } - onYes().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (instruction.asKnown().isPresent) 1 else 0) + - type.let { if (it == JsonValue.from("yes_no")) 1 else 0 } + - (onNo.asKnown().getOrNull()?.validity() ?: 0) + - (onUnknown.asKnown().getOrNull()?.validity() ?: 0) + - (onYes.asKnown().getOrNull()?.validity() ?: 0) - - /** Actions to execute if the AI answers no. */ - class OnNo - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val addTags: JsonField>, - private val removeTags: JsonField>, - private val setMetadata: JsonField>, - private val unsetMetadata: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("add_tags") - @ExcludeMissing - addTags: JsonField> = JsonMissing.of(), - @JsonProperty("remove_tags") - @ExcludeMissing - removeTags: JsonField> = JsonMissing.of(), - @JsonProperty("set_metadata") - @ExcludeMissing - setMetadata: JsonField> = JsonMissing.of(), - @JsonProperty("unset_metadata") - @ExcludeMissing - unsetMetadata: JsonField> = JsonMissing.of(), - ) : this( - addTags, - removeTags, - setMetadata, - unsetMetadata, - mutableMapOf(), - ) - - /** - * Array of tag strings to add to the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun addTags(): Optional> = addTags.getOptional("add_tags") - - /** - * Array of tag strings to remove from the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun removeTags(): Optional> = - removeTags.getOptional("remove_tags") - - /** - * Array of custom metadata field updates. - * - * @throws ImageKitInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun setMetadata(): Optional> = - setMetadata.getOptional("set_metadata") - - /** - * Array of custom metadata fields to remove. - * - * @throws ImageKitInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun unsetMetadata(): Optional> = - unsetMetadata.getOptional("unset_metadata") - - /** - * Returns the raw JSON value of [addTags]. - * - * Unlike [addTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("add_tags") - @ExcludeMissing - fun _addTags(): JsonField> = addTags - - /** - * Returns the raw JSON value of [removeTags]. - * - * Unlike [removeTags], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("remove_tags") - @ExcludeMissing - fun _removeTags(): JsonField> = removeTags - - /** - * Returns the raw JSON value of [setMetadata]. - * - * Unlike [setMetadata], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("set_metadata") - @ExcludeMissing - fun _setMetadata(): JsonField> = setMetadata - - /** - * Returns the raw JSON value of [unsetMetadata]. - * - * Unlike [unsetMetadata], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("unset_metadata") - @ExcludeMissing - fun _unsetMetadata(): JsonField> = unsetMetadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [OnNo]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OnNo]. */ - class Builder internal constructor() { - - private var addTags: JsonField>? = null - private var removeTags: JsonField>? = null - private var setMetadata: JsonField>? = null - private var unsetMetadata: JsonField>? = - null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(onNo: OnNo) = apply { - addTags = onNo.addTags.map { it.toMutableList() } - removeTags = onNo.removeTags.map { it.toMutableList() } - setMetadata = onNo.setMetadata.map { it.toMutableList() } - unsetMetadata = onNo.unsetMetadata.map { it.toMutableList() } - additionalProperties = onNo.additionalProperties.toMutableMap() - } - - /** Array of tag strings to add to the asset. */ - fun addTags(addTags: List) = addTags(JsonField.of(addTags)) - - /** - * Sets [Builder.addTags] to an arbitrary JSON value. - * - * You should usually call [Builder.addTags] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun addTags(addTags: JsonField>) = apply { - this.addTags = addTags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [addTags]. - * - * @throws IllegalStateException if the field was previously set to - * a non-list. - */ - fun addAddTag(addTag: String) = apply { - addTags = - (addTags ?: JsonField.of(mutableListOf())).also { - checkKnown("addTags", it).add(addTag) - } - } - - /** Array of tag strings to remove from the asset. */ - fun removeTags(removeTags: List) = - removeTags(JsonField.of(removeTags)) - - /** - * Sets [Builder.removeTags] to an arbitrary JSON value. - * - * You should usually call [Builder.removeTags] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun removeTags(removeTags: JsonField>) = apply { - this.removeTags = removeTags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [removeTags]. - * - * @throws IllegalStateException if the field was previously set to - * a non-list. - */ - fun addRemoveTag(removeTag: String) = apply { - removeTags = - (removeTags ?: JsonField.of(mutableListOf())).also { - checkKnown("removeTags", it).add(removeTag) - } - } - - /** Array of custom metadata field updates. */ - fun setMetadata(setMetadata: List) = - setMetadata(JsonField.of(setMetadata)) - - /** - * Sets [Builder.setMetadata] to an arbitrary JSON value. - * - * You should usually call [Builder.setMetadata] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun setMetadata(setMetadata: JsonField>) = apply { - this.setMetadata = setMetadata.map { it.toMutableList() } - } - - /** - * Adds a single [SetMetadata] to [Builder.setMetadata]. - * - * @throws IllegalStateException if the field was previously set to - * a non-list. - */ - fun addSetMetadata(setMetadata: SetMetadata) = apply { - this.setMetadata = - (this.setMetadata ?: JsonField.of(mutableListOf())).also { - checkKnown("setMetadata", it).add(setMetadata) - } - } - - /** Array of custom metadata fields to remove. */ - fun unsetMetadata(unsetMetadata: List) = - unsetMetadata(JsonField.of(unsetMetadata)) - - /** - * Sets [Builder.unsetMetadata] to an arbitrary JSON value. - * - * You should usually call [Builder.unsetMetadata] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun unsetMetadata(unsetMetadata: JsonField>) = - apply { - this.unsetMetadata = - unsetMetadata.map { it.toMutableList() } - } - - /** - * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. - * - * @throws IllegalStateException if the field was previously set to - * a non-list. - */ - fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { - this.unsetMetadata = - (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { - checkKnown("unsetMetadata", it).add(unsetMetadata) - } - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [OnNo]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): OnNo = - OnNo( - (addTags ?: JsonMissing.of()).map { it.toImmutable() }, - (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, - (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, - (unsetMetadata ?: JsonMissing.of()).map { - it.toImmutable() - }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): OnNo = apply { - if (validated) { - return@apply - } - - addTags() - removeTags() - setMetadata().ifPresent { it.forEach { it.validate() } } - unsetMetadata().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in - * this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (addTags.asKnown().getOrNull()?.size ?: 0) + - (removeTags.asKnown().getOrNull()?.size ?: 0) + - (setMetadata.asKnown().getOrNull()?.sumOf { - it.validity().toInt() - } ?: 0) + - (unsetMetadata.asKnown().getOrNull()?.sumOf { - it.validity().toInt() - } ?: 0) - - class SetMetadata - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val field: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("field") - @ExcludeMissing - field: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - value: JsonField = JsonMissing.of(), - ) : this(field, value, mutableMapOf()) - - /** - * Name of the custom metadata field to set. - * - * @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 field(): String = field.getRequired("field") - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - * - * @throws ImageKitInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the - * server responded with an unexpected value). - */ - fun value(): Value = value.getRequired("value") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("field") - @ExcludeMissing - fun _field(): JsonField = field - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SetMetadata]. - * - * The following fields are required: - * ```java - * .field() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SetMetadata]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(setMetadata: SetMetadata) = apply { - field = setMetadata.field - value = setMetadata.value - additionalProperties = - setMetadata.additionalProperties.toMutableMap() - } - - /** Name of the custom metadata field to set. */ - fun field(field: String) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed - * [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { - this.field = field - } - - /** - * Value to set for the custom metadata field. The value type - * should match the custom metadata field type. - */ - fun value(value: Value) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed - * [Value] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun value(value: JsonField) = apply { - this.value = value - } - - /** Alias for calling [value] with `Value.ofString(string)`. */ - fun value(string: String) = value(Value.ofString(string)) - - /** Alias for calling [value] with `Value.ofNumber(number)`. */ - fun value(number: Double) = value(Value.ofNumber(number)) - - /** Alias for calling [value] with `Value.ofBool(bool)`. */ - fun value(bool: Boolean) = value(Value.ofBool(bool)) - - /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ - fun valueOfMixed( - mixed: List - ) = value(Value.ofMixed(mixed)) - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SetMetadata]. - * - * Further updates to this [Builder] will not mutate the - * returned instance. - * - * The following fields are required: - * ```java - * .field() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SetMetadata = - SetMetadata( - checkRequired("field", field), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SetMetadata = apply { - if (validated) { - return@apply - } - - field() - value().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in - * this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (field.asKnown().isPresent) 1 else 0) + - (value.asKnown().getOrNull()?.validity() ?: 0) - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - */ - @JsonDeserialize(using = Value.Deserializer::class) - @JsonSerialize(using = Value.Serializer::class) - class Value - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val mixed: List? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun mixed(): Optional> = - Optional.ofNullable(mixed) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun isMixed(): Boolean = mixed != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun asMixed(): List = - mixed.getOrThrow("mixed") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - mixed != null -> visitor.visitMixed(mixed) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Value = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} - - override fun visitMixed( - mixed: List - ) { - mixed.forEach { it.validate() } - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are - * contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitString(string: String) = 1 - - override fun visitNumber(number: Double) = 1 - - override fun visitBool(bool: Boolean) = 1 - - override fun visitMixed( - mixed: List - ) = mixed.sumOf { it.validity().toInt() } - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Value && - string == other.string && - number == other.number && - bool == other.bool && - mixed == other.mixed - } - - override fun hashCode(): Int = - Objects.hash(string, number, bool, mixed) - - override fun toString(): String = - when { - string != null -> "Value{string=$string}" - number != null -> "Value{number=$number}" - bool != null -> "Value{bool=$bool}" - mixed != null -> "Value{mixed=$mixed}" - _json != null -> "Value{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Value") - } - - companion object { - - @JvmStatic - fun ofString(string: String) = Value(string = string) - - @JvmStatic - fun ofNumber(number: Double) = Value(number = number) - - @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) - - @JvmStatic - fun ofMixed(mixed: List) = - Value(mixed = mixed.toImmutable()) - } - - /** - * An interface that defines how to map each variant of [Value] - * to a value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - fun visitMixed( - mixed: List - ): T - - /** - * Maps an unknown variant of [Value] to a value of type - * [T]. - * - * An instance of [Value] can contain an unknown variant if - * it was deserialized from data that doesn't match any - * known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException( - "Unknown Value: $json" - ) - } - } - - internal class Deserializer : - BaseDeserializer(Value::class) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): Value { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Value(string = it, _json = json) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Value(number = it, _json = json) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Value(bool = it, _json = json) - }, - tryDeserialize( - node, - jacksonTypeRef< - List< - UnnamedSchemaWithArrayParent5 - > - >(), - ) - ?.let { - Value(mixed = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is - // completely incompatible with all the possible - // variants (e.g. deserializing from object). - 0 -> Value(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest - // validity, then use the first completely valid - // match, or simply the first match if none are - // completely valid. - else -> - bestMatches.firstOrNull { it.isValid() } - ?: bestMatches.first() - } - } - } - - internal class Serializer : - BaseSerializer(Value::class) { - - override fun serialize( - value: Value, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> - generator.writeObject(value.string) - value.number != null -> - generator.writeObject(value.number) - value.bool != null -> - generator.writeObject(value.bool) - value.mixed != null -> - generator.writeObject(value.mixed) - value._json != null -> - generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Value") - } - } - } - - @JsonDeserialize( - using = UnnamedSchemaWithArrayParent5.Deserializer::class - ) - @JsonSerialize( - using = UnnamedSchemaWithArrayParent5.Serializer::class - ) - class UnnamedSchemaWithArrayParent5 - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun _json(): Optional = - Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): UnnamedSchemaWithArrayParent5 = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} - } - ) - 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 = - accept( - object : Visitor { - override fun visitString(string: String) = 1 - - override fun visitNumber(number: Double) = 1 - - override fun visitBool(bool: Boolean) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnnamedSchemaWithArrayParent5 && - string == other.string && - number == other.number && - bool == other.bool - } - - override fun hashCode(): Int = - Objects.hash(string, number, bool) - - override fun toString(): String = - when { - string != null -> - "UnnamedSchemaWithArrayParent5{string=$string}" - number != null -> - "UnnamedSchemaWithArrayParent5{number=$number}" - bool != null -> - "UnnamedSchemaWithArrayParent5{bool=$bool}" - _json != null -> - "UnnamedSchemaWithArrayParent5{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent5" - ) - } - - companion object { - - @JvmStatic - fun ofString(string: String) = - UnnamedSchemaWithArrayParent5(string = string) - - @JvmStatic - fun ofNumber(number: Double) = - UnnamedSchemaWithArrayParent5(number = number) - - @JvmStatic - fun ofBool(bool: Boolean) = - UnnamedSchemaWithArrayParent5(bool = bool) - } - - /** - * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent5] to a value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - /** - * Maps an unknown variant of - * [UnnamedSchemaWithArrayParent5] to a value of type - * [T]. - * - * An instance of [UnnamedSchemaWithArrayParent5] can - * contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For - * example, if the SDK is on an older version than the - * API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent5: $json" - ) - } - } - - internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent5::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): UnnamedSchemaWithArrayParent5 { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - UnnamedSchemaWithArrayParent5( - string = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - UnnamedSchemaWithArrayParent5( - number = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - UnnamedSchemaWithArrayParent5( - bool = it, - _json = json, - ) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing - // is completely incompatible with all the - // possible variants (e.g. deserializing from - // object). - 0 -> UnnamedSchemaWithArrayParent5(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the - // highest validity, then use the first - // completely valid match, or simply the first - // match if none are completely valid. - else -> - bestMatches.firstOrNull { it.isValid() } - ?: bestMatches.first() - } - } - } - - internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent5::class - ) { - - override fun serialize( - value: UnnamedSchemaWithArrayParent5, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> - generator.writeObject(value.string) - value.number != null -> - generator.writeObject(value.number) - value.bool != null -> - generator.writeObject(value.bool) - value._json != null -> - generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent5" - ) - } - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SetMetadata && - field == other.field && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, value, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" - } - - class UnsetMetadata - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val field: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("field") - @ExcludeMissing - field: JsonField = JsonMissing.of() - ) : this(field, mutableMapOf()) - - /** - * Name of the custom metadata field to remove. - * - * @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 field(): String = field.getRequired("field") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("field") - @ExcludeMissing - fun _field(): JsonField = field - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [UnsetMetadata]. - * - * The following fields are required: - * ```java - * .field() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnsetMetadata]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unsetMetadata: UnsetMetadata) = apply { - field = unsetMetadata.field - additionalProperties = - unsetMetadata.additionalProperties.toMutableMap() - } - - /** Name of the custom metadata field to remove. */ - fun field(field: String) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed - * [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { - this.field = field - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnsetMetadata]. - * - * Further updates to this [Builder] will not mutate the - * returned instance. - * - * The following fields are required: - * ```java - * .field() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UnsetMetadata = - UnsetMetadata( - checkRequired("field", field), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnsetMetadata = apply { - if (validated) { - return@apply - } - - field() - 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 (field.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnsetMetadata && - field == other.field && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OnNo && - addTags == other.addTags && - removeTags == other.removeTags && - setMetadata == other.setMetadata && - unsetMetadata == other.unsetMetadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - addTags, - removeTags, - setMetadata, - unsetMetadata, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OnNo{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" - } - - /** Actions to execute if the AI cannot determine the answer. */ - class OnUnknown - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val addTags: JsonField>, - private val removeTags: JsonField>, - private val setMetadata: JsonField>, - private val unsetMetadata: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("add_tags") - @ExcludeMissing - addTags: JsonField> = JsonMissing.of(), - @JsonProperty("remove_tags") - @ExcludeMissing - removeTags: JsonField> = JsonMissing.of(), - @JsonProperty("set_metadata") - @ExcludeMissing - setMetadata: JsonField> = JsonMissing.of(), - @JsonProperty("unset_metadata") - @ExcludeMissing - unsetMetadata: JsonField> = JsonMissing.of(), - ) : this( - addTags, - removeTags, - setMetadata, - unsetMetadata, - mutableMapOf(), - ) - - /** - * Array of tag strings to add to the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun addTags(): Optional> = addTags.getOptional("add_tags") - - /** - * Array of tag strings to remove from the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun removeTags(): Optional> = - removeTags.getOptional("remove_tags") - - /** - * Array of custom metadata field updates. - * - * @throws ImageKitInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun setMetadata(): Optional> = - setMetadata.getOptional("set_metadata") - - /** - * Array of custom metadata fields to remove. - * - * @throws ImageKitInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun unsetMetadata(): Optional> = - unsetMetadata.getOptional("unset_metadata") - - /** - * Returns the raw JSON value of [addTags]. - * - * Unlike [addTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("add_tags") - @ExcludeMissing - fun _addTags(): JsonField> = addTags - - /** - * Returns the raw JSON value of [removeTags]. - * - * Unlike [removeTags], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("remove_tags") - @ExcludeMissing - fun _removeTags(): JsonField> = removeTags - - /** - * Returns the raw JSON value of [setMetadata]. - * - * Unlike [setMetadata], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("set_metadata") - @ExcludeMissing - fun _setMetadata(): JsonField> = setMetadata - - /** - * Returns the raw JSON value of [unsetMetadata]. - * - * Unlike [unsetMetadata], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("unset_metadata") - @ExcludeMissing - fun _unsetMetadata(): JsonField> = unsetMetadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [OnUnknown]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OnUnknown]. */ - class Builder internal constructor() { - - private var addTags: JsonField>? = null - private var removeTags: JsonField>? = null - private var setMetadata: JsonField>? = null - private var unsetMetadata: JsonField>? = - null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(onUnknown: OnUnknown) = apply { - addTags = onUnknown.addTags.map { it.toMutableList() } - removeTags = onUnknown.removeTags.map { it.toMutableList() } - setMetadata = onUnknown.setMetadata.map { it.toMutableList() } - unsetMetadata = - onUnknown.unsetMetadata.map { it.toMutableList() } - additionalProperties = - onUnknown.additionalProperties.toMutableMap() - } - - /** Array of tag strings to add to the asset. */ - fun addTags(addTags: List) = addTags(JsonField.of(addTags)) - - /** - * Sets [Builder.addTags] to an arbitrary JSON value. - * - * You should usually call [Builder.addTags] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun addTags(addTags: JsonField>) = apply { - this.addTags = addTags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [addTags]. - * - * @throws IllegalStateException if the field was previously set to - * a non-list. - */ - fun addAddTag(addTag: String) = apply { - addTags = - (addTags ?: JsonField.of(mutableListOf())).also { - checkKnown("addTags", it).add(addTag) - } - } - - /** Array of tag strings to remove from the asset. */ - fun removeTags(removeTags: List) = - removeTags(JsonField.of(removeTags)) - - /** - * Sets [Builder.removeTags] to an arbitrary JSON value. - * - * You should usually call [Builder.removeTags] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun removeTags(removeTags: JsonField>) = apply { - this.removeTags = removeTags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [removeTags]. - * - * @throws IllegalStateException if the field was previously set to - * a non-list. - */ - fun addRemoveTag(removeTag: String) = apply { - removeTags = - (removeTags ?: JsonField.of(mutableListOf())).also { - checkKnown("removeTags", it).add(removeTag) - } - } - - /** Array of custom metadata field updates. */ - fun setMetadata(setMetadata: List) = - setMetadata(JsonField.of(setMetadata)) - - /** - * Sets [Builder.setMetadata] to an arbitrary JSON value. - * - * You should usually call [Builder.setMetadata] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun setMetadata(setMetadata: JsonField>) = apply { - this.setMetadata = setMetadata.map { it.toMutableList() } - } - - /** - * Adds a single [SetMetadata] to [Builder.setMetadata]. - * - * @throws IllegalStateException if the field was previously set to - * a non-list. - */ - fun addSetMetadata(setMetadata: SetMetadata) = apply { - this.setMetadata = - (this.setMetadata ?: JsonField.of(mutableListOf())).also { - checkKnown("setMetadata", it).add(setMetadata) - } - } - - /** Array of custom metadata fields to remove. */ - fun unsetMetadata(unsetMetadata: List) = - unsetMetadata(JsonField.of(unsetMetadata)) - - /** - * Sets [Builder.unsetMetadata] to an arbitrary JSON value. - * - * You should usually call [Builder.unsetMetadata] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun unsetMetadata(unsetMetadata: JsonField>) = - apply { - this.unsetMetadata = - unsetMetadata.map { it.toMutableList() } - } - - /** - * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. - * - * @throws IllegalStateException if the field was previously set to - * a non-list. - */ - fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { - this.unsetMetadata = - (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { - checkKnown("unsetMetadata", it).add(unsetMetadata) - } - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [OnUnknown]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): OnUnknown = - OnUnknown( - (addTags ?: JsonMissing.of()).map { it.toImmutable() }, - (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, - (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, - (unsetMetadata ?: JsonMissing.of()).map { - it.toImmutable() - }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): OnUnknown = apply { - if (validated) { - return@apply - } - - addTags() - removeTags() - setMetadata().ifPresent { it.forEach { it.validate() } } - unsetMetadata().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in - * this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (addTags.asKnown().getOrNull()?.size ?: 0) + - (removeTags.asKnown().getOrNull()?.size ?: 0) + - (setMetadata.asKnown().getOrNull()?.sumOf { - it.validity().toInt() - } ?: 0) + - (unsetMetadata.asKnown().getOrNull()?.sumOf { - it.validity().toInt() - } ?: 0) - - class SetMetadata - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val field: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("field") - @ExcludeMissing - field: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - value: JsonField = JsonMissing.of(), - ) : this(field, value, mutableMapOf()) - - /** - * Name of the custom metadata field to set. - * - * @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 field(): String = field.getRequired("field") - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - * - * @throws ImageKitInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the - * server responded with an unexpected value). - */ - fun value(): Value = value.getRequired("value") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("field") - @ExcludeMissing - fun _field(): JsonField = field - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SetMetadata]. - * - * The following fields are required: - * ```java - * .field() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SetMetadata]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(setMetadata: SetMetadata) = apply { - field = setMetadata.field - value = setMetadata.value - additionalProperties = - setMetadata.additionalProperties.toMutableMap() - } - - /** Name of the custom metadata field to set. */ - fun field(field: String) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed - * [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { - this.field = field - } - - /** - * Value to set for the custom metadata field. The value type - * should match the custom metadata field type. - */ - fun value(value: Value) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed - * [Value] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun value(value: JsonField) = apply { - this.value = value - } - - /** Alias for calling [value] with `Value.ofString(string)`. */ - fun value(string: String) = value(Value.ofString(string)) - - /** Alias for calling [value] with `Value.ofNumber(number)`. */ - fun value(number: Double) = value(Value.ofNumber(number)) - - /** Alias for calling [value] with `Value.ofBool(bool)`. */ - fun value(bool: Boolean) = value(Value.ofBool(bool)) - - /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ - fun valueOfMixed( - mixed: List - ) = value(Value.ofMixed(mixed)) - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SetMetadata]. - * - * Further updates to this [Builder] will not mutate the - * returned instance. - * - * The following fields are required: - * ```java - * .field() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SetMetadata = - SetMetadata( - checkRequired("field", field), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SetMetadata = apply { - if (validated) { - return@apply - } - - field() - value().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in - * this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (field.asKnown().isPresent) 1 else 0) + - (value.asKnown().getOrNull()?.validity() ?: 0) - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - */ - @JsonDeserialize(using = Value.Deserializer::class) - @JsonSerialize(using = Value.Serializer::class) - class Value - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val mixed: List? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun mixed(): Optional> = - Optional.ofNullable(mixed) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun isMixed(): Boolean = mixed != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun asMixed(): List = - mixed.getOrThrow("mixed") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - mixed != null -> visitor.visitMixed(mixed) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Value = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} - - override fun visitMixed( - mixed: List - ) { - mixed.forEach { it.validate() } - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are - * contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitString(string: String) = 1 - - override fun visitNumber(number: Double) = 1 - - override fun visitBool(bool: Boolean) = 1 - - override fun visitMixed( - mixed: List - ) = mixed.sumOf { it.validity().toInt() } - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Value && - string == other.string && - number == other.number && - bool == other.bool && - mixed == other.mixed - } - - override fun hashCode(): Int = - Objects.hash(string, number, bool, mixed) - - override fun toString(): String = - when { - string != null -> "Value{string=$string}" - number != null -> "Value{number=$number}" - bool != null -> "Value{bool=$bool}" - mixed != null -> "Value{mixed=$mixed}" - _json != null -> "Value{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Value") - } - - companion object { - - @JvmStatic - fun ofString(string: String) = Value(string = string) - - @JvmStatic - fun ofNumber(number: Double) = Value(number = number) - - @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) - - @JvmStatic - fun ofMixed(mixed: List) = - Value(mixed = mixed.toImmutable()) - } - - /** - * An interface that defines how to map each variant of [Value] - * to a value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - fun visitMixed( - mixed: List - ): T - - /** - * Maps an unknown variant of [Value] to a value of type - * [T]. - * - * An instance of [Value] can contain an unknown variant if - * it was deserialized from data that doesn't match any - * known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException( - "Unknown Value: $json" - ) - } - } - - internal class Deserializer : - BaseDeserializer(Value::class) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): Value { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Value(string = it, _json = json) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Value(number = it, _json = json) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Value(bool = it, _json = json) - }, - tryDeserialize( - node, - jacksonTypeRef< - List< - UnnamedSchemaWithArrayParent6 - > - >(), - ) - ?.let { - Value(mixed = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is - // completely incompatible with all the possible - // variants (e.g. deserializing from object). - 0 -> Value(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest - // validity, then use the first completely valid - // match, or simply the first match if none are - // completely valid. - else -> - bestMatches.firstOrNull { it.isValid() } - ?: bestMatches.first() - } - } - } - - internal class Serializer : - BaseSerializer(Value::class) { - - override fun serialize( - value: Value, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> - generator.writeObject(value.string) - value.number != null -> - generator.writeObject(value.number) - value.bool != null -> - generator.writeObject(value.bool) - value.mixed != null -> - generator.writeObject(value.mixed) - value._json != null -> - generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Value") - } - } - } - - @JsonDeserialize( - using = UnnamedSchemaWithArrayParent6.Deserializer::class - ) - @JsonSerialize( - using = UnnamedSchemaWithArrayParent6.Serializer::class - ) - class UnnamedSchemaWithArrayParent6 - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun _json(): Optional = - Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): UnnamedSchemaWithArrayParent6 = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} - } - ) - 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 = - accept( - object : Visitor { - override fun visitString(string: String) = 1 - - override fun visitNumber(number: Double) = 1 - - override fun visitBool(bool: Boolean) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnnamedSchemaWithArrayParent6 && - string == other.string && - number == other.number && - bool == other.bool - } - - override fun hashCode(): Int = - Objects.hash(string, number, bool) - - override fun toString(): String = - when { - string != null -> - "UnnamedSchemaWithArrayParent6{string=$string}" - number != null -> - "UnnamedSchemaWithArrayParent6{number=$number}" - bool != null -> - "UnnamedSchemaWithArrayParent6{bool=$bool}" - _json != null -> - "UnnamedSchemaWithArrayParent6{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent6" - ) - } - - companion object { - - @JvmStatic - fun ofString(string: String) = - UnnamedSchemaWithArrayParent6(string = string) - - @JvmStatic - fun ofNumber(number: Double) = - UnnamedSchemaWithArrayParent6(number = number) - - @JvmStatic - fun ofBool(bool: Boolean) = - UnnamedSchemaWithArrayParent6(bool = bool) - } - - /** - * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent6] to a value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - /** - * Maps an unknown variant of - * [UnnamedSchemaWithArrayParent6] to a value of type - * [T]. - * - * An instance of [UnnamedSchemaWithArrayParent6] can - * contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For - * example, if the SDK is on an older version than the - * API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent6: $json" - ) - } - } - - internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent6::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): UnnamedSchemaWithArrayParent6 { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - UnnamedSchemaWithArrayParent6( - string = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - UnnamedSchemaWithArrayParent6( - number = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - UnnamedSchemaWithArrayParent6( - bool = it, - _json = json, - ) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing - // is completely incompatible with all the - // possible variants (e.g. deserializing from - // object). - 0 -> UnnamedSchemaWithArrayParent6(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the - // highest validity, then use the first - // completely valid match, or simply the first - // match if none are completely valid. - else -> - bestMatches.firstOrNull { it.isValid() } - ?: bestMatches.first() - } - } - } - - internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent6::class - ) { - - override fun serialize( - value: UnnamedSchemaWithArrayParent6, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> - generator.writeObject(value.string) - value.number != null -> - generator.writeObject(value.number) - value.bool != null -> - generator.writeObject(value.bool) - value._json != null -> - generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent6" - ) - } - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SetMetadata && - field == other.field && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, value, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" - } - - class UnsetMetadata - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val field: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("field") - @ExcludeMissing - field: JsonField = JsonMissing.of() - ) : this(field, mutableMapOf()) - - /** - * Name of the custom metadata field to remove. - * - * @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 field(): String = field.getRequired("field") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("field") - @ExcludeMissing - fun _field(): JsonField = field - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [UnsetMetadata]. - * - * The following fields are required: - * ```java - * .field() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnsetMetadata]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unsetMetadata: UnsetMetadata) = apply { - field = unsetMetadata.field - additionalProperties = - unsetMetadata.additionalProperties.toMutableMap() - } - - /** Name of the custom metadata field to remove. */ - fun field(field: String) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed - * [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { - this.field = field - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnsetMetadata]. - * - * Further updates to this [Builder] will not mutate the - * returned instance. - * - * The following fields are required: - * ```java - * .field() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UnsetMetadata = - UnsetMetadata( - checkRequired("field", field), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnsetMetadata = apply { - if (validated) { - return@apply - } - - field() - 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 (field.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnsetMetadata && - field == other.field && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OnUnknown && - addTags == other.addTags && - removeTags == other.removeTags && - setMetadata == other.setMetadata && - unsetMetadata == other.unsetMetadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - addTags, - removeTags, - setMetadata, - unsetMetadata, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OnUnknown{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" - } - - /** Actions to execute if the AI answers yes. */ - class OnYes - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val addTags: JsonField>, - private val removeTags: JsonField>, - private val setMetadata: JsonField>, - private val unsetMetadata: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("add_tags") - @ExcludeMissing - addTags: JsonField> = JsonMissing.of(), - @JsonProperty("remove_tags") - @ExcludeMissing - removeTags: JsonField> = JsonMissing.of(), - @JsonProperty("set_metadata") - @ExcludeMissing - setMetadata: JsonField> = JsonMissing.of(), - @JsonProperty("unset_metadata") - @ExcludeMissing - unsetMetadata: JsonField> = JsonMissing.of(), - ) : this( - addTags, - removeTags, - setMetadata, - unsetMetadata, - mutableMapOf(), - ) - - /** - * Array of tag strings to add to the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun addTags(): Optional> = addTags.getOptional("add_tags") - - /** - * Array of tag strings to remove from the asset. - * - * @throws ImageKitInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun removeTags(): Optional> = - removeTags.getOptional("remove_tags") - - /** - * Array of custom metadata field updates. - * - * @throws ImageKitInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun setMetadata(): Optional> = - setMetadata.getOptional("set_metadata") - - /** - * Array of custom metadata fields to remove. - * - * @throws ImageKitInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun unsetMetadata(): Optional> = - unsetMetadata.getOptional("unset_metadata") - - /** - * Returns the raw JSON value of [addTags]. - * - * Unlike [addTags], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("add_tags") - @ExcludeMissing - fun _addTags(): JsonField> = addTags - - /** - * Returns the raw JSON value of [removeTags]. - * - * Unlike [removeTags], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("remove_tags") - @ExcludeMissing - fun _removeTags(): JsonField> = removeTags - - /** - * Returns the raw JSON value of [setMetadata]. - * - * Unlike [setMetadata], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("set_metadata") - @ExcludeMissing - fun _setMetadata(): JsonField> = setMetadata - - /** - * Returns the raw JSON value of [unsetMetadata]. - * - * Unlike [unsetMetadata], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("unset_metadata") - @ExcludeMissing - fun _unsetMetadata(): JsonField> = unsetMetadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [OnYes]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OnYes]. */ - class Builder internal constructor() { - - private var addTags: JsonField>? = null - private var removeTags: JsonField>? = null - private var setMetadata: JsonField>? = null - private var unsetMetadata: JsonField>? = - null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(onYes: OnYes) = apply { - addTags = onYes.addTags.map { it.toMutableList() } - removeTags = onYes.removeTags.map { it.toMutableList() } - setMetadata = onYes.setMetadata.map { it.toMutableList() } - unsetMetadata = onYes.unsetMetadata.map { it.toMutableList() } - additionalProperties = onYes.additionalProperties.toMutableMap() - } - - /** Array of tag strings to add to the asset. */ - fun addTags(addTags: List) = addTags(JsonField.of(addTags)) - - /** - * Sets [Builder.addTags] to an arbitrary JSON value. - * - * You should usually call [Builder.addTags] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun addTags(addTags: JsonField>) = apply { - this.addTags = addTags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [addTags]. - * - * @throws IllegalStateException if the field was previously set to - * a non-list. - */ - fun addAddTag(addTag: String) = apply { - addTags = - (addTags ?: JsonField.of(mutableListOf())).also { - checkKnown("addTags", it).add(addTag) - } - } - - /** Array of tag strings to remove from the asset. */ - fun removeTags(removeTags: List) = - removeTags(JsonField.of(removeTags)) - - /** - * Sets [Builder.removeTags] to an arbitrary JSON value. - * - * You should usually call [Builder.removeTags] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun removeTags(removeTags: JsonField>) = apply { - this.removeTags = removeTags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [removeTags]. - * - * @throws IllegalStateException if the field was previously set to - * a non-list. - */ - fun addRemoveTag(removeTag: String) = apply { - removeTags = - (removeTags ?: JsonField.of(mutableListOf())).also { - checkKnown("removeTags", it).add(removeTag) - } - } - - /** Array of custom metadata field updates. */ - fun setMetadata(setMetadata: List) = - setMetadata(JsonField.of(setMetadata)) - - /** - * Sets [Builder.setMetadata] to an arbitrary JSON value. - * - * You should usually call [Builder.setMetadata] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun setMetadata(setMetadata: JsonField>) = apply { - this.setMetadata = setMetadata.map { it.toMutableList() } - } - - /** - * Adds a single [SetMetadata] to [Builder.setMetadata]. - * - * @throws IllegalStateException if the field was previously set to - * a non-list. - */ - fun addSetMetadata(setMetadata: SetMetadata) = apply { - this.setMetadata = - (this.setMetadata ?: JsonField.of(mutableListOf())).also { - checkKnown("setMetadata", it).add(setMetadata) - } - } - - /** Array of custom metadata fields to remove. */ - fun unsetMetadata(unsetMetadata: List) = - unsetMetadata(JsonField.of(unsetMetadata)) - - /** - * Sets [Builder.unsetMetadata] to an arbitrary JSON value. - * - * You should usually call [Builder.unsetMetadata] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun unsetMetadata(unsetMetadata: JsonField>) = - apply { - this.unsetMetadata = - unsetMetadata.map { it.toMutableList() } - } - - /** - * Adds a single [UnsetMetadata] to [Builder.unsetMetadata]. - * - * @throws IllegalStateException if the field was previously set to - * a non-list. - */ - fun addUnsetMetadata(unsetMetadata: UnsetMetadata) = apply { - this.unsetMetadata = - (this.unsetMetadata ?: JsonField.of(mutableListOf())).also { - checkKnown("unsetMetadata", it).add(unsetMetadata) - } - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [OnYes]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): OnYes = - OnYes( - (addTags ?: JsonMissing.of()).map { it.toImmutable() }, - (removeTags ?: JsonMissing.of()).map { it.toImmutable() }, - (setMetadata ?: JsonMissing.of()).map { it.toImmutable() }, - (unsetMetadata ?: JsonMissing.of()).map { - it.toImmutable() - }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): OnYes = apply { - if (validated) { - return@apply - } - - addTags() - removeTags() - setMetadata().ifPresent { it.forEach { it.validate() } } - unsetMetadata().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in - * this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (addTags.asKnown().getOrNull()?.size ?: 0) + - (removeTags.asKnown().getOrNull()?.size ?: 0) + - (setMetadata.asKnown().getOrNull()?.sumOf { - it.validity().toInt() - } ?: 0) + - (unsetMetadata.asKnown().getOrNull()?.sumOf { - it.validity().toInt() - } ?: 0) - - class SetMetadata - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val field: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("field") - @ExcludeMissing - field: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - value: JsonField = JsonMissing.of(), - ) : this(field, value, mutableMapOf()) - - /** - * Name of the custom metadata field to set. - * - * @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 field(): String = field.getRequired("field") - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - * - * @throws ImageKitInvalidDataException if the JSON field has an - * unexpected type or is unexpectedly missing or null (e.g. if the - * server responded with an unexpected value). - */ - fun value(): Value = value.getRequired("value") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("field") - @ExcludeMissing - fun _field(): JsonField = field - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("value") - @ExcludeMissing - fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SetMetadata]. - * - * The following fields are required: - * ```java - * .field() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SetMetadata]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(setMetadata: SetMetadata) = apply { - field = setMetadata.field - value = setMetadata.value - additionalProperties = - setMetadata.additionalProperties.toMutableMap() - } - - /** Name of the custom metadata field to set. */ - fun field(field: String) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed - * [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { - this.field = field - } - - /** - * Value to set for the custom metadata field. The value type - * should match the custom metadata field type. - */ - fun value(value: Value) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed - * [Value] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun value(value: JsonField) = apply { - this.value = value - } - - /** Alias for calling [value] with `Value.ofString(string)`. */ - fun value(string: String) = value(Value.ofString(string)) - - /** Alias for calling [value] with `Value.ofNumber(number)`. */ - fun value(number: Double) = value(Value.ofNumber(number)) - - /** Alias for calling [value] with `Value.ofBool(bool)`. */ - fun value(bool: Boolean) = value(Value.ofBool(bool)) - - /** Alias for calling [value] with `Value.ofMixed(mixed)`. */ - fun valueOfMixed( - mixed: List - ) = value(Value.ofMixed(mixed)) - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SetMetadata]. - * - * Further updates to this [Builder] will not mutate the - * returned instance. - * - * The following fields are required: - * ```java - * .field() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SetMetadata = - SetMetadata( - checkRequired("field", field), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SetMetadata = apply { - if (validated) { - return@apply - } - - field() - value().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in - * this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (field.asKnown().isPresent) 1 else 0) + - (value.asKnown().getOrNull()?.validity() ?: 0) - - /** - * Value to set for the custom metadata field. The value type should - * match the custom metadata field type. - */ - @JsonDeserialize(using = Value.Deserializer::class) - @JsonSerialize(using = Value.Serializer::class) - class Value - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val mixed: List? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun mixed(): Optional> = - Optional.ofNullable(mixed) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun isMixed(): Boolean = mixed != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun asMixed(): List = - mixed.getOrThrow("mixed") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - mixed != null -> visitor.visitMixed(mixed) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Value = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} - - override fun visitMixed( - mixed: List - ) { - mixed.forEach { it.validate() } - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are - * contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitString(string: String) = 1 - - override fun visitNumber(number: Double) = 1 - - override fun visitBool(bool: Boolean) = 1 - - override fun visitMixed( - mixed: List - ) = mixed.sumOf { it.validity().toInt() } - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Value && - string == other.string && - number == other.number && - bool == other.bool && - mixed == other.mixed - } - - override fun hashCode(): Int = - Objects.hash(string, number, bool, mixed) - - override fun toString(): String = - when { - string != null -> "Value{string=$string}" - number != null -> "Value{number=$number}" - bool != null -> "Value{bool=$bool}" - mixed != null -> "Value{mixed=$mixed}" - _json != null -> "Value{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Value") - } - - companion object { - - @JvmStatic - fun ofString(string: String) = Value(string = string) - - @JvmStatic - fun ofNumber(number: Double) = Value(number = number) - - @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) - - @JvmStatic - fun ofMixed(mixed: List) = - Value(mixed = mixed.toImmutable()) - } - - /** - * An interface that defines how to map each variant of [Value] - * to a value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - fun visitMixed( - mixed: List - ): T - - /** - * Maps an unknown variant of [Value] to a value of type - * [T]. - * - * An instance of [Value] can contain an unknown variant if - * it was deserialized from data that doesn't match any - * known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException( - "Unknown Value: $json" - ) - } - } - - internal class Deserializer : - BaseDeserializer(Value::class) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): Value { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Value(string = it, _json = json) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Value(number = it, _json = json) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Value(bool = it, _json = json) - }, - tryDeserialize( - node, - jacksonTypeRef< - List< - UnnamedSchemaWithArrayParent7 - > - >(), - ) - ?.let { - Value(mixed = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is - // completely incompatible with all the possible - // variants (e.g. deserializing from object). - 0 -> Value(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest - // validity, then use the first completely valid - // match, or simply the first match if none are - // completely valid. - else -> - bestMatches.firstOrNull { it.isValid() } - ?: bestMatches.first() - } - } - } - - internal class Serializer : - BaseSerializer(Value::class) { - - override fun serialize( - value: Value, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> - generator.writeObject(value.string) - value.number != null -> - generator.writeObject(value.number) - value.bool != null -> - generator.writeObject(value.bool) - value.mixed != null -> - generator.writeObject(value.mixed) - value._json != null -> - generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Value") - } - } - } - - @JsonDeserialize( - using = UnnamedSchemaWithArrayParent7.Deserializer::class - ) - @JsonSerialize( - using = UnnamedSchemaWithArrayParent7.Serializer::class - ) - class UnnamedSchemaWithArrayParent7 - private constructor( - private val string: String? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun isString(): Boolean = string != null - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun asString(): String = string.getOrThrow("string") - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun _json(): Optional = - Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): UnnamedSchemaWithArrayParent7 = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNumber(number: Double) {} - - override fun visitBool(bool: Boolean) {} - } - ) - 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 = - accept( - object : Visitor { - override fun visitString(string: String) = 1 - - override fun visitNumber(number: Double) = 1 - - override fun visitBool(bool: Boolean) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnnamedSchemaWithArrayParent7 && - string == other.string && - number == other.number && - bool == other.bool - } - - override fun hashCode(): Int = - Objects.hash(string, number, bool) - - override fun toString(): String = - when { - string != null -> - "UnnamedSchemaWithArrayParent7{string=$string}" - number != null -> - "UnnamedSchemaWithArrayParent7{number=$number}" - bool != null -> - "UnnamedSchemaWithArrayParent7{bool=$bool}" - _json != null -> - "UnnamedSchemaWithArrayParent7{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent7" - ) - } - - companion object { - - @JvmStatic - fun ofString(string: String) = - UnnamedSchemaWithArrayParent7(string = string) - - @JvmStatic - fun ofNumber(number: Double) = - UnnamedSchemaWithArrayParent7(number = number) - - @JvmStatic - fun ofBool(bool: Boolean) = - UnnamedSchemaWithArrayParent7(bool = bool) - } - - /** - * An interface that defines how to map each variant of - * [UnnamedSchemaWithArrayParent7] to a value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - /** - * Maps an unknown variant of - * [UnnamedSchemaWithArrayParent7] to a value of type - * [T]. - * - * An instance of [UnnamedSchemaWithArrayParent7] can - * contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For - * example, if the SDK is on an older version than the - * API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws ImageKitInvalidDataException in the default - * implementation. - */ - fun unknown(json: JsonValue?): T { - throw ImageKitInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent7: $json" - ) - } - } - - internal class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent7::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): UnnamedSchemaWithArrayParent7 { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - UnnamedSchemaWithArrayParent7( - string = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - UnnamedSchemaWithArrayParent7( - number = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - UnnamedSchemaWithArrayParent7( - bool = it, - _json = json, - ) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing - // is completely incompatible with all the - // possible variants (e.g. deserializing from - // object). - 0 -> UnnamedSchemaWithArrayParent7(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the - // highest validity, then use the first - // completely valid match, or simply the first - // match if none are completely valid. - else -> - bestMatches.firstOrNull { it.isValid() } - ?: bestMatches.first() - } - } - } - - internal class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent7::class - ) { - - override fun serialize( - value: UnnamedSchemaWithArrayParent7, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> - generator.writeObject(value.string) - value.number != null -> - generator.writeObject(value.number) - value.bool != null -> - generator.writeObject(value.bool) - value._json != null -> - generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent7" - ) - } - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SetMetadata && - field == other.field && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, value, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SetMetadata{field=$field, value=$value, additionalProperties=$additionalProperties}" - } - - class UnsetMetadata - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val field: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("field") - @ExcludeMissing - field: JsonField = JsonMissing.of() - ) : this(field, mutableMapOf()) - - /** - * Name of the custom metadata field to remove. - * - * @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 field(): String = field.getRequired("field") - - /** - * Returns the raw JSON value of [field]. - * - * Unlike [field], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("field") - @ExcludeMissing - fun _field(): JsonField = field - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [UnsetMetadata]. - * - * The following fields are required: - * ```java - * .field() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnsetMetadata]. */ - class Builder internal constructor() { - - private var field: JsonField? = null - private var additionalProperties: - MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unsetMetadata: UnsetMetadata) = apply { - field = unsetMetadata.field - additionalProperties = - unsetMetadata.additionalProperties.toMutableMap() - } - - /** Name of the custom metadata field to remove. */ - fun field(field: String) = field(JsonField.of(field)) - - /** - * Sets [Builder.field] to an arbitrary JSON value. - * - * You should usually call [Builder.field] with a well-typed - * [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun field(field: JsonField) = apply { - this.field = field - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnsetMetadata]. - * - * Further updates to this [Builder] will not mutate the - * returned instance. - * - * The following fields are required: - * ```java - * .field() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UnsetMetadata = - UnsetMetadata( - checkRequired("field", field), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnsetMetadata = apply { - if (validated) { - return@apply - } - - field() - 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 (field.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnsetMetadata && - field == other.field && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(field, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnsetMetadata{field=$field, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OnYes && - addTags == other.addTags && - removeTags == other.removeTags && - setMetadata == other.setMetadata && - unsetMetadata == other.unsetMetadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - addTags, - removeTags, - setMetadata, - unsetMetadata, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OnYes{addTags=$addTags, removeTags=$removeTags, setMetadata=$setMetadata, unsetMetadata=$unsetMetadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is YesNo && - instruction == other.instruction && - type == other.type && - onNo == other.onNo && - onUnknown == other.onUnknown && - onYes == other.onYes && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - instruction, - type, - onNo, - onUnknown, - onYes, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "YesNo{instruction=$instruction, type=$type, onNo=$onNo, onUnknown=$onUnknown, onYes=$onYes, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AiTasks && - name == other.name && - tasks == other.tasks && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(name, tasks, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AiTasks{name=$name, tasks=$tasks, additionalProperties=$additionalProperties}" - } - - class SavedExtension - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val name: JsonValue, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), - ) : this(id, name, mutableMapOf()) - - /** - * The unique ID of the saved extension to apply. - * - * @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") - - /** - * Indicates this is a reference to a saved extension. - * - * Expected to always return the following: - * ```java - * JsonValue.from("saved-extension") - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server - * responded with an unexpected value). - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [SavedExtension]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SavedExtension]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonValue = JsonValue.from("saved-extension") - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(savedExtension: SavedExtension) = apply { - id = savedExtension.id - name = savedExtension.name - additionalProperties = savedExtension.additionalProperties.toMutableMap() - } - - /** The unique ID of the saved extension to apply. */ - 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 } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to - * the following: - * ```java - * JsonValue.from("saved-extension") - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonValue) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SavedExtension]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SavedExtension = - SavedExtension( - checkRequired("id", id), - name, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SavedExtension = apply { - if (validated) { - return@apply - } - - id() - _name().let { - if (it != JsonValue.from("saved-extension")) { - throw ImageKitInvalidDataException("'name' is invalid, received $it") - } - } - 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) + - name.let { if (it == JsonValue.from("saved-extension")) 1 else 0 } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SavedExtension && - id == other.id && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SavedExtension{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - } - /** * An array of AITags associated with the file that you want to remove, e.g. `["car", * "vehicle", "motorsports"]`. diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt index 30e5b4d4..90e34d74 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt @@ -15,6 +15,11 @@ import com.imagekit.api.core.checkKnown import com.imagekit.api.core.checkRequired import com.imagekit.api.core.toImmutable import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.AiTag +import com.imagekit.api.models.CustomMetadata +import com.imagekit.api.models.EmbeddedMetadata +import com.imagekit.api.models.SelectedFieldsSchema +import com.imagekit.api.models.VersionInfo import com.imagekit.api.models.files.Metadata import java.time.OffsetDateTime import java.util.Collections @@ -1500,447 +1505,6 @@ private constructor( (if (videoCodec.asKnown().isPresent) 1 else 0) + (if (width.asKnown().isPresent) 1 else 0) - /** - * AI-generated tag associated with an image. These tags can be added using the - * `google-auto-tagging` or `aws-auto-tagging` extensions. - */ - class AiTag - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val confidence: JsonField, - private val name: JsonField, - private val source: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("confidence") - @ExcludeMissing - confidence: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), - ) : this(confidence, name, source, mutableMapOf()) - - /** - * Confidence score of the tag. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun confidence(): Optional = confidence.getOptional("confidence") - - /** - * Name of the tag. - * - * @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") - - /** - * Source of the tag. Possible values are `google-auto-tagging` and `aws-auto-tagging`. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun source(): Optional = source.getOptional("source") - - /** - * Returns the raw JSON value of [confidence]. - * - * Unlike [confidence], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("confidence") - @ExcludeMissing - fun _confidence(): JsonField = confidence - - /** - * 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 [source]. - * - * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [AiTag]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AiTag]. */ - class Builder internal constructor() { - - private var confidence: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var source: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(aiTag: AiTag) = apply { - confidence = aiTag.confidence - name = aiTag.name - source = aiTag.source - additionalProperties = aiTag.additionalProperties.toMutableMap() - } - - /** Confidence score of the tag. */ - fun confidence(confidence: Double) = confidence(JsonField.of(confidence)) - - /** - * Sets [Builder.confidence] to an arbitrary JSON value. - * - * You should usually call [Builder.confidence] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun confidence(confidence: JsonField) = apply { - this.confidence = confidence - } - - /** Name of the tag. */ - 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 } - - /** - * Source of the tag. Possible values are `google-auto-tagging` and - * `aws-auto-tagging`. - */ - fun source(source: String) = source(JsonField.of(source)) - - /** - * Sets [Builder.source] to an arbitrary JSON value. - * - * You should usually call [Builder.source] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun source(source: JsonField) = apply { this.source = source } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AiTag]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AiTag = - AiTag(confidence, name, source, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): AiTag = apply { - if (validated) { - return@apply - } - - confidence() - name() - source() - 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 (confidence.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (source.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AiTag && - confidence == other.confidence && - name == other.name && - source == other.source && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(confidence, name, source, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AiTag{confidence=$confidence, name=$name, source=$source, additionalProperties=$additionalProperties}" - } - - /** A key-value data associated with the asset. */ - class CustomMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [CustomMetadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customMetadata: CustomMetadata) = apply { - additionalProperties = customMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [CustomMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CustomMetadata = CustomMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): CustomMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CustomMetadata && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "CustomMetadata{additionalProperties=$additionalProperties}" - } - - /** - * Consolidated embedded metadata associated with the file. It includes exif, iptc, and xmp - * data. - */ - class EmbeddedMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [EmbeddedMetadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EmbeddedMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(embeddedMetadata: EmbeddedMetadata) = apply { - additionalProperties = embeddedMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [EmbeddedMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): EmbeddedMetadata = EmbeddedMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): EmbeddedMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EmbeddedMetadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "EmbeddedMetadata{additionalProperties=$additionalProperties}" - } - /** * Extension names with their processing status at the time of completion of the request. It * could have one of the following status values: @@ -2973,303 +2537,6 @@ private constructor( "ExtensionStatus{aiAutoDescription=$aiAutoDescription, aiTasks=$aiTasks, awsAutoTagging=$awsAutoTagging, googleAutoTagging=$googleAutoTagging, removeBg=$removeBg, additionalProperties=$additionalProperties}" } - /** - * This field is included in the response only if the Path policy feature is available in - * the plan. It contains schema definitions for the custom metadata fields selected for the - * specified file path. Field selection can only be done when the Path policy feature is - * enabled. - * - * Keys are the names of the custom metadata fields; the value object has details about the - * custom metadata schema. - */ - class SelectedFieldsSchema - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [SelectedFieldsSchema]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SelectedFieldsSchema]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(selectedFieldsSchema: SelectedFieldsSchema) = apply { - additionalProperties = selectedFieldsSchema.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SelectedFieldsSchema]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): SelectedFieldsSchema = - SelectedFieldsSchema(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): SelectedFieldsSchema = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SelectedFieldsSchema && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SelectedFieldsSchema{additionalProperties=$additionalProperties}" - } - - /** An object containing the file or file version's `id` (versionId) and `name`. */ - class VersionInfo - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(id, name, mutableMapOf()) - - /** - * Unique identifier of the file version. - * - * @throws ImageKitInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") - - /** - * Name of the file version. - * - * @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") - - /** - * 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 [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [VersionInfo]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [VersionInfo]. */ - class Builder internal constructor() { - - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(versionInfo: VersionInfo) = apply { - id = versionInfo.id - name = versionInfo.name - additionalProperties = versionInfo.additionalProperties.toMutableMap() - } - - /** Unique identifier of the file version. */ - 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 } - - /** Name of the file version. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [VersionInfo]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): VersionInfo = - VersionInfo(id, name, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): VersionInfo = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: ImageKitInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is VersionInfo && - id == other.id && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "VersionInfo{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookServiceImpl.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookServiceImpl.kt index f028a009..c550aa22 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookServiceImpl.kt @@ -12,6 +12,7 @@ import com.imagekit.api.models.webhooks.UnsafeUnwrapWebhookEvent import com.imagekit.api.models.webhooks.UnwrapWebhookEvent import com.standardwebhooks.Webhook import com.standardwebhooks.exceptions.WebhookVerificationException +import java.util.Base64 import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -55,7 +56,8 @@ class WebhookServiceImpl internal constructor(private val clientOptions: ClientO val headersMap = headers.names().associateWith { name -> headers.values(name) }.toMap() - val webhook = Webhook(webhookSecret) + val encodedKey = Base64.getEncoder().encodeToString(webhookSecret.toByteArray()) + val webhook = Webhook(encodedKey) webhook.verify(unwrapParams.body(), headersMap) } catch (e: WebhookVerificationException) { throw ImageKitWebhookException("Could not verify webhook event signature", e) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AiTagTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AiTagTest.kt new file mode 100644 index 00000000..3d673cad --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AiTagTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AiTagTest { + + @Test + fun create() { + val aiTag = AiTag.builder().confidence(0.0).name("name").source("source").build() + + assertThat(aiTag.confidence()).contains(0.0) + assertThat(aiTag.name()).contains("name") + assertThat(aiTag.source()).contains("source") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val aiTag = AiTag.builder().confidence(0.0).name("name").source("source").build() + + val roundtrippedAiTag = + jsonMapper.readValue(jsonMapper.writeValueAsString(aiTag), jacksonTypeRef()) + + assertThat(roundtrippedAiTag).isEqualTo(aiTag) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/CustomMetadataTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/CustomMetadataTest.kt new file mode 100644 index 00000000..4b26a678 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/CustomMetadataTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CustomMetadataTest { + + @Test + fun create() { + val customMetadata = + CustomMetadata.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val customMetadata = + CustomMetadata.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() + + val roundtrippedCustomMetadata = + jsonMapper.readValue( + jsonMapper.writeValueAsString(customMetadata), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCustomMetadata).isEqualTo(customMetadata) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/EmbeddedMetadataTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/EmbeddedMetadataTest.kt new file mode 100644 index 00000000..b6ae79a4 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/EmbeddedMetadataTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class EmbeddedMetadataTest { + + @Test + fun create() { + val embeddedMetadata = + EmbeddedMetadata.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val embeddedMetadata = + EmbeddedMetadata.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() + + val roundtrippedEmbeddedMetadata = + jsonMapper.readValue( + jsonMapper.writeValueAsString(embeddedMetadata), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEmbeddedMetadata).isEqualTo(embeddedMetadata) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExtensionItemTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExtensionItemTest.kt new file mode 100644 index 00000000..00fdcc83 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExtensionItemTest.kt @@ -0,0 +1,227 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import com.imagekit.api.errors.ImageKitInvalidDataException +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class ExtensionItemTest { + + @Test + fun ofRemoveBg() { + val removeBg = + ExtensionItem.RemoveBg.builder() + .options( + ExtensionItem.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + + val extensionItem = ExtensionItem.ofRemoveBg(removeBg) + + assertThat(extensionItem.removeBg()).contains(removeBg) + assertThat(extensionItem.autoTaggingExtension()).isEmpty + assertThat(extensionItem.aiAutoDescription()).isEmpty + assertThat(extensionItem.aiTasks()).isEmpty + assertThat(extensionItem.savedExtension()).isEmpty + } + + @Test + fun ofRemoveBgRoundtrip() { + val jsonMapper = jsonMapper() + val extensionItem = + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() + .options( + ExtensionItem.RemoveBg.Options.builder() + .addShadow(true) + .bgColor("bg_color") + .bgImageUrl("bg_image_url") + .semitransparency(true) + .build() + ) + .build() + ) + + val roundtrippedExtensionItem = + jsonMapper.readValue( + jsonMapper.writeValueAsString(extensionItem), + jacksonTypeRef(), + ) + + assertThat(roundtrippedExtensionItem).isEqualTo(extensionItem) + } + + @Test + fun ofAutoTaggingExtension() { + val autoTaggingExtension = + ExtensionItem.AutoTaggingExtension.builder() + .maxTags(0L) + .minConfidence(0L) + .name(ExtensionItem.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .build() + + val extensionItem = ExtensionItem.ofAutoTaggingExtension(autoTaggingExtension) + + assertThat(extensionItem.removeBg()).isEmpty + assertThat(extensionItem.autoTaggingExtension()).contains(autoTaggingExtension) + assertThat(extensionItem.aiAutoDescription()).isEmpty + assertThat(extensionItem.aiTasks()).isEmpty + assertThat(extensionItem.savedExtension()).isEmpty + } + + @Test + fun ofAutoTaggingExtensionRoundtrip() { + val jsonMapper = jsonMapper() + val extensionItem = + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() + .maxTags(0L) + .minConfidence(0L) + .name(ExtensionItem.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) + .build() + ) + + val roundtrippedExtensionItem = + jsonMapper.readValue( + jsonMapper.writeValueAsString(extensionItem), + jacksonTypeRef(), + ) + + assertThat(roundtrippedExtensionItem).isEqualTo(extensionItem) + } + + @Test + fun ofAiAutoDescription() { + val extensionItem = ExtensionItem.ofAiAutoDescription() + + assertThat(extensionItem.removeBg()).isEmpty + assertThat(extensionItem.autoTaggingExtension()).isEmpty + assertThat(extensionItem.aiAutoDescription()) + .contains(JsonValue.from(mapOf("name" to "ai-auto-description"))) + assertThat(extensionItem.aiTasks()).isEmpty + assertThat(extensionItem.savedExtension()).isEmpty + } + + @Test + fun ofAiAutoDescriptionRoundtrip() { + val jsonMapper = jsonMapper() + val extensionItem = ExtensionItem.ofAiAutoDescription() + + val roundtrippedExtensionItem = + jsonMapper.readValue( + jsonMapper.writeValueAsString(extensionItem), + jacksonTypeRef(), + ) + + assertThat(roundtrippedExtensionItem).isEqualTo(extensionItem) + } + + @Test + fun ofAiTasks() { + val aiTasks = + ExtensionItem.AiTasks.builder() + .addTask( + ExtensionItem.AiTasks.Task.SelectTags.builder() + .instruction("What types of clothing items are visible in this image?") + .maxSelections(1L) + .minSelections(0L) + .vocabulary(listOf("shirt", "tshirt", "dress", "trousers", "jacket")) + .build() + ) + .build() + + val extensionItem = ExtensionItem.ofAiTasks(aiTasks) + + assertThat(extensionItem.removeBg()).isEmpty + assertThat(extensionItem.autoTaggingExtension()).isEmpty + assertThat(extensionItem.aiAutoDescription()).isEmpty + assertThat(extensionItem.aiTasks()).contains(aiTasks) + assertThat(extensionItem.savedExtension()).isEmpty + } + + @Test + fun ofAiTasksRoundtrip() { + val jsonMapper = jsonMapper() + val extensionItem = + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() + .addTask( + ExtensionItem.AiTasks.Task.SelectTags.builder() + .instruction("What types of clothing items are visible in this image?") + .maxSelections(1L) + .minSelections(0L) + .vocabulary(listOf("shirt", "tshirt", "dress", "trousers", "jacket")) + .build() + ) + .build() + ) + + val roundtrippedExtensionItem = + jsonMapper.readValue( + jsonMapper.writeValueAsString(extensionItem), + jacksonTypeRef(), + ) + + assertThat(roundtrippedExtensionItem).isEqualTo(extensionItem) + } + + @Test + fun ofSavedExtension() { + val savedExtension = ExtensionItem.SavedExtension.builder().id("ext_abc123").build() + + val extensionItem = ExtensionItem.ofSavedExtension(savedExtension) + + assertThat(extensionItem.removeBg()).isEmpty + assertThat(extensionItem.autoTaggingExtension()).isEmpty + assertThat(extensionItem.aiAutoDescription()).isEmpty + assertThat(extensionItem.aiTasks()).isEmpty + assertThat(extensionItem.savedExtension()).contains(savedExtension) + } + + @Test + fun ofSavedExtensionRoundtrip() { + val jsonMapper = jsonMapper() + val extensionItem = + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() + ) + + val roundtrippedExtensionItem = + jsonMapper.readValue( + jsonMapper.writeValueAsString(extensionItem), + jacksonTypeRef(), + ) + + assertThat(roundtrippedExtensionItem).isEqualTo(extensionItem) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val extensionItem = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { extensionItem.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SelectedFieldsSchemaTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SelectedFieldsSchemaTest.kt new file mode 100644 index 00000000..b3939645 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SelectedFieldsSchemaTest.kt @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.JsonValue +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SelectedFieldsSchemaTest { + + @Test + fun create() { + val selectedFieldsSchema = + SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to listOf(true, 10, "Hello"), + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val selectedFieldsSchema = + SelectedFieldsSchema.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "type" to "Text", + "defaultValue" to listOf(true, 10, "Hello"), + "isValueRequired" to true, + "maxLength" to 0, + "maxValue" to "string", + "minLength" to 0, + "minValue" to "string", + "readOnly" to true, + "selectOptions" to listOf("small", "medium", "large", 30, 40, true), + "selectOptionsTruncated" to true, + ) + ), + ) + .build() + + val roundtrippedSelectedFieldsSchema = + jsonMapper.readValue( + jsonMapper.writeValueAsString(selectedFieldsSchema), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSelectedFieldsSchema).isEqualTo(selectedFieldsSchema) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VersionInfoTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VersionInfoTest.kt new file mode 100644 index 00000000..23ca3a57 --- /dev/null +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VersionInfoTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.imagekit.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.imagekit.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VersionInfoTest { + + @Test + fun create() { + val versionInfo = VersionInfo.builder().id("id").name("name").build() + + assertThat(versionInfo.id()).contains("id") + assertThat(versionInfo.name()).contains("name") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val versionInfo = VersionInfo.builder().id("id").name("name").build() + + val roundtrippedVersionInfo = + jsonMapper.readValue( + jsonMapper.writeValueAsString(versionInfo), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVersionInfo).isEqualTo(versionInfo) + } +} diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt index 038c8128..6e6f20fb 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt @@ -6,6 +6,11 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.AiTag +import com.imagekit.api.models.CustomMetadata +import com.imagekit.api.models.EmbeddedMetadata +import com.imagekit.api.models.SelectedFieldsSchema +import com.imagekit.api.models.VersionInfo import com.imagekit.api.models.files.File import com.imagekit.api.models.files.Folder import java.time.OffsetDateTime @@ -21,22 +26,20 @@ internal class AssetListResponseTest { fun ofFile() { val file = File.builder() - .addAiTag( - File.AiTag.builder().confidence(0.0).name("name").source("source").build() - ) + .addAiTag(AiTag.builder().confidence(0.0).name("name").source("source").build()) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -50,7 +53,7 @@ internal class AssetListResponseTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -77,7 +80,7 @@ internal class AssetListResponseTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -94,22 +97,20 @@ internal class AssetListResponseTest { val assetListResponse = AssetListResponse.ofFile( File.builder() - .addAiTag( - File.AiTag.builder().confidence(0.0).name("name").source("source").build() - ) + .addAiTag(AiTag.builder().confidence(0.0).name("name").source("source").build()) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -123,7 +124,7 @@ internal class AssetListResponseTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -150,7 +151,7 @@ internal class AssetListResponseTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt index 20626522..4233c7ea 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt @@ -4,7 +4,7 @@ package com.imagekit.api.models.beta.v2.files import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField -import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 +import com.imagekit.api.models.ExtensionItem import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -28,10 +28,10 @@ internal class FileUploadParamsTest { .description("Running shoes") .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -40,21 +40,18 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(ExtensionItem.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags.builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -66,28 +63,23 @@ internal class FileUploadParamsTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction("Is this a luxury or high-end fashion item?") .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .SetMetadata + ExtensionItem.AiTasks.Task.YesNo.OnNo.SetMetadata .builder() .field("price_range") .value("premium") .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .UnsetMetadata + ExtensionItem.AiTasks.Task.YesNo.OnNo.UnsetMetadata .builder() .field("price_range") .build() @@ -95,15 +87,13 @@ internal class FileUploadParamsTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnUnknown - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnUnknown.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .SetMetadata .builder() .field("price_range") @@ -111,8 +101,7 @@ internal class FileUploadParamsTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .UnsetMetadata .builder() .field("price_range") @@ -121,25 +110,20 @@ internal class FileUploadParamsTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .SetMetadata + ExtensionItem.AiTasks.Task.YesNo.OnYes.SetMetadata .builder() .field("price_range") .value("premium") .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .UnsetMetadata + ExtensionItem.AiTasks.Task.YesNo.OnYes.UnsetMetadata .builder() .field("price_range") .build() @@ -150,10 +134,8 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -173,15 +155,15 @@ internal class FileUploadParamsTest { ) .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) + FileUploadParams.UploadTransformation.Post.Abs.builder() + .protocol(FileUploadParams.UploadTransformation.Post.Abs.Protocol.DASH) .value("sr-240_360_480_720_1080") .build() ) @@ -211,10 +193,10 @@ internal class FileUploadParamsTest { .description("Running shoes") .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -223,21 +205,18 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(ExtensionItem.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags.builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -249,18 +228,16 @@ internal class FileUploadParamsTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction("Is this a luxury or high-end fashion item?") .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -268,8 +245,7 @@ internal class FileUploadParamsTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -278,16 +254,13 @@ internal class FileUploadParamsTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnUnknown.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .SetMetadata .builder() .field("price_range") @@ -295,8 +268,7 @@ internal class FileUploadParamsTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .UnsetMetadata .builder() .field("price_range") @@ -305,15 +277,13 @@ internal class FileUploadParamsTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -321,8 +291,7 @@ internal class FileUploadParamsTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -334,10 +303,8 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -357,15 +324,17 @@ internal class FileUploadParamsTest { ) .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) + FileUploadParams.UploadTransformation.Post.Abs.builder() + .protocol( + FileUploadParams.UploadTransformation.Post.Abs.Protocol.DASH + ) .value("sr-240_360_480_720_1080") .build() ) @@ -404,11 +373,10 @@ internal class FileUploadParamsTest { "extensions" to MultipartField.of( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options - .builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -417,24 +385,21 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension - .Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -452,25 +417,19 @@ internal class FileUploadParamsTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4 - .AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnNo .SetMetadata .builder() @@ -479,10 +438,7 @@ internal class FileUploadParamsTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4 - .AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnNo .UnsetMetadata .builder() @@ -492,19 +448,14 @@ internal class FileUploadParamsTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4 - .AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .SetMetadata .builder() @@ -513,10 +464,7 @@ internal class FileUploadParamsTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4 - .AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .UnsetMetadata .builder() @@ -526,19 +474,14 @@ internal class FileUploadParamsTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4 - .AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnYes .SetMetadata .builder() @@ -547,10 +490,7 @@ internal class FileUploadParamsTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4 - .AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnYes .UnsetMetadata .builder() @@ -563,8 +503,8 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder() .id("ext_abc123") .build() ), @@ -588,16 +528,18 @@ internal class FileUploadParamsTest { "tags" to MultipartField.of(listOf("t-shirt", "round-neck", "men")), "transformation" to MultipartField.of( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail + .builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol + FileUploadParams.UploadTransformation.Post.Abs + .Protocol .DASH ) .value("sr-240_360_480_720_1080") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt index 141cd730..ef3b62e3 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt @@ -5,6 +5,11 @@ package com.imagekit.api.models.beta.v2.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper +import com.imagekit.api.models.AiTag +import com.imagekit.api.models.CustomMetadata +import com.imagekit.api.models.EmbeddedMetadata +import com.imagekit.api.models.SelectedFieldsSchema +import com.imagekit.api.models.VersionInfo import com.imagekit.api.models.files.Metadata import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -16,25 +21,19 @@ internal class FileUploadResponseTest { fun create() { val fileUploadResponse = FileUploadResponse.builder() - .addAiTag( - FileUploadResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) + .addAiTag(AiTag.builder().confidence(0.0).name("name").source("source").build()) .audioCodec("audioCodec") .bitRate(0L) .customCoordinates("customCoordinates") .customMetadata( - FileUploadResponse.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - FileUploadResponse.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -66,7 +65,7 @@ internal class FileUploadResponseTest { .exif( Metadata.Exif.builder() .exif( - Metadata.Exif.InnerExif.builder() + Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -147,7 +146,7 @@ internal class FileUploadResponseTest { ) .name("name") .selectedFieldsSchema( - FileUploadResponse.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -172,33 +171,25 @@ internal class FileUploadResponseTest { .addTag("string") .thumbnailUrl("thumbnailUrl") .url("url") - .versionInfo(FileUploadResponse.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() assertThat(fileUploadResponse.aiTags().getOrNull()) - .containsExactly( - FileUploadResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) + .containsExactly(AiTag.builder().confidence(0.0).name("name").source("source").build()) assertThat(fileUploadResponse.audioCodec()).contains("audioCodec") assertThat(fileUploadResponse.bitRate()).contains(0L) assertThat(fileUploadResponse.customCoordinates()).contains("customCoordinates") assertThat(fileUploadResponse.customMetadata()) .contains( - FileUploadResponse.CustomMetadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() + CustomMetadata.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() ) assertThat(fileUploadResponse.description()).contains("description") assertThat(fileUploadResponse.duration()).contains(0L) assertThat(fileUploadResponse.embeddedMetadata()) .contains( - FileUploadResponse.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -228,7 +219,7 @@ internal class FileUploadResponseTest { .exif( Metadata.Exif.builder() .exif( - Metadata.Exif.InnerExif.builder() + Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -310,7 +301,7 @@ internal class FileUploadResponseTest { assertThat(fileUploadResponse.name()).contains("name") assertThat(fileUploadResponse.selectedFieldsSchema()) .contains( - FileUploadResponse.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -335,7 +326,7 @@ internal class FileUploadResponseTest { assertThat(fileUploadResponse.thumbnailUrl()).contains("thumbnailUrl") assertThat(fileUploadResponse.url()).contains("url") assertThat(fileUploadResponse.versionInfo()) - .contains(FileUploadResponse.VersionInfo.builder().id("id").name("name").build()) + .contains(VersionInfo.builder().id("id").name("name").build()) assertThat(fileUploadResponse.videoCodec()).contains("videoCodec") assertThat(fileUploadResponse.width()).contains(0.0) } @@ -345,25 +336,19 @@ internal class FileUploadResponseTest { val jsonMapper = jsonMapper() val fileUploadResponse = FileUploadResponse.builder() - .addAiTag( - FileUploadResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) + .addAiTag(AiTag.builder().confidence(0.0).name("name").source("source").build()) .audioCodec("audioCodec") .bitRate(0L) .customCoordinates("customCoordinates") .customMetadata( - FileUploadResponse.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - FileUploadResponse.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -395,7 +380,7 @@ internal class FileUploadResponseTest { .exif( Metadata.Exif.builder() .exif( - Metadata.Exif.InnerExif.builder() + Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -476,7 +461,7 @@ internal class FileUploadResponseTest { ) .name("name") .selectedFieldsSchema( - FileUploadResponse.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -501,7 +486,7 @@ internal class FileUploadResponseTest { .addTag("string") .thumbnailUrl("thumbnailUrl") .url("url") - .versionInfo(FileUploadResponse.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt index 009962ae..fd1a70d5 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt @@ -17,14 +17,11 @@ internal class CustomMetadataFieldCreateParamsTest { .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) .defaultValueOfMixed( listOf( - CustomMetadataFieldCreateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent8 + CustomMetadataFieldCreateParams.Schema.DefaultValue.DefaultValueItem .ofBool(true), - CustomMetadataFieldCreateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent8 + CustomMetadataFieldCreateParams.Schema.DefaultValue.DefaultValueItem .ofNumber(10.0), - CustomMetadataFieldCreateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent8 + CustomMetadataFieldCreateParams.Schema.DefaultValue.DefaultValueItem .ofString("Hello"), ) ) @@ -59,14 +56,11 @@ internal class CustomMetadataFieldCreateParamsTest { .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) .defaultValueOfMixed( listOf( - CustomMetadataFieldCreateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent8 + CustomMetadataFieldCreateParams.Schema.DefaultValue.DefaultValueItem .ofBool(true), - CustomMetadataFieldCreateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent8 + CustomMetadataFieldCreateParams.Schema.DefaultValue.DefaultValueItem .ofNumber(10.0), - CustomMetadataFieldCreateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent8 + CustomMetadataFieldCreateParams.Schema.DefaultValue.DefaultValueItem .ofString("Hello"), ) ) @@ -105,14 +99,11 @@ internal class CustomMetadataFieldCreateParamsTest { .type(CustomMetadataFieldCreateParams.Schema.Type.NUMBER) .defaultValueOfMixed( listOf( - CustomMetadataFieldCreateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent8 + CustomMetadataFieldCreateParams.Schema.DefaultValue.DefaultValueItem .ofBool(true), - CustomMetadataFieldCreateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent8 + CustomMetadataFieldCreateParams.Schema.DefaultValue.DefaultValueItem .ofNumber(10.0), - CustomMetadataFieldCreateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent8 + CustomMetadataFieldCreateParams.Schema.DefaultValue.DefaultValueItem .ofString("Hello"), ) ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt index 670f7f8c..6deccd53 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt @@ -21,15 +21,15 @@ internal class CustomMetadataFieldTest { .type(CustomMetadataField.Schema.Type.TEXT) .defaultValueOfMixed( listOf( - CustomMetadataField.Schema.DefaultValue - .UnnamedSchemaWithArrayParent3 - .ofBool(true), - CustomMetadataField.Schema.DefaultValue - .UnnamedSchemaWithArrayParent3 - .ofNumber(10.0), - CustomMetadataField.Schema.DefaultValue - .UnnamedSchemaWithArrayParent3 - .ofString("Hello"), + CustomMetadataField.Schema.DefaultValue.DefaultValueItem.ofBool( + true + ), + CustomMetadataField.Schema.DefaultValue.DefaultValueItem.ofNumber( + 10.0 + ), + CustomMetadataField.Schema.DefaultValue.DefaultValueItem.ofString( + "Hello" + ), ) ) .isValueRequired(true) @@ -60,12 +60,11 @@ internal class CustomMetadataFieldTest { .type(CustomMetadataField.Schema.Type.TEXT) .defaultValueOfMixed( listOf( - CustomMetadataField.Schema.DefaultValue.UnnamedSchemaWithArrayParent3 - .ofBool(true), - CustomMetadataField.Schema.DefaultValue.UnnamedSchemaWithArrayParent3 - .ofNumber(10.0), - CustomMetadataField.Schema.DefaultValue.UnnamedSchemaWithArrayParent3 - .ofString("Hello"), + CustomMetadataField.Schema.DefaultValue.DefaultValueItem.ofBool(true), + CustomMetadataField.Schema.DefaultValue.DefaultValueItem.ofNumber(10.0), + CustomMetadataField.Schema.DefaultValue.DefaultValueItem.ofString( + "Hello" + ), ) ) .isValueRequired(true) @@ -100,15 +99,15 @@ internal class CustomMetadataFieldTest { .type(CustomMetadataField.Schema.Type.TEXT) .defaultValueOfMixed( listOf( - CustomMetadataField.Schema.DefaultValue - .UnnamedSchemaWithArrayParent3 - .ofBool(true), - CustomMetadataField.Schema.DefaultValue - .UnnamedSchemaWithArrayParent3 - .ofNumber(10.0), - CustomMetadataField.Schema.DefaultValue - .UnnamedSchemaWithArrayParent3 - .ofString("Hello"), + CustomMetadataField.Schema.DefaultValue.DefaultValueItem.ofBool( + true + ), + CustomMetadataField.Schema.DefaultValue.DefaultValueItem.ofNumber( + 10.0 + ), + CustomMetadataField.Schema.DefaultValue.DefaultValueItem.ofString( + "Hello" + ), ) ) .isValueRequired(true) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt index c950a4ae..54c3e400 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt @@ -16,14 +16,11 @@ internal class CustomMetadataFieldUpdateParamsTest { CustomMetadataFieldUpdateParams.Schema.builder() .defaultValueOfMixed( listOf( - CustomMetadataFieldUpdateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent9 + CustomMetadataFieldUpdateParams.Schema.DefaultValue.DefaultValueItem .ofBool(true), - CustomMetadataFieldUpdateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent9 + CustomMetadataFieldUpdateParams.Schema.DefaultValue.DefaultValueItem .ofNumber(10.0), - CustomMetadataFieldUpdateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent9 + CustomMetadataFieldUpdateParams.Schema.DefaultValue.DefaultValueItem .ofString("Hello"), ) ) @@ -66,14 +63,11 @@ internal class CustomMetadataFieldUpdateParamsTest { CustomMetadataFieldUpdateParams.Schema.builder() .defaultValueOfMixed( listOf( - CustomMetadataFieldUpdateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent9 + CustomMetadataFieldUpdateParams.Schema.DefaultValue.DefaultValueItem .ofBool(true), - CustomMetadataFieldUpdateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent9 + CustomMetadataFieldUpdateParams.Schema.DefaultValue.DefaultValueItem .ofNumber(10.0), - CustomMetadataFieldUpdateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent9 + CustomMetadataFieldUpdateParams.Schema.DefaultValue.DefaultValueItem .ofString("Hello"), ) ) @@ -110,14 +104,11 @@ internal class CustomMetadataFieldUpdateParamsTest { CustomMetadataFieldUpdateParams.Schema.builder() .defaultValueOfMixed( listOf( - CustomMetadataFieldUpdateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent9 + CustomMetadataFieldUpdateParams.Schema.DefaultValue.DefaultValueItem .ofBool(true), - CustomMetadataFieldUpdateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent9 + CustomMetadataFieldUpdateParams.Schema.DefaultValue.DefaultValueItem .ofNumber(10.0), - CustomMetadataFieldUpdateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent9 + CustomMetadataFieldUpdateParams.Schema.DefaultValue.DefaultValueItem .ofString("Hello"), ) ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt index f5cfff0e..90586c91 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt @@ -5,6 +5,11 @@ package com.imagekit.api.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper +import com.imagekit.api.models.AiTag +import com.imagekit.api.models.CustomMetadata +import com.imagekit.api.models.EmbeddedMetadata +import com.imagekit.api.models.SelectedFieldsSchema +import com.imagekit.api.models.VersionInfo import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -16,22 +21,20 @@ internal class FileTest { fun create() { val file = File.builder() - .addAiTag( - File.AiTag.builder().confidence(0.0).name("name").source("source").build() - ) + .addAiTag(AiTag.builder().confidence(0.0).name("name").source("source").build()) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -45,7 +48,7 @@ internal class FileTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -72,30 +75,26 @@ internal class FileTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() assertThat(file.aiTags().getOrNull()) - .containsExactly( - File.AiTag.builder().confidence(0.0).name("name").source("source").build() - ) + .containsExactly(AiTag.builder().confidence(0.0).name("name").source("source").build()) assertThat(file.audioCodec()).contains("audioCodec") assertThat(file.bitRate()).contains(0L) assertThat(file.createdAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(file.customCoordinates()).contains("customCoordinates") assertThat(file.customMetadata()) .contains( - File.CustomMetadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() + CustomMetadata.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() ) assertThat(file.description()).contains("description") assertThat(file.duration()).contains(0L) assertThat(file.embeddedMetadata()) .contains( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -110,7 +109,7 @@ internal class FileTest { assertThat(file.name()).contains("name") assertThat(file.selectedFieldsSchema()) .contains( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -136,8 +135,7 @@ internal class FileTest { assertThat(file.type()).contains(File.Type.FILE) assertThat(file.updatedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(file.url()).contains("https://example.com") - assertThat(file.versionInfo()) - .contains(File.VersionInfo.builder().id("id").name("name").build()) + assertThat(file.versionInfo()).contains(VersionInfo.builder().id("id").name("name").build()) assertThat(file.videoCodec()).contains("videoCodec") assertThat(file.width()).contains(0.0) } @@ -147,22 +145,20 @@ internal class FileTest { val jsonMapper = jsonMapper() val file = File.builder() - .addAiTag( - File.AiTag.builder().confidence(0.0).name("name").source("source").build() - ) + .addAiTag(AiTag.builder().confidence(0.0).name("name").source("source").build()) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -176,7 +172,7 @@ internal class FileTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -203,7 +199,7 @@ internal class FileTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt index 0daa7c0e..8e7beb45 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt @@ -3,7 +3,7 @@ package com.imagekit.api.models.files import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 +import com.imagekit.api.models.ExtensionItem import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -25,10 +25,10 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -37,32 +37,27 @@ internal class FileUpdateParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING + ExtensionItem.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) - .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name - .AWS_AUTO_TAGGING - ) + .name(ExtensionItem.AutoTaggingExtension.Name.AWS_AUTO_TAGGING) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible?" ) @@ -73,10 +68,8 @@ internal class FileUpdateParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -119,10 +112,10 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -131,32 +124,30 @@ internal class FileUpdateParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name - .AWS_AUTO_TAGGING + ExtensionItem.AutoTaggingExtension.Name.AWS_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible?" ) @@ -167,10 +158,8 @@ internal class FileUpdateParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -198,10 +187,10 @@ internal class FileUpdateParamsTest { .description("description") .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -210,32 +199,30 @@ internal class FileUpdateParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name - .AWS_AUTO_TAGGING + ExtensionItem.AutoTaggingExtension.Name.AWS_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible?" ) @@ -246,10 +233,8 @@ internal class FileUpdateParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt index 29185f54..26932192 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt @@ -5,6 +5,11 @@ package com.imagekit.api.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper +import com.imagekit.api.models.AiTag +import com.imagekit.api.models.CustomMetadata +import com.imagekit.api.models.EmbeddedMetadata +import com.imagekit.api.models.SelectedFieldsSchema +import com.imagekit.api.models.VersionInfo import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat @@ -16,22 +21,20 @@ internal class FileUpdateResponseTest { fun create() { val fileUpdateResponse = FileUpdateResponse.builder() - .addAiTag( - File.AiTag.builder().confidence(0.0).name("name").source("source").build() - ) + .addAiTag(AiTag.builder().confidence(0.0).name("name").source("source").build()) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -45,7 +48,7 @@ internal class FileUpdateResponseTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -72,7 +75,7 @@ internal class FileUpdateResponseTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .extensionStatus( @@ -91,9 +94,7 @@ internal class FileUpdateResponseTest { .build() assertThat(fileUpdateResponse.aiTags().getOrNull()) - .containsExactly( - File.AiTag.builder().confidence(0.0).name("name").source("source").build() - ) + .containsExactly(AiTag.builder().confidence(0.0).name("name").source("source").build()) assertThat(fileUpdateResponse.audioCodec()).contains("audioCodec") assertThat(fileUpdateResponse.bitRate()).contains(0L) assertThat(fileUpdateResponse.createdAt()) @@ -101,15 +102,13 @@ internal class FileUpdateResponseTest { assertThat(fileUpdateResponse.customCoordinates()).contains("customCoordinates") assertThat(fileUpdateResponse.customMetadata()) .contains( - File.CustomMetadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() + CustomMetadata.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() ) assertThat(fileUpdateResponse.description()).contains("description") assertThat(fileUpdateResponse.duration()).contains(0L) assertThat(fileUpdateResponse.embeddedMetadata()) .contains( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -124,7 +123,7 @@ internal class FileUpdateResponseTest { assertThat(fileUpdateResponse.name()).contains("name") assertThat(fileUpdateResponse.selectedFieldsSchema()) .contains( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -152,7 +151,7 @@ internal class FileUpdateResponseTest { .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(fileUpdateResponse.url()).contains("https://example.com") assertThat(fileUpdateResponse.versionInfo()) - .contains(File.VersionInfo.builder().id("id").name("name").build()) + .contains(VersionInfo.builder().id("id").name("name").build()) assertThat(fileUpdateResponse.videoCodec()).contains("videoCodec") assertThat(fileUpdateResponse.width()).contains(0.0) assertThat(fileUpdateResponse.extensionStatus()) @@ -172,22 +171,20 @@ internal class FileUpdateResponseTest { val jsonMapper = jsonMapper() val fileUpdateResponse = FileUpdateResponse.builder() - .addAiTag( - File.AiTag.builder().confidence(0.0).name("name").source("source").build() - ) + .addAiTag(AiTag.builder().confidence(0.0).name("name").source("source").build()) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -201,7 +198,7 @@ internal class FileUpdateResponseTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -228,7 +225,7 @@ internal class FileUpdateResponseTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .extensionStatus( diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt index c2b7158a..2e9a3412 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt @@ -4,7 +4,7 @@ package com.imagekit.api.models.files import com.imagekit.api.core.JsonValue import com.imagekit.api.core.MultipartField -import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 +import com.imagekit.api.models.ExtensionItem import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -29,10 +29,10 @@ internal class FileUploadParamsTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -41,21 +41,18 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(ExtensionItem.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags.builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -67,28 +64,23 @@ internal class FileUploadParamsTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction("Is this a luxury or high-end fashion item?") .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .SetMetadata + ExtensionItem.AiTasks.Task.YesNo.OnNo.SetMetadata .builder() .field("price_range") .value("premium") .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .UnsetMetadata + ExtensionItem.AiTasks.Task.YesNo.OnNo.UnsetMetadata .builder() .field("price_range") .build() @@ -96,15 +88,13 @@ internal class FileUploadParamsTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnUnknown - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnUnknown.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .SetMetadata .builder() .field("price_range") @@ -112,8 +102,7 @@ internal class FileUploadParamsTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .UnsetMetadata .builder() .field("price_range") @@ -122,25 +111,20 @@ internal class FileUploadParamsTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .SetMetadata + ExtensionItem.AiTasks.Task.YesNo.OnYes.SetMetadata .builder() .field("price_range") .value("premium") .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .UnsetMetadata + ExtensionItem.AiTasks.Task.YesNo.OnYes.UnsetMetadata .builder() .field("price_range") .build() @@ -151,10 +135,8 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -176,15 +158,15 @@ internal class FileUploadParamsTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) + FileUploadParams.UploadTransformation.Post.Abs.builder() + .protocol(FileUploadParams.UploadTransformation.Post.Abs.Protocol.DASH) .value("sr-240_360_480_720_1080") .build() ) @@ -215,10 +197,10 @@ internal class FileUploadParamsTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -227,21 +209,18 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(ExtensionItem.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags.builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -253,18 +232,16 @@ internal class FileUploadParamsTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction("Is this a luxury or high-end fashion item?") .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -272,8 +249,7 @@ internal class FileUploadParamsTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -282,16 +258,13 @@ internal class FileUploadParamsTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnUnknown.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .SetMetadata .builder() .field("price_range") @@ -299,8 +272,7 @@ internal class FileUploadParamsTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .UnsetMetadata .builder() .field("price_range") @@ -309,15 +281,13 @@ internal class FileUploadParamsTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -325,8 +295,7 @@ internal class FileUploadParamsTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -338,10 +307,8 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -363,15 +330,17 @@ internal class FileUploadParamsTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) + FileUploadParams.UploadTransformation.Post.Abs.builder() + .protocol( + FileUploadParams.UploadTransformation.Post.Abs.Protocol.DASH + ) .value("sr-240_360_480_720_1080") .build() ) @@ -411,11 +380,10 @@ internal class FileUploadParamsTest { "extensions" to MultipartField.of( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options - .builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -424,24 +392,21 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension - .Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -459,25 +424,19 @@ internal class FileUploadParamsTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4 - .AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnNo .SetMetadata .builder() @@ -486,10 +445,7 @@ internal class FileUploadParamsTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4 - .AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnNo .UnsetMetadata .builder() @@ -499,19 +455,14 @@ internal class FileUploadParamsTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4 - .AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .SetMetadata .builder() @@ -520,10 +471,7 @@ internal class FileUploadParamsTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4 - .AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .UnsetMetadata .builder() @@ -533,19 +481,14 @@ internal class FileUploadParamsTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4 - .AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnYes .SetMetadata .builder() @@ -554,10 +497,7 @@ internal class FileUploadParamsTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4 - .AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnYes .UnsetMetadata .builder() @@ -570,8 +510,8 @@ internal class FileUploadParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder() .id("ext_abc123") .build() ), @@ -597,16 +537,18 @@ internal class FileUploadParamsTest { "tags" to MultipartField.of(listOf("t-shirt", "round-neck", "men")), "transformation" to MultipartField.of( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail + .builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol + FileUploadParams.UploadTransformation.Post.Abs + .Protocol .DASH ) .value("sr-240_360_480_720_1080") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt index abeaf46d..e3847af3 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt @@ -5,6 +5,11 @@ package com.imagekit.api.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper +import com.imagekit.api.models.AiTag +import com.imagekit.api.models.CustomMetadata +import com.imagekit.api.models.EmbeddedMetadata +import com.imagekit.api.models.SelectedFieldsSchema +import com.imagekit.api.models.VersionInfo import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -15,25 +20,19 @@ internal class FileUploadResponseTest { fun create() { val fileUploadResponse = FileUploadResponse.builder() - .addAiTag( - FileUploadResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) + .addAiTag(AiTag.builder().confidence(0.0).name("name").source("source").build()) .audioCodec("audioCodec") .bitRate(0L) .customCoordinates("customCoordinates") .customMetadata( - FileUploadResponse.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - FileUploadResponse.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -65,7 +64,7 @@ internal class FileUploadResponseTest { .exif( Metadata.Exif.builder() .exif( - Metadata.Exif.InnerExif.builder() + Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -146,7 +145,7 @@ internal class FileUploadResponseTest { ) .name("name") .selectedFieldsSchema( - FileUploadResponse.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -171,33 +170,25 @@ internal class FileUploadResponseTest { .addTag("string") .thumbnailUrl("thumbnailUrl") .url("url") - .versionInfo(FileUploadResponse.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() assertThat(fileUploadResponse.aiTags().getOrNull()) - .containsExactly( - FileUploadResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) + .containsExactly(AiTag.builder().confidence(0.0).name("name").source("source").build()) assertThat(fileUploadResponse.audioCodec()).contains("audioCodec") assertThat(fileUploadResponse.bitRate()).contains(0L) assertThat(fileUploadResponse.customCoordinates()).contains("customCoordinates") assertThat(fileUploadResponse.customMetadata()) .contains( - FileUploadResponse.CustomMetadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() + CustomMetadata.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() ) assertThat(fileUploadResponse.description()).contains("description") assertThat(fileUploadResponse.duration()).contains(0L) assertThat(fileUploadResponse.embeddedMetadata()) .contains( - FileUploadResponse.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -227,7 +218,7 @@ internal class FileUploadResponseTest { .exif( Metadata.Exif.builder() .exif( - Metadata.Exif.InnerExif.builder() + Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -309,7 +300,7 @@ internal class FileUploadResponseTest { assertThat(fileUploadResponse.name()).contains("name") assertThat(fileUploadResponse.selectedFieldsSchema()) .contains( - FileUploadResponse.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -334,7 +325,7 @@ internal class FileUploadResponseTest { assertThat(fileUploadResponse.thumbnailUrl()).contains("thumbnailUrl") assertThat(fileUploadResponse.url()).contains("url") assertThat(fileUploadResponse.versionInfo()) - .contains(FileUploadResponse.VersionInfo.builder().id("id").name("name").build()) + .contains(VersionInfo.builder().id("id").name("name").build()) assertThat(fileUploadResponse.videoCodec()).contains("videoCodec") assertThat(fileUploadResponse.width()).contains(0.0) } @@ -344,25 +335,19 @@ internal class FileUploadResponseTest { val jsonMapper = jsonMapper() val fileUploadResponse = FileUploadResponse.builder() - .addAiTag( - FileUploadResponse.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) + .addAiTag(AiTag.builder().confidence(0.0).name("name").source("source").build()) .audioCodec("audioCodec") .bitRate(0L) .customCoordinates("customCoordinates") .customMetadata( - FileUploadResponse.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - FileUploadResponse.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -394,7 +379,7 @@ internal class FileUploadResponseTest { .exif( Metadata.Exif.builder() .exif( - Metadata.Exif.InnerExif.builder() + Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -475,7 +460,7 @@ internal class FileUploadResponseTest { ) .name("name") .selectedFieldsSchema( - FileUploadResponse.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -500,7 +485,7 @@ internal class FileUploadResponseTest { .addTag("string") .thumbnailUrl("thumbnailUrl") .url("url") - .versionInfo(FileUploadResponse.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/MetadataTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/MetadataTest.kt index aacb71cb..c1387776 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/MetadataTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/MetadataTest.kt @@ -21,7 +21,7 @@ internal class MetadataTest { .exif( Metadata.Exif.builder() .exif( - Metadata.Exif.InnerExif.builder() + Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -108,7 +108,7 @@ internal class MetadataTest { .contains( Metadata.Exif.builder() .exif( - Metadata.Exif.InnerExif.builder() + Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -199,7 +199,7 @@ internal class MetadataTest { .exif( Metadata.Exif.builder() .exif( - Metadata.Exif.InnerExif.builder() + Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt index db1fe903..51cdf7d7 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt @@ -6,7 +6,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 +import com.imagekit.api.models.ExtensionItem import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows @@ -28,10 +28,10 @@ internal class UpdateFileRequestTest { .description("description") .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -40,21 +40,18 @@ internal class UpdateFileRequestTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(ExtensionItem.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags.builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -66,18 +63,16 @@ internal class UpdateFileRequestTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction("Is this a luxury or high-end fashion item?") .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -85,8 +80,7 @@ internal class UpdateFileRequestTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -95,16 +89,13 @@ internal class UpdateFileRequestTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnUnknown.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .SetMetadata .builder() .field("price_range") @@ -112,8 +103,7 @@ internal class UpdateFileRequestTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .UnsetMetadata .builder() .field("price_range") @@ -122,15 +112,13 @@ internal class UpdateFileRequestTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -138,8 +126,7 @@ internal class UpdateFileRequestTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -151,10 +138,8 @@ internal class UpdateFileRequestTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -185,10 +170,10 @@ internal class UpdateFileRequestTest { .description("description") .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -197,22 +182,20 @@ internal class UpdateFileRequestTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING + ExtensionItem.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -230,22 +213,18 @@ internal class UpdateFileRequestTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -253,9 +232,7 @@ internal class UpdateFileRequestTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -264,17 +241,13 @@ internal class UpdateFileRequestTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnUnknown.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .SetMetadata .builder() .field("price_range") @@ -282,9 +255,7 @@ internal class UpdateFileRequestTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .UnsetMetadata .builder() .field("price_range") @@ -293,17 +264,13 @@ internal class UpdateFileRequestTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -311,9 +278,7 @@ internal class UpdateFileRequestTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -325,10 +290,8 @@ internal class UpdateFileRequestTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileCreateEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileCreateEventTest.kt index b64071b7..0a490898 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileCreateEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileCreateEventTest.kt @@ -5,6 +5,11 @@ package com.imagekit.api.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper +import com.imagekit.api.models.AiTag +import com.imagekit.api.models.CustomMetadata +import com.imagekit.api.models.EmbeddedMetadata +import com.imagekit.api.models.SelectedFieldsSchema +import com.imagekit.api.models.VersionInfo import com.imagekit.api.models.files.File import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -22,25 +27,21 @@ internal class FileCreateEventTest { .data( File.builder() .addAiTag( - File.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + AiTag.builder().confidence(0.0).name("name").source("source").build() ) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -54,7 +55,7 @@ internal class FileCreateEventTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -81,7 +82,7 @@ internal class FileCreateEventTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -95,22 +96,20 @@ internal class FileCreateEventTest { assertThat(fileCreateEvent.data()) .isEqualTo( File.builder() - .addAiTag( - File.AiTag.builder().confidence(0.0).name("name").source("source").build() - ) + .addAiTag(AiTag.builder().confidence(0.0).name("name").source("source").build()) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -124,7 +123,7 @@ internal class FileCreateEventTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -151,7 +150,7 @@ internal class FileCreateEventTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -169,25 +168,21 @@ internal class FileCreateEventTest { .data( File.builder() .addAiTag( - File.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + AiTag.builder().confidence(0.0).name("name").source("source").build() ) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -201,7 +196,7 @@ internal class FileCreateEventTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -228,7 +223,7 @@ internal class FileCreateEventTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileUpdateEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileUpdateEventTest.kt index 44862f99..c736ed41 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileUpdateEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileUpdateEventTest.kt @@ -5,6 +5,11 @@ package com.imagekit.api.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper +import com.imagekit.api.models.AiTag +import com.imagekit.api.models.CustomMetadata +import com.imagekit.api.models.EmbeddedMetadata +import com.imagekit.api.models.SelectedFieldsSchema +import com.imagekit.api.models.VersionInfo import com.imagekit.api.models.files.File import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -22,25 +27,21 @@ internal class FileUpdateEventTest { .data( File.builder() .addAiTag( - File.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + AiTag.builder().confidence(0.0).name("name").source("source").build() ) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -54,7 +55,7 @@ internal class FileUpdateEventTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -81,7 +82,7 @@ internal class FileUpdateEventTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -95,22 +96,20 @@ internal class FileUpdateEventTest { assertThat(fileUpdateEvent.data()) .isEqualTo( File.builder() - .addAiTag( - File.AiTag.builder().confidence(0.0).name("name").source("source").build() - ) + .addAiTag(AiTag.builder().confidence(0.0).name("name").source("source").build()) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -124,7 +123,7 @@ internal class FileUpdateEventTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -151,7 +150,7 @@ internal class FileUpdateEventTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -169,25 +168,21 @@ internal class FileUpdateEventTest { .data( File.builder() .addAiTag( - File.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + AiTag.builder().confidence(0.0).name("name").source("source").build() ) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -201,7 +196,7 @@ internal class FileUpdateEventTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -228,7 +223,7 @@ internal class FileUpdateEventTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionCreateEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionCreateEventTest.kt index 29ff3fbb..38ed6986 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionCreateEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionCreateEventTest.kt @@ -5,6 +5,11 @@ package com.imagekit.api.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper +import com.imagekit.api.models.AiTag +import com.imagekit.api.models.CustomMetadata +import com.imagekit.api.models.EmbeddedMetadata +import com.imagekit.api.models.SelectedFieldsSchema +import com.imagekit.api.models.VersionInfo import com.imagekit.api.models.files.File import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -22,25 +27,21 @@ internal class FileVersionCreateEventTest { .data( File.builder() .addAiTag( - File.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + AiTag.builder().confidence(0.0).name("name").source("source").build() ) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -54,7 +55,7 @@ internal class FileVersionCreateEventTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -81,7 +82,7 @@ internal class FileVersionCreateEventTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -95,22 +96,20 @@ internal class FileVersionCreateEventTest { assertThat(fileVersionCreateEvent.data()) .isEqualTo( File.builder() - .addAiTag( - File.AiTag.builder().confidence(0.0).name("name").source("source").build() - ) + .addAiTag(AiTag.builder().confidence(0.0).name("name").source("source").build()) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -124,7 +123,7 @@ internal class FileVersionCreateEventTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -151,7 +150,7 @@ internal class FileVersionCreateEventTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -169,25 +168,21 @@ internal class FileVersionCreateEventTest { .data( File.builder() .addAiTag( - File.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + AiTag.builder().confidence(0.0).name("name").source("source").build() ) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -201,7 +196,7 @@ internal class FileVersionCreateEventTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -228,7 +223,7 @@ internal class FileVersionCreateEventTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt index 754e106d..d6343d92 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt @@ -6,6 +6,11 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.AiTag +import com.imagekit.api.models.CustomMetadata +import com.imagekit.api.models.EmbeddedMetadata +import com.imagekit.api.models.SelectedFieldsSchema +import com.imagekit.api.models.VersionInfo import com.imagekit.api.models.files.File import com.imagekit.api.models.files.Metadata import java.time.OffsetDateTime @@ -573,24 +578,20 @@ internal class UnsafeUnwrapWebhookEventTest { .data( UploadPreTransformSuccessEvent.Data.builder() .addAiTag( - UploadPreTransformSuccessEvent.Data.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + AiTag.builder().confidence(0.0).name("name").source("source").build() ) .audioCodec("audioCodec") .bitRate(0L) .customCoordinates("customCoordinates") .customMetadata( - UploadPreTransformSuccessEvent.Data.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - UploadPreTransformSuccessEvent.Data.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -636,7 +637,7 @@ internal class UnsafeUnwrapWebhookEventTest { .exif( Metadata.Exif.builder() .exif( - Metadata.Exif.InnerExif.builder() + Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -719,7 +720,7 @@ internal class UnsafeUnwrapWebhookEventTest { ) .name("name") .selectedFieldsSchema( - UploadPreTransformSuccessEvent.Data.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -744,12 +745,7 @@ internal class UnsafeUnwrapWebhookEventTest { .addTag("string") .thumbnailUrl("thumbnailUrl") .url("url") - .versionInfo( - UploadPreTransformSuccessEvent.Data.VersionInfo.builder() - .id("id") - .name("name") - .build() - ) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -792,7 +788,7 @@ internal class UnsafeUnwrapWebhookEventTest { .data( UploadPreTransformSuccessEvent.Data.builder() .addAiTag( - UploadPreTransformSuccessEvent.Data.AiTag.builder() + AiTag.builder() .confidence(0.0) .name("name") .source("source") @@ -802,14 +798,14 @@ internal class UnsafeUnwrapWebhookEventTest { .bitRate(0L) .customCoordinates("customCoordinates") .customMetadata( - UploadPreTransformSuccessEvent.Data.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - UploadPreTransformSuccessEvent.Data.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -855,7 +851,7 @@ internal class UnsafeUnwrapWebhookEventTest { .exif( Metadata.Exif.builder() .exif( - Metadata.Exif.InnerExif.builder() + Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -943,7 +939,7 @@ internal class UnsafeUnwrapWebhookEventTest { ) .name("name") .selectedFieldsSchema( - UploadPreTransformSuccessEvent.Data.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -975,12 +971,7 @@ internal class UnsafeUnwrapWebhookEventTest { .addTag("string") .thumbnailUrl("thumbnailUrl") .url("url") - .versionInfo( - UploadPreTransformSuccessEvent.Data.VersionInfo.builder() - .id("id") - .name("name") - .build() - ) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -1324,25 +1315,21 @@ internal class UnsafeUnwrapWebhookEventTest { .data( File.builder() .addAiTag( - File.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + AiTag.builder().confidence(0.0).name("name").source("source").build() ) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -1356,7 +1343,7 @@ internal class UnsafeUnwrapWebhookEventTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1383,7 +1370,7 @@ internal class UnsafeUnwrapWebhookEventTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -1418,7 +1405,7 @@ internal class UnsafeUnwrapWebhookEventTest { .data( File.builder() .addAiTag( - File.AiTag.builder() + AiTag.builder() .confidence(0.0) .name("name") .source("source") @@ -1429,14 +1416,14 @@ internal class UnsafeUnwrapWebhookEventTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -1450,7 +1437,7 @@ internal class UnsafeUnwrapWebhookEventTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1484,7 +1471,7 @@ internal class UnsafeUnwrapWebhookEventTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -1511,25 +1498,21 @@ internal class UnsafeUnwrapWebhookEventTest { .data( File.builder() .addAiTag( - File.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + AiTag.builder().confidence(0.0).name("name").source("source").build() ) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -1543,7 +1526,7 @@ internal class UnsafeUnwrapWebhookEventTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1570,7 +1553,7 @@ internal class UnsafeUnwrapWebhookEventTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -1605,7 +1588,7 @@ internal class UnsafeUnwrapWebhookEventTest { .data( File.builder() .addAiTag( - File.AiTag.builder() + AiTag.builder() .confidence(0.0) .name("name") .source("source") @@ -1616,14 +1599,14 @@ internal class UnsafeUnwrapWebhookEventTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -1637,7 +1620,7 @@ internal class UnsafeUnwrapWebhookEventTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1671,7 +1654,7 @@ internal class UnsafeUnwrapWebhookEventTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -1746,25 +1729,21 @@ internal class UnsafeUnwrapWebhookEventTest { .data( File.builder() .addAiTag( - File.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + AiTag.builder().confidence(0.0).name("name").source("source").build() ) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -1778,7 +1757,7 @@ internal class UnsafeUnwrapWebhookEventTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1805,7 +1784,7 @@ internal class UnsafeUnwrapWebhookEventTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -1841,7 +1820,7 @@ internal class UnsafeUnwrapWebhookEventTest { .data( File.builder() .addAiTag( - File.AiTag.builder() + AiTag.builder() .confidence(0.0) .name("name") .source("source") @@ -1852,14 +1831,14 @@ internal class UnsafeUnwrapWebhookEventTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -1873,7 +1852,7 @@ internal class UnsafeUnwrapWebhookEventTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1907,7 +1886,7 @@ internal class UnsafeUnwrapWebhookEventTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt index 2891f29f..cda13726 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt @@ -6,6 +6,11 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper import com.imagekit.api.errors.ImageKitInvalidDataException +import com.imagekit.api.models.AiTag +import com.imagekit.api.models.CustomMetadata +import com.imagekit.api.models.EmbeddedMetadata +import com.imagekit.api.models.SelectedFieldsSchema +import com.imagekit.api.models.VersionInfo import com.imagekit.api.models.files.File import com.imagekit.api.models.files.Metadata import java.time.OffsetDateTime @@ -571,24 +576,20 @@ internal class UnwrapWebhookEventTest { .data( UploadPreTransformSuccessEvent.Data.builder() .addAiTag( - UploadPreTransformSuccessEvent.Data.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + AiTag.builder().confidence(0.0).name("name").source("source").build() ) .audioCodec("audioCodec") .bitRate(0L) .customCoordinates("customCoordinates") .customMetadata( - UploadPreTransformSuccessEvent.Data.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - UploadPreTransformSuccessEvent.Data.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -634,7 +635,7 @@ internal class UnwrapWebhookEventTest { .exif( Metadata.Exif.builder() .exif( - Metadata.Exif.InnerExif.builder() + Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -717,7 +718,7 @@ internal class UnwrapWebhookEventTest { ) .name("name") .selectedFieldsSchema( - UploadPreTransformSuccessEvent.Data.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -742,12 +743,7 @@ internal class UnwrapWebhookEventTest { .addTag("string") .thumbnailUrl("thumbnailUrl") .url("url") - .versionInfo( - UploadPreTransformSuccessEvent.Data.VersionInfo.builder() - .id("id") - .name("name") - .build() - ) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -790,7 +786,7 @@ internal class UnwrapWebhookEventTest { .data( UploadPreTransformSuccessEvent.Data.builder() .addAiTag( - UploadPreTransformSuccessEvent.Data.AiTag.builder() + AiTag.builder() .confidence(0.0) .name("name") .source("source") @@ -800,14 +796,14 @@ internal class UnwrapWebhookEventTest { .bitRate(0L) .customCoordinates("customCoordinates") .customMetadata( - UploadPreTransformSuccessEvent.Data.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - UploadPreTransformSuccessEvent.Data.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -853,7 +849,7 @@ internal class UnwrapWebhookEventTest { .exif( Metadata.Exif.builder() .exif( - Metadata.Exif.InnerExif.builder() + Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -941,7 +937,7 @@ internal class UnwrapWebhookEventTest { ) .name("name") .selectedFieldsSchema( - UploadPreTransformSuccessEvent.Data.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -973,12 +969,7 @@ internal class UnwrapWebhookEventTest { .addTag("string") .thumbnailUrl("thumbnailUrl") .url("url") - .versionInfo( - UploadPreTransformSuccessEvent.Data.VersionInfo.builder() - .id("id") - .name("name") - .build() - ) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -1320,25 +1311,21 @@ internal class UnwrapWebhookEventTest { .data( File.builder() .addAiTag( - File.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + AiTag.builder().confidence(0.0).name("name").source("source").build() ) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -1352,7 +1339,7 @@ internal class UnwrapWebhookEventTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1379,7 +1366,7 @@ internal class UnwrapWebhookEventTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -1414,7 +1401,7 @@ internal class UnwrapWebhookEventTest { .data( File.builder() .addAiTag( - File.AiTag.builder() + AiTag.builder() .confidence(0.0) .name("name") .source("source") @@ -1425,14 +1412,14 @@ internal class UnwrapWebhookEventTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -1446,7 +1433,7 @@ internal class UnwrapWebhookEventTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1480,7 +1467,7 @@ internal class UnwrapWebhookEventTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -1507,25 +1494,21 @@ internal class UnwrapWebhookEventTest { .data( File.builder() .addAiTag( - File.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + AiTag.builder().confidence(0.0).name("name").source("source").build() ) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -1539,7 +1522,7 @@ internal class UnwrapWebhookEventTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1566,7 +1549,7 @@ internal class UnwrapWebhookEventTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -1601,7 +1584,7 @@ internal class UnwrapWebhookEventTest { .data( File.builder() .addAiTag( - File.AiTag.builder() + AiTag.builder() .confidence(0.0) .name("name") .source("source") @@ -1612,14 +1595,14 @@ internal class UnwrapWebhookEventTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -1633,7 +1616,7 @@ internal class UnwrapWebhookEventTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1667,7 +1650,7 @@ internal class UnwrapWebhookEventTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -1742,25 +1725,21 @@ internal class UnwrapWebhookEventTest { .data( File.builder() .addAiTag( - File.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + AiTag.builder().confidence(0.0).name("name").source("source").build() ) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -1774,7 +1753,7 @@ internal class UnwrapWebhookEventTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1801,7 +1780,7 @@ internal class UnwrapWebhookEventTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -1836,7 +1815,7 @@ internal class UnwrapWebhookEventTest { .data( File.builder() .addAiTag( - File.AiTag.builder() + AiTag.builder() .confidence(0.0) .name("name") .source("source") @@ -1847,14 +1826,14 @@ internal class UnwrapWebhookEventTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -1868,7 +1847,7 @@ internal class UnwrapWebhookEventTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1902,7 +1881,7 @@ internal class UnwrapWebhookEventTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt index c30f3f49..f44367c8 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt @@ -5,6 +5,11 @@ package com.imagekit.api.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper +import com.imagekit.api.models.AiTag +import com.imagekit.api.models.CustomMetadata +import com.imagekit.api.models.EmbeddedMetadata +import com.imagekit.api.models.SelectedFieldsSchema +import com.imagekit.api.models.VersionInfo import com.imagekit.api.models.files.Metadata import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -22,24 +27,20 @@ internal class UploadPreTransformSuccessEventTest { .data( UploadPreTransformSuccessEvent.Data.builder() .addAiTag( - UploadPreTransformSuccessEvent.Data.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + AiTag.builder().confidence(0.0).name("name").source("source").build() ) .audioCodec("audioCodec") .bitRate(0L) .customCoordinates("customCoordinates") .customMetadata( - UploadPreTransformSuccessEvent.Data.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - UploadPreTransformSuccessEvent.Data.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -85,7 +86,7 @@ internal class UploadPreTransformSuccessEventTest { .exif( Metadata.Exif.builder() .exif( - Metadata.Exif.InnerExif.builder() + Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -168,7 +169,7 @@ internal class UploadPreTransformSuccessEventTest { ) .name("name") .selectedFieldsSchema( - UploadPreTransformSuccessEvent.Data.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -193,12 +194,7 @@ internal class UploadPreTransformSuccessEventTest { .addTag("string") .thumbnailUrl("thumbnailUrl") .url("url") - .versionInfo( - UploadPreTransformSuccessEvent.Data.VersionInfo.builder() - .id("id") - .name("name") - .build() - ) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -218,25 +214,19 @@ internal class UploadPreTransformSuccessEventTest { assertThat(uploadPreTransformSuccessEvent.data()) .isEqualTo( UploadPreTransformSuccessEvent.Data.builder() - .addAiTag( - UploadPreTransformSuccessEvent.Data.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() - ) + .addAiTag(AiTag.builder().confidence(0.0).name("name").source("source").build()) .audioCodec("audioCodec") .bitRate(0L) .customCoordinates("customCoordinates") .customMetadata( - UploadPreTransformSuccessEvent.Data.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - UploadPreTransformSuccessEvent.Data.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -279,7 +269,7 @@ internal class UploadPreTransformSuccessEventTest { .exif( Metadata.Exif.builder() .exif( - Metadata.Exif.InnerExif.builder() + Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -360,7 +350,7 @@ internal class UploadPreTransformSuccessEventTest { ) .name("name") .selectedFieldsSchema( - UploadPreTransformSuccessEvent.Data.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -385,12 +375,7 @@ internal class UploadPreTransformSuccessEventTest { .addTag("string") .thumbnailUrl("thumbnailUrl") .url("url") - .versionInfo( - UploadPreTransformSuccessEvent.Data.VersionInfo.builder() - .id("id") - .name("name") - .build() - ) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -415,24 +400,20 @@ internal class UploadPreTransformSuccessEventTest { .data( UploadPreTransformSuccessEvent.Data.builder() .addAiTag( - UploadPreTransformSuccessEvent.Data.AiTag.builder() - .confidence(0.0) - .name("name") - .source("source") - .build() + AiTag.builder().confidence(0.0).name("name").source("source").build() ) .audioCodec("audioCodec") .bitRate(0L) .customCoordinates("customCoordinates") .customMetadata( - UploadPreTransformSuccessEvent.Data.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - UploadPreTransformSuccessEvent.Data.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -478,7 +459,7 @@ internal class UploadPreTransformSuccessEventTest { .exif( Metadata.Exif.builder() .exif( - Metadata.Exif.InnerExif.builder() + Metadata.Exif.ExifDetails.builder() .apertureValue(0.0) .colorSpace(0L) .createDate("CreateDate") @@ -561,7 +542,7 @@ internal class UploadPreTransformSuccessEventTest { ) .name("name") .selectedFieldsSchema( - UploadPreTransformSuccessEvent.Data.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -586,12 +567,7 @@ internal class UploadPreTransformSuccessEventTest { .addTag("string") .thumbnailUrl("thumbnailUrl") .url("url") - .versionInfo( - UploadPreTransformSuccessEvent.Data.VersionInfo.builder() - .id("id") - .name("name") - .build() - ) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt index 15ebd90e..6d1b06d4 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt @@ -22,7 +22,7 @@ import com.imagekit.api.errors.RateLimitException import com.imagekit.api.errors.UnauthorizedException import com.imagekit.api.errors.UnexpectedStatusCodeException import com.imagekit.api.errors.UnprocessableEntityException -import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 +import com.imagekit.api.models.ExtensionItem import com.imagekit.api.models.files.FileUploadParams import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.entry @@ -89,10 +89,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -101,22 +101,21 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -134,24 +133,18 @@ internal class ErrorHandlingTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -159,10 +152,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -171,17 +161,14 @@ internal class ErrorHandlingTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .SetMetadata .builder() @@ -190,9 +177,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .UnsetMetadata .builder() @@ -202,18 +187,13 @@ internal class ErrorHandlingTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -221,10 +201,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -236,10 +213,8 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -261,16 +236,17 @@ internal class ErrorHandlingTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + FileUploadParams.UploadTransformation.Post.Abs.Protocol + .DASH ) .value("sr-240_360_480_720_1080") .build() @@ -318,10 +294,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -330,22 +306,21 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -363,24 +338,18 @@ internal class ErrorHandlingTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -388,10 +357,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -400,17 +366,14 @@ internal class ErrorHandlingTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .SetMetadata .builder() @@ -419,9 +382,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .UnsetMetadata .builder() @@ -431,18 +392,13 @@ internal class ErrorHandlingTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -450,10 +406,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -465,10 +418,8 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -490,16 +441,17 @@ internal class ErrorHandlingTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + FileUploadParams.UploadTransformation.Post.Abs.Protocol + .DASH ) .value("sr-240_360_480_720_1080") .build() @@ -547,10 +499,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -559,22 +511,21 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -592,24 +543,18 @@ internal class ErrorHandlingTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -617,10 +562,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -629,17 +571,14 @@ internal class ErrorHandlingTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .SetMetadata .builder() @@ -648,9 +587,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .UnsetMetadata .builder() @@ -660,18 +597,13 @@ internal class ErrorHandlingTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -679,10 +611,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -694,10 +623,8 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -719,16 +646,17 @@ internal class ErrorHandlingTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + FileUploadParams.UploadTransformation.Post.Abs.Protocol + .DASH ) .value("sr-240_360_480_720_1080") .build() @@ -776,10 +704,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -788,22 +716,21 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -821,24 +748,18 @@ internal class ErrorHandlingTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -846,10 +767,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -858,17 +776,14 @@ internal class ErrorHandlingTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .SetMetadata .builder() @@ -877,9 +792,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .UnsetMetadata .builder() @@ -889,18 +802,13 @@ internal class ErrorHandlingTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -908,10 +816,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -923,10 +828,8 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -948,16 +851,17 @@ internal class ErrorHandlingTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + FileUploadParams.UploadTransformation.Post.Abs.Protocol + .DASH ) .value("sr-240_360_480_720_1080") .build() @@ -1005,10 +909,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1017,22 +921,21 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -1050,24 +953,18 @@ internal class ErrorHandlingTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -1075,10 +972,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -1087,17 +981,14 @@ internal class ErrorHandlingTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .SetMetadata .builder() @@ -1106,9 +997,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .UnsetMetadata .builder() @@ -1118,18 +1007,13 @@ internal class ErrorHandlingTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -1137,10 +1021,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -1152,10 +1033,8 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -1177,16 +1056,17 @@ internal class ErrorHandlingTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + FileUploadParams.UploadTransformation.Post.Abs.Protocol + .DASH ) .value("sr-240_360_480_720_1080") .build() @@ -1234,10 +1114,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1246,22 +1126,21 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -1279,24 +1158,18 @@ internal class ErrorHandlingTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -1304,10 +1177,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -1316,17 +1186,14 @@ internal class ErrorHandlingTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .SetMetadata .builder() @@ -1335,9 +1202,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .UnsetMetadata .builder() @@ -1347,18 +1212,13 @@ internal class ErrorHandlingTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -1366,10 +1226,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -1381,10 +1238,8 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -1406,16 +1261,17 @@ internal class ErrorHandlingTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + FileUploadParams.UploadTransformation.Post.Abs.Protocol + .DASH ) .value("sr-240_360_480_720_1080") .build() @@ -1463,10 +1319,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1475,22 +1331,21 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -1508,24 +1363,18 @@ internal class ErrorHandlingTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -1533,10 +1382,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -1545,17 +1391,14 @@ internal class ErrorHandlingTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .SetMetadata .builder() @@ -1564,9 +1407,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .UnsetMetadata .builder() @@ -1576,18 +1417,13 @@ internal class ErrorHandlingTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -1595,10 +1431,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -1610,10 +1443,8 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -1635,16 +1466,17 @@ internal class ErrorHandlingTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + FileUploadParams.UploadTransformation.Post.Abs.Protocol + .DASH ) .value("sr-240_360_480_720_1080") .build() @@ -1692,10 +1524,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1704,22 +1536,21 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -1737,24 +1568,18 @@ internal class ErrorHandlingTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -1762,10 +1587,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -1774,17 +1596,14 @@ internal class ErrorHandlingTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .SetMetadata .builder() @@ -1793,9 +1612,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .UnsetMetadata .builder() @@ -1805,18 +1622,13 @@ internal class ErrorHandlingTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -1824,10 +1636,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -1839,10 +1648,8 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -1864,16 +1671,17 @@ internal class ErrorHandlingTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + FileUploadParams.UploadTransformation.Post.Abs.Protocol + .DASH ) .value("sr-240_360_480_720_1080") .build() @@ -1921,10 +1729,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -1933,22 +1741,21 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -1966,24 +1773,18 @@ internal class ErrorHandlingTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -1991,10 +1792,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -2003,17 +1801,14 @@ internal class ErrorHandlingTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .SetMetadata .builder() @@ -2022,9 +1817,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .UnsetMetadata .builder() @@ -2034,18 +1827,13 @@ internal class ErrorHandlingTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -2053,10 +1841,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -2068,10 +1853,8 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -2093,16 +1876,17 @@ internal class ErrorHandlingTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + FileUploadParams.UploadTransformation.Post.Abs.Protocol + .DASH ) .value("sr-240_360_480_720_1080") .build() @@ -2150,10 +1934,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -2162,22 +1946,21 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -2195,24 +1978,18 @@ internal class ErrorHandlingTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -2220,10 +1997,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -2232,17 +2006,14 @@ internal class ErrorHandlingTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .SetMetadata .builder() @@ -2251,9 +2022,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .UnsetMetadata .builder() @@ -2263,18 +2032,13 @@ internal class ErrorHandlingTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -2282,10 +2046,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -2297,10 +2058,8 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -2322,16 +2081,17 @@ internal class ErrorHandlingTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + FileUploadParams.UploadTransformation.Post.Abs.Protocol + .DASH ) .value("sr-240_360_480_720_1080") .build() @@ -2379,10 +2139,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -2391,22 +2151,21 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -2424,24 +2183,18 @@ internal class ErrorHandlingTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -2449,10 +2202,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -2461,17 +2211,14 @@ internal class ErrorHandlingTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .SetMetadata .builder() @@ -2480,9 +2227,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .UnsetMetadata .builder() @@ -2492,18 +2237,13 @@ internal class ErrorHandlingTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -2511,10 +2251,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -2526,10 +2263,8 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -2551,16 +2286,17 @@ internal class ErrorHandlingTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + FileUploadParams.UploadTransformation.Post.Abs.Protocol + .DASH ) .value("sr-240_360_480_720_1080") .build() @@ -2608,10 +2344,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -2620,22 +2356,21 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -2653,24 +2388,18 @@ internal class ErrorHandlingTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -2678,10 +2407,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -2690,17 +2416,14 @@ internal class ErrorHandlingTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .SetMetadata .builder() @@ -2709,9 +2432,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .UnsetMetadata .builder() @@ -2721,18 +2442,13 @@ internal class ErrorHandlingTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -2740,10 +2456,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -2755,10 +2468,8 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -2780,16 +2491,17 @@ internal class ErrorHandlingTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + FileUploadParams.UploadTransformation.Post.Abs.Protocol + .DASH ) .value("sr-240_360_480_720_1080") .build() @@ -2837,10 +2549,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -2849,22 +2561,21 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -2882,24 +2593,18 @@ internal class ErrorHandlingTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -2907,10 +2612,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -2919,17 +2621,14 @@ internal class ErrorHandlingTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .SetMetadata .builder() @@ -2938,9 +2637,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .UnsetMetadata .builder() @@ -2950,18 +2647,13 @@ internal class ErrorHandlingTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -2969,10 +2661,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -2984,10 +2673,8 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -3009,16 +2696,17 @@ internal class ErrorHandlingTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + FileUploadParams.UploadTransformation.Post.Abs.Protocol + .DASH ) .value("sr-240_360_480_720_1080") .build() @@ -3066,10 +2754,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -3078,22 +2766,21 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -3111,24 +2798,18 @@ internal class ErrorHandlingTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -3136,10 +2817,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -3148,17 +2826,14 @@ internal class ErrorHandlingTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .SetMetadata .builder() @@ -3167,9 +2842,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .UnsetMetadata .builder() @@ -3179,18 +2852,13 @@ internal class ErrorHandlingTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -3198,10 +2866,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -3213,10 +2878,8 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -3238,16 +2901,17 @@ internal class ErrorHandlingTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + FileUploadParams.UploadTransformation.Post.Abs.Protocol + .DASH ) .value("sr-240_360_480_720_1080") .build() @@ -3295,10 +2959,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -3307,22 +2971,21 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -3340,24 +3003,18 @@ internal class ErrorHandlingTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -3365,10 +3022,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -3377,17 +3031,14 @@ internal class ErrorHandlingTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .SetMetadata .builder() @@ -3396,9 +3047,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .UnsetMetadata .builder() @@ -3408,18 +3057,13 @@ internal class ErrorHandlingTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -3427,10 +3071,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -3442,10 +3083,8 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -3467,16 +3106,17 @@ internal class ErrorHandlingTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + FileUploadParams.UploadTransformation.Post.Abs.Protocol + .DASH ) .value("sr-240_360_480_720_1080") .build() @@ -3524,10 +3164,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -3536,22 +3176,21 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -3569,24 +3208,18 @@ internal class ErrorHandlingTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -3594,10 +3227,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -3606,17 +3236,14 @@ internal class ErrorHandlingTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .SetMetadata .builder() @@ -3625,9 +3252,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .UnsetMetadata .builder() @@ -3637,18 +3262,13 @@ internal class ErrorHandlingTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -3656,10 +3276,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -3671,10 +3288,8 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -3696,16 +3311,17 @@ internal class ErrorHandlingTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + FileUploadParams.UploadTransformation.Post.Abs.Protocol + .DASH ) .value("sr-240_360_480_720_1080") .build() @@ -3751,10 +3367,10 @@ internal class ErrorHandlingTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -3763,22 +3379,21 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -3796,24 +3411,18 @@ internal class ErrorHandlingTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -3821,10 +3430,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -3833,17 +3439,14 @@ internal class ErrorHandlingTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .SetMetadata .builder() @@ -3852,9 +3455,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo + ExtensionItem.AiTasks.Task.YesNo .OnUnknown .UnsetMetadata .builder() @@ -3864,18 +3465,13 @@ internal class ErrorHandlingTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -3883,10 +3479,7 @@ internal class ErrorHandlingTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks - .Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -3898,10 +3491,8 @@ internal class ErrorHandlingTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -3923,16 +3514,17 @@ internal class ErrorHandlingTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + FileUploadParams.UploadTransformation.Post.Abs.Protocol + .DASH ) .value("sr-240_360_480_720_1080") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt index 0f2117e7..26f11219 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt @@ -15,7 +15,7 @@ import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.imagekit.api.client.ImageKitClient import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 +import com.imagekit.api.models.ExtensionItem import com.imagekit.api.models.files.FileUploadParams import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Disabled @@ -61,10 +61,10 @@ internal class ServiceParamsTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -73,21 +73,18 @@ internal class ServiceParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) - .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING - ) + .name(ExtensionItem.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags.builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -99,18 +96,16 @@ internal class ServiceParamsTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction("Is this a luxury or high-end fashion item?") .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -118,8 +113,7 @@ internal class ServiceParamsTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -128,16 +122,13 @@ internal class ServiceParamsTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnUnknown.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .SetMetadata .builder() .field("price_range") @@ -145,8 +136,7 @@ internal class ServiceParamsTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .UnsetMetadata .builder() .field("price_range") @@ -155,15 +145,13 @@ internal class ServiceParamsTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -171,8 +159,7 @@ internal class ServiceParamsTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -184,10 +171,8 @@ internal class ServiceParamsTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -209,15 +194,17 @@ internal class ServiceParamsTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() - .protocol(FileUploadParams.Transformation.Post.Abs.Protocol.DASH) + FileUploadParams.UploadTransformation.Post.Abs.builder() + .protocol( + FileUploadParams.UploadTransformation.Post.Abs.Protocol.DASH + ) .value("sr-240_360_480_720_1080") .build() ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt index e7ab6ff2..b9ff7128 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt @@ -32,13 +32,13 @@ internal class CustomMetadataFieldServiceAsyncTest { .defaultValueOfMixed( listOf( CustomMetadataFieldCreateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent8 + .DefaultValueItem .ofBool(true), CustomMetadataFieldCreateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent8 + .DefaultValueItem .ofNumber(10.0), CustomMetadataFieldCreateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent8 + .DefaultValueItem .ofString("Hello"), ) ) @@ -96,13 +96,13 @@ internal class CustomMetadataFieldServiceAsyncTest { .defaultValueOfMixed( listOf( CustomMetadataFieldUpdateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent9 + .DefaultValueItem .ofBool(true), CustomMetadataFieldUpdateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent9 + .DefaultValueItem .ofNumber(10.0), CustomMetadataFieldUpdateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent9 + .DefaultValueItem .ofString("Hello"), ) ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt index f9d0c9ab..e36a222e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -4,7 +4,7 @@ package com.imagekit.api.services.async import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 +import com.imagekit.api.models.ExtensionItem import com.imagekit.api.models.files.FileCopyParams import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileRenameParams @@ -42,11 +42,10 @@ internal class FileServiceAsyncTest { .description("description") .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options - .builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -55,35 +54,31 @@ internal class FileServiceAsyncTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension - .Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension - .Name + ExtensionItem.AutoTaggingExtension.Name .AWS_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible?" ) @@ -94,8 +89,8 @@ internal class FileServiceAsyncTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder() .id("ext_abc123") .build() ), @@ -241,10 +236,10 @@ internal class FileServiceAsyncTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -253,22 +248,20 @@ internal class FileServiceAsyncTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING + ExtensionItem.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -286,22 +279,18 @@ internal class FileServiceAsyncTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -309,9 +298,7 @@ internal class FileServiceAsyncTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -320,17 +307,13 @@ internal class FileServiceAsyncTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnUnknown.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .SetMetadata .builder() .field("price_range") @@ -338,9 +321,7 @@ internal class FileServiceAsyncTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .UnsetMetadata .builder() .field("price_range") @@ -349,17 +330,13 @@ internal class FileServiceAsyncTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -367,9 +344,7 @@ internal class FileServiceAsyncTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -381,10 +356,8 @@ internal class FileServiceAsyncTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -406,16 +379,16 @@ internal class FileServiceAsyncTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + FileUploadParams.UploadTransformation.Post.Abs.Protocol.DASH ) .value("sr-240_360_480_720_1080") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt index 9ac39ec8..e6332630 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt @@ -4,7 +4,7 @@ package com.imagekit.api.services.async.beta.v2 import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 +import com.imagekit.api.models.ExtensionItem import com.imagekit.api.models.beta.v2.files.FileUploadParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -38,10 +38,10 @@ internal class FileServiceAsyncTest { .description("Running shoes") .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -50,22 +50,20 @@ internal class FileServiceAsyncTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING + ExtensionItem.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -83,22 +81,18 @@ internal class FileServiceAsyncTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -106,9 +100,7 @@ internal class FileServiceAsyncTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -117,17 +109,13 @@ internal class FileServiceAsyncTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnUnknown.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .SetMetadata .builder() .field("price_range") @@ -135,9 +123,7 @@ internal class FileServiceAsyncTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .UnsetMetadata .builder() .field("price_range") @@ -146,17 +132,13 @@ internal class FileServiceAsyncTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -164,9 +146,7 @@ internal class FileServiceAsyncTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -178,10 +158,8 @@ internal class FileServiceAsyncTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -201,16 +179,16 @@ internal class FileServiceAsyncTest { ) .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + FileUploadParams.UploadTransformation.Post.Abs.Protocol.DASH ) .value("sr-240_360_480_720_1080") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt index 1b11abc7..095789a4 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt @@ -32,13 +32,13 @@ internal class CustomMetadataFieldServiceTest { .defaultValueOfMixed( listOf( CustomMetadataFieldCreateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent8 + .DefaultValueItem .ofBool(true), CustomMetadataFieldCreateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent8 + .DefaultValueItem .ofNumber(10.0), CustomMetadataFieldCreateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent8 + .DefaultValueItem .ofString("Hello"), ) ) @@ -95,13 +95,13 @@ internal class CustomMetadataFieldServiceTest { .defaultValueOfMixed( listOf( CustomMetadataFieldUpdateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent9 + .DefaultValueItem .ofBool(true), CustomMetadataFieldUpdateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent9 + .DefaultValueItem .ofNumber(10.0), CustomMetadataFieldUpdateParams.Schema.DefaultValue - .UnnamedSchemaWithArrayParent9 + .DefaultValueItem .ofString("Hello"), ) ) diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt index 477c11b0..e21ee937 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt @@ -4,7 +4,7 @@ package com.imagekit.api.services.blocking import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 +import com.imagekit.api.models.ExtensionItem import com.imagekit.api.models.files.FileCopyParams import com.imagekit.api.models.files.FileMoveParams import com.imagekit.api.models.files.FileRenameParams @@ -42,11 +42,10 @@ internal class FileServiceTest { .description("description") .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options - .builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -55,35 +54,31 @@ internal class FileServiceTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension - .Name + ExtensionItem.AutoTaggingExtension.Name .GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension - .Name + ExtensionItem.AutoTaggingExtension.Name .AWS_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible?" ) @@ -94,8 +89,8 @@ internal class FileServiceTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder() .id("ext_abc123") .build() ), @@ -234,10 +229,10 @@ internal class FileServiceTest { .expire(0L) .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -246,22 +241,20 @@ internal class FileServiceTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING + ExtensionItem.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -279,22 +272,18 @@ internal class FileServiceTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -302,9 +291,7 @@ internal class FileServiceTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -313,17 +300,13 @@ internal class FileServiceTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnUnknown.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .SetMetadata .builder() .field("price_range") @@ -331,9 +314,7 @@ internal class FileServiceTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .UnsetMetadata .builder() .field("price_range") @@ -342,17 +323,13 @@ internal class FileServiceTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -360,9 +337,7 @@ internal class FileServiceTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -374,10 +349,8 @@ internal class FileServiceTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -399,16 +372,16 @@ internal class FileServiceTest { .signature("signature") .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + FileUploadParams.UploadTransformation.Post.Abs.Protocol.DASH ) .value("sr-240_360_480_720_1080") .build() diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt index 63433f0d..0870287b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt @@ -4,7 +4,7 @@ package com.imagekit.api.services.blocking.beta.v2 import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 +import com.imagekit.api.models.ExtensionItem import com.imagekit.api.models.beta.v2.files.FileUploadParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -38,10 +38,10 @@ internal class FileServiceTest { .description("Running shoes") .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -50,22 +50,20 @@ internal class FileServiceTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(5L) .minConfidence(95L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING + ExtensionItem.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible in this image?" ) @@ -83,22 +81,18 @@ internal class FileServiceTest { .build() ) .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo.builder() + ExtensionItem.AiTasks.Task.YesNo.builder() .instruction( "Is this a luxury or high-end fashion item?" ) .onNo( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnNo - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnNo.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .SetMetadata .builder() .field("price_range") @@ -106,9 +100,7 @@ internal class FileServiceTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnNo + ExtensionItem.AiTasks.Task.YesNo.OnNo .UnsetMetadata .builder() .field("price_range") @@ -117,17 +109,13 @@ internal class FileServiceTest { .build() ) .onUnknown( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnUnknown - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnUnknown.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .SetMetadata .builder() .field("price_range") @@ -135,9 +123,7 @@ internal class FileServiceTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnUnknown + ExtensionItem.AiTasks.Task.YesNo.OnUnknown .UnsetMetadata .builder() .field("price_range") @@ -146,17 +132,13 @@ internal class FileServiceTest { .build() ) .onYes( - UnnamedSchemaWithArrayParent4.AiTasks.Task.YesNo - .OnYes - .builder() + ExtensionItem.AiTasks.Task.YesNo.OnYes.builder() .addAddTag("luxury") .addAddTag("premium") .addRemoveTag("budget") .addRemoveTag("affordable") .addSetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .SetMetadata .builder() .field("price_range") @@ -164,9 +146,7 @@ internal class FileServiceTest { .build() ) .addUnsetMetadata( - UnnamedSchemaWithArrayParent4.AiTasks.Task - .YesNo - .OnYes + ExtensionItem.AiTasks.Task.YesNo.OnYes .UnsetMetadata .builder() .field("price_range") @@ -178,10 +158,8 @@ internal class FileServiceTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) @@ -201,16 +179,16 @@ internal class FileServiceTest { ) .tags(listOf("t-shirt", "round-neck", "men")) .transformation( - FileUploadParams.Transformation.builder() + FileUploadParams.UploadTransformation.builder() .addPost( - FileUploadParams.Transformation.Post.Thumbnail.builder() + FileUploadParams.UploadTransformation.Post.Thumbnail.builder() .value("w-150,h-150") .build() ) .addPost( - FileUploadParams.Transformation.Post.Abs.builder() + FileUploadParams.UploadTransformation.Post.Abs.builder() .protocol( - FileUploadParams.Transformation.Post.Abs.Protocol.DASH + FileUploadParams.UploadTransformation.Post.Abs.Protocol.DASH ) .value("sr-240_360_480_720_1080") .build() diff --git a/image-kit-java-example/src/main/java/com/imagekit/api/example/Main.java b/image-kit-java-example/src/main/java/com/imagekit/api/example/Main.java new file mode 100644 index 00000000..9c07ef84 --- /dev/null +++ b/image-kit-java-example/src/main/java/com/imagekit/api/example/Main.java @@ -0,0 +1,117 @@ +package com.imagekit.api.example; + +import com.imagekit.api.client.ImageKitClient; +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import com.imagekit.api.models.ExtensionItem; +import com.imagekit.api.models.ExtensionItem.AiTasks.Task.YesNo; +import com.imagekit.api.models.ExtensionItem.AiTasks.Task.YesNo.OnNo; +import com.imagekit.api.models.ExtensionItem.AiTasks.Task.YesNo.OnYes; +import com.imagekit.api.models.files.FileUploadParams; +import com.imagekit.api.models.files.FileUploadResponse; +import java.io.IOException; +import java.io.InputStream; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +public final class Main { + public static void main(String[] args) throws IOException, URISyntaxException { + // Initialize the client using the IMAGEKIT_PRIVATE_KEY environment variable + ImageKitClient client = ImageKitOkHttpClient.builder().fromEnv().build(); + + // Resolve the sample image bundled in src/main/resources/test.png + Path filePath; + if (args.length > 0) { + filePath = Paths.get(args[0]); + } else { + filePath = Paths.get(Main.class.getResource("/test.png").toURI()); + } + System.out.println("Using file: " + filePath); + System.out.println(); + + // --- Example 1: Upload using Path --- + System.out.println("=== Upload using Path ==="); + FileUploadParams pathParams = FileUploadParams.builder() + .fileName("path-upload.jpg") + .file(filePath) + .folder("/java-sdk-testing") + .build(); + FileUploadResponse pathResponse = client.files().upload(pathParams); + System.out.println("Uploaded: " + pathResponse.name()); + System.out.println("URL: " + pathResponse.url()); + System.out.println("File ID: " + pathResponse.fileId()); + System.out.println(); + + // --- Example 2: Upload using InputStream --- + System.out.println("=== Upload using InputStream ==="); + InputStream imageStream = Main.class.getResourceAsStream("/test.png"); + FileUploadParams streamParams = FileUploadParams.builder() + .fileName("stream-upload.jpg") + .file(imageStream) + .folder("/java-sdk-testing") + .build(); + FileUploadResponse streamResponse = client.files().upload(streamParams); + System.out.println("Uploaded: " + streamResponse.name()); + System.out.println("URL: " + streamResponse.url()); + System.out.println("File ID: " + streamResponse.fileId()); + System.out.println(); + + // --- Example 3: Upload using byte[] --- + System.out.println("=== Upload using byte[] ==="); + byte[] fileBytes = Files.readAllBytes(filePath); + FileUploadParams bytesParams = FileUploadParams.builder() + .fileName("bytes-upload.jpg") + .file(fileBytes) + .folder("/java-sdk-testing") + .build(); + FileUploadResponse bytesResponse = client.files().upload(bytesParams); + System.out.println("Uploaded: " + bytesResponse.name()); + System.out.println("URL: " + bytesResponse.url()); + System.out.println("File ID: " + bytesResponse.fileId()); + System.out.println(); + + // --- Example 4: Upload with tags and folder --- + System.out.println("=== Upload with tags and folder ==="); + FileUploadParams taggedParams = FileUploadParams.builder() + .fileName("tagged-upload.jpg") + .file(filePath) + .folder("/java-sdk-testing") + .addTag("example") + .addTag("java-sdk") + .useUniqueFileName(false) + .build(); + FileUploadResponse taggedResponse = client.files().upload(taggedParams); + System.out.println("Uploaded: " + taggedResponse.name()); + System.out.println("URL: " + taggedResponse.url()); + System.out.println("File ID: " + taggedResponse.fileId()); + System.out.println("Tags: " + taggedResponse.tags()); + + System.out.println(); + + // --- Example 5: Upload with AI tasks extension --- + System.out.println("=== Upload with AI tasks extension ==="); + FileUploadParams aiParams = FileUploadParams.builder() + .fileName("ai-task-upload.png") + .file(filePath) + .folder("/java-sdk-testing") + .addExtension(ExtensionItem.AiTasks.builder() + .addTask(YesNo.builder() + .instruction("Does this image contain a person?") + .onYes(OnYes.builder().addAddTag("has-person").build()) + .onNo(OnNo.builder().addAddTag("no-person").build()) + .build()) + .addSelectTagsTask("What objects are visible in this image?") + .build()) + .addTag("ai-processed") + .build(); + FileUploadResponse aiResponse = client.files().upload(aiParams); + System.out.println("Uploaded: " + aiResponse.name()); + System.out.println("URL: " + aiResponse.url()); + System.out.println("File ID: " + aiResponse.fileId()); + System.out.println("Extensions: " + aiResponse.extensionStatus()); + + System.out.println(); + System.out.println("All uploads completed successfully!"); + } +} diff --git a/image-kit-java-lib/build.gradle.kts b/image-kit-java-lib/build.gradle.kts new file mode 100644 index 00000000..dc97c82e --- /dev/null +++ b/image-kit-java-lib/build.gradle.kts @@ -0,0 +1,13 @@ +plugins { + id("image-kit.kotlin") +} + +dependencies { + api(project(":image-kit-java-core")) + + testImplementation(kotlin("test")) + testImplementation(project(":image-kit-java-client-okhttp")) + testImplementation("org.assertj:assertj-core:3.27.7") + testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") + testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3") +} diff --git a/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperAdvancedTransformationsTest.kt b/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperAdvancedTransformationsTest.kt new file mode 100644 index 00000000..9ed906c2 --- /dev/null +++ b/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperAdvancedTransformationsTest.kt @@ -0,0 +1,516 @@ +package com.imagekit.api.lib + +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.models.SrcOptions +import com.imagekit.api.models.StreamingResolution +import com.imagekit.api.models.Transformation +import com.imagekit.api.models.TransformationPosition +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class HelperAdvancedTransformationsTest { + + private val privateKey = "My Private API Key" + private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() + + // AI Transformation Tests + @Test + fun `should generate the correct URL for AI background removal when set to true`() { + val transformation = + listOf( + Transformation.builder() + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-bgremove") + } + + @Test + fun `should generate the correct URL for external AI background removal when set to true`() { + val transformation = + listOf( + Transformation.builder() + .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-removedotbg") + } + + @Test + fun `should generate the correct URL when AI drop shadow transformation is set to true`() { + val transformation = listOf(Transformation.builder().aiDropShadowTrue().build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-dropshadow") + } + + @Test + fun `should generate the correct URL when gradient transformation is set to true`() { + val transformation = listOf(Transformation.builder().gradientTrue().build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-gradient") + } + + @Test + fun `should not apply AI background removal when value is not true`() { + val transformation = listOf(Transformation.builder().build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg") + } + + @Test + fun `should not apply external AI background removal when value is not true`() { + val transformation = listOf(Transformation.builder().build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg") + } + + @Test + fun `should handle AI transformations with parameters`() { + val transformation = + listOf(Transformation.builder().aiDropShadow("custom-shadow-params").build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-dropshadow-custom-shadow-params" + ) + } + + @Test + fun `should handle gradient with parameters`() { + val transformation = + listOf(Transformation.builder().gradient("ld-top_from-green_to-00FF0010_sp-1").build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-gradient-ld-top_from-green_to-00FF0010_sp-1" + ) + } + + @Test + fun `should combine AI transformations with regular transformations`() { + val transformation = + listOf( + Transformation.builder() + .width(300.0) + .height(200.0) + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=w-300,h-200,e-bgremove" + ) + } + + @Test + fun `should handle multiple AI transformations`() { + val transformation = + listOf( + Transformation.builder() + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .aiDropShadowTrue() + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-bgremove,e-dropshadow" + ) + } + + // Parameter-specific tests + @Test + fun `should generate the correct URL for width transformation when provided with a number value`() { + val transformation = listOf(Transformation.builder().width(400.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=w-400") + } + + @Test + fun `should generate the correct URL for height transformation when provided with a string value`() { + val transformation = listOf(Transformation.builder().height("300").build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=h-300") + } + + @Test + fun `should generate the correct URL for aspectRatio transformation when provided with colon format`() { + val transformation = listOf(Transformation.builder().aspectRatio("4:3").build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=ar-4:3") + } + + @Test + fun `should generate the correct URL for quality transformation when provided with a number value`() { + val transformation = listOf(Transformation.builder().quality(80.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=q-80") + } + + @Test + fun `should skip transformation parameters that are undefined or empty`() { + val transformation = listOf(Transformation.builder().width(300.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=w-300") + } + + @Test + fun `should handle boolean transformation values`() { + val transformation = listOf(Transformation.builder().trimTrue().build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=t-true") + } + + @Test + fun `should handle transformation parameter with empty string value`() { + val transformation = listOf(Transformation.builder().defaultImage("").build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg") + } + + @Test + fun `should handle complex transformation combinations`() { + val transformation = + listOf( + Transformation.builder() + .width(300.0) + .height(200.0) + .quality(85.0) + .border("5_FF0000") + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=w-300,h-200,q-85,b-5_FF0000" + ) + } + + @Test + fun `should generate the correct URL for radius transformation with string value for per corner radius`() { + val transformation = listOf(Transformation.builder().radius("10_10_max_10").build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=r-10_10_max_10") + } + + @Test + fun `should generate the correct URL with many transformations, including video and AI transforms`() { + val transformation = + listOf( + Transformation.builder() + .height(300.0) + .width(400.0) + .aspectRatio("4-3") + .quality(40.0) + .crop(Transformation.Crop.FORCE) + .cropMode(Transformation.CropMode.EXTRACT) + .focus("left") + .format(Transformation.Format.JPEG) + .radius(50.0) + .background("A94D34") + .border("5-A94D34") + .rotation(90.0) + .blur(10.0) + .named("some_name") + .progressive(true) + .lossless(true) + .trim(5.0) + .metadata(true) + .colorProfile(true) + .defaultImage("/folder/file.jpg/") + .dpr(3.0) + .x(10.0) + .y(20.0) + .xCenter(30.0) + .yCenter(40.0) + .flip(Transformation.Flip.H) + .opacity(0.8) + .zoom(2.0) + .videoCodec(Transformation.VideoCodec.H264) + .audioCodec(Transformation.AudioCodec.AAC) + .startOffset(5.0) + .endOffset(15.0) + .duration(10.0) + .streamingResolutions( + listOf(StreamingResolution._1440, StreamingResolution._1080) + ) + .grayscale(Transformation.Grayscale.TRUE) + .aiUpscale(Transformation.AiUpscale.TRUE) + .aiRetouch(Transformation.AiRetouch.TRUE) + .aiVariation(Transformation.AiVariation.TRUE) + .aiDropShadowTrue() + .aiChangeBackground("prompt-car") + .aiEdit("prompt-make it vintage") + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .contrastStretch(Transformation.ContrastStretch.TRUE) + .shadow("bl-15_st-40_x-10_y-N5") + .sharpen(10.0) + .unsharpMask("2-2-0.8-0.024") + .gradient("from-red_to-white") + .colorReplace("FF0000_100_0000FF") + .distort("a-45") + .original(true) + .page("2_4") + .raw("h-200,w-300,l-image,i-logo.png,l-end") + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300,q-40,ar-4-3,c-force,cm-extract,fo-left,f-jpeg,r-50,bg-A94D34,b-5-A94D34,cr-FF0000_100_0000FF,di-folder@@file.jpg,dpr-3,x-10,y-20,xc-30,yc-40,o-0.8,z-2,rt-90,bl-10,n-some_name,pr-true,lo-true,fl-h,t-5,md-true,cp-true,vc-h264,ac-aac,so-5,eo-15,du-10,sr-1440_1080,e-grayscale,e-upscale,e-retouch,e-genvar,e-bgremove,e-contrast,e-dropshadow,e-changebg-prompt-car,e-edit-prompt-make it vintage,e-shadow-bl-15_st-40_x-10_y-N5,e-sharpen-10,e-usm-2-2-0.8-0.024,e-gradient-from-red_to-white,e-distort-a-45,orig-true,pg-2_4,h-200,w-300,l-image,i-logo.png,l-end" + ) + } +} diff --git a/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperAuthenticationTest.kt b/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperAuthenticationTest.kt new file mode 100644 index 00000000..b866b936 --- /dev/null +++ b/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperAuthenticationTest.kt @@ -0,0 +1,101 @@ +package com.imagekit.api.lib + +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import kotlin.test.assertFailsWith +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class HelperAuthenticationTest { + + private val privateKey = "private_key_test" + private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() + + @Test + fun `should return correct authentication parameters with provided token and expire`() { + val token = "your_token" + val expire = 1582269249L + + val params = client.helper().getAuthenticationParameters(token, expire) + + // Expected exact match with Node.js/Go SDK output + val expectedSignature = "e71bcd6031016b060d349d212e23e85c791decdd" + + assertThat(params["token"]).isEqualTo(token) + assertThat(params["expire"]).isEqualTo(expire) + assertThat(params["signature"]).isEqualTo(expectedSignature) + } + + @Test + fun `should return authentication parameters with required properties when no params provided`() { + val params = client.helper().getAuthenticationParameters(null, null) + + // Check that all required properties exist + assertThat(params).containsKeys("token", "expire", "signature") + + // Token should be a 32-character hex string (16 bytes as hex) + val token = params["token"] as String + assertThat(token).matches("^[0-9a-f]{32}$") + + // Expire should be a number greater than current time + val expire = params["expire"] as Long + val currentTime = System.currentTimeMillis() / 1000 + assertThat(expire).isGreaterThan(currentTime) + + // Signature should be a hex string (40 characters for HMAC-SHA1) + val signature = params["signature"] as String + assertThat(signature).matches("^[a-f0-9]{40}$") + } + + @Test + fun `should handle edge case with expire time 0`() { + val token = "test-token" + val expire = 0L + + val params = client.helper().getAuthenticationParameters(token, expire) + + assertThat(params["token"]).isEqualTo(token) + + // When expire is 0 (falsy), it should use default expire time (30 minutes from now) + val expireResult = params["expire"] as Long + val expectedExpire = System.currentTimeMillis() / 1000 + 60 * 30 + + // Allow a 10 second tolerance for test execution time + assertThat(expireResult).isBetween(expectedExpire - 10, expectedExpire + 10) + + // Signature should be a hex string (40 characters for HMAC-SHA1) + val signature = params["signature"] as String + assertThat(signature).matches("^[a-f0-9]{40}$") + } + + @Test + fun `should handle empty string token`() { + val token = "" // Empty string is falsy + val expire = 1582269249L + + val params = client.helper().getAuthenticationParameters(token, expire) + + // Since empty string is falsy, it should generate a hex token + val tokenResult = params["token"] as String + assertThat(tokenResult).isNotEmpty() + assertThat(tokenResult).matches("^[0-9a-f]{32}$") + + assertThat(params["expire"]).isEqualTo(expire) + + // Signature should be a hex string (40 characters for HMAC-SHA1) + val signature = params["signature"] as String + assertThat(signature).matches("^[a-f0-9]{40}$") + } + + @Test + fun `should return error when private key is not provided`() { + val emptyKeyClient = ImageKitOkHttpClient.builder().privateKey("").build() + + val exception = + assertFailsWith { + emptyKeyClient.helper().getAuthenticationParameters("test", 123L) + } + + assertThat(exception.message) + .isEqualTo("private API key is required for authentication parameters generation") + } +} diff --git a/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperBuildUrlTest.kt b/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperBuildUrlTest.kt new file mode 100644 index 00000000..be99d4d3 --- /dev/null +++ b/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperBuildUrlTest.kt @@ -0,0 +1,433 @@ +package com.imagekit.api.lib + +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.core.JsonValue +import com.imagekit.api.models.SrcOptions +import com.imagekit.api.models.Transformation +import com.imagekit.api.models.TransformationPosition +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class HelperBuildUrlTest { + + private val privateKey = "My Private API Key" + private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() + + @Test + fun `should throw exception when src is not provided`() { + org.junit.jupiter.api.assertThrows { + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .build() + ) + } + } + + @Test + fun `should generate a valid URL when src is slash`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/") + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/") + } + + @Test + fun `should generate a valid URL when src is provided without transformation`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path.jpg") + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path.jpg") + } + + @Test + fun `should generate a valid URL when absolute URL is provided without transformation`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg") + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg") + } + + @Test + fun `should generate valid URL when undefined transformation parameters are provided with path`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .src("/test_path_alt.jpg") + .transformationPosition(TransformationPosition.QUERY) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg") + } + + @Test + fun `by default transformationPosition should be query`() { + val transformation = + listOf( + Transformation.builder().height(300.0).width(400.0).build(), + Transformation.builder().rotation(90.0).build(), + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .src("/test_path.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300:rt-90" + ) + } + + @Test + fun `should generate the URL without sdk version`() { + val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .src("/test_path.jpg") + .transformation(transformation) + .transformationPosition(TransformationPosition.PATH) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/tr:w-400,h-300/test_path.jpg") + } + + @Test + fun `should generate the correct URL with a valid src and transformation`() { + val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300") + } + + @Test + fun `should add transformation as query when src has absolute url even if transformationPosition is path`() { + val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("https://my.custom.domain.com/test_path.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url).isEqualTo("https://my.custom.domain.com/test_path.jpg?tr=w-400,h-300") + } + + @Test + fun `handle non-default url-endpoint case`() { + val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/imagekit_id/new-endpoint/") + .src("/test_path.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/imagekit_id/new-endpoint/test_path.jpg?tr=w-400,h-300" + ) + } + + @Test + fun `should generate the correct URL when the provided path contains multiple leading slashes`() { + val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("///test_path.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300") + } + + @Test + fun `should generate the correct URL when the urlEndpoint is overridden`() { + val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint_alt") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint_alt/test_path.jpg?tr=w-400,h-300") + } + + @Test + fun `should generate the correct URL with transformationPosition as query parameter when src is provided`() { + val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .src("/test_path.jpg") + .transformationPosition(TransformationPosition.QUERY) + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300") + } + + @Test + fun `should generate the correct URL with a valid src parameter and transformation`() { + val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg?tr=w-400,h-300") + } + + @Test + fun `should merge query parameters correctly in the generated URL`() { + val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) + + val queryParams = + SrcOptions.QueryParameters.builder() + .putAdditionalProperty("t2", JsonValue.from("v2")) + .putAdditionalProperty("t3", JsonValue.from("v3")) + .build() + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg?t1=v1") + .queryParameters(queryParams) + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg?t1=v1&t2=v2&t3=v3&tr=w-400,h-300" + ) + } + + @Test + fun `should generate the correct URL with chained transformations`() { + val transformation = + listOf( + Transformation.builder().height(300.0).width(400.0).build(), + Transformation.builder().rotation(90.0).build(), + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300:rt-90" + ) + } + + @Test + fun `should generate the correct URL with chained transformations including raw transformation`() { + val transformation = + listOf( + Transformation.builder().height(300.0).width(400.0).build(), + Transformation.builder().raw("rndm_trnsf-abcd").build(), + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300:rndm_trnsf-abcd" + ) + } + + @Test + fun `should generate the correct URL when border transformation is applied`() { + val transformation = + listOf(Transformation.builder().height(300.0).width(400.0).border("20_FF0000").build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300,b-20_FF0000" + ) + } + + @Test + fun `should generate the correct URL when transformation has empty key and value`() { + val transformation = listOf(Transformation.builder().raw("").build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path.jpg") + } + + @Test + fun `should generate a valid URL when cname is used`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://custom.domain.com") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path.jpg") + .build() + ) + + assertThat(url).isEqualTo("https://custom.domain.com/test_path.jpg") + } + + @Test + fun `should generate a valid URL when cname is used with a url-pattern`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://custom.domain.com/url-pattern") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path.jpg") + .build() + ) + + assertThat(url).isEqualTo("https://custom.domain.com/url-pattern/test_path.jpg") + } +} diff --git a/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperOverlayTest.kt b/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperOverlayTest.kt new file mode 100644 index 00000000..6d16d855 --- /dev/null +++ b/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperOverlayTest.kt @@ -0,0 +1,1564 @@ +package com.imagekit.api.lib + +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.core.JsonValue +import com.imagekit.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class HelperOverlayTest { + + private val privateKey = "My Private API Key" + private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() + + // ======================================== + // TestOverlayTransformations - 12 tests + // ======================================== + + @Test + fun `should ignore overlay when type property is missing`() { + val transformation = listOf(Transformation.builder().width(300.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/tr:w-300/base-image.jpg") + } + + @Test + fun `should ignore text overlay when text property is missing`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder().text("").type(JsonValue.from("text")).build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/base-image.jpg") + } + + @Test + fun `should ignore image overlay when input property is missing`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder().input("").type(JsonValue.from("image")).build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/base-image.jpg") + } + + @Test + fun `should ignore video overlay when input property is missing`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofVideo( + VideoOverlay.builder().input("").type(JsonValue.from("video")).build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/base-image.jpg") + } + + @Test + fun `should ignore subtitle overlay when input property is missing`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofSubtitle( + SubtitleOverlay.builder() + .input("") + .type(JsonValue.from("subtitle")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/base-image.jpg") + } + + @Test + fun `should ignore solid color overlay when color property is missing`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofSolidColor( + SolidColorOverlay.builder() + .color("") + .type(JsonValue.from("solidColor")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/base-image.jpg") + } + + @Test + fun `should generate URL with text overlay using URL encoding`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("Minimal Text") + .type(JsonValue.from("text")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Minimal%20Text,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate URL with image overlay from input file`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("logo.png") + .type(JsonValue.from("image")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-logo.png,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate URL with video overlay from input file`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofVideo( + VideoOverlay.builder() + .input("play-pause-loop.mp4") + .type(JsonValue.from("video")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-video.mp4") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-video,i-play-pause-loop.mp4,l-end/base-video.mp4" + ) + } + + @Test + fun `should generate URL with subtitle overlay from input file`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofSubtitle( + SubtitleOverlay.builder() + .input("subtitle.srt") + .type(JsonValue.from("subtitle")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-video.mp4") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-subtitles,i-subtitle.srt,l-end/base-video.mp4" + ) + } + + @Test + fun `should generate URL with solid color overlay using background color`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofSolidColor( + SolidColorOverlay.builder() + .color("FF0000") + .type(JsonValue.from("solidColor")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-ik_canvas,bg-FF0000,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate URL with multiple complex overlays including nested transformations`() { + val transformation = + listOf( + // Text overlay with complex transformations + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("Every thing") + .type(JsonValue.from("text")) + .position( + OverlayPosition.builder() + .x("10") + .y("20") + .focus(OverlayPosition.Focus.CENTER) + .build() + ) + .timing( + OverlayTiming.builder() + .start(5.0) + .duration("10") + .end(15.0) + .build() + ) + .transformation( + listOf( + TextOverlayTransformation.builder() + .width("bw_mul_0.5") + .fontSize(20.0) + .fontFamily("Arial") + .fontColor("0000ff") + .innerAlignment( + TextOverlayTransformation.InnerAlignment.LEFT + ) + .padding(5.0) + .alpha(7.0) + .typography("b") + .background("red") + .radius(10.0) + .rotation("N45") + .flip(TextOverlayTransformation.Flip.H) + .lineHeight(20.0) + .build() + ) + ) + .build() + ) + ) + .build(), + // Image overlay with nested transformations including nested text overlay + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("logo.png") + .type(JsonValue.from("image")) + .position( + OverlayPosition.builder() + .x("10") + .y("20") + .focus(OverlayPosition.Focus.CENTER) + .build() + ) + .timing( + OverlayTiming.builder() + .start(5.0) + .duration("10") + .end(15.0) + .build() + ) + .transformation( + listOf( + Transformation.builder() + .width("bw_mul_0.5") + .height("bh_mul_0.5") + .rotation("N45") + .flip(Transformation.Flip.H) + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("Nested text overlay") + .type(JsonValue.from("text")) + .build() + ) + ) + .build() + ) + ) + .build() + ) + ) + .build(), + // Video overlay + Transformation.builder() + .overlay( + Overlay.ofVideo( + VideoOverlay.builder() + .input("play-pause-loop.mp4") + .type(JsonValue.from("video")) + .position( + OverlayPosition.builder() + .x("10") + .y("20") + .focus(OverlayPosition.Focus.CENTER) + .build() + ) + .timing( + OverlayTiming.builder() + .start(5.0) + .duration("10") + .end(15.0) + .build() + ) + .transformation( + listOf( + Transformation.builder() + .width("bw_mul_0.5") + .height("bh_mul_0.5") + .rotation("N45") + .flip(Transformation.Flip.H) + .build() + ) + ) + .build() + ) + ) + .build(), + // Subtitle overlay + Transformation.builder() + .overlay( + Overlay.ofSubtitle( + SubtitleOverlay.builder() + .input("subtitle.srt") + .type(JsonValue.from("subtitle")) + .position( + OverlayPosition.builder() + .x("10") + .y("20") + .focus(OverlayPosition.Focus.CENTER) + .build() + ) + .timing( + OverlayTiming.builder() + .start(5.0) + .duration("10") + .end(15.0) + .build() + ) + .transformation( + listOf( + SubtitleOverlayTransformation.builder() + .background("red") + .color("0000ff") + .fontFamily("Arial") + .fontOutline("2_A1CCDD50") + .fontShadow("A1CCDD_3") + .build() + ) + ) + .build() + ) + ) + .build(), + // Solid color overlay + Transformation.builder() + .overlay( + Overlay.ofSolidColor( + SolidColorOverlay.builder() + .color("FF0000") + .type(JsonValue.from("solidColor")) + .position( + OverlayPosition.builder() + .x("10") + .y("20") + .focus(OverlayPosition.Focus.CENTER) + .build() + ) + .timing( + OverlayTiming.builder() + .start(5.0) + .duration("10") + .end(15.0) + .build() + ) + .transformation( + listOf( + SolidColorOverlayTransformation.builder() + .width("bw_mul_0.5") + .height("bh_mul_0.5") + .alpha(0.5) + .background("red") + .gradientTrue() + .radiusMax() + .build() + ) + ) + .build() + ) + ) + .build(), + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Every%20thing,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,w-bw_mul_0.5,fs-20,ff-Arial,co-0000ff,ia-left,pa-5,al-7,tg-b,bg-red,r-10,rt-N45,fl-h,lh-20,l-end:l-image,i-logo.png,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,w-bw_mul_0.5,h-bh_mul_0.5,rt-N45,fl-h,l-text,i-Nested%20text%20overlay,l-end,l-end:l-video,i-play-pause-loop.mp4,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,w-bw_mul_0.5,h-bh_mul_0.5,rt-N45,fl-h,l-end:l-subtitles,i-subtitle.srt,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,bg-red,co-0000ff,ff-Arial,fol-2_A1CCDD50,fsh-A1CCDD_3,l-end:l-image,i-ik_canvas,bg-FF0000,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,w-bw_mul_0.5,h-bh_mul_0.5,al-0.5,bg-red,e-gradient,r-max,l-end/base-image.jpg" + ) + } + + // ======================================== + // TestOverlayEncoding - 19 tests + // ======================================== + + @Test + fun `should use plain encoding for simple image paths with slashes converted to @@`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("/customer_logo/nykaa.png") + .type(JsonValue.from("image")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/medium_cafe_B1iTdD0C.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-image,i-customer_logo@@nykaa.png,l-end/medium_cafe_B1iTdD0C.jpg" + ) + } + + @Test + fun `should use base64 encoding for image paths containing special characters`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("/customer_logo/Ñykaa.png") + .type(JsonValue.from("image")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/medium_cafe_B1iTdD0C.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-image,ie-Y3VzdG9tZXJfbG9nby%2FDkXlrYWEucG5n,l-end/medium_cafe_B1iTdD0C.jpg" + ) + } + + @Test + fun `should use plain encoding for simple text overlays`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder().text("Manu").type(JsonValue.from("text")).build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/medium_cafe_B1iTdD0C.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-text,i-Manu,l-end/medium_cafe_B1iTdD0C.jpg" + ) + } + + @Test + fun `should convert slashes to @@ in fontFamily paths for custom fonts`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("Manu") + .type(JsonValue.from("text")) + .transformation( + listOf( + TextOverlayTransformation.builder() + .fontFamily("nested-path/Poppins-Regular_Q15GrYWmL.ttf") + .build() + ) + ) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/medium_cafe_B1iTdD0C.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-text,i-Manu,ff-nested-path@@Poppins-Regular_Q15GrYWmL.ttf,l-end/medium_cafe_B1iTdD0C.jpg" + ) + } + + @Test + fun `should use URL encoding for text overlays with spaces and safe characters`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("alnum123-._ ") + .type(JsonValue.from("text")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/medium_cafe_B1iTdD0C.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-text,i-alnum123-._%20,l-end/medium_cafe_B1iTdD0C.jpg" + ) + } + + @Test + fun `should use base64 encoding for text overlays with special unicode characters`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("Let's use ©, ®, ™, etc") + .type(JsonValue.from("text")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/medium_cafe_B1iTdD0C.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-text,ie-TGV0J3MgdXNlIMKpLCDCriwg4oSiLCBldGM%3D,l-end/medium_cafe_B1iTdD0C.jpg" + ) + } + + @Test + fun `should use plain encoding when explicitly specified for text overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("HelloWorld") + .type(JsonValue.from("text")) + .encoding(TextOverlay.Encoding.PLAIN) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/sample.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/demo/tr:l-text,i-HelloWorld,l-end/sample.jpg") + } + + @Test + fun `should use base64 encoding when explicitly specified for text overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("HelloWorld") + .type(JsonValue.from("text")) + .encoding(TextOverlay.Encoding.BASE64) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/sample.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-text,ie-SGVsbG9Xb3JsZA%3D%3D,l-end/sample.jpg" + ) + } + + @Test + fun `should use plain encoding when explicitly specified for image overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("/customer/logo.png") + .type(JsonValue.from("image")) + .encoding(ImageOverlay.Encoding.PLAIN) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/sample.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-image,i-customer@@logo.png,l-end/sample.jpg" + ) + } + + @Test + fun `should use base64 encoding when explicitly specified for image overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("/customer/logo.png") + .type(JsonValue.from("image")) + .encoding(ImageOverlay.Encoding.BASE64) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/sample.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-image,ie-Y3VzdG9tZXIvbG9nby5wbmc%3D,l-end/sample.jpg" + ) + } + + @Test + fun `should use base64 encoding when explicitly specified for video overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofVideo( + VideoOverlay.builder() + .input("/path/to/video.mp4") + .type(JsonValue.from("video")) + .encoding(VideoOverlay.Encoding.BASE64) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/sample.mp4") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-video,ie-cGF0aC90by92aWRlby5tcDQ%3D,l-end/sample.mp4" + ) + } + + @Test + fun `should use plain encoding when explicitly specified for subtitle overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofSubtitle( + SubtitleOverlay.builder() + .input("/sub.srt") + .type(JsonValue.from("subtitle")) + .encoding(SubtitleOverlay.Encoding.PLAIN) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/sample.mp4") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/demo/tr:l-subtitles,i-sub.srt,l-end/sample.mp4") + } + + @Test + fun `should use base64 encoding when explicitly specified for subtitle overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofSubtitle( + SubtitleOverlay.builder() + .input("sub.srt") + .type(JsonValue.from("subtitle")) + .encoding(SubtitleOverlay.Encoding.BASE64) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/sample.mp4") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-subtitles,ie-c3ViLnNydA%3D%3D,l-end/sample.mp4" + ) + } + + @Test + fun `should properly encode overlay text when transformations are in query parameters`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("Minimal Text") + .type(JsonValue.from("text")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.QUERY) + .src("/sample.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/demo/sample.jpg?tr=l-text,i-Minimal%20Text,l-end") + } + + @Test + fun `should generate URL with image overlay using layerMode multiply`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("logo.png") + .type(JsonValue.from("image")) + .layerMode(BaseOverlay.LayerMode.MULTIPLY) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-logo.png,lm-multiply,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate URL with image overlay using layerMode cutter`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("mask.png") + .type(JsonValue.from("image")) + .layerMode(BaseOverlay.LayerMode.CUTTER) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-mask.png,lm-cutter,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate URL with image overlay using layerMode cutout`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("shape.png") + .type(JsonValue.from("image")) + .layerMode(BaseOverlay.LayerMode.CUTOUT) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-shape.png,lm-cutout,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate URL with image overlay using layerMode displace`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("displacement.png") + .type(JsonValue.from("image")) + .layerMode(BaseOverlay.LayerMode.DISPLACE) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-displacement.png,lm-displace,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate URL with image overlay using xCenter yCenter and anchorPoint`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("logo.png") + .type(JsonValue.from("image")) + .position( + OverlayPosition.builder() + .xCenter(50.0) + .yCenter("bh_mul_0.5") + .anchorPoint(OverlayPosition.AnchorPoint.TOP_LEFT) + .build() + ) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-logo.png,lxc-50,lyc-bh_mul_0.5,lap-top_left,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate layerMode on text overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("Hello") + .type(JsonValue.from("text")) + .layerMode(BaseOverlay.LayerMode.MULTIPLY) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Hello,lm-multiply,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate layerMode on video overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofVideo( + VideoOverlay.builder() + .input("video.mp4") + .type(JsonValue.from("video")) + .layerMode(BaseOverlay.LayerMode.MULTIPLY) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-video,i-video.mp4,lm-multiply,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate layerMode on subtitle overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofSubtitle( + SubtitleOverlay.builder() + .input("subtitle.srt") + .type(JsonValue.from("subtitle")) + .layerMode(BaseOverlay.LayerMode.CUTTER) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-subtitles,i-subtitle.srt,lm-cutter,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate layerMode on solid color overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofSolidColor( + SolidColorOverlay.builder() + .color("FF0000") + .type(JsonValue.from("solidColor")) + .layerMode(BaseOverlay.LayerMode.CUTOUT) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-ik_canvas,bg-FF0000,lm-cutout,l-end/base-image.jpg" + ) + } + + @Test + fun `should strip leading and trailing slashes from image overlay input path`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("/path/to/logo.png/") + .type(JsonValue.from("image")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-path@@to@@logo.png,l-end/base-image.jpg" + ) + } + + @Test + fun `should strip leading and trailing slashes from fontFamily in text overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("Hello") + .type(JsonValue.from("text")) + .transformation( + listOf( + TextOverlayTransformation.builder() + .fontFamily("/sdk-testing-files/Poppins-Regular.ttf/") + .build() + ) + ) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Hello,ff-sdk-testing-files@@Poppins-Regular.ttf,l-end/base-image.jpg" + ) + } + + @Test + fun `should use processInputPath for subtitle overlay with slashes`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofSubtitle( + SubtitleOverlay.builder() + .input("/path/to/subtitle.srt") + .type(JsonValue.from("subtitle")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-subtitles,i-path@@to@@subtitle.srt,l-end/base-image.jpg" + ) + } + + @Test + fun `should order anchorPoint before focus in overlay position`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("logo.png") + .type(JsonValue.from("image")) + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .anchorPoint(OverlayPosition.AnchorPoint.BOTTOM_RIGHT) + .build() + ) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-logo.png,lap-bottom_right,lfo-center,l-end/base-image.jpg" + ) + } + + @Test + fun `should properly path-escape special characters in plain text overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("Hello World") + .type(JsonValue.from("text")) + .encoding(TextOverlay.Encoding.PLAIN) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Hello%20World,l-end/base-image.jpg" + ) + } +} diff --git a/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperSigningTest.kt b/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperSigningTest.kt new file mode 100644 index 00000000..e5caee28 --- /dev/null +++ b/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperSigningTest.kt @@ -0,0 +1,279 @@ +package com.imagekit.api.lib + +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.core.JsonValue +import com.imagekit.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class HelperSigningTest { + + private val privateKey = "dummy-key" + private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() + + @Test + fun `should generate a signed URL when signed is true without expiresIn`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo/") + .src("sdk-testing-files/future-search.png") + .signed(true) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/sdk-testing-files/future-search.png?ik-s=32dbbbfc5f945c0403c71b54c38e76896ef2d6b0" + ) + } + + @Test + fun `should generate a signed URL when signed is true with expiresIn`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo/") + .src("sdk-testing-files/future-search.png") + .signed(true) + .expiresIn(3600.0) + .build() + ) + + // Expect ik-t exist in the URL. We don't assert signature because it will keep changing. + assertThat(url).contains("ik-t") + } + + @Test + fun `should generate a signed URL when expiresIn is above 0 and even if signed is false`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo/") + .src("sdk-testing-files/future-search.png") + .signed(false) + .expiresIn(3600.0) + .build() + ) + + // Expect ik-t exist in the URL. We don't assert signature because it will keep changing. + assertThat(url).contains("ik-t") + } + + @Test + fun `should generate signed URL with special characters in filename`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo/") + .src("sdk-testing-files/हिन्दी.png") + .signed(true) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/sdk-testing-files/%E0%A4%B9%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%A6%E0%A5%80.png?ik-s=3fff2f31da1f45e007adcdbe95f88c8c330e743c" + ) + } + + @Test + fun `should generate signed URL with text overlay containing special characters`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("हिन्दी") + .type(JsonValue.from("text")) + .transformation( + listOf( + TextOverlayTransformation.builder() + .fontColor("red") + .fontSize("32") + .fontFamily( + "sdk-testing-files/Poppins-Regular_Q15GrYWmL.ttf" + ) + .build() + ) + ) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo/") + .src("sdk-testing-files/हिन्दी.png") + .transformation(transformation) + .signed(true) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/sdk-testing-files/%E0%A4%B9%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%A6%E0%A5%80.png?tr=l-text,ie-4KS54KS%2F4KSo4KWN4KSm4KWA,fs-32,ff-sdk-testing-files@@Poppins-Regular_Q15GrYWmL.ttf,co-red,l-end&ik-s=705e41579d368caa6530a4375355325277fcfe5c" + ) + } + + @Test + fun `should generate signed URL with text overlay and special characters using path transformation position`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("हिन्दी") + .type(JsonValue.from("text")) + .transformation( + listOf( + TextOverlayTransformation.builder() + .fontColor("red") + .fontSize("32") + .fontFamily( + "sdk-testing-files/Poppins-Regular_Q15GrYWmL.ttf" + ) + .build() + ) + ) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo/") + .src("sdk-testing-files/हिन्दी.png") + .transformationPosition(TransformationPosition.PATH) + .transformation(transformation) + .signed(true) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-text,ie-4KS54KS%2F4KSo4KWN4KSm4KWA,fs-32,ff-sdk-testing-files@@Poppins-Regular_Q15GrYWmL.ttf,co-red,l-end/sdk-testing-files/%E0%A4%B9%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%A6%E0%A5%80.png?ik-s=20958f6126fd67c90653f55a49f2b7bb938d9d1c" + ) + } + + @Test + fun `should generate signed URL with query parameters`() { + val queryParams = + SrcOptions.QueryParameters.builder() + .putAdditionalProperty("version", JsonValue.from("1.0")) + .putAdditionalProperty("cache", JsonValue.from("false")) + .build() + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo/") + .src("sdk-testing-files/future-search.png") + .queryParameters(queryParams) + .signed(true) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/sdk-testing-files/future-search.png?cache=false&version=1.0&ik-s=03767bb6f0898c04e42f65714af65d937c696d66" + ) + } + + @Test + fun `should generate signed URL with transformations and query parameters`() { + val transformation = listOf(Transformation.builder().width(300.0).height(200.0).build()) + + val queryParams = + SrcOptions.QueryParameters.builder() + .putAdditionalProperty("version", JsonValue.from("2.0")) + .build() + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo/") + .src("sdk-testing-files/future-search.png") + .transformation(transformation) + .queryParameters(queryParams) + .signed(true) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/sdk-testing-files/future-search.png?version=2.0&tr=w-300,h-200&ik-s=601d97a7834b7554f4dabf0d3fc3a219ceeb6b31" + ) + } + + @Test + fun `should not sign URL when signed is false`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo/") + .src("sdk-testing-files/future-search.png") + .signed(false) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/demo/sdk-testing-files/future-search.png") + assertThat(url).doesNotContain("ik-s=") + assertThat(url).doesNotContain("ik-t=") + } + + @Test + fun `should generate signed URL with transformations in path position and query parameters`() { + val transformation = listOf(Transformation.builder().width(300.0).height(200.0).build()) + + val queryParams = + SrcOptions.QueryParameters.builder() + .putAdditionalProperty("version", JsonValue.from("2.0")) + .build() + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo/") + .src("sdk-testing-files/future-search.png") + .transformation(transformation) + .transformationPosition(TransformationPosition.PATH) + .queryParameters(queryParams) + .signed(true) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:w-300,h-200/sdk-testing-files/future-search.png?version=2.0&ik-s=dd1ee8f83d019bc59fd57a5fc4674a11eb8a3496" + ) + } +} diff --git a/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperTransformationTest.kt b/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperTransformationTest.kt new file mode 100644 index 00000000..bd33eb0b --- /dev/null +++ b/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperTransformationTest.kt @@ -0,0 +1,108 @@ +package com.imagekit.api.lib + +import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import com.imagekit.api.core.JsonValue +import com.imagekit.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class HelperTransformationTest { + + private val privateKey = "test-key" + private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() + + @Test + fun `should return empty string for empty transformation array`() { + val result = client.helper().buildTransformationString(null) + assertThat(result).isEmpty() + + val result2 = client.helper().buildTransformationString(emptyList()) + assertThat(result2).isEmpty() + } + + @Test + fun `should generate transformation string for width only`() { + val transformation = listOf(Transformation.builder().width(300.0).build()) + + val result = client.helper().buildTransformationString(transformation) + assertThat(result).isEqualTo("w-300") + } + + @Test + fun `should generate transformation string for multiple parameters`() { + val transformation = listOf(Transformation.builder().width(300.0).height(200.0).build()) + + val result = client.helper().buildTransformationString(transformation) + assertThat(result).isEqualTo("w-300,h-200") + } + + @Test + fun `should generate transformation string for chained transformations`() { + val transformation = + listOf( + Transformation.builder().width(300.0).build(), + Transformation.builder().height(200.0).build(), + ) + + val result = client.helper().buildTransformationString(transformation) + assertThat(result).isEqualTo("w-300:h-200") + } + + @Test + fun `should handle empty transformation object`() { + val transformation = listOf(Transformation.builder().build()) + + val result = client.helper().buildTransformationString(transformation) + assertThat(result).isEmpty() + } + + @Test + fun `should handle transformation with overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder().text("Hello").type(JsonValue.from("text")).build() + ) + ) + .build() + ) + + val result = client.helper().buildTransformationString(transformation) + assertThat(result).isEqualTo("l-text,i-Hello,l-end") + } + + @Test + fun `should handle raw transformation parameter`() { + val transformation = listOf(Transformation.builder().raw("custom-transform-123").build()) + + val result = client.helper().buildTransformationString(transformation) + assertThat(result).isEqualTo("custom-transform-123") + } + + @Test + fun `should handle mixed parameters with raw`() { + val transformation = + listOf(Transformation.builder().width(300.0).raw("custom-param-123").build()) + + val result = client.helper().buildTransformationString(transformation) + assertThat(result).isEqualTo("w-300,custom-param-123") + } + + @Test + fun `should handle quality parameter`() { + val transformation = listOf(Transformation.builder().quality(80.0).build()) + + val result = client.helper().buildTransformationString(transformation) + assertThat(result).isEqualTo("q-80") + } + + @Test + fun `should handle aspect ratio parameter`() { + val transformation = listOf(Transformation.builder().aspectRatio("4:3").build()) + + val result = client.helper().buildTransformationString(transformation) + assertThat(result).isEqualTo("ar-4:3") + } +} diff --git a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt index 4a743bae..8c89a189 100644 --- a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt +++ b/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt @@ -6,8 +6,13 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.imagekit.api.client.okhttp.ImageKitOkHttpClient import com.imagekit.api.core.JsonValue import com.imagekit.api.core.jsonMapper +import com.imagekit.api.models.AiTag +import com.imagekit.api.models.CustomMetadata +import com.imagekit.api.models.EmbeddedMetadata +import com.imagekit.api.models.ExtensionItem +import com.imagekit.api.models.SelectedFieldsSchema import com.imagekit.api.models.StreamingResolution -import com.imagekit.api.models.UnnamedSchemaWithArrayParent4 +import com.imagekit.api.models.VersionInfo import com.imagekit.api.models.files.File import com.imagekit.api.models.files.UpdateFileRequest import java.time.OffsetDateTime @@ -72,22 +77,20 @@ internal class ProGuardCompatibilityTest { val jsonMapper = jsonMapper() val file = File.builder() - .addAiTag( - File.AiTag.builder().confidence(0.0).name("name").source("source").build() - ) + .addAiTag(AiTag.builder().confidence(0.0).name("name").source("source").build()) .audioCodec("audioCodec") .bitRate(0L) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customCoordinates("customCoordinates") .customMetadata( - File.CustomMetadata.builder() + CustomMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .description("description") .duration(0L) .embeddedMetadata( - File.EmbeddedMetadata.builder() + EmbeddedMetadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -101,7 +104,7 @@ internal class ProGuardCompatibilityTest { .mime("mime") .name("name") .selectedFieldsSchema( - File.SelectedFieldsSchema.builder() + SelectedFieldsSchema.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -128,7 +131,7 @@ internal class ProGuardCompatibilityTest { .type(File.Type.FILE) .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .url("https://example.com") - .versionInfo(File.VersionInfo.builder().id("id").name("name").build()) + .versionInfo(VersionInfo.builder().id("id").name("name").build()) .videoCodec("videoCodec") .width(0.0) .build() @@ -155,10 +158,10 @@ internal class ProGuardCompatibilityTest { .description("description") .extensions( listOf( - UnnamedSchemaWithArrayParent4.ofRemoveBg( - UnnamedSchemaWithArrayParent4.RemoveBg.builder() + ExtensionItem.ofRemoveBg( + ExtensionItem.RemoveBg.builder() .options( - UnnamedSchemaWithArrayParent4.RemoveBg.Options.builder() + ExtensionItem.RemoveBg.Options.builder() .addShadow(true) .bgColor("bg_color") .bgImageUrl("bg_image_url") @@ -167,32 +170,27 @@ internal class ProGuardCompatibilityTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name - .GOOGLE_AUTO_TAGGING + ExtensionItem.AutoTaggingExtension.Name.GOOGLE_AUTO_TAGGING ) .build() ), - UnnamedSchemaWithArrayParent4.ofAutoTaggingExtension( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.builder() + ExtensionItem.ofAutoTaggingExtension( + ExtensionItem.AutoTaggingExtension.builder() .maxTags(10L) .minConfidence(80L) - .name( - UnnamedSchemaWithArrayParent4.AutoTaggingExtension.Name - .AWS_AUTO_TAGGING - ) + .name(ExtensionItem.AutoTaggingExtension.Name.AWS_AUTO_TAGGING) .build() ), - UnnamedSchemaWithArrayParent4.ofAiAutoDescription(), - UnnamedSchemaWithArrayParent4.ofAiTasks( - UnnamedSchemaWithArrayParent4.AiTasks.builder() + ExtensionItem.ofAiAutoDescription(), + ExtensionItem.ofAiTasks( + ExtensionItem.AiTasks.builder() .addTask( - UnnamedSchemaWithArrayParent4.AiTasks.Task.SelectTags - .builder() + ExtensionItem.AiTasks.Task.SelectTags.builder() .instruction( "What types of clothing items are visible?" ) @@ -203,10 +201,8 @@ internal class ProGuardCompatibilityTest { ) .build() ), - UnnamedSchemaWithArrayParent4.ofSavedExtension( - UnnamedSchemaWithArrayParent4.SavedExtension.builder() - .id("ext_abc123") - .build() + ExtensionItem.ofSavedExtension( + ExtensionItem.SavedExtension.builder().id("ext_abc123").build() ), ) ) From 75ff27c3c8a2c90d7bf5d14e75b1e3de05733781 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 05:13:08 +0000 Subject: [PATCH 136/142] feat(api): manual updates From b39e9dc8e9af7806353b5f9276f023fec45c5905 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 05:16:08 +0000 Subject: [PATCH 137/142] chore: update SDK settings --- .github/workflows/publish-sonatype.yml | 41 ++++++++++++ .github/workflows/release-doctor.yml | 24 +++++++ .release-please-manifest.json | 3 + .stats.yml | 2 +- README.md | 25 ++++++- bin/check-release-environment | 33 +++++++++ build.gradle.kts | 2 +- .../main/kotlin/image-kit.publish.gradle.kts | 6 +- .../kotlin/com/imagekit/api/core/Check.kt | 2 +- release-please-config.json | 67 +++++++++++++++++++ 10 files changed, 198 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/publish-sonatype.yml create mode 100644 .github/workflows/release-doctor.yml create mode 100644 .release-please-manifest.json create mode 100644 bin/check-release-environment create mode 100644 release-please-config.json diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml new file mode 100644 index 00000000..739856ac --- /dev/null +++ b/.github/workflows/publish-sonatype.yml @@ -0,0 +1,41 @@ +# This workflow is triggered when a GitHub release is created. +# It can also be run manually to re-publish to Sonatype in case it failed for some reason. +# You can run this workflow by navigating to https://www.github.com/imagekit-developer/imagekit-java/actions/workflows/publish-sonatype.yml +name: Publish Sonatype +on: + workflow_dispatch: + + release: + types: [published] + +jobs: + publish: + name: publish + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + + - name: Set up Java + uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: | + 8 + 21 + cache: gradle + + - name: Set up Gradle + uses: gradle/gradle-build-action@v2 + + - name: Publish to Sonatype + run: |- + export -- GPG_SIGNING_KEY_ID + printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD" + GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')" + ./gradlew publish --no-configuration-cache + env: + SONATYPE_USERNAME: ${{ secrets.IMAGE_KIT_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.IMAGE_KIT_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} + GPG_SIGNING_KEY: ${{ secrets.IMAGE_KIT_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} + GPG_SIGNING_PASSWORD: ${{ secrets.IMAGE_KIT_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }} \ No newline at end of file diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml new file mode 100644 index 00000000..d9896ce1 --- /dev/null +++ b/.github/workflows/release-doctor.yml @@ -0,0 +1,24 @@ +name: Release Doctor +on: + pull_request: + branches: + - master + workflow_dispatch: + +jobs: + release_doctor: + name: release doctor + runs-on: ubuntu-latest + if: github.repository == 'imagekit-developer/imagekit-java' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') + + steps: + - uses: actions/checkout@v6 + + - name: Check release environment + run: | + bash ./bin/check-release-environment + env: + SONATYPE_USERNAME: ${{ secrets.IMAGE_KIT_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.IMAGE_KIT_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} + GPG_SIGNING_KEY: ${{ secrets.IMAGE_KIT_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} + GPG_SIGNING_PASSWORD: ${{ secrets.IMAGE_KIT_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..1332969b --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.0.1" +} \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 779aaa91..a37aee71 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 -config_hash: dd05bc22f655304a173260e96c9588b2 +config_hash: 4fa07762cb363071cfdeef3f7eeec56e diff --git a/README.md b/README.md index 6c3bdf64..c329a208 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,12 @@ # ImageKit.io Java SDK + + [![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-java)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-java/0.0.1) [![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1) + + The ImageKit Java SDK is a comprehensive library designed to simplify the integration of ImageKit into your server-side applications. It provides powerful tools for working with the ImageKit REST API, including building and transforming URLs, generating signed URLs for secure content delivery, verifying webhooks, and handling file uploads. The full API of this library can be found in [api.md](api.md). @@ -33,8 +37,25 @@ For additional details, refer to the [ImageKit REST API documentation](https://i - [Logging](#logging) - [Semantic versioning](#semantic-versioning) +## MCP Server + +Use the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application. + +[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19) +[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D) + +> Note: You may need to set environment variables in your MCP client. + + + +The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1). + + + ## Installation + + ### Gradle ```kotlin @@ -51,6 +72,8 @@ implementation("com.imagekit.api:image-kit-java:0.0.1") ``` + + ## Requirements This library requires Java 8 or later. @@ -1014,4 +1037,4 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. -We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/imagekit-java/issues) with questions, bugs, or suggestions. +We are keen for your feedback; please open an [issue](https://www.github.com/imagekit-developer/imagekit-java/issues) with questions, bugs, or suggestions. diff --git a/bin/check-release-environment b/bin/check-release-environment new file mode 100644 index 00000000..3a6a7b4a --- /dev/null +++ b/bin/check-release-environment @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +errors=() + +if [ -z "${SONATYPE_USERNAME}" ]; then + errors+=("The SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +if [ -z "${SONATYPE_PASSWORD}" ]; then + errors+=("The SONATYPE_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +if [ -z "${GPG_SIGNING_KEY}" ]; then + errors+=("The GPG_SIGNING_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +if [ -z "${GPG_SIGNING_PASSWORD}" ]; then + errors+=("The GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +lenErrors=${#errors[@]} + +if [[ lenErrors -gt 0 ]]; then + echo -e "Found the following errors in the release environment:\n" + + for error in "${errors[@]}"; do + echo -e "- $error\n" + done + + exit 1 +fi + +echo "The environment is ready to push releases!" diff --git a/build.gradle.kts b/build.gradle.kts index 7712ede0..ce9ad14f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ repositories { allprojects { group = "com.imagekit.api" - version = "0.0.1" + version = "0.0.1" // x-release-please-version } subprojects { diff --git a/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts b/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts index 2ab3f74a..995d7f2e 100644 --- a/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts @@ -27,9 +27,9 @@ configure { } scm { - connection.set("scm:git:git://github.com/stainless-sdks/imagekit-java.git") - developerConnection.set("scm:git:git://github.com/stainless-sdks/imagekit-java.git") - url.set("https://github.com/stainless-sdks/imagekit-java") + connection.set("scm:git:git://github.com/imagekit-developer/imagekit-java.git") + developerConnection.set("scm:git:git://github.com/imagekit-developer/imagekit-java.git") + url.set("https://github.com/imagekit-developer/imagekit-java") } versionMapping { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Check.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Check.kt index 93bcc538..f587fcc9 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Check.kt +++ b/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Check.kt @@ -77,7 +77,7 @@ This can happen if you are either: Double-check that you are depending on compatible Jackson versions. -See https://www.github.com/stainless-sdks/imagekit-java#jackson for more information. +See https://www.github.com/imagekit-developer/imagekit-java#jackson for more information. """ .trimIndent() } diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..8f987198 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,67 @@ +{ + "packages": { + ".": {} + }, + "$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json", + "include-v-in-tag": true, + "include-component-in-tag": false, + "versioning": "prerelease", + "prerelease": true, + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": false, + "pull-request-header": "Automated Release PR", + "pull-request-title-pattern": "release: ${version}", + "changelog-sections": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "perf", + "section": "Performance Improvements" + }, + { + "type": "revert", + "section": "Reverts" + }, + { + "type": "chore", + "section": "Chores" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "style", + "section": "Styles" + }, + { + "type": "refactor", + "section": "Refactors" + }, + { + "type": "test", + "section": "Tests", + "hidden": true + }, + { + "type": "build", + "section": "Build System" + }, + { + "type": "ci", + "section": "Continuous Integration", + "hidden": true + } + ], + "release-type": "simple", + "extra-files": [ + "README.md", + "build.gradle.kts" + ] +} \ No newline at end of file From b586d513361b7ed938fb9a4c29a44a9e47e1cca2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 07:13:03 +0000 Subject: [PATCH 138/142] feat(api): manual updates --- .github/workflows/publish-sonatype.yml | 2 +- .stats.yml | 2 +- build.gradle.kts | 15 +-- buildSrc/build.gradle.kts | 3 + .../src/main/kotlin/image-kit.java.gradle.kts | 9 -- .../main/kotlin/image-kit.publish.gradle.kts | 107 +++++++++--------- .../io}/client/okhttp/ImageKitOkHttpClient.kt | 22 ++-- .../okhttp/ImageKitOkHttpClientAsync.kt | 22 ++-- .../io}/client/okhttp/OkHttpClient.kt | 22 ++-- .../io}/client/okhttp/OkHttpClientTest.kt | 6 +- .../imagekit/io}/client/ImageKitClient.kt | 0 .../io}/client/ImageKitClientAsync.kt | 0 .../io}/client/ImageKitClientAsyncImpl.kt | 0 .../imagekit/io}/client/ImageKitClientImpl.kt | 0 .../imagekit/io}/core/BaseDeserializer.kt | 2 +- .../imagekit/io}/core/BaseSerializer.kt | 2 +- .../api => io/imagekit/io}/core/Check.kt | 2 +- .../imagekit/io}/core/ClientOptions.kt | 16 +-- .../imagekit/io}/core/DefaultSleeper.kt | 2 +- .../imagekit/io}/core/ObjectMappers.kt | 2 +- .../api => io/imagekit/io}/core/Params.kt | 6 +- .../imagekit/io}/core/PhantomReachable.kt | 4 +- .../core/PhantomReachableExecutorService.kt | 2 +- .../io}/core/PhantomReachableSleeper.kt | 2 +- .../imagekit/io}/core/PrepareRequest.kt | 4 +- .../api => io/imagekit/io}/core/Properties.kt | 4 +- .../imagekit/io}/core/RequestOptions.kt | 2 +- .../api => io/imagekit/io}/core/Sleeper.kt | 2 +- .../api => io/imagekit/io}/core/Timeout.kt | 2 +- .../imagekit/io}/core/UnwrapWebhookParams.kt | 4 +- .../api => io/imagekit/io}/core/Utils.kt | 4 +- .../api => io/imagekit/io}/core/Values.kt | 4 +- .../io}/core/handlers/EmptyHandler.kt | 6 +- .../io}/core/handlers/ErrorHandler.kt | 26 ++--- .../imagekit/io}/core/handlers/JsonHandler.kt | 8 +- .../io}/core/handlers/StringHandler.kt | 6 +- .../io}/core/http/AsyncStreamResponse.kt | 4 +- .../imagekit/io}/core/http/Headers.kt | 22 ++-- .../imagekit/io}/core/http/HttpClient.kt | 4 +- .../imagekit/io}/core/http/HttpMethod.kt | 2 +- .../imagekit/io}/core/http/HttpRequest.kt | 6 +- .../io}/core/http/HttpRequestBodies.kt | 8 +- .../imagekit/io}/core/http/HttpRequestBody.kt | 2 +- .../imagekit/io}/core/http/HttpResponse.kt | 2 +- .../imagekit/io}/core/http/HttpResponseFor.kt | 2 +- ...ntomReachableClosingAsyncStreamResponse.kt | 6 +- .../http/PhantomReachableClosingHttpClient.kt | 6 +- .../PhantomReachableClosingStreamResponse.kt | 4 +- .../imagekit/io}/core/http/QueryParams.kt | 22 ++-- .../io}/core/http/RetryingHttpClient.kt | 16 +-- .../imagekit/io}/core/http/StreamResponse.kt | 2 +- .../io}/errors/BadRequestException.kt | 8 +- .../imagekit/io}/errors/ImageKitException.kt | 2 +- .../errors/ImageKitInvalidDataException.kt | 2 +- .../io}/errors/ImageKitIoException.kt | 2 +- .../io}/errors/ImageKitRetryableException.kt | 2 +- .../io}/errors/ImageKitServiceException.kt | 6 +- .../io}/errors/ImageKitWebhookException.kt | 2 +- .../io}/errors/InternalServerException.kt | 8 +- .../imagekit/io}/errors/NotFoundException.kt | 8 +- .../io}/errors/PermissionDeniedException.kt | 8 +- .../imagekit/io}/errors/RateLimitException.kt | 8 +- .../io}/errors/UnauthorizedException.kt | 8 +- .../errors/UnexpectedStatusCodeException.kt | 8 +- .../errors/UnprocessableEntityException.kt | 8 +- .../api => io/imagekit/io}/models/AiTag.kt | 12 +- .../imagekit/io}/models/BaseOverlay.kt | 14 +-- .../imagekit/io}/models/CustomMetadata.kt | 10 +- .../imagekit/io}/models/EmbeddedMetadata.kt | 10 +- .../imagekit/io}/models/ExtensionConfig.kt | 28 ++--- .../imagekit/io}/models/ExtensionItem.kt | 28 ++--- .../io}/models/GetImageAttributesOptions.kt | 18 +-- .../imagekit/io}/models/ImageOverlay.kt | 20 ++-- .../api => io/imagekit/io}/models/Overlay.kt | 12 +- .../imagekit/io}/models/OverlayPosition.kt | 22 ++-- .../imagekit/io}/models/OverlayTiming.kt | 20 ++-- .../io}/models/ResponsiveImageAttributes.kt | 14 +-- .../imagekit/io}/models/SavedExtension.kt | 12 +- .../io}/models/SelectedFieldsSchema.kt | 10 +- .../imagekit/io}/models/SolidColorOverlay.kt | 18 +-- .../models/SolidColorOverlayTransformation.kt | 20 ++-- .../imagekit/io}/models/SrcOptions.kt | 18 +-- .../io}/models/StreamingResolution.kt | 8 +- .../imagekit/io}/models/SubtitleOverlay.kt | 20 ++-- .../models/SubtitleOverlayTransformation.kt | 14 +-- .../imagekit/io}/models/TextOverlay.kt | 20 ++-- .../io}/models/TextOverlayTransformation.kt | 22 ++-- .../imagekit/io}/models/Transformation.kt | 26 ++--- .../io}/models/TransformationPosition.kt | 8 +- .../imagekit/io}/models/VersionInfo.kt | 12 +- .../imagekit/io}/models/VideoOverlay.kt | 20 ++-- .../accounts/origins/OriginCreateParams.kt | 10 +- .../accounts/origins/OriginDeleteParams.kt | 12 +- .../accounts/origins/OriginGetParams.kt | 8 +- .../accounts/origins/OriginListParams.kt | 8 +- .../models/accounts/origins/OriginRequest.kt | 20 ++-- .../models/accounts/origins/OriginResponse.kt | 20 ++-- .../accounts/origins/OriginUpdateParams.kt | 10 +- .../urlendpoints/UrlEndpointCreateParams.kt | 12 +- .../urlendpoints/UrlEndpointDeleteParams.kt | 12 +- .../urlendpoints/UrlEndpointGetParams.kt | 8 +- .../urlendpoints/UrlEndpointListParams.kt | 8 +- .../urlendpoints/UrlEndpointRequest.kt | 24 ++-- .../urlendpoints/UrlEndpointResponse.kt | 24 ++-- .../urlendpoints/UrlEndpointUpdateParams.kt | 12 +- .../models/accounts/usage/UsageGetParams.kt | 10 +- .../models/accounts/usage/UsageGetResponse.kt | 12 +- .../io}/models/assets/AssetListParams.kt | 14 +-- .../io}/models/assets/AssetListResponse.kt | 16 +-- .../models/beta/v2/files/FileUploadParams.kt | 0 .../beta/v2/files/FileUploadResponse.kt | 30 ++--- .../invalidation/InvalidationCreateParams.kt | 20 ++-- .../InvalidationCreateResponse.kt | 12 +- .../invalidation/InvalidationGetParams.kt | 8 +- .../invalidation/InvalidationGetResponse.kt | 14 +-- .../CustomMetadataField.kt | 28 ++--- .../CustomMetadataFieldCreateParams.kt | 34 +++--- .../CustomMetadataFieldDeleteParams.kt | 12 +- .../CustomMetadataFieldDeleteResponse.kt | 8 +- .../CustomMetadataFieldListParams.kt | 8 +- .../CustomMetadataFieldUpdateParams.kt | 30 ++--- .../imagekit/io}/models/files/File.kt | 28 ++--- .../io}/models/files/FileCopyParams.kt | 20 ++-- .../io}/models/files/FileCopyResponse.kt | 8 +- .../io}/models/files/FileDeleteParams.kt | 12 +- .../io}/models/files/FileGetParams.kt | 8 +- .../io}/models/files/FileMoveParams.kt | 20 ++-- .../io}/models/files/FileMoveResponse.kt | 8 +- .../io}/models/files/FileRenameParams.kt | 20 ++-- .../io}/models/files/FileRenameResponse.kt | 12 +- .../io}/models/files/FileUpdateParams.kt | 10 +- .../io}/models/files/FileUpdateResponse.kt | 28 ++--- .../io}/models/files/FileUploadParams.kt | 0 .../io}/models/files/FileUploadResponse.kt | 28 ++--- .../imagekit/io}/models/files/Folder.kt | 16 +-- .../imagekit/io}/models/files/Metadata.kt | 16 +-- .../io}/models/files/UpdateFileRequest.kt | 28 ++--- .../models/files/bulk/BulkAddTagsParams.kt | 24 ++-- .../models/files/bulk/BulkAddTagsResponse.kt | 16 +-- .../io}/models/files/bulk/BulkDeleteParams.kt | 24 ++-- .../models/files/bulk/BulkDeleteResponse.kt | 16 +-- .../files/bulk/BulkRemoveAiTagsParams.kt | 24 ++-- .../files/bulk/BulkRemoveAiTagsResponse.kt | 16 +-- .../models/files/bulk/BulkRemoveTagsParams.kt | 24 ++-- .../files/bulk/BulkRemoveTagsResponse.kt | 16 +-- .../metadata/MetadataGetFromUrlParams.kt | 10 +- .../files/metadata/MetadataGetParams.kt | 8 +- .../files/versions/VersionDeleteParams.kt | 16 +-- .../files/versions/VersionDeleteResponse.kt | 8 +- .../models/files/versions/VersionGetParams.kt | 10 +- .../files/versions/VersionListParams.kt | 8 +- .../files/versions/VersionRestoreParams.kt | 16 +-- .../io}/models/folders/FolderCopyParams.kt | 20 ++-- .../io}/models/folders/FolderCopyResponse.kt | 14 +-- .../io}/models/folders/FolderCreateParams.kt | 20 ++-- .../models/folders/FolderCreateResponse.kt | 8 +- .../io}/models/folders/FolderDeleteParams.kt | 20 ++-- .../models/folders/FolderDeleteResponse.kt | 8 +- .../io}/models/folders/FolderMoveParams.kt | 20 ++-- .../io}/models/folders/FolderMoveResponse.kt | 14 +-- .../io}/models/folders/FolderRenameParams.kt | 20 ++-- .../models/folders/FolderRenameResponse.kt | 14 +-- .../io}/models/folders/job/JobGetParams.kt | 8 +- .../io}/models/folders/job/JobGetResponse.kt | 14 +-- .../SavedExtensionCreateParams.kt | 22 ++-- .../SavedExtensionDeleteParams.kt | 12 +- .../SavedExtensionGetParams.kt | 8 +- .../SavedExtensionListParams.kt | 8 +- .../SavedExtensionUpdateParams.kt | 20 ++-- .../io}/models/webhooks/BaseWebhookEvent.kt | 14 +-- .../io}/models/webhooks/FileCreateEvent.kt | 16 +-- .../io}/models/webhooks/FileDeleteEvent.kt | 14 +-- .../io}/models/webhooks/FileUpdateEvent.kt | 16 +-- .../models/webhooks/FileVersionCreateEvent.kt | 16 +-- .../models/webhooks/FileVersionDeleteEvent.kt | 14 +-- .../webhooks/UnsafeUnwrapWebhookEvent.kt | 14 +-- .../io}/models/webhooks/UnwrapWebhookEvent.kt | 14 +-- .../webhooks/UploadPostTransformErrorEvent.kt | 16 +-- .../UploadPostTransformSuccessEvent.kt | 16 +-- .../webhooks/UploadPreTransformErrorEvent.kt | 14 +-- .../UploadPreTransformSuccessEvent.kt | 32 +++--- .../VideoTransformationAcceptedEvent.kt | 20 ++-- .../webhooks/VideoTransformationErrorEvent.kt | 20 ++-- .../webhooks/VideoTransformationReadyEvent.kt | 20 ++-- .../io}/services/async/AccountServiceAsync.kt | 10 +- .../services/async/AccountServiceAsyncImpl.kt | 18 +-- .../io}/services/async/AssetServiceAsync.kt | 12 +- .../services/async/AssetServiceAsyncImpl.kt | 30 ++--- .../io}/services/async/BetaServiceAsync.kt | 6 +- .../services/async/BetaServiceAsyncImpl.kt | 8 +- .../io}/services/async/CacheServiceAsync.kt | 6 +- .../services/async/CacheServiceAsyncImpl.kt | 8 +- .../async/CustomMetadataFieldServiceAsync.kt | 22 ++-- .../CustomMetadataFieldServiceAsyncImpl.kt | 44 +++---- .../io}/services/async/FileServiceAsync.kt | 44 +++---- .../services/async/FileServiceAsyncImpl.kt | 74 ++++++------ .../io}/services/async/FolderServiceAsync.kt | 32 +++--- .../services/async/FolderServiceAsyncImpl.kt | 52 ++++----- .../async/SavedExtensionServiceAsync.kt | 24 ++-- .../async/SavedExtensionServiceAsyncImpl.kt | 46 ++++---- .../io}/services/async/WebhookServiceAsync.kt | 16 +-- .../services/async/WebhookServiceAsyncImpl.kt | 12 +- .../async/accounts/OriginServiceAsync.kt | 26 ++--- .../async/accounts/OriginServiceAsyncImpl.kt | 46 ++++---- .../async/accounts/UrlEndpointServiceAsync.kt | 26 ++--- .../accounts/UrlEndpointServiceAsyncImpl.kt | 46 ++++---- .../async/accounts/UsageServiceAsync.kt | 12 +- .../async/accounts/UsageServiceAsyncImpl.kt | 30 ++--- .../io}/services/async/beta/V2ServiceAsync.kt | 6 +- .../services/async/beta/V2ServiceAsyncImpl.kt | 8 +- .../async/beta/v2/FileServiceAsync.kt | 12 +- .../async/beta/v2/FileServiceAsyncImpl.kt | 32 +++--- .../async/cache/InvalidationServiceAsync.kt | 18 +-- .../cache/InvalidationServiceAsyncImpl.kt | 38 +++---- .../services/async/files/BulkServiceAsync.kt | 26 ++--- .../async/files/BulkServiceAsyncImpl.kt | 46 ++++---- .../async/files/MetadataServiceAsync.kt | 16 +-- .../async/files/MetadataServiceAsyncImpl.kt | 34 +++--- .../async/files/VersionServiceAsync.kt | 22 ++-- .../async/files/VersionServiceAsyncImpl.kt | 44 +++---- .../services/async/folders/JobServiceAsync.kt | 12 +- .../async/folders/JobServiceAsyncImpl.kt | 32 +++--- .../io}/services/blocking/AccountService.kt | 10 +- .../services/blocking/AccountServiceImpl.kt | 18 +-- .../io}/services/blocking/AssetService.kt | 12 +- .../io}/services/blocking/AssetServiceImpl.kt | 30 ++--- .../io}/services/blocking/BetaService.kt | 6 +- .../io}/services/blocking/BetaServiceImpl.kt | 8 +- .../io}/services/blocking/CacheService.kt | 6 +- .../io}/services/blocking/CacheServiceImpl.kt | 8 +- .../blocking/CustomMetadataFieldService.kt | 20 ++-- .../CustomMetadataFieldServiceImpl.kt | 44 +++---- .../io}/services/blocking/FileService.kt | 42 +++---- .../io}/services/blocking/FileServiceImpl.kt | 74 ++++++------ .../io}/services/blocking/FolderService.kt | 30 ++--- .../services/blocking/FolderServiceImpl.kt | 54 ++++----- .../blocking/SavedExtensionService.kt | 22 ++-- .../blocking/SavedExtensionServiceImpl.kt | 46 ++++---- .../io}/services/blocking/WebhookService.kt | 16 +-- .../services/blocking/WebhookServiceImpl.kt | 0 .../blocking/accounts/OriginService.kt | 24 ++-- .../blocking/accounts/OriginServiceImpl.kt | 46 ++++---- .../blocking/accounts/UrlEndpointService.kt | 24 ++-- .../accounts/UrlEndpointServiceImpl.kt | 46 ++++---- .../blocking/accounts/UsageService.kt | 12 +- .../blocking/accounts/UsageServiceImpl.kt | 30 ++--- .../io}/services/blocking/beta/V2Service.kt | 6 +- .../services/blocking/beta/V2ServiceImpl.kt | 8 +- .../services/blocking/beta/v2/FileService.kt | 12 +- .../blocking/beta/v2/FileServiceImpl.kt | 32 +++--- .../blocking/cache/InvalidationService.kt | 16 +-- .../blocking/cache/InvalidationServiceImpl.kt | 38 +++---- .../services/blocking/files/BulkService.kt | 24 ++-- .../blocking/files/BulkServiceImpl.kt | 46 ++++---- .../blocking/files/MetadataService.kt | 14 +-- .../blocking/files/MetadataServiceImpl.kt | 34 +++--- .../services/blocking/files/VersionService.kt | 20 ++-- .../blocking/files/VersionServiceImpl.kt | 44 +++---- .../services/blocking/folders/JobService.kt | 12 +- .../blocking/folders/JobServiceImpl.kt | 32 +++--- .../META-INF/proguard/image-kit-java-core.pro | 6 +- .../imagekit/io}/core/ClientOptionsTest.kt | 4 +- .../imagekit/io}/core/ObjectMappersTest.kt | 2 +- .../imagekit/io}/core/PhantomReachableTest.kt | 2 +- .../api => io/imagekit/io}/core/UtilsTest.kt | 2 +- .../api => io/imagekit/io}/core/ValuesTest.kt | 2 +- .../io}/core/http/AsyncStreamResponseTest.kt | 2 +- .../imagekit/io}/core/http/HeadersTest.kt | 2 +- .../io}/core/http/HttpRequestBodiesTest.kt | 6 +- .../imagekit/io}/core/http/HttpRequestTest.kt | 2 +- .../imagekit/io}/core/http/QueryParamsTest.kt | 2 +- .../io}/core/http/RetryingHttpClientTest.kt | 10 +- .../imagekit/io}/models/AiTagTest.kt | 4 +- .../imagekit/io}/models/BaseOverlayTest.kt | 4 +- .../imagekit/io}/models/CustomMetadataTest.kt | 6 +- .../io}/models/EmbeddedMetadataTest.kt | 6 +- .../io}/models/ExtensionConfigTest.kt | 8 +- .../imagekit/io}/models/ExtensionItemTest.kt | 8 +- .../models/GetImageAttributesOptionsTest.kt | 6 +- .../imagekit/io}/models/ImageOverlayTest.kt | 4 +- .../io}/models/OverlayPositionTest.kt | 4 +- .../imagekit/io}/models/OverlayTest.kt | 8 +- .../imagekit/io}/models/OverlayTimingTest.kt | 4 +- .../models/ResponsiveImageAttributesTest.kt | 4 +- .../imagekit/io}/models/SavedExtensionTest.kt | 4 +- .../io}/models/SelectedFieldsSchemaTest.kt | 6 +- .../io}/models/SolidColorOverlayTest.kt | 4 +- .../SolidColorOverlayTransformationTest.kt | 4 +- .../imagekit/io}/models/SrcOptionsTest.kt | 6 +- .../io}/models/SubtitleOverlayTest.kt | 4 +- .../SubtitleOverlayTransformationTest.kt | 4 +- .../imagekit/io}/models/TextOverlayTest.kt | 4 +- .../models/TextOverlayTransformationTest.kt | 4 +- .../imagekit/io}/models/TransformationTest.kt | 4 +- .../imagekit/io}/models/VersionInfoTest.kt | 4 +- .../imagekit/io}/models/VideoOverlayTest.kt | 4 +- .../origins/OriginCreateParamsTest.kt | 2 +- .../origins/OriginDeleteParamsTest.kt | 2 +- .../accounts/origins/OriginGetParamsTest.kt | 2 +- .../accounts/origins/OriginListParamsTest.kt | 2 +- .../accounts/origins/OriginRequestTest.kt | 8 +- .../accounts/origins/OriginResponseTest.kt | 8 +- .../origins/OriginUpdateParamsTest.kt | 2 +- .../UrlEndpointCreateParamsTest.kt | 2 +- .../UrlEndpointDeleteParamsTest.kt | 2 +- .../urlendpoints/UrlEndpointGetParamsTest.kt | 2 +- .../urlendpoints/UrlEndpointListParamsTest.kt | 2 +- .../urlendpoints/UrlEndpointRequestTest.kt | 4 +- .../urlendpoints/UrlEndpointResponseTest.kt | 4 +- .../UrlEndpointUpdateParamsTest.kt | 2 +- .../accounts/usage/UsageGetParamsTest.kt | 4 +- .../accounts/usage/UsageGetResponseTest.kt | 4 +- .../io}/models/assets/AssetListParamsTest.kt | 4 +- .../models/assets/AssetListResponseTest.kt | 22 ++-- .../beta/v2/files/FileUploadParamsTest.kt | 8 +- .../beta/v2/files/FileUploadResponseTest.kt | 18 +-- .../InvalidationCreateParamsTest.kt | 2 +- .../InvalidationCreateResponseTest.kt | 4 +- .../invalidation/InvalidationGetParamsTest.kt | 2 +- .../InvalidationGetResponseTest.kt | 4 +- .../CustomMetadataFieldCreateParamsTest.kt | 2 +- .../CustomMetadataFieldDeleteParamsTest.kt | 2 +- .../CustomMetadataFieldDeleteResponseTest.kt | 4 +- .../CustomMetadataFieldListParamsTest.kt | 4 +- .../CustomMetadataFieldTest.kt | 4 +- .../CustomMetadataFieldUpdateParamsTest.kt | 2 +- .../io}/models/files/FileCopyParamsTest.kt | 2 +- .../io}/models/files/FileCopyResponseTest.kt | 4 +- .../io}/models/files/FileDeleteParamsTest.kt | 2 +- .../io}/models/files/FileGetParamsTest.kt | 2 +- .../io}/models/files/FileMoveParamsTest.kt | 2 +- .../io}/models/files/FileMoveResponseTest.kt | 4 +- .../io}/models/files/FileRenameParamsTest.kt | 2 +- .../models/files/FileRenameResponseTest.kt | 4 +- .../imagekit/io}/models/files/FileTest.kt | 16 +-- .../io}/models/files/FileUpdateParamsTest.kt | 6 +- .../models/files/FileUpdateResponseTest.kt | 16 +-- .../io}/models/files/FileUploadParamsTest.kt | 8 +- .../models/files/FileUploadResponseTest.kt | 16 +-- .../imagekit/io}/models/files/FolderTest.kt | 6 +- .../imagekit/io}/models/files/MetadataTest.kt | 6 +- .../io}/models/files/UpdateFileRequestTest.kt | 10 +- .../files/bulk/BulkAddTagsParamsTest.kt | 2 +- .../files/bulk/BulkAddTagsResponseTest.kt | 4 +- .../models/files/bulk/BulkDeleteParamsTest.kt | 2 +- .../files/bulk/BulkDeleteResponseTest.kt | 4 +- .../files/bulk/BulkRemoveAiTagsParamsTest.kt | 2 +- .../bulk/BulkRemoveAiTagsResponseTest.kt | 4 +- .../files/bulk/BulkRemoveTagsParamsTest.kt | 2 +- .../files/bulk/BulkRemoveTagsResponseTest.kt | 4 +- .../metadata/MetadataGetFromUrlParamsTest.kt | 4 +- .../files/metadata/MetadataGetParamsTest.kt | 2 +- .../files/versions/VersionDeleteParamsTest.kt | 2 +- .../versions/VersionDeleteResponseTest.kt | 4 +- .../files/versions/VersionGetParamsTest.kt | 2 +- .../files/versions/VersionListParamsTest.kt | 2 +- .../versions/VersionRestoreParamsTest.kt | 2 +- .../models/folders/FolderCopyParamsTest.kt | 2 +- .../models/folders/FolderCopyResponseTest.kt | 4 +- .../models/folders/FolderCreateParamsTest.kt | 2 +- .../folders/FolderCreateResponseTest.kt | 4 +- .../models/folders/FolderDeleteParamsTest.kt | 2 +- .../folders/FolderDeleteResponseTest.kt | 4 +- .../models/folders/FolderMoveParamsTest.kt | 2 +- .../models/folders/FolderMoveResponseTest.kt | 4 +- .../models/folders/FolderRenameParamsTest.kt | 2 +- .../folders/FolderRenameResponseTest.kt | 4 +- .../models/folders/job/JobGetParamsTest.kt | 2 +- .../models/folders/job/JobGetResponseTest.kt | 4 +- .../SavedExtensionCreateParamsTest.kt | 4 +- .../SavedExtensionDeleteParamsTest.kt | 2 +- .../SavedExtensionGetParamsTest.kt | 2 +- .../SavedExtensionListParamsTest.kt | 2 +- .../SavedExtensionUpdateParamsTest.kt | 4 +- .../models/webhooks/BaseWebhookEventTest.kt | 4 +- .../models/webhooks/FileCreateEventTest.kt | 18 +-- .../models/webhooks/FileDeleteEventTest.kt | 4 +- .../models/webhooks/FileUpdateEventTest.kt | 18 +-- .../webhooks/FileVersionCreateEventTest.kt | 18 +-- .../webhooks/FileVersionDeleteEventTest.kt | 4 +- .../webhooks/UnsafeUnwrapWebhookEventTest.kt | 22 ++-- .../models/webhooks/UnwrapWebhookEventTest.kt | 22 ++-- .../UploadPostTransformErrorEventTest.kt | 4 +- .../UploadPostTransformSuccessEventTest.kt | 4 +- .../UploadPreTransformErrorEventTest.kt | 4 +- .../UploadPreTransformSuccessEventTest.kt | 18 +-- .../VideoTransformationAcceptedEventTest.kt | 4 +- .../VideoTransformationErrorEventTest.kt | 4 +- .../VideoTransformationReadyEventTest.kt | 4 +- .../io}/services/ErrorHandlingTest.kt | 34 +++--- .../io}/services/ServiceParamsTest.kt | 12 +- .../services/async/AssetServiceAsyncTest.kt | 6 +- .../CustomMetadataFieldServiceAsyncTest.kt | 10 +- .../services/async/FileServiceAsyncTest.kt | 20 ++-- .../services/async/FolderServiceAsyncTest.kt | 16 +-- .../async/SavedExtensionServiceAsyncTest.kt | 10 +- .../services/async/WebhookServiceAsyncTest.kt | 10 +- .../async/accounts/OriginServiceAsyncTest.kt | 8 +- .../accounts/UrlEndpointServiceAsyncTest.kt | 8 +- .../async/accounts/UsageServiceAsyncTest.kt | 6 +- .../async/beta/v2/FileServiceAsyncTest.kt | 10 +- .../cache/InvalidationServiceAsyncTest.kt | 6 +- .../async/files/BulkServiceAsyncTest.kt | 12 +- .../async/files/MetadataServiceAsyncTest.kt | 6 +- .../async/files/VersionServiceAsyncTest.kt | 10 +- .../async/folders/JobServiceAsyncTest.kt | 4 +- .../io}/services/blocking/AssetServiceTest.kt | 6 +- .../CustomMetadataFieldServiceTest.kt | 10 +- .../io}/services/blocking/FileServiceTest.kt | 20 ++-- .../services/blocking/FolderServiceTest.kt | 16 +-- .../blocking/SavedExtensionServiceTest.kt | 10 +- .../services/blocking/WebhookServiceTest.kt | 10 +- .../blocking/accounts/OriginServiceTest.kt | 8 +- .../accounts/UrlEndpointServiceTest.kt | 8 +- .../blocking/accounts/UsageServiceTest.kt | 6 +- .../blocking/beta/v2/FileServiceTest.kt | 10 +- .../blocking/cache/InvalidationServiceTest.kt | 6 +- .../blocking/files/BulkServiceTest.kt | 12 +- .../blocking/files/MetadataServiceTest.kt | 6 +- .../blocking/files/VersionServiceTest.kt | 10 +- .../blocking/folders/JobServiceTest.kt | 4 +- image-kit-java-proguard-test/build.gradle.kts | 4 +- .../io}/proguard/ProGuardCompatibilityTest.kt | 26 ++--- image-kit-java-proguard-test/test.pro | 2 +- 424 files changed, 2673 insertions(+), 2689 deletions(-) rename image-kit-java-client-okhttp/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/client/okhttp/ImageKitOkHttpClient.kt (96%) rename image-kit-java-client-okhttp/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/client/okhttp/ImageKitOkHttpClientAsync.kt (96%) rename image-kit-java-client-okhttp/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/client/okhttp/OkHttpClient.kt (96%) rename image-kit-java-client-okhttp/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/client/okhttp/OkHttpClientTest.kt (91%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/client/ImageKitClient.kt (100%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/client/ImageKitClientAsync.kt (100%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/client/ImageKitClientAsyncImpl.kt (100%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/client/ImageKitClientImpl.kt (100%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/BaseDeserializer.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/BaseSerializer.kt (85%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/Check.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/ClientOptions.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/DefaultSleeper.kt (95%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/ObjectMappers.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/Params.kt (76%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/PhantomReachable.kt (96%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/PhantomReachableExecutorService.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/PhantomReachableSleeper.kt (95%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/PrepareRequest.kt (90%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/Properties.kt (93%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/RequestOptions.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/Sleeper.kt (95%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/Timeout.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/UnwrapWebhookParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/Utils.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/Values.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/handlers/EmptyHandler.kt (62%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/handlers/ErrorHandler.kt (81%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/handlers/JsonHandler.kt (73%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/handlers/StringHandler.kt (67%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/http/AsyncStreamResponse.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/http/Headers.kt (88%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/http/HttpClient.kt (90%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/http/HttpMethod.kt (78%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/http/HttpRequest.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/http/HttpRequestBodies.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/http/HttpRequestBody.kt (95%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/http/HttpResponse.kt (92%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/http/HttpResponseFor.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/http/PhantomReachableClosingAsyncStreamResponse.kt (92%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/http/PhantomReachableClosingHttpClient.kt (85%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/http/PhantomReachableClosingStreamResponse.kt (86%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/http/QueryParams.kt (90%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/http/RetryingHttpClient.kt (96%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/core/http/StreamResponse.kt (93%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/errors/BadRequestException.kt (93%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/errors/ImageKitException.kt (81%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/errors/ImageKitInvalidDataException.kt (82%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/errors/ImageKitIoException.kt (81%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/errors/ImageKitRetryableException.kt (93%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/errors/ImageKitServiceException.kt (73%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/errors/ImageKitWebhookException.kt (81%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/errors/InternalServerException.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/errors/NotFoundException.kt (93%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/errors/PermissionDeniedException.kt (93%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/errors/RateLimitException.kt (93%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/errors/UnauthorizedException.kt (93%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/errors/UnexpectedStatusCodeException.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/errors/UnprocessableEntityException.kt (93%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/AiTag.kt (96%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/BaseOverlay.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/CustomMetadata.kt (93%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/EmbeddedMetadata.kt (93%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/ExtensionConfig.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/ExtensionItem.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/GetImageAttributesOptions.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/ImageOverlay.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/Overlay.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/OverlayPosition.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/OverlayTiming.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/ResponsiveImageAttributes.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/SavedExtension.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/SelectedFieldsSchema.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/SolidColorOverlay.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/SolidColorOverlayTransformation.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/SrcOptions.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/StreamingResolution.kt (96%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/SubtitleOverlay.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/SubtitleOverlayTransformation.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/TextOverlay.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/TextOverlayTransformation.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/Transformation.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/TransformationPosition.kt (96%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/VersionInfo.kt (96%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/VideoOverlay.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/origins/OriginCreateParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/origins/OriginDeleteParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/origins/OriginGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/origins/OriginListParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/origins/OriginRequest.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/origins/OriginResponse.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/origins/OriginUpdateParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/urlendpoints/UrlEndpointCreateParams.kt (96%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/urlendpoints/UrlEndpointGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/urlendpoints/UrlEndpointListParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/urlendpoints/UrlEndpointRequest.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/urlendpoints/UrlEndpointResponse.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/usage/UsageGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/usage/UsageGetResponse.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/assets/AssetListParams.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/assets/AssetListResponse.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/beta/v2/files/FileUploadParams.kt (100%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/beta/v2/files/FileUploadResponse.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/cache/invalidation/InvalidationCreateParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/cache/invalidation/InvalidationCreateResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/cache/invalidation/InvalidationGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/cache/invalidation/InvalidationGetResponse.kt (96%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/custommetadatafields/CustomMetadataField.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/custommetadatafields/CustomMetadataFieldCreateParams.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/custommetadatafields/CustomMetadataFieldListParams.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/File.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileCopyParams.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileCopyResponse.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileDeleteParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileMoveParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileMoveResponse.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileRenameParams.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileRenameResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileUpdateParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileUpdateResponse.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileUploadParams.kt (100%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileUploadResponse.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/Folder.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/Metadata.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/UpdateFileRequest.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/bulk/BulkAddTagsParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/bulk/BulkAddTagsResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/bulk/BulkDeleteParams.kt (96%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/bulk/BulkDeleteResponse.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/bulk/BulkRemoveAiTagsParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/bulk/BulkRemoveAiTagsResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/bulk/BulkRemoveTagsParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/bulk/BulkRemoveTagsResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/metadata/MetadataGetFromUrlParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/metadata/MetadataGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/versions/VersionDeleteParams.kt (96%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/versions/VersionDeleteResponse.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/versions/VersionGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/versions/VersionListParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/versions/VersionRestoreParams.kt (96%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/FolderCopyParams.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/FolderCopyResponse.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/FolderCreateParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/FolderCreateResponse.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/FolderDeleteParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/FolderDeleteResponse.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/FolderMoveParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/FolderMoveResponse.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/FolderRenameParams.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/FolderRenameResponse.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/job/JobGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/job/JobGetResponse.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/savedextensions/SavedExtensionCreateParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/savedextensions/SavedExtensionDeleteParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/savedextensions/SavedExtensionGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/savedextensions/SavedExtensionListParams.kt (97%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/savedextensions/SavedExtensionUpdateParams.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/BaseWebhookEvent.kt (95%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/FileCreateEvent.kt (96%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/FileDeleteEvent.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/FileUpdateEvent.kt (96%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/FileVersionCreateEvent.kt (96%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/FileVersionDeleteEvent.kt (98%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/UnsafeUnwrapWebhookEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/UnwrapWebhookEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/UploadPostTransformErrorEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/UploadPostTransformSuccessEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/UploadPreTransformErrorEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/UploadPreTransformSuccessEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/VideoTransformationAcceptedEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/VideoTransformationErrorEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/VideoTransformationReadyEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/AccountServiceAsync.kt (81%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/AccountServiceAsyncImpl.kt (81%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/AssetServiceAsync.kt (91%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/AssetServiceAsyncImpl.kt (79%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/BetaServiceAsync.kt (87%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/BetaServiceAsyncImpl.kt (86%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/CacheServiceAsync.kt (87%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/CacheServiceAsyncImpl.kt (86%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/CustomMetadataFieldServiceAsync.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/CustomMetadataFieldServiceAsyncImpl.kt (88%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/FileServiceAsync.kt (92%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/FileServiceAsyncImpl.kt (88%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/FolderServiceAsync.kt (89%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/FolderServiceAsyncImpl.kt (87%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/SavedExtensionServiceAsync.kt (95%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/SavedExtensionServiceAsyncImpl.kt (89%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/WebhookServiceAsync.kt (82%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/WebhookServiceAsyncImpl.kt (82%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/accounts/OriginServiceAsync.kt (96%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/accounts/OriginServiceAsyncImpl.kt (89%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/accounts/UrlEndpointServiceAsync.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/accounts/UrlEndpointServiceAsyncImpl.kt (89%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/accounts/UsageServiceAsync.kt (87%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/accounts/UsageServiceAsyncImpl.kt (78%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/beta/V2ServiceAsync.kt (86%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/beta/V2ServiceAsyncImpl.kt (86%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/beta/v2/FileServiceAsync.kt (91%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/beta/v2/FileServiceAsyncImpl.kt (79%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/cache/InvalidationServiceAsync.kt (91%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/cache/InvalidationServiceAsyncImpl.kt (82%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/files/BulkServiceAsync.kt (88%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/files/BulkServiceAsyncImpl.kt (87%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/files/MetadataServiceAsync.kt (93%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/files/MetadataServiceAsyncImpl.kt (84%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/files/VersionServiceAsync.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/files/VersionServiceAsyncImpl.kt (89%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/folders/JobServiceAsync.kt (92%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/folders/JobServiceAsyncImpl.kt (79%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/AccountService.kt (80%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/AccountServiceImpl.kt (81%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/AssetService.kt (90%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/AssetServiceImpl.kt (77%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/BetaService.kt (87%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/BetaServiceImpl.kt (86%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/CacheService.kt (86%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/CacheServiceImpl.kt (86%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/CustomMetadataFieldService.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/CustomMetadataFieldServiceImpl.kt (86%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/FileService.kt (92%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/FileServiceImpl.kt (87%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/FolderService.kt (88%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/FolderServiceImpl.kt (86%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/SavedExtensionService.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/SavedExtensionServiceImpl.kt (88%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/WebhookService.kt (81%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/WebhookServiceImpl.kt (100%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/accounts/OriginService.kt (96%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/accounts/OriginServiceImpl.kt (88%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/accounts/UrlEndpointService.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/accounts/UrlEndpointServiceImpl.kt (87%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/accounts/UsageService.kt (86%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/accounts/UsageServiceImpl.kt (76%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/beta/V2Service.kt (86%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/beta/V2ServiceImpl.kt (85%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/beta/v2/FileService.kt (91%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/beta/v2/FileServiceImpl.kt (77%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/cache/InvalidationService.kt (91%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/cache/InvalidationServiceImpl.kt (81%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/files/BulkService.kt (88%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/files/BulkServiceImpl.kt (85%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/files/MetadataService.kt (92%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/files/MetadataServiceImpl.kt (82%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/files/VersionService.kt (94%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/files/VersionServiceImpl.kt (88%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/folders/JobService.kt (91%) rename image-kit-java-core/src/main/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/folders/JobServiceImpl.kt (77%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/core/ClientOptionsTest.kt (96%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/core/ObjectMappersTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/core/PhantomReachableTest.kt (95%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/core/UtilsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/core/ValuesTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/core/http/AsyncStreamResponseTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/core/http/HeadersTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/core/http/HttpRequestBodiesTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/core/http/HttpRequestTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/core/http/QueryParamsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/core/http/RetryingHttpClientTest.kt (98%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/AiTagTest.kt (92%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/BaseOverlayTest.kt (97%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/CustomMetadataTest.kt (88%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/EmbeddedMetadataTest.kt (89%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/ExtensionConfigTest.kt (97%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/ExtensionItemTest.kt (97%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/GetImageAttributesOptionsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/ImageOverlayTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/OverlayPositionTest.kt (96%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/OverlayTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/OverlayTimingTest.kt (93%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/ResponsiveImageAttributesTest.kt (96%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/SavedExtensionTest.kt (98%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/SelectedFieldsSchemaTest.kt (95%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/SolidColorOverlayTest.kt (98%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/SolidColorOverlayTransformationTest.kt (96%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/SrcOptionsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/SubtitleOverlayTest.kt (98%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/SubtitleOverlayTransformationTest.kt (96%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/TextOverlayTest.kt (98%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/TextOverlayTransformationTest.kt (97%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/TransformationTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/VersionInfoTest.kt (92%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/VideoOverlayTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/origins/OriginCreateParamsTest.kt (98%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/origins/OriginDeleteParamsTest.kt (91%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/origins/OriginGetParamsTest.kt (91%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/origins/OriginListParamsTest.kt (81%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/origins/OriginRequestTest.kt (98%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/origins/OriginResponseTest.kt (98%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/origins/OriginUpdateParamsTest.kt (98%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt (90%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt (90%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt (80%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/urlendpoints/UrlEndpointRequestTest.kt (95%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/urlendpoints/UrlEndpointResponseTest.kt (95%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt (98%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/usage/UsageGetParamsTest.kt (90%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/accounts/usage/UsageGetResponseTest.kt (94%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/assets/AssetListParamsTest.kt (95%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/assets/AssetListResponseTest.kt (94%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/beta/v2/files/FileUploadParamsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/beta/v2/files/FileUploadResponseTest.kt (98%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/cache/invalidation/InvalidationCreateParamsTest.kt (93%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/cache/invalidation/InvalidationCreateResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/cache/invalidation/InvalidationGetParamsTest.kt (91%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/cache/invalidation/InvalidationGetResponseTest.kt (92%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt (91%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt (91%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/custommetadatafields/CustomMetadataFieldTest.kt (98%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileCopyParamsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileCopyResponseTest.kt (90%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileDeleteParamsTest.kt (93%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileGetParamsTest.kt (93%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileMoveParamsTest.kt (95%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileMoveResponseTest.kt (90%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileRenameParamsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileRenameResponseTest.kt (92%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileTest.kt (96%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileUpdateParamsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileUpdateResponseTest.kt (97%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileUploadParamsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FileUploadResponseTest.kt (98%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/FolderTest.kt (95%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/MetadataTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/UpdateFileRequestTest.kt (98%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/bulk/BulkAddTagsParamsTest.kt (95%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/bulk/BulkAddTagsResponseTest.kt (92%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/bulk/BulkDeleteParamsTest.kt (94%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/bulk/BulkDeleteResponseTest.kt (92%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/bulk/BulkRemoveAiTagsParamsTest.kt (95%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/bulk/BulkRemoveAiTagsResponseTest.kt (93%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/bulk/BulkRemoveTagsParamsTest.kt (95%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/bulk/BulkRemoveTagsResponseTest.kt (92%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/metadata/MetadataGetFromUrlParamsTest.kt (86%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/metadata/MetadataGetParamsTest.kt (92%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/versions/VersionDeleteParamsTest.kt (93%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/versions/VersionDeleteResponseTest.kt (90%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/versions/VersionGetParamsTest.kt (93%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/versions/VersionListParamsTest.kt (92%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/files/versions/VersionRestoreParamsTest.kt (93%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/FolderCopyParamsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/FolderCopyResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/FolderCreateParamsTest.kt (94%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/FolderCreateResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/FolderDeleteParamsTest.kt (92%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/FolderDeleteResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/FolderMoveParamsTest.kt (95%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/FolderMoveResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/FolderRenameParamsTest.kt (96%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/FolderRenameResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/job/JobGetParamsTest.kt (92%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/folders/job/JobGetResponseTest.kt (94%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/savedextensions/SavedExtensionCreateParamsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/savedextensions/SavedExtensionDeleteParamsTest.kt (92%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/savedextensions/SavedExtensionGetParamsTest.kt (91%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/savedextensions/SavedExtensionListParamsTest.kt (82%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/savedextensions/SavedExtensionUpdateParamsTest.kt (96%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/BaseWebhookEventTest.kt (92%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/FileCreateEventTest.kt (96%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/FileDeleteEventTest.kt (95%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/FileUpdateEventTest.kt (96%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/FileVersionCreateEventTest.kt (96%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/FileVersionDeleteEventTest.kt (96%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/UnsafeUnwrapWebhookEventTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/UnwrapWebhookEventTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/UploadPostTransformErrorEventTest.kt (98%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/UploadPostTransformSuccessEventTest.kt (98%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/UploadPreTransformErrorEventTest.kt (98%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/UploadPreTransformSuccessEventTest.kt (98%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/VideoTransformationAcceptedEventTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/VideoTransformationErrorEventTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/models/webhooks/VideoTransformationReadyEventTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/ErrorHandlingTest.kt (99%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/ServiceParamsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/AssetServiceAsyncTest.kt (86%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/CustomMetadataFieldServiceAsyncTest.kt (95%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/FileServiceAsyncTest.kt (97%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/FolderServiceAsyncTest.kt (89%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/SavedExtensionServiceAsyncTest.kt (93%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/WebhookServiceAsyncTest.kt (96%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/accounts/OriginServiceAsyncTest.kt (93%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/accounts/UrlEndpointServiceAsyncTest.kt (93%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/accounts/UsageServiceAsyncTest.kt (82%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/beta/v2/FileServiceAsyncTest.kt (97%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/cache/InvalidationServiceAsyncTest.kt (87%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/files/BulkServiceAsyncTest.kt (89%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/files/MetadataServiceAsyncTest.kt (87%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/files/VersionServiceAsyncTest.kt (88%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/async/folders/JobServiceAsyncTest.kt (84%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/AssetServiceTest.kt (86%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/CustomMetadataFieldServiceTest.kt (95%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/FileServiceTest.kt (97%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/FolderServiceTest.kt (88%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/SavedExtensionServiceTest.kt (92%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/WebhookServiceTest.kt (96%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/accounts/OriginServiceTest.kt (93%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/accounts/UrlEndpointServiceTest.kt (93%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/accounts/UsageServiceTest.kt (82%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/beta/v2/FileServiceTest.kt (97%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/cache/InvalidationServiceTest.kt (86%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/files/BulkServiceTest.kt (88%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/files/MetadataServiceTest.kt (85%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/files/VersionServiceTest.kt (87%) rename image-kit-java-core/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/services/blocking/folders/JobServiceTest.kt (82%) rename image-kit-java-proguard-test/src/test/kotlin/{com/imagekit/api => io/imagekit/io}/proguard/ProGuardCompatibilityTest.kt (94%) diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index 739856ac..57643855 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -33,7 +33,7 @@ jobs: export -- GPG_SIGNING_KEY_ID printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD" GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')" - ./gradlew publish --no-configuration-cache + ./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" --no-configuration-cache env: SONATYPE_USERNAME: ${{ secrets.IMAGE_KIT_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.IMAGE_KIT_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} diff --git a/.stats.yml b/.stats.yml index a37aee71..71485510 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 -config_hash: 4fa07762cb363071cfdeef3f7eeec56e +config_hash: ef918f7e878d4168a07e867607eb68ea diff --git a/build.gradle.kts b/build.gradle.kts index ce9ad14f..be2e1e8c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,4 @@ plugins { - id("io.github.gradle-nexus.publish-plugin") version "1.1.0" id("org.jetbrains.dokka") version "2.0.0" } @@ -8,7 +7,7 @@ repositories { } allprojects { - group = "com.imagekit.api" + group = "io.imagekit.io" version = "0.0.1" // x-release-please-version } @@ -35,15 +34,3 @@ tasks.named("dokkaJavadocCollector").configure { .filter { it.project.name != "image-kit-java" && it.name == "dokkaJavadocJar" } .forEach { mustRunAfter(it) } } - -nexusPublishing { - repositories { - sonatype { - nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) - snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) - - username.set(System.getenv("SONATYPE_USERNAME")) - password.set(System.getenv("SONATYPE_PASSWORD")) - } - } -} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 0b141353..c6dc92ec 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,12 +1,15 @@ plugins { `kotlin-dsl` kotlin("jvm") version "1.9.20" + id("com.vanniktech.maven.publish") version "0.28.0" } repositories { gradlePluginPortal() + mavenCentral() } dependencies { implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20") + implementation("com.vanniktech:gradle-maven-publish-plugin:0.28.0") } diff --git a/buildSrc/src/main/kotlin/image-kit.java.gradle.kts b/buildSrc/src/main/kotlin/image-kit.java.gradle.kts index d3ef265d..0f1f0c0e 100644 --- a/buildSrc/src/main/kotlin/image-kit.java.gradle.kts +++ b/buildSrc/src/main/kotlin/image-kit.java.gradle.kts @@ -8,11 +8,6 @@ repositories { mavenCentral() } -configure { - withJavadocJar() - withSourcesJar() -} - java { toolchain { languageVersion.set(JavaLanguageVersion.of(17)) @@ -27,10 +22,6 @@ tasks.withType().configureEach { options.release.set(8) } -tasks.named("javadocJar") { - setZip64(true) -} - tasks.named("jar") { manifest { attributes(mapOf( diff --git a/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts b/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts index 995d7f2e..992f6693 100644 --- a/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/image-kit.publish.gradle.kts @@ -1,69 +1,72 @@ +import com.vanniktech.maven.publish.JavadocJar +import com.vanniktech.maven.publish.KotlinJvm +import com.vanniktech.maven.publish.MavenPublishBaseExtension +import com.vanniktech.maven.publish.SonatypeHost + plugins { - `maven-publish` - signing + id("com.vanniktech.maven.publish") +} + +publishing { + repositories { + if (project.hasProperty("publishLocal")) { + maven { + name = "LocalFileSystem" + url = uri("${rootProject.layout.buildDirectory.get()}/local-maven-repo") + } + } + } } -configure { - publications { - register("maven") { - from(components["java"]) +repositories { + gradlePluginPortal() + mavenCentral() +} - pom { - name.set("ImageKit API") - description.set("Checkout [API overview](/docs/api-overview) to learn about ImageKit's APIs,\nauthentication, rate limits, and error codes etc.") - url.set("https://imagekit.io/docs/api-reference") +extra["signingInMemoryKey"] = System.getenv("GPG_SIGNING_KEY") +extra["signingInMemoryKeyId"] = System.getenv("GPG_SIGNING_KEY_ID") +extra["signingInMemoryKeyPassword"] = System.getenv("GPG_SIGNING_PASSWORD") - licenses { - license { - name.set("Apache-2.0") - } - } +configure { + if (!project.hasProperty("publishLocal")) { + signAllPublications() + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + } - developers { - developer { - name.set("Image Kit") - email.set("developer@imagekit.io") - } - } + coordinates(project.group.toString(), project.name, project.version.toString()) + configure( + KotlinJvm( + javadocJar = JavadocJar.Dokka("dokkaJavadoc"), + sourcesJar = true, + ) + ) - scm { - connection.set("scm:git:git://github.com/imagekit-developer/imagekit-java.git") - developerConnection.set("scm:git:git://github.com/imagekit-developer/imagekit-java.git") - url.set("https://github.com/imagekit-developer/imagekit-java") - } + pom { + name.set("ImageKit API") + description.set("Checkout [API overview](/docs/api-overview) to learn about ImageKit's APIs,\nauthentication, rate limits, and error codes etc.") + url.set("https://imagekit.io/docs/api-reference") - versionMapping { - allVariants { - fromResolutionResult() - } - } + licenses { + license { + name.set("Apache-2.0") } } - } - repositories { - if (project.hasProperty("publishLocal")) { - maven { - name = "LocalFileSystem" - url = uri("${rootProject.layout.buildDirectory.get()}/local-maven-repo") + + developers { + developer { + name.set("Image Kit") + email.set("developer@imagekit.io") } } - } -} -signing { - val signingKeyId = System.getenv("GPG_SIGNING_KEY_ID")?.ifBlank { null } - val signingKey = System.getenv("GPG_SIGNING_KEY")?.ifBlank { null } - val signingPassword = System.getenv("GPG_SIGNING_PASSWORD")?.ifBlank { null } - if (signingKey != null && signingPassword != null) { - useInMemoryPgpKeys( - signingKeyId, - signingKey, - signingPassword, - ) - sign(publishing.publications["maven"]) + scm { + connection.set("scm:git:git://github.com/imagekit-developer/imagekit-java.git") + developerConnection.set("scm:git:git://github.com/imagekit-developer/imagekit-java.git") + url.set("https://github.com/imagekit-developer/imagekit-java") + } } } -tasks.named("publish") { - dependsOn(":closeAndReleaseSonatypeStagingRepository") +tasks.withType().configureEach { + isZip64 = true } diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClient.kt similarity index 96% rename from image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt rename to image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClient.kt index 24ad8e9e..07f0ca84 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClient.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.client.okhttp +package io.imagekit.io.client.okhttp import com.fasterxml.jackson.databind.json.JsonMapper -import com.imagekit.api.client.ImageKitClient -import com.imagekit.api.client.ImageKitClientImpl -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.Sleeper -import com.imagekit.api.core.Timeout -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.HttpClient -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.client.ImageKitClient +import io.imagekit.io.client.ImageKitClientImpl +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.Sleeper +import io.imagekit.io.core.Timeout +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.HttpClient +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.core.jsonMapper import java.net.Proxy import java.time.Clock import java.time.Duration @@ -179,7 +179,7 @@ class ImageKitOkHttpClient private constructor() { /** * The Jackson JSON mapper to use for serializing and deserializing JSON. * - * Defaults to [com.imagekit.api.core.jsonMapper]. The default is usually sufficient and + * Defaults to [io.imagekit.io.core.jsonMapper]. The default is usually sufficient and * rarely needs to be overridden. */ fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClientAsync.kt similarity index 96% rename from image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt rename to image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClientAsync.kt index eb060bd7..c8109c64 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClientAsync.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.client.okhttp +package io.imagekit.io.client.okhttp import com.fasterxml.jackson.databind.json.JsonMapper -import com.imagekit.api.client.ImageKitClientAsync -import com.imagekit.api.client.ImageKitClientAsyncImpl -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.Sleeper -import com.imagekit.api.core.Timeout -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.HttpClient -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.client.ImageKitClientAsync +import io.imagekit.io.client.ImageKitClientAsyncImpl +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.Sleeper +import io.imagekit.io.core.Timeout +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.HttpClient +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.core.jsonMapper import java.net.Proxy import java.time.Clock import java.time.Duration @@ -179,7 +179,7 @@ class ImageKitOkHttpClientAsync private constructor() { /** * The Jackson JSON mapper to use for serializing and deserializing JSON. * - * Defaults to [com.imagekit.api.core.jsonMapper]. The default is usually sufficient and + * Defaults to [io.imagekit.io.core.jsonMapper]. The default is usually sufficient and * rarely needs to be overridden. */ fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } diff --git a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/OkHttpClient.kt similarity index 96% rename from image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt rename to image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/OkHttpClient.kt index b9b0e81d..aa067ad3 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/OkHttpClient.kt @@ -1,14 +1,14 @@ -package com.imagekit.api.client.okhttp - -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.Timeout -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.HttpClient -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpRequestBody -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.errors.ImageKitIoException +package io.imagekit.io.client.okhttp + +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.Timeout +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.HttpClient +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpRequestBody +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.errors.ImageKitIoException import java.io.IOException import java.io.InputStream import java.net.Proxy diff --git a/image-kit-java-client-okhttp/src/test/kotlin/com/imagekit/api/client/okhttp/OkHttpClientTest.kt b/image-kit-java-client-okhttp/src/test/kotlin/io/imagekit/io/client/okhttp/OkHttpClientTest.kt similarity index 91% rename from image-kit-java-client-okhttp/src/test/kotlin/com/imagekit/api/client/okhttp/OkHttpClientTest.kt rename to image-kit-java-client-okhttp/src/test/kotlin/io/imagekit/io/client/okhttp/OkHttpClientTest.kt index d99380df..a50e36c2 100644 --- a/image-kit-java-client-okhttp/src/test/kotlin/com/imagekit/api/client/okhttp/OkHttpClientTest.kt +++ b/image-kit-java-client-okhttp/src/test/kotlin/io/imagekit/io/client/okhttp/OkHttpClientTest.kt @@ -1,10 +1,10 @@ -package com.imagekit.api.client.okhttp +package io.imagekit.io.client.okhttp import com.github.tomakehurst.wiremock.client.WireMock.* import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClient.kt similarity index 100% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClient.kt diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientAsync.kt similarity index 100% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientAsync.kt diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientAsyncImpl.kt similarity index 100% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientAsyncImpl.kt diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientImpl.kt similarity index 100% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientImpl.kt diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/BaseDeserializer.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/BaseDeserializer.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/BaseDeserializer.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/BaseDeserializer.kt index 106fb746..54a1d03c 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/BaseDeserializer.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/BaseDeserializer.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.core +package io.imagekit.io.core import com.fasterxml.jackson.core.JsonParser import com.fasterxml.jackson.core.ObjectCodec diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/BaseSerializer.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/BaseSerializer.kt similarity index 85% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/BaseSerializer.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/BaseSerializer.kt index b0d195be..f2cd60ff 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/BaseSerializer.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/BaseSerializer.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.core +package io.imagekit.io.core import com.fasterxml.jackson.databind.ser.std.StdSerializer import kotlin.reflect.KClass diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Check.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Check.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Check.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Check.kt index f587fcc9..8a3145f3 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Check.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Check.kt @@ -1,6 +1,6 @@ @file:JvmName("Check") -package com.imagekit.api.core +package io.imagekit.io.core import com.fasterxml.jackson.core.Version import com.fasterxml.jackson.core.util.VersionUtil diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/ClientOptions.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/ClientOptions.kt index bfd06a44..1162d8ef 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ClientOptions.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/ClientOptions.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.core +package io.imagekit.io.core import com.fasterxml.jackson.databind.json.JsonMapper -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.HttpClient -import com.imagekit.api.core.http.PhantomReachableClosingHttpClient -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.core.http.RetryingHttpClient +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.HttpClient +import io.imagekit.io.core.http.PhantomReachableClosingHttpClient +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.core.http.RetryingHttpClient import java.time.Clock import java.time.Duration import java.util.Base64 @@ -37,7 +37,7 @@ private constructor( /** * The Jackson JSON mapper to use for serializing and deserializing JSON. * - * Defaults to [com.imagekit.api.core.jsonMapper]. The default is usually sufficient and rarely + * Defaults to [io.imagekit.io.core.jsonMapper]. The default is usually sufficient and rarely * needs to be overridden. */ @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, @@ -219,7 +219,7 @@ private constructor( /** * The Jackson JSON mapper to use for serializing and deserializing JSON. * - * Defaults to [com.imagekit.api.core.jsonMapper]. The default is usually sufficient and + * Defaults to [io.imagekit.io.core.jsonMapper]. The default is usually sufficient and * rarely needs to be overridden. */ fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/DefaultSleeper.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/DefaultSleeper.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/DefaultSleeper.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/DefaultSleeper.kt index 457f5920..65a0f3dc 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/DefaultSleeper.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/DefaultSleeper.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.core +package io.imagekit.io.core import java.time.Duration import java.util.Timer diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ObjectMappers.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/ObjectMappers.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ObjectMappers.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/ObjectMappers.kt index 765f7633..c2daca2c 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/ObjectMappers.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/ObjectMappers.kt @@ -1,6 +1,6 @@ @file:JvmName("ObjectMappers") -package com.imagekit.api.core +package io.imagekit.io.core import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.core.JsonGenerator diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Params.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Params.kt similarity index 76% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Params.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Params.kt index 2a62a936..36e5d3bb 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Params.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Params.kt @@ -1,7 +1,7 @@ -package com.imagekit.api.core +package io.imagekit.io.core -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams /** An interface representing parameters passed to a service method. */ interface Params { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachable.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PhantomReachable.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachable.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PhantomReachable.kt index d17a6894..cf13b66e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachable.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PhantomReachable.kt @@ -1,8 +1,8 @@ @file:JvmName("PhantomReachable") -package com.imagekit.api.core +package io.imagekit.io.core -import com.imagekit.api.errors.ImageKitException +import io.imagekit.io.errors.ImageKitException import java.lang.reflect.InvocationTargetException /** diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachableExecutorService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PhantomReachableExecutorService.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachableExecutorService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PhantomReachableExecutorService.kt index 19a35385..e36be75d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachableExecutorService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PhantomReachableExecutorService.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.core +package io.imagekit.io.core import java.util.concurrent.Callable import java.util.concurrent.ExecutorService diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachableSleeper.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PhantomReachableSleeper.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachableSleeper.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PhantomReachableSleeper.kt index 4b69d4d8..363c5f5f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PhantomReachableSleeper.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PhantomReachableSleeper.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.core +package io.imagekit.io.core import java.time.Duration import java.util.concurrent.CompletableFuture diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PrepareRequest.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PrepareRequest.kt similarity index 90% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PrepareRequest.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PrepareRequest.kt index 5ea20e42..dc89659e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/PrepareRequest.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PrepareRequest.kt @@ -1,8 +1,8 @@ @file:JvmName("PrepareRequest") -package com.imagekit.api.core +package io.imagekit.io.core -import com.imagekit.api.core.http.HttpRequest +import io.imagekit.io.core.http.HttpRequest import java.util.concurrent.CompletableFuture @JvmSynthetic diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Properties.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Properties.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Properties.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Properties.kt index f2b87adf..82f7b76f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Properties.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Properties.kt @@ -1,8 +1,8 @@ @file:JvmName("Properties") -package com.imagekit.api.core +package io.imagekit.io.core -import com.imagekit.api.client.ImageKitClient +import io.imagekit.io.client.ImageKitClient fun getOsArch(): String { val osArch = System.getProperty("os.arch") diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/RequestOptions.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/RequestOptions.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/RequestOptions.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/RequestOptions.kt index 2d4840a6..169073e7 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/RequestOptions.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/RequestOptions.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.core +package io.imagekit.io.core import java.time.Duration diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Sleeper.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Sleeper.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Sleeper.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Sleeper.kt index 00564e44..4233d6ce 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Sleeper.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Sleeper.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.core +package io.imagekit.io.core import java.time.Duration import java.util.concurrent.CompletableFuture diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Timeout.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Timeout.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Timeout.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Timeout.kt index 5ca59899..7aca153c 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Timeout.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Timeout.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.core +package io.imagekit.io.core import java.time.Duration import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/UnwrapWebhookParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/UnwrapWebhookParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/UnwrapWebhookParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/UnwrapWebhookParams.kt index 58dc26b8..9ed0f3c8 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/UnwrapWebhookParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/UnwrapWebhookParams.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.core +package io.imagekit.io.core -import com.imagekit.api.core.http.Headers +import io.imagekit.io.core.http.Headers import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Utils.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Utils.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Utils.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Utils.kt index 20765365..973173a3 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Utils.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Utils.kt @@ -1,8 +1,8 @@ @file:JvmName("Utils") -package com.imagekit.api.core +package io.imagekit.io.core -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.SortedMap import java.util.concurrent.CompletableFuture diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Values.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Values.kt index 43bda412..43d1ff48 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Values.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.core +package io.imagekit.io.core import com.fasterxml.jackson.annotation.JacksonAnnotationsInside import com.fasterxml.jackson.annotation.JsonCreator @@ -24,7 +24,7 @@ import com.fasterxml.jackson.databind.node.JsonNodeType.OBJECT import com.fasterxml.jackson.databind.node.JsonNodeType.POJO import com.fasterxml.jackson.databind.node.JsonNodeType.STRING import com.fasterxml.jackson.databind.ser.std.NullSerializer -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.errors.ImageKitInvalidDataException import java.io.InputStream import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/EmptyHandler.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/EmptyHandler.kt similarity index 62% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/EmptyHandler.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/EmptyHandler.kt index 3828715e..05d5e838 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/EmptyHandler.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/EmptyHandler.kt @@ -1,9 +1,9 @@ @file:JvmName("EmptyHandler") -package com.imagekit.api.core.handlers +package io.imagekit.io.core.handlers -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler @JvmSynthetic internal fun emptyHandler(): Handler = EmptyHandlerInternal diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/ErrorHandler.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/ErrorHandler.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/ErrorHandler.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/ErrorHandler.kt index 203fb654..896acf44 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/ErrorHandler.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/ErrorHandler.kt @@ -2,21 +2,21 @@ @file:JvmName("ErrorHandler") -package com.imagekit.api.core.handlers +package io.imagekit.io.core.handlers import com.fasterxml.jackson.databind.json.JsonMapper -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.errors.BadRequestException -import com.imagekit.api.errors.InternalServerException -import com.imagekit.api.errors.NotFoundException -import com.imagekit.api.errors.PermissionDeniedException -import com.imagekit.api.errors.RateLimitException -import com.imagekit.api.errors.UnauthorizedException -import com.imagekit.api.errors.UnexpectedStatusCodeException -import com.imagekit.api.errors.UnprocessableEntityException +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.errors.BadRequestException +import io.imagekit.io.errors.InternalServerException +import io.imagekit.io.errors.NotFoundException +import io.imagekit.io.errors.PermissionDeniedException +import io.imagekit.io.errors.RateLimitException +import io.imagekit.io.errors.UnauthorizedException +import io.imagekit.io.errors.UnexpectedStatusCodeException +import io.imagekit.io.errors.UnprocessableEntityException @JvmSynthetic internal fun errorBodyHandler(jsonMapper: JsonMapper): Handler { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/JsonHandler.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/JsonHandler.kt similarity index 73% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/JsonHandler.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/JsonHandler.kt index 7eedf389..f48e4c57 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/JsonHandler.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/JsonHandler.kt @@ -1,12 +1,12 @@ @file:JvmName("JsonHandler") -package com.imagekit.api.core.handlers +package io.imagekit.io.core.handlers import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.errors.ImageKitInvalidDataException @JvmSynthetic internal inline fun jsonHandler(jsonMapper: JsonMapper): Handler = diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/StringHandler.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/StringHandler.kt similarity index 67% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/StringHandler.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/StringHandler.kt index 7c374505..3604ff88 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/handlers/StringHandler.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/StringHandler.kt @@ -1,9 +1,9 @@ @file:JvmName("StringHandler") -package com.imagekit.api.core.handlers +package io.imagekit.io.core.handlers -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler @JvmSynthetic internal fun stringHandler(): Handler = StringHandlerInternal diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/AsyncStreamResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/AsyncStreamResponse.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/AsyncStreamResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/AsyncStreamResponse.kt index 21385e33..c03a5229 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/AsyncStreamResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/AsyncStreamResponse.kt @@ -1,6 +1,6 @@ -package com.imagekit.api.core.http +package io.imagekit.io.core.http -import com.imagekit.api.core.http.AsyncStreamResponse.Handler +import io.imagekit.io.core.http.AsyncStreamResponse.Handler import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/Headers.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/Headers.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/Headers.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/Headers.kt index 9c6ac033..1421f37f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/Headers.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/Headers.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.core.http - -import com.imagekit.api.core.JsonArray -import com.imagekit.api.core.JsonBoolean -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonNull -import com.imagekit.api.core.JsonNumber -import com.imagekit.api.core.JsonObject -import com.imagekit.api.core.JsonString -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.toImmutable +package io.imagekit.io.core.http + +import io.imagekit.io.core.JsonArray +import io.imagekit.io.core.JsonBoolean +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonNull +import io.imagekit.io.core.JsonNumber +import io.imagekit.io.core.JsonObject +import io.imagekit.io.core.JsonString +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.toImmutable import java.util.TreeMap class Headers diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpClient.kt similarity index 90% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpClient.kt index c26e5152..12a86e9c 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpClient.kt @@ -1,6 +1,6 @@ -package com.imagekit.api.core.http +package io.imagekit.io.core.http -import com.imagekit.api.core.RequestOptions +import io.imagekit.io.core.RequestOptions import java.lang.AutoCloseable import java.util.concurrent.CompletableFuture diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpMethod.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpMethod.kt similarity index 78% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpMethod.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpMethod.kt index 8f320c37..bd4c91ef 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpMethod.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpMethod.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.core.http +package io.imagekit.io.core.http enum class HttpMethod { GET, diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequest.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpRequest.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequest.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpRequest.kt index 9852b94d..9b9421d1 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequest.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpRequest.kt @@ -1,7 +1,7 @@ -package com.imagekit.api.core.http +package io.imagekit.io.core.http -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.toImmutable +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.toImmutable import java.net.URLEncoder class HttpRequest diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequestBodies.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpRequestBodies.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequestBodies.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpRequestBodies.kt index e8ee34a2..7703a3bb 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequestBodies.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpRequestBodies.kt @@ -2,14 +2,14 @@ @file:JvmName("HttpRequestBodies") -package com.imagekit.api.core.http +package io.imagekit.io.core.http import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.databind.node.JsonNodeType -import com.imagekit.api.core.MultipartField -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.MultipartField +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.io.ByteArrayInputStream import java.io.InputStream import java.io.OutputStream diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequestBody.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpRequestBody.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequestBody.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpRequestBody.kt index 31269712..559d71e9 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpRequestBody.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpRequestBody.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.core.http +package io.imagekit.io.core.http import java.io.OutputStream import java.lang.AutoCloseable diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpResponse.kt similarity index 92% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpResponse.kt index 4df614c0..1a080a95 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.core.http +package io.imagekit.io.core.http import java.io.InputStream diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpResponseFor.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpResponseFor.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpResponseFor.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpResponseFor.kt index e8951c98..453d4736 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpResponseFor.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpResponseFor.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.core.http +package io.imagekit.io.core.http import java.io.InputStream diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/PhantomReachableClosingAsyncStreamResponse.kt similarity index 92% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/PhantomReachableClosingAsyncStreamResponse.kt index 791212d3..668ab64f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/PhantomReachableClosingAsyncStreamResponse.kt @@ -1,7 +1,7 @@ -package com.imagekit.api.core.http +package io.imagekit.io.core.http -import com.imagekit.api.core.closeWhenPhantomReachable -import com.imagekit.api.core.http.AsyncStreamResponse.Handler +import io.imagekit.io.core.closeWhenPhantomReachable +import io.imagekit.io.core.http.AsyncStreamResponse.Handler import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/PhantomReachableClosingHttpClient.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/PhantomReachableClosingHttpClient.kt similarity index 85% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/PhantomReachableClosingHttpClient.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/PhantomReachableClosingHttpClient.kt index fc9a25e3..1de13648 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/PhantomReachableClosingHttpClient.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/PhantomReachableClosingHttpClient.kt @@ -1,7 +1,7 @@ -package com.imagekit.api.core.http +package io.imagekit.io.core.http -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.closeWhenPhantomReachable +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.closeWhenPhantomReachable import java.util.concurrent.CompletableFuture /** diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/PhantomReachableClosingStreamResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/PhantomReachableClosingStreamResponse.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/PhantomReachableClosingStreamResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/PhantomReachableClosingStreamResponse.kt index cf856563..cd161cd0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/PhantomReachableClosingStreamResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/PhantomReachableClosingStreamResponse.kt @@ -1,6 +1,6 @@ -package com.imagekit.api.core.http +package io.imagekit.io.core.http -import com.imagekit.api.core.closeWhenPhantomReachable +import io.imagekit.io.core.closeWhenPhantomReachable import java.util.stream.Stream /** diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/QueryParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/QueryParams.kt similarity index 90% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/QueryParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/QueryParams.kt index 3f16c45e..bb2a1c53 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/QueryParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/QueryParams.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.core.http - -import com.imagekit.api.core.JsonArray -import com.imagekit.api.core.JsonBoolean -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonNull -import com.imagekit.api.core.JsonNumber -import com.imagekit.api.core.JsonObject -import com.imagekit.api.core.JsonString -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.toImmutable +package io.imagekit.io.core.http + +import io.imagekit.io.core.JsonArray +import io.imagekit.io.core.JsonBoolean +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonNull +import io.imagekit.io.core.JsonNumber +import io.imagekit.io.core.JsonObject +import io.imagekit.io.core.JsonString +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.toImmutable class QueryParams private constructor( diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/RetryingHttpClient.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/RetryingHttpClient.kt index 7b72b0b3..5d7ca8ed 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/RetryingHttpClient.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/RetryingHttpClient.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.core.http - -import com.imagekit.api.core.DefaultSleeper -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.Sleeper -import com.imagekit.api.core.checkRequired -import com.imagekit.api.errors.ImageKitIoException -import com.imagekit.api.errors.ImageKitRetryableException +package io.imagekit.io.core.http + +import io.imagekit.io.core.DefaultSleeper +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.Sleeper +import io.imagekit.io.core.checkRequired +import io.imagekit.io.errors.ImageKitIoException +import io.imagekit.io.errors.ImageKitRetryableException import java.io.IOException import java.time.Clock import java.time.Duration diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/StreamResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/StreamResponse.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/StreamResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/StreamResponse.kt index d5427be4..6ccb4687 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/StreamResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/StreamResponse.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.core.http +package io.imagekit.io.core.http import java.util.stream.Stream diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/BadRequestException.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/BadRequestException.kt index c0928e0a..5c602a73 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/BadRequestException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.errors +package io.imagekit.io.errors -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitException.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitException.kt index 799b887b..f6706953 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitException.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.errors +package io.imagekit.io.errors open class ImageKitException @JvmOverloads diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitInvalidDataException.kt similarity index 82% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitInvalidDataException.kt index 5ab2f9b4..387148ed 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitInvalidDataException.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.errors +package io.imagekit.io.errors class ImageKitInvalidDataException @JvmOverloads diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitIoException.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitIoException.kt index 0cb36092..49fbc968 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitIoException.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.errors +package io.imagekit.io.errors class ImageKitIoException @JvmOverloads diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitRetryableException.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitRetryableException.kt index a9c4e94b..fc2875ad 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitRetryableException.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.errors +package io.imagekit.io.errors /** * Exception that indicates a transient error that can be retried. diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitServiceException.kt similarity index 73% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitServiceException.kt index 3e8bb7ca..de7339e8 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitServiceException.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.errors +package io.imagekit.io.errors -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.http.Headers +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.http.Headers abstract class ImageKitServiceException protected constructor(message: String, cause: Throwable? = null) : diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitWebhookException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitWebhookException.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitWebhookException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitWebhookException.kt index 7b846cc8..9ffe13a3 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitWebhookException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitWebhookException.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.errors +package io.imagekit.io.errors class ImageKitWebhookException @JvmOverloads diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/InternalServerException.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/InternalServerException.kt index dbdbcc04..e3d79cee 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/InternalServerException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.errors +package io.imagekit.io.errors -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/NotFoundException.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/NotFoundException.kt index 61926165..c114f693 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/NotFoundException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.errors +package io.imagekit.io.errors -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/PermissionDeniedException.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/PermissionDeniedException.kt index 95f536bc..950ae3a0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/PermissionDeniedException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.errors +package io.imagekit.io.errors -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/RateLimitException.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/RateLimitException.kt index c9d078b9..5cad2f59 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/RateLimitException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.errors +package io.imagekit.io.errors -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnauthorizedException.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnauthorizedException.kt index 46009ee1..3e93ef7d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnauthorizedException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.errors +package io.imagekit.io.errors -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnexpectedStatusCodeException.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnexpectedStatusCodeException.kt index f21d5606..d09cb4d7 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnexpectedStatusCodeException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.errors +package io.imagekit.io.errors -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnprocessableEntityException.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnprocessableEntityException.kt index 2d468300..8e92aecb 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnprocessableEntityException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.errors +package io.imagekit.io.errors -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AiTag.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/AiTag.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AiTag.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/AiTag.kt index 59067439..d2172275 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/AiTag.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/AiTag.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/BaseOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/BaseOverlay.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/BaseOverlay.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/BaseOverlay.kt index e9672404..ad6d9f0b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/BaseOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/BaseOverlay.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/CustomMetadata.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/CustomMetadata.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/CustomMetadata.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/CustomMetadata.kt index d9cbf73b..eee8299d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/CustomMetadata.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/CustomMetadata.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonCreator -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Objects /** A key-value data associated with the asset. */ diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/EmbeddedMetadata.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/EmbeddedMetadata.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/EmbeddedMetadata.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/EmbeddedMetadata.kt index 24ff0de0..054b3b91 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/EmbeddedMetadata.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/EmbeddedMetadata.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonCreator -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Objects /** diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ExtensionConfig.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ExtensionConfig.kt index f4f659d1..45a6b143 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionConfig.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ExtensionConfig.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,19 +13,19 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.allMaxBy -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.getOrThrow -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.BaseDeserializer +import io.imagekit.io.core.BaseSerializer +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.allMaxBy +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.getOrThrow +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionItem.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ExtensionItem.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionItem.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ExtensionItem.kt index 190388c3..1bda9ae5 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ExtensionItem.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ExtensionItem.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,19 +13,19 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.allMaxBy -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.getOrThrow -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.BaseDeserializer +import io.imagekit.io.core.BaseSerializer +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.allMaxBy +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.getOrThrow +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/GetImageAttributesOptions.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/GetImageAttributesOptions.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/GetImageAttributesOptions.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/GetImageAttributesOptions.kt index 96f3a01c..8dfc91cb 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/GetImageAttributesOptions.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/GetImageAttributesOptions.kt @@ -1,19 +1,19 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ImageOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ImageOverlay.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ImageOverlay.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ImageOverlay.kt index c4c0d114..a6b78622 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ImageOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ImageOverlay.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Overlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/Overlay.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Overlay.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/Overlay.kt index 52adca4d..d6093d58 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Overlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/Overlay.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -9,11 +9,11 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.getOrThrow -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.BaseDeserializer +import io.imagekit.io.core.BaseSerializer +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.getOrThrow +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/OverlayPosition.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/OverlayPosition.kt index 9baf1c6c..bf5f9088 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayPosition.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/OverlayPosition.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,16 +13,16 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.allMaxBy -import com.imagekit.api.core.getOrThrow -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.BaseDeserializer +import io.imagekit.io.core.BaseSerializer +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.allMaxBy +import io.imagekit.io.core.getOrThrow +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayTiming.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/OverlayTiming.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayTiming.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/OverlayTiming.kt index d9a4b897..bbccaaa9 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/OverlayTiming.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/OverlayTiming.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,15 +13,15 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.allMaxBy -import com.imagekit.api.core.getOrThrow -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.BaseDeserializer +import io.imagekit.io.core.BaseSerializer +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.allMaxBy +import io.imagekit.io.core.getOrThrow +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ResponsiveImageAttributes.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ResponsiveImageAttributes.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ResponsiveImageAttributes.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ResponsiveImageAttributes.kt index c079f6a4..6e0134b4 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/ResponsiveImageAttributes.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ResponsiveImageAttributes.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SavedExtension.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SavedExtension.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SavedExtension.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SavedExtension.kt index d3389ef3..61ccf3a6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SavedExtension.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SavedExtension.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SelectedFieldsSchema.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SelectedFieldsSchema.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SelectedFieldsSchema.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SelectedFieldsSchema.kt index 5e3b22bd..8baaa4b0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SelectedFieldsSchema.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SelectedFieldsSchema.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonCreator -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Objects /** diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SolidColorOverlay.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlay.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SolidColorOverlay.kt index d8dfb6e2..ee9ae6dc 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SolidColorOverlay.kt @@ -1,19 +1,19 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SolidColorOverlayTransformation.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SolidColorOverlayTransformation.kt index 89a9ee26..07a36643 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SolidColorOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SolidColorOverlayTransformation.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,15 +13,15 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.allMaxBy -import com.imagekit.api.core.getOrThrow -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.BaseDeserializer +import io.imagekit.io.core.BaseSerializer +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.allMaxBy +import io.imagekit.io.core.getOrThrow +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SrcOptions.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SrcOptions.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SrcOptions.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SrcOptions.kt index ff3827ea..773e11bc 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SrcOptions.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SrcOptions.kt @@ -1,19 +1,19 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/StreamingResolution.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/StreamingResolution.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/StreamingResolution.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/StreamingResolution.kt index f9aa05d5..d41f75f1 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/StreamingResolution.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/StreamingResolution.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonCreator -import com.imagekit.api.core.Enum -import com.imagekit.api.core.JsonField -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.Enum +import io.imagekit.io.core.JsonField +import io.imagekit.io.errors.ImageKitInvalidDataException /** * Available streaming resolutions for diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SubtitleOverlay.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlay.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SubtitleOverlay.kt index e9df4a45..3354b37b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SubtitleOverlay.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SubtitleOverlayTransformation.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlayTransformation.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SubtitleOverlayTransformation.kt index ed11217f..81b9aa94 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/SubtitleOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SubtitleOverlayTransformation.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/TextOverlay.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlay.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/TextOverlay.kt index 3ca84fd6..4b8e00d2 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/TextOverlay.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/TextOverlayTransformation.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/TextOverlayTransformation.kt index 737b98a8..add8fe48 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TextOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/TextOverlayTransformation.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,16 +13,16 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.allMaxBy -import com.imagekit.api.core.getOrThrow -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.BaseDeserializer +import io.imagekit.io.core.BaseSerializer +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.allMaxBy +import io.imagekit.io.core.getOrThrow +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/Transformation.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/Transformation.kt index ef063f90..8174423f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/Transformation.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/Transformation.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,18 +13,18 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.allMaxBy -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.getOrThrow -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.BaseDeserializer +import io.imagekit.io.core.BaseSerializer +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.allMaxBy +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.getOrThrow +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TransformationPosition.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/TransformationPosition.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TransformationPosition.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/TransformationPosition.kt index 5a62532e..49816596 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/TransformationPosition.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/TransformationPosition.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonCreator -import com.imagekit.api.core.Enum -import com.imagekit.api.core.JsonField -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.Enum +import io.imagekit.io.core.JsonField +import io.imagekit.io.errors.ImageKitInvalidDataException /** * By default, the transformation string is added as a query parameter in the URL, e.g., diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VersionInfo.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/VersionInfo.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VersionInfo.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/VersionInfo.kt index c912f75d..8e56d192 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VersionInfo.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/VersionInfo.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VideoOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/VideoOverlay.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VideoOverlay.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/VideoOverlay.kt index 243162a6..94b81487 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/VideoOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/VideoOverlay.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginCreateParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginCreateParams.kt index 6ea32300..e3198f52 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginCreateParams.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.origins +package io.imagekit.io.models.accounts.origins -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams import java.util.Objects /** **Note:** This API is currently in beta. Creates a new origin and returns the origin object. */ diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginDeleteParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginDeleteParams.kt index f96b6b3e..13fec183 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginDeleteParams.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.origins +package io.imagekit.io.models.accounts.origins -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.core.toImmutable +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.core.toImmutable import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginGetParams.kt index b4b2f306..c57a37bd 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginGetParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.origins +package io.imagekit.io.models.accounts.origins -import com.imagekit.api.core.Params -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.Params +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginListParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginListParams.kt index a1f09509..0ac75f6c 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginListParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginListParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.origins +package io.imagekit.io.models.accounts.origins -import com.imagekit.api.core.Params -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.Params +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams import java.util.Objects /** diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginRequest.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginRequest.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginRequest.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginRequest.kt index ba4d09bc..4c3549e7 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginRequest.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginRequest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.origins +package io.imagekit.io.models.accounts.origins import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,15 +13,15 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.getOrThrow -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.BaseDeserializer +import io.imagekit.io.core.BaseSerializer +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.getOrThrow +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginResponse.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginResponse.kt index 4b04735c..73868127 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.origins +package io.imagekit.io.models.accounts.origins import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,15 +13,15 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.getOrThrow -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.BaseDeserializer +import io.imagekit.io.core.BaseSerializer +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.getOrThrow +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginUpdateParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginUpdateParams.kt index fb70ae47..3497120b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginUpdateParams.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.origins +package io.imagekit.io.models.accounts.origins -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointCreateParams.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointCreateParams.kt index 82e57e9a..cede1ad0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointCreateParams.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.urlendpoints +package io.imagekit.io.models.accounts.urlendpoints -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams import java.util.Objects /** diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt index 754f9291..335ee545 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.urlendpoints +package io.imagekit.io.models.accounts.urlendpoints -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.core.toImmutable +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.core.toImmutable import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointGetParams.kt index a07244eb..83344c14 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointGetParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.urlendpoints +package io.imagekit.io.models.accounts.urlendpoints -import com.imagekit.api.core.Params -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.Params +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointListParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointListParams.kt index a37cdaee..75bad774 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointListParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.urlendpoints +package io.imagekit.io.models.accounts.urlendpoints -import com.imagekit.api.core.Params -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.Params +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams import java.util.Objects /** diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequest.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointRequest.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequest.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointRequest.kt index cfb1f51f..f32c4238 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequest.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointRequest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.urlendpoints +package io.imagekit.io.models.accounts.urlendpoints import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,17 +13,17 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.getOrThrow -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.BaseDeserializer +import io.imagekit.io.core.BaseSerializer +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.getOrThrow +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointResponse.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointResponse.kt index 90b2b7ad..23584cba 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.urlendpoints +package io.imagekit.io.models.accounts.urlendpoints import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,17 +13,17 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.getOrThrow -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.BaseDeserializer +import io.imagekit.io.core.BaseSerializer +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.getOrThrow +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt index 0af7b50e..93cb445d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.urlendpoints +package io.imagekit.io.models.accounts.urlendpoints -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/usage/UsageGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/usage/UsageGetParams.kt index a8e88bf6..d2b73e35 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/usage/UsageGetParams.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.usage +package io.imagekit.io.models.accounts.usage -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams import java.time.LocalDate import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/usage/UsageGetResponse.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/usage/UsageGetResponse.kt index f8065d3d..d23cbbe0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/usage/UsageGetResponse.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.usage +package io.imagekit.io.models.accounts.usage import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/AssetListParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/assets/AssetListParams.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/AssetListParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/assets/AssetListParams.kt index 78ed7c98..73e8542c 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/AssetListParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/assets/AssetListParams.kt @@ -1,14 +1,14 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.assets +package io.imagekit.io.models.assets import com.fasterxml.jackson.annotation.JsonCreator -import com.imagekit.api.core.Enum -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.Params -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.Enum +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.Params +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/AssetListResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/assets/AssetListResponse.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/AssetListResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/assets/AssetListResponse.kt index 8e1fbee8..dad42ce5 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/assets/AssetListResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/assets/AssetListResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.assets +package io.imagekit.io.models.assets import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -9,13 +9,13 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.getOrThrow -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.files.File -import com.imagekit.api.models.files.Folder +import io.imagekit.io.core.BaseDeserializer +import io.imagekit.io.core.BaseSerializer +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.getOrThrow +import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.io.models.files.File +import io.imagekit.io.models.files.Folder import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadParams.kt similarity index 100% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadParams.kt diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadResponse.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadResponse.kt index 2cd0297c..d614c4ca 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadResponse.kt @@ -1,25 +1,25 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.beta.v2.files +package io.imagekit.io.models.beta.v2.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.AiTag -import com.imagekit.api.models.CustomMetadata -import com.imagekit.api.models.EmbeddedMetadata -import com.imagekit.api.models.SelectedFieldsSchema -import com.imagekit.api.models.VersionInfo -import com.imagekit.api.models.files.Metadata +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.io.models.AiTag +import io.imagekit.io.models.CustomMetadata +import io.imagekit.io.models.EmbeddedMetadata +import io.imagekit.io.models.SelectedFieldsSchema +import io.imagekit.io.models.VersionInfo +import io.imagekit.io.models.files.Metadata import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateParams.kt index 3f4985aa..ad75a670 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.cache.invalidation +package io.imagekit.io.models.cache.invalidation import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateResponse.kt index beddefa3..85493d41 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateResponse.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.cache.invalidation +package io.imagekit.io.models.cache.invalidation import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetParams.kt index 38accc77..987f7210 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.cache.invalidation +package io.imagekit.io.models.cache.invalidation -import com.imagekit.api.core.Params -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.Params +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetResponse.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetResponse.kt index eb953ad6..5ed4dba7 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetResponse.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.cache.invalidation +package io.imagekit.io.models.cache.invalidation import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataField.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataField.kt index a9c08142..adf4507f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataField.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataField.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.custommetadatafields +package io.imagekit.io.models.custommetadatafields import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,19 +13,19 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.allMaxBy -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.getOrThrow -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.BaseDeserializer +import io.imagekit.io.core.BaseSerializer +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.allMaxBy +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.getOrThrow +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldCreateParams.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldCreateParams.kt index 3878c620..77ac3281 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldCreateParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.custommetadatafields +package io.imagekit.io.models.custommetadatafields import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,22 +13,22 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.allMaxBy -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.getOrThrow -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.BaseDeserializer +import io.imagekit.io.core.BaseSerializer +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.allMaxBy +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.getOrThrow +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt index 6266a56b..b53d904b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.custommetadatafields +package io.imagekit.io.models.custommetadatafields -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.core.toImmutable +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.core.toImmutable import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt index ddfd5eaa..ccce4839 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.custommetadatafields +package io.imagekit.io.models.custommetadatafields import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldListParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldListParams.kt index caaf35ac..583a8d29 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldListParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.custommetadatafields +package io.imagekit.io.models.custommetadatafields -import com.imagekit.api.core.Params -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.Params +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt index 156b402e..c328992a 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.custommetadatafields +package io.imagekit.io.models.custommetadatafields import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,20 +13,20 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.allMaxBy -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.getOrThrow -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.BaseDeserializer +import io.imagekit.io.core.BaseSerializer +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.allMaxBy +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.getOrThrow +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/File.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/File.kt index b07ce3ff..ce2f9d60 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/File.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/File.kt @@ -1,24 +1,24 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.AiTag -import com.imagekit.api.models.CustomMetadata -import com.imagekit.api.models.EmbeddedMetadata -import com.imagekit.api.models.SelectedFieldsSchema -import com.imagekit.api.models.VersionInfo +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.io.models.AiTag +import io.imagekit.io.models.CustomMetadata +import io.imagekit.io.models.EmbeddedMetadata +import io.imagekit.io.models.SelectedFieldsSchema +import io.imagekit.io.models.VersionInfo import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileCopyParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileCopyParams.kt index 1256c678..687af58f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileCopyParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileCopyResponse.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileCopyResponse.kt index ae3f5bf1..ae35acff 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileCopyResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileCopyResponse.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileDeleteParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileDeleteParams.kt index 16ae1104..62d925ee 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileDeleteParams.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.core.toImmutable +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.core.toImmutable import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileGetParams.kt index e5a88219..6a45258d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileGetParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files -import com.imagekit.api.core.Params -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.Params +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileMoveParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileMoveParams.kt index e8a9761e..e9e2b57f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileMoveParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileMoveResponse.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileMoveResponse.kt index 7f946c51..0795ab61 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileMoveResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileMoveResponse.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileRenameParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileRenameParams.kt index 0fe5f024..82fd46b9 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileRenameParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileRenameResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileRenameResponse.kt index e8707efe..f5e249ab 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileRenameResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileRenameResponse.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUpdateParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUpdateParams.kt index 43ac63f9..6faac1fb 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUpdateParams.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUpdateResponse.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUpdateResponse.kt index 34e1f146..c36b5df4 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUpdateResponse.kt @@ -1,24 +1,24 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.AiTag -import com.imagekit.api.models.CustomMetadata -import com.imagekit.api.models.EmbeddedMetadata -import com.imagekit.api.models.SelectedFieldsSchema -import com.imagekit.api.models.VersionInfo +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.io.models.AiTag +import io.imagekit.io.models.CustomMetadata +import io.imagekit.io.models.EmbeddedMetadata +import io.imagekit.io.models.SelectedFieldsSchema +import io.imagekit.io.models.VersionInfo import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUploadParams.kt similarity index 100% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUploadParams.kt diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUploadResponse.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUploadResponse.kt index 8db21cc4..fb85557d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/FileUploadResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUploadResponse.kt @@ -1,24 +1,24 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.AiTag -import com.imagekit.api.models.CustomMetadata -import com.imagekit.api.models.EmbeddedMetadata -import com.imagekit.api.models.SelectedFieldsSchema -import com.imagekit.api.models.VersionInfo +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.io.models.AiTag +import io.imagekit.io.models.CustomMetadata +import io.imagekit.io.models.EmbeddedMetadata +import io.imagekit.io.models.SelectedFieldsSchema +import io.imagekit.io.models.VersionInfo import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Folder.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/Folder.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Folder.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/Folder.kt index 54b903e6..9540234e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Folder.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/Folder.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Metadata.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/Metadata.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Metadata.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/Metadata.kt index 5e27752b..899a00b3 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/Metadata.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/Metadata.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/UpdateFileRequest.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/UpdateFileRequest.kt index 618f5e92..b1875d5d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/UpdateFileRequest.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/UpdateFileRequest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,19 +13,19 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.allMaxBy -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.getOrThrow -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.ExtensionItem +import io.imagekit.io.core.BaseDeserializer +import io.imagekit.io.core.BaseSerializer +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.allMaxBy +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.getOrThrow +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.io.models.ExtensionItem import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsParams.kt index 8bbc2da9..a379fa91 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsParams.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.bulk +package io.imagekit.io.models.files.bulk import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsResponse.kt index b46409d9..9d52ada9 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsResponse.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.bulk +package io.imagekit.io.models.files.bulk import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteParams.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteParams.kt index e2da50c4..9a62d24c 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteParams.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.bulk +package io.imagekit.io.models.files.bulk import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteResponse.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteResponse.kt index 8f302126..ef143ca9 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteResponse.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.bulk +package io.imagekit.io.models.files.bulk import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsParams.kt index ccfe5368..37d092d6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsParams.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.bulk +package io.imagekit.io.models.files.bulk import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsResponse.kt index fe19c147..c0b81c17 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsResponse.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.bulk +package io.imagekit.io.models.files.bulk import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsParams.kt index 38006117..5eec3b2f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsParams.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.bulk +package io.imagekit.io.models.files.bulk import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsResponse.kt index b4293490..37bb3920 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsResponse.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.bulk +package io.imagekit.io.models.files.bulk import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/metadata/MetadataGetFromUrlParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/metadata/MetadataGetFromUrlParams.kt index a5131a3d..c848d9a0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/metadata/MetadataGetFromUrlParams.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.metadata +package io.imagekit.io.models.files.metadata -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams import java.util.Objects /** Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API. */ diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/metadata/MetadataGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/metadata/MetadataGetParams.kt index cab27ba0..2d738739 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/metadata/MetadataGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/metadata/MetadataGetParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.metadata +package io.imagekit.io.models.files.metadata -import com.imagekit.api.core.Params -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.Params +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionDeleteParams.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionDeleteParams.kt index f43c5223..fb010612 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionDeleteParams.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.versions - -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.core.toImmutable +package io.imagekit.io.models.files.versions + +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.core.toImmutable import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionDeleteResponse.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionDeleteResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionDeleteResponse.kt index 0cb9389e..1c7f68bc 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionDeleteResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionDeleteResponse.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.versions +package io.imagekit.io.models.files.versions import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionGetParams.kt index fd71f44e..4621565e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionGetParams.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.versions +package io.imagekit.io.models.files.versions -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionListParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionListParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionListParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionListParams.kt index 92b5d691..cb273621 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionListParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionListParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.versions +package io.imagekit.io.models.files.versions -import com.imagekit.api.core.Params -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.Params +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRestoreParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionRestoreParams.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRestoreParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionRestoreParams.kt index 6edc115f..7e1e95a9 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/files/versions/VersionRestoreParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionRestoreParams.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.versions - -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.core.toImmutable +package io.imagekit.io.models.files.versions + +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.core.toImmutable import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCopyParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCopyParams.kt index 66ce29e5..dbba412d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCopyParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders +package io.imagekit.io.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCopyResponse.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCopyResponse.kt index b9bec4d9..629b78e5 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCopyResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCopyResponse.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders +package io.imagekit.io.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCreateParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCreateParams.kt index 8260f507..659009e0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCreateParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders +package io.imagekit.io.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCreateResponse.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCreateResponse.kt index d82d3171..0aca95f5 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCreateResponse.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders +package io.imagekit.io.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderDeleteParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderDeleteParams.kt index 5cc97b7c..f16d61c6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderDeleteParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders +package io.imagekit.io.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderDeleteResponse.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderDeleteResponse.kt index cd0cd73f..f6e62e09 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderDeleteResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderDeleteResponse.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders +package io.imagekit.io.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderMoveParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderMoveParams.kt index 948dea58..d752f7d0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderMoveParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders +package io.imagekit.io.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderMoveResponse.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderMoveResponse.kt index d948d7ce..6df5e531 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderMoveResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderMoveResponse.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders +package io.imagekit.io.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderRenameParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderRenameParams.kt index 3dd2d495..25562eb4 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderRenameParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders +package io.imagekit.io.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderRenameResponse.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderRenameResponse.kt index 1210c3d6..a765a825 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/FolderRenameResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderRenameResponse.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders +package io.imagekit.io.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/job/JobGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/job/JobGetParams.kt index 6e87f9b0..38faa702 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/job/JobGetParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders.job +package io.imagekit.io.models.folders.job -import com.imagekit.api.core.Params -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.Params +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/job/JobGetResponse.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/job/JobGetResponse.kt index e563ae4b..ac181a52 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/folders/job/JobGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/job/JobGetResponse.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders.job +package io.imagekit.io.models.folders.job import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionCreateParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionCreateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionCreateParams.kt index d9eebe0a..6670e08e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionCreateParams.kt @@ -1,21 +1,21 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.savedextensions +package io.imagekit.io.models.savedextensions import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.ExtensionConfig +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.io.models.ExtensionConfig import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionDeleteParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionDeleteParams.kt index 8c45c4a6..6d429e80 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionDeleteParams.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.savedextensions +package io.imagekit.io.models.savedextensions -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.core.toImmutable +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.core.toImmutable import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionGetParams.kt index ff235907..aa0f08c8 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionGetParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.savedextensions +package io.imagekit.io.models.savedextensions -import com.imagekit.api.core.Params -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.Params +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionListParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionListParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionListParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionListParams.kt index 34e4dbc2..160d4fe9 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionListParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionListParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.savedextensions +package io.imagekit.io.models.savedextensions -import com.imagekit.api.core.Params -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.Params +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams import java.util.Objects /** diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionUpdateParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionUpdateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionUpdateParams.kt index 5d368dca..acc0464e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionUpdateParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.savedextensions +package io.imagekit.io.models.savedextensions import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.Params -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.ExtensionConfig +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.Params +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.http.QueryParams +import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.io.models.ExtensionConfig import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/BaseWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/BaseWebhookEvent.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/BaseWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/BaseWebhookEvent.kt index 9446ec87..adc27d7c 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/BaseWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/BaseWebhookEvent.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileCreateEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileCreateEvent.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileCreateEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileCreateEvent.kt index 4ea563a0..711d2141 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileCreateEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileCreateEvent.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.files.File +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.io.models.files.File import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileDeleteEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileDeleteEvent.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileDeleteEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileDeleteEvent.kt index d7e6177f..19ba2f05 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileDeleteEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileDeleteEvent.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileUpdateEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileUpdateEvent.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileUpdateEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileUpdateEvent.kt index aa0a2c51..9a104c9d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileUpdateEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileUpdateEvent.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.files.File +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.io.models.files.File import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionCreateEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileVersionCreateEvent.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionCreateEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileVersionCreateEvent.kt index c86abcce..110681cc 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionCreateEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileVersionCreateEvent.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.files.File +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.io.models.files.File import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionDeleteEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileVersionDeleteEvent.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionDeleteEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileVersionDeleteEvent.kt index 9b9219bb..61642038 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/FileVersionDeleteEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileVersionDeleteEvent.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UnsafeUnwrapWebhookEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UnsafeUnwrapWebhookEvent.kt index 1e6d8516..fec05714 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UnsafeUnwrapWebhookEvent.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -9,12 +9,12 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.allMaxBy -import com.imagekit.api.core.getOrThrow -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.BaseDeserializer +import io.imagekit.io.core.BaseSerializer +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.allMaxBy +import io.imagekit.io.core.getOrThrow +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UnwrapWebhookEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UnwrapWebhookEvent.kt index 70c27e7a..2ea46ede 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UnwrapWebhookEvent.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -9,12 +9,12 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.BaseDeserializer -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.allMaxBy -import com.imagekit.api.core.getOrThrow -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.BaseDeserializer +import io.imagekit.io.core.BaseSerializer +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.allMaxBy +import io.imagekit.io.core.getOrThrow +import io.imagekit.io.errors.ImageKitInvalidDataException import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformErrorEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformErrorEvent.kt index 9ec85370..4a0f3dae 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformErrorEvent.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformSuccessEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformSuccessEvent.kt index cf6e340c..a1342ecb 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformSuccessEvent.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformErrorEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformErrorEvent.kt index e346a9ca..5f951024 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformErrorEvent.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkRequired -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkRequired +import io.imagekit.io.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformSuccessEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformSuccessEvent.kt index 90e34d74..2757905c 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformSuccessEvent.kt @@ -1,26 +1,26 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.AiTag -import com.imagekit.api.models.CustomMetadata -import com.imagekit.api.models.EmbeddedMetadata -import com.imagekit.api.models.SelectedFieldsSchema -import com.imagekit.api.models.VersionInfo -import com.imagekit.api.models.files.Metadata +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.io.models.AiTag +import io.imagekit.io.models.CustomMetadata +import io.imagekit.io.models.EmbeddedMetadata +import io.imagekit.io.models.SelectedFieldsSchema +import io.imagekit.io.models.VersionInfo +import io.imagekit.io.models.files.Metadata import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/VideoTransformationAcceptedEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/VideoTransformationAcceptedEvent.kt index 38e493b3..5193bde4 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/VideoTransformationAcceptedEvent.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/VideoTransformationErrorEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/VideoTransformationErrorEvent.kt index e61c14b3..17cfd117 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/VideoTransformationErrorEvent.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/VideoTransformationReadyEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/VideoTransformationReadyEvent.kt index d16c228d..78f49627 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/VideoTransformationReadyEvent.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonMissing -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.Enum +import io.imagekit.io.core.ExcludeMissing +import io.imagekit.io.core.JsonField +import io.imagekit.io.core.JsonMissing +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.checkKnown +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.toImmutable +import io.imagekit.io.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AccountServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AccountServiceAsync.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AccountServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AccountServiceAsync.kt index b8387b91..ba3b573b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AccountServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AccountServiceAsync.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async +package io.imagekit.io.services.async -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.services.async.accounts.OriginServiceAsync -import com.imagekit.api.services.async.accounts.UrlEndpointServiceAsync -import com.imagekit.api.services.async.accounts.UsageServiceAsync +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.services.async.accounts.OriginServiceAsync +import io.imagekit.io.services.async.accounts.UrlEndpointServiceAsync +import io.imagekit.io.services.async.accounts.UsageServiceAsync import java.util.function.Consumer interface AccountServiceAsync { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AccountServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AccountServiceAsyncImpl.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AccountServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AccountServiceAsyncImpl.kt index a6322df0..54d9bc8e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AccountServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AccountServiceAsyncImpl.kt @@ -1,14 +1,14 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.services.async.accounts.OriginServiceAsync -import com.imagekit.api.services.async.accounts.OriginServiceAsyncImpl -import com.imagekit.api.services.async.accounts.UrlEndpointServiceAsync -import com.imagekit.api.services.async.accounts.UrlEndpointServiceAsyncImpl -import com.imagekit.api.services.async.accounts.UsageServiceAsync -import com.imagekit.api.services.async.accounts.UsageServiceAsyncImpl +package io.imagekit.io.services.async + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.services.async.accounts.OriginServiceAsync +import io.imagekit.io.services.async.accounts.OriginServiceAsyncImpl +import io.imagekit.io.services.async.accounts.UrlEndpointServiceAsync +import io.imagekit.io.services.async.accounts.UrlEndpointServiceAsyncImpl +import io.imagekit.io.services.async.accounts.UsageServiceAsync +import io.imagekit.io.services.async.accounts.UsageServiceAsyncImpl import java.util.function.Consumer class AccountServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AssetServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AssetServiceAsync.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AssetServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AssetServiceAsync.kt index cd5259cf..6df3b9d8 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AssetServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AssetServiceAsync.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async +package io.imagekit.io.services.async -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.assets.AssetListParams -import com.imagekit.api.models.assets.AssetListResponse +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.assets.AssetListParams +import io.imagekit.io.models.assets.AssetListResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AssetServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AssetServiceAsyncImpl.kt similarity index 79% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AssetServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AssetServiceAsyncImpl.kt index 316d3882..45fc46c6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/AssetServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AssetServiceAsyncImpl.kt @@ -1,21 +1,21 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async +package io.imagekit.io.services.async -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepareAsync -import com.imagekit.api.models.assets.AssetListParams -import com.imagekit.api.models.assets.AssetListResponse +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepareAsync +import io.imagekit.io.models.assets.AssetListParams +import io.imagekit.io.models.assets.AssetListResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BetaServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/BetaServiceAsync.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BetaServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/BetaServiceAsync.kt index 10252777..3cb535ec 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BetaServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/BetaServiceAsync.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async +package io.imagekit.io.services.async -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.services.async.beta.V2ServiceAsync +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.services.async.beta.V2ServiceAsync import java.util.function.Consumer interface BetaServiceAsync { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BetaServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/BetaServiceAsyncImpl.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BetaServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/BetaServiceAsyncImpl.kt index 1ad19f0c..39d22a52 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/BetaServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/BetaServiceAsyncImpl.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async +package io.imagekit.io.services.async -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.services.async.beta.V2ServiceAsync -import com.imagekit.api.services.async.beta.V2ServiceAsyncImpl +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.services.async.beta.V2ServiceAsync +import io.imagekit.io.services.async.beta.V2ServiceAsyncImpl import java.util.function.Consumer class BetaServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CacheServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CacheServiceAsync.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CacheServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CacheServiceAsync.kt index 76b4415c..35190bfe 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CacheServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CacheServiceAsync.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async +package io.imagekit.io.services.async -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.services.async.cache.InvalidationServiceAsync +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.services.async.cache.InvalidationServiceAsync import java.util.function.Consumer interface CacheServiceAsync { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CacheServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CacheServiceAsyncImpl.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CacheServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CacheServiceAsyncImpl.kt index 0690192a..ba6ba04f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CacheServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CacheServiceAsyncImpl.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async +package io.imagekit.io.services.async -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.services.async.cache.InvalidationServiceAsync -import com.imagekit.api.services.async.cache.InvalidationServiceAsyncImpl +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.services.async.cache.InvalidationServiceAsync +import io.imagekit.io.services.async.cache.InvalidationServiceAsyncImpl import java.util.function.Consumer class CacheServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CustomMetadataFieldServiceAsync.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CustomMetadataFieldServiceAsync.kt index 77621817..e34966a6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CustomMetadataFieldServiceAsync.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.custommetadatafields.CustomMetadataField -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +package io.imagekit.io.services.async + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.custommetadatafields.CustomMetadataField +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldCreateParams +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldDeleteParams +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldDeleteResponse +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldListParams +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CustomMetadataFieldServiceAsyncImpl.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CustomMetadataFieldServiceAsyncImpl.kt index 35d3ee2c..e4aed63f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CustomMetadataFieldServiceAsyncImpl.kt @@ -1,27 +1,27 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.json -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepareAsync -import com.imagekit.api.models.custommetadatafields.CustomMetadataField -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +package io.imagekit.io.services.async + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.json +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepareAsync +import io.imagekit.io.models.custommetadatafields.CustomMetadataField +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldCreateParams +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldDeleteParams +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldDeleteResponse +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldListParams +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FileServiceAsync.kt similarity index 92% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FileServiceAsync.kt index 24b3f071..29ec4e54 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FileServiceAsync.kt @@ -1,27 +1,27 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.files.File -import com.imagekit.api.models.files.FileCopyParams -import com.imagekit.api.models.files.FileCopyResponse -import com.imagekit.api.models.files.FileDeleteParams -import com.imagekit.api.models.files.FileGetParams -import com.imagekit.api.models.files.FileMoveParams -import com.imagekit.api.models.files.FileMoveResponse -import com.imagekit.api.models.files.FileRenameParams -import com.imagekit.api.models.files.FileRenameResponse -import com.imagekit.api.models.files.FileUpdateParams -import com.imagekit.api.models.files.FileUpdateResponse -import com.imagekit.api.models.files.FileUploadParams -import com.imagekit.api.models.files.FileUploadResponse -import com.imagekit.api.services.async.files.BulkServiceAsync -import com.imagekit.api.services.async.files.MetadataServiceAsync -import com.imagekit.api.services.async.files.VersionServiceAsync +package io.imagekit.io.services.async + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.files.File +import io.imagekit.io.models.files.FileCopyParams +import io.imagekit.io.models.files.FileCopyResponse +import io.imagekit.io.models.files.FileDeleteParams +import io.imagekit.io.models.files.FileGetParams +import io.imagekit.io.models.files.FileMoveParams +import io.imagekit.io.models.files.FileMoveResponse +import io.imagekit.io.models.files.FileRenameParams +import io.imagekit.io.models.files.FileRenameResponse +import io.imagekit.io.models.files.FileUpdateParams +import io.imagekit.io.models.files.FileUpdateResponse +import io.imagekit.io.models.files.FileUploadParams +import io.imagekit.io.models.files.FileUploadResponse +import io.imagekit.io.services.async.files.BulkServiceAsync +import io.imagekit.io.services.async.files.MetadataServiceAsync +import io.imagekit.io.services.async.files.VersionServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FileServiceAsyncImpl.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FileServiceAsyncImpl.kt index f50f873a..e3fce0f6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FileServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FileServiceAsyncImpl.kt @@ -1,42 +1,42 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.handlers.emptyHandler -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.json -import com.imagekit.api.core.http.multipartFormData -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepareAsync -import com.imagekit.api.models.files.File -import com.imagekit.api.models.files.FileCopyParams -import com.imagekit.api.models.files.FileCopyResponse -import com.imagekit.api.models.files.FileDeleteParams -import com.imagekit.api.models.files.FileGetParams -import com.imagekit.api.models.files.FileMoveParams -import com.imagekit.api.models.files.FileMoveResponse -import com.imagekit.api.models.files.FileRenameParams -import com.imagekit.api.models.files.FileRenameResponse -import com.imagekit.api.models.files.FileUpdateParams -import com.imagekit.api.models.files.FileUpdateResponse -import com.imagekit.api.models.files.FileUploadParams -import com.imagekit.api.models.files.FileUploadResponse -import com.imagekit.api.services.async.files.BulkServiceAsync -import com.imagekit.api.services.async.files.BulkServiceAsyncImpl -import com.imagekit.api.services.async.files.MetadataServiceAsync -import com.imagekit.api.services.async.files.MetadataServiceAsyncImpl -import com.imagekit.api.services.async.files.VersionServiceAsync -import com.imagekit.api.services.async.files.VersionServiceAsyncImpl +package io.imagekit.io.services.async + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.handlers.emptyHandler +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.json +import io.imagekit.io.core.http.multipartFormData +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepareAsync +import io.imagekit.io.models.files.File +import io.imagekit.io.models.files.FileCopyParams +import io.imagekit.io.models.files.FileCopyResponse +import io.imagekit.io.models.files.FileDeleteParams +import io.imagekit.io.models.files.FileGetParams +import io.imagekit.io.models.files.FileMoveParams +import io.imagekit.io.models.files.FileMoveResponse +import io.imagekit.io.models.files.FileRenameParams +import io.imagekit.io.models.files.FileRenameResponse +import io.imagekit.io.models.files.FileUpdateParams +import io.imagekit.io.models.files.FileUpdateResponse +import io.imagekit.io.models.files.FileUploadParams +import io.imagekit.io.models.files.FileUploadResponse +import io.imagekit.io.services.async.files.BulkServiceAsync +import io.imagekit.io.services.async.files.BulkServiceAsyncImpl +import io.imagekit.io.services.async.files.MetadataServiceAsync +import io.imagekit.io.services.async.files.MetadataServiceAsyncImpl +import io.imagekit.io.services.async.files.VersionServiceAsync +import io.imagekit.io.services.async.files.VersionServiceAsyncImpl import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FolderServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FolderServiceAsync.kt similarity index 89% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FolderServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FolderServiceAsync.kt index aaa08ff2..57354a82 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FolderServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FolderServiceAsync.kt @@ -1,21 +1,21 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.folders.FolderCopyParams -import com.imagekit.api.models.folders.FolderCopyResponse -import com.imagekit.api.models.folders.FolderCreateParams -import com.imagekit.api.models.folders.FolderCreateResponse -import com.imagekit.api.models.folders.FolderDeleteParams -import com.imagekit.api.models.folders.FolderDeleteResponse -import com.imagekit.api.models.folders.FolderMoveParams -import com.imagekit.api.models.folders.FolderMoveResponse -import com.imagekit.api.models.folders.FolderRenameParams -import com.imagekit.api.models.folders.FolderRenameResponse -import com.imagekit.api.services.async.folders.JobServiceAsync +package io.imagekit.io.services.async + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.folders.FolderCopyParams +import io.imagekit.io.models.folders.FolderCopyResponse +import io.imagekit.io.models.folders.FolderCreateParams +import io.imagekit.io.models.folders.FolderCreateResponse +import io.imagekit.io.models.folders.FolderDeleteParams +import io.imagekit.io.models.folders.FolderDeleteResponse +import io.imagekit.io.models.folders.FolderMoveParams +import io.imagekit.io.models.folders.FolderMoveResponse +import io.imagekit.io.models.folders.FolderRenameParams +import io.imagekit.io.models.folders.FolderRenameResponse +import io.imagekit.io.services.async.folders.JobServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FolderServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FolderServiceAsyncImpl.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FolderServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FolderServiceAsyncImpl.kt index 426fe095..c2a728d0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/FolderServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FolderServiceAsyncImpl.kt @@ -1,32 +1,32 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async +package io.imagekit.io.services.async -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.json -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepareAsync -import com.imagekit.api.models.folders.FolderCopyParams -import com.imagekit.api.models.folders.FolderCopyResponse -import com.imagekit.api.models.folders.FolderCreateParams -import com.imagekit.api.models.folders.FolderCreateResponse -import com.imagekit.api.models.folders.FolderDeleteParams -import com.imagekit.api.models.folders.FolderDeleteResponse -import com.imagekit.api.models.folders.FolderMoveParams -import com.imagekit.api.models.folders.FolderMoveResponse -import com.imagekit.api.models.folders.FolderRenameParams -import com.imagekit.api.models.folders.FolderRenameResponse -import com.imagekit.api.services.async.folders.JobServiceAsync -import com.imagekit.api.services.async.folders.JobServiceAsyncImpl +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.json +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepareAsync +import io.imagekit.io.models.folders.FolderCopyParams +import io.imagekit.io.models.folders.FolderCopyResponse +import io.imagekit.io.models.folders.FolderCreateParams +import io.imagekit.io.models.folders.FolderCreateResponse +import io.imagekit.io.models.folders.FolderDeleteParams +import io.imagekit.io.models.folders.FolderDeleteResponse +import io.imagekit.io.models.folders.FolderMoveParams +import io.imagekit.io.models.folders.FolderMoveResponse +import io.imagekit.io.models.folders.FolderRenameParams +import io.imagekit.io.models.folders.FolderRenameResponse +import io.imagekit.io.services.async.folders.JobServiceAsync +import io.imagekit.io.services.async.folders.JobServiceAsyncImpl import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/SavedExtensionServiceAsync.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/SavedExtensionServiceAsync.kt index aad46996..99c8b35e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/SavedExtensionServiceAsync.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.SavedExtension -import com.imagekit.api.models.savedextensions.SavedExtensionCreateParams -import com.imagekit.api.models.savedextensions.SavedExtensionDeleteParams -import com.imagekit.api.models.savedextensions.SavedExtensionGetParams -import com.imagekit.api.models.savedextensions.SavedExtensionListParams -import com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams +package io.imagekit.io.services.async + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.SavedExtension +import io.imagekit.io.models.savedextensions.SavedExtensionCreateParams +import io.imagekit.io.models.savedextensions.SavedExtensionDeleteParams +import io.imagekit.io.models.savedextensions.SavedExtensionGetParams +import io.imagekit.io.models.savedextensions.SavedExtensionListParams +import io.imagekit.io.models.savedextensions.SavedExtensionUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/SavedExtensionServiceAsyncImpl.kt similarity index 89% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/SavedExtensionServiceAsyncImpl.kt index e9df15a3..b5366cba 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/SavedExtensionServiceAsyncImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.handlers.emptyHandler -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.json -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepareAsync -import com.imagekit.api.models.SavedExtension -import com.imagekit.api.models.savedextensions.SavedExtensionCreateParams -import com.imagekit.api.models.savedextensions.SavedExtensionDeleteParams -import com.imagekit.api.models.savedextensions.SavedExtensionGetParams -import com.imagekit.api.models.savedextensions.SavedExtensionListParams -import com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams +package io.imagekit.io.services.async + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.handlers.emptyHandler +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.json +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepareAsync +import io.imagekit.io.models.SavedExtension +import io.imagekit.io.models.savedextensions.SavedExtensionCreateParams +import io.imagekit.io.models.savedextensions.SavedExtensionDeleteParams +import io.imagekit.io.models.savedextensions.SavedExtensionGetParams +import io.imagekit.io.models.savedextensions.SavedExtensionListParams +import io.imagekit.io.models.savedextensions.SavedExtensionUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/WebhookServiceAsync.kt similarity index 82% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/WebhookServiceAsync.kt index 0ba2e5ca..aed8107d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/WebhookServiceAsync.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.UnwrapWebhookParams -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.errors.ImageKitWebhookException -import com.imagekit.api.models.webhooks.UnsafeUnwrapWebhookEvent -import com.imagekit.api.models.webhooks.UnwrapWebhookEvent +package io.imagekit.io.services.async + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.UnwrapWebhookParams +import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.io.errors.ImageKitWebhookException +import io.imagekit.io.models.webhooks.UnsafeUnwrapWebhookEvent +import io.imagekit.io.models.webhooks.UnwrapWebhookEvent import java.util.function.Consumer interface WebhookServiceAsync { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/WebhookServiceAsyncImpl.kt similarity index 82% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/WebhookServiceAsyncImpl.kt index 5ea79828..e3a1ef36 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/WebhookServiceAsyncImpl.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async +package io.imagekit.io.services.async -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.UnwrapWebhookParams -import com.imagekit.api.models.webhooks.UnsafeUnwrapWebhookEvent -import com.imagekit.api.models.webhooks.UnwrapWebhookEvent -import com.imagekit.api.services.blocking.WebhookServiceImpl +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.UnwrapWebhookParams +import io.imagekit.io.models.webhooks.UnsafeUnwrapWebhookEvent +import io.imagekit.io.models.webhooks.UnwrapWebhookEvent +import io.imagekit.io.services.blocking.WebhookServiceImpl import java.util.function.Consumer class WebhookServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/OriginServiceAsync.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/OriginServiceAsync.kt index c568f188..e05cfd42 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/OriginServiceAsync.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.accounts - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.accounts.origins.OriginCreateParams -import com.imagekit.api.models.accounts.origins.OriginDeleteParams -import com.imagekit.api.models.accounts.origins.OriginGetParams -import com.imagekit.api.models.accounts.origins.OriginListParams -import com.imagekit.api.models.accounts.origins.OriginRequest -import com.imagekit.api.models.accounts.origins.OriginResponse -import com.imagekit.api.models.accounts.origins.OriginUpdateParams +package io.imagekit.io.services.async.accounts + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.accounts.origins.OriginCreateParams +import io.imagekit.io.models.accounts.origins.OriginDeleteParams +import io.imagekit.io.models.accounts.origins.OriginGetParams +import io.imagekit.io.models.accounts.origins.OriginListParams +import io.imagekit.io.models.accounts.origins.OriginRequest +import io.imagekit.io.models.accounts.origins.OriginResponse +import io.imagekit.io.models.accounts.origins.OriginUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/OriginServiceAsyncImpl.kt similarity index 89% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/OriginServiceAsyncImpl.kt index 7b9da703..238a1c14 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/OriginServiceAsyncImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.accounts - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.handlers.emptyHandler -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.json -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepareAsync -import com.imagekit.api.models.accounts.origins.OriginCreateParams -import com.imagekit.api.models.accounts.origins.OriginDeleteParams -import com.imagekit.api.models.accounts.origins.OriginGetParams -import com.imagekit.api.models.accounts.origins.OriginListParams -import com.imagekit.api.models.accounts.origins.OriginResponse -import com.imagekit.api.models.accounts.origins.OriginUpdateParams +package io.imagekit.io.services.async.accounts + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.handlers.emptyHandler +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.json +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepareAsync +import io.imagekit.io.models.accounts.origins.OriginCreateParams +import io.imagekit.io.models.accounts.origins.OriginDeleteParams +import io.imagekit.io.models.accounts.origins.OriginGetParams +import io.imagekit.io.models.accounts.origins.OriginListParams +import io.imagekit.io.models.accounts.origins.OriginResponse +import io.imagekit.io.models.accounts.origins.OriginUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UrlEndpointServiceAsync.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UrlEndpointServiceAsync.kt index 51897d33..bfae96d4 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UrlEndpointServiceAsync.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.accounts - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +package io.imagekit.io.services.async.accounts + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointCreateParams +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointDeleteParams +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointGetParams +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointListParams +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointRequest +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointResponse +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UrlEndpointServiceAsyncImpl.kt similarity index 89% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UrlEndpointServiceAsyncImpl.kt index de716666..ec8770bf 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UrlEndpointServiceAsyncImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.accounts - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.handlers.emptyHandler -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.json -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepareAsync -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +package io.imagekit.io.services.async.accounts + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.handlers.emptyHandler +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.json +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepareAsync +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointCreateParams +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointDeleteParams +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointGetParams +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointListParams +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointResponse +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UsageServiceAsync.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UsageServiceAsync.kt index 86d7d141..08d989e4 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UsageServiceAsync.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.accounts +package io.imagekit.io.services.async.accounts -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.accounts.usage.UsageGetParams -import com.imagekit.api.models.accounts.usage.UsageGetResponse +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.accounts.usage.UsageGetParams +import io.imagekit.io.models.accounts.usage.UsageGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UsageServiceAsyncImpl.kt similarity index 78% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UsageServiceAsyncImpl.kt index 60ebeddd..7e2ad1d2 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UsageServiceAsyncImpl.kt @@ -1,21 +1,21 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.accounts +package io.imagekit.io.services.async.accounts -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepareAsync -import com.imagekit.api.models.accounts.usage.UsageGetParams -import com.imagekit.api.models.accounts.usage.UsageGetResponse +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepareAsync +import io.imagekit.io.models.accounts.usage.UsageGetParams +import io.imagekit.io.models.accounts.usage.UsageGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/V2ServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/V2ServiceAsync.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/V2ServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/V2ServiceAsync.kt index 1048ace9..1b4e61f5 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/V2ServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/V2ServiceAsync.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.beta +package io.imagekit.io.services.async.beta -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.services.async.beta.v2.FileServiceAsync +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.services.async.beta.v2.FileServiceAsync import java.util.function.Consumer interface V2ServiceAsync { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/V2ServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/V2ServiceAsyncImpl.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/V2ServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/V2ServiceAsyncImpl.kt index f07a7a24..b254fd2a 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/V2ServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/V2ServiceAsyncImpl.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.beta +package io.imagekit.io.services.async.beta -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.services.async.beta.v2.FileServiceAsync -import com.imagekit.api.services.async.beta.v2.FileServiceAsyncImpl +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.services.async.beta.v2.FileServiceAsync +import io.imagekit.io.services.async.beta.v2.FileServiceAsyncImpl import java.util.function.Consumer class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/v2/FileServiceAsync.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/v2/FileServiceAsync.kt index 389f5f70..2b43a16c 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/v2/FileServiceAsync.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.beta.v2 +package io.imagekit.io.services.async.beta.v2 -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.beta.v2.files.FileUploadParams -import com.imagekit.api.models.beta.v2.files.FileUploadResponse +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.beta.v2.files.FileUploadParams +import io.imagekit.io.models.beta.v2.files.FileUploadResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/v2/FileServiceAsyncImpl.kt similarity index 79% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/v2/FileServiceAsyncImpl.kt index 1649f9bb..8d90b871 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/v2/FileServiceAsyncImpl.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.beta.v2 +package io.imagekit.io.services.async.beta.v2 -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.multipartFormData -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepareAsync -import com.imagekit.api.models.beta.v2.files.FileUploadParams -import com.imagekit.api.models.beta.v2.files.FileUploadResponse +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.multipartFormData +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepareAsync +import io.imagekit.io.models.beta.v2.files.FileUploadParams +import io.imagekit.io.models.beta.v2.files.FileUploadResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/cache/InvalidationServiceAsync.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/cache/InvalidationServiceAsync.kt index 49c88616..a520b176 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/cache/InvalidationServiceAsync.kt @@ -1,14 +1,14 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.cache - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.cache.invalidation.InvalidationCreateParams -import com.imagekit.api.models.cache.invalidation.InvalidationCreateResponse -import com.imagekit.api.models.cache.invalidation.InvalidationGetParams -import com.imagekit.api.models.cache.invalidation.InvalidationGetResponse +package io.imagekit.io.services.async.cache + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.cache.invalidation.InvalidationCreateParams +import io.imagekit.io.models.cache.invalidation.InvalidationCreateResponse +import io.imagekit.io.models.cache.invalidation.InvalidationGetParams +import io.imagekit.io.models.cache.invalidation.InvalidationGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/cache/InvalidationServiceAsyncImpl.kt similarity index 82% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/cache/InvalidationServiceAsyncImpl.kt index d7e41771..edf9c8f0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/cache/InvalidationServiceAsyncImpl.kt @@ -1,25 +1,25 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.cache +package io.imagekit.io.services.async.cache -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.json -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepareAsync -import com.imagekit.api.models.cache.invalidation.InvalidationCreateParams -import com.imagekit.api.models.cache.invalidation.InvalidationCreateResponse -import com.imagekit.api.models.cache.invalidation.InvalidationGetParams -import com.imagekit.api.models.cache.invalidation.InvalidationGetResponse +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.json +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepareAsync +import io.imagekit.io.models.cache.invalidation.InvalidationCreateParams +import io.imagekit.io.models.cache.invalidation.InvalidationCreateResponse +import io.imagekit.io.models.cache.invalidation.InvalidationGetParams +import io.imagekit.io.models.cache.invalidation.InvalidationGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BulkServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/BulkServiceAsync.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BulkServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/BulkServiceAsync.kt index bab5c67a..678856da 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BulkServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/BulkServiceAsync.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.files - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.files.bulk.BulkAddTagsParams -import com.imagekit.api.models.files.bulk.BulkAddTagsResponse -import com.imagekit.api.models.files.bulk.BulkDeleteParams -import com.imagekit.api.models.files.bulk.BulkDeleteResponse -import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams -import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse -import com.imagekit.api.models.files.bulk.BulkRemoveTagsParams -import com.imagekit.api.models.files.bulk.BulkRemoveTagsResponse +package io.imagekit.io.services.async.files + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.files.bulk.BulkAddTagsParams +import io.imagekit.io.models.files.bulk.BulkAddTagsResponse +import io.imagekit.io.models.files.bulk.BulkDeleteParams +import io.imagekit.io.models.files.bulk.BulkDeleteResponse +import io.imagekit.io.models.files.bulk.BulkRemoveAiTagsParams +import io.imagekit.io.models.files.bulk.BulkRemoveAiTagsResponse +import io.imagekit.io.models.files.bulk.BulkRemoveTagsParams +import io.imagekit.io.models.files.bulk.BulkRemoveTagsResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/BulkServiceAsyncImpl.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/BulkServiceAsyncImpl.kt index b4f268d4..6a4a72b8 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/BulkServiceAsyncImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.files - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.json -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepareAsync -import com.imagekit.api.models.files.bulk.BulkAddTagsParams -import com.imagekit.api.models.files.bulk.BulkAddTagsResponse -import com.imagekit.api.models.files.bulk.BulkDeleteParams -import com.imagekit.api.models.files.bulk.BulkDeleteResponse -import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams -import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse -import com.imagekit.api.models.files.bulk.BulkRemoveTagsParams -import com.imagekit.api.models.files.bulk.BulkRemoveTagsResponse +package io.imagekit.io.services.async.files + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.json +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepareAsync +import io.imagekit.io.models.files.bulk.BulkAddTagsParams +import io.imagekit.io.models.files.bulk.BulkAddTagsResponse +import io.imagekit.io.models.files.bulk.BulkDeleteParams +import io.imagekit.io.models.files.bulk.BulkDeleteResponse +import io.imagekit.io.models.files.bulk.BulkRemoveAiTagsParams +import io.imagekit.io.models.files.bulk.BulkRemoveAiTagsResponse +import io.imagekit.io.models.files.bulk.BulkRemoveTagsParams +import io.imagekit.io.models.files.bulk.BulkRemoveTagsResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/MetadataServiceAsync.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/MetadataServiceAsync.kt index 29bb636f..d314bcb0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/MetadataServiceAsync.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.files - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.files.Metadata -import com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams -import com.imagekit.api.models.files.metadata.MetadataGetParams +package io.imagekit.io.services.async.files + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.files.Metadata +import io.imagekit.io.models.files.metadata.MetadataGetFromUrlParams +import io.imagekit.io.models.files.metadata.MetadataGetParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/MetadataServiceAsyncImpl.kt similarity index 84% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/MetadataServiceAsyncImpl.kt index 6c02890b..5031ec4f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/MetadataServiceAsyncImpl.kt @@ -1,23 +1,23 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.files +package io.imagekit.io.services.async.files -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepareAsync -import com.imagekit.api.models.files.Metadata -import com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams -import com.imagekit.api.models.files.metadata.MetadataGetParams +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepareAsync +import io.imagekit.io.models.files.Metadata +import io.imagekit.io.models.files.metadata.MetadataGetFromUrlParams +import io.imagekit.io.models.files.metadata.MetadataGetParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/VersionServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/VersionServiceAsync.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/VersionServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/VersionServiceAsync.kt index 62bdd118..490362f0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/VersionServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/VersionServiceAsync.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.files - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.files.File -import com.imagekit.api.models.files.versions.VersionDeleteParams -import com.imagekit.api.models.files.versions.VersionDeleteResponse -import com.imagekit.api.models.files.versions.VersionGetParams -import com.imagekit.api.models.files.versions.VersionListParams -import com.imagekit.api.models.files.versions.VersionRestoreParams +package io.imagekit.io.services.async.files + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.files.File +import io.imagekit.io.models.files.versions.VersionDeleteParams +import io.imagekit.io.models.files.versions.VersionDeleteResponse +import io.imagekit.io.models.files.versions.VersionGetParams +import io.imagekit.io.models.files.versions.VersionListParams +import io.imagekit.io.models.files.versions.VersionRestoreParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/VersionServiceAsyncImpl.kt similarity index 89% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/VersionServiceAsyncImpl.kt index c601ebe2..23bc5802 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/VersionServiceAsyncImpl.kt @@ -1,27 +1,27 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.files - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.json -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepareAsync -import com.imagekit.api.models.files.File -import com.imagekit.api.models.files.versions.VersionDeleteParams -import com.imagekit.api.models.files.versions.VersionDeleteResponse -import com.imagekit.api.models.files.versions.VersionGetParams -import com.imagekit.api.models.files.versions.VersionListParams -import com.imagekit.api.models.files.versions.VersionRestoreParams +package io.imagekit.io.services.async.files + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.json +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepareAsync +import io.imagekit.io.models.files.File +import io.imagekit.io.models.files.versions.VersionDeleteParams +import io.imagekit.io.models.files.versions.VersionDeleteResponse +import io.imagekit.io.models.files.versions.VersionGetParams +import io.imagekit.io.models.files.versions.VersionListParams +import io.imagekit.io.models.files.versions.VersionRestoreParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/folders/JobServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/folders/JobServiceAsync.kt similarity index 92% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/folders/JobServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/folders/JobServiceAsync.kt index 48bf8371..cc6a4bfe 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/folders/JobServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/folders/JobServiceAsync.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.folders +package io.imagekit.io.services.async.folders -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.folders.job.JobGetParams -import com.imagekit.api.models.folders.job.JobGetResponse +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.folders.job.JobGetParams +import io.imagekit.io.models.folders.job.JobGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/folders/JobServiceAsyncImpl.kt similarity index 79% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/folders/JobServiceAsyncImpl.kt index 4f0f7a34..315718b5 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/folders/JobServiceAsyncImpl.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.folders +package io.imagekit.io.services.async.folders -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepareAsync -import com.imagekit.api.models.folders.job.JobGetParams -import com.imagekit.api.models.folders.job.JobGetResponse +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepareAsync +import io.imagekit.io.models.folders.job.JobGetParams +import io.imagekit.io.models.folders.job.JobGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AccountService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AccountService.kt similarity index 80% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AccountService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AccountService.kt index 40a68ccd..4643e217 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AccountService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AccountService.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking +package io.imagekit.io.services.blocking -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.services.blocking.accounts.OriginService -import com.imagekit.api.services.blocking.accounts.UrlEndpointService -import com.imagekit.api.services.blocking.accounts.UsageService +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.services.blocking.accounts.OriginService +import io.imagekit.io.services.blocking.accounts.UrlEndpointService +import io.imagekit.io.services.blocking.accounts.UsageService import java.util.function.Consumer interface AccountService { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AccountServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AccountServiceImpl.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AccountServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AccountServiceImpl.kt index 3f7a4a19..d437536e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AccountServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AccountServiceImpl.kt @@ -1,14 +1,14 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.services.blocking.accounts.OriginService -import com.imagekit.api.services.blocking.accounts.OriginServiceImpl -import com.imagekit.api.services.blocking.accounts.UrlEndpointService -import com.imagekit.api.services.blocking.accounts.UrlEndpointServiceImpl -import com.imagekit.api.services.blocking.accounts.UsageService -import com.imagekit.api.services.blocking.accounts.UsageServiceImpl +package io.imagekit.io.services.blocking + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.services.blocking.accounts.OriginService +import io.imagekit.io.services.blocking.accounts.OriginServiceImpl +import io.imagekit.io.services.blocking.accounts.UrlEndpointService +import io.imagekit.io.services.blocking.accounts.UrlEndpointServiceImpl +import io.imagekit.io.services.blocking.accounts.UsageService +import io.imagekit.io.services.blocking.accounts.UsageServiceImpl import java.util.function.Consumer class AccountServiceImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AssetService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AssetService.kt similarity index 90% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AssetService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AssetService.kt index 0d407ff4..b55e492b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AssetService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AssetService.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking +package io.imagekit.io.services.blocking import com.google.errorprone.annotations.MustBeClosed -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.assets.AssetListParams -import com.imagekit.api.models.assets.AssetListResponse +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.assets.AssetListParams +import io.imagekit.io.models.assets.AssetListResponse import java.util.function.Consumer interface AssetService { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AssetServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AssetServiceImpl.kt similarity index 77% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AssetServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AssetServiceImpl.kt index 0297ddbc..a6ff5784 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/AssetServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AssetServiceImpl.kt @@ -1,21 +1,21 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking +package io.imagekit.io.services.blocking -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepare -import com.imagekit.api.models.assets.AssetListParams -import com.imagekit.api.models.assets.AssetListResponse +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepare +import io.imagekit.io.models.assets.AssetListParams +import io.imagekit.io.models.assets.AssetListResponse import java.util.function.Consumer class AssetServiceImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BetaService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/BetaService.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BetaService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/BetaService.kt index 4b76e4e6..911cffec 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BetaService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/BetaService.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking +package io.imagekit.io.services.blocking -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.services.blocking.beta.V2Service +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.services.blocking.beta.V2Service import java.util.function.Consumer interface BetaService { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BetaServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/BetaServiceImpl.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BetaServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/BetaServiceImpl.kt index 89cc1179..f8aef7c7 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/BetaServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/BetaServiceImpl.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking +package io.imagekit.io.services.blocking -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.services.blocking.beta.V2Service -import com.imagekit.api.services.blocking.beta.V2ServiceImpl +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.services.blocking.beta.V2Service +import io.imagekit.io.services.blocking.beta.V2ServiceImpl import java.util.function.Consumer class BetaServiceImpl internal constructor(private val clientOptions: ClientOptions) : BetaService { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CacheService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CacheService.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CacheService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CacheService.kt index f12bf842..8283818e 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CacheService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CacheService.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking +package io.imagekit.io.services.blocking -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.services.blocking.cache.InvalidationService +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.services.blocking.cache.InvalidationService import java.util.function.Consumer interface CacheService { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CacheServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CacheServiceImpl.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CacheServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CacheServiceImpl.kt index 32e92965..a307d223 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CacheServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CacheServiceImpl.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking +package io.imagekit.io.services.blocking -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.services.blocking.cache.InvalidationService -import com.imagekit.api.services.blocking.cache.InvalidationServiceImpl +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.services.blocking.cache.InvalidationService +import io.imagekit.io.services.blocking.cache.InvalidationServiceImpl import java.util.function.Consumer class CacheServiceImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CustomMetadataFieldService.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CustomMetadataFieldService.kt index e9751f5a..992332f0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CustomMetadataFieldService.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking +package io.imagekit.io.services.blocking import com.google.errorprone.annotations.MustBeClosed -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.custommetadatafields.CustomMetadataField -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.custommetadatafields.CustomMetadataField +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldCreateParams +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldDeleteParams +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldDeleteResponse +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldListParams +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldUpdateParams import java.util.function.Consumer interface CustomMetadataFieldService { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CustomMetadataFieldServiceImpl.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CustomMetadataFieldServiceImpl.kt index ac2e2357..84563b6f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CustomMetadataFieldServiceImpl.kt @@ -1,27 +1,27 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.json -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepare -import com.imagekit.api.models.custommetadatafields.CustomMetadataField -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +package io.imagekit.io.services.blocking + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.json +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepare +import io.imagekit.io.models.custommetadatafields.CustomMetadataField +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldCreateParams +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldDeleteParams +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldDeleteResponse +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldListParams +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FileService.kt similarity index 92% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FileService.kt index d5031fd9..6f873938 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FileService.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking +package io.imagekit.io.services.blocking import com.google.errorprone.annotations.MustBeClosed -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.files.File -import com.imagekit.api.models.files.FileCopyParams -import com.imagekit.api.models.files.FileCopyResponse -import com.imagekit.api.models.files.FileDeleteParams -import com.imagekit.api.models.files.FileGetParams -import com.imagekit.api.models.files.FileMoveParams -import com.imagekit.api.models.files.FileMoveResponse -import com.imagekit.api.models.files.FileRenameParams -import com.imagekit.api.models.files.FileRenameResponse -import com.imagekit.api.models.files.FileUpdateParams -import com.imagekit.api.models.files.FileUpdateResponse -import com.imagekit.api.models.files.FileUploadParams -import com.imagekit.api.models.files.FileUploadResponse -import com.imagekit.api.services.blocking.files.BulkService -import com.imagekit.api.services.blocking.files.MetadataService -import com.imagekit.api.services.blocking.files.VersionService +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.files.File +import io.imagekit.io.models.files.FileCopyParams +import io.imagekit.io.models.files.FileCopyResponse +import io.imagekit.io.models.files.FileDeleteParams +import io.imagekit.io.models.files.FileGetParams +import io.imagekit.io.models.files.FileMoveParams +import io.imagekit.io.models.files.FileMoveResponse +import io.imagekit.io.models.files.FileRenameParams +import io.imagekit.io.models.files.FileRenameResponse +import io.imagekit.io.models.files.FileUpdateParams +import io.imagekit.io.models.files.FileUpdateResponse +import io.imagekit.io.models.files.FileUploadParams +import io.imagekit.io.models.files.FileUploadResponse +import io.imagekit.io.services.blocking.files.BulkService +import io.imagekit.io.services.blocking.files.MetadataService +import io.imagekit.io.services.blocking.files.VersionService import java.util.function.Consumer interface FileService { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FileServiceImpl.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FileServiceImpl.kt index 790f4b66..d61f3bc6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FileServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FileServiceImpl.kt @@ -1,42 +1,42 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.handlers.emptyHandler -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.json -import com.imagekit.api.core.http.multipartFormData -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepare -import com.imagekit.api.models.files.File -import com.imagekit.api.models.files.FileCopyParams -import com.imagekit.api.models.files.FileCopyResponse -import com.imagekit.api.models.files.FileDeleteParams -import com.imagekit.api.models.files.FileGetParams -import com.imagekit.api.models.files.FileMoveParams -import com.imagekit.api.models.files.FileMoveResponse -import com.imagekit.api.models.files.FileRenameParams -import com.imagekit.api.models.files.FileRenameResponse -import com.imagekit.api.models.files.FileUpdateParams -import com.imagekit.api.models.files.FileUpdateResponse -import com.imagekit.api.models.files.FileUploadParams -import com.imagekit.api.models.files.FileUploadResponse -import com.imagekit.api.services.blocking.files.BulkService -import com.imagekit.api.services.blocking.files.BulkServiceImpl -import com.imagekit.api.services.blocking.files.MetadataService -import com.imagekit.api.services.blocking.files.MetadataServiceImpl -import com.imagekit.api.services.blocking.files.VersionService -import com.imagekit.api.services.blocking.files.VersionServiceImpl +package io.imagekit.io.services.blocking + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.handlers.emptyHandler +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.json +import io.imagekit.io.core.http.multipartFormData +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepare +import io.imagekit.io.models.files.File +import io.imagekit.io.models.files.FileCopyParams +import io.imagekit.io.models.files.FileCopyResponse +import io.imagekit.io.models.files.FileDeleteParams +import io.imagekit.io.models.files.FileGetParams +import io.imagekit.io.models.files.FileMoveParams +import io.imagekit.io.models.files.FileMoveResponse +import io.imagekit.io.models.files.FileRenameParams +import io.imagekit.io.models.files.FileRenameResponse +import io.imagekit.io.models.files.FileUpdateParams +import io.imagekit.io.models.files.FileUpdateResponse +import io.imagekit.io.models.files.FileUploadParams +import io.imagekit.io.models.files.FileUploadResponse +import io.imagekit.io.services.blocking.files.BulkService +import io.imagekit.io.services.blocking.files.BulkServiceImpl +import io.imagekit.io.services.blocking.files.MetadataService +import io.imagekit.io.services.blocking.files.MetadataServiceImpl +import io.imagekit.io.services.blocking.files.VersionService +import io.imagekit.io.services.blocking.files.VersionServiceImpl import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FolderService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FolderService.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FolderService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FolderService.kt index e38020e4..622a1439 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FolderService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FolderService.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking +package io.imagekit.io.services.blocking import com.google.errorprone.annotations.MustBeClosed -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.folders.FolderCopyParams -import com.imagekit.api.models.folders.FolderCopyResponse -import com.imagekit.api.models.folders.FolderCreateParams -import com.imagekit.api.models.folders.FolderCreateResponse -import com.imagekit.api.models.folders.FolderDeleteParams -import com.imagekit.api.models.folders.FolderDeleteResponse -import com.imagekit.api.models.folders.FolderMoveParams -import com.imagekit.api.models.folders.FolderMoveResponse -import com.imagekit.api.models.folders.FolderRenameParams -import com.imagekit.api.models.folders.FolderRenameResponse -import com.imagekit.api.services.blocking.folders.JobService +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.folders.FolderCopyParams +import io.imagekit.io.models.folders.FolderCopyResponse +import io.imagekit.io.models.folders.FolderCreateParams +import io.imagekit.io.models.folders.FolderCreateResponse +import io.imagekit.io.models.folders.FolderDeleteParams +import io.imagekit.io.models.folders.FolderDeleteResponse +import io.imagekit.io.models.folders.FolderMoveParams +import io.imagekit.io.models.folders.FolderMoveResponse +import io.imagekit.io.models.folders.FolderRenameParams +import io.imagekit.io.models.folders.FolderRenameResponse +import io.imagekit.io.services.blocking.folders.JobService import java.util.function.Consumer interface FolderService { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FolderServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FolderServiceImpl.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FolderServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FolderServiceImpl.kt index 42a20bf2..95bb5888 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/FolderServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FolderServiceImpl.kt @@ -1,32 +1,32 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.json -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepare -import com.imagekit.api.models.folders.FolderCopyParams -import com.imagekit.api.models.folders.FolderCopyResponse -import com.imagekit.api.models.folders.FolderCreateParams -import com.imagekit.api.models.folders.FolderCreateResponse -import com.imagekit.api.models.folders.FolderDeleteParams -import com.imagekit.api.models.folders.FolderDeleteResponse -import com.imagekit.api.models.folders.FolderMoveParams -import com.imagekit.api.models.folders.FolderMoveResponse -import com.imagekit.api.models.folders.FolderRenameParams -import com.imagekit.api.models.folders.FolderRenameResponse -import com.imagekit.api.services.blocking.folders.JobService -import com.imagekit.api.services.blocking.folders.JobServiceImpl +package io.imagekit.io.services.blocking + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.json +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepare +import io.imagekit.io.models.folders.FolderCopyParams +import io.imagekit.io.models.folders.FolderCopyResponse +import io.imagekit.io.models.folders.FolderCreateParams +import io.imagekit.io.models.folders.FolderCreateResponse +import io.imagekit.io.models.folders.FolderDeleteParams +import io.imagekit.io.models.folders.FolderDeleteResponse +import io.imagekit.io.models.folders.FolderMoveParams +import io.imagekit.io.models.folders.FolderMoveResponse +import io.imagekit.io.models.folders.FolderRenameParams +import io.imagekit.io.models.folders.FolderRenameResponse +import io.imagekit.io.services.blocking.folders.JobService +import io.imagekit.io.services.blocking.folders.JobServiceImpl import java.util.function.Consumer class FolderServiceImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/SavedExtensionService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/SavedExtensionService.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/SavedExtensionService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/SavedExtensionService.kt index 8121edf1..547729b0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/SavedExtensionService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/SavedExtensionService.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking +package io.imagekit.io.services.blocking import com.google.errorprone.annotations.MustBeClosed -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.SavedExtension -import com.imagekit.api.models.savedextensions.SavedExtensionCreateParams -import com.imagekit.api.models.savedextensions.SavedExtensionDeleteParams -import com.imagekit.api.models.savedextensions.SavedExtensionGetParams -import com.imagekit.api.models.savedextensions.SavedExtensionListParams -import com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.SavedExtension +import io.imagekit.io.models.savedextensions.SavedExtensionCreateParams +import io.imagekit.io.models.savedextensions.SavedExtensionDeleteParams +import io.imagekit.io.models.savedextensions.SavedExtensionGetParams +import io.imagekit.io.models.savedextensions.SavedExtensionListParams +import io.imagekit.io.models.savedextensions.SavedExtensionUpdateParams import java.util.function.Consumer interface SavedExtensionService { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/SavedExtensionServiceImpl.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/SavedExtensionServiceImpl.kt index c1eed28e..cba546e4 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/SavedExtensionServiceImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.handlers.emptyHandler -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.json -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepare -import com.imagekit.api.models.SavedExtension -import com.imagekit.api.models.savedextensions.SavedExtensionCreateParams -import com.imagekit.api.models.savedextensions.SavedExtensionDeleteParams -import com.imagekit.api.models.savedextensions.SavedExtensionGetParams -import com.imagekit.api.models.savedextensions.SavedExtensionListParams -import com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams +package io.imagekit.io.services.blocking + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.handlers.emptyHandler +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.json +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepare +import io.imagekit.io.models.SavedExtension +import io.imagekit.io.models.savedextensions.SavedExtensionCreateParams +import io.imagekit.io.models.savedextensions.SavedExtensionDeleteParams +import io.imagekit.io.models.savedextensions.SavedExtensionGetParams +import io.imagekit.io.models.savedextensions.SavedExtensionListParams +import io.imagekit.io.models.savedextensions.SavedExtensionUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/WebhookService.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/WebhookService.kt index fbbfb89b..e5f4a90b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/WebhookService.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.UnwrapWebhookParams -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.errors.ImageKitWebhookException -import com.imagekit.api.models.webhooks.UnsafeUnwrapWebhookEvent -import com.imagekit.api.models.webhooks.UnwrapWebhookEvent +package io.imagekit.io.services.blocking + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.UnwrapWebhookParams +import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.io.errors.ImageKitWebhookException +import io.imagekit.io.models.webhooks.UnsafeUnwrapWebhookEvent +import io.imagekit.io.models.webhooks.UnwrapWebhookEvent import java.util.function.Consumer interface WebhookService { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/WebhookServiceImpl.kt similarity index 100% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/WebhookServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/WebhookServiceImpl.kt diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/OriginService.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/OriginService.kt index 4cbab138..472063d6 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/OriginService.kt @@ -1,19 +1,19 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.accounts +package io.imagekit.io.services.blocking.accounts import com.google.errorprone.annotations.MustBeClosed -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.accounts.origins.OriginCreateParams -import com.imagekit.api.models.accounts.origins.OriginDeleteParams -import com.imagekit.api.models.accounts.origins.OriginGetParams -import com.imagekit.api.models.accounts.origins.OriginListParams -import com.imagekit.api.models.accounts.origins.OriginRequest -import com.imagekit.api.models.accounts.origins.OriginResponse -import com.imagekit.api.models.accounts.origins.OriginUpdateParams +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.accounts.origins.OriginCreateParams +import io.imagekit.io.models.accounts.origins.OriginDeleteParams +import io.imagekit.io.models.accounts.origins.OriginGetParams +import io.imagekit.io.models.accounts.origins.OriginListParams +import io.imagekit.io.models.accounts.origins.OriginRequest +import io.imagekit.io.models.accounts.origins.OriginResponse +import io.imagekit.io.models.accounts.origins.OriginUpdateParams import java.util.function.Consumer interface OriginService { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/OriginServiceImpl.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/OriginServiceImpl.kt index bbbd6358..1ca54627 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/OriginServiceImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.accounts - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.handlers.emptyHandler -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.json -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepare -import com.imagekit.api.models.accounts.origins.OriginCreateParams -import com.imagekit.api.models.accounts.origins.OriginDeleteParams -import com.imagekit.api.models.accounts.origins.OriginGetParams -import com.imagekit.api.models.accounts.origins.OriginListParams -import com.imagekit.api.models.accounts.origins.OriginResponse -import com.imagekit.api.models.accounts.origins.OriginUpdateParams +package io.imagekit.io.services.blocking.accounts + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.handlers.emptyHandler +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.json +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepare +import io.imagekit.io.models.accounts.origins.OriginCreateParams +import io.imagekit.io.models.accounts.origins.OriginDeleteParams +import io.imagekit.io.models.accounts.origins.OriginGetParams +import io.imagekit.io.models.accounts.origins.OriginListParams +import io.imagekit.io.models.accounts.origins.OriginResponse +import io.imagekit.io.models.accounts.origins.OriginUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UrlEndpointService.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UrlEndpointService.kt index 567a037d..a42045a4 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UrlEndpointService.kt @@ -1,19 +1,19 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.accounts +package io.imagekit.io.services.blocking.accounts import com.google.errorprone.annotations.MustBeClosed -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointCreateParams +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointDeleteParams +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointGetParams +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointListParams +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointRequest +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointResponse +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointUpdateParams import java.util.function.Consumer interface UrlEndpointService { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UrlEndpointServiceImpl.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UrlEndpointServiceImpl.kt index 5d2e17e0..bdf11794 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UrlEndpointServiceImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.accounts - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.handlers.emptyHandler -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.json -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepare -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +package io.imagekit.io.services.blocking.accounts + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.handlers.emptyHandler +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.json +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepare +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointCreateParams +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointDeleteParams +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointGetParams +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointListParams +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointResponse +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UsageService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UsageService.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UsageService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UsageService.kt index 5cdcc94c..20971463 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UsageService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UsageService.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.accounts +package io.imagekit.io.services.blocking.accounts import com.google.errorprone.annotations.MustBeClosed -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.accounts.usage.UsageGetParams -import com.imagekit.api.models.accounts.usage.UsageGetResponse +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.accounts.usage.UsageGetParams +import io.imagekit.io.models.accounts.usage.UsageGetResponse import java.util.function.Consumer interface UsageService { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UsageServiceImpl.kt similarity index 76% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UsageServiceImpl.kt index e9884d20..14dc4a17 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UsageServiceImpl.kt @@ -1,21 +1,21 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.accounts +package io.imagekit.io.services.blocking.accounts -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepare -import com.imagekit.api.models.accounts.usage.UsageGetParams -import com.imagekit.api.models.accounts.usage.UsageGetResponse +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepare +import io.imagekit.io.models.accounts.usage.UsageGetParams +import io.imagekit.io.models.accounts.usage.UsageGetResponse import java.util.function.Consumer class UsageServiceImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/V2Service.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/V2Service.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/V2Service.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/V2Service.kt index 9452e843..6a5a814b 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/V2Service.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/V2Service.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.beta +package io.imagekit.io.services.blocking.beta -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.services.blocking.beta.v2.FileService +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.services.blocking.beta.v2.FileService import java.util.function.Consumer interface V2Service { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/V2ServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/V2ServiceImpl.kt similarity index 85% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/V2ServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/V2ServiceImpl.kt index 43beea32..328ed26c 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/V2ServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/V2ServiceImpl.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.beta +package io.imagekit.io.services.blocking.beta -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.services.blocking.beta.v2.FileService -import com.imagekit.api.services.blocking.beta.v2.FileServiceImpl +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.services.blocking.beta.v2.FileService +import io.imagekit.io.services.blocking.beta.v2.FileServiceImpl import java.util.function.Consumer class V2ServiceImpl internal constructor(private val clientOptions: ClientOptions) : V2Service { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/v2/FileService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/v2/FileService.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/v2/FileService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/v2/FileService.kt index 5f365a33..770891ef 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/v2/FileService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/v2/FileService.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.beta.v2 +package io.imagekit.io.services.blocking.beta.v2 import com.google.errorprone.annotations.MustBeClosed -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.beta.v2.files.FileUploadParams -import com.imagekit.api.models.beta.v2.files.FileUploadResponse +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.beta.v2.files.FileUploadParams +import io.imagekit.io.models.beta.v2.files.FileUploadResponse import java.util.function.Consumer interface FileService { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/v2/FileServiceImpl.kt similarity index 77% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/v2/FileServiceImpl.kt index 17203aee..e0f1a46f 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/v2/FileServiceImpl.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.beta.v2 +package io.imagekit.io.services.blocking.beta.v2 -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.multipartFormData -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepare -import com.imagekit.api.models.beta.v2.files.FileUploadParams -import com.imagekit.api.models.beta.v2.files.FileUploadResponse +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.multipartFormData +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepare +import io.imagekit.io.models.beta.v2.files.FileUploadParams +import io.imagekit.io.models.beta.v2.files.FileUploadResponse import java.util.function.Consumer class FileServiceImpl internal constructor(private val clientOptions: ClientOptions) : FileService { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/cache/InvalidationService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/cache/InvalidationService.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/cache/InvalidationService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/cache/InvalidationService.kt index 4a5bd1e0..b4f056ed 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/cache/InvalidationService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/cache/InvalidationService.kt @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.cache +package io.imagekit.io.services.blocking.cache import com.google.errorprone.annotations.MustBeClosed -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.cache.invalidation.InvalidationCreateParams -import com.imagekit.api.models.cache.invalidation.InvalidationCreateResponse -import com.imagekit.api.models.cache.invalidation.InvalidationGetParams -import com.imagekit.api.models.cache.invalidation.InvalidationGetResponse +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.cache.invalidation.InvalidationCreateParams +import io.imagekit.io.models.cache.invalidation.InvalidationCreateResponse +import io.imagekit.io.models.cache.invalidation.InvalidationGetParams +import io.imagekit.io.models.cache.invalidation.InvalidationGetResponse import java.util.function.Consumer interface InvalidationService { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/cache/InvalidationServiceImpl.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/cache/InvalidationServiceImpl.kt index 72aee8db..999460ec 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/cache/InvalidationServiceImpl.kt @@ -1,25 +1,25 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.cache +package io.imagekit.io.services.blocking.cache -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.json -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepare -import com.imagekit.api.models.cache.invalidation.InvalidationCreateParams -import com.imagekit.api.models.cache.invalidation.InvalidationCreateResponse -import com.imagekit.api.models.cache.invalidation.InvalidationGetParams -import com.imagekit.api.models.cache.invalidation.InvalidationGetResponse +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.json +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepare +import io.imagekit.io.models.cache.invalidation.InvalidationCreateParams +import io.imagekit.io.models.cache.invalidation.InvalidationCreateResponse +import io.imagekit.io.models.cache.invalidation.InvalidationGetParams +import io.imagekit.io.models.cache.invalidation.InvalidationGetResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BulkService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/BulkService.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BulkService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/BulkService.kt index dbc0c409..6282d37d 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BulkService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/BulkService.kt @@ -1,19 +1,19 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.files +package io.imagekit.io.services.blocking.files import com.google.errorprone.annotations.MustBeClosed -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.files.bulk.BulkAddTagsParams -import com.imagekit.api.models.files.bulk.BulkAddTagsResponse -import com.imagekit.api.models.files.bulk.BulkDeleteParams -import com.imagekit.api.models.files.bulk.BulkDeleteResponse -import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams -import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse -import com.imagekit.api.models.files.bulk.BulkRemoveTagsParams -import com.imagekit.api.models.files.bulk.BulkRemoveTagsResponse +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.files.bulk.BulkAddTagsParams +import io.imagekit.io.models.files.bulk.BulkAddTagsResponse +import io.imagekit.io.models.files.bulk.BulkDeleteParams +import io.imagekit.io.models.files.bulk.BulkDeleteResponse +import io.imagekit.io.models.files.bulk.BulkRemoveAiTagsParams +import io.imagekit.io.models.files.bulk.BulkRemoveAiTagsResponse +import io.imagekit.io.models.files.bulk.BulkRemoveTagsParams +import io.imagekit.io.models.files.bulk.BulkRemoveTagsResponse import java.util.function.Consumer interface BulkService { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BulkServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/BulkServiceImpl.kt similarity index 85% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BulkServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/BulkServiceImpl.kt index 537b3912..876406f0 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/BulkServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/BulkServiceImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.files - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.json -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepare -import com.imagekit.api.models.files.bulk.BulkAddTagsParams -import com.imagekit.api.models.files.bulk.BulkAddTagsResponse -import com.imagekit.api.models.files.bulk.BulkDeleteParams -import com.imagekit.api.models.files.bulk.BulkDeleteResponse -import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams -import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse -import com.imagekit.api.models.files.bulk.BulkRemoveTagsParams -import com.imagekit.api.models.files.bulk.BulkRemoveTagsResponse +package io.imagekit.io.services.blocking.files + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.json +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepare +import io.imagekit.io.models.files.bulk.BulkAddTagsParams +import io.imagekit.io.models.files.bulk.BulkAddTagsResponse +import io.imagekit.io.models.files.bulk.BulkDeleteParams +import io.imagekit.io.models.files.bulk.BulkDeleteResponse +import io.imagekit.io.models.files.bulk.BulkRemoveAiTagsParams +import io.imagekit.io.models.files.bulk.BulkRemoveAiTagsResponse +import io.imagekit.io.models.files.bulk.BulkRemoveTagsParams +import io.imagekit.io.models.files.bulk.BulkRemoveTagsResponse import java.util.function.Consumer class BulkServiceImpl internal constructor(private val clientOptions: ClientOptions) : BulkService { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/MetadataService.kt similarity index 92% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/MetadataService.kt index 95f9a8e4..33f9a650 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/MetadataService.kt @@ -1,14 +1,14 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.files +package io.imagekit.io.services.blocking.files import com.google.errorprone.annotations.MustBeClosed -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.files.Metadata -import com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams -import com.imagekit.api.models.files.metadata.MetadataGetParams +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.files.Metadata +import io.imagekit.io.models.files.metadata.MetadataGetFromUrlParams +import io.imagekit.io.models.files.metadata.MetadataGetParams import java.util.function.Consumer interface MetadataService { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/MetadataServiceImpl.kt similarity index 82% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/MetadataServiceImpl.kt index f5ea7bb7..a37178c2 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/MetadataServiceImpl.kt @@ -1,23 +1,23 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.files +package io.imagekit.io.services.blocking.files -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepare -import com.imagekit.api.models.files.Metadata -import com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams -import com.imagekit.api.models.files.metadata.MetadataGetParams +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepare +import io.imagekit.io.models.files.Metadata +import io.imagekit.io.models.files.metadata.MetadataGetFromUrlParams +import io.imagekit.io.models.files.metadata.MetadataGetParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/VersionService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/VersionService.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/VersionService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/VersionService.kt index eb1195eb..36eeb6ac 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/VersionService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/VersionService.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.files +package io.imagekit.io.services.blocking.files import com.google.errorprone.annotations.MustBeClosed -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.files.File -import com.imagekit.api.models.files.versions.VersionDeleteParams -import com.imagekit.api.models.files.versions.VersionDeleteResponse -import com.imagekit.api.models.files.versions.VersionGetParams -import com.imagekit.api.models.files.versions.VersionListParams -import com.imagekit.api.models.files.versions.VersionRestoreParams +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.files.File +import io.imagekit.io.models.files.versions.VersionDeleteParams +import io.imagekit.io.models.files.versions.VersionDeleteResponse +import io.imagekit.io.models.files.versions.VersionGetParams +import io.imagekit.io.models.files.versions.VersionListParams +import io.imagekit.io.models.files.versions.VersionRestoreParams import java.util.function.Consumer interface VersionService { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/VersionServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/VersionServiceImpl.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/VersionServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/VersionServiceImpl.kt index 2637882f..cc821536 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/files/VersionServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/VersionServiceImpl.kt @@ -1,27 +1,27 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.files - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.json -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepare -import com.imagekit.api.models.files.File -import com.imagekit.api.models.files.versions.VersionDeleteParams -import com.imagekit.api.models.files.versions.VersionDeleteResponse -import com.imagekit.api.models.files.versions.VersionGetParams -import com.imagekit.api.models.files.versions.VersionListParams -import com.imagekit.api.models.files.versions.VersionRestoreParams +package io.imagekit.io.services.blocking.files + +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.json +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepare +import io.imagekit.io.models.files.File +import io.imagekit.io.models.files.versions.VersionDeleteParams +import io.imagekit.io.models.files.versions.VersionDeleteResponse +import io.imagekit.io.models.files.versions.VersionGetParams +import io.imagekit.io.models.files.versions.VersionListParams +import io.imagekit.io.models.files.versions.VersionRestoreParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/folders/JobService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/folders/JobService.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/folders/JobService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/folders/JobService.kt index e40fbfb6..58150fb1 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/folders/JobService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/folders/JobService.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.folders +package io.imagekit.io.services.blocking.folders import com.google.errorprone.annotations.MustBeClosed -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.models.folders.job.JobGetParams -import com.imagekit.api.models.folders.job.JobGetResponse +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.models.folders.job.JobGetParams +import io.imagekit.io.models.folders.job.JobGetResponse import java.util.function.Consumer interface JobService { diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/folders/JobServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/folders/JobServiceImpl.kt similarity index 77% rename from image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/folders/JobServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/folders/JobServiceImpl.kt index 8be9b5af..2cf38510 100644 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/services/blocking/folders/JobServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/folders/JobServiceImpl.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.folders +package io.imagekit.io.services.blocking.folders -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.handlers.errorBodyHandler -import com.imagekit.api.core.handlers.errorHandler -import com.imagekit.api.core.handlers.jsonHandler -import com.imagekit.api.core.http.HttpMethod -import com.imagekit.api.core.http.HttpRequest -import com.imagekit.api.core.http.HttpResponse -import com.imagekit.api.core.http.HttpResponse.Handler -import com.imagekit.api.core.http.HttpResponseFor -import com.imagekit.api.core.http.parseable -import com.imagekit.api.core.prepare -import com.imagekit.api.models.folders.job.JobGetParams -import com.imagekit.api.models.folders.job.JobGetResponse +import io.imagekit.io.core.ClientOptions +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.checkRequired +import io.imagekit.io.core.handlers.errorBodyHandler +import io.imagekit.io.core.handlers.errorHandler +import io.imagekit.io.core.handlers.jsonHandler +import io.imagekit.io.core.http.HttpMethod +import io.imagekit.io.core.http.HttpRequest +import io.imagekit.io.core.http.HttpResponse +import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.io.core.http.HttpResponseFor +import io.imagekit.io.core.http.parseable +import io.imagekit.io.core.prepare +import io.imagekit.io.models.folders.job.JobGetParams +import io.imagekit.io.models.folders.job.JobGetResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro b/image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro index dedf4950..f94dc567 100644 --- a/image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro +++ b/image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro @@ -22,11 +22,11 @@ -keep class * extends com.fasterxml.jackson.core.type.TypeReference { *; } # Jackson uses reflection to access our class serializers and deserializers. --keep @com.fasterxml.jackson.databind.annotation.JsonSerialize class com.imagekit.api.** { *; } --keep @com.fasterxml.jackson.databind.annotation.JsonDeserialize class com.imagekit.api.** { *; } +-keep @com.fasterxml.jackson.databind.annotation.JsonSerialize class io.imagekit.io.** { *; } +-keep @com.fasterxml.jackson.databind.annotation.JsonDeserialize class io.imagekit.io.** { *; } # Jackson uses reflection to serialize and deserialize our classes based on their constructors and annotated members. --keepclassmembers class com.imagekit.api.** { +-keepclassmembers class io.imagekit.io.** { (...); @com.fasterxml.jackson.annotation.* *; } \ No newline at end of file diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/ClientOptionsTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/core/ClientOptionsTest.kt index 323aed25..52212fa4 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ClientOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/ClientOptionsTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.core +package io.imagekit.io.core -import com.imagekit.api.core.http.HttpClient +import io.imagekit.io.core.http.HttpClient import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ObjectMappersTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/ObjectMappersTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ObjectMappersTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/core/ObjectMappersTest.kt index 4f6d8c5e..d08718a9 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ObjectMappersTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/ObjectMappersTest.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.core +package io.imagekit.io.core import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.exc.MismatchedInputException diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/PhantomReachableTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/PhantomReachableTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/core/PhantomReachableTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/core/PhantomReachableTest.kt index 8e35e81d..1148b526 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/PhantomReachableTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/PhantomReachableTest.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.core +package io.imagekit.io.core import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/UtilsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/UtilsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/core/UtilsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/core/UtilsTest.kt index 1da50cf8..506aee57 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/UtilsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/UtilsTest.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.core +package io.imagekit.io.core import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ValuesTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/ValuesTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ValuesTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/core/ValuesTest.kt index e044d52d..0d5b0d83 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/ValuesTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/ValuesTest.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.core +package io.imagekit.io.core import java.util.Optional import org.assertj.core.api.Assertions.assertThat diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/AsyncStreamResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/AsyncStreamResponseTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/AsyncStreamResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/AsyncStreamResponseTest.kt index bb36e9b2..ae33c213 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/AsyncStreamResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/AsyncStreamResponseTest.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.core.http +package io.imagekit.io.core.http import java.util.* import java.util.concurrent.CompletableFuture diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/HeadersTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/HeadersTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/HeadersTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/HeadersTest.kt index af17ead3..543dc978 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/HeadersTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/HeadersTest.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.core.http +package io.imagekit.io.core.http import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.params.ParameterizedTest diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/HttpRequestBodiesTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/HttpRequestBodiesTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/HttpRequestBodiesTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/HttpRequestBodiesTest.kt index 40f188f6..abfa9342 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/HttpRequestBodiesTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/HttpRequestBodiesTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.core.http +package io.imagekit.io.core.http -import com.imagekit.api.core.MultipartField -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.MultipartField +import io.imagekit.io.core.jsonMapper import java.io.ByteArrayOutputStream import java.io.InputStream import org.assertj.core.api.Assertions.assertThat diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/HttpRequestTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/HttpRequestTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/HttpRequestTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/HttpRequestTest.kt index dec0c7ad..9a0900df 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/HttpRequestTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/HttpRequestTest.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.core.http +package io.imagekit.io.core.http import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.params.ParameterizedTest diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/QueryParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/QueryParamsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/QueryParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/QueryParamsTest.kt index 87748918..aa7fe114 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/QueryParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/QueryParamsTest.kt @@ -1,4 +1,4 @@ -package com.imagekit.api.core.http +package io.imagekit.io.core.http import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.params.ParameterizedTest diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/RetryingHttpClientTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/RetryingHttpClientTest.kt index 3d2a391c..68463a03 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/core/http/RetryingHttpClientTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/RetryingHttpClientTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.core.http +package io.imagekit.io.core.http import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.matching @@ -15,10 +15,10 @@ import com.github.tomakehurst.wiremock.client.WireMock.verify import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.github.tomakehurst.wiremock.stubbing.Scenario -import com.imagekit.api.client.okhttp.OkHttpClient -import com.imagekit.api.core.RequestOptions -import com.imagekit.api.core.Sleeper -import com.imagekit.api.errors.ImageKitRetryableException +import io.imagekit.io.client.okhttp.OkHttpClient +import io.imagekit.io.core.RequestOptions +import io.imagekit.io.core.Sleeper +import io.imagekit.io.errors.ImageKitRetryableException import java.io.InputStream import java.time.Clock import java.time.Duration diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AiTagTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/AiTagTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AiTagTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/AiTagTest.kt index 3d673cad..8d41108c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/AiTagTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/AiTagTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/BaseOverlayTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/BaseOverlayTest.kt index 4955f427..3cfb1f4c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/BaseOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/BaseOverlayTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/CustomMetadataTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/CustomMetadataTest.kt similarity index 88% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/CustomMetadataTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/CustomMetadataTest.kt index 4b26a678..b90d9dea 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/CustomMetadataTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/CustomMetadataTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/EmbeddedMetadataTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/EmbeddedMetadataTest.kt similarity index 89% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/EmbeddedMetadataTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/EmbeddedMetadataTest.kt index b6ae79a4..fc859110 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/EmbeddedMetadataTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/EmbeddedMetadataTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExtensionConfigTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ExtensionConfigTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExtensionConfigTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ExtensionConfigTest.kt index 9d548b34..0deb4df3 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExtensionConfigTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ExtensionConfigTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper +import io.imagekit.io.errors.ImageKitInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExtensionItemTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ExtensionItemTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExtensionItemTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ExtensionItemTest.kt index 00fdcc83..f45dc441 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ExtensionItemTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ExtensionItemTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper +import io.imagekit.io.errors.ImageKitInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/GetImageAttributesOptionsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/GetImageAttributesOptionsTest.kt index dc36825f..2b5c3afe 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/GetImageAttributesOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/GetImageAttributesOptionsTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ImageOverlayTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ImageOverlayTest.kt index 75e60ec0..c904e328 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ImageOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ImageOverlayTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayPositionTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/OverlayPositionTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayPositionTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/OverlayPositionTest.kt index 3d474c62..3c7a15e5 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayPositionTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/OverlayPositionTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/OverlayTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/OverlayTest.kt index d244bc3b..ba1322af 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/OverlayTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper +import io.imagekit.io.errors.ImageKitInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTimingTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/OverlayTimingTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTimingTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/OverlayTimingTest.kt index b31c4ea4..feb5042e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/OverlayTimingTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/OverlayTimingTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ResponsiveImageAttributesTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ResponsiveImageAttributesTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ResponsiveImageAttributesTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ResponsiveImageAttributesTest.kt index e6429aae..884b12fe 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/ResponsiveImageAttributesTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ResponsiveImageAttributesTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SavedExtensionTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SavedExtensionTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SavedExtensionTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SavedExtensionTest.kt index 8b19dcd2..7edc6515 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SavedExtensionTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SavedExtensionTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SelectedFieldsSchemaTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SelectedFieldsSchemaTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SelectedFieldsSchemaTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SelectedFieldsSchemaTest.kt index b3939645..5bd98100 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SelectedFieldsSchemaTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SelectedFieldsSchemaTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SolidColorOverlayTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SolidColorOverlayTest.kt index fb8980b0..13d14139 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SolidColorOverlayTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTransformationTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SolidColorOverlayTransformationTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTransformationTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SolidColorOverlayTransformationTest.kt index ad8ef85a..bea6fd98 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SolidColorOverlayTransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SolidColorOverlayTransformationTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SrcOptionsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SrcOptionsTest.kt index 47f231d1..4572a0cc 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SrcOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SrcOptionsTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SubtitleOverlayTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SubtitleOverlayTest.kt index be605a48..a0bf7f54 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SubtitleOverlayTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTransformationTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SubtitleOverlayTransformationTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTransformationTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SubtitleOverlayTransformationTest.kt index 1fcf8c66..f6d681d4 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/SubtitleOverlayTransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SubtitleOverlayTransformationTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/TextOverlayTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/TextOverlayTest.kt index 65a652f3..0299dff9 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/TextOverlayTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTransformationTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/TextOverlayTransformationTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTransformationTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/TextOverlayTransformationTest.kt index 00f631fd..6a3de249 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TextOverlayTransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/TextOverlayTransformationTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/TransformationTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/TransformationTest.kt index 1b468cd5..526f81fb 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/TransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/TransformationTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VersionInfoTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/VersionInfoTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VersionInfoTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/VersionInfoTest.kt index 23ca3a57..6ce80b1f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VersionInfoTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/VersionInfoTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/VideoOverlayTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/VideoOverlayTest.kt index 840d8b42..0790f5d1 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/VideoOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/VideoOverlayTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models +package io.imagekit.io.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginCreateParamsTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginCreateParamsTest.kt index 7c03cc60..c1f8a46b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginCreateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.origins +package io.imagekit.io.models.accounts.origins import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginDeleteParamsTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginDeleteParamsTest.kt index ef9d5f33..4321d287 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.origins +package io.imagekit.io.models.accounts.origins import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginGetParamsTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginGetParamsTest.kt index e029b05d..e70383e3 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.origins +package io.imagekit.io.models.accounts.origins import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginListParamsTest.kt similarity index 81% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginListParamsTest.kt index 4a9eb551..217de8e2 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginListParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginListParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.origins +package io.imagekit.io.models.accounts.origins import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginRequestTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginRequestTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginRequestTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginRequestTest.kt index 74f88fc9..4eaa9959 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginRequestTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginRequestTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.origins +package io.imagekit.io.models.accounts.origins import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper +import io.imagekit.io.errors.ImageKitInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginResponseTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginResponseTest.kt index da0a3935..6f5a4be8 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginResponseTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.origins +package io.imagekit.io.models.accounts.origins import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper -import com.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper +import io.imagekit.io.errors.ImageKitInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginUpdateParamsTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginUpdateParamsTest.kt index d90d8ccb..b89c4a43 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/origins/OriginUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginUpdateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.origins +package io.imagekit.io.models.accounts.origins import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt index 93293ea4..ba15bb19 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.urlendpoints +package io.imagekit.io.models.accounts.urlendpoints import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt similarity index 90% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt index 180ae83e..3cf5132a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.urlendpoints +package io.imagekit.io.models.accounts.urlendpoints import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt similarity index 90% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt index 83851559..c2f390a4 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.urlendpoints +package io.imagekit.io.models.accounts.urlendpoints import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt similarity index 80% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt index 0aa9b747..fa41afa5 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.urlendpoints +package io.imagekit.io.models.accounts.urlendpoints import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequestTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointRequestTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequestTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointRequestTest.kt index 7c2de876..9c186088 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequestTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointRequestTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.urlendpoints +package io.imagekit.io.models.accounts.urlendpoints import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointResponseTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointResponseTest.kt index fa5854c1..86ca85f1 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.urlendpoints +package io.imagekit.io.models.accounts.urlendpoints import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt index 434647b2..c2116918 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.urlendpoints +package io.imagekit.io.models.accounts.urlendpoints import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/usage/UsageGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/usage/UsageGetParamsTest.kt similarity index 90% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/usage/UsageGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/usage/UsageGetParamsTest.kt index 260fb488..11cf8c51 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/usage/UsageGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/usage/UsageGetParamsTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.usage +package io.imagekit.io.models.accounts.usage -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.http.QueryParams import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/usage/UsageGetResponseTest.kt similarity index 94% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/usage/UsageGetResponseTest.kt index c0b5123a..5ba5017f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/accounts/usage/UsageGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/usage/UsageGetResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.accounts.usage +package io.imagekit.io.models.accounts.usage import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/assets/AssetListParamsTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/assets/AssetListParamsTest.kt index 711b9e12..b45d1521 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/assets/AssetListParamsTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.assets +package io.imagekit.io.models.assets -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/assets/AssetListResponseTest.kt similarity index 94% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/assets/AssetListResponseTest.kt index 6e6f20fb..ffa4a350 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/assets/AssetListResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/assets/AssetListResponseTest.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.assets +package io.imagekit.io.models.assets import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.AiTag -import com.imagekit.api.models.CustomMetadata -import com.imagekit.api.models.EmbeddedMetadata -import com.imagekit.api.models.SelectedFieldsSchema -import com.imagekit.api.models.VersionInfo -import com.imagekit.api.models.files.File -import com.imagekit.api.models.files.Folder +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper +import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.io.models.AiTag +import io.imagekit.io.models.CustomMetadata +import io.imagekit.io.models.EmbeddedMetadata +import io.imagekit.io.models.SelectedFieldsSchema +import io.imagekit.io.models.VersionInfo +import io.imagekit.io.models.files.File +import io.imagekit.io.models.files.Folder import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadParamsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadParamsTest.kt index 4233c7ea..dc784d3b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadParamsTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.beta.v2.files +package io.imagekit.io.models.beta.v2.files -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.MultipartField -import com.imagekit.api.models.ExtensionItem +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.MultipartField +import io.imagekit.io.models.ExtensionItem import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadResponseTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadResponseTest.kt index ef3b62e3..54fcf523 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadResponseTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.beta.v2.files +package io.imagekit.io.models.beta.v2.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper -import com.imagekit.api.models.AiTag -import com.imagekit.api.models.CustomMetadata -import com.imagekit.api.models.EmbeddedMetadata -import com.imagekit.api.models.SelectedFieldsSchema -import com.imagekit.api.models.VersionInfo -import com.imagekit.api.models.files.Metadata +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper +import io.imagekit.io.models.AiTag +import io.imagekit.io.models.CustomMetadata +import io.imagekit.io.models.EmbeddedMetadata +import io.imagekit.io.models.SelectedFieldsSchema +import io.imagekit.io.models.VersionInfo +import io.imagekit.io.models.files.Metadata import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateParamsTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateParamsTest.kt index 94ef7b2c..5985e173 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.cache.invalidation +package io.imagekit.io.models.cache.invalidation import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateResponseTest.kt index 70da7c09..b9f3b0b1 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationCreateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.cache.invalidation +package io.imagekit.io.models.cache.invalidation import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetParamsTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetParamsTest.kt index 452b8982..64536930 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.cache.invalidation +package io.imagekit.io.models.cache.invalidation import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetResponseTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetResponseTest.kt index 0bcd4825..aafff5de 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/cache/invalidation/InvalidationGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.cache.invalidation +package io.imagekit.io.models.cache.invalidation import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt index fd1a70d5..a1fffc99 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.custommetadatafields +package io.imagekit.io.models.custommetadatafields import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt index 1ce51ef0..9bbe742a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.custommetadatafields +package io.imagekit.io.models.custommetadatafields import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt index 3f1974cd..95be91f3 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.custommetadatafields +package io.imagekit.io.models.custommetadatafields import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt index 395d54c2..951751c3 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.custommetadatafields +package io.imagekit.io.models.custommetadatafields -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldTest.kt index 6deccd53..10c24701 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.custommetadatafields +package io.imagekit.io.models.custommetadatafields import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt index 54c3e400..04d86784 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.custommetadatafields +package io.imagekit.io.models.custommetadatafields import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileCopyParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileCopyParamsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileCopyParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileCopyParamsTest.kt index f6e8ba6d..91936d72 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileCopyParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileCopyParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileCopyResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileCopyResponseTest.kt similarity index 90% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileCopyResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileCopyResponseTest.kt index 24b46ab7..79835523 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileCopyResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileCopyResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileDeleteParamsTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileDeleteParamsTest.kt index ec09e31f..d2f4ab1f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileGetParamsTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileGetParamsTest.kt index 633e0e5e..2cd9973a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileMoveParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileMoveParamsTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileMoveParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileMoveParamsTest.kt index f0cc0dc1..b687d6c0 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileMoveParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileMoveParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileMoveResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileMoveResponseTest.kt similarity index 90% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileMoveResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileMoveResponseTest.kt index d8560b52..830fc567 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileMoveResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileMoveResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRenameParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileRenameParamsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRenameParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileRenameParamsTest.kt index cd3b78c5..976d292a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRenameParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileRenameParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRenameResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileRenameResponseTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRenameResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileRenameResponseTest.kt index 79e2867b..c5765cb3 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileRenameResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileRenameResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileTest.kt index 90586c91..7e3a2a9d 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileTest.kt @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper -import com.imagekit.api.models.AiTag -import com.imagekit.api.models.CustomMetadata -import com.imagekit.api.models.EmbeddedMetadata -import com.imagekit.api.models.SelectedFieldsSchema -import com.imagekit.api.models.VersionInfo +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper +import io.imagekit.io.models.AiTag +import io.imagekit.io.models.CustomMetadata +import io.imagekit.io.models.EmbeddedMetadata +import io.imagekit.io.models.SelectedFieldsSchema +import io.imagekit.io.models.VersionInfo import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUpdateParamsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUpdateParamsTest.kt index 8e7beb45..dd092af9 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUpdateParamsTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files -import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.ExtensionItem +import io.imagekit.io.core.JsonValue +import io.imagekit.io.models.ExtensionItem import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUpdateResponseTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUpdateResponseTest.kt index 26932192..f517aa9b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUpdateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUpdateResponseTest.kt @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper -import com.imagekit.api.models.AiTag -import com.imagekit.api.models.CustomMetadata -import com.imagekit.api.models.EmbeddedMetadata -import com.imagekit.api.models.SelectedFieldsSchema -import com.imagekit.api.models.VersionInfo +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper +import io.imagekit.io.models.AiTag +import io.imagekit.io.models.CustomMetadata +import io.imagekit.io.models.EmbeddedMetadata +import io.imagekit.io.models.SelectedFieldsSchema +import io.imagekit.io.models.VersionInfo import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUploadParamsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUploadParamsTest.kt index 2e9a3412..455a5d08 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUploadParamsTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.MultipartField -import com.imagekit.api.models.ExtensionItem +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.MultipartField +import io.imagekit.io.models.ExtensionItem import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUploadResponseTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUploadResponseTest.kt index e3847af3..dc11488f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FileUploadResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUploadResponseTest.kt @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper -import com.imagekit.api.models.AiTag -import com.imagekit.api.models.CustomMetadata -import com.imagekit.api.models.EmbeddedMetadata -import com.imagekit.api.models.SelectedFieldsSchema -import com.imagekit.api.models.VersionInfo +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper +import io.imagekit.io.models.AiTag +import io.imagekit.io.models.CustomMetadata +import io.imagekit.io.models.EmbeddedMetadata +import io.imagekit.io.models.SelectedFieldsSchema +import io.imagekit.io.models.VersionInfo import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FolderTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FolderTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FolderTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FolderTest.kt index 71de26a4..6611842f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/FolderTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FolderTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/MetadataTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/MetadataTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/MetadataTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/MetadataTest.kt index c1387776..175fb2fe 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/MetadataTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/MetadataTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/UpdateFileRequestTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/UpdateFileRequestTest.kt index 51cdf7d7..9e2487b2 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/UpdateFileRequestTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/UpdateFileRequestTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.io.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.ExtensionItem +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper +import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.io.models.ExtensionItem import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsParamsTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsParamsTest.kt index e4f87508..a1f947ba 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.bulk +package io.imagekit.io.models.files.bulk import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsResponseTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsResponseTest.kt index 78d57ab9..50015a65 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkAddTagsResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.bulk +package io.imagekit.io.models.files.bulk import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteParamsTest.kt similarity index 94% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteParamsTest.kt index c7ff4764..8d349e22 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.bulk +package io.imagekit.io.models.files.bulk import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteResponseTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteResponseTest.kt index f0b7a28f..17f1e33c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkDeleteResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.bulk +package io.imagekit.io.models.files.bulk import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsParamsTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsParamsTest.kt index 21a08ec7..61cccec8 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.bulk +package io.imagekit.io.models.files.bulk import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsResponseTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsResponseTest.kt index f4831008..3b21ad1b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.bulk +package io.imagekit.io.models.files.bulk import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsParamsTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsParamsTest.kt index 0f1de44e..2b013171 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.bulk +package io.imagekit.io.models.files.bulk import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsResponseTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsResponseTest.kt index ce354384..342d3b18 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/bulk/BulkRemoveTagsResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.bulk +package io.imagekit.io.models.files.bulk import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/metadata/MetadataGetFromUrlParamsTest.kt similarity index 86% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/metadata/MetadataGetFromUrlParamsTest.kt index 2d4617b6..0c55f38c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetFromUrlParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/metadata/MetadataGetFromUrlParamsTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.metadata +package io.imagekit.io.models.files.metadata -import com.imagekit.api.core.http.QueryParams +import io.imagekit.io.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/metadata/MetadataGetParamsTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/metadata/MetadataGetParamsTest.kt index 566257d5..86103156 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/metadata/MetadataGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/metadata/MetadataGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.metadata +package io.imagekit.io.models.files.metadata import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionDeleteParamsTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionDeleteParamsTest.kt index 67e06b93..887722b4 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.versions +package io.imagekit.io.models.files.versions import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionDeleteResponseTest.kt similarity index 90% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionDeleteResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionDeleteResponseTest.kt index c6c6c196..7e5b9695 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionDeleteResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionDeleteResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.versions +package io.imagekit.io.models.files.versions import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionGetParamsTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionGetParamsTest.kt index 223c3985..8af9ee86 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.versions +package io.imagekit.io.models.files.versions import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionListParamsTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionListParamsTest.kt index 76dcfa05..8cc12253 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionListParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionListParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.versions +package io.imagekit.io.models.files.versions import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRestoreParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionRestoreParamsTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRestoreParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionRestoreParamsTest.kt index cb877ca2..77ffad32 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/files/versions/VersionRestoreParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionRestoreParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files.versions +package io.imagekit.io.models.files.versions import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCopyParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCopyParamsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCopyParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCopyParamsTest.kt index 2592d7ab..4491d0eb 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCopyParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCopyParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders +package io.imagekit.io.models.folders import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCopyResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCopyResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCopyResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCopyResponseTest.kt index 43edd665..4f564393 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCopyResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCopyResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders +package io.imagekit.io.models.folders import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCreateParamsTest.kt similarity index 94% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCreateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCreateParamsTest.kt index 7f8ba557..ce179e30 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCreateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders +package io.imagekit.io.models.folders import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCreateResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCreateResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCreateResponseTest.kt index de873d35..4ec5480a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderCreateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCreateResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders +package io.imagekit.io.models.folders import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderDeleteParamsTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderDeleteParamsTest.kt index 7a1a4fca..74c7bd80 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders +package io.imagekit.io.models.folders import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderDeleteResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderDeleteResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderDeleteResponseTest.kt index 332055e2..a837f6b6 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderDeleteResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderDeleteResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders +package io.imagekit.io.models.folders import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderMoveParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderMoveParamsTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderMoveParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderMoveParamsTest.kt index 7df75c01..99662e39 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderMoveParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderMoveParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders +package io.imagekit.io.models.folders import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderMoveResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderMoveResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderMoveResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderMoveResponseTest.kt index c0bbe474..6f655902 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderMoveResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderMoveResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders +package io.imagekit.io.models.folders import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderRenameParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderRenameParamsTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderRenameParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderRenameParamsTest.kt index 46e46772..55a09138 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderRenameParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderRenameParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders +package io.imagekit.io.models.folders import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderRenameResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderRenameResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderRenameResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderRenameResponseTest.kt index 73535f74..2a29c34a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/FolderRenameResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderRenameResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders +package io.imagekit.io.models.folders import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/job/JobGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/job/JobGetParamsTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/job/JobGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/job/JobGetParamsTest.kt index 0128480f..c69ea598 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/job/JobGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/job/JobGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders.job +package io.imagekit.io.models.folders.job import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/job/JobGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/job/JobGetResponseTest.kt similarity index 94% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/job/JobGetResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/job/JobGetResponseTest.kt index 502bf546..8f382df3 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/folders/job/JobGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/job/JobGetResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.folders.job +package io.imagekit.io.models.folders.job import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionCreateParamsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionCreateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionCreateParamsTest.kt index 2f40bb6c..6783b54b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionCreateParamsTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.savedextensions +package io.imagekit.io.models.savedextensions -import com.imagekit.api.models.ExtensionConfig +import io.imagekit.io.models.ExtensionConfig import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionDeleteParamsTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionDeleteParamsTest.kt index dbe6b570..2e50c2bf 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.savedextensions +package io.imagekit.io.models.savedextensions import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionGetParamsTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionGetParamsTest.kt index da2a95b1..06926a16 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.savedextensions +package io.imagekit.io.models.savedextensions import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionListParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionListParamsTest.kt similarity index 82% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionListParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionListParamsTest.kt index ed9def38..92510888 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionListParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionListParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.savedextensions +package io.imagekit.io.models.savedextensions import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionUpdateParamsTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionUpdateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionUpdateParamsTest.kt index 66429daf..899b1378 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/savedextensions/SavedExtensionUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionUpdateParamsTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.savedextensions +package io.imagekit.io.models.savedextensions -import com.imagekit.api.models.ExtensionConfig +import io.imagekit.io.models.ExtensionConfig import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/BaseWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/BaseWebhookEventTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/BaseWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/BaseWebhookEventTest.kt index 577eb730..ae01b4ce 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/BaseWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/BaseWebhookEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileCreateEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileCreateEventTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileCreateEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileCreateEventTest.kt index 0a490898..67088d14 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileCreateEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileCreateEventTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper -import com.imagekit.api.models.AiTag -import com.imagekit.api.models.CustomMetadata -import com.imagekit.api.models.EmbeddedMetadata -import com.imagekit.api.models.SelectedFieldsSchema -import com.imagekit.api.models.VersionInfo -import com.imagekit.api.models.files.File +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper +import io.imagekit.io.models.AiTag +import io.imagekit.io.models.CustomMetadata +import io.imagekit.io.models.EmbeddedMetadata +import io.imagekit.io.models.SelectedFieldsSchema +import io.imagekit.io.models.VersionInfo +import io.imagekit.io.models.files.File import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileDeleteEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileDeleteEventTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileDeleteEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileDeleteEventTest.kt index 01ba34cd..39e045de 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileDeleteEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileDeleteEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileUpdateEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileUpdateEventTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileUpdateEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileUpdateEventTest.kt index c736ed41..1dcd6a4b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileUpdateEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileUpdateEventTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper -import com.imagekit.api.models.AiTag -import com.imagekit.api.models.CustomMetadata -import com.imagekit.api.models.EmbeddedMetadata -import com.imagekit.api.models.SelectedFieldsSchema -import com.imagekit.api.models.VersionInfo -import com.imagekit.api.models.files.File +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper +import io.imagekit.io.models.AiTag +import io.imagekit.io.models.CustomMetadata +import io.imagekit.io.models.EmbeddedMetadata +import io.imagekit.io.models.SelectedFieldsSchema +import io.imagekit.io.models.VersionInfo +import io.imagekit.io.models.files.File import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionCreateEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileVersionCreateEventTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionCreateEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileVersionCreateEventTest.kt index 38ed6986..03339f56 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionCreateEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileVersionCreateEventTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper -import com.imagekit.api.models.AiTag -import com.imagekit.api.models.CustomMetadata -import com.imagekit.api.models.EmbeddedMetadata -import com.imagekit.api.models.SelectedFieldsSchema -import com.imagekit.api.models.VersionInfo -import com.imagekit.api.models.files.File +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper +import io.imagekit.io.models.AiTag +import io.imagekit.io.models.CustomMetadata +import io.imagekit.io.models.EmbeddedMetadata +import io.imagekit.io.models.SelectedFieldsSchema +import io.imagekit.io.models.VersionInfo +import io.imagekit.io.models.files.File import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionDeleteEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileVersionDeleteEventTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionDeleteEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileVersionDeleteEventTest.kt index 07077d96..777a43e3 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/FileVersionDeleteEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileVersionDeleteEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UnsafeUnwrapWebhookEventTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UnsafeUnwrapWebhookEventTest.kt index d6343d92..4056774b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UnsafeUnwrapWebhookEventTest.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.AiTag -import com.imagekit.api.models.CustomMetadata -import com.imagekit.api.models.EmbeddedMetadata -import com.imagekit.api.models.SelectedFieldsSchema -import com.imagekit.api.models.VersionInfo -import com.imagekit.api.models.files.File -import com.imagekit.api.models.files.Metadata +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper +import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.io.models.AiTag +import io.imagekit.io.models.CustomMetadata +import io.imagekit.io.models.EmbeddedMetadata +import io.imagekit.io.models.SelectedFieldsSchema +import io.imagekit.io.models.VersionInfo +import io.imagekit.io.models.files.File +import io.imagekit.io.models.files.Metadata import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UnwrapWebhookEventTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UnwrapWebhookEventTest.kt index cda13726..5bd9f63f 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UnwrapWebhookEventTest.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.AiTag -import com.imagekit.api.models.CustomMetadata -import com.imagekit.api.models.EmbeddedMetadata -import com.imagekit.api.models.SelectedFieldsSchema -import com.imagekit.api.models.VersionInfo -import com.imagekit.api.models.files.File -import com.imagekit.api.models.files.Metadata +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper +import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.io.models.AiTag +import io.imagekit.io.models.CustomMetadata +import io.imagekit.io.models.EmbeddedMetadata +import io.imagekit.io.models.SelectedFieldsSchema +import io.imagekit.io.models.VersionInfo +import io.imagekit.io.models.files.File +import io.imagekit.io.models.files.Metadata import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformErrorEventTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformErrorEventTest.kt index ce99a9c9..c8cc37d4 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformErrorEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformErrorEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformSuccessEventTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformSuccessEventTest.kt index ded4c114..f566c2bc 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPostTransformSuccessEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformSuccessEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformErrorEventTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformErrorEventTest.kt index e02922a7..3b4b8331 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformErrorEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformErrorEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformSuccessEventTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformSuccessEventTest.kt index f44367c8..93fb59f3 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformSuccessEventTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper -import com.imagekit.api.models.AiTag -import com.imagekit.api.models.CustomMetadata -import com.imagekit.api.models.EmbeddedMetadata -import com.imagekit.api.models.SelectedFieldsSchema -import com.imagekit.api.models.VersionInfo -import com.imagekit.api.models.files.Metadata +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper +import io.imagekit.io.models.AiTag +import io.imagekit.io.models.CustomMetadata +import io.imagekit.io.models.EmbeddedMetadata +import io.imagekit.io.models.SelectedFieldsSchema +import io.imagekit.io.models.VersionInfo +import io.imagekit.io.models.files.Metadata import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/VideoTransformationAcceptedEventTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/VideoTransformationAcceptedEventTest.kt index 3ae8d593..c401f219 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/VideoTransformationAcceptedEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/VideoTransformationErrorEventTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/VideoTransformationErrorEventTest.kt index f03c9e27..c62eefaf 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/VideoTransformationErrorEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/VideoTransformationReadyEventTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/VideoTransformationReadyEventTest.kt index a65e2a16..f6802ba0 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/VideoTransformationReadyEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.webhooks +package io.imagekit.io.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.jsonMapper +import io.imagekit.io.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/ErrorHandlingTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/ErrorHandlingTest.kt index 6d1b06d4..c93ab931 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ErrorHandlingTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/ErrorHandlingTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services +package io.imagekit.io.services import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.post @@ -8,22 +8,22 @@ import com.github.tomakehurst.wiremock.client.WireMock.status import com.github.tomakehurst.wiremock.client.WireMock.stubFor import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest -import com.imagekit.api.client.ImageKitClient -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.jsonMapper -import com.imagekit.api.errors.BadRequestException -import com.imagekit.api.errors.ImageKitException -import com.imagekit.api.errors.InternalServerException -import com.imagekit.api.errors.NotFoundException -import com.imagekit.api.errors.PermissionDeniedException -import com.imagekit.api.errors.RateLimitException -import com.imagekit.api.errors.UnauthorizedException -import com.imagekit.api.errors.UnexpectedStatusCodeException -import com.imagekit.api.errors.UnprocessableEntityException -import com.imagekit.api.models.ExtensionItem -import com.imagekit.api.models.files.FileUploadParams +import io.imagekit.io.client.ImageKitClient +import io.imagekit.io.client.okhttp.ImageKitOkHttpClient +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.http.Headers +import io.imagekit.io.core.jsonMapper +import io.imagekit.io.errors.BadRequestException +import io.imagekit.io.errors.ImageKitException +import io.imagekit.io.errors.InternalServerException +import io.imagekit.io.errors.NotFoundException +import io.imagekit.io.errors.PermissionDeniedException +import io.imagekit.io.errors.RateLimitException +import io.imagekit.io.errors.UnauthorizedException +import io.imagekit.io.errors.UnexpectedStatusCodeException +import io.imagekit.io.errors.UnprocessableEntityException +import io.imagekit.io.models.ExtensionItem +import io.imagekit.io.models.files.FileUploadParams import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.entry import org.junit.jupiter.api.BeforeEach diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/ServiceParamsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/ServiceParamsTest.kt index 26f11219..cf80a8c6 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/ServiceParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services +package io.imagekit.io.services import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.equalTo @@ -12,11 +12,11 @@ import com.github.tomakehurst.wiremock.client.WireMock.stubFor import com.github.tomakehurst.wiremock.client.WireMock.verify import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest -import com.imagekit.api.client.ImageKitClient -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.ExtensionItem -import com.imagekit.api.models.files.FileUploadParams +import io.imagekit.io.client.ImageKitClient +import io.imagekit.io.client.okhttp.ImageKitOkHttpClient +import io.imagekit.io.core.JsonValue +import io.imagekit.io.models.ExtensionItem +import io.imagekit.io.models.files.FileUploadParams import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/AssetServiceAsyncTest.kt similarity index 86% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/AssetServiceAsyncTest.kt index e7a3e05a..4f7c43d7 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/AssetServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/AssetServiceAsyncTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async +package io.imagekit.io.services.async -import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import com.imagekit.api.models.assets.AssetListParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.io.models.assets.AssetListParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/CustomMetadataFieldServiceAsyncTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/CustomMetadataFieldServiceAsyncTest.kt index b9ff7128..e64ec208 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/CustomMetadataFieldServiceAsyncTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async +package io.imagekit.io.services.async -import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldCreateParams +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldListParams +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/FileServiceAsyncTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/FileServiceAsyncTest.kt index e36a222e..becb09e5 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/FileServiceAsyncTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async +package io.imagekit.io.services.async -import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.ExtensionItem -import com.imagekit.api.models.files.FileCopyParams -import com.imagekit.api.models.files.FileMoveParams -import com.imagekit.api.models.files.FileRenameParams -import com.imagekit.api.models.files.FileUpdateParams -import com.imagekit.api.models.files.FileUploadParams -import com.imagekit.api.models.files.UpdateFileRequest +import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.io.core.JsonValue +import io.imagekit.io.models.ExtensionItem +import io.imagekit.io.models.files.FileCopyParams +import io.imagekit.io.models.files.FileMoveParams +import io.imagekit.io.models.files.FileRenameParams +import io.imagekit.io.models.files.FileUpdateParams +import io.imagekit.io.models.files.FileUploadParams +import io.imagekit.io.models.files.UpdateFileRequest import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/FolderServiceAsyncTest.kt similarity index 89% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/FolderServiceAsyncTest.kt index 5d9e7f7b..c8b10d81 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/FolderServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/FolderServiceAsyncTest.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async - -import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import com.imagekit.api.models.folders.FolderCopyParams -import com.imagekit.api.models.folders.FolderCreateParams -import com.imagekit.api.models.folders.FolderDeleteParams -import com.imagekit.api.models.folders.FolderMoveParams -import com.imagekit.api.models.folders.FolderRenameParams +package io.imagekit.io.services.async + +import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.io.models.folders.FolderCopyParams +import io.imagekit.io.models.folders.FolderCreateParams +import io.imagekit.io.models.folders.FolderDeleteParams +import io.imagekit.io.models.folders.FolderMoveParams +import io.imagekit.io.models.folders.FolderRenameParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/SavedExtensionServiceAsyncTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/SavedExtensionServiceAsyncTest.kt index 60099607..793956a8 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/SavedExtensionServiceAsyncTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async +package io.imagekit.io.services.async -import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import com.imagekit.api.models.ExtensionConfig -import com.imagekit.api.models.savedextensions.SavedExtensionCreateParams -import com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.io.models.ExtensionConfig +import io.imagekit.io.models.savedextensions.SavedExtensionCreateParams +import io.imagekit.io.models.savedextensions.SavedExtensionUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/WebhookServiceAsyncTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/WebhookServiceAsyncTest.kt index 1b7f1056..2186b5e9 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/WebhookServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/WebhookServiceAsyncTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async +package io.imagekit.io.services.async -import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import com.imagekit.api.core.UnwrapWebhookParams -import com.imagekit.api.core.http.Headers -import com.imagekit.api.errors.ImageKitWebhookException import com.standardwebhooks.Webhook +import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.io.core.UnwrapWebhookParams +import io.imagekit.io.core.http.Headers +import io.imagekit.io.errors.ImageKitWebhookException import java.time.Instant import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/accounts/OriginServiceAsyncTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/accounts/OriginServiceAsyncTest.kt index 85eaf6b8..5cfbcfb3 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/accounts/OriginServiceAsyncTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.accounts +package io.imagekit.io.services.async.accounts -import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import com.imagekit.api.models.accounts.origins.OriginRequest -import com.imagekit.api.models.accounts.origins.OriginUpdateParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.io.models.accounts.origins.OriginRequest +import io.imagekit.io.models.accounts.origins.OriginUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/accounts/UrlEndpointServiceAsyncTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/accounts/UrlEndpointServiceAsyncTest.kt index b5a0bbb1..4006a00e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/accounts/UrlEndpointServiceAsyncTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.accounts +package io.imagekit.io.services.async.accounts -import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointRequest +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/accounts/UsageServiceAsyncTest.kt similarity index 82% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/accounts/UsageServiceAsyncTest.kt index 1ff7697b..cff198a7 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/accounts/UsageServiceAsyncTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.accounts +package io.imagekit.io.services.async.accounts -import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import com.imagekit.api.models.accounts.usage.UsageGetParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.io.models.accounts.usage.UsageGetParams import java.time.LocalDate import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/beta/v2/FileServiceAsyncTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/beta/v2/FileServiceAsyncTest.kt index e6332630..6f202fa6 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/beta/v2/FileServiceAsyncTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.beta.v2 +package io.imagekit.io.services.async.beta.v2 -import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.ExtensionItem -import com.imagekit.api.models.beta.v2.files.FileUploadParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.io.core.JsonValue +import io.imagekit.io.models.ExtensionItem +import io.imagekit.io.models.beta.v2.files.FileUploadParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/cache/InvalidationServiceAsyncTest.kt similarity index 87% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/cache/InvalidationServiceAsyncTest.kt index 373cbd39..99164f5c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/cache/InvalidationServiceAsyncTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.cache +package io.imagekit.io.services.async.cache -import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import com.imagekit.api.models.cache.invalidation.InvalidationCreateParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.io.models.cache.invalidation.InvalidationCreateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/files/BulkServiceAsyncTest.kt similarity index 89% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/files/BulkServiceAsyncTest.kt index f4726319..4b91cff5 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/BulkServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/files/BulkServiceAsyncTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.files +package io.imagekit.io.services.async.files -import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import com.imagekit.api.models.files.bulk.BulkAddTagsParams -import com.imagekit.api.models.files.bulk.BulkDeleteParams -import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams -import com.imagekit.api.models.files.bulk.BulkRemoveTagsParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.io.models.files.bulk.BulkAddTagsParams +import io.imagekit.io.models.files.bulk.BulkDeleteParams +import io.imagekit.io.models.files.bulk.BulkRemoveAiTagsParams +import io.imagekit.io.models.files.bulk.BulkRemoveTagsParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/files/MetadataServiceAsyncTest.kt similarity index 87% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/files/MetadataServiceAsyncTest.kt index a60fc3c3..d4cce619 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/files/MetadataServiceAsyncTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.files +package io.imagekit.io.services.async.files -import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.io.models.files.metadata.MetadataGetFromUrlParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/files/VersionServiceAsyncTest.kt similarity index 88% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/files/VersionServiceAsyncTest.kt index 4774b045..110dc254 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/files/VersionServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/files/VersionServiceAsyncTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.files +package io.imagekit.io.services.async.files -import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import com.imagekit.api.models.files.versions.VersionDeleteParams -import com.imagekit.api.models.files.versions.VersionGetParams -import com.imagekit.api.models.files.versions.VersionRestoreParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.io.models.files.versions.VersionDeleteParams +import io.imagekit.io.models.files.versions.VersionGetParams +import io.imagekit.io.models.files.versions.VersionRestoreParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/folders/JobServiceAsyncTest.kt similarity index 84% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/folders/JobServiceAsyncTest.kt index 0013515c..c14501b0 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/async/folders/JobServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/folders/JobServiceAsyncTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.async.folders +package io.imagekit.io.services.async.folders -import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/AssetServiceTest.kt similarity index 86% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/AssetServiceTest.kt index 8e46580b..aa848f0a 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/AssetServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/AssetServiceTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking +package io.imagekit.io.services.blocking -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.models.assets.AssetListParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClient +import io.imagekit.io.models.assets.AssetListParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/CustomMetadataFieldServiceTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/CustomMetadataFieldServiceTest.kt index 095789a4..133962b2 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/CustomMetadataFieldServiceTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking +package io.imagekit.io.services.blocking -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams -import com.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClient +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldCreateParams +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldListParams +import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/FileServiceTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/FileServiceTest.kt index e21ee937..68183268 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/FileServiceTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking +package io.imagekit.io.services.blocking -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.ExtensionItem -import com.imagekit.api.models.files.FileCopyParams -import com.imagekit.api.models.files.FileMoveParams -import com.imagekit.api.models.files.FileRenameParams -import com.imagekit.api.models.files.FileUpdateParams -import com.imagekit.api.models.files.FileUploadParams -import com.imagekit.api.models.files.UpdateFileRequest +import io.imagekit.io.client.okhttp.ImageKitOkHttpClient +import io.imagekit.io.core.JsonValue +import io.imagekit.io.models.ExtensionItem +import io.imagekit.io.models.files.FileCopyParams +import io.imagekit.io.models.files.FileMoveParams +import io.imagekit.io.models.files.FileRenameParams +import io.imagekit.io.models.files.FileUpdateParams +import io.imagekit.io.models.files.FileUploadParams +import io.imagekit.io.models.files.UpdateFileRequest import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/FolderServiceTest.kt similarity index 88% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/FolderServiceTest.kt index 6b2960a6..7185ffbb 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/FolderServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/FolderServiceTest.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking - -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.models.folders.FolderCopyParams -import com.imagekit.api.models.folders.FolderCreateParams -import com.imagekit.api.models.folders.FolderDeleteParams -import com.imagekit.api.models.folders.FolderMoveParams -import com.imagekit.api.models.folders.FolderRenameParams +package io.imagekit.io.services.blocking + +import io.imagekit.io.client.okhttp.ImageKitOkHttpClient +import io.imagekit.io.models.folders.FolderCopyParams +import io.imagekit.io.models.folders.FolderCreateParams +import io.imagekit.io.models.folders.FolderDeleteParams +import io.imagekit.io.models.folders.FolderMoveParams +import io.imagekit.io.models.folders.FolderRenameParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/SavedExtensionServiceTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/SavedExtensionServiceTest.kt index fdc452d2..b09656a6 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/SavedExtensionServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/SavedExtensionServiceTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking +package io.imagekit.io.services.blocking -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.models.ExtensionConfig -import com.imagekit.api.models.savedextensions.SavedExtensionCreateParams -import com.imagekit.api.models.savedextensions.SavedExtensionUpdateParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClient +import io.imagekit.io.models.ExtensionConfig +import io.imagekit.io.models.savedextensions.SavedExtensionCreateParams +import io.imagekit.io.models.savedextensions.SavedExtensionUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/WebhookServiceTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/WebhookServiceTest.kt index c8c85d90..962b28df 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/WebhookServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/WebhookServiceTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking +package io.imagekit.io.services.blocking -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.core.UnwrapWebhookParams -import com.imagekit.api.core.http.Headers -import com.imagekit.api.errors.ImageKitWebhookException import com.standardwebhooks.Webhook +import io.imagekit.io.client.okhttp.ImageKitOkHttpClient +import io.imagekit.io.core.UnwrapWebhookParams +import io.imagekit.io.core.http.Headers +import io.imagekit.io.errors.ImageKitWebhookException import java.time.Instant import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/accounts/OriginServiceTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/accounts/OriginServiceTest.kt index 9ce07bc5..a251974c 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/OriginServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/accounts/OriginServiceTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.accounts +package io.imagekit.io.services.blocking.accounts -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.models.accounts.origins.OriginRequest -import com.imagekit.api.models.accounts.origins.OriginUpdateParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClient +import io.imagekit.io.models.accounts.origins.OriginRequest +import io.imagekit.io.models.accounts.origins.OriginUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/accounts/UrlEndpointServiceTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/accounts/UrlEndpointServiceTest.kt index b0970249..46626d87 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/accounts/UrlEndpointServiceTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.accounts +package io.imagekit.io.services.blocking.accounts -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest -import com.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClient +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointRequest +import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/accounts/UsageServiceTest.kt similarity index 82% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/accounts/UsageServiceTest.kt index 74cf58ed..2157d5cc 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/accounts/UsageServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/accounts/UsageServiceTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.accounts +package io.imagekit.io.services.blocking.accounts -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.models.accounts.usage.UsageGetParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClient +import io.imagekit.io.models.accounts.usage.UsageGetParams import java.time.LocalDate import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/beta/v2/FileServiceTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/beta/v2/FileServiceTest.kt index 0870287b..e34c88d9 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/beta/v2/FileServiceTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.beta.v2 +package io.imagekit.io.services.blocking.beta.v2 -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.ExtensionItem -import com.imagekit.api.models.beta.v2.files.FileUploadParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClient +import io.imagekit.io.core.JsonValue +import io.imagekit.io.models.ExtensionItem +import io.imagekit.io.models.beta.v2.files.FileUploadParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/cache/InvalidationServiceTest.kt similarity index 86% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/cache/InvalidationServiceTest.kt index 9d0a4b88..7109694b 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/cache/InvalidationServiceTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.cache +package io.imagekit.io.services.blocking.cache -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.models.cache.invalidation.InvalidationCreateParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClient +import io.imagekit.io.models.cache.invalidation.InvalidationCreateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/files/BulkServiceTest.kt similarity index 88% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/files/BulkServiceTest.kt index 4c5321e0..3d45028e 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/BulkServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/files/BulkServiceTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.files +package io.imagekit.io.services.blocking.files -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.models.files.bulk.BulkAddTagsParams -import com.imagekit.api.models.files.bulk.BulkDeleteParams -import com.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams -import com.imagekit.api.models.files.bulk.BulkRemoveTagsParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClient +import io.imagekit.io.models.files.bulk.BulkAddTagsParams +import io.imagekit.io.models.files.bulk.BulkDeleteParams +import io.imagekit.io.models.files.bulk.BulkRemoveAiTagsParams +import io.imagekit.io.models.files.bulk.BulkRemoveTagsParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/files/MetadataServiceTest.kt similarity index 85% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/files/MetadataServiceTest.kt index 3c5e115f..2a42cb3d 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/MetadataServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/files/MetadataServiceTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.files +package io.imagekit.io.services.blocking.files -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.models.files.metadata.MetadataGetFromUrlParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClient +import io.imagekit.io.models.files.metadata.MetadataGetFromUrlParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/files/VersionServiceTest.kt similarity index 87% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/files/VersionServiceTest.kt index 383718f3..dfbc6c03 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/files/VersionServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/files/VersionServiceTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.files +package io.imagekit.io.services.blocking.files -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.models.files.versions.VersionDeleteParams -import com.imagekit.api.models.files.versions.VersionGetParams -import com.imagekit.api.models.files.versions.VersionRestoreParams +import io.imagekit.io.client.okhttp.ImageKitOkHttpClient +import io.imagekit.io.models.files.versions.VersionDeleteParams +import io.imagekit.io.models.files.versions.VersionGetParams +import io.imagekit.io.models.files.versions.VersionRestoreParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/folders/JobServiceTest.kt similarity index 82% rename from image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/folders/JobServiceTest.kt index fe1ac070..22c86a55 100644 --- a/image-kit-java-core/src/test/kotlin/com/imagekit/api/services/blocking/folders/JobServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/folders/JobServiceTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking.folders +package io.imagekit.io.services.blocking.folders -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient +import io.imagekit.io.client.okhttp.ImageKitOkHttpClient import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-proguard-test/build.gradle.kts b/image-kit-java-proguard-test/build.gradle.kts index 13025755..a921f20a 100644 --- a/image-kit-java-proguard-test/build.gradle.kts +++ b/image-kit-java-proguard-test/build.gradle.kts @@ -59,7 +59,7 @@ val testProGuard by tasks.registering(JavaExec::class) { dependsOn(proguardJar) notCompatibleWithConfigurationCache("ProGuard") - mainClass.set("com.imagekit.api.proguard.ProGuardCompatibilityTest") + mainClass.set("io.imagekit.io.proguard.ProGuardCompatibilityTest") classpath = files(proguardJarPath) } @@ -89,7 +89,7 @@ val testR8 by tasks.registering(JavaExec::class) { dependsOn(r8Jar) notCompatibleWithConfigurationCache("R8") - mainClass.set("com.imagekit.api.proguard.ProGuardCompatibilityTest") + mainClass.set("io.imagekit.io.proguard.ProGuardCompatibilityTest") classpath = files(r8JarPath) } diff --git a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt b/image-kit-java-proguard-test/src/test/kotlin/io/imagekit/io/proguard/ProGuardCompatibilityTest.kt similarity index 94% rename from image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt rename to image-kit-java-proguard-test/src/test/kotlin/io/imagekit/io/proguard/ProGuardCompatibilityTest.kt index 8c89a189..5338df20 100644 --- a/image-kit-java-proguard-test/src/test/kotlin/com/imagekit/api/proguard/ProGuardCompatibilityTest.kt +++ b/image-kit-java-proguard-test/src/test/kotlin/io/imagekit/io/proguard/ProGuardCompatibilityTest.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.proguard +package io.imagekit.io.proguard import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.jsonMapper -import com.imagekit.api.models.AiTag -import com.imagekit.api.models.CustomMetadata -import com.imagekit.api.models.EmbeddedMetadata -import com.imagekit.api.models.ExtensionItem -import com.imagekit.api.models.SelectedFieldsSchema -import com.imagekit.api.models.StreamingResolution -import com.imagekit.api.models.VersionInfo -import com.imagekit.api.models.files.File -import com.imagekit.api.models.files.UpdateFileRequest +import io.imagekit.io.client.okhttp.ImageKitOkHttpClient +import io.imagekit.io.core.JsonValue +import io.imagekit.io.core.jsonMapper +import io.imagekit.io.models.AiTag +import io.imagekit.io.models.CustomMetadata +import io.imagekit.io.models.EmbeddedMetadata +import io.imagekit.io.models.ExtensionItem +import io.imagekit.io.models.SelectedFieldsSchema +import io.imagekit.io.models.StreamingResolution +import io.imagekit.io.models.VersionInfo +import io.imagekit.io.models.files.File +import io.imagekit.io.models.files.UpdateFileRequest import java.time.OffsetDateTime import kotlin.reflect.full.memberFunctions import kotlin.reflect.jvm.javaMethod diff --git a/image-kit-java-proguard-test/test.pro b/image-kit-java-proguard-test/test.pro index 64d7928e..dc442971 100644 --- a/image-kit-java-proguard-test/test.pro +++ b/image-kit-java-proguard-test/test.pro @@ -1,5 +1,5 @@ # Specify the entrypoint where ProGuard starts to determine what's reachable. --keep class com.imagekit.api.proguard.** { *; } +-keep class io.imagekit.io.proguard.** { *; } # For the testing framework. -keep class org.junit.** { *; } From ec944a0fafc93f26bc277530738901258e787bb1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 14:09:13 -0400 Subject: [PATCH 139/142] chore: remove custom code --- .gitignore | 4 - .stats.yml | 2 +- README.md | 584 ++---- build.gradle.kts | 2 +- .../src/main/kotlin/image-kit.java.gradle.kts | 2 +- .../main/kotlin/image-kit.kotlin.gradle.kts | 2 +- .../client/okhttp/ImageKitOkHttpClient.kt | 22 +- .../okhttp/ImageKitOkHttpClientAsync.kt | 22 +- .../{io => api}/client/okhttp/OkHttpClient.kt | 22 +- .../client/okhttp/OkHttpClientTest.kt | 6 +- .../kotlin/com/imagekit/api/lib/Helper.kt | 970 ---------- .../com/imagekit/api/lib/HelperService.kt | 26 - .../{io => api}/client/ImageKitClient.kt | 27 +- .../{io => api}/client/ImageKitClientAsync.kt | 27 +- .../client/ImageKitClientAsyncImpl.kt | 50 +- .../{io => api}/client/ImageKitClientImpl.kt | 50 +- .../{io => api}/core/BaseDeserializer.kt | 2 +- .../{io => api}/core/BaseSerializer.kt | 2 +- .../io/imagekit/{io => api}/core/Check.kt | 2 +- .../{io => api}/core/ClientOptions.kt | 16 +- .../{io => api}/core/DefaultSleeper.kt | 2 +- .../{io => api}/core/ObjectMappers.kt | 2 +- .../io/imagekit/{io => api}/core/Params.kt | 6 +- .../{io => api}/core/PhantomReachable.kt | 4 +- .../core/PhantomReachableExecutorService.kt | 2 +- .../core/PhantomReachableSleeper.kt | 2 +- .../{io => api}/core/PrepareRequest.kt | 4 +- .../imagekit/{io => api}/core/Properties.kt | 4 +- .../{io => api}/core/RequestOptions.kt | 2 +- .../io/imagekit/{io => api}/core/Sleeper.kt | 2 +- .../io/imagekit/{io => api}/core/Timeout.kt | 2 +- .../{io => api}/core/UnwrapWebhookParams.kt | 4 +- .../io/imagekit/{io => api}/core/Utils.kt | 4 +- .../io/imagekit/{io => api}/core/Values.kt | 4 +- .../{io => api}/core/handlers/EmptyHandler.kt | 6 +- .../{io => api}/core/handlers/ErrorHandler.kt | 26 +- .../{io => api}/core/handlers/JsonHandler.kt | 8 +- .../core/handlers/StringHandler.kt | 6 +- .../core/http/AsyncStreamResponse.kt | 4 +- .../imagekit/{io => api}/core/http/Headers.kt | 22 +- .../{io => api}/core/http/HttpClient.kt | 4 +- .../{io => api}/core/http/HttpMethod.kt | 2 +- .../{io => api}/core/http/HttpRequest.kt | 6 +- .../core/http/HttpRequestBodies.kt | 8 +- .../{io => api}/core/http/HttpRequestBody.kt | 2 +- .../{io => api}/core/http/HttpResponse.kt | 2 +- .../{io => api}/core/http/HttpResponseFor.kt | 2 +- ...ntomReachableClosingAsyncStreamResponse.kt | 6 +- .../http/PhantomReachableClosingHttpClient.kt | 6 +- .../PhantomReachableClosingStreamResponse.kt | 4 +- .../{io => api}/core/http/QueryParams.kt | 22 +- .../core/http/RetryingHttpClient.kt | 16 +- .../{io => api}/core/http/StreamResponse.kt | 2 +- .../{io => api}/errors/BadRequestException.kt | 8 +- .../{io => api}/errors/ImageKitException.kt | 2 +- .../errors/ImageKitInvalidDataException.kt | 2 +- .../{io => api}/errors/ImageKitIoException.kt | 2 +- .../errors/ImageKitRetryableException.kt | 2 +- .../errors/ImageKitServiceException.kt | 6 +- .../errors/ImageKitWebhookException.kt | 2 +- .../errors/InternalServerException.kt | 8 +- .../{io => api}/errors/NotFoundException.kt | 8 +- .../errors/PermissionDeniedException.kt | 8 +- .../{io => api}/errors/RateLimitException.kt | 8 +- .../errors/UnauthorizedException.kt | 8 +- .../errors/UnexpectedStatusCodeException.kt | 8 +- .../errors/UnprocessableEntityException.kt | 8 +- .../io/imagekit/{io => api}/models/AiTag.kt | 12 +- .../{io => api}/models/BaseOverlay.kt | 14 +- .../{io => api}/models/CustomMetadata.kt | 10 +- .../{io => api}/models/EmbeddedMetadata.kt | 10 +- .../{io => api}/models/ExtensionConfig.kt | 28 +- .../{io => api}/models/ExtensionItem.kt | 28 +- .../models/GetImageAttributesOptions.kt | 18 +- .../{io => api}/models/ImageOverlay.kt | 20 +- .../io/imagekit/{io => api}/models/Overlay.kt | 12 +- .../{io => api}/models/OverlayPosition.kt | 22 +- .../{io => api}/models/OverlayTiming.kt | 20 +- .../models/ResponsiveImageAttributes.kt | 14 +- .../{io => api}/models/SavedExtension.kt | 12 +- .../models/SelectedFieldsSchema.kt | 10 +- .../{io => api}/models/SolidColorOverlay.kt | 18 +- .../models/SolidColorOverlayTransformation.kt | 20 +- .../imagekit/{io => api}/models/SrcOptions.kt | 18 +- .../{io => api}/models/StreamingResolution.kt | 8 +- .../{io => api}/models/SubtitleOverlay.kt | 20 +- .../models/SubtitleOverlayTransformation.kt | 14 +- .../{io => api}/models/TextOverlay.kt | 20 +- .../models/TextOverlayTransformation.kt | 22 +- .../{io => api}/models/Transformation.kt | 26 +- .../models/TransformationPosition.kt | 8 +- .../{io => api}/models/VersionInfo.kt | 12 +- .../{io => api}/models/VideoOverlay.kt | 20 +- .../accounts/origins/OriginCreateParams.kt | 10 +- .../accounts/origins/OriginDeleteParams.kt | 12 +- .../accounts/origins/OriginGetParams.kt | 8 +- .../accounts/origins/OriginListParams.kt | 8 +- .../models/accounts/origins/OriginRequest.kt | 20 +- .../models/accounts/origins/OriginResponse.kt | 20 +- .../accounts/origins/OriginUpdateParams.kt | 10 +- .../urlendpoints/UrlEndpointCreateParams.kt | 12 +- .../urlendpoints/UrlEndpointDeleteParams.kt | 12 +- .../urlendpoints/UrlEndpointGetParams.kt | 8 +- .../urlendpoints/UrlEndpointListParams.kt | 8 +- .../urlendpoints/UrlEndpointRequest.kt | 24 +- .../urlendpoints/UrlEndpointResponse.kt | 24 +- .../urlendpoints/UrlEndpointUpdateParams.kt | 12 +- .../models/accounts/usage/UsageGetParams.kt | 10 +- .../models/accounts/usage/UsageGetResponse.kt | 12 +- .../models/assets/AssetListParams.kt | 14 +- .../models/assets/AssetListResponse.kt | 16 +- .../models/beta/v2/files/FileUploadParams.kt | 74 +- .../beta/v2/files/FileUploadResponse.kt | 30 +- .../invalidation/InvalidationCreateParams.kt | 20 +- .../InvalidationCreateResponse.kt | 12 +- .../invalidation/InvalidationGetParams.kt | 8 +- .../invalidation/InvalidationGetResponse.kt | 14 +- .../CustomMetadataField.kt | 28 +- .../CustomMetadataFieldCreateParams.kt | 34 +- .../CustomMetadataFieldDeleteParams.kt | 12 +- .../CustomMetadataFieldDeleteResponse.kt | 8 +- .../CustomMetadataFieldListParams.kt | 8 +- .../CustomMetadataFieldUpdateParams.kt | 30 +- .../imagekit/{io => api}/models/files/File.kt | 28 +- .../models/files/FileCopyParams.kt | 20 +- .../models/files/FileCopyResponse.kt | 8 +- .../models/files/FileDeleteParams.kt | 12 +- .../{io => api}/models/files/FileGetParams.kt | 8 +- .../models/files/FileMoveParams.kt | 20 +- .../models/files/FileMoveResponse.kt | 8 +- .../models/files/FileRenameParams.kt | 20 +- .../models/files/FileRenameResponse.kt | 12 +- .../models/files/FileUpdateParams.kt | 10 +- .../models/files/FileUpdateResponse.kt | 28 +- .../models/files/FileUploadParams.kt | 74 +- .../models/files/FileUploadResponse.kt | 28 +- .../{io => api}/models/files/Folder.kt | 16 +- .../{io => api}/models/files/Metadata.kt | 16 +- .../models/files/UpdateFileRequest.kt | 28 +- .../models/files/bulk/BulkAddTagsParams.kt | 24 +- .../models/files/bulk/BulkAddTagsResponse.kt | 16 +- .../models/files/bulk/BulkDeleteParams.kt | 24 +- .../models/files/bulk/BulkDeleteResponse.kt | 16 +- .../files/bulk/BulkRemoveAiTagsParams.kt | 24 +- .../files/bulk/BulkRemoveAiTagsResponse.kt | 16 +- .../models/files/bulk/BulkRemoveTagsParams.kt | 24 +- .../files/bulk/BulkRemoveTagsResponse.kt | 16 +- .../metadata/MetadataGetFromUrlParams.kt | 10 +- .../files/metadata/MetadataGetParams.kt | 8 +- .../files/versions/VersionDeleteParams.kt | 16 +- .../files/versions/VersionDeleteResponse.kt | 8 +- .../models/files/versions/VersionGetParams.kt | 10 +- .../files/versions/VersionListParams.kt | 8 +- .../files/versions/VersionRestoreParams.kt | 16 +- .../models/folders/FolderCopyParams.kt | 20 +- .../models/folders/FolderCopyResponse.kt | 14 +- .../models/folders/FolderCreateParams.kt | 20 +- .../models/folders/FolderCreateResponse.kt | 8 +- .../models/folders/FolderDeleteParams.kt | 20 +- .../models/folders/FolderDeleteResponse.kt | 8 +- .../models/folders/FolderMoveParams.kt | 20 +- .../models/folders/FolderMoveResponse.kt | 14 +- .../models/folders/FolderRenameParams.kt | 20 +- .../models/folders/FolderRenameResponse.kt | 14 +- .../models/folders/job/JobGetParams.kt | 8 +- .../models/folders/job/JobGetResponse.kt | 14 +- .../SavedExtensionCreateParams.kt | 22 +- .../SavedExtensionDeleteParams.kt | 12 +- .../SavedExtensionGetParams.kt | 8 +- .../SavedExtensionListParams.kt | 8 +- .../SavedExtensionUpdateParams.kt | 20 +- .../models/webhooks/BaseWebhookEvent.kt | 14 +- .../models/webhooks/FileCreateEvent.kt | 16 +- .../models/webhooks/FileDeleteEvent.kt | 14 +- .../models/webhooks/FileUpdateEvent.kt | 16 +- .../models/webhooks/FileVersionCreateEvent.kt | 16 +- .../models/webhooks/FileVersionDeleteEvent.kt | 14 +- .../webhooks/UnsafeUnwrapWebhookEvent.kt | 14 +- .../models/webhooks/UnwrapWebhookEvent.kt | 14 +- .../webhooks/UploadPostTransformErrorEvent.kt | 16 +- .../UploadPostTransformSuccessEvent.kt | 16 +- .../webhooks/UploadPreTransformErrorEvent.kt | 14 +- .../UploadPreTransformSuccessEvent.kt | 32 +- .../VideoTransformationAcceptedEvent.kt | 20 +- .../webhooks/VideoTransformationErrorEvent.kt | 20 +- .../webhooks/VideoTransformationReadyEvent.kt | 20 +- .../services/async/AccountServiceAsync.kt | 10 +- .../services/async/AccountServiceAsyncImpl.kt | 18 +- .../services/async/AssetServiceAsync.kt | 12 +- .../services/async/AssetServiceAsyncImpl.kt | 30 +- .../services/async/BetaServiceAsync.kt | 6 +- .../services/async/BetaServiceAsyncImpl.kt | 8 +- .../services/async/CacheServiceAsync.kt | 6 +- .../services/async/CacheServiceAsyncImpl.kt | 8 +- .../async/CustomMetadataFieldServiceAsync.kt | 22 +- .../CustomMetadataFieldServiceAsyncImpl.kt | 44 +- .../services/async/FileServiceAsync.kt | 44 +- .../services/async/FileServiceAsyncImpl.kt | 74 +- .../services/async/FolderServiceAsync.kt | 32 +- .../services/async/FolderServiceAsyncImpl.kt | 52 +- .../async/SavedExtensionServiceAsync.kt | 24 +- .../async/SavedExtensionServiceAsyncImpl.kt | 46 +- .../services/async/WebhookServiceAsync.kt | 16 +- .../services/async/WebhookServiceAsyncImpl.kt | 12 +- .../async/accounts/OriginServiceAsync.kt | 26 +- .../async/accounts/OriginServiceAsyncImpl.kt | 46 +- .../async/accounts/UrlEndpointServiceAsync.kt | 26 +- .../accounts/UrlEndpointServiceAsyncImpl.kt | 46 +- .../async/accounts/UsageServiceAsync.kt | 12 +- .../async/accounts/UsageServiceAsyncImpl.kt | 30 +- .../services/async/beta/V2ServiceAsync.kt | 6 +- .../services/async/beta/V2ServiceAsyncImpl.kt | 8 +- .../async/beta/v2/FileServiceAsync.kt | 12 +- .../async/beta/v2/FileServiceAsyncImpl.kt | 32 +- .../async/cache/InvalidationServiceAsync.kt | 18 +- .../cache/InvalidationServiceAsyncImpl.kt | 38 +- .../services/async/files/BulkServiceAsync.kt | 26 +- .../async/files/BulkServiceAsyncImpl.kt | 46 +- .../async/files/MetadataServiceAsync.kt | 16 +- .../async/files/MetadataServiceAsyncImpl.kt | 34 +- .../async/files/VersionServiceAsync.kt | 22 +- .../async/files/VersionServiceAsyncImpl.kt | 44 +- .../services/async/folders/JobServiceAsync.kt | 12 +- .../async/folders/JobServiceAsyncImpl.kt | 32 +- .../services/blocking/AccountService.kt | 10 +- .../services/blocking/AccountServiceImpl.kt | 18 +- .../services/blocking/AssetService.kt | 12 +- .../services/blocking/AssetServiceImpl.kt | 30 +- .../services/blocking/BetaService.kt | 6 +- .../services/blocking/BetaServiceImpl.kt | 8 +- .../services/blocking/CacheService.kt | 6 +- .../services/blocking/CacheServiceImpl.kt | 8 +- .../blocking/CustomMetadataFieldService.kt | 20 +- .../CustomMetadataFieldServiceImpl.kt | 44 +- .../services/blocking/FileService.kt | 42 +- .../services/blocking/FileServiceImpl.kt | 74 +- .../services/blocking/FolderService.kt | 30 +- .../services/blocking/FolderServiceImpl.kt | 54 +- .../blocking/SavedExtensionService.kt | 22 +- .../blocking/SavedExtensionServiceImpl.kt | 46 +- .../services/blocking/WebhookService.kt | 16 +- .../services/blocking/WebhookServiceImpl.kt | 20 +- .../blocking/accounts/OriginService.kt | 24 +- .../blocking/accounts/OriginServiceImpl.kt | 46 +- .../blocking/accounts/UrlEndpointService.kt | 24 +- .../accounts/UrlEndpointServiceImpl.kt | 46 +- .../blocking/accounts/UsageService.kt | 12 +- .../blocking/accounts/UsageServiceImpl.kt | 30 +- .../services/blocking/beta/V2Service.kt | 6 +- .../services/blocking/beta/V2ServiceImpl.kt | 8 +- .../services/blocking/beta/v2/FileService.kt | 12 +- .../blocking/beta/v2/FileServiceImpl.kt | 32 +- .../blocking/cache/InvalidationService.kt | 16 +- .../blocking/cache/InvalidationServiceImpl.kt | 38 +- .../services/blocking/files/BulkService.kt | 24 +- .../blocking/files/BulkServiceImpl.kt | 46 +- .../blocking/files/MetadataService.kt | 14 +- .../blocking/files/MetadataServiceImpl.kt | 34 +- .../services/blocking/files/VersionService.kt | 20 +- .../blocking/files/VersionServiceImpl.kt | 44 +- .../services/blocking/folders/JobService.kt | 12 +- .../blocking/folders/JobServiceImpl.kt | 32 +- .../META-INF/proguard/image-kit-java-core.pro | 6 +- .../{io => api}/core/ClientOptionsTest.kt | 4 +- .../{io => api}/core/ObjectMappersTest.kt | 2 +- .../{io => api}/core/PhantomReachableTest.kt | 2 +- .../io/imagekit/{io => api}/core/UtilsTest.kt | 2 +- .../imagekit/{io => api}/core/ValuesTest.kt | 2 +- .../core/http/AsyncStreamResponseTest.kt | 2 +- .../{io => api}/core/http/HeadersTest.kt | 2 +- .../core/http/HttpRequestBodiesTest.kt | 6 +- .../{io => api}/core/http/HttpRequestTest.kt | 2 +- .../{io => api}/core/http/QueryParamsTest.kt | 2 +- .../core/http/RetryingHttpClientTest.kt | 10 +- .../imagekit/{io => api}/models/AiTagTest.kt | 4 +- .../{io => api}/models/BaseOverlayTest.kt | 4 +- .../{io => api}/models/CustomMetadataTest.kt | 6 +- .../models/EmbeddedMetadataTest.kt | 6 +- .../{io => api}/models/ExtensionConfigTest.kt | 8 +- .../{io => api}/models/ExtensionItemTest.kt | 8 +- .../models/GetImageAttributesOptionsTest.kt | 6 +- .../{io => api}/models/ImageOverlayTest.kt | 4 +- .../{io => api}/models/OverlayPositionTest.kt | 4 +- .../{io => api}/models/OverlayTest.kt | 8 +- .../{io => api}/models/OverlayTimingTest.kt | 4 +- .../models/ResponsiveImageAttributesTest.kt | 4 +- .../{io => api}/models/SavedExtensionTest.kt | 4 +- .../models/SelectedFieldsSchemaTest.kt | 6 +- .../models/SolidColorOverlayTest.kt | 4 +- .../SolidColorOverlayTransformationTest.kt | 4 +- .../{io => api}/models/SrcOptionsTest.kt | 6 +- .../{io => api}/models/SubtitleOverlayTest.kt | 4 +- .../SubtitleOverlayTransformationTest.kt | 4 +- .../{io => api}/models/TextOverlayTest.kt | 4 +- .../models/TextOverlayTransformationTest.kt | 4 +- .../{io => api}/models/TransformationTest.kt | 4 +- .../{io => api}/models/VersionInfoTest.kt | 4 +- .../{io => api}/models/VideoOverlayTest.kt | 4 +- .../origins/OriginCreateParamsTest.kt | 2 +- .../origins/OriginDeleteParamsTest.kt | 2 +- .../accounts/origins/OriginGetParamsTest.kt | 2 +- .../accounts/origins/OriginListParamsTest.kt | 2 +- .../accounts/origins/OriginRequestTest.kt | 8 +- .../accounts/origins/OriginResponseTest.kt | 8 +- .../origins/OriginUpdateParamsTest.kt | 2 +- .../UrlEndpointCreateParamsTest.kt | 2 +- .../UrlEndpointDeleteParamsTest.kt | 2 +- .../urlendpoints/UrlEndpointGetParamsTest.kt | 2 +- .../urlendpoints/UrlEndpointListParamsTest.kt | 2 +- .../urlendpoints/UrlEndpointRequestTest.kt | 4 +- .../urlendpoints/UrlEndpointResponseTest.kt | 4 +- .../UrlEndpointUpdateParamsTest.kt | 2 +- .../accounts/usage/UsageGetParamsTest.kt | 4 +- .../accounts/usage/UsageGetResponseTest.kt | 4 +- .../models/assets/AssetListParamsTest.kt | 4 +- .../models/assets/AssetListResponseTest.kt | 22 +- .../beta/v2/files/FileUploadParamsTest.kt | 8 +- .../beta/v2/files/FileUploadResponseTest.kt | 18 +- .../InvalidationCreateParamsTest.kt | 2 +- .../InvalidationCreateResponseTest.kt | 4 +- .../invalidation/InvalidationGetParamsTest.kt | 2 +- .../InvalidationGetResponseTest.kt | 4 +- .../CustomMetadataFieldCreateParamsTest.kt | 2 +- .../CustomMetadataFieldDeleteParamsTest.kt | 2 +- .../CustomMetadataFieldDeleteResponseTest.kt | 4 +- .../CustomMetadataFieldListParamsTest.kt | 4 +- .../CustomMetadataFieldTest.kt | 4 +- .../CustomMetadataFieldUpdateParamsTest.kt | 2 +- .../models/files/FileCopyParamsTest.kt | 2 +- .../models/files/FileCopyResponseTest.kt | 4 +- .../models/files/FileDeleteParamsTest.kt | 2 +- .../models/files/FileGetParamsTest.kt | 2 +- .../models/files/FileMoveParamsTest.kt | 2 +- .../models/files/FileMoveResponseTest.kt | 4 +- .../models/files/FileRenameParamsTest.kt | 2 +- .../models/files/FileRenameResponseTest.kt | 4 +- .../{io => api}/models/files/FileTest.kt | 16 +- .../models/files/FileUpdateParamsTest.kt | 6 +- .../models/files/FileUpdateResponseTest.kt | 16 +- .../models/files/FileUploadParamsTest.kt | 8 +- .../models/files/FileUploadResponseTest.kt | 16 +- .../{io => api}/models/files/FolderTest.kt | 6 +- .../{io => api}/models/files/MetadataTest.kt | 6 +- .../models/files/UpdateFileRequestTest.kt | 10 +- .../files/bulk/BulkAddTagsParamsTest.kt | 2 +- .../files/bulk/BulkAddTagsResponseTest.kt | 4 +- .../models/files/bulk/BulkDeleteParamsTest.kt | 2 +- .../files/bulk/BulkDeleteResponseTest.kt | 4 +- .../files/bulk/BulkRemoveAiTagsParamsTest.kt | 2 +- .../bulk/BulkRemoveAiTagsResponseTest.kt | 4 +- .../files/bulk/BulkRemoveTagsParamsTest.kt | 2 +- .../files/bulk/BulkRemoveTagsResponseTest.kt | 4 +- .../metadata/MetadataGetFromUrlParamsTest.kt | 4 +- .../files/metadata/MetadataGetParamsTest.kt | 2 +- .../files/versions/VersionDeleteParamsTest.kt | 2 +- .../versions/VersionDeleteResponseTest.kt | 4 +- .../files/versions/VersionGetParamsTest.kt | 2 +- .../files/versions/VersionListParamsTest.kt | 2 +- .../versions/VersionRestoreParamsTest.kt | 2 +- .../models/folders/FolderCopyParamsTest.kt | 2 +- .../models/folders/FolderCopyResponseTest.kt | 4 +- .../models/folders/FolderCreateParamsTest.kt | 2 +- .../folders/FolderCreateResponseTest.kt | 4 +- .../models/folders/FolderDeleteParamsTest.kt | 2 +- .../folders/FolderDeleteResponseTest.kt | 4 +- .../models/folders/FolderMoveParamsTest.kt | 2 +- .../models/folders/FolderMoveResponseTest.kt | 4 +- .../models/folders/FolderRenameParamsTest.kt | 2 +- .../folders/FolderRenameResponseTest.kt | 4 +- .../models/folders/job/JobGetParamsTest.kt | 2 +- .../models/folders/job/JobGetResponseTest.kt | 4 +- .../SavedExtensionCreateParamsTest.kt | 4 +- .../SavedExtensionDeleteParamsTest.kt | 2 +- .../SavedExtensionGetParamsTest.kt | 2 +- .../SavedExtensionListParamsTest.kt | 2 +- .../SavedExtensionUpdateParamsTest.kt | 4 +- .../models/webhooks/BaseWebhookEventTest.kt | 4 +- .../models/webhooks/FileCreateEventTest.kt | 18 +- .../models/webhooks/FileDeleteEventTest.kt | 4 +- .../models/webhooks/FileUpdateEventTest.kt | 18 +- .../webhooks/FileVersionCreateEventTest.kt | 18 +- .../webhooks/FileVersionDeleteEventTest.kt | 4 +- .../webhooks/UnsafeUnwrapWebhookEventTest.kt | 22 +- .../models/webhooks/UnwrapWebhookEventTest.kt | 22 +- .../UploadPostTransformErrorEventTest.kt | 4 +- .../UploadPostTransformSuccessEventTest.kt | 4 +- .../UploadPreTransformErrorEventTest.kt | 4 +- .../UploadPreTransformSuccessEventTest.kt | 18 +- .../VideoTransformationAcceptedEventTest.kt | 4 +- .../VideoTransformationErrorEventTest.kt | 4 +- .../VideoTransformationReadyEventTest.kt | 4 +- .../{io => api}/services/ErrorHandlingTest.kt | 34 +- .../{io => api}/services/ServiceParamsTest.kt | 12 +- .../services/async/AssetServiceAsyncTest.kt | 6 +- .../CustomMetadataFieldServiceAsyncTest.kt | 10 +- .../services/async/FileServiceAsyncTest.kt | 20 +- .../services/async/FolderServiceAsyncTest.kt | 16 +- .../async/SavedExtensionServiceAsyncTest.kt | 10 +- .../services/async/WebhookServiceAsyncTest.kt | 10 +- .../async/accounts/OriginServiceAsyncTest.kt | 8 +- .../accounts/UrlEndpointServiceAsyncTest.kt | 8 +- .../async/accounts/UsageServiceAsyncTest.kt | 6 +- .../async/beta/v2/FileServiceAsyncTest.kt | 10 +- .../cache/InvalidationServiceAsyncTest.kt | 6 +- .../async/files/BulkServiceAsyncTest.kt | 12 +- .../async/files/MetadataServiceAsyncTest.kt | 6 +- .../async/files/VersionServiceAsyncTest.kt | 10 +- .../async/folders/JobServiceAsyncTest.kt | 4 +- .../services/blocking/AssetServiceTest.kt | 6 +- .../CustomMetadataFieldServiceTest.kt | 10 +- .../services/blocking/FileServiceTest.kt | 20 +- .../services/blocking/FolderServiceTest.kt | 16 +- .../blocking/SavedExtensionServiceTest.kt | 10 +- .../services/blocking/WebhookServiceTest.kt | 10 +- .../blocking/accounts/OriginServiceTest.kt | 8 +- .../accounts/UrlEndpointServiceTest.kt | 8 +- .../blocking/accounts/UsageServiceTest.kt | 6 +- .../blocking/beta/v2/FileServiceTest.kt | 10 +- .../blocking/cache/InvalidationServiceTest.kt | 6 +- .../blocking/files/BulkServiceTest.kt | 12 +- .../blocking/files/MetadataServiceTest.kt | 6 +- .../blocking/files/VersionServiceTest.kt | 10 +- .../blocking/folders/JobServiceTest.kt | 4 +- .../java/com/imagekit/api/example/Main.java | 117 -- image-kit-java-lib/build.gradle.kts | 13 - .../lib/HelperAdvancedTransformationsTest.kt | 516 ------ .../api/lib/HelperAuthenticationTest.kt | 101 -- .../imagekit/api/lib/HelperBuildUrlTest.kt | 433 ----- .../com/imagekit/api/lib/HelperOverlayTest.kt | 1564 ----------------- .../com/imagekit/api/lib/HelperSigningTest.kt | 279 --- .../api/lib/HelperTransformationTest.kt | 108 -- image-kit-java-proguard-test/build.gradle.kts | 4 +- .../proguard/ProGuardCompatibilityTest.kt | 26 +- image-kit-java-proguard-test/test.pro | 2 +- 434 files changed, 2876 insertions(+), 7393 deletions(-) rename image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/{io => api}/client/okhttp/ImageKitOkHttpClient.kt (96%) rename image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/{io => api}/client/okhttp/ImageKitOkHttpClientAsync.kt (96%) rename image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/{io => api}/client/okhttp/OkHttpClient.kt (96%) rename image-kit-java-client-okhttp/src/test/kotlin/io/imagekit/{io => api}/client/okhttp/OkHttpClientTest.kt (91%) delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/lib/Helper.kt delete mode 100644 image-kit-java-core/src/main/kotlin/com/imagekit/api/lib/HelperService.kt rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/client/ImageKitClient.kt (83%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/client/ImageKitClientAsync.kt (83%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/client/ImageKitClientAsyncImpl.kt (79%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/client/ImageKitClientImpl.kt (78%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/BaseDeserializer.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/BaseSerializer.kt (85%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/Check.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/ClientOptions.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/DefaultSleeper.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/ObjectMappers.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/Params.kt (77%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/PhantomReachable.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/PhantomReachableExecutorService.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/PhantomReachableSleeper.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/PrepareRequest.kt (91%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/Properties.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/RequestOptions.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/Sleeper.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/Timeout.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/UnwrapWebhookParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/Utils.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/Values.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/handlers/EmptyHandler.kt (62%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/handlers/ErrorHandler.kt (81%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/handlers/JsonHandler.kt (73%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/handlers/StringHandler.kt (68%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/http/AsyncStreamResponse.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/http/Headers.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/http/HttpClient.kt (90%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/http/HttpMethod.kt (78%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/http/HttpRequest.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/http/HttpRequestBodies.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/http/HttpRequestBody.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/http/HttpResponse.kt (92%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/http/HttpResponseFor.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/http/PhantomReachableClosingAsyncStreamResponse.kt (92%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/http/PhantomReachableClosingHttpClient.kt (85%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/http/PhantomReachableClosingStreamResponse.kt (86%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/http/QueryParams.kt (90%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/http/RetryingHttpClient.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/core/http/StreamResponse.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/errors/BadRequestException.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/errors/ImageKitException.kt (82%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/errors/ImageKitInvalidDataException.kt (82%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/errors/ImageKitIoException.kt (81%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/errors/ImageKitRetryableException.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/errors/ImageKitServiceException.kt (74%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/errors/ImageKitWebhookException.kt (82%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/errors/InternalServerException.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/errors/NotFoundException.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/errors/PermissionDeniedException.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/errors/RateLimitException.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/errors/UnauthorizedException.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/errors/UnexpectedStatusCodeException.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/errors/UnprocessableEntityException.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/AiTag.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/BaseOverlay.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/CustomMetadata.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/EmbeddedMetadata.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/ExtensionConfig.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/ExtensionItem.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/GetImageAttributesOptions.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/ImageOverlay.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/Overlay.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/OverlayPosition.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/OverlayTiming.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/ResponsiveImageAttributes.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/SavedExtension.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/SelectedFieldsSchema.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/SolidColorOverlay.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/SolidColorOverlayTransformation.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/SrcOptions.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/StreamingResolution.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/SubtitleOverlay.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/SubtitleOverlayTransformation.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/TextOverlay.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/TextOverlayTransformation.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/Transformation.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/TransformationPosition.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/VersionInfo.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/VideoOverlay.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/accounts/origins/OriginCreateParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/accounts/origins/OriginDeleteParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/accounts/origins/OriginGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/accounts/origins/OriginListParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/accounts/origins/OriginRequest.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/accounts/origins/OriginResponse.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/accounts/origins/OriginUpdateParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/accounts/urlendpoints/UrlEndpointCreateParams.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/accounts/urlendpoints/UrlEndpointGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/accounts/urlendpoints/UrlEndpointListParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/accounts/urlendpoints/UrlEndpointRequest.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/accounts/urlendpoints/UrlEndpointResponse.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/accounts/usage/UsageGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/accounts/usage/UsageGetResponse.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/assets/AssetListParams.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/assets/AssetListResponse.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/beta/v2/files/FileUploadParams.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/beta/v2/files/FileUploadResponse.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/cache/invalidation/InvalidationCreateParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/cache/invalidation/InvalidationCreateResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/cache/invalidation/InvalidationGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/cache/invalidation/InvalidationGetResponse.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/custommetadatafields/CustomMetadataField.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/custommetadatafields/CustomMetadataFieldCreateParams.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/custommetadatafields/CustomMetadataFieldListParams.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/File.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/FileCopyParams.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/FileCopyResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/FileDeleteParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/FileGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/FileMoveParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/FileMoveResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/FileRenameParams.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/FileRenameResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/FileUpdateParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/FileUpdateResponse.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/FileUploadParams.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/FileUploadResponse.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/Folder.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/Metadata.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/UpdateFileRequest.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/bulk/BulkAddTagsParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/bulk/BulkAddTagsResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/bulk/BulkDeleteParams.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/bulk/BulkDeleteResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/bulk/BulkRemoveAiTagsParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/bulk/BulkRemoveAiTagsResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/bulk/BulkRemoveTagsParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/bulk/BulkRemoveTagsResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/metadata/MetadataGetFromUrlParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/metadata/MetadataGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/versions/VersionDeleteParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/versions/VersionDeleteResponse.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/versions/VersionGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/versions/VersionListParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/files/versions/VersionRestoreParams.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/folders/FolderCopyParams.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/folders/FolderCopyResponse.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/folders/FolderCreateParams.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/folders/FolderCreateResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/folders/FolderDeleteParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/folders/FolderDeleteResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/folders/FolderMoveParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/folders/FolderMoveResponse.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/folders/FolderRenameParams.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/folders/FolderRenameResponse.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/folders/job/JobGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/folders/job/JobGetResponse.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/savedextensions/SavedExtensionCreateParams.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/savedextensions/SavedExtensionDeleteParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/savedextensions/SavedExtensionGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/savedextensions/SavedExtensionListParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/savedextensions/SavedExtensionUpdateParams.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/webhooks/BaseWebhookEvent.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/webhooks/FileCreateEvent.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/webhooks/FileDeleteEvent.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/webhooks/FileUpdateEvent.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/webhooks/FileVersionCreateEvent.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/webhooks/FileVersionDeleteEvent.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/webhooks/UnsafeUnwrapWebhookEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/webhooks/UnwrapWebhookEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/webhooks/UploadPostTransformErrorEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/webhooks/UploadPostTransformSuccessEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/webhooks/UploadPreTransformErrorEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/webhooks/UploadPreTransformSuccessEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/webhooks/VideoTransformationAcceptedEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/webhooks/VideoTransformationErrorEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/models/webhooks/VideoTransformationReadyEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/AccountServiceAsync.kt (81%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/AccountServiceAsyncImpl.kt (82%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/AssetServiceAsync.kt (91%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/AssetServiceAsyncImpl.kt (79%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/BetaServiceAsync.kt (87%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/BetaServiceAsyncImpl.kt (87%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/CacheServiceAsync.kt (87%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/CacheServiceAsyncImpl.kt (87%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/CustomMetadataFieldServiceAsync.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/CustomMetadataFieldServiceAsyncImpl.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/FileServiceAsync.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/FileServiceAsyncImpl.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/FolderServiceAsync.kt (89%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/FolderServiceAsyncImpl.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/SavedExtensionServiceAsync.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/SavedExtensionServiceAsyncImpl.kt (89%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/WebhookServiceAsync.kt (82%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/WebhookServiceAsyncImpl.kt (82%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/accounts/OriginServiceAsync.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/accounts/OriginServiceAsyncImpl.kt (89%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/accounts/UrlEndpointServiceAsync.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/accounts/UrlEndpointServiceAsyncImpl.kt (89%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/accounts/UsageServiceAsync.kt (87%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/accounts/UsageServiceAsyncImpl.kt (79%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/beta/V2ServiceAsync.kt (87%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/beta/V2ServiceAsyncImpl.kt (86%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/beta/v2/FileServiceAsync.kt (91%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/beta/v2/FileServiceAsyncImpl.kt (79%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/cache/InvalidationServiceAsync.kt (91%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/cache/InvalidationServiceAsyncImpl.kt (83%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/files/BulkServiceAsync.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/files/BulkServiceAsyncImpl.kt (87%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/files/MetadataServiceAsync.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/files/MetadataServiceAsyncImpl.kt (84%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/files/VersionServiceAsync.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/files/VersionServiceAsyncImpl.kt (89%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/folders/JobServiceAsync.kt (92%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/async/folders/JobServiceAsyncImpl.kt (79%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/AccountService.kt (81%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/AccountServiceImpl.kt (81%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/AssetService.kt (90%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/AssetServiceImpl.kt (77%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/BetaService.kt (87%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/BetaServiceImpl.kt (86%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/CacheService.kt (87%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/CacheServiceImpl.kt (86%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/CustomMetadataFieldService.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/CustomMetadataFieldServiceImpl.kt (86%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/FileService.kt (92%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/FileServiceImpl.kt (87%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/FolderService.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/FolderServiceImpl.kt (86%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/SavedExtensionService.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/SavedExtensionServiceImpl.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/WebhookService.kt (81%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/WebhookServiceImpl.kt (81%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/accounts/OriginService.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/accounts/OriginServiceImpl.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/accounts/UrlEndpointService.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/accounts/UrlEndpointServiceImpl.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/accounts/UsageService.kt (86%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/accounts/UsageServiceImpl.kt (76%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/beta/V2Service.kt (86%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/beta/V2ServiceImpl.kt (85%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/beta/v2/FileService.kt (91%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/beta/v2/FileServiceImpl.kt (77%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/cache/InvalidationService.kt (91%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/cache/InvalidationServiceImpl.kt (81%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/files/BulkService.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/files/BulkServiceImpl.kt (86%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/files/MetadataService.kt (92%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/files/MetadataServiceImpl.kt (83%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/files/VersionService.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/files/VersionServiceImpl.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/folders/JobService.kt (91%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{io => api}/services/blocking/folders/JobServiceImpl.kt (77%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/core/ClientOptionsTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/core/ObjectMappersTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/core/PhantomReachableTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/core/UtilsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/core/ValuesTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/core/http/AsyncStreamResponseTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/core/http/HeadersTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/core/http/HttpRequestBodiesTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/core/http/HttpRequestTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/core/http/QueryParamsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/core/http/RetryingHttpClientTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/AiTagTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/BaseOverlayTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/CustomMetadataTest.kt (89%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/EmbeddedMetadataTest.kt (89%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/ExtensionConfigTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/ExtensionItemTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/GetImageAttributesOptionsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/ImageOverlayTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/OverlayPositionTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/OverlayTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/OverlayTimingTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/ResponsiveImageAttributesTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/SavedExtensionTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/SelectedFieldsSchemaTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/SolidColorOverlayTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/SolidColorOverlayTransformationTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/SrcOptionsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/SubtitleOverlayTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/SubtitleOverlayTransformationTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/TextOverlayTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/TextOverlayTransformationTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/TransformationTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/VersionInfoTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/VideoOverlayTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/accounts/origins/OriginCreateParamsTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/accounts/origins/OriginDeleteParamsTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/accounts/origins/OriginGetParamsTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/accounts/origins/OriginListParamsTest.kt (81%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/accounts/origins/OriginRequestTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/accounts/origins/OriginResponseTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/accounts/origins/OriginUpdateParamsTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt (90%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt (80%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/accounts/urlendpoints/UrlEndpointRequestTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/accounts/urlendpoints/UrlEndpointResponseTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/accounts/usage/UsageGetParamsTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/accounts/usage/UsageGetResponseTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/assets/AssetListParamsTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/assets/AssetListResponseTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/beta/v2/files/FileUploadParamsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/beta/v2/files/FileUploadResponseTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/cache/invalidation/InvalidationCreateParamsTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/cache/invalidation/InvalidationCreateResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/cache/invalidation/InvalidationGetParamsTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/cache/invalidation/InvalidationGetResponseTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/custommetadatafields/CustomMetadataFieldTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/FileCopyParamsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/FileCopyResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/FileDeleteParamsTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/FileGetParamsTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/FileMoveParamsTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/FileMoveResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/FileRenameParamsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/FileRenameResponseTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/FileTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/FileUpdateParamsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/FileUpdateResponseTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/FileUploadParamsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/FileUploadResponseTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/FolderTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/MetadataTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/UpdateFileRequestTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/bulk/BulkAddTagsParamsTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/bulk/BulkAddTagsResponseTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/bulk/BulkDeleteParamsTest.kt (94%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/bulk/BulkDeleteResponseTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/bulk/BulkRemoveAiTagsParamsTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/bulk/BulkRemoveAiTagsResponseTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/bulk/BulkRemoveTagsParamsTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/bulk/BulkRemoveTagsResponseTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/metadata/MetadataGetFromUrlParamsTest.kt (86%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/metadata/MetadataGetParamsTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/versions/VersionDeleteParamsTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/versions/VersionDeleteResponseTest.kt (90%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/versions/VersionGetParamsTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/versions/VersionListParamsTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/files/versions/VersionRestoreParamsTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/folders/FolderCopyParamsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/folders/FolderCopyResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/folders/FolderCreateParamsTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/folders/FolderCreateResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/folders/FolderDeleteParamsTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/folders/FolderDeleteResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/folders/FolderMoveParamsTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/folders/FolderMoveResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/folders/FolderRenameParamsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/folders/FolderRenameResponseTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/folders/job/JobGetParamsTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/folders/job/JobGetResponseTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/savedextensions/SavedExtensionCreateParamsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/savedextensions/SavedExtensionDeleteParamsTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/savedextensions/SavedExtensionGetParamsTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/savedextensions/SavedExtensionListParamsTest.kt (82%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/savedextensions/SavedExtensionUpdateParamsTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/webhooks/BaseWebhookEventTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/webhooks/FileCreateEventTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/webhooks/FileDeleteEventTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/webhooks/FileUpdateEventTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/webhooks/FileVersionCreateEventTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/webhooks/FileVersionDeleteEventTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/webhooks/UnsafeUnwrapWebhookEventTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/webhooks/UnwrapWebhookEventTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/webhooks/UploadPostTransformErrorEventTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/webhooks/UploadPostTransformSuccessEventTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/webhooks/UploadPreTransformErrorEventTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/webhooks/UploadPreTransformSuccessEventTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/webhooks/VideoTransformationAcceptedEventTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/webhooks/VideoTransformationErrorEventTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/models/webhooks/VideoTransformationReadyEventTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/ErrorHandlingTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/ServiceParamsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/async/AssetServiceAsyncTest.kt (86%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/async/CustomMetadataFieldServiceAsyncTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/async/FileServiceAsyncTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/async/FolderServiceAsyncTest.kt (89%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/async/SavedExtensionServiceAsyncTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/async/WebhookServiceAsyncTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/async/accounts/OriginServiceAsyncTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/async/accounts/UrlEndpointServiceAsyncTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/async/accounts/UsageServiceAsyncTest.kt (83%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/async/beta/v2/FileServiceAsyncTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/async/cache/InvalidationServiceAsyncTest.kt (88%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/async/files/BulkServiceAsyncTest.kt (89%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/async/files/MetadataServiceAsyncTest.kt (87%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/async/files/VersionServiceAsyncTest.kt (88%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/async/folders/JobServiceAsyncTest.kt (84%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/blocking/AssetServiceTest.kt (86%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/blocking/CustomMetadataFieldServiceTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/blocking/FileServiceTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/blocking/FolderServiceTest.kt (89%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/blocking/SavedExtensionServiceTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/blocking/WebhookServiceTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/blocking/accounts/OriginServiceTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/blocking/accounts/UrlEndpointServiceTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/blocking/accounts/UsageServiceTest.kt (82%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/blocking/beta/v2/FileServiceTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/blocking/cache/InvalidationServiceTest.kt (86%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/blocking/files/BulkServiceTest.kt (88%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/blocking/files/MetadataServiceTest.kt (85%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/blocking/files/VersionServiceTest.kt (87%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{io => api}/services/blocking/folders/JobServiceTest.kt (83%) delete mode 100644 image-kit-java-example/src/main/java/com/imagekit/api/example/Main.java delete mode 100644 image-kit-java-lib/build.gradle.kts delete mode 100644 image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperAdvancedTransformationsTest.kt delete mode 100644 image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperAuthenticationTest.kt delete mode 100644 image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperBuildUrlTest.kt delete mode 100644 image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperOverlayTest.kt delete mode 100644 image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperSigningTest.kt delete mode 100644 image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperTransformationTest.kt rename image-kit-java-proguard-test/src/test/kotlin/io/imagekit/{io => api}/proguard/ProGuardCompatibilityTest.kt (94%) diff --git a/.gitignore b/.gitignore index 3b66adc5..90b85e94 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,3 @@ build/ codegen.log kls_database.db - -image-kit-java-example/resources -image-kit-java-example/src/main/resources/ -temp \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 71485510..8624958a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 -config_hash: ef918f7e878d4168a07e867607eb68ea +config_hash: 4e6bdc90056ab9bddbeb207bd720cf53 diff --git a/README.md b/README.md index c329a208..fcdc768b 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,13 @@ -# ImageKit.io Java SDK +# Image Kit Java API Library -[![Maven Central](https://img.shields.io/maven-central/v/com.imagekit.api/image-kit-java)](https://central.sonatype.com/artifact/com.imagekit.api/image-kit-java/0.0.1) -[![javadoc](https://javadoc.io/badge2/com.imagekit.api/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1) +[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit.api/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit.api/image-kit-java/0.0.1) +[![javadoc](https://javadoc.io/badge2/io.imagekit.api/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/io.imagekit.api/image-kit-java/0.0.1) -The ImageKit Java SDK is a comprehensive library designed to simplify the integration of ImageKit into your server-side applications. It provides powerful tools for working with the ImageKit REST API, including building and transforming URLs, generating signed URLs for secure content delivery, verifying webhooks, and handling file uploads. - -The full API of this library can be found in [api.md](api.md). - -For additional details, refer to the [ImageKit REST API documentation](https://imagekit.io/docs/api-reference) or the [javadoc](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1). - -## Table of Contents - -- [Installation](#installation) -- [Requirements](#requirements) -- [Usage](#usage) -- [URL generation](#url-generation) - - [Basic URL generation](#basic-url-generation) - - [URL generation with transformations](#url-generation-with-transformations) - - [URL generation with image overlay](#url-generation-with-image-overlay) - - [URL generation with text overlay](#url-generation-with-text-overlay) - - [URL generation with multiple overlays](#url-generation-with-multiple-overlays) - - [Signed URLs for secure delivery](#signed-urls-for-secure-delivery) -- [Authentication parameters for client-side uploads](#authentication-parameters-for-client-side-uploads) -- [Webhook verification](#webhook-verification) -- [Advanced Usage](#advanced-usage) - - [Client configuration](#client-configuration) - - [File uploads](#file-uploads) - - [Error handling](#error-handling) - - [Retries](#retries) - - [Timeouts](#timeouts) - - [Proxies](#proxies) - - [Logging](#logging) -- [Semantic versioning](#semantic-versioning) +The Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java. ## MCP Server @@ -48,7 +20,7 @@ Use the Image Kit MCP Server to enable AI assistants to interact with this API, -The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.imagekit.api/image-kit-java/0.0.1). +The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit.api/image-kit-java/0.0.1). @@ -59,14 +31,14 @@ The REST API documentation can be found on [imagekit.io](https://imagekit.io/doc ### Gradle ```kotlin -implementation("com.imagekit.api:image-kit-java:0.0.1") +implementation("io.imagekit.api:image-kit-java:0.0.1") ``` ### Maven ```xml - com.imagekit.api + io.imagekit.api image-kit-java 0.0.1 @@ -81,66 +53,72 @@ This library requires Java 8 or later. ## Usage ```java -import com.imagekit.api.client.ImageKitClient; -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; -import com.imagekit.api.models.files.FileUploadParams; -import com.imagekit.api.models.files.FileUploadResponse; -import java.io.FileInputStream; +import io.imagekit.api.client.ImageKitClient; +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.api.models.files.FileUploadParams; +import io.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; -ImageKitClient client = ImageKitOkHttpClient.builder() - .privateKey("private_key_xxx") // defaults to IMAGEKIT_PRIVATE_KEY env var - .build(); +// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables +ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() - .file(new FileInputStream("/path/to/your/image.jpg")) - .fileName("uploaded-image.jpg") + .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") .build(); FileUploadResponse response = client.files().upload(params); -System.out.println(response); ``` ## Client configuration -Configure the client using environment variables: +Configure the client using system properties or environment variables: ```java -import com.imagekit.api.client.ImageKitClient; -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.api.client.ImageKitClient; +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; -// Configures using the `IMAGEKIT_PRIVATE_KEY` and `IMAGEKIT_WEBHOOK_SECRET` environment variables +// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); ``` Or manually: ```java -import com.imagekit.api.client.ImageKitClient; -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.api.client.ImageKitClient; +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; ImageKitClient client = ImageKitOkHttpClient.builder() - .privateKey("private_key_xxx") + .privateKey("My Private Key") + .password("My Password") .build(); ``` Or using a combination of the two approaches: ```java -import com.imagekit.api.client.ImageKitClient; -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.api.client.ImageKitClient; +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; ImageKitClient client = ImageKitOkHttpClient.builder() + // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties + // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables .fromEnv() - .privateKey("private_key_xxx") + .privateKey("My Private Key") .build(); ``` See this table for the available options: -| Setter | Environment variable | Required | Default value | -| --------------- | -------------------------------- | -------- | --------------------------- | -| `privateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - | -| `webhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - | -| `baseUrl` | `IMAGE_KIT_BASE_URL` | false | `"https://api.imagekit.io"` | +| Setter | System property | Environment variable | Required | Default value | +| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- | +| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - | +| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` | +| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - | +| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` | + +System properties take precedence over environment variables. > [!TIP] > Don't create more than one client in the same application. Each client has a connection pool and @@ -151,7 +129,7 @@ See this table for the available options: To temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service: ```java -import com.imagekit.api.client.ImageKitClient; +import io.imagekit.api.client.ImageKitClient; ImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> { optionsBuilder.baseUrl("https://example.com"); @@ -161,284 +139,6 @@ ImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> { The `withOptions()` method does not affect the original client or service. -## URL generation - -The ImageKit SDK provides a powerful `client.helper().buildUrl()` method for generating optimized image and video URLs with transformations. - -### Basic URL generation - -Generate a simple URL without any transformations: - -```java -import com.imagekit.api.client.ImageKitClient; -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; -import com.imagekit.api.models.SrcOptions; - -ImageKitClient client = ImageKitOkHttpClient.builder() - .privateKey("private_key_xxx") - .build(); - -String url = client.helper().buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") - .src("/path/to/image.jpg") - .build() -); -System.out.println(url); -// Result: https://ik.imagekit.io/your_imagekit_id/path/to/image.jpg -``` - -### URL generation with transformations - -Apply common transformations like resizing, quality, and format conversion: - -```java -import com.imagekit.api.models.SrcOptions; -import com.imagekit.api.models.Transformation; - -String url = client.helper().buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") - .src("/path/to/image.jpg") - .addTransformation( - Transformation.builder() - .width(400.0) - .height(300.0) - .crop(Transformation.Crop.MAINTAIN_RATIO) - .quality(80.0) - .format(Transformation.Format.WEBP) - .build() - ) - .build() -); -System.out.println(url); -// Result: https://ik.imagekit.io/your_imagekit_id/path/to/image.jpg?tr=w-400,h-300,c-maintain_ratio,q-80,f-webp -``` - -### URL generation with image overlay - -Add image overlays to your base image: - -```java -import com.imagekit.api.models.ImageOverlay; -import com.imagekit.api.models.Overlay; -import com.imagekit.api.models.OverlayPosition; -import com.imagekit.api.models.SrcOptions; -import com.imagekit.api.models.Transformation; - -String url = client.helper().buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") - .src("/path/to/base-image.jpg") - .addTransformation( - Transformation.builder() - .width(500.0) - .height(400.0) - .overlay(Overlay.ofImage( - ImageOverlay.builder() - .input("/path/to/overlay-logo.png") - .position(OverlayPosition.builder() - .x(10.0) - .y(10.0) - .build()) - .addTransformation( - Transformation.builder() - .width(100.0) - .height(50.0) - .build() - ) - .build() - )) - .build() - ) - .build() -); -System.out.println(url); -// Result: URL with image overlay positioned at x:10, y:10 -``` - -### URL generation with text overlay - -Add customized text overlays: - -```java -import com.imagekit.api.models.Overlay; -import com.imagekit.api.models.OverlayPosition; -import com.imagekit.api.models.SrcOptions; -import com.imagekit.api.models.TextOverlay; -import com.imagekit.api.models.TextOverlayTransformation; -import com.imagekit.api.models.Transformation; - -String url = client.helper().buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") - .src("/path/to/base-image.jpg") - .addTransformation( - Transformation.builder() - .width(600.0) - .height(400.0) - .overlay(Overlay.ofText( - TextOverlay.builder() - .text("Sample Text Overlay") - .position(OverlayPosition.builder() - .x(50.0) - .y(50.0) - .focus(OverlayPosition.Focus.CENTER) - .build()) - .addTransformation( - TextOverlayTransformation.builder() - .fontSize(40.0) - .fontFamily("Arial") - .fontColor("FFFFFF") - .build() - ) - .build() - )) - .build() - ) - .build() -); -System.out.println(url); -// Result: URL with white Arial text overlay at center position -``` - -### URL generation with multiple overlays - -Combine multiple overlays for complex compositions: - -```java -import com.imagekit.api.models.ImageOverlay; -import com.imagekit.api.models.Overlay; -import com.imagekit.api.models.OverlayPosition; -import com.imagekit.api.models.SrcOptions; -import com.imagekit.api.models.TextOverlay; -import com.imagekit.api.models.TextOverlayTransformation; -import com.imagekit.api.models.Transformation; -import java.util.Arrays; - -String url = client.helper().buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") - .src("/path/to/base-image.jpg") - .addTransformation( - // First transformation step: text overlay - Transformation.builder() - .width(800.0) - .height(600.0) - .overlay(Overlay.ofText( - TextOverlay.builder() - .text("Header Text") - .position(OverlayPosition.builder() - .x(20.0) - .y(20.0) - .build()) - .addTransformation( - TextOverlayTransformation.builder() - .fontSize(30.0) - .fontColor("000000") - .build() - ) - .build() - )) - .build() - ) - .addTransformation( - // Second transformation step: image watermark overlay - Transformation.builder() - .overlay(Overlay.ofImage( - ImageOverlay.builder() - .input("/watermark.png") - .position(OverlayPosition.builder() - .focus(OverlayPosition.Focus.BOTTOM_RIGHT) - .build()) - .addTransformation( - Transformation.builder() - .width(100.0) - .opacity(70.0) - .build() - ) - .build() - )) - .build() - ) - .build() -); -System.out.println(url); -// Result: URL with text overlay at top-left and semi-transparent watermark at bottom-right -``` - -### Signed URLs for secure delivery - -Generate signed URLs that expire after a specified time for secure content delivery: - -```java -import com.imagekit.api.models.SrcOptions; -import com.imagekit.api.models.Transformation; - -// Generate a signed URL that expires in 1 hour (3600 seconds) -String url = client.helper().buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") - .src("/private/secure-image.jpg") - .addTransformation( - Transformation.builder() - .width(400.0) - .height(300.0) - .quality(90.0) - .build() - ) - .signed(true) - .expiresIn(3600.0) // URL expires in 1 hour - .build() -); -System.out.println(url); -// Result: URL with signature parameters (?ik-t=timestamp&ik-s=signature) - -// Generate a signed URL that doesn't expire -String permanentSignedUrl = client.helper().buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") - .src("/private/secure-image.jpg") - .signed(true) - // No expiresIn means the URL won't expire - .build() -); -System.out.println(permanentSignedUrl); -// Result: URL with signature parameter (?ik-s=signature) -``` - -## Authentication parameters for client-side uploads - -Generate authentication parameters for secure client-side file uploads: - -```java -import com.imagekit.api.client.ImageKitClient; -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; -import java.util.Map; - -ImageKitClient client = ImageKitOkHttpClient.builder() - .privateKey("private_key_xxx") - .build(); - -// Generate authentication parameters with auto-generated token and default expiry -Map authParams = client.helper().getAuthenticationParameters(null, null); -System.out.println(authParams); -// Result: {token=, expire=, signature=} - -// Generate with custom token and expiry -Map customAuthParams = client.helper().getAuthenticationParameters("my-custom-token", 1800L); -System.out.println(customAuthParams); -// Result: {token=my-custom-token, expire=1800, signature=} -``` - -These authentication parameters can be used in client-side upload forms to securely upload files without exposing your private API key. - -## Webhook verification - -The ImageKit SDK provides utilities to verify webhook signatures for secure event handling. This ensures that webhook requests are actually coming from ImageKit and haven't been tampered with. - -For detailed information about webhook setup, signature verification, and handling different webhook events, refer to the [ImageKit webhook documentation](https://imagekit.io/docs/webhooks#verify-webhook-signature). - ## Requests and responses To send a request to the Image Kit API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. @@ -458,20 +158,20 @@ Because each class is immutable, builder modification will _never_ affect alread The default client is synchronous. To switch to asynchronous execution, call the `async()` method: ```java -import com.imagekit.api.client.ImageKitClient; -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; -import com.imagekit.api.models.files.FileUploadParams; -import com.imagekit.api.models.files.FileUploadResponse; -import java.io.FileInputStream; +import io.imagekit.api.client.ImageKitClient; +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.api.models.files.FileUploadParams; +import io.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; -ImageKitClient client = ImageKitOkHttpClient.builder() - .privateKey("private_key_xxx") - .build(); +// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables +ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() - .file(new FileInputStream("/path/to/your/image.jpg")) - .fileName("uploaded-image.jpg") + .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") .build(); CompletableFuture response = client.async().files().upload(params); ``` @@ -479,20 +179,20 @@ CompletableFuture response = client.async().files().upload(p Or create an asynchronous client from the beginning: ```java -import com.imagekit.api.client.ImageKitClientAsync; -import com.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync; -import com.imagekit.api.models.files.FileUploadParams; -import com.imagekit.api.models.files.FileUploadResponse; -import java.io.FileInputStream; +import io.imagekit.api.client.ImageKitClientAsync; +import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync; +import io.imagekit.api.models.files.FileUploadParams; +import io.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; -ImageKitClientAsync client = ImageKitOkHttpClientAsync.builder() - .privateKey("private_key_xxx") - .build(); +// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables +ImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv(); FileUploadParams params = FileUploadParams.builder() - .file(new FileInputStream("/path/to/your/image.jpg")) - .fileName("uploaded-image.jpg") + .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") .build(); CompletableFuture response = client.files().upload(params); ``` @@ -506,13 +206,13 @@ The SDK defines methods that accept files. To upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html): ```java -import com.imagekit.api.models.files.FileUploadParams; -import com.imagekit.api.models.files.FileUploadResponse; +import io.imagekit.api.models.files.FileUploadParams; +import io.imagekit.api.models.files.FileUploadResponse; import java.nio.file.Paths; FileUploadParams params = FileUploadParams.builder() - .fileName("uploaded-image.jpg") - .file(Paths.get("/path/to/your/image.jpg")) + .fileName("fileName") + .file(Paths.get("/path/to/file")) .build(); FileUploadResponse response = client.files().upload(params); ``` @@ -520,13 +220,13 @@ FileUploadResponse response = client.files().upload(params); Or an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html): ```java -import com.imagekit.api.models.files.FileUploadParams; -import com.imagekit.api.models.files.FileUploadResponse; -import java.io.FileInputStream; +import io.imagekit.api.models.files.FileUploadParams; +import io.imagekit.api.models.files.FileUploadResponse; +import java.net.URL; FileUploadParams params = FileUploadParams.builder() - .fileName("uploaded-image.jpg") - .file(new FileInputStream("/path/to/your/image.jpg")) + .fileName("fileName") + .file(new URL("https://example.com//path/to/file").openStream()) .build(); FileUploadResponse response = client.files().upload(params); ``` @@ -534,32 +234,30 @@ FileUploadResponse response = client.files().upload(params); Or a `byte[]` array: ```java -import com.imagekit.api.models.files.FileUploadParams; -import com.imagekit.api.models.files.FileUploadResponse; +import io.imagekit.api.models.files.FileUploadParams; +import io.imagekit.api.models.files.FileUploadResponse; -byte[] imageData = /* your binary data */; FileUploadParams params = FileUploadParams.builder() - .fileName("binary-upload.jpg") - .file(imageData) + .fileName("fileName") + .file("content".getBytes()) .build(); FileUploadResponse response = client.files().upload(params); ``` -Note that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt): +Note that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt): ```java -import com.imagekit.api.core.MultipartField; -import com.imagekit.api.models.files.FileUploadParams; -import com.imagekit.api.models.files.FileUploadResponse; -import java.io.FileInputStream; +import io.imagekit.api.core.MultipartField; +import io.imagekit.api.models.files.FileUploadParams; +import io.imagekit.api.models.files.FileUploadResponse; import java.io.InputStream; +import java.net.URL; FileUploadParams params = FileUploadParams.builder() - .fileName("custom-upload.jpg") + .fileName("fileName") .file(MultipartField.builder() - .value(new FileInputStream("/path/to/your/image.jpg")) - .filename("image.jpg") - .contentType("image/jpeg") + .value(new URL("https://example.com//path/to/file").openStream()) + .filename("/path/to/file") .build()) .build(); FileUploadResponse response = client.files().upload(params); @@ -572,15 +270,15 @@ The SDK defines methods that deserialize responses into instances of Java classe To access this data, prefix any HTTP method call on a client or service with `withRawResponse()`: ```java -import com.imagekit.api.core.http.Headers; -import com.imagekit.api.core.http.HttpResponseFor; -import com.imagekit.api.models.files.FileUploadParams; -import com.imagekit.api.models.files.FileUploadResponse; -import java.io.FileInputStream; +import io.imagekit.api.core.http.Headers; +import io.imagekit.api.core.http.HttpResponseFor; +import io.imagekit.api.models.files.FileUploadParams; +import io.imagekit.api.models.files.FileUploadResponse; +import java.io.ByteArrayInputStream; FileUploadParams params = FileUploadParams.builder() - .file(new FileInputStream("/path/to/your/image.jpg")) - .fileName("uploaded-image.jpg") + .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) + .fileName("file-name.jpg") .build(); HttpResponseFor response = client.files().withRawResponse().upload(params); @@ -591,7 +289,7 @@ Headers headers = response.headers(); You can still deserialize the response into an instance of a Java class if needed: ```java -import com.imagekit.api.models.files.FileUploadResponse; +import io.imagekit.api.models.files.FileUploadResponse; FileUploadResponse parsedResponse = response.parse(); ``` @@ -600,26 +298,26 @@ FileUploadResponse parsedResponse = response.parse(); The SDK throws custom unchecked exception types: -- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code: +- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code: - | Status | Exception | - | ------ | ------------------------------------------------------------------------------------------------------------------------------- | - | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/BadRequestException.kt) | - | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnauthorizedException.kt) | - | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/PermissionDeniedException.kt) | - | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/NotFoundException.kt) | - | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnprocessableEntityException.kt) | - | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/RateLimitException.kt) | - | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/InternalServerException.kt) | - | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/UnexpectedStatusCodeException.kt) | + | Status | Exception | + | ------ | ------------------------------------------------------------------------------------------------------------------------------ | + | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/BadRequestException.kt) | + | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnauthorizedException.kt) | + | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/PermissionDeniedException.kt) | + | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/NotFoundException.kt) | + | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnprocessableEntityException.kt) | + | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/RateLimitException.kt) | + | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/InternalServerException.kt) | + | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnexpectedStatusCodeException.kt) | -- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors. +- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors. -- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client. +- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client. -- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response. +- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response. -- [`ImageKitException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class. +- [`ImageKitException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class. ## Logging @@ -649,7 +347,7 @@ The SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON seri The SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config). -If the SDK threw an exception, but you're _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt). +If the SDK threw an exception, but you're _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt). > [!CAUTION] > We make no guarantee that the SDK works correctly when the Jackson version check is disabled. @@ -675,8 +373,8 @@ The API may also explicitly instruct the SDK to retry or not retry a request. To set a custom number of retries, configure the client using the `maxRetries` method: ```java -import com.imagekit.api.client.ImageKitClient; -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.api.client.ImageKitClient; +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; ImageKitClient client = ImageKitOkHttpClient.builder() .fromEnv() @@ -691,7 +389,7 @@ Requests time out after 1 minute by default. To set a custom timeout, configure the method call using the `timeout` method: ```java -import com.imagekit.api.models.files.FileUploadResponse; +import io.imagekit.api.models.files.FileUploadResponse; FileUploadResponse response = client.files().upload( params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build() @@ -701,8 +399,8 @@ FileUploadResponse response = client.files().upload( Or configure the default for all method calls at the client level: ```java -import com.imagekit.api.client.ImageKitClient; -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.api.client.ImageKitClient; +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; import java.time.Duration; ImageKitClient client = ImageKitOkHttpClient.builder() @@ -716,8 +414,8 @@ ImageKitClient client = ImageKitOkHttpClient.builder() To route requests through a proxy, configure the client using the `proxy` method: ```java -import com.imagekit.api.client.ImageKitClient; -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.api.client.ImageKitClient; +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; import java.net.InetSocketAddress; import java.net.Proxy; @@ -736,8 +434,8 @@ ImageKitClient client = ImageKitOkHttpClient.builder() To customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods: ```java -import com.imagekit.api.client.ImageKitClient; -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.api.client.ImageKitClient; +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; import java.time.Duration; ImageKitClient client = ImageKitOkHttpClient.builder() @@ -759,8 +457,8 @@ If both options are unset, OkHttp's default connection pool settings are used. To configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods: ```java -import com.imagekit.api.client.ImageKitClient; -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.api.client.ImageKitClient; +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; ImageKitClient client = ImageKitOkHttpClient.builder() .fromEnv() @@ -778,10 +476,10 @@ The SDK consists of three artifacts: - `image-kit-java-core` - Contains core SDK logic - Does not depend on [OkHttp](https://square.github.io/okhttp) - - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client + - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client - `image-kit-java-client-okhttp` - Depends on [OkHttp](https://square.github.io/okhttp) - - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp + - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp - `image-kit-java` - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp` - Does not have its own logic @@ -796,16 +494,16 @@ This structure allows replacing the SDK's default HTTP client without pulling in To use a customized `OkHttpClient`: 1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core` -2. Copy `image-kit-java-client-okhttp`'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it -3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client +2. Copy `image-kit-java-client-okhttp`'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it +3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client ### Completely custom HTTP client To use a completely custom HTTP client: 1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core` -2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/http/HttpClient.kt) interface -3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/com/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/com/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class +2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpClient.kt) interface +3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class ## Undocumented API functionality @@ -816,8 +514,8 @@ The SDK is typed for convenient usage of the documented API. However, it also su To set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class: ```java -import com.imagekit.api.core.JsonValue; -import com.imagekit.api.models.files.FileUploadParams; +import io.imagekit.api.core.JsonValue; +import io.imagekit.api.models.files.FileUploadParams; FileUploadParams params = FileUploadParams.builder() .putAdditionalHeader("Secret-Header", "42") @@ -831,8 +529,8 @@ These can be accessed on the built object later using the `_additionalHeaders()` To set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class: ```java -import com.imagekit.api.core.JsonValue; -import com.imagekit.api.models.files.FileUploadParams; +import io.imagekit.api.core.JsonValue; +import io.imagekit.api.models.files.FileUploadParams; FileUploadParams params = FileUploadParams.builder() .transformation(FileUploadParams.UploadTransformation.builder() @@ -843,11 +541,11 @@ FileUploadParams params = FileUploadParams.builder() These properties can be accessed on the nested built object later using the `_additionalProperties()` method. -To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) object to its setter: +To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt) object to its setter: ```java -import com.imagekit.api.core.JsonValue; -import com.imagekit.api.models.files.FileUploadParams; +import io.imagekit.api.core.JsonValue; +import io.imagekit.api.models.files.FileUploadParams; FileUploadParams params = FileUploadParams.builder() .file(JsonValue.from(42)) @@ -855,10 +553,10 @@ FileUploadParams params = FileUploadParams.builder() .build(); ``` -The most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt) is using its `from(...)` method: +The most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt) is using its `from(...)` method: ```java -import com.imagekit.api.core.JsonValue; +import io.imagekit.api.core.JsonValue; import java.util.List; import java.util.Map; @@ -896,11 +594,11 @@ JsonValue complexValue = JsonValue.from(Map.of( Normally a `Builder` class's `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset. -To forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/com/imagekit/api/core/Values.kt): +To forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt): ```java -import com.imagekit.api.core.JsonMissing; -import com.imagekit.api.models.files.FileUploadParams; +import io.imagekit.api.core.JsonMissing; +import io.imagekit.api.models.files.FileUploadParams; FileUploadParams params = FileUploadParams.builder() .fileName("fileName") @@ -913,7 +611,7 @@ FileUploadParams params = FileUploadParams.builder() To access undocumented response properties, call the `_additionalProperties()` method: ```java -import com.imagekit.api.core.JsonValue; +import io.imagekit.api.core.JsonValue; import java.util.Map; Map additionalProperties = client.files().upload(params)._additionalProperties(); @@ -943,7 +641,7 @@ String result = secretPropertyValue.accept(new JsonValue.Visitor<>() { To access a property's raw JSON value, which may be undocumented, call its `_` prefixed method: ```java -import com.imagekit.api.core.JsonField; +import io.imagekit.api.core.JsonField; import java.io.InputStream; import java.util.Optional; @@ -967,12 +665,12 @@ if (file.isMissing()) { In rare cases, the API may return a response that doesn't match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else. -By default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/com/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property. +By default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property. If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`: ```java -import com.imagekit.api.models.files.FileUploadResponse; +import io.imagekit.api.models.files.FileUploadResponse; FileUploadResponse response = client.files().upload(params).validate(); ``` @@ -980,7 +678,7 @@ FileUploadResponse response = client.files().upload(params).validate(); Or configure the method call to validate the response using the `responseValidation` method: ```java -import com.imagekit.api.models.files.FileUploadResponse; +import io.imagekit.api.models.files.FileUploadResponse; FileUploadResponse response = client.files().upload( params, RequestOptions.builder().responseValidation(true).build() @@ -990,8 +688,8 @@ FileUploadResponse response = client.files().upload( Or configure the default for all method calls at the client level: ```java -import com.imagekit.api.client.ImageKitClient; -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.api.client.ImageKitClient; +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; ImageKitClient client = ImageKitOkHttpClient.builder() .fromEnv() diff --git a/build.gradle.kts b/build.gradle.kts index be2e1e8c..22c72257 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ repositories { } allprojects { - group = "io.imagekit.io" + group = "io.imagekit.api" version = "0.0.1" // x-release-please-version } diff --git a/buildSrc/src/main/kotlin/image-kit.java.gradle.kts b/buildSrc/src/main/kotlin/image-kit.java.gradle.kts index 0f1f0c0e..8f4f902a 100644 --- a/buildSrc/src/main/kotlin/image-kit.java.gradle.kts +++ b/buildSrc/src/main/kotlin/image-kit.java.gradle.kts @@ -10,7 +10,7 @@ repositories { java { toolchain { - languageVersion.set(JavaLanguageVersion.of(17)) + languageVersion.set(JavaLanguageVersion.of(21)) } sourceCompatibility = JavaVersion.VERSION_1_8 diff --git a/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts b/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts index ffb5e8d6..dd476783 100644 --- a/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts @@ -12,7 +12,7 @@ repositories { kotlin { jvmToolchain { - languageVersion.set(JavaLanguageVersion.of(17)) + languageVersion.set(JavaLanguageVersion.of(21)) } compilerOptions { diff --git a/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt similarity index 96% rename from image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClient.kt rename to image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt index 07f0ca84..249aa459 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClient.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.client.okhttp +package io.imagekit.api.client.okhttp import com.fasterxml.jackson.databind.json.JsonMapper -import io.imagekit.io.client.ImageKitClient -import io.imagekit.io.client.ImageKitClientImpl -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.Sleeper -import io.imagekit.io.core.Timeout -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.HttpClient -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.client.ImageKitClient +import io.imagekit.api.client.ImageKitClientImpl +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.Sleeper +import io.imagekit.api.core.Timeout +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.HttpClient +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.core.jsonMapper import java.net.Proxy import java.time.Clock import java.time.Duration @@ -179,7 +179,7 @@ class ImageKitOkHttpClient private constructor() { /** * The Jackson JSON mapper to use for serializing and deserializing JSON. * - * Defaults to [io.imagekit.io.core.jsonMapper]. The default is usually sufficient and + * Defaults to [io.imagekit.api.core.jsonMapper]. The default is usually sufficient and * rarely needs to be overridden. */ fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } diff --git a/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClientAsync.kt b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt similarity index 96% rename from image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClientAsync.kt rename to image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt index c8109c64..5923d63a 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/ImageKitOkHttpClientAsync.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.client.okhttp +package io.imagekit.api.client.okhttp import com.fasterxml.jackson.databind.json.JsonMapper -import io.imagekit.io.client.ImageKitClientAsync -import io.imagekit.io.client.ImageKitClientAsyncImpl -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.Sleeper -import io.imagekit.io.core.Timeout -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.HttpClient -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.client.ImageKitClientAsync +import io.imagekit.api.client.ImageKitClientAsyncImpl +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.Sleeper +import io.imagekit.api.core.Timeout +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.HttpClient +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.core.jsonMapper import java.net.Proxy import java.time.Clock import java.time.Duration @@ -179,7 +179,7 @@ class ImageKitOkHttpClientAsync private constructor() { /** * The Jackson JSON mapper to use for serializing and deserializing JSON. * - * Defaults to [io.imagekit.io.core.jsonMapper]. The default is usually sufficient and + * Defaults to [io.imagekit.api.core.jsonMapper]. The default is usually sufficient and * rarely needs to be overridden. */ fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } diff --git a/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/OkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/OkHttpClient.kt similarity index 96% rename from image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/OkHttpClient.kt rename to image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/OkHttpClient.kt index aa067ad3..bcbd305d 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/io/client/okhttp/OkHttpClient.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/OkHttpClient.kt @@ -1,14 +1,14 @@ -package io.imagekit.io.client.okhttp - -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.Timeout -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.HttpClient -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpRequestBody -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.errors.ImageKitIoException +package io.imagekit.api.client.okhttp + +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.Timeout +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.HttpClient +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpRequestBody +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.errors.ImageKitIoException import java.io.IOException import java.io.InputStream import java.net.Proxy diff --git a/image-kit-java-client-okhttp/src/test/kotlin/io/imagekit/io/client/okhttp/OkHttpClientTest.kt b/image-kit-java-client-okhttp/src/test/kotlin/io/imagekit/api/client/okhttp/OkHttpClientTest.kt similarity index 91% rename from image-kit-java-client-okhttp/src/test/kotlin/io/imagekit/io/client/okhttp/OkHttpClientTest.kt rename to image-kit-java-client-okhttp/src/test/kotlin/io/imagekit/api/client/okhttp/OkHttpClientTest.kt index a50e36c2..1ce7e04a 100644 --- a/image-kit-java-client-okhttp/src/test/kotlin/io/imagekit/io/client/okhttp/OkHttpClientTest.kt +++ b/image-kit-java-client-okhttp/src/test/kotlin/io/imagekit/api/client/okhttp/OkHttpClientTest.kt @@ -1,10 +1,10 @@ -package io.imagekit.io.client.okhttp +package io.imagekit.api.client.okhttp import com.github.tomakehurst.wiremock.client.WireMock.* import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/lib/Helper.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/lib/Helper.kt deleted file mode 100644 index 3829d852..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/lib/Helper.kt +++ /dev/null @@ -1,970 +0,0 @@ -// Package lib provides helper utilities for ImageKit SDK -// This file contains custom helper functions - not generated - -package com.imagekit.api.lib - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.models.SrcOptions -import com.imagekit.api.models.Transformation -import com.imagekit.api.models.TransformationPosition -import java.security.SecureRandom -import java.time.Instant -import javax.crypto.Mac -import javax.crypto.spec.SecretKeySpec - -/** - * Helper service containing utility methods for ImageKit SDK operations like URL building, - * transformation string generation, and authentication parameter generation. - */ -class Helper(private val privateKey: String) : HelperService { - - companion object { - private const val DEFAULT_TIMESTAMP = 9999999999L - - /** - * Creates a new Helper instance with the given private key. - * - * @param privateKey The private API key from ImageKit dashboard - * @return A new Helper instance - */ - @JvmStatic fun create(privateKey: String): Helper = Helper(privateKey) - - /** - * Creates a new Helper instance from ClientOptions. - * - * @param options The client options containing the private key - * @return A new Helper instance - */ - @JvmStatic fun create(options: ClientOptions): Helper = Helper(options.privateKey) - } - - /** - * Builds a URL with the given options including transformations. - * - * @param options The source options for URL generation - * @return The generated URL string - */ - override fun buildUrl(options: SrcOptions): String { - val urlEndpoint = options.urlEndpoint() - val src = options.src() - - if (src.isEmpty()) { - return "" - } - - val transformationPosition = - options.transformationPosition().orElse(TransformationPosition.QUERY) - - val isAbsoluteURL = src.startsWith("http://") || src.startsWith("https://") - - val urlObj: java.net.URL - val isSrcParameterUsedForURL: Boolean - - try { - if (!isAbsoluteURL) { - urlObj = java.net.URL(urlEndpoint) - isSrcParameterUsedForURL = false - } else { - urlObj = java.net.URL(src) - isSrcParameterUsedForURL = true - } - } catch (e: Exception) { - return "" - } - - // Extract existing query parameters from URL if present - val existingQuery = - if (isSrcParameterUsedForURL && urlObj.query != null) { - urlObj.query - } else { - "" - } - - // Build query parameters - val queryParts = mutableListOf() - - // Add existing query parameters first - if (existingQuery.isNotEmpty()) { - queryParts.add(existingQuery) - } - - // Add new query parameters (sorted alphabetically for consistent signing) - options.queryParameters().ifPresent { queryParams -> - val params = queryParams._additionalProperties() - if (params.isNotEmpty()) { - val newQuery = - params.entries - .sortedBy { it.key } // Sort alphabetically by key - .joinToString("&") { (key, value) -> - val valueStr = - value.asString().orElseGet { - value - .asNumber() - .map { it.toString() } - .orElseGet { - value - .asBoolean() - .map { it.toString() } - .orElse(value.toString()) - } - } - "${java.net.URLEncoder.encode(key, "UTF-8")}=${java.net.URLEncoder.encode(valueStr, "UTF-8")}" - } - queryParts.add(newQuery) - } - } - - val query = queryParts.joinToString("&") - - // Build transformation string - val transformationString = - options.transformation().map { buildTransformationString(it) }.orElse("") - - // Determine if transformation will be in query params - val addAsQuery = - transformationPosition == TransformationPosition.QUERY || isSrcParameterUsedForURL - - // Transformation placeholder to avoid URL encoding issues - val transformationPlaceholder = "PLEASEREPLACEJUSTBEFORESIGN" - - // Build the URL path - var path = "" - if (!isAbsoluteURL) { - // For non-absolute URLs, construct: endpoint_path + transformations + src - val endpointPath = urlObj.path.ifEmpty { "/" } - val pathParts = mutableListOf() - pathParts.add(endpointPath) - - if (transformationString.isNotEmpty() && !addAsQuery) { - pathParts.add("tr:$transformationPlaceholder") - } - pathParts.add(src) - - path = pathParts.joinToString("/") { it.trim('/') }.replace(Regex("/+"), "/") - if (!path.startsWith("/")) { - path = "/$path" - } - } else { - path = urlObj.path - } - - // Build the complete URL using URI to properly encode the path - val uriString = - try { - java.net - .URI( - urlObj.protocol, - null, // user info - urlObj.host, - if (urlObj.port != -1 && urlObj.port != urlObj.defaultPort) urlObj.port - else -1, - path, - null, // query will be added later - null, // fragment - ) - .toASCIIString() - } catch (e: Exception) { - // Fallback to manual construction - "${urlObj.protocol}://${urlObj.host}${if (urlObj.port != -1 && urlObj.port != urlObj.defaultPort) ":${urlObj.port}" else ""}$path" - } - - var finalURL = uriString - - // Add query parameters - if (query.isNotEmpty()) { - finalURL += "?$query" - } - - // Add transformation parameter to query if needed - if (transformationString.isNotEmpty() && addAsQuery) { - val separator = if (query.isEmpty()) "?" else "&" - finalURL += "${separator}tr=$transformationPlaceholder" - } - - // Replace the placeholder with actual transformation string - if (transformationString.isNotEmpty()) { - finalURL = finalURL.replace(transformationPlaceholder, transformationString) - } - - // Sign the URL if needed - val shouldSign = options.signed().orElse(false) || (options.expiresIn().orElse(0.0) > 0) - if (shouldSign) { - val expiryTimestamp = getSignatureTimestamp(options.expiresIn().orElse(0.0)) - val urlSignature = getSignature(finalURL, urlEndpoint, expiryTimestamp) - - val hasExistingParams = finalURL.contains("?") - val separator = if (hasExistingParams) "&" else "?" - - if (expiryTimestamp != DEFAULT_TIMESTAMP) { - finalURL += "${separator}ik-t=$expiryTimestamp&ik-s=$urlSignature" - } else { - finalURL += "${separator}ik-s=$urlSignature" - } - } - - return finalURL - } - - private fun getSignatureTimestamp(expiresIn: Double): Long { - return if (expiresIn > 0) { - Instant.now().epochSecond + expiresIn.toLong() - } else { - DEFAULT_TIMESTAMP - } - } - - private fun getSignature(finalURL: String, urlEndpoint: String, expiryTimestamp: Long): String { - if (privateKey.isEmpty() || finalURL.isEmpty() || urlEndpoint.isEmpty()) { - return "" - } - - // Create the string to sign: relative path + expiry timestamp - val urlEndpointWithSlash = if (urlEndpoint.endsWith("/")) urlEndpoint else "$urlEndpoint/" - val stringToSign = - finalURL.replaceFirst(urlEndpointWithSlash, "") + expiryTimestamp.toString() - - val mac = Mac.getInstance("HmacSHA1") - val secretKey = SecretKeySpec(privateKey.toByteArray(), "HmacSHA1") - mac.init(secretKey) - val hash = mac.doFinal(stringToSign.toByteArray()) - - return hash.joinToString("") { "%02x".format(it) } - } - - /** - * Builds a transformation string from the given transformations. - * - * @param transformations The list of transformations - * @return The transformation string - */ - override fun buildTransformationString(transformations: List?): String { - if (transformations.isNullOrEmpty()) { - return "" - } - - val parsedTransforms = mutableListOf() - - for (transform in transformations) { - val parts = mutableListOf() - - // Basic transformations (in order from Go SDK) - - // Width - transform.width().ifPresent { w -> - when { - w.isNumber() -> parts.add("w-${formatNumber(w.asNumber())}") - w.isString() -> parts.add("w-${w.asString()}") - } - } - - // Height - transform.height().ifPresent { h -> - when { - h.isNumber() -> parts.add("h-${formatNumber(h.asNumber())}") - h.isString() -> parts.add("h-${h.asString()}") - } - } - - // Quality - transform.quality().ifPresent { q -> parts.add("q-${formatNumber(q)}") } - - // Aspect Ratio - transform.aspectRatio().ifPresent { ar -> - when { - ar.isNumber() -> parts.add("ar-${formatNumber(ar.asNumber())}") - ar.isString() -> parts.add("ar-${ar.asString()}") - } - } - - // Crop - transform.crop().ifPresent { c -> if (c.toString().isNotEmpty()) parts.add("c-$c") } - - // Crop Mode - transform.cropMode().ifPresent { cm -> - if (cm.toString().isNotEmpty()) parts.add("cm-$cm") - } - - // Focus - transform.focus().ifPresent { fo -> parts.add("fo-$fo") } - - // Format - transform.format().ifPresent { f -> if (f.toString().isNotEmpty()) parts.add("f-$f") } - - // Radius - transform.radius().ifPresent { r -> - when { - r.isMax() -> parts.add("r-max") - r.isNumber() -> parts.add("r-${formatNumber(r.asNumber())}") - r.isString() -> parts.add("r-${r.asString()}") - } - } - - // Background - transform.background().ifPresent { bg -> parts.add("bg-$bg") } - - // Border - transform.border().ifPresent { b -> parts.add("b-$b") } - - // Color Replace - transform.colorReplace().ifPresent { cr -> parts.add("cr-$cr") } - - // Default Image - transform.defaultImage().ifPresent { di -> - if (di.isNotEmpty()) { - val value = di.removePrefix("/").removeSuffix("/").replace("/", "@@") - parts.add("di-$value") - } - } - - // DPR - transform.dpr().ifPresent { dpr -> parts.add("dpr-${formatNumber(dpr)}") } - - // X position - transform.x().ifPresent { x -> - when { - x.isNumber() -> parts.add("x-${formatNumber(x.asNumber())}") - x.isString() -> parts.add("x-${x.asString()}") - } - } - - // Y position - transform.y().ifPresent { y -> - when { - y.isNumber() -> parts.add("y-${formatNumber(y.asNumber())}") - y.isString() -> parts.add("y-${y.asString()}") - } - } - - // X Center - transform.xCenter().ifPresent { xc -> - when { - xc.isNumber() -> parts.add("xc-${formatNumber(xc.asNumber())}") - xc.isString() -> parts.add("xc-${xc.asString()}") - } - } - - // Y Center - transform.yCenter().ifPresent { yc -> - when { - yc.isNumber() -> parts.add("yc-${formatNumber(yc.asNumber())}") - yc.isString() -> parts.add("yc-${yc.asString()}") - } - } - - // Opacity - transform.opacity().ifPresent { o -> parts.add("o-${formatNumber(o)}") } - - // Zoom - transform.zoom().ifPresent { z -> parts.add("z-${formatNumber(z)}") } - - // Rotation - transform.rotation().ifPresent { rt -> - when { - rt.isNumber() -> parts.add("rt-${formatNumber(rt.asNumber())}") - rt.isString() -> parts.add("rt-${rt.asString()}") - } - } - - // Blur - transform.blur().ifPresent { bl -> parts.add("bl-${formatNumber(bl)}") } - - // Named - transform.named().ifPresent { n -> parts.add("n-$n") } - - // Progressive - transform.progressive().ifPresent { pr -> parts.add("pr-$pr") } - - // Lossless - transform.lossless().ifPresent { lo -> parts.add("lo-$lo") } - - // Flip - transform.flip().ifPresent { fl -> if (fl.toString().isNotEmpty()) parts.add("fl-$fl") } - - // Trim - transform.trim().ifPresent { t -> - when { - t.isTrue() -> parts.add("t-true") - t.isNumber() -> parts.add("t-${formatNumber(t.asNumber())}") - } - } - - // Metadata - transform.metadata().ifPresent { md -> parts.add("md-$md") } - - // Color Profile - transform.colorProfile().ifPresent { cp -> parts.add("cp-$cp") } - - // Video Codec - transform.videoCodec().ifPresent { vc -> - if (vc.toString().isNotEmpty()) parts.add("vc-$vc") - } - - // Audio Codec - transform.audioCodec().ifPresent { ac -> - if (ac.toString().isNotEmpty()) parts.add("ac-$ac") - } - - // Start Offset - transform.startOffset().ifPresent { so -> - when { - so.isNumber() -> parts.add("so-${formatNumber(so.asNumber())}") - so.isString() -> parts.add("so-${so.asString()}") - } - } - - // End Offset - transform.endOffset().ifPresent { eo -> - when { - eo.isNumber() -> parts.add("eo-${formatNumber(eo.asNumber())}") - eo.isString() -> parts.add("eo-${eo.asString()}") - } - } - - // Duration - transform.duration().ifPresent { du -> - when { - du.isNumber() -> parts.add("du-${formatNumber(du.asNumber())}") - du.isString() -> parts.add("du-${du.asString()}") - } - } - - // Streaming Resolutions - transform.streamingResolutions().ifPresent { resolutions -> - if (resolutions.isNotEmpty()) { - val sr = resolutions.joinToString("_") - parts.add("sr-$sr") - } - } - - // AI transformations (boolean flags) - transform.grayscale().ifPresent { gs -> if (gs.asBoolean()) parts.add("e-grayscale") } - transform.aiUpscale().ifPresent { au -> if (au.asBoolean()) parts.add("e-upscale") } - transform.aiRetouch().ifPresent { ar -> if (ar.asBoolean()) parts.add("e-retouch") } - transform.aiVariation().ifPresent { av -> if (av.asBoolean()) parts.add("e-genvar") } - transform.aiRemoveBackground().ifPresent { rb -> - if (rb.asBoolean()) parts.add("e-bgremove") - } - transform.aiRemoveBackgroundExternal().ifPresent { re -> - if (re.asBoolean()) parts.add("e-removedotbg") - } - transform.contrastStretch().ifPresent { cs -> - if (cs.asBoolean()) parts.add("e-contrast") - } - - // AI Drop Shadow - transform.aiDropShadow().ifPresent { ds -> - when { - ds.isTrue() -> parts.add("e-dropshadow") - ds.isString() -> parts.add("e-dropshadow-${ds.asString()}") - } - } - - // AI Change Background - transform.aiChangeBackground().ifPresent { bg -> parts.add("e-changebg-$bg") } - - // AI Edit - transform.aiEdit().ifPresent { edit -> parts.add("e-edit-$edit") } - - // Effects - transform.shadow().ifPresent { s -> - when { - s.isTrue() -> parts.add("e-shadow") - s.isString() -> parts.add("e-shadow-${s.asString()}") - } - } - - transform.sharpen().ifPresent { sh -> - when { - sh.isTrue() -> parts.add("e-sharpen") - sh.isNumber() -> parts.add("e-sharpen-${formatNumber(sh.asNumber())}") - } - } - - transform.unsharpMask().ifPresent { usm -> - when { - usm.isTrue() -> parts.add("e-usm") - usm.isString() -> parts.add("e-usm-${usm.asString()}") - } - } - - transform.gradient().ifPresent { gr -> - when { - gr.isTrue() -> parts.add("e-gradient") - gr.isString() -> parts.add("e-gradient-${gr.asString()}") - } - } - - transform.distort().ifPresent { d -> parts.add("e-distort-$d") } - - // Original - transform.original().ifPresent { orig -> if (orig) parts.add("orig-true") } - - // Page - transform.page().ifPresent { pg -> - when { - pg.isNumber() -> parts.add("pg-${formatNumber(pg.asNumber())}") - pg.isString() -> parts.add("pg-${pg.asString()}") - } - } - - // Overlay - transform.overlay().ifPresent { overlay -> - val overlayStr = processOverlay(overlay) - if (overlayStr.isNotEmpty()) { - parts.add(overlayStr) - } - } - - // Raw parameter (added last) - transform.raw().ifPresent { raw -> - if (raw.isNotEmpty()) { - parts.add(raw) - } - } - - if (parts.isNotEmpty()) { - parsedTransforms.add(parts.joinToString(",")) - } - } - - return parsedTransforms.joinToString(":") - } - - private fun formatNumber(value: Double): String { - return if (value == value.toLong().toDouble()) { - value.toLong().toString() - } else { - value.toString() - } - } - - private val simpleOverlayPathRegex = Regex("^[a-zA-Z0-9\\-._/ ]*$") - private val simpleOverlayTextRegex = Regex("^[a-zA-Z0-9\\-._ ]*$") - - private fun processOverlay(overlay: com.imagekit.api.models.Overlay): String { - val entries = mutableListOf() - var transformationString = "" - - // Each branch: add layer type + input, extract base overlay fields, build transformation - // string - var layerMode: String? = null - var position: com.imagekit.api.models.OverlayPosition? = null - var timing: com.imagekit.api.models.OverlayTiming? = null - - when { - overlay.isText() -> { - val textOverlay = overlay.asText() - if (textOverlay.text().isEmpty()) return "" - - val encoding = - textOverlay.encoding().orElse(null)?.toString()?.lowercase() ?: "auto" - entries.add("l-text") - entries.add(processText(textOverlay.text(), encoding)) - - textOverlay.layerMode().ifPresent { layerMode = it.toString().lowercase() } - textOverlay.position().ifPresent { position = it } - textOverlay.timing().ifPresent { timing = it } - - textOverlay.transformation().ifPresent { transformations -> - if (transformations.isNotEmpty()) { - transformationString = buildTextOverlayTransformation(transformations) - } - } - } - - overlay.isImage() -> { - val imageOverlay = overlay.asImage() - if (imageOverlay.input().isEmpty()) return "" - - val encoding = - imageOverlay.encoding().orElse(null)?.toString()?.lowercase() ?: "auto" - entries.add("l-image") - entries.add(processInputPath(imageOverlay.input(), encoding)) - - imageOverlay.layerMode().ifPresent { layerMode = it.toString().lowercase() } - imageOverlay.position().ifPresent { position = it } - imageOverlay.timing().ifPresent { timing = it } - - imageOverlay.transformation().ifPresent { transformations -> - if (transformations.isNotEmpty()) { - transformationString = buildTransformationString(transformations) - } - } - } - - overlay.isVideo() -> { - val videoOverlay = overlay.asVideo() - if (videoOverlay.input().isEmpty()) return "" - - val encoding = - videoOverlay.encoding().orElse(null)?.toString()?.lowercase() ?: "auto" - entries.add("l-video") - entries.add(processInputPath(videoOverlay.input(), encoding)) - - videoOverlay.layerMode().ifPresent { layerMode = it.toString().lowercase() } - videoOverlay.position().ifPresent { position = it } - videoOverlay.timing().ifPresent { timing = it } - - videoOverlay.transformation().ifPresent { transformations -> - if (transformations.isNotEmpty()) { - transformationString = buildTransformationString(transformations) - } - } - } - - overlay.isSubtitle() -> { - val subtitleOverlay = overlay.asSubtitle() - if (subtitleOverlay.input().isEmpty()) return "" - - val encoding = - subtitleOverlay.encoding().orElse(null)?.toString()?.lowercase() ?: "auto" - entries.add("l-subtitles") - entries.add(processInputPath(subtitleOverlay.input(), encoding)) - - subtitleOverlay.layerMode().ifPresent { layerMode = it.toString().lowercase() } - subtitleOverlay.position().ifPresent { position = it } - subtitleOverlay.timing().ifPresent { timing = it } - - subtitleOverlay.transformation().ifPresent { transformations -> - if (transformations.isNotEmpty()) { - transformationString = buildSubtitleOverlayTransformation(transformations) - } - } - } - - overlay.isSolidColor() -> { - val solidColorOverlay = overlay.asSolidColor() - if (solidColorOverlay.color().isEmpty()) return "" - - entries.add("l-image") - entries.add("i-ik_canvas") - entries.add("bg-${solidColorOverlay.color()}") - - solidColorOverlay.layerMode().ifPresent { layerMode = it.toString().lowercase() } - solidColorOverlay.position().ifPresent { position = it } - solidColorOverlay.timing().ifPresent { timing = it } - - solidColorOverlay.transformation().ifPresent { transformations -> - if (transformations.isNotEmpty()) { - transformationString = buildSolidColorOverlayTransformation(transformations) - } - } - } - } - - if (entries.isEmpty()) return "" - - // Shared base overlay processing (matches Go's order) - // LayerMode - if (!layerMode.isNullOrEmpty()) { - entries.add("lm-$layerMode") - } - - // Position - if (position != null) { - processOverlayPosition(position!!, entries) - } - - // Timing - if (timing != null) { - processOverlayTiming(timing!!, entries) - } - - // Transformation string - if (transformationString.isNotEmpty()) { - entries.add(transformationString) - } - - // Close layer - entries.add("l-end") - return entries.joinToString(",") - } - - private fun processInputPath(str: String, encoding: String): String { - val cleaned = str.removePrefix("/").removeSuffix("/") - - if (encoding == "plain") { - return "i-${cleaned.replace("/", "@@")}" - } - - if (encoding == "base64") { - val base64 = java.util.Base64.getEncoder().encodeToString(cleaned.toByteArray()) - return "ie-${java.net.URLEncoder.encode(base64, "UTF-8")}" - } - - // Auto-detect - if (simpleOverlayPathRegex.matches(cleaned)) { - return "i-${cleaned.replace("/", "@@")}" - } - - val base64 = java.util.Base64.getEncoder().encodeToString(cleaned.toByteArray()) - return "ie-${java.net.URLEncoder.encode(base64, "UTF-8")}" - } - - private fun processText(str: String, encoding: String): String { - if (encoding == "plain") { - return "i-${pathEscape(str)}" - } - - if (encoding == "base64") { - val base64 = java.util.Base64.getEncoder().encodeToString(str.toByteArray()) - return "ie-${java.net.URLEncoder.encode(base64, "UTF-8")}" - } - - // Auto-detect - if (simpleOverlayTextRegex.matches(str)) { - return "i-${pathEscape(str)}" - } - - val base64 = java.util.Base64.getEncoder().encodeToString(str.toByteArray()) - return "ie-${java.net.URLEncoder.encode(base64, "UTF-8")}" - } - - /** Equivalent to Go's url.PathEscape — encodes for use in URL path segments */ - private fun pathEscape(str: String): String { - return java.net.URI(null, null, "/$str", null).toASCIIString().removePrefix("/") - } - - private fun buildTextOverlayTransformation( - transformations: List - ): String { - val entries = mutableListOf() - for (transform in transformations) { - processTextOverlayTransformation(transform, entries) - } - return entries.joinToString(",") - } - - private fun buildSubtitleOverlayTransformation( - transformations: List - ): String { - val entries = mutableListOf() - for (transform in transformations) { - processSubtitleOverlayTransformation(transform, entries) - } - return entries.joinToString(",") - } - - private fun buildSolidColorOverlayTransformation( - transformations: List - ): String { - val entries = mutableListOf() - for (transform in transformations) { - processSolidColorOverlayTransformation(transform, entries) - } - return entries.joinToString(",") - } - - private fun processTextOverlayTransformation( - transform: com.imagekit.api.models.TextOverlayTransformation, - parts: MutableList, - ) { - transform.width().ifPresent { w -> - when { - w.isNumber() -> parts.add("w-${formatNumber(w.asNumber())}") - w.isString() -> parts.add("w-${w.asString()}") - } - } - transform.fontSize().ifPresent { fs -> - when { - fs.isNumber() -> parts.add("fs-${formatNumber(fs.asNumber())}") - fs.isString() -> parts.add("fs-${fs.asString()}") - } - } - transform.fontFamily().ifPresent { ff -> - val cleaned = ff.removePrefix("/").removeSuffix("/").replace("/", "@@") - parts.add("ff-$cleaned") - } - transform.fontColor().ifPresent { fc -> parts.add("co-$fc") } - transform.innerAlignment().ifPresent { ia -> parts.add("ia-${ia.toString().lowercase()}") } - transform.padding().ifPresent { p -> - when { - p.isNumber() -> parts.add("pa-${formatNumber(p.asNumber())}") - p.isString() -> parts.add("pa-${p.asString()}") - } - } - transform.alpha().ifPresent { a -> parts.add("al-${formatNumber(a)}") } - transform.typography().ifPresent { t -> parts.add("tg-$t") } - transform.background().ifPresent { bg -> parts.add("bg-$bg") } - transform.radius().ifPresent { r -> - when { - r.isMax() -> parts.add("r-max") - r.isNumber() -> parts.add("r-${formatNumber(r.asNumber())}") - r.isString() -> parts.add("r-${r.asString()}") - } - } - transform.rotation().ifPresent { rt -> - when { - rt.isNumber() -> parts.add("rt-${formatNumber(rt.asNumber())}") - rt.isString() -> parts.add("rt-${rt.asString()}") - } - } - transform.flip().ifPresent { fl -> parts.add("fl-${fl.toString().lowercase()}") } - transform.lineHeight().ifPresent { lh -> - when { - lh.isNumber() -> parts.add("lh-${formatNumber(lh.asNumber())}") - lh.isString() -> parts.add("lh-${lh.asString()}") - } - } - } - - private fun processSolidColorOverlayTransformation( - transform: com.imagekit.api.models.SolidColorOverlayTransformation, - parts: MutableList, - ) { - transform.width().ifPresent { w -> - when { - w.isNumber() -> parts.add("w-${formatNumber(w.asNumber())}") - w.isString() -> parts.add("w-${w.asString()}") - } - } - transform.height().ifPresent { h -> - when { - h.isNumber() -> parts.add("h-${formatNumber(h.asNumber())}") - h.isString() -> parts.add("h-${h.asString()}") - } - } - transform.alpha().ifPresent { a -> parts.add("al-${formatNumber(a)}") } - transform.background().ifPresent { bg -> parts.add("bg-$bg") } - transform.gradient().ifPresent { g -> - when { - g.isTrue() -> parts.add("e-gradient") - g.isString() -> parts.add("e-gradient-${g.asString()}") - } - } - transform.radius().ifPresent { r -> - when { - r.isMax() -> parts.add("r-max") - r.isNumber() -> parts.add("r-${formatNumber(r.asNumber())}") - r.isString() -> parts.add("r-${r.asString()}") - } - } - } - - private fun processSubtitleOverlayTransformation( - transform: com.imagekit.api.models.SubtitleOverlayTransformation, - parts: MutableList, - ) { - transform.background().ifPresent { bg -> parts.add("bg-$bg") } - transform.color().ifPresent { c -> parts.add("co-$c") } - transform.fontSize().ifPresent { fs -> parts.add("fs-${formatNumber(fs)}") } - transform.fontFamily().ifPresent { ff -> parts.add("ff-$ff") } - transform.fontOutline().ifPresent { fo -> parts.add("fol-$fo") } - transform.fontShadow().ifPresent { fs -> parts.add("fsh-$fs") } - transform.typography().ifPresent { tg -> parts.add("tg-$tg") } - } - - private fun processOverlayPosition( - position: com.imagekit.api.models.OverlayPosition, - parts: MutableList, - ) { - position.x().ifPresent { x -> - when { - x.isNumber() -> parts.add("lx-${formatNumber(x.asNumber())}") - x.isString() -> parts.add("lx-${x.asString()}") - } - } - position.y().ifPresent { y -> - when { - y.isNumber() -> parts.add("ly-${formatNumber(y.asNumber())}") - y.isString() -> parts.add("ly-${y.asString()}") - } - } - position.xCenter().ifPresent { xc -> - when { - xc.isNumber() -> parts.add("lxc-${formatNumber(xc.asNumber())}") - xc.isString() -> parts.add("lxc-${xc.asString()}") - } - } - position.yCenter().ifPresent { yc -> - when { - yc.isNumber() -> parts.add("lyc-${formatNumber(yc.asNumber())}") - yc.isString() -> parts.add("lyc-${yc.asString()}") - } - } - position.anchorPoint().ifPresent { ap -> parts.add("lap-${ap.toString().lowercase()}") } - position.focus().ifPresent { f -> parts.add("lfo-${f.toString().lowercase()}") } - } - - private fun processOverlayTiming( - timing: com.imagekit.api.models.OverlayTiming, - parts: MutableList, - ) { - timing.start().ifPresent { s -> - when { - s.isNumber() -> parts.add("lso-${formatNumber(s.asNumber())}") - s.isString() -> parts.add("lso-${s.asString()}") - } - } - timing.end().ifPresent { e -> - when { - e.isNumber() -> parts.add("leo-${formatNumber(e.asNumber())}") - e.isString() -> parts.add("leo-${e.asString()}") - } - } - timing.duration().ifPresent { d -> - when { - d.isNumber() -> parts.add("ldu-${formatNumber(d.asNumber())}") - d.isString() -> parts.add("ldu-${d.asString()}") - } - } - } - - /** - * Generates authentication parameters for client-side file uploads. - * - * @param token Optional custom token. If null or empty, a random token will be generated. - * @param expire Optional expiration timestamp in seconds. If 0 or null, defaults to 30 minutes - * from now. - * @return Map containing token, expire, and signature - */ - override fun getAuthenticationParameters(token: String?, expire: Long?): Map { - if (privateKey.isEmpty()) { - throw IllegalStateException( - "private API key is required for authentication parameters generation" - ) - } - - val defaultExpire = Instant.now().epochSecond + (60 * 30) // 30 minutes - val finalToken = - if (token.isNullOrEmpty()) { - generateToken() - } else { - token - } - - val finalExpire = - if (expire == null || expire == 0L) { - defaultExpire - } else { - expire - } - - val signature = getAuthenticationSignature(finalToken, finalExpire, privateKey) - - return mapOf("token" to finalToken, "expire" to finalExpire, "signature" to signature) - } - - // Private helper methods - - private fun getAuthenticationSignature( - token: String, - expire: Long, - privateKey: String, - ): String { - val signatureString = "$token$expire" - val mac = Mac.getInstance("HmacSHA1") - val secretKey = SecretKeySpec(privateKey.toByteArray(), "HmacSHA1") - mac.init(secretKey) - val hash = mac.doFinal(signatureString.toByteArray()) - - return hash.joinToString("") { "%02x".format(it) } - } - - private fun generateToken(): String { - val random = SecureRandom() - val bytes = ByteArray(16) - random.nextBytes(bytes) - return bytes.joinToString("") { "%02x".format(it) } - } -} diff --git a/image-kit-java-core/src/main/kotlin/com/imagekit/api/lib/HelperService.kt b/image-kit-java-core/src/main/kotlin/com/imagekit/api/lib/HelperService.kt deleted file mode 100644 index 93ab4792..00000000 --- a/image-kit-java-core/src/main/kotlin/com/imagekit/api/lib/HelperService.kt +++ /dev/null @@ -1,26 +0,0 @@ -package com.imagekit.api.lib - -import com.imagekit.api.models.SrcOptions -import com.imagekit.api.models.Transformation - -/** - * Helper service interface for ImageKit SDK operations like URL building, transformation string - * generation, and authentication parameter generation. - * - * You should not instantiate this service directly, and instead use it via the client: - * ```java - * ImageKitClient client = ImageKitOkHttpClient.builder() - * .privateKey("private_key_xxx") - * .build(); - * - * String url = client.helper().buildUrl(srcOptions); - * ``` - */ -interface HelperService { - - fun buildUrl(options: SrcOptions): String - - fun buildTransformationString(transformations: List?): String - - fun getAuthenticationParameters(token: String? = null, expire: Long? = null): Map -} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClient.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClient.kt similarity index 83% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClient.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClient.kt index 020c96db..891ec0ce 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClient.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClient.kt @@ -1,18 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.client - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.lib.HelperService -import com.imagekit.api.services.blocking.AccountService -import com.imagekit.api.services.blocking.AssetService -import com.imagekit.api.services.blocking.BetaService -import com.imagekit.api.services.blocking.CacheService -import com.imagekit.api.services.blocking.CustomMetadataFieldService -import com.imagekit.api.services.blocking.FileService -import com.imagekit.api.services.blocking.FolderService -import com.imagekit.api.services.blocking.SavedExtensionService -import com.imagekit.api.services.blocking.WebhookService +package io.imagekit.api.client + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.services.blocking.AccountService +import io.imagekit.api.services.blocking.AssetService +import io.imagekit.api.services.blocking.BetaService +import io.imagekit.api.services.blocking.CacheService +import io.imagekit.api.services.blocking.CustomMetadataFieldService +import io.imagekit.api.services.blocking.FileService +import io.imagekit.api.services.blocking.FolderService +import io.imagekit.api.services.blocking.SavedExtensionService +import io.imagekit.api.services.blocking.WebhookService import java.util.function.Consumer /** @@ -69,8 +68,6 @@ interface ImageKitClient { fun webhooks(): WebhookService - fun helper(): HelperService - /** * Closes this client, relinquishing any underlying resources. * diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsync.kt similarity index 83% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsync.kt index efacb147..40d641b7 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsync.kt @@ -1,18 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.client - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.lib.HelperService -import com.imagekit.api.services.async.AccountServiceAsync -import com.imagekit.api.services.async.AssetServiceAsync -import com.imagekit.api.services.async.BetaServiceAsync -import com.imagekit.api.services.async.CacheServiceAsync -import com.imagekit.api.services.async.CustomMetadataFieldServiceAsync -import com.imagekit.api.services.async.FileServiceAsync -import com.imagekit.api.services.async.FolderServiceAsync -import com.imagekit.api.services.async.SavedExtensionServiceAsync -import com.imagekit.api.services.async.WebhookServiceAsync +package io.imagekit.api.client + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.services.async.AccountServiceAsync +import io.imagekit.api.services.async.AssetServiceAsync +import io.imagekit.api.services.async.BetaServiceAsync +import io.imagekit.api.services.async.CacheServiceAsync +import io.imagekit.api.services.async.CustomMetadataFieldServiceAsync +import io.imagekit.api.services.async.FileServiceAsync +import io.imagekit.api.services.async.FolderServiceAsync +import io.imagekit.api.services.async.SavedExtensionServiceAsync +import io.imagekit.api.services.async.WebhookServiceAsync import java.util.function.Consumer /** @@ -69,8 +68,6 @@ interface ImageKitClientAsync { fun webhooks(): WebhookServiceAsync - fun helper(): HelperService - /** * Closes this client, relinquishing any underlying resources. * diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt similarity index 79% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt index 48d3a864..ed596c22 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt @@ -1,29 +1,27 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.client - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.getPackageVersion -import com.imagekit.api.lib.Helper -import com.imagekit.api.lib.HelperService -import com.imagekit.api.services.async.AccountServiceAsync -import com.imagekit.api.services.async.AccountServiceAsyncImpl -import com.imagekit.api.services.async.AssetServiceAsync -import com.imagekit.api.services.async.AssetServiceAsyncImpl -import com.imagekit.api.services.async.BetaServiceAsync -import com.imagekit.api.services.async.BetaServiceAsyncImpl -import com.imagekit.api.services.async.CacheServiceAsync -import com.imagekit.api.services.async.CacheServiceAsyncImpl -import com.imagekit.api.services.async.CustomMetadataFieldServiceAsync -import com.imagekit.api.services.async.CustomMetadataFieldServiceAsyncImpl -import com.imagekit.api.services.async.FileServiceAsync -import com.imagekit.api.services.async.FileServiceAsyncImpl -import com.imagekit.api.services.async.FolderServiceAsync -import com.imagekit.api.services.async.FolderServiceAsyncImpl -import com.imagekit.api.services.async.SavedExtensionServiceAsync -import com.imagekit.api.services.async.SavedExtensionServiceAsyncImpl -import com.imagekit.api.services.async.WebhookServiceAsync -import com.imagekit.api.services.async.WebhookServiceAsyncImpl +package io.imagekit.api.client + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.getPackageVersion +import io.imagekit.api.services.async.AccountServiceAsync +import io.imagekit.api.services.async.AccountServiceAsyncImpl +import io.imagekit.api.services.async.AssetServiceAsync +import io.imagekit.api.services.async.AssetServiceAsyncImpl +import io.imagekit.api.services.async.BetaServiceAsync +import io.imagekit.api.services.async.BetaServiceAsyncImpl +import io.imagekit.api.services.async.CacheServiceAsync +import io.imagekit.api.services.async.CacheServiceAsyncImpl +import io.imagekit.api.services.async.CustomMetadataFieldServiceAsync +import io.imagekit.api.services.async.CustomMetadataFieldServiceAsyncImpl +import io.imagekit.api.services.async.FileServiceAsync +import io.imagekit.api.services.async.FileServiceAsyncImpl +import io.imagekit.api.services.async.FolderServiceAsync +import io.imagekit.api.services.async.FolderServiceAsyncImpl +import io.imagekit.api.services.async.SavedExtensionServiceAsync +import io.imagekit.api.services.async.SavedExtensionServiceAsyncImpl +import io.imagekit.api.services.async.WebhookServiceAsync +import io.imagekit.api.services.async.WebhookServiceAsyncImpl import java.util.function.Consumer class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageKitClientAsync { @@ -75,8 +73,6 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK WebhookServiceAsyncImpl(clientOptionsWithUserAgent) } - private val helper: Helper by lazy { Helper.create(clientOptions) } - override fun sync(): ImageKitClient = sync override fun withRawResponse(): ImageKitClientAsync.WithRawResponse = withRawResponse @@ -102,8 +98,6 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK override fun webhooks(): WebhookServiceAsync = webhooks - override fun helper(): HelperService = helper - override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt similarity index 78% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt index c47a5db0..d976c665 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/client/ImageKitClientImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt @@ -1,29 +1,27 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.client - -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.getPackageVersion -import com.imagekit.api.lib.Helper -import com.imagekit.api.lib.HelperService -import com.imagekit.api.services.blocking.AccountService -import com.imagekit.api.services.blocking.AccountServiceImpl -import com.imagekit.api.services.blocking.AssetService -import com.imagekit.api.services.blocking.AssetServiceImpl -import com.imagekit.api.services.blocking.BetaService -import com.imagekit.api.services.blocking.BetaServiceImpl -import com.imagekit.api.services.blocking.CacheService -import com.imagekit.api.services.blocking.CacheServiceImpl -import com.imagekit.api.services.blocking.CustomMetadataFieldService -import com.imagekit.api.services.blocking.CustomMetadataFieldServiceImpl -import com.imagekit.api.services.blocking.FileService -import com.imagekit.api.services.blocking.FileServiceImpl -import com.imagekit.api.services.blocking.FolderService -import com.imagekit.api.services.blocking.FolderServiceImpl -import com.imagekit.api.services.blocking.SavedExtensionService -import com.imagekit.api.services.blocking.SavedExtensionServiceImpl -import com.imagekit.api.services.blocking.WebhookService -import com.imagekit.api.services.blocking.WebhookServiceImpl +package io.imagekit.api.client + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.getPackageVersion +import io.imagekit.api.services.blocking.AccountService +import io.imagekit.api.services.blocking.AccountServiceImpl +import io.imagekit.api.services.blocking.AssetService +import io.imagekit.api.services.blocking.AssetServiceImpl +import io.imagekit.api.services.blocking.BetaService +import io.imagekit.api.services.blocking.BetaServiceImpl +import io.imagekit.api.services.blocking.CacheService +import io.imagekit.api.services.blocking.CacheServiceImpl +import io.imagekit.api.services.blocking.CustomMetadataFieldService +import io.imagekit.api.services.blocking.CustomMetadataFieldServiceImpl +import io.imagekit.api.services.blocking.FileService +import io.imagekit.api.services.blocking.FileServiceImpl +import io.imagekit.api.services.blocking.FolderService +import io.imagekit.api.services.blocking.FolderServiceImpl +import io.imagekit.api.services.blocking.SavedExtensionService +import io.imagekit.api.services.blocking.SavedExtensionServiceImpl +import io.imagekit.api.services.blocking.WebhookService +import io.imagekit.api.services.blocking.WebhookServiceImpl import java.util.function.Consumer class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitClient { @@ -65,8 +63,6 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli private val webhooks: WebhookService by lazy { WebhookServiceImpl(clientOptionsWithUserAgent) } - private val helper: Helper by lazy { Helper.create(clientOptions) } - override fun async(): ImageKitClientAsync = async override fun withRawResponse(): ImageKitClient.WithRawResponse = withRawResponse @@ -92,8 +88,6 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli override fun webhooks(): WebhookService = webhooks - override fun helper(): HelperService = helper - override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/BaseDeserializer.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/BaseDeserializer.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/BaseDeserializer.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/BaseDeserializer.kt index 54a1d03c..11845068 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/BaseDeserializer.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/BaseDeserializer.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.core +package io.imagekit.api.core import com.fasterxml.jackson.core.JsonParser import com.fasterxml.jackson.core.ObjectCodec diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/BaseSerializer.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/BaseSerializer.kt similarity index 85% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/BaseSerializer.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/BaseSerializer.kt index f2cd60ff..d5fe1b5b 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/BaseSerializer.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/BaseSerializer.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.core +package io.imagekit.api.core import com.fasterxml.jackson.databind.ser.std.StdSerializer import kotlin.reflect.KClass diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Check.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Check.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Check.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Check.kt index 8a3145f3..43cc495d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Check.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Check.kt @@ -1,6 +1,6 @@ @file:JvmName("Check") -package io.imagekit.io.core +package io.imagekit.api.core import com.fasterxml.jackson.core.Version import com.fasterxml.jackson.core.util.VersionUtil diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/ClientOptions.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/ClientOptions.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/ClientOptions.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/ClientOptions.kt index 1162d8ef..d0ae63ce 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/ClientOptions.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/ClientOptions.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.core +package io.imagekit.api.core import com.fasterxml.jackson.databind.json.JsonMapper -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.HttpClient -import io.imagekit.io.core.http.PhantomReachableClosingHttpClient -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.core.http.RetryingHttpClient +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.HttpClient +import io.imagekit.api.core.http.PhantomReachableClosingHttpClient +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.core.http.RetryingHttpClient import java.time.Clock import java.time.Duration import java.util.Base64 @@ -37,7 +37,7 @@ private constructor( /** * The Jackson JSON mapper to use for serializing and deserializing JSON. * - * Defaults to [io.imagekit.io.core.jsonMapper]. The default is usually sufficient and rarely + * Defaults to [io.imagekit.api.core.jsonMapper]. The default is usually sufficient and rarely * needs to be overridden. */ @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, @@ -219,7 +219,7 @@ private constructor( /** * The Jackson JSON mapper to use for serializing and deserializing JSON. * - * Defaults to [io.imagekit.io.core.jsonMapper]. The default is usually sufficient and + * Defaults to [io.imagekit.api.core.jsonMapper]. The default is usually sufficient and * rarely needs to be overridden. */ fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/DefaultSleeper.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/DefaultSleeper.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/DefaultSleeper.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/DefaultSleeper.kt index 65a0f3dc..37341444 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/DefaultSleeper.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/DefaultSleeper.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.core +package io.imagekit.api.core import java.time.Duration import java.util.Timer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/ObjectMappers.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/ObjectMappers.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/ObjectMappers.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/ObjectMappers.kt index c2daca2c..5fa7f285 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/ObjectMappers.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/ObjectMappers.kt @@ -1,6 +1,6 @@ @file:JvmName("ObjectMappers") -package io.imagekit.io.core +package io.imagekit.api.core import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.core.JsonGenerator diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Params.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Params.kt similarity index 77% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Params.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Params.kt index 36e5d3bb..43fed708 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Params.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Params.kt @@ -1,7 +1,7 @@ -package io.imagekit.io.core +package io.imagekit.api.core -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams /** An interface representing parameters passed to a service method. */ interface Params { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PhantomReachable.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PhantomReachable.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PhantomReachable.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PhantomReachable.kt index cf13b66e..3a4fb11a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PhantomReachable.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PhantomReachable.kt @@ -1,8 +1,8 @@ @file:JvmName("PhantomReachable") -package io.imagekit.io.core +package io.imagekit.api.core -import io.imagekit.io.errors.ImageKitException +import io.imagekit.api.errors.ImageKitException import java.lang.reflect.InvocationTargetException /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PhantomReachableExecutorService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PhantomReachableExecutorService.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PhantomReachableExecutorService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PhantomReachableExecutorService.kt index e36be75d..fd0be25c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PhantomReachableExecutorService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PhantomReachableExecutorService.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.core +package io.imagekit.api.core import java.util.concurrent.Callable import java.util.concurrent.ExecutorService diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PhantomReachableSleeper.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PhantomReachableSleeper.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PhantomReachableSleeper.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PhantomReachableSleeper.kt index 363c5f5f..9da2c352 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PhantomReachableSleeper.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PhantomReachableSleeper.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.core +package io.imagekit.api.core import java.time.Duration import java.util.concurrent.CompletableFuture diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PrepareRequest.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PrepareRequest.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PrepareRequest.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PrepareRequest.kt index dc89659e..ead8466f 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/PrepareRequest.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PrepareRequest.kt @@ -1,8 +1,8 @@ @file:JvmName("PrepareRequest") -package io.imagekit.io.core +package io.imagekit.api.core -import io.imagekit.io.core.http.HttpRequest +import io.imagekit.api.core.http.HttpRequest import java.util.concurrent.CompletableFuture @JvmSynthetic diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Properties.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Properties.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Properties.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Properties.kt index 82f7b76f..f5e46a07 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Properties.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Properties.kt @@ -1,8 +1,8 @@ @file:JvmName("Properties") -package io.imagekit.io.core +package io.imagekit.api.core -import io.imagekit.io.client.ImageKitClient +import io.imagekit.api.client.ImageKitClient fun getOsArch(): String { val osArch = System.getProperty("os.arch") diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/RequestOptions.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/RequestOptions.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/RequestOptions.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/RequestOptions.kt index 169073e7..4dbbec22 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/RequestOptions.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/RequestOptions.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.core +package io.imagekit.api.core import java.time.Duration diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Sleeper.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Sleeper.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Sleeper.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Sleeper.kt index 4233d6ce..bc448c25 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Sleeper.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Sleeper.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.core +package io.imagekit.api.core import java.time.Duration import java.util.concurrent.CompletableFuture diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Timeout.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Timeout.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Timeout.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Timeout.kt index 7aca153c..7555e325 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Timeout.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Timeout.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.core +package io.imagekit.api.core import java.time.Duration import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/UnwrapWebhookParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/UnwrapWebhookParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/UnwrapWebhookParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/UnwrapWebhookParams.kt index 9ed0f3c8..4a287ab7 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/UnwrapWebhookParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/UnwrapWebhookParams.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.core +package io.imagekit.api.core -import io.imagekit.io.core.http.Headers +import io.imagekit.api.core.http.Headers import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Utils.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Utils.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Utils.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Utils.kt index 973173a3..4eab8308 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Utils.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Utils.kt @@ -1,8 +1,8 @@ @file:JvmName("Utils") -package io.imagekit.io.core +package io.imagekit.api.core -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.SortedMap import java.util.concurrent.CompletableFuture diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Values.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Values.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt index 43d1ff48..5711a914 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/Values.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.core +package io.imagekit.api.core import com.fasterxml.jackson.annotation.JacksonAnnotationsInside import com.fasterxml.jackson.annotation.JsonCreator @@ -24,7 +24,7 @@ import com.fasterxml.jackson.databind.node.JsonNodeType.OBJECT import com.fasterxml.jackson.databind.node.JsonNodeType.POJO import com.fasterxml.jackson.databind.node.JsonNodeType.STRING import com.fasterxml.jackson.databind.ser.std.NullSerializer -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.errors.ImageKitInvalidDataException import java.io.InputStream import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/EmptyHandler.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/EmptyHandler.kt similarity index 62% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/EmptyHandler.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/EmptyHandler.kt index 05d5e838..775d5bf5 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/EmptyHandler.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/EmptyHandler.kt @@ -1,9 +1,9 @@ @file:JvmName("EmptyHandler") -package io.imagekit.io.core.handlers +package io.imagekit.api.core.handlers -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler @JvmSynthetic internal fun emptyHandler(): Handler = EmptyHandlerInternal diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/ErrorHandler.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/ErrorHandler.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/ErrorHandler.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/ErrorHandler.kt index 896acf44..a48b2e53 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/ErrorHandler.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/ErrorHandler.kt @@ -2,21 +2,21 @@ @file:JvmName("ErrorHandler") -package io.imagekit.io.core.handlers +package io.imagekit.api.core.handlers import com.fasterxml.jackson.databind.json.JsonMapper -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.errors.BadRequestException -import io.imagekit.io.errors.InternalServerException -import io.imagekit.io.errors.NotFoundException -import io.imagekit.io.errors.PermissionDeniedException -import io.imagekit.io.errors.RateLimitException -import io.imagekit.io.errors.UnauthorizedException -import io.imagekit.io.errors.UnexpectedStatusCodeException -import io.imagekit.io.errors.UnprocessableEntityException +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.errors.BadRequestException +import io.imagekit.api.errors.InternalServerException +import io.imagekit.api.errors.NotFoundException +import io.imagekit.api.errors.PermissionDeniedException +import io.imagekit.api.errors.RateLimitException +import io.imagekit.api.errors.UnauthorizedException +import io.imagekit.api.errors.UnexpectedStatusCodeException +import io.imagekit.api.errors.UnprocessableEntityException @JvmSynthetic internal fun errorBodyHandler(jsonMapper: JsonMapper): Handler { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/JsonHandler.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/JsonHandler.kt similarity index 73% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/JsonHandler.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/JsonHandler.kt index f48e4c57..20590773 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/JsonHandler.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/JsonHandler.kt @@ -1,12 +1,12 @@ @file:JvmName("JsonHandler") -package io.imagekit.io.core.handlers +package io.imagekit.api.core.handlers import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.errors.ImageKitInvalidDataException @JvmSynthetic internal inline fun jsonHandler(jsonMapper: JsonMapper): Handler = diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/StringHandler.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/StringHandler.kt similarity index 68% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/StringHandler.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/StringHandler.kt index 3604ff88..a31433dd 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/handlers/StringHandler.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/StringHandler.kt @@ -1,9 +1,9 @@ @file:JvmName("StringHandler") -package io.imagekit.io.core.handlers +package io.imagekit.api.core.handlers -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler @JvmSynthetic internal fun stringHandler(): Handler = StringHandlerInternal diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/AsyncStreamResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/AsyncStreamResponse.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/AsyncStreamResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/AsyncStreamResponse.kt index c03a5229..7231f80d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/AsyncStreamResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/AsyncStreamResponse.kt @@ -1,6 +1,6 @@ -package io.imagekit.io.core.http +package io.imagekit.api.core.http -import io.imagekit.io.core.http.AsyncStreamResponse.Handler +import io.imagekit.api.core.http.AsyncStreamResponse.Handler import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/Headers.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/Headers.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/Headers.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/Headers.kt index 1421f37f..5b14b8e9 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/Headers.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/Headers.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.core.http - -import io.imagekit.io.core.JsonArray -import io.imagekit.io.core.JsonBoolean -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonNull -import io.imagekit.io.core.JsonNumber -import io.imagekit.io.core.JsonObject -import io.imagekit.io.core.JsonString -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.toImmutable +package io.imagekit.api.core.http + +import io.imagekit.api.core.JsonArray +import io.imagekit.api.core.JsonBoolean +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonNull +import io.imagekit.api.core.JsonNumber +import io.imagekit.api.core.JsonObject +import io.imagekit.api.core.JsonString +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.toImmutable import java.util.TreeMap class Headers diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpClient.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpClient.kt similarity index 90% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpClient.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpClient.kt index 12a86e9c..cf9c1a37 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpClient.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpClient.kt @@ -1,6 +1,6 @@ -package io.imagekit.io.core.http +package io.imagekit.api.core.http -import io.imagekit.io.core.RequestOptions +import io.imagekit.api.core.RequestOptions import java.lang.AutoCloseable import java.util.concurrent.CompletableFuture diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpMethod.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpMethod.kt similarity index 78% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpMethod.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpMethod.kt index bd4c91ef..303e7791 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpMethod.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpMethod.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.core.http +package io.imagekit.api.core.http enum class HttpMethod { GET, diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpRequest.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpRequest.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpRequest.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpRequest.kt index 9b9421d1..c85c3149 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpRequest.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpRequest.kt @@ -1,7 +1,7 @@ -package io.imagekit.io.core.http +package io.imagekit.api.core.http -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.toImmutable +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.toImmutable import java.net.URLEncoder class HttpRequest diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpRequestBodies.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpRequestBodies.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpRequestBodies.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpRequestBodies.kt index 7703a3bb..0457e4a0 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpRequestBodies.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpRequestBodies.kt @@ -2,14 +2,14 @@ @file:JvmName("HttpRequestBodies") -package io.imagekit.io.core.http +package io.imagekit.api.core.http import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.databind.node.JsonNodeType -import io.imagekit.io.core.MultipartField -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.MultipartField +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.io.ByteArrayInputStream import java.io.InputStream import java.io.OutputStream diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpRequestBody.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpRequestBody.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpRequestBody.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpRequestBody.kt index 559d71e9..f4d018cb 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpRequestBody.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpRequestBody.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.core.http +package io.imagekit.api.core.http import java.io.OutputStream import java.lang.AutoCloseable diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpResponse.kt similarity index 92% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpResponse.kt index 1a080a95..ee1ce039 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.core.http +package io.imagekit.api.core.http import java.io.InputStream diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpResponseFor.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpResponseFor.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpResponseFor.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpResponseFor.kt index 453d4736..e1d7058f 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/HttpResponseFor.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpResponseFor.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.core.http +package io.imagekit.api.core.http import java.io.InputStream diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/PhantomReachableClosingAsyncStreamResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt similarity index 92% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/PhantomReachableClosingAsyncStreamResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt index 668ab64f..17fd9091 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/PhantomReachableClosingAsyncStreamResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt @@ -1,7 +1,7 @@ -package io.imagekit.io.core.http +package io.imagekit.api.core.http -import io.imagekit.io.core.closeWhenPhantomReachable -import io.imagekit.io.core.http.AsyncStreamResponse.Handler +import io.imagekit.api.core.closeWhenPhantomReachable +import io.imagekit.api.core.http.AsyncStreamResponse.Handler import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/PhantomReachableClosingHttpClient.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/PhantomReachableClosingHttpClient.kt similarity index 85% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/PhantomReachableClosingHttpClient.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/PhantomReachableClosingHttpClient.kt index 1de13648..d0fc712b 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/PhantomReachableClosingHttpClient.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/PhantomReachableClosingHttpClient.kt @@ -1,7 +1,7 @@ -package io.imagekit.io.core.http +package io.imagekit.api.core.http -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.closeWhenPhantomReachable +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.closeWhenPhantomReachable import java.util.concurrent.CompletableFuture /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/PhantomReachableClosingStreamResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/PhantomReachableClosingStreamResponse.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/PhantomReachableClosingStreamResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/PhantomReachableClosingStreamResponse.kt index cd161cd0..20fdf928 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/PhantomReachableClosingStreamResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/PhantomReachableClosingStreamResponse.kt @@ -1,6 +1,6 @@ -package io.imagekit.io.core.http +package io.imagekit.api.core.http -import io.imagekit.io.core.closeWhenPhantomReachable +import io.imagekit.api.core.closeWhenPhantomReachable import java.util.stream.Stream /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/QueryParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/QueryParams.kt similarity index 90% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/QueryParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/QueryParams.kt index bb2a1c53..2ca231d5 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/QueryParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/QueryParams.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.core.http - -import io.imagekit.io.core.JsonArray -import io.imagekit.io.core.JsonBoolean -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonNull -import io.imagekit.io.core.JsonNumber -import io.imagekit.io.core.JsonObject -import io.imagekit.io.core.JsonString -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.toImmutable +package io.imagekit.api.core.http + +import io.imagekit.api.core.JsonArray +import io.imagekit.api.core.JsonBoolean +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonNull +import io.imagekit.api.core.JsonNumber +import io.imagekit.api.core.JsonObject +import io.imagekit.api.core.JsonString +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.toImmutable class QueryParams private constructor( diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/RetryingHttpClient.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/RetryingHttpClient.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/RetryingHttpClient.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/RetryingHttpClient.kt index 5d7ca8ed..78456b46 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/RetryingHttpClient.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/RetryingHttpClient.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.core.http - -import io.imagekit.io.core.DefaultSleeper -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.Sleeper -import io.imagekit.io.core.checkRequired -import io.imagekit.io.errors.ImageKitIoException -import io.imagekit.io.errors.ImageKitRetryableException +package io.imagekit.api.core.http + +import io.imagekit.api.core.DefaultSleeper +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.Sleeper +import io.imagekit.api.core.checkRequired +import io.imagekit.api.errors.ImageKitIoException +import io.imagekit.api.errors.ImageKitRetryableException import java.io.IOException import java.time.Clock import java.time.Duration diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/StreamResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/StreamResponse.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/StreamResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/StreamResponse.kt index 6ccb4687..9eb3d797 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/core/http/StreamResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/StreamResponse.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.core.http +package io.imagekit.api.core.http import java.util.stream.Stream diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/BadRequestException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/BadRequestException.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/BadRequestException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/BadRequestException.kt index 5c602a73..fe88342e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/BadRequestException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/BadRequestException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.errors +package io.imagekit.api.errors -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitException.kt similarity index 82% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitException.kt index f6706953..154209c8 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitException.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.errors +package io.imagekit.api.errors open class ImageKitException @JvmOverloads diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitInvalidDataException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitInvalidDataException.kt similarity index 82% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitInvalidDataException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitInvalidDataException.kt index 387148ed..bfb165d7 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitInvalidDataException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitInvalidDataException.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.errors +package io.imagekit.api.errors class ImageKitInvalidDataException @JvmOverloads diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitIoException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitIoException.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitIoException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitIoException.kt index 49fbc968..adeb3734 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitIoException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitIoException.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.errors +package io.imagekit.api.errors class ImageKitIoException @JvmOverloads diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitRetryableException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitRetryableException.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitRetryableException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitRetryableException.kt index fc2875ad..87876047 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitRetryableException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitRetryableException.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.errors +package io.imagekit.api.errors /** * Exception that indicates a transient error that can be retried. diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitServiceException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitServiceException.kt similarity index 74% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitServiceException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitServiceException.kt index de7339e8..c9a01f2c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitServiceException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitServiceException.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.errors +package io.imagekit.api.errors -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.http.Headers +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.http.Headers abstract class ImageKitServiceException protected constructor(message: String, cause: Throwable? = null) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitWebhookException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitWebhookException.kt similarity index 82% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitWebhookException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitWebhookException.kt index 9ffe13a3..b0dd35a0 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/ImageKitWebhookException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitWebhookException.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.errors +package io.imagekit.api.errors class ImageKitWebhookException @JvmOverloads diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/InternalServerException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/InternalServerException.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/InternalServerException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/InternalServerException.kt index e3d79cee..e549eba2 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/InternalServerException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/InternalServerException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.errors +package io.imagekit.api.errors -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/NotFoundException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/NotFoundException.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/NotFoundException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/NotFoundException.kt index c114f693..ab310ae6 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/NotFoundException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/NotFoundException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.errors +package io.imagekit.api.errors -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/PermissionDeniedException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/PermissionDeniedException.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/PermissionDeniedException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/PermissionDeniedException.kt index 950ae3a0..1cccf75c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/PermissionDeniedException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/PermissionDeniedException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.errors +package io.imagekit.api.errors -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/RateLimitException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/RateLimitException.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/RateLimitException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/RateLimitException.kt index 5cad2f59..56d017e3 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/RateLimitException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/RateLimitException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.errors +package io.imagekit.api.errors -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnauthorizedException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnauthorizedException.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnauthorizedException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnauthorizedException.kt index 3e93ef7d..3881bcee 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnauthorizedException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnauthorizedException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.errors +package io.imagekit.api.errors -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnexpectedStatusCodeException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnexpectedStatusCodeException.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnexpectedStatusCodeException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnexpectedStatusCodeException.kt index d09cb4d7..8be813dc 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnexpectedStatusCodeException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnexpectedStatusCodeException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.errors +package io.imagekit.api.errors -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnprocessableEntityException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnprocessableEntityException.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnprocessableEntityException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnprocessableEntityException.kt index 8e92aecb..3283d359 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/errors/UnprocessableEntityException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnprocessableEntityException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.errors +package io.imagekit.api.errors -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/AiTag.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/AiTag.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/AiTag.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/AiTag.kt index d2172275..73274625 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/AiTag.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/AiTag.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/BaseOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/BaseOverlay.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/BaseOverlay.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/BaseOverlay.kt index ad6d9f0b..0b7f2a8b 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/BaseOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/BaseOverlay.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import io.imagekit.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/CustomMetadata.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/CustomMetadata.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/CustomMetadata.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/CustomMetadata.kt index eee8299d..ea53a38d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/CustomMetadata.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/CustomMetadata.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Objects /** A key-value data associated with the asset. */ diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/EmbeddedMetadata.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/EmbeddedMetadata.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/EmbeddedMetadata.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/EmbeddedMetadata.kt index 054b3b91..85782a77 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/EmbeddedMetadata.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/EmbeddedMetadata.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Objects /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ExtensionConfig.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ExtensionConfig.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ExtensionConfig.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ExtensionConfig.kt index 45a6b143..799e0b40 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ExtensionConfig.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ExtensionConfig.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,19 +13,19 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.BaseDeserializer -import io.imagekit.io.core.BaseSerializer -import io.imagekit.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.allMaxBy -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.getOrThrow -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.BaseDeserializer +import io.imagekit.api.core.BaseSerializer +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.allMaxBy +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.getOrThrow +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ExtensionItem.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ExtensionItem.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ExtensionItem.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ExtensionItem.kt index 1bda9ae5..57d777ec 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ExtensionItem.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ExtensionItem.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,19 +13,19 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.BaseDeserializer -import io.imagekit.io.core.BaseSerializer -import io.imagekit.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.allMaxBy -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.getOrThrow -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.BaseDeserializer +import io.imagekit.api.core.BaseSerializer +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.allMaxBy +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.getOrThrow +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/GetImageAttributesOptions.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/GetImageAttributesOptions.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/GetImageAttributesOptions.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/GetImageAttributesOptions.kt index 8dfc91cb..b6bcbf14 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/GetImageAttributesOptions.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/GetImageAttributesOptions.kt @@ -1,19 +1,19 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ImageOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ImageOverlay.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ImageOverlay.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ImageOverlay.kt index a6b78622..99582dbf 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ImageOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ImageOverlay.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import io.imagekit.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/Overlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/Overlay.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/Overlay.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/Overlay.kt index d6093d58..84a17378 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/Overlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/Overlay.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -9,11 +9,11 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.BaseDeserializer -import io.imagekit.io.core.BaseSerializer -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.getOrThrow -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.BaseDeserializer +import io.imagekit.api.core.BaseSerializer +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.getOrThrow +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/OverlayPosition.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/OverlayPosition.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/OverlayPosition.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/OverlayPosition.kt index bf5f9088..953f6e46 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/OverlayPosition.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/OverlayPosition.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,16 +13,16 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.BaseDeserializer -import io.imagekit.io.core.BaseSerializer -import io.imagekit.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.allMaxBy -import io.imagekit.io.core.getOrThrow -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.BaseDeserializer +import io.imagekit.api.core.BaseSerializer +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.allMaxBy +import io.imagekit.api.core.getOrThrow +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/OverlayTiming.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/OverlayTiming.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/OverlayTiming.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/OverlayTiming.kt index bbccaaa9..473b0c44 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/OverlayTiming.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/OverlayTiming.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,15 +13,15 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.BaseDeserializer -import io.imagekit.io.core.BaseSerializer -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.allMaxBy -import io.imagekit.io.core.getOrThrow -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.BaseDeserializer +import io.imagekit.api.core.BaseSerializer +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.allMaxBy +import io.imagekit.api.core.getOrThrow +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ResponsiveImageAttributes.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ResponsiveImageAttributes.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ResponsiveImageAttributes.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ResponsiveImageAttributes.kt index 6e0134b4..8651431e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/ResponsiveImageAttributes.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ResponsiveImageAttributes.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SavedExtension.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SavedExtension.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SavedExtension.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SavedExtension.kt index 61ccf3a6..6e8748c5 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SavedExtension.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SavedExtension.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SelectedFieldsSchema.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SelectedFieldsSchema.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SelectedFieldsSchema.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SelectedFieldsSchema.kt index 8baaa4b0..552dadf7 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SelectedFieldsSchema.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SelectedFieldsSchema.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Objects /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SolidColorOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SolidColorOverlay.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SolidColorOverlay.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SolidColorOverlay.kt index ee9ae6dc..e9758fae 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SolidColorOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SolidColorOverlay.kt @@ -1,19 +1,19 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SolidColorOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SolidColorOverlayTransformation.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SolidColorOverlayTransformation.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SolidColorOverlayTransformation.kt index 07a36643..90cdda47 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SolidColorOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SolidColorOverlayTransformation.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,15 +13,15 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.BaseDeserializer -import io.imagekit.io.core.BaseSerializer -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.allMaxBy -import io.imagekit.io.core.getOrThrow -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.BaseDeserializer +import io.imagekit.api.core.BaseSerializer +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.allMaxBy +import io.imagekit.api.core.getOrThrow +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SrcOptions.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SrcOptions.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SrcOptions.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SrcOptions.kt index 773e11bc..27ec9d42 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SrcOptions.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SrcOptions.kt @@ -1,19 +1,19 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/StreamingResolution.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/StreamingResolution.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/StreamingResolution.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/StreamingResolution.kt index d41f75f1..207b6799 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/StreamingResolution.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/StreamingResolution.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.io.core.Enum -import io.imagekit.io.core.JsonField -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.Enum +import io.imagekit.api.core.JsonField +import io.imagekit.api.errors.ImageKitInvalidDataException /** * Available streaming resolutions for diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SubtitleOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SubtitleOverlay.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SubtitleOverlay.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SubtitleOverlay.kt index 3354b37b..ed428531 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SubtitleOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SubtitleOverlay.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import io.imagekit.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SubtitleOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SubtitleOverlayTransformation.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SubtitleOverlayTransformation.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SubtitleOverlayTransformation.kt index 81b9aa94..5503e8f7 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/SubtitleOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SubtitleOverlayTransformation.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import io.imagekit.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/TextOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/TextOverlay.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/TextOverlay.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/TextOverlay.kt index 4b8e00d2..6dea0fd0 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/TextOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/TextOverlay.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import io.imagekit.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/TextOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/TextOverlayTransformation.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/TextOverlayTransformation.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/TextOverlayTransformation.kt index add8fe48..6f2e8ca5 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/TextOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/TextOverlayTransformation.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,16 +13,16 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.BaseDeserializer -import io.imagekit.io.core.BaseSerializer -import io.imagekit.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.allMaxBy -import io.imagekit.io.core.getOrThrow -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.BaseDeserializer +import io.imagekit.api.core.BaseSerializer +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.allMaxBy +import io.imagekit.api.core.getOrThrow +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/Transformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/Transformation.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/Transformation.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/Transformation.kt index 8174423f..1eb86fe1 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/Transformation.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/Transformation.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,18 +13,18 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.BaseDeserializer -import io.imagekit.io.core.BaseSerializer -import io.imagekit.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.allMaxBy -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.getOrThrow -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.BaseDeserializer +import io.imagekit.api.core.BaseSerializer +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.allMaxBy +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.getOrThrow +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/TransformationPosition.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/TransformationPosition.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/TransformationPosition.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/TransformationPosition.kt index 49816596..43212e10 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/TransformationPosition.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/TransformationPosition.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.io.core.Enum -import io.imagekit.io.core.JsonField -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.Enum +import io.imagekit.api.core.JsonField +import io.imagekit.api.errors.ImageKitInvalidDataException /** * By default, the transformation string is added as a query parameter in the URL, e.g., diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/VersionInfo.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/VersionInfo.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/VersionInfo.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/VersionInfo.kt index 8e56d192..a6b92f97 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/VersionInfo.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/VersionInfo.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/VideoOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/VideoOverlay.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/VideoOverlay.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/VideoOverlay.kt index 94b81487..d598b1f5 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/VideoOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/VideoOverlay.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import io.imagekit.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginCreateParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginCreateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginCreateParams.kt index e3198f52..1e09dbf1 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginCreateParams.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.origins +package io.imagekit.api.models.accounts.origins -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams import java.util.Objects /** **Note:** This API is currently in beta. Creates a new origin and returns the origin object. */ diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginDeleteParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginDeleteParams.kt index 13fec183..eebfc5d3 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginDeleteParams.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.origins +package io.imagekit.api.models.accounts.origins -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.core.toImmutable +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.core.toImmutable import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginGetParams.kt index c57a37bd..0e22d779 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginGetParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.origins +package io.imagekit.api.models.accounts.origins -import io.imagekit.io.core.Params -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.Params +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginListParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginListParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginListParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginListParams.kt index 0ac75f6c..f1823b0c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginListParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginListParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.origins +package io.imagekit.api.models.accounts.origins -import io.imagekit.io.core.Params -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.Params +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams import java.util.Objects /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginRequest.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginRequest.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginRequest.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginRequest.kt index 4c3549e7..9619119f 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginRequest.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginRequest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.origins +package io.imagekit.api.models.accounts.origins import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,15 +13,15 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.BaseDeserializer -import io.imagekit.io.core.BaseSerializer -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.getOrThrow -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.BaseDeserializer +import io.imagekit.api.core.BaseSerializer +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.getOrThrow +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginResponse.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginResponse.kt index 73868127..9e8eeb85 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.origins +package io.imagekit.api.models.accounts.origins import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,15 +13,15 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.BaseDeserializer -import io.imagekit.io.core.BaseSerializer -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.getOrThrow -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.BaseDeserializer +import io.imagekit.api.core.BaseSerializer +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.getOrThrow +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginUpdateParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginUpdateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginUpdateParams.kt index 3497120b..98ed8632 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/origins/OriginUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginUpdateParams.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.origins +package io.imagekit.api.models.accounts.origins -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParams.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointCreateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParams.kt index cede1ad0..21798404 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParams.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.urlendpoints +package io.imagekit.api.models.accounts.urlendpoints -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams import java.util.Objects /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt index 335ee545..873cc944 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.urlendpoints +package io.imagekit.api.models.accounts.urlendpoints -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.core.toImmutable +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.core.toImmutable import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParams.kt index 83344c14..6bbcefed 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.urlendpoints +package io.imagekit.api.models.accounts.urlendpoints -import io.imagekit.io.core.Params -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.Params +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointListParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointListParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParams.kt index 75bad774..963474ea 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointListParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.urlendpoints +package io.imagekit.api.models.accounts.urlendpoints -import io.imagekit.io.core.Params -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.Params +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams import java.util.Objects /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointRequest.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequest.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointRequest.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequest.kt index f32c4238..18dd5d20 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointRequest.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.urlendpoints +package io.imagekit.api.models.accounts.urlendpoints import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,17 +13,17 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.BaseDeserializer -import io.imagekit.io.core.BaseSerializer -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.getOrThrow -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.BaseDeserializer +import io.imagekit.api.core.BaseSerializer +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.getOrThrow +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponse.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponse.kt index 23584cba..4c1e4146 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.urlendpoints +package io.imagekit.api.models.accounts.urlendpoints import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,17 +13,17 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.BaseDeserializer -import io.imagekit.io.core.BaseSerializer -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.getOrThrow -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.BaseDeserializer +import io.imagekit.api.core.BaseSerializer +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.getOrThrow +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt index 93cb445d..e59831b1 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.urlendpoints +package io.imagekit.api.models.accounts.urlendpoints -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/usage/UsageGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/usage/UsageGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/usage/UsageGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/usage/UsageGetParams.kt index d2b73e35..e014eaca 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/usage/UsageGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/usage/UsageGetParams.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.usage +package io.imagekit.api.models.accounts.usage -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams import java.time.LocalDate import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/usage/UsageGetResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/usage/UsageGetResponse.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/usage/UsageGetResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/usage/UsageGetResponse.kt index d23cbbe0..79a32f9b 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/accounts/usage/UsageGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/usage/UsageGetResponse.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.usage +package io.imagekit.api.models.accounts.usage 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/assets/AssetListParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/assets/AssetListParams.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/assets/AssetListParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/assets/AssetListParams.kt index 73e8542c..a03de4d5 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/assets/AssetListParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/assets/AssetListParams.kt @@ -1,14 +1,14 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.assets +package io.imagekit.api.models.assets import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.io.core.Enum -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.Params -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.Enum +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.Params +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/assets/AssetListResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/assets/AssetListResponse.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/assets/AssetListResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/assets/AssetListResponse.kt index dad42ce5..8c5cbcb4 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/assets/AssetListResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/assets/AssetListResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.assets +package io.imagekit.api.models.assets import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -9,13 +9,13 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.BaseDeserializer -import io.imagekit.io.core.BaseSerializer -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.getOrThrow -import io.imagekit.io.errors.ImageKitInvalidDataException -import io.imagekit.io.models.files.File -import io.imagekit.io.models.files.Folder +import io.imagekit.api.core.BaseDeserializer +import io.imagekit.api.core.BaseSerializer +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.getOrThrow +import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.api.models.files.File +import io.imagekit.api.models.files.Folder import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadParams.kt index a752cdf1..81b85cf1 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadParams.kt @@ -1,31 +1,29 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.beta.v2.files +package io.imagekit.api.models.beta.v2.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.MultipartField -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.getOrThrow -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.core.jsonMapper -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.ExtensionItem +import io.imagekit.api.core.BaseSerializer +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.MultipartField +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.getOrThrow +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.api.models.ExtensionItem import java.io.InputStream import java.nio.file.Path import java.util.Collections @@ -1084,9 +1082,9 @@ private constructor( "token" to _token(), "checks" to _checks(), "customCoordinates" to _customCoordinates(), - "customMetadata" to _toJsonString(_customMetadata()), + "customMetadata" to _customMetadata(), "description" to _description(), - "extensions" to _toJsonString(_extensions()), + "extensions" to _extensions(), "folder" to _folder(), "isPrivateFile" to _isPrivateFile(), "isPublished" to _isPublished(), @@ -1094,44 +1092,14 @@ private constructor( "overwriteCustomMetadata" to _overwriteCustomMetadata(), "overwriteFile" to _overwriteFile(), "overwriteTags" to _overwriteTags(), - "responseFields" to _toCommaSeparated(_responseFields()), - "tags" to _toCommaSeparated(_tags()), - "transformation" to _toJsonString(_transformation()), + "responseFields" to _responseFields(), + "tags" to _tags(), + "transformation" to _transformation(), "useUniqueFileName" to _useUniqueFileName(), "webhookUrl" to _webhookUrl(), ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) .toImmutable() - private fun _toJsonString(field: MultipartField<*>): MultipartField { - if (field.value.isMissing() || field.value.isNull()) { - @Suppress("UNCHECKED_CAST") - return field as MultipartField - } - val jsonString = jsonMapper().writeValueAsString(field.value) - return MultipartField.of(jsonString) - } - - private fun _toCommaSeparated(field: MultipartField<*>): MultipartField { - if (field.value.isMissing() || field.value.isNull()) { - @Suppress("UNCHECKED_CAST") - return field as MultipartField - } - val mapper = jsonMapper() - val node = mapper.valueToTree(field.value) - if (!node.isArray) { - @Suppress("UNCHECKED_CAST") - return field as MultipartField - } - val csv = - node - .elements() - .asSequence() - .filter { !it.isNull && !it.isMissingNode } - .map { it.asText() } - .joinToString(",") - return MultipartField.of(csv) - } - override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadResponse.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadResponse.kt index d614c4ca..b2f1338f 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadResponse.kt @@ -1,25 +1,25 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.beta.v2.files +package io.imagekit.api.models.beta.v2.files 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.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException -import io.imagekit.io.models.AiTag -import io.imagekit.io.models.CustomMetadata -import io.imagekit.io.models.EmbeddedMetadata -import io.imagekit.io.models.SelectedFieldsSchema -import io.imagekit.io.models.VersionInfo -import io.imagekit.io.models.files.Metadata +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.api.models.AiTag +import io.imagekit.api.models.CustomMetadata +import io.imagekit.api.models.EmbeddedMetadata +import io.imagekit.api.models.SelectedFieldsSchema +import io.imagekit.api.models.VersionInfo +import io.imagekit.api.models.files.Metadata import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateParams.kt index ad75a670..37ba7e32 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.cache.invalidation +package io.imagekit.api.models.cache.invalidation 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateResponse.kt index 85493d41..c6979018 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateResponse.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.cache.invalidation +package io.imagekit.api.models.cache.invalidation 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetParams.kt index 987f7210..f766c993 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.cache.invalidation +package io.imagekit.api.models.cache.invalidation -import io.imagekit.io.core.Params -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.Params +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetResponse.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetResponse.kt index 5ed4dba7..a7c3b8d9 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetResponse.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.cache.invalidation +package io.imagekit.api.models.cache.invalidation 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.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataField.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataField.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataField.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataField.kt index adf4507f..72e4e0ad 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataField.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataField.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.custommetadatafields +package io.imagekit.api.models.custommetadatafields import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,19 +13,19 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.BaseDeserializer -import io.imagekit.io.core.BaseSerializer -import io.imagekit.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.allMaxBy -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.getOrThrow -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.BaseDeserializer +import io.imagekit.api.core.BaseSerializer +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.allMaxBy +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.getOrThrow +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldCreateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt index 77ac3281..eb87e03d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.custommetadatafields +package io.imagekit.api.models.custommetadatafields import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,22 +13,22 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.BaseDeserializer -import io.imagekit.io.core.BaseSerializer -import io.imagekit.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.allMaxBy -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.getOrThrow -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.BaseDeserializer +import io.imagekit.api.core.BaseSerializer +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.allMaxBy +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.getOrThrow +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt index b53d904b..30af50b5 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.custommetadatafields +package io.imagekit.api.models.custommetadatafields -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.core.toImmutable +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.core.toImmutable import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt index ccce4839..63a160df 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.custommetadatafields +package io.imagekit.api.models.custommetadatafields import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldListParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldListParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParams.kt index 583a8d29..432b35bd 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldListParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.custommetadatafields +package io.imagekit.api.models.custommetadatafields -import io.imagekit.io.core.Params -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.Params +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt index c328992a..fd72bb5c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.custommetadatafields +package io.imagekit.api.models.custommetadatafields import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,20 +13,20 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.BaseDeserializer -import io.imagekit.io.core.BaseSerializer -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.allMaxBy -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.getOrThrow -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.BaseDeserializer +import io.imagekit.api.core.BaseSerializer +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.allMaxBy +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.getOrThrow +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/File.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/File.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/File.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/File.kt index ce2f9d60..94799525 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/File.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/File.kt @@ -1,24 +1,24 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files 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.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException -import io.imagekit.io.models.AiTag -import io.imagekit.io.models.CustomMetadata -import io.imagekit.io.models.EmbeddedMetadata -import io.imagekit.io.models.SelectedFieldsSchema -import io.imagekit.io.models.VersionInfo +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.api.models.AiTag +import io.imagekit.api.models.CustomMetadata +import io.imagekit.api.models.EmbeddedMetadata +import io.imagekit.api.models.SelectedFieldsSchema +import io.imagekit.api.models.VersionInfo import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileCopyParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileCopyParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileCopyParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileCopyParams.kt index 687af58f..de237dbe 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileCopyParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileCopyParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileCopyResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileCopyResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileCopyResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileCopyResponse.kt index ae35acff..5551c970 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileCopyResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileCopyResponse.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileDeleteParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileDeleteParams.kt index 62d925ee..db27e56d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileDeleteParams.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.core.toImmutable +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.core.toImmutable import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileGetParams.kt index 6a45258d..d2036f07 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileGetParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files -import io.imagekit.io.core.Params -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.Params +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileMoveParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileMoveParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileMoveParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileMoveParams.kt index e9e2b57f..1a6e9b67 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileMoveParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileMoveParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileMoveResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileMoveResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileMoveResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileMoveResponse.kt index 0795ab61..021ac591 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileMoveResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileMoveResponse.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileRenameParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileRenameParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileRenameParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileRenameParams.kt index 82fd46b9..1ccfab29 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileRenameParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileRenameParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileRenameResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileRenameResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileRenameResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileRenameResponse.kt index f5e249ab..15b0ba2f 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileRenameResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileRenameResponse.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUpdateParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUpdateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUpdateParams.kt index 6faac1fb..e948d9a5 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUpdateParams.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUpdateResponse.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUpdateResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUpdateResponse.kt index c36b5df4..c76a278c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUpdateResponse.kt @@ -1,24 +1,24 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files 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.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException -import io.imagekit.io.models.AiTag -import io.imagekit.io.models.CustomMetadata -import io.imagekit.io.models.EmbeddedMetadata -import io.imagekit.io.models.SelectedFieldsSchema -import io.imagekit.io.models.VersionInfo +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.api.models.AiTag +import io.imagekit.api.models.CustomMetadata +import io.imagekit.api.models.EmbeddedMetadata +import io.imagekit.api.models.SelectedFieldsSchema +import io.imagekit.api.models.VersionInfo import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUploadParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUploadParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUploadParams.kt index 11f8f8b2..af79f5b7 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUploadParams.kt @@ -1,31 +1,29 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.models.files +package io.imagekit.api.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.imagekit.api.core.BaseSerializer -import com.imagekit.api.core.Enum -import com.imagekit.api.core.ExcludeMissing -import com.imagekit.api.core.JsonField -import com.imagekit.api.core.JsonValue -import com.imagekit.api.core.MultipartField -import com.imagekit.api.core.Params -import com.imagekit.api.core.checkKnown -import com.imagekit.api.core.checkRequired -import com.imagekit.api.core.getOrThrow -import com.imagekit.api.core.http.Headers -import com.imagekit.api.core.http.QueryParams -import com.imagekit.api.core.jsonMapper -import com.imagekit.api.core.toImmutable -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.models.ExtensionItem +import io.imagekit.api.core.BaseSerializer +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.MultipartField +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.getOrThrow +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.api.models.ExtensionItem import java.io.InputStream import java.nio.file.Path import java.util.Collections @@ -1203,10 +1201,10 @@ private constructor( "token" to _token(), "checks" to _checks(), "customCoordinates" to _customCoordinates(), - "customMetadata" to _toJsonString(_customMetadata()), + "customMetadata" to _customMetadata(), "description" to _description(), "expire" to _expire(), - "extensions" to _toJsonString(_extensions()), + "extensions" to _extensions(), "folder" to _folder(), "isPrivateFile" to _isPrivateFile(), "isPublished" to _isPublished(), @@ -1215,45 +1213,15 @@ private constructor( "overwriteFile" to _overwriteFile(), "overwriteTags" to _overwriteTags(), "publicKey" to _publicKey(), - "responseFields" to _toCommaSeparated(_responseFields()), + "responseFields" to _responseFields(), "signature" to _signature(), - "tags" to _toCommaSeparated(_tags()), - "transformation" to _toJsonString(_transformation()), + "tags" to _tags(), + "transformation" to _transformation(), "useUniqueFileName" to _useUniqueFileName(), "webhookUrl" to _webhookUrl(), ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) .toImmutable() - private fun _toJsonString(field: MultipartField<*>): MultipartField { - if (field.value.isMissing() || field.value.isNull()) { - @Suppress("UNCHECKED_CAST") - return field as MultipartField - } - val jsonString = jsonMapper().writeValueAsString(field.value) - return MultipartField.of(jsonString) - } - - private fun _toCommaSeparated(field: MultipartField<*>): MultipartField { - if (field.value.isMissing() || field.value.isNull()) { - @Suppress("UNCHECKED_CAST") - return field as MultipartField - } - val mapper = jsonMapper() - val node = mapper.valueToTree(field.value) - if (!node.isArray) { - @Suppress("UNCHECKED_CAST") - return field as MultipartField - } - val csv = - node - .elements() - .asSequence() - .filter { !it.isNull && !it.isMissingNode } - .map { it.asText() } - .joinToString(",") - return MultipartField.of(csv) - } - override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUploadResponse.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUploadResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUploadResponse.kt index fb85557d..8452e3ef 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/FileUploadResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUploadResponse.kt @@ -1,24 +1,24 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files 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.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException -import io.imagekit.io.models.AiTag -import io.imagekit.io.models.CustomMetadata -import io.imagekit.io.models.EmbeddedMetadata -import io.imagekit.io.models.SelectedFieldsSchema -import io.imagekit.io.models.VersionInfo +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.api.models.AiTag +import io.imagekit.api.models.CustomMetadata +import io.imagekit.api.models.EmbeddedMetadata +import io.imagekit.api.models.SelectedFieldsSchema +import io.imagekit.api.models.VersionInfo import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/Folder.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/Folder.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/Folder.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/Folder.kt index 9540234e..32c7d678 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/Folder.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/Folder.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files 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.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/Metadata.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/Metadata.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/Metadata.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/Metadata.kt index 899a00b3..9d0ac8e4 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/Metadata.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/Metadata.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/UpdateFileRequest.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/UpdateFileRequest.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/UpdateFileRequest.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/UpdateFileRequest.kt index b1875d5d..7b37cd33 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/UpdateFileRequest.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/UpdateFileRequest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,19 +13,19 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.BaseDeserializer -import io.imagekit.io.core.BaseSerializer -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.allMaxBy -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.getOrThrow -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException -import io.imagekit.io.models.ExtensionItem +import io.imagekit.api.core.BaseDeserializer +import io.imagekit.api.core.BaseSerializer +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.allMaxBy +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.getOrThrow +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.api.models.ExtensionItem import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsParams.kt index a379fa91..f46828d2 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsParams.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.bulk +package io.imagekit.api.models.files.bulk 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsResponse.kt index 9d52ada9..fd0160ee 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsResponse.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.bulk +package io.imagekit.api.models.files.bulk 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteParams.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteParams.kt index 9a62d24c..a7e54721 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteParams.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.bulk +package io.imagekit.api.models.files.bulk 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteResponse.kt index ef143ca9..08c74e59 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteResponse.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.bulk +package io.imagekit.api.models.files.bulk 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsParams.kt index 37d092d6..1395723d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsParams.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.bulk +package io.imagekit.api.models.files.bulk 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponse.kt index c0b81c17..a183fc71 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponse.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.bulk +package io.imagekit.api.models.files.bulk 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsParams.kt index 5eec3b2f..d059ac8b 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsParams.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.bulk +package io.imagekit.api.models.files.bulk 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsResponse.kt index 37bb3920..0ee86d18 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsResponse.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.bulk +package io.imagekit.api.models.files.bulk 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/metadata/MetadataGetFromUrlParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/metadata/MetadataGetFromUrlParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/metadata/MetadataGetFromUrlParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/metadata/MetadataGetFromUrlParams.kt index c848d9a0..f0fd2de7 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/metadata/MetadataGetFromUrlParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/metadata/MetadataGetFromUrlParams.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.metadata +package io.imagekit.api.models.files.metadata -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams import java.util.Objects /** Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API. */ diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/metadata/MetadataGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/metadata/MetadataGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/metadata/MetadataGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/metadata/MetadataGetParams.kt index 2d738739..c46eca25 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/metadata/MetadataGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/metadata/MetadataGetParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.metadata +package io.imagekit.api.models.files.metadata -import io.imagekit.io.core.Params -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.Params +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionDeleteParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionDeleteParams.kt index fb010612..98218d88 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionDeleteParams.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.versions - -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.core.toImmutable +package io.imagekit.api.models.files.versions + +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.core.toImmutable import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionDeleteResponse.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionDeleteResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionDeleteResponse.kt index 1c7f68bc..8887e072 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionDeleteResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionDeleteResponse.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.versions +package io.imagekit.api.models.files.versions import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionGetParams.kt index 4621565e..4aca8292 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionGetParams.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.versions +package io.imagekit.api.models.files.versions -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionListParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionListParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionListParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionListParams.kt index cb273621..ba9e6ccd 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionListParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionListParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.versions +package io.imagekit.api.models.files.versions -import io.imagekit.io.core.Params -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.Params +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionRestoreParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionRestoreParams.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionRestoreParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionRestoreParams.kt index 7e1e95a9..3b621ed5 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/files/versions/VersionRestoreParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionRestoreParams.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.versions - -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.core.toImmutable +package io.imagekit.api.models.files.versions + +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.core.toImmutable import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCopyParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCopyParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCopyParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCopyParams.kt index dbba412d..c0b97ce1 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCopyParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCopyParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders +package io.imagekit.api.models.folders 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCopyResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCopyResponse.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCopyResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCopyResponse.kt index 629b78e5..5ce8295a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCopyResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCopyResponse.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders +package io.imagekit.api.models.folders 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCreateParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCreateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCreateParams.kt index 659009e0..e710351b 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCreateParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders +package io.imagekit.api.models.folders 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCreateResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCreateResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCreateResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCreateResponse.kt index 0aca95f5..60c0a6f0 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCreateResponse.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders +package io.imagekit.api.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderDeleteParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderDeleteParams.kt index f16d61c6..92fee7ce 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderDeleteParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders +package io.imagekit.api.models.folders 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderDeleteResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderDeleteResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderDeleteResponse.kt index f6e62e09..74280bb4 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderDeleteResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderDeleteResponse.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders +package io.imagekit.api.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderMoveParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderMoveParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderMoveParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderMoveParams.kt index d752f7d0..0b5f5e5a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderMoveParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderMoveParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders +package io.imagekit.api.models.folders 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderMoveResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderMoveResponse.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderMoveResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderMoveResponse.kt index 6df5e531..252b6a96 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderMoveResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderMoveResponse.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders +package io.imagekit.api.models.folders 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderRenameParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderRenameParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderRenameParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderRenameParams.kt index 25562eb4..61324c7b 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderRenameParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderRenameParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders +package io.imagekit.api.models.folders 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderRenameResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderRenameResponse.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderRenameResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderRenameResponse.kt index a765a825..e970ff31 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/FolderRenameResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderRenameResponse.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders +package io.imagekit.api.models.folders 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/job/JobGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/job/JobGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/job/JobGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/job/JobGetParams.kt index 38faa702..cc415e6e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/job/JobGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/job/JobGetParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders.job +package io.imagekit.api.models.folders.job -import io.imagekit.io.core.Params -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.Params +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/job/JobGetResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/job/JobGetResponse.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/job/JobGetResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/job/JobGetResponse.kt index ac181a52..5a213887 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/folders/job/JobGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/job/JobGetResponse.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders.job +package io.imagekit.api.models.folders.job 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.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionCreateParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionCreateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionCreateParams.kt index 6670e08e..195ab60a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionCreateParams.kt @@ -1,21 +1,21 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.savedextensions +package io.imagekit.api.models.savedextensions 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.errors.ImageKitInvalidDataException -import io.imagekit.io.models.ExtensionConfig +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.api.models.ExtensionConfig import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionDeleteParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionDeleteParams.kt index 6d429e80..b58db767 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionDeleteParams.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.savedextensions +package io.imagekit.api.models.savedextensions -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.core.toImmutable +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.core.toImmutable import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionGetParams.kt index aa0f08c8..d0882a0a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionGetParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.savedextensions +package io.imagekit.api.models.savedextensions -import io.imagekit.io.core.Params -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.Params +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionListParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionListParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionListParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionListParams.kt index 160d4fe9..634f6ef7 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionListParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionListParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.savedextensions +package io.imagekit.api.models.savedextensions -import io.imagekit.io.core.Params -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.Params +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams import java.util.Objects /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionUpdateParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionUpdateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionUpdateParams.kt index acc0464e..eb8060b9 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionUpdateParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.savedextensions +package io.imagekit.api.models.savedextensions 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.Params -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.http.QueryParams -import io.imagekit.io.errors.ImageKitInvalidDataException -import io.imagekit.io.models.ExtensionConfig +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.Params +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.http.QueryParams +import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.api.models.ExtensionConfig import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/BaseWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/BaseWebhookEvent.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/BaseWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/BaseWebhookEvent.kt index adc27d7c..c398d991 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/BaseWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/BaseWebhookEvent.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileCreateEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileCreateEvent.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileCreateEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileCreateEvent.kt index 711d2141..b5835b89 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileCreateEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileCreateEvent.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.errors.ImageKitInvalidDataException -import io.imagekit.io.models.files.File +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.api.models.files.File import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileDeleteEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileDeleteEvent.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileDeleteEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileDeleteEvent.kt index 19ba2f05..a5aa1a39 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileDeleteEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileDeleteEvent.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileUpdateEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileUpdateEvent.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileUpdateEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileUpdateEvent.kt index 9a104c9d..1ef9b420 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileUpdateEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileUpdateEvent.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.errors.ImageKitInvalidDataException -import io.imagekit.io.models.files.File +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.api.models.files.File import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileVersionCreateEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileVersionCreateEvent.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileVersionCreateEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileVersionCreateEvent.kt index 110681cc..6c5e1131 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileVersionCreateEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileVersionCreateEvent.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.errors.ImageKitInvalidDataException -import io.imagekit.io.models.files.File +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.api.models.files.File import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileVersionDeleteEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileVersionDeleteEvent.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileVersionDeleteEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileVersionDeleteEvent.kt index 61642038..cce06f26 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/FileVersionDeleteEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileVersionDeleteEvent.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UnsafeUnwrapWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UnsafeUnwrapWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt index fec05714..69f2966f 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UnsafeUnwrapWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -9,12 +9,12 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.BaseDeserializer -import io.imagekit.io.core.BaseSerializer -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.allMaxBy -import io.imagekit.io.core.getOrThrow -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.BaseDeserializer +import io.imagekit.api.core.BaseSerializer +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.allMaxBy +import io.imagekit.api.core.getOrThrow +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UnwrapWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UnwrapWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt index 2ea46ede..6e40ba9f 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UnwrapWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -9,12 +9,12 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.BaseDeserializer -import io.imagekit.io.core.BaseSerializer -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.allMaxBy -import io.imagekit.io.core.getOrThrow -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.BaseDeserializer +import io.imagekit.api.core.BaseSerializer +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.allMaxBy +import io.imagekit.api.core.getOrThrow +import io.imagekit.api.errors.ImageKitInvalidDataException import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformErrorEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformErrorEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt index 4a0f3dae..45a14591 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformErrorEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks 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.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformSuccessEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformSuccessEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt index a1342ecb..611c1353 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformSuccessEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks 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.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformErrorEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformErrorEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt index 5f951024..e306081b 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformErrorEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks 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.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkRequired -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkRequired +import io.imagekit.api.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformSuccessEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformSuccessEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt index 2757905c..0fc5cc5b 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformSuccessEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt @@ -1,26 +1,26 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks 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.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException -import io.imagekit.io.models.AiTag -import io.imagekit.io.models.CustomMetadata -import io.imagekit.io.models.EmbeddedMetadata -import io.imagekit.io.models.SelectedFieldsSchema -import io.imagekit.io.models.VersionInfo -import io.imagekit.io.models.files.Metadata +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.api.models.AiTag +import io.imagekit.api.models.CustomMetadata +import io.imagekit.api.models.EmbeddedMetadata +import io.imagekit.api.models.SelectedFieldsSchema +import io.imagekit.api.models.VersionInfo +import io.imagekit.api.models.files.Metadata import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/VideoTransformationAcceptedEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/VideoTransformationAcceptedEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt index 5193bde4..0f54c1bd 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/VideoTransformationAcceptedEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks 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.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/VideoTransformationErrorEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/VideoTransformationErrorEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt index 17cfd117..eefb103d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/VideoTransformationErrorEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks 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.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/VideoTransformationReadyEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/VideoTransformationReadyEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt index 78f49627..d9c1bdd2 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/models/webhooks/VideoTransformationReadyEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks 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.io.core.Enum -import io.imagekit.io.core.ExcludeMissing -import io.imagekit.io.core.JsonField -import io.imagekit.io.core.JsonMissing -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.checkKnown -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.toImmutable -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.Enum +import io.imagekit.api.core.ExcludeMissing +import io.imagekit.api.core.JsonField +import io.imagekit.api.core.JsonMissing +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.checkKnown +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.toImmutable +import io.imagekit.api.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AccountServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AccountServiceAsync.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AccountServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AccountServiceAsync.kt index ba3b573b..209efd83 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AccountServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AccountServiceAsync.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async +package io.imagekit.api.services.async -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.services.async.accounts.OriginServiceAsync -import io.imagekit.io.services.async.accounts.UrlEndpointServiceAsync -import io.imagekit.io.services.async.accounts.UsageServiceAsync +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.services.async.accounts.OriginServiceAsync +import io.imagekit.api.services.async.accounts.UrlEndpointServiceAsync +import io.imagekit.api.services.async.accounts.UsageServiceAsync import java.util.function.Consumer interface AccountServiceAsync { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AccountServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AccountServiceAsyncImpl.kt similarity index 82% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AccountServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AccountServiceAsyncImpl.kt index 54d9bc8e..27a1510d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AccountServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AccountServiceAsyncImpl.kt @@ -1,14 +1,14 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.services.async.accounts.OriginServiceAsync -import io.imagekit.io.services.async.accounts.OriginServiceAsyncImpl -import io.imagekit.io.services.async.accounts.UrlEndpointServiceAsync -import io.imagekit.io.services.async.accounts.UrlEndpointServiceAsyncImpl -import io.imagekit.io.services.async.accounts.UsageServiceAsync -import io.imagekit.io.services.async.accounts.UsageServiceAsyncImpl +package io.imagekit.api.services.async + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.services.async.accounts.OriginServiceAsync +import io.imagekit.api.services.async.accounts.OriginServiceAsyncImpl +import io.imagekit.api.services.async.accounts.UrlEndpointServiceAsync +import io.imagekit.api.services.async.accounts.UrlEndpointServiceAsyncImpl +import io.imagekit.api.services.async.accounts.UsageServiceAsync +import io.imagekit.api.services.async.accounts.UsageServiceAsyncImpl import java.util.function.Consumer class AccountServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AssetServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AssetServiceAsync.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AssetServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AssetServiceAsync.kt index 6df3b9d8..c195e8b2 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AssetServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AssetServiceAsync.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async +package io.imagekit.api.services.async -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.assets.AssetListParams -import io.imagekit.io.models.assets.AssetListResponse +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.assets.AssetListParams +import io.imagekit.api.models.assets.AssetListResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AssetServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AssetServiceAsyncImpl.kt similarity index 79% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AssetServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AssetServiceAsyncImpl.kt index 45fc46c6..e59efd72 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/AssetServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AssetServiceAsyncImpl.kt @@ -1,21 +1,21 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async +package io.imagekit.api.services.async -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepareAsync -import io.imagekit.io.models.assets.AssetListParams -import io.imagekit.io.models.assets.AssetListResponse +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepareAsync +import io.imagekit.api.models.assets.AssetListParams +import io.imagekit.api.models.assets.AssetListResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/BetaServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/BetaServiceAsync.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/BetaServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/BetaServiceAsync.kt index 3cb535ec..b05446ec 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/BetaServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/BetaServiceAsync.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async +package io.imagekit.api.services.async -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.services.async.beta.V2ServiceAsync +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.services.async.beta.V2ServiceAsync import java.util.function.Consumer interface BetaServiceAsync { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/BetaServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/BetaServiceAsyncImpl.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/BetaServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/BetaServiceAsyncImpl.kt index 39d22a52..5911488c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/BetaServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/BetaServiceAsyncImpl.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async +package io.imagekit.api.services.async -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.services.async.beta.V2ServiceAsync -import io.imagekit.io.services.async.beta.V2ServiceAsyncImpl +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.services.async.beta.V2ServiceAsync +import io.imagekit.api.services.async.beta.V2ServiceAsyncImpl import java.util.function.Consumer class BetaServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CacheServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CacheServiceAsync.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CacheServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CacheServiceAsync.kt index 35190bfe..f8432587 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CacheServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CacheServiceAsync.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async +package io.imagekit.api.services.async -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.services.async.cache.InvalidationServiceAsync +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.services.async.cache.InvalidationServiceAsync import java.util.function.Consumer interface CacheServiceAsync { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CacheServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CacheServiceAsyncImpl.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CacheServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CacheServiceAsyncImpl.kt index ba6ba04f..7925b3d6 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CacheServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CacheServiceAsyncImpl.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async +package io.imagekit.api.services.async -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.services.async.cache.InvalidationServiceAsync -import io.imagekit.io.services.async.cache.InvalidationServiceAsyncImpl +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.services.async.cache.InvalidationServiceAsync +import io.imagekit.api.services.async.cache.InvalidationServiceAsyncImpl import java.util.function.Consumer class CacheServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CustomMetadataFieldServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CustomMetadataFieldServiceAsync.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CustomMetadataFieldServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CustomMetadataFieldServiceAsync.kt index e34966a6..d7fe5574 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CustomMetadataFieldServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CustomMetadataFieldServiceAsync.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.custommetadatafields.CustomMetadataField -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldCreateParams -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldDeleteParams -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldDeleteResponse -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldListParams -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldUpdateParams +package io.imagekit.api.services.async + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.custommetadatafields.CustomMetadataField +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CustomMetadataFieldServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CustomMetadataFieldServiceAsyncImpl.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CustomMetadataFieldServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CustomMetadataFieldServiceAsyncImpl.kt index e4aed63f..8ebc7fdc 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/CustomMetadataFieldServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CustomMetadataFieldServiceAsyncImpl.kt @@ -1,27 +1,27 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.json -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepareAsync -import io.imagekit.io.models.custommetadatafields.CustomMetadataField -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldCreateParams -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldDeleteParams -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldDeleteResponse -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldListParams -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldUpdateParams +package io.imagekit.api.services.async + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.json +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepareAsync +import io.imagekit.api.models.custommetadatafields.CustomMetadataField +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FileServiceAsync.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FileServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FileServiceAsync.kt index 29ec4e54..9988fc96 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FileServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FileServiceAsync.kt @@ -1,27 +1,27 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.files.File -import io.imagekit.io.models.files.FileCopyParams -import io.imagekit.io.models.files.FileCopyResponse -import io.imagekit.io.models.files.FileDeleteParams -import io.imagekit.io.models.files.FileGetParams -import io.imagekit.io.models.files.FileMoveParams -import io.imagekit.io.models.files.FileMoveResponse -import io.imagekit.io.models.files.FileRenameParams -import io.imagekit.io.models.files.FileRenameResponse -import io.imagekit.io.models.files.FileUpdateParams -import io.imagekit.io.models.files.FileUpdateResponse -import io.imagekit.io.models.files.FileUploadParams -import io.imagekit.io.models.files.FileUploadResponse -import io.imagekit.io.services.async.files.BulkServiceAsync -import io.imagekit.io.services.async.files.MetadataServiceAsync -import io.imagekit.io.services.async.files.VersionServiceAsync +package io.imagekit.api.services.async + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.files.File +import io.imagekit.api.models.files.FileCopyParams +import io.imagekit.api.models.files.FileCopyResponse +import io.imagekit.api.models.files.FileDeleteParams +import io.imagekit.api.models.files.FileGetParams +import io.imagekit.api.models.files.FileMoveParams +import io.imagekit.api.models.files.FileMoveResponse +import io.imagekit.api.models.files.FileRenameParams +import io.imagekit.api.models.files.FileRenameResponse +import io.imagekit.api.models.files.FileUpdateParams +import io.imagekit.api.models.files.FileUpdateResponse +import io.imagekit.api.models.files.FileUploadParams +import io.imagekit.api.models.files.FileUploadResponse +import io.imagekit.api.services.async.files.BulkServiceAsync +import io.imagekit.api.services.async.files.MetadataServiceAsync +import io.imagekit.api.services.async.files.VersionServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FileServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FileServiceAsyncImpl.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FileServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FileServiceAsyncImpl.kt index e3fce0f6..07220375 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FileServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FileServiceAsyncImpl.kt @@ -1,42 +1,42 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.handlers.emptyHandler -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.json -import io.imagekit.io.core.http.multipartFormData -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepareAsync -import io.imagekit.io.models.files.File -import io.imagekit.io.models.files.FileCopyParams -import io.imagekit.io.models.files.FileCopyResponse -import io.imagekit.io.models.files.FileDeleteParams -import io.imagekit.io.models.files.FileGetParams -import io.imagekit.io.models.files.FileMoveParams -import io.imagekit.io.models.files.FileMoveResponse -import io.imagekit.io.models.files.FileRenameParams -import io.imagekit.io.models.files.FileRenameResponse -import io.imagekit.io.models.files.FileUpdateParams -import io.imagekit.io.models.files.FileUpdateResponse -import io.imagekit.io.models.files.FileUploadParams -import io.imagekit.io.models.files.FileUploadResponse -import io.imagekit.io.services.async.files.BulkServiceAsync -import io.imagekit.io.services.async.files.BulkServiceAsyncImpl -import io.imagekit.io.services.async.files.MetadataServiceAsync -import io.imagekit.io.services.async.files.MetadataServiceAsyncImpl -import io.imagekit.io.services.async.files.VersionServiceAsync -import io.imagekit.io.services.async.files.VersionServiceAsyncImpl +package io.imagekit.api.services.async + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.handlers.emptyHandler +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.json +import io.imagekit.api.core.http.multipartFormData +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepareAsync +import io.imagekit.api.models.files.File +import io.imagekit.api.models.files.FileCopyParams +import io.imagekit.api.models.files.FileCopyResponse +import io.imagekit.api.models.files.FileDeleteParams +import io.imagekit.api.models.files.FileGetParams +import io.imagekit.api.models.files.FileMoveParams +import io.imagekit.api.models.files.FileMoveResponse +import io.imagekit.api.models.files.FileRenameParams +import io.imagekit.api.models.files.FileRenameResponse +import io.imagekit.api.models.files.FileUpdateParams +import io.imagekit.api.models.files.FileUpdateResponse +import io.imagekit.api.models.files.FileUploadParams +import io.imagekit.api.models.files.FileUploadResponse +import io.imagekit.api.services.async.files.BulkServiceAsync +import io.imagekit.api.services.async.files.BulkServiceAsyncImpl +import io.imagekit.api.services.async.files.MetadataServiceAsync +import io.imagekit.api.services.async.files.MetadataServiceAsyncImpl +import io.imagekit.api.services.async.files.VersionServiceAsync +import io.imagekit.api.services.async.files.VersionServiceAsyncImpl import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FolderServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FolderServiceAsync.kt similarity index 89% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FolderServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FolderServiceAsync.kt index 57354a82..a455aca8 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FolderServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FolderServiceAsync.kt @@ -1,21 +1,21 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.folders.FolderCopyParams -import io.imagekit.io.models.folders.FolderCopyResponse -import io.imagekit.io.models.folders.FolderCreateParams -import io.imagekit.io.models.folders.FolderCreateResponse -import io.imagekit.io.models.folders.FolderDeleteParams -import io.imagekit.io.models.folders.FolderDeleteResponse -import io.imagekit.io.models.folders.FolderMoveParams -import io.imagekit.io.models.folders.FolderMoveResponse -import io.imagekit.io.models.folders.FolderRenameParams -import io.imagekit.io.models.folders.FolderRenameResponse -import io.imagekit.io.services.async.folders.JobServiceAsync +package io.imagekit.api.services.async + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.folders.FolderCopyParams +import io.imagekit.api.models.folders.FolderCopyResponse +import io.imagekit.api.models.folders.FolderCreateParams +import io.imagekit.api.models.folders.FolderCreateResponse +import io.imagekit.api.models.folders.FolderDeleteParams +import io.imagekit.api.models.folders.FolderDeleteResponse +import io.imagekit.api.models.folders.FolderMoveParams +import io.imagekit.api.models.folders.FolderMoveResponse +import io.imagekit.api.models.folders.FolderRenameParams +import io.imagekit.api.models.folders.FolderRenameResponse +import io.imagekit.api.services.async.folders.JobServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FolderServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FolderServiceAsyncImpl.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FolderServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FolderServiceAsyncImpl.kt index c2a728d0..92a21c8a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/FolderServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FolderServiceAsyncImpl.kt @@ -1,32 +1,32 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async +package io.imagekit.api.services.async -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.json -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepareAsync -import io.imagekit.io.models.folders.FolderCopyParams -import io.imagekit.io.models.folders.FolderCopyResponse -import io.imagekit.io.models.folders.FolderCreateParams -import io.imagekit.io.models.folders.FolderCreateResponse -import io.imagekit.io.models.folders.FolderDeleteParams -import io.imagekit.io.models.folders.FolderDeleteResponse -import io.imagekit.io.models.folders.FolderMoveParams -import io.imagekit.io.models.folders.FolderMoveResponse -import io.imagekit.io.models.folders.FolderRenameParams -import io.imagekit.io.models.folders.FolderRenameResponse -import io.imagekit.io.services.async.folders.JobServiceAsync -import io.imagekit.io.services.async.folders.JobServiceAsyncImpl +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.json +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepareAsync +import io.imagekit.api.models.folders.FolderCopyParams +import io.imagekit.api.models.folders.FolderCopyResponse +import io.imagekit.api.models.folders.FolderCreateParams +import io.imagekit.api.models.folders.FolderCreateResponse +import io.imagekit.api.models.folders.FolderDeleteParams +import io.imagekit.api.models.folders.FolderDeleteResponse +import io.imagekit.api.models.folders.FolderMoveParams +import io.imagekit.api.models.folders.FolderMoveResponse +import io.imagekit.api.models.folders.FolderRenameParams +import io.imagekit.api.models.folders.FolderRenameResponse +import io.imagekit.api.services.async.folders.JobServiceAsync +import io.imagekit.api.services.async.folders.JobServiceAsyncImpl import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/SavedExtensionServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/SavedExtensionServiceAsync.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/SavedExtensionServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/SavedExtensionServiceAsync.kt index 99c8b35e..70f5cc8e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/SavedExtensionServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/SavedExtensionServiceAsync.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.SavedExtension -import io.imagekit.io.models.savedextensions.SavedExtensionCreateParams -import io.imagekit.io.models.savedextensions.SavedExtensionDeleteParams -import io.imagekit.io.models.savedextensions.SavedExtensionGetParams -import io.imagekit.io.models.savedextensions.SavedExtensionListParams -import io.imagekit.io.models.savedextensions.SavedExtensionUpdateParams +package io.imagekit.api.services.async + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.SavedExtension +import io.imagekit.api.models.savedextensions.SavedExtensionCreateParams +import io.imagekit.api.models.savedextensions.SavedExtensionDeleteParams +import io.imagekit.api.models.savedextensions.SavedExtensionGetParams +import io.imagekit.api.models.savedextensions.SavedExtensionListParams +import io.imagekit.api.models.savedextensions.SavedExtensionUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/SavedExtensionServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/SavedExtensionServiceAsyncImpl.kt similarity index 89% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/SavedExtensionServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/SavedExtensionServiceAsyncImpl.kt index b5366cba..f289a3cd 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/SavedExtensionServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/SavedExtensionServiceAsyncImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.handlers.emptyHandler -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.json -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepareAsync -import io.imagekit.io.models.SavedExtension -import io.imagekit.io.models.savedextensions.SavedExtensionCreateParams -import io.imagekit.io.models.savedextensions.SavedExtensionDeleteParams -import io.imagekit.io.models.savedextensions.SavedExtensionGetParams -import io.imagekit.io.models.savedextensions.SavedExtensionListParams -import io.imagekit.io.models.savedextensions.SavedExtensionUpdateParams +package io.imagekit.api.services.async + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.handlers.emptyHandler +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.json +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepareAsync +import io.imagekit.api.models.SavedExtension +import io.imagekit.api.models.savedextensions.SavedExtensionCreateParams +import io.imagekit.api.models.savedextensions.SavedExtensionDeleteParams +import io.imagekit.api.models.savedextensions.SavedExtensionGetParams +import io.imagekit.api.models.savedextensions.SavedExtensionListParams +import io.imagekit.api.models.savedextensions.SavedExtensionUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/WebhookServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/WebhookServiceAsync.kt similarity index 82% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/WebhookServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/WebhookServiceAsync.kt index aed8107d..21584614 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/WebhookServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/WebhookServiceAsync.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.UnwrapWebhookParams -import io.imagekit.io.errors.ImageKitInvalidDataException -import io.imagekit.io.errors.ImageKitWebhookException -import io.imagekit.io.models.webhooks.UnsafeUnwrapWebhookEvent -import io.imagekit.io.models.webhooks.UnwrapWebhookEvent +package io.imagekit.api.services.async + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.UnwrapWebhookParams +import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.api.errors.ImageKitWebhookException +import io.imagekit.api.models.webhooks.UnsafeUnwrapWebhookEvent +import io.imagekit.api.models.webhooks.UnwrapWebhookEvent import java.util.function.Consumer interface WebhookServiceAsync { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/WebhookServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/WebhookServiceAsyncImpl.kt similarity index 82% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/WebhookServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/WebhookServiceAsyncImpl.kt index e3a1ef36..c2a5bbd3 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/WebhookServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/WebhookServiceAsyncImpl.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async +package io.imagekit.api.services.async -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.UnwrapWebhookParams -import io.imagekit.io.models.webhooks.UnsafeUnwrapWebhookEvent -import io.imagekit.io.models.webhooks.UnwrapWebhookEvent -import io.imagekit.io.services.blocking.WebhookServiceImpl +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.UnwrapWebhookParams +import io.imagekit.api.models.webhooks.UnsafeUnwrapWebhookEvent +import io.imagekit.api.models.webhooks.UnwrapWebhookEvent +import io.imagekit.api.services.blocking.WebhookServiceImpl import java.util.function.Consumer class WebhookServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/OriginServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/OriginServiceAsync.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/OriginServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/OriginServiceAsync.kt index e05cfd42..ace1dd61 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/OriginServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/OriginServiceAsync.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.accounts - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.accounts.origins.OriginCreateParams -import io.imagekit.io.models.accounts.origins.OriginDeleteParams -import io.imagekit.io.models.accounts.origins.OriginGetParams -import io.imagekit.io.models.accounts.origins.OriginListParams -import io.imagekit.io.models.accounts.origins.OriginRequest -import io.imagekit.io.models.accounts.origins.OriginResponse -import io.imagekit.io.models.accounts.origins.OriginUpdateParams +package io.imagekit.api.services.async.accounts + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.accounts.origins.OriginCreateParams +import io.imagekit.api.models.accounts.origins.OriginDeleteParams +import io.imagekit.api.models.accounts.origins.OriginGetParams +import io.imagekit.api.models.accounts.origins.OriginListParams +import io.imagekit.api.models.accounts.origins.OriginRequest +import io.imagekit.api.models.accounts.origins.OriginResponse +import io.imagekit.api.models.accounts.origins.OriginUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/OriginServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/OriginServiceAsyncImpl.kt similarity index 89% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/OriginServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/OriginServiceAsyncImpl.kt index 238a1c14..7ba0f5e7 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/OriginServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/OriginServiceAsyncImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.accounts - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.handlers.emptyHandler -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.json -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepareAsync -import io.imagekit.io.models.accounts.origins.OriginCreateParams -import io.imagekit.io.models.accounts.origins.OriginDeleteParams -import io.imagekit.io.models.accounts.origins.OriginGetParams -import io.imagekit.io.models.accounts.origins.OriginListParams -import io.imagekit.io.models.accounts.origins.OriginResponse -import io.imagekit.io.models.accounts.origins.OriginUpdateParams +package io.imagekit.api.services.async.accounts + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.handlers.emptyHandler +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.json +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepareAsync +import io.imagekit.api.models.accounts.origins.OriginCreateParams +import io.imagekit.api.models.accounts.origins.OriginDeleteParams +import io.imagekit.api.models.accounts.origins.OriginGetParams +import io.imagekit.api.models.accounts.origins.OriginListParams +import io.imagekit.api.models.accounts.origins.OriginResponse +import io.imagekit.api.models.accounts.origins.OriginUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UrlEndpointServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UrlEndpointServiceAsync.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UrlEndpointServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UrlEndpointServiceAsync.kt index bfae96d4..74c40398 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UrlEndpointServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UrlEndpointServiceAsync.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.accounts - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointCreateParams -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointDeleteParams -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointGetParams -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointListParams -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointRequest -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointResponse -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointUpdateParams +package io.imagekit.api.services.async.accounts + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UrlEndpointServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncImpl.kt similarity index 89% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UrlEndpointServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncImpl.kt index ec8770bf..cd9bf44d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UrlEndpointServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.accounts - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.handlers.emptyHandler -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.json -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepareAsync -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointCreateParams -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointDeleteParams -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointGetParams -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointListParams -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointResponse -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointUpdateParams +package io.imagekit.api.services.async.accounts + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.handlers.emptyHandler +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.json +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepareAsync +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UsageServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UsageServiceAsync.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UsageServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UsageServiceAsync.kt index 08d989e4..5d272a4f 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UsageServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UsageServiceAsync.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.accounts +package io.imagekit.api.services.async.accounts -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.accounts.usage.UsageGetParams -import io.imagekit.io.models.accounts.usage.UsageGetResponse +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.accounts.usage.UsageGetParams +import io.imagekit.api.models.accounts.usage.UsageGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UsageServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UsageServiceAsyncImpl.kt similarity index 79% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UsageServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UsageServiceAsyncImpl.kt index 7e2ad1d2..a0984331 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/accounts/UsageServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UsageServiceAsyncImpl.kt @@ -1,21 +1,21 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.accounts +package io.imagekit.api.services.async.accounts -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepareAsync -import io.imagekit.io.models.accounts.usage.UsageGetParams -import io.imagekit.io.models.accounts.usage.UsageGetResponse +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepareAsync +import io.imagekit.api.models.accounts.usage.UsageGetParams +import io.imagekit.api.models.accounts.usage.UsageGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/V2ServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/V2ServiceAsync.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/V2ServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/V2ServiceAsync.kt index 1b4e61f5..795b5c70 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/V2ServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/V2ServiceAsync.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.beta +package io.imagekit.api.services.async.beta -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.services.async.beta.v2.FileServiceAsync +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.services.async.beta.v2.FileServiceAsync import java.util.function.Consumer interface V2ServiceAsync { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/V2ServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/V2ServiceAsyncImpl.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/V2ServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/V2ServiceAsyncImpl.kt index b254fd2a..ba1a287e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/V2ServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/V2ServiceAsyncImpl.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.beta +package io.imagekit.api.services.async.beta -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.services.async.beta.v2.FileServiceAsync -import io.imagekit.io.services.async.beta.v2.FileServiceAsyncImpl +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.services.async.beta.v2.FileServiceAsync +import io.imagekit.api.services.async.beta.v2.FileServiceAsyncImpl import java.util.function.Consumer class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/v2/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/v2/FileServiceAsync.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/v2/FileServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/v2/FileServiceAsync.kt index 2b43a16c..aa7d9a99 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/v2/FileServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/v2/FileServiceAsync.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.beta.v2 +package io.imagekit.api.services.async.beta.v2 -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.beta.v2.files.FileUploadParams -import io.imagekit.io.models.beta.v2.files.FileUploadResponse +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.beta.v2.files.FileUploadParams +import io.imagekit.api.models.beta.v2.files.FileUploadResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/v2/FileServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/v2/FileServiceAsyncImpl.kt similarity index 79% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/v2/FileServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/v2/FileServiceAsyncImpl.kt index 8d90b871..dbc739e8 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/beta/v2/FileServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/v2/FileServiceAsyncImpl.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.beta.v2 +package io.imagekit.api.services.async.beta.v2 -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.multipartFormData -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepareAsync -import io.imagekit.io.models.beta.v2.files.FileUploadParams -import io.imagekit.io.models.beta.v2.files.FileUploadResponse +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.multipartFormData +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepareAsync +import io.imagekit.api.models.beta.v2.files.FileUploadParams +import io.imagekit.api.models.beta.v2.files.FileUploadResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/cache/InvalidationServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/cache/InvalidationServiceAsync.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/cache/InvalidationServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/cache/InvalidationServiceAsync.kt index a520b176..2f50da90 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/cache/InvalidationServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/cache/InvalidationServiceAsync.kt @@ -1,14 +1,14 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.cache - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.cache.invalidation.InvalidationCreateParams -import io.imagekit.io.models.cache.invalidation.InvalidationCreateResponse -import io.imagekit.io.models.cache.invalidation.InvalidationGetParams -import io.imagekit.io.models.cache.invalidation.InvalidationGetResponse +package io.imagekit.api.services.async.cache + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.cache.invalidation.InvalidationCreateParams +import io.imagekit.api.models.cache.invalidation.InvalidationCreateResponse +import io.imagekit.api.models.cache.invalidation.InvalidationGetParams +import io.imagekit.api.models.cache.invalidation.InvalidationGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/cache/InvalidationServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/cache/InvalidationServiceAsyncImpl.kt similarity index 83% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/cache/InvalidationServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/cache/InvalidationServiceAsyncImpl.kt index edf9c8f0..8fb4fb67 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/cache/InvalidationServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/cache/InvalidationServiceAsyncImpl.kt @@ -1,25 +1,25 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.cache +package io.imagekit.api.services.async.cache -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.json -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepareAsync -import io.imagekit.io.models.cache.invalidation.InvalidationCreateParams -import io.imagekit.io.models.cache.invalidation.InvalidationCreateResponse -import io.imagekit.io.models.cache.invalidation.InvalidationGetParams -import io.imagekit.io.models.cache.invalidation.InvalidationGetResponse +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.json +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepareAsync +import io.imagekit.api.models.cache.invalidation.InvalidationCreateParams +import io.imagekit.api.models.cache.invalidation.InvalidationCreateResponse +import io.imagekit.api.models.cache.invalidation.InvalidationGetParams +import io.imagekit.api.models.cache.invalidation.InvalidationGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/BulkServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/BulkServiceAsync.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/BulkServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/BulkServiceAsync.kt index 678856da..fb6db5c8 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/BulkServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/BulkServiceAsync.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.files - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.files.bulk.BulkAddTagsParams -import io.imagekit.io.models.files.bulk.BulkAddTagsResponse -import io.imagekit.io.models.files.bulk.BulkDeleteParams -import io.imagekit.io.models.files.bulk.BulkDeleteResponse -import io.imagekit.io.models.files.bulk.BulkRemoveAiTagsParams -import io.imagekit.io.models.files.bulk.BulkRemoveAiTagsResponse -import io.imagekit.io.models.files.bulk.BulkRemoveTagsParams -import io.imagekit.io.models.files.bulk.BulkRemoveTagsResponse +package io.imagekit.api.services.async.files + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.files.bulk.BulkAddTagsParams +import io.imagekit.api.models.files.bulk.BulkAddTagsResponse +import io.imagekit.api.models.files.bulk.BulkDeleteParams +import io.imagekit.api.models.files.bulk.BulkDeleteResponse +import io.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams +import io.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse +import io.imagekit.api.models.files.bulk.BulkRemoveTagsParams +import io.imagekit.api.models.files.bulk.BulkRemoveTagsResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/BulkServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/BulkServiceAsyncImpl.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/BulkServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/BulkServiceAsyncImpl.kt index 6a4a72b8..07518862 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/BulkServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/BulkServiceAsyncImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.files - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.json -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepareAsync -import io.imagekit.io.models.files.bulk.BulkAddTagsParams -import io.imagekit.io.models.files.bulk.BulkAddTagsResponse -import io.imagekit.io.models.files.bulk.BulkDeleteParams -import io.imagekit.io.models.files.bulk.BulkDeleteResponse -import io.imagekit.io.models.files.bulk.BulkRemoveAiTagsParams -import io.imagekit.io.models.files.bulk.BulkRemoveAiTagsResponse -import io.imagekit.io.models.files.bulk.BulkRemoveTagsParams -import io.imagekit.io.models.files.bulk.BulkRemoveTagsResponse +package io.imagekit.api.services.async.files + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.json +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepareAsync +import io.imagekit.api.models.files.bulk.BulkAddTagsParams +import io.imagekit.api.models.files.bulk.BulkAddTagsResponse +import io.imagekit.api.models.files.bulk.BulkDeleteParams +import io.imagekit.api.models.files.bulk.BulkDeleteResponse +import io.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams +import io.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse +import io.imagekit.api.models.files.bulk.BulkRemoveTagsParams +import io.imagekit.api.models.files.bulk.BulkRemoveTagsResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/MetadataServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/MetadataServiceAsync.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/MetadataServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/MetadataServiceAsync.kt index d314bcb0..e6dccc4d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/MetadataServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/MetadataServiceAsync.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.files - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.files.Metadata -import io.imagekit.io.models.files.metadata.MetadataGetFromUrlParams -import io.imagekit.io.models.files.metadata.MetadataGetParams +package io.imagekit.api.services.async.files + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.files.Metadata +import io.imagekit.api.models.files.metadata.MetadataGetFromUrlParams +import io.imagekit.api.models.files.metadata.MetadataGetParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/MetadataServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/MetadataServiceAsyncImpl.kt similarity index 84% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/MetadataServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/MetadataServiceAsyncImpl.kt index 5031ec4f..218afe26 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/MetadataServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/MetadataServiceAsyncImpl.kt @@ -1,23 +1,23 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.files +package io.imagekit.api.services.async.files -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepareAsync -import io.imagekit.io.models.files.Metadata -import io.imagekit.io.models.files.metadata.MetadataGetFromUrlParams -import io.imagekit.io.models.files.metadata.MetadataGetParams +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepareAsync +import io.imagekit.api.models.files.Metadata +import io.imagekit.api.models.files.metadata.MetadataGetFromUrlParams +import io.imagekit.api.models.files.metadata.MetadataGetParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/VersionServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/VersionServiceAsync.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/VersionServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/VersionServiceAsync.kt index 490362f0..3559bd31 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/VersionServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/VersionServiceAsync.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.files - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.files.File -import io.imagekit.io.models.files.versions.VersionDeleteParams -import io.imagekit.io.models.files.versions.VersionDeleteResponse -import io.imagekit.io.models.files.versions.VersionGetParams -import io.imagekit.io.models.files.versions.VersionListParams -import io.imagekit.io.models.files.versions.VersionRestoreParams +package io.imagekit.api.services.async.files + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.files.File +import io.imagekit.api.models.files.versions.VersionDeleteParams +import io.imagekit.api.models.files.versions.VersionDeleteResponse +import io.imagekit.api.models.files.versions.VersionGetParams +import io.imagekit.api.models.files.versions.VersionListParams +import io.imagekit.api.models.files.versions.VersionRestoreParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/VersionServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/VersionServiceAsyncImpl.kt similarity index 89% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/VersionServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/VersionServiceAsyncImpl.kt index 23bc5802..c552cce0 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/files/VersionServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/VersionServiceAsyncImpl.kt @@ -1,27 +1,27 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.files - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.json -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepareAsync -import io.imagekit.io.models.files.File -import io.imagekit.io.models.files.versions.VersionDeleteParams -import io.imagekit.io.models.files.versions.VersionDeleteResponse -import io.imagekit.io.models.files.versions.VersionGetParams -import io.imagekit.io.models.files.versions.VersionListParams -import io.imagekit.io.models.files.versions.VersionRestoreParams +package io.imagekit.api.services.async.files + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.json +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepareAsync +import io.imagekit.api.models.files.File +import io.imagekit.api.models.files.versions.VersionDeleteParams +import io.imagekit.api.models.files.versions.VersionDeleteResponse +import io.imagekit.api.models.files.versions.VersionGetParams +import io.imagekit.api.models.files.versions.VersionListParams +import io.imagekit.api.models.files.versions.VersionRestoreParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/folders/JobServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/folders/JobServiceAsync.kt similarity index 92% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/folders/JobServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/folders/JobServiceAsync.kt index cc6a4bfe..d3f41024 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/folders/JobServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/folders/JobServiceAsync.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.folders +package io.imagekit.api.services.async.folders -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.folders.job.JobGetParams -import io.imagekit.io.models.folders.job.JobGetResponse +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.folders.job.JobGetParams +import io.imagekit.api.models.folders.job.JobGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/folders/JobServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/folders/JobServiceAsyncImpl.kt similarity index 79% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/folders/JobServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/folders/JobServiceAsyncImpl.kt index 315718b5..ae7703ca 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/async/folders/JobServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/folders/JobServiceAsyncImpl.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.folders +package io.imagekit.api.services.async.folders -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepareAsync -import io.imagekit.io.models.folders.job.JobGetParams -import io.imagekit.io.models.folders.job.JobGetResponse +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepareAsync +import io.imagekit.api.models.folders.job.JobGetParams +import io.imagekit.api.models.folders.job.JobGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AccountService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AccountService.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AccountService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AccountService.kt index 4643e217..95795703 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AccountService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AccountService.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking +package io.imagekit.api.services.blocking -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.services.blocking.accounts.OriginService -import io.imagekit.io.services.blocking.accounts.UrlEndpointService -import io.imagekit.io.services.blocking.accounts.UsageService +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.services.blocking.accounts.OriginService +import io.imagekit.api.services.blocking.accounts.UrlEndpointService +import io.imagekit.api.services.blocking.accounts.UsageService import java.util.function.Consumer interface AccountService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AccountServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AccountServiceImpl.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AccountServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AccountServiceImpl.kt index d437536e..5c10a8cf 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AccountServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AccountServiceImpl.kt @@ -1,14 +1,14 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.services.blocking.accounts.OriginService -import io.imagekit.io.services.blocking.accounts.OriginServiceImpl -import io.imagekit.io.services.blocking.accounts.UrlEndpointService -import io.imagekit.io.services.blocking.accounts.UrlEndpointServiceImpl -import io.imagekit.io.services.blocking.accounts.UsageService -import io.imagekit.io.services.blocking.accounts.UsageServiceImpl +package io.imagekit.api.services.blocking + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.services.blocking.accounts.OriginService +import io.imagekit.api.services.blocking.accounts.OriginServiceImpl +import io.imagekit.api.services.blocking.accounts.UrlEndpointService +import io.imagekit.api.services.blocking.accounts.UrlEndpointServiceImpl +import io.imagekit.api.services.blocking.accounts.UsageService +import io.imagekit.api.services.blocking.accounts.UsageServiceImpl import java.util.function.Consumer class AccountServiceImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AssetService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AssetService.kt similarity index 90% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AssetService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AssetService.kt index b55e492b..508d8533 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AssetService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AssetService.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking +package io.imagekit.api.services.blocking import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.assets.AssetListParams -import io.imagekit.io.models.assets.AssetListResponse +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.assets.AssetListParams +import io.imagekit.api.models.assets.AssetListResponse import java.util.function.Consumer interface AssetService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AssetServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AssetServiceImpl.kt similarity index 77% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AssetServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AssetServiceImpl.kt index a6ff5784..4626620e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/AssetServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AssetServiceImpl.kt @@ -1,21 +1,21 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking +package io.imagekit.api.services.blocking -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepare -import io.imagekit.io.models.assets.AssetListParams -import io.imagekit.io.models.assets.AssetListResponse +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepare +import io.imagekit.api.models.assets.AssetListParams +import io.imagekit.api.models.assets.AssetListResponse import java.util.function.Consumer class AssetServiceImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/BetaService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/BetaService.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/BetaService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/BetaService.kt index 911cffec..b090eb03 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/BetaService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/BetaService.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking +package io.imagekit.api.services.blocking -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.services.blocking.beta.V2Service +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.services.blocking.beta.V2Service import java.util.function.Consumer interface BetaService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/BetaServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/BetaServiceImpl.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/BetaServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/BetaServiceImpl.kt index f8aef7c7..5953a110 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/BetaServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/BetaServiceImpl.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking +package io.imagekit.api.services.blocking -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.services.blocking.beta.V2Service -import io.imagekit.io.services.blocking.beta.V2ServiceImpl +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.services.blocking.beta.V2Service +import io.imagekit.api.services.blocking.beta.V2ServiceImpl import java.util.function.Consumer class BetaServiceImpl internal constructor(private val clientOptions: ClientOptions) : BetaService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CacheService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CacheService.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CacheService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CacheService.kt index 8283818e..f92ffbe5 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CacheService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CacheService.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking +package io.imagekit.api.services.blocking -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.services.blocking.cache.InvalidationService +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.services.blocking.cache.InvalidationService import java.util.function.Consumer interface CacheService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CacheServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CacheServiceImpl.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CacheServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CacheServiceImpl.kt index a307d223..4df61fe6 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CacheServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CacheServiceImpl.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking +package io.imagekit.api.services.blocking -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.services.blocking.cache.InvalidationService -import io.imagekit.io.services.blocking.cache.InvalidationServiceImpl +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.services.blocking.cache.InvalidationService +import io.imagekit.api.services.blocking.cache.InvalidationServiceImpl import java.util.function.Consumer class CacheServiceImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CustomMetadataFieldService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CustomMetadataFieldService.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CustomMetadataFieldService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CustomMetadataFieldService.kt index 992332f0..19bcb0dc 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CustomMetadataFieldService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CustomMetadataFieldService.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking +package io.imagekit.api.services.blocking import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.custommetadatafields.CustomMetadataField -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldCreateParams -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldDeleteParams -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldDeleteResponse -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldListParams -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldUpdateParams +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.custommetadatafields.CustomMetadataField +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams import java.util.function.Consumer interface CustomMetadataFieldService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CustomMetadataFieldServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CustomMetadataFieldServiceImpl.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CustomMetadataFieldServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CustomMetadataFieldServiceImpl.kt index 84563b6f..bbb5b94a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/CustomMetadataFieldServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CustomMetadataFieldServiceImpl.kt @@ -1,27 +1,27 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.json -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepare -import io.imagekit.io.models.custommetadatafields.CustomMetadataField -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldCreateParams -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldDeleteParams -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldDeleteResponse -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldListParams -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldUpdateParams +package io.imagekit.api.services.blocking + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.json +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepare +import io.imagekit.api.models.custommetadatafields.CustomMetadataField +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FileService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FileService.kt similarity index 92% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FileService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FileService.kt index 6f873938..cab5f57e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FileService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FileService.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking +package io.imagekit.api.services.blocking import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.files.File -import io.imagekit.io.models.files.FileCopyParams -import io.imagekit.io.models.files.FileCopyResponse -import io.imagekit.io.models.files.FileDeleteParams -import io.imagekit.io.models.files.FileGetParams -import io.imagekit.io.models.files.FileMoveParams -import io.imagekit.io.models.files.FileMoveResponse -import io.imagekit.io.models.files.FileRenameParams -import io.imagekit.io.models.files.FileRenameResponse -import io.imagekit.io.models.files.FileUpdateParams -import io.imagekit.io.models.files.FileUpdateResponse -import io.imagekit.io.models.files.FileUploadParams -import io.imagekit.io.models.files.FileUploadResponse -import io.imagekit.io.services.blocking.files.BulkService -import io.imagekit.io.services.blocking.files.MetadataService -import io.imagekit.io.services.blocking.files.VersionService +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.files.File +import io.imagekit.api.models.files.FileCopyParams +import io.imagekit.api.models.files.FileCopyResponse +import io.imagekit.api.models.files.FileDeleteParams +import io.imagekit.api.models.files.FileGetParams +import io.imagekit.api.models.files.FileMoveParams +import io.imagekit.api.models.files.FileMoveResponse +import io.imagekit.api.models.files.FileRenameParams +import io.imagekit.api.models.files.FileRenameResponse +import io.imagekit.api.models.files.FileUpdateParams +import io.imagekit.api.models.files.FileUpdateResponse +import io.imagekit.api.models.files.FileUploadParams +import io.imagekit.api.models.files.FileUploadResponse +import io.imagekit.api.services.blocking.files.BulkService +import io.imagekit.api.services.blocking.files.MetadataService +import io.imagekit.api.services.blocking.files.VersionService import java.util.function.Consumer interface FileService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FileServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FileServiceImpl.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FileServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FileServiceImpl.kt index d61f3bc6..d8c59a86 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FileServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FileServiceImpl.kt @@ -1,42 +1,42 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.handlers.emptyHandler -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.json -import io.imagekit.io.core.http.multipartFormData -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepare -import io.imagekit.io.models.files.File -import io.imagekit.io.models.files.FileCopyParams -import io.imagekit.io.models.files.FileCopyResponse -import io.imagekit.io.models.files.FileDeleteParams -import io.imagekit.io.models.files.FileGetParams -import io.imagekit.io.models.files.FileMoveParams -import io.imagekit.io.models.files.FileMoveResponse -import io.imagekit.io.models.files.FileRenameParams -import io.imagekit.io.models.files.FileRenameResponse -import io.imagekit.io.models.files.FileUpdateParams -import io.imagekit.io.models.files.FileUpdateResponse -import io.imagekit.io.models.files.FileUploadParams -import io.imagekit.io.models.files.FileUploadResponse -import io.imagekit.io.services.blocking.files.BulkService -import io.imagekit.io.services.blocking.files.BulkServiceImpl -import io.imagekit.io.services.blocking.files.MetadataService -import io.imagekit.io.services.blocking.files.MetadataServiceImpl -import io.imagekit.io.services.blocking.files.VersionService -import io.imagekit.io.services.blocking.files.VersionServiceImpl +package io.imagekit.api.services.blocking + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.handlers.emptyHandler +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.json +import io.imagekit.api.core.http.multipartFormData +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepare +import io.imagekit.api.models.files.File +import io.imagekit.api.models.files.FileCopyParams +import io.imagekit.api.models.files.FileCopyResponse +import io.imagekit.api.models.files.FileDeleteParams +import io.imagekit.api.models.files.FileGetParams +import io.imagekit.api.models.files.FileMoveParams +import io.imagekit.api.models.files.FileMoveResponse +import io.imagekit.api.models.files.FileRenameParams +import io.imagekit.api.models.files.FileRenameResponse +import io.imagekit.api.models.files.FileUpdateParams +import io.imagekit.api.models.files.FileUpdateResponse +import io.imagekit.api.models.files.FileUploadParams +import io.imagekit.api.models.files.FileUploadResponse +import io.imagekit.api.services.blocking.files.BulkService +import io.imagekit.api.services.blocking.files.BulkServiceImpl +import io.imagekit.api.services.blocking.files.MetadataService +import io.imagekit.api.services.blocking.files.MetadataServiceImpl +import io.imagekit.api.services.blocking.files.VersionService +import io.imagekit.api.services.blocking.files.VersionServiceImpl import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FolderService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FolderService.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FolderService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FolderService.kt index 622a1439..7bb974bf 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FolderService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FolderService.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking +package io.imagekit.api.services.blocking import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.folders.FolderCopyParams -import io.imagekit.io.models.folders.FolderCopyResponse -import io.imagekit.io.models.folders.FolderCreateParams -import io.imagekit.io.models.folders.FolderCreateResponse -import io.imagekit.io.models.folders.FolderDeleteParams -import io.imagekit.io.models.folders.FolderDeleteResponse -import io.imagekit.io.models.folders.FolderMoveParams -import io.imagekit.io.models.folders.FolderMoveResponse -import io.imagekit.io.models.folders.FolderRenameParams -import io.imagekit.io.models.folders.FolderRenameResponse -import io.imagekit.io.services.blocking.folders.JobService +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.folders.FolderCopyParams +import io.imagekit.api.models.folders.FolderCopyResponse +import io.imagekit.api.models.folders.FolderCreateParams +import io.imagekit.api.models.folders.FolderCreateResponse +import io.imagekit.api.models.folders.FolderDeleteParams +import io.imagekit.api.models.folders.FolderDeleteResponse +import io.imagekit.api.models.folders.FolderMoveParams +import io.imagekit.api.models.folders.FolderMoveResponse +import io.imagekit.api.models.folders.FolderRenameParams +import io.imagekit.api.models.folders.FolderRenameResponse +import io.imagekit.api.services.blocking.folders.JobService import java.util.function.Consumer interface FolderService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FolderServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FolderServiceImpl.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FolderServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FolderServiceImpl.kt index 95bb5888..1446fa71 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/FolderServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FolderServiceImpl.kt @@ -1,32 +1,32 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.json -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepare -import io.imagekit.io.models.folders.FolderCopyParams -import io.imagekit.io.models.folders.FolderCopyResponse -import io.imagekit.io.models.folders.FolderCreateParams -import io.imagekit.io.models.folders.FolderCreateResponse -import io.imagekit.io.models.folders.FolderDeleteParams -import io.imagekit.io.models.folders.FolderDeleteResponse -import io.imagekit.io.models.folders.FolderMoveParams -import io.imagekit.io.models.folders.FolderMoveResponse -import io.imagekit.io.models.folders.FolderRenameParams -import io.imagekit.io.models.folders.FolderRenameResponse -import io.imagekit.io.services.blocking.folders.JobService -import io.imagekit.io.services.blocking.folders.JobServiceImpl +package io.imagekit.api.services.blocking + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.json +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepare +import io.imagekit.api.models.folders.FolderCopyParams +import io.imagekit.api.models.folders.FolderCopyResponse +import io.imagekit.api.models.folders.FolderCreateParams +import io.imagekit.api.models.folders.FolderCreateResponse +import io.imagekit.api.models.folders.FolderDeleteParams +import io.imagekit.api.models.folders.FolderDeleteResponse +import io.imagekit.api.models.folders.FolderMoveParams +import io.imagekit.api.models.folders.FolderMoveResponse +import io.imagekit.api.models.folders.FolderRenameParams +import io.imagekit.api.models.folders.FolderRenameResponse +import io.imagekit.api.services.blocking.folders.JobService +import io.imagekit.api.services.blocking.folders.JobServiceImpl import java.util.function.Consumer class FolderServiceImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/SavedExtensionService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/SavedExtensionService.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/SavedExtensionService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/SavedExtensionService.kt index 547729b0..edbd1687 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/SavedExtensionService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/SavedExtensionService.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking +package io.imagekit.api.services.blocking import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.SavedExtension -import io.imagekit.io.models.savedextensions.SavedExtensionCreateParams -import io.imagekit.io.models.savedextensions.SavedExtensionDeleteParams -import io.imagekit.io.models.savedextensions.SavedExtensionGetParams -import io.imagekit.io.models.savedextensions.SavedExtensionListParams -import io.imagekit.io.models.savedextensions.SavedExtensionUpdateParams +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.SavedExtension +import io.imagekit.api.models.savedextensions.SavedExtensionCreateParams +import io.imagekit.api.models.savedextensions.SavedExtensionDeleteParams +import io.imagekit.api.models.savedextensions.SavedExtensionGetParams +import io.imagekit.api.models.savedextensions.SavedExtensionListParams +import io.imagekit.api.models.savedextensions.SavedExtensionUpdateParams import java.util.function.Consumer interface SavedExtensionService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/SavedExtensionServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/SavedExtensionServiceImpl.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/SavedExtensionServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/SavedExtensionServiceImpl.kt index cba546e4..251a44ad 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/SavedExtensionServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/SavedExtensionServiceImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.handlers.emptyHandler -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.json -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepare -import io.imagekit.io.models.SavedExtension -import io.imagekit.io.models.savedextensions.SavedExtensionCreateParams -import io.imagekit.io.models.savedextensions.SavedExtensionDeleteParams -import io.imagekit.io.models.savedextensions.SavedExtensionGetParams -import io.imagekit.io.models.savedextensions.SavedExtensionListParams -import io.imagekit.io.models.savedextensions.SavedExtensionUpdateParams +package io.imagekit.api.services.blocking + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.handlers.emptyHandler +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.json +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepare +import io.imagekit.api.models.SavedExtension +import io.imagekit.api.models.savedextensions.SavedExtensionCreateParams +import io.imagekit.api.models.savedextensions.SavedExtensionDeleteParams +import io.imagekit.api.models.savedextensions.SavedExtensionGetParams +import io.imagekit.api.models.savedextensions.SavedExtensionListParams +import io.imagekit.api.models.savedextensions.SavedExtensionUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/WebhookService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/WebhookService.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/WebhookService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/WebhookService.kt index e5f4a90b..92a8edde 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/WebhookService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/WebhookService.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.UnwrapWebhookParams -import io.imagekit.io.errors.ImageKitInvalidDataException -import io.imagekit.io.errors.ImageKitWebhookException -import io.imagekit.io.models.webhooks.UnsafeUnwrapWebhookEvent -import io.imagekit.io.models.webhooks.UnwrapWebhookEvent +package io.imagekit.api.services.blocking + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.UnwrapWebhookParams +import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.api.errors.ImageKitWebhookException +import io.imagekit.api.models.webhooks.UnsafeUnwrapWebhookEvent +import io.imagekit.api.models.webhooks.UnwrapWebhookEvent import java.util.function.Consumer interface WebhookService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/WebhookServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/WebhookServiceImpl.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/WebhookServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/WebhookServiceImpl.kt index c550aa22..f78b1220 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/WebhookServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/WebhookServiceImpl.kt @@ -1,18 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.imagekit.api.services.blocking +package io.imagekit.api.services.blocking import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.imagekit.api.core.ClientOptions -import com.imagekit.api.core.UnwrapWebhookParams -import com.imagekit.api.core.checkRequired -import com.imagekit.api.errors.ImageKitInvalidDataException -import com.imagekit.api.errors.ImageKitWebhookException -import com.imagekit.api.models.webhooks.UnsafeUnwrapWebhookEvent -import com.imagekit.api.models.webhooks.UnwrapWebhookEvent import com.standardwebhooks.Webhook import com.standardwebhooks.exceptions.WebhookVerificationException -import java.util.Base64 +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.UnwrapWebhookParams +import io.imagekit.api.core.checkRequired +import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.api.errors.ImageKitWebhookException +import io.imagekit.api.models.webhooks.UnsafeUnwrapWebhookEvent +import io.imagekit.api.models.webhooks.UnwrapWebhookEvent import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -56,8 +55,7 @@ class WebhookServiceImpl internal constructor(private val clientOptions: ClientO val headersMap = headers.names().associateWith { name -> headers.values(name) }.toMap() - val encodedKey = Base64.getEncoder().encodeToString(webhookSecret.toByteArray()) - val webhook = Webhook(encodedKey) + val webhook = Webhook(webhookSecret) webhook.verify(unwrapParams.body(), headersMap) } catch (e: WebhookVerificationException) { throw ImageKitWebhookException("Could not verify webhook event signature", e) diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/OriginService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/OriginService.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/OriginService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/OriginService.kt index 472063d6..3c21f6c8 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/OriginService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/OriginService.kt @@ -1,19 +1,19 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.accounts +package io.imagekit.api.services.blocking.accounts import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.accounts.origins.OriginCreateParams -import io.imagekit.io.models.accounts.origins.OriginDeleteParams -import io.imagekit.io.models.accounts.origins.OriginGetParams -import io.imagekit.io.models.accounts.origins.OriginListParams -import io.imagekit.io.models.accounts.origins.OriginRequest -import io.imagekit.io.models.accounts.origins.OriginResponse -import io.imagekit.io.models.accounts.origins.OriginUpdateParams +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.accounts.origins.OriginCreateParams +import io.imagekit.api.models.accounts.origins.OriginDeleteParams +import io.imagekit.api.models.accounts.origins.OriginGetParams +import io.imagekit.api.models.accounts.origins.OriginListParams +import io.imagekit.api.models.accounts.origins.OriginRequest +import io.imagekit.api.models.accounts.origins.OriginResponse +import io.imagekit.api.models.accounts.origins.OriginUpdateParams import java.util.function.Consumer interface OriginService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/OriginServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/OriginServiceImpl.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/OriginServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/OriginServiceImpl.kt index 1ca54627..d7e56549 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/OriginServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/OriginServiceImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.accounts - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.handlers.emptyHandler -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.json -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepare -import io.imagekit.io.models.accounts.origins.OriginCreateParams -import io.imagekit.io.models.accounts.origins.OriginDeleteParams -import io.imagekit.io.models.accounts.origins.OriginGetParams -import io.imagekit.io.models.accounts.origins.OriginListParams -import io.imagekit.io.models.accounts.origins.OriginResponse -import io.imagekit.io.models.accounts.origins.OriginUpdateParams +package io.imagekit.api.services.blocking.accounts + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.handlers.emptyHandler +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.json +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepare +import io.imagekit.api.models.accounts.origins.OriginCreateParams +import io.imagekit.api.models.accounts.origins.OriginDeleteParams +import io.imagekit.api.models.accounts.origins.OriginGetParams +import io.imagekit.api.models.accounts.origins.OriginListParams +import io.imagekit.api.models.accounts.origins.OriginResponse +import io.imagekit.api.models.accounts.origins.OriginUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UrlEndpointService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UrlEndpointService.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UrlEndpointService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UrlEndpointService.kt index a42045a4..a15b85a8 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UrlEndpointService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UrlEndpointService.kt @@ -1,19 +1,19 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.accounts +package io.imagekit.api.services.blocking.accounts import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointCreateParams -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointDeleteParams -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointGetParams -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointListParams -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointRequest -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointResponse -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointUpdateParams +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams import java.util.function.Consumer interface UrlEndpointService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UrlEndpointServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UrlEndpointServiceImpl.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UrlEndpointServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UrlEndpointServiceImpl.kt index bdf11794..be5dd00a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UrlEndpointServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UrlEndpointServiceImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.accounts - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.handlers.emptyHandler -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.json -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepare -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointCreateParams -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointDeleteParams -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointGetParams -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointListParams -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointResponse -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointUpdateParams +package io.imagekit.api.services.blocking.accounts + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.handlers.emptyHandler +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.json +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepare +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UsageService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UsageService.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UsageService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UsageService.kt index 20971463..14739d50 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UsageService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UsageService.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.accounts +package io.imagekit.api.services.blocking.accounts import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.accounts.usage.UsageGetParams -import io.imagekit.io.models.accounts.usage.UsageGetResponse +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.accounts.usage.UsageGetParams +import io.imagekit.api.models.accounts.usage.UsageGetResponse import java.util.function.Consumer interface UsageService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UsageServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UsageServiceImpl.kt similarity index 76% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UsageServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UsageServiceImpl.kt index 14dc4a17..79e454f3 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/accounts/UsageServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UsageServiceImpl.kt @@ -1,21 +1,21 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.accounts +package io.imagekit.api.services.blocking.accounts -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepare -import io.imagekit.io.models.accounts.usage.UsageGetParams -import io.imagekit.io.models.accounts.usage.UsageGetResponse +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepare +import io.imagekit.api.models.accounts.usage.UsageGetParams +import io.imagekit.api.models.accounts.usage.UsageGetResponse import java.util.function.Consumer class UsageServiceImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/V2Service.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/V2Service.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/V2Service.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/V2Service.kt index 6a5a814b..f8c12520 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/V2Service.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/V2Service.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.beta +package io.imagekit.api.services.blocking.beta -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.services.blocking.beta.v2.FileService +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.services.blocking.beta.v2.FileService import java.util.function.Consumer interface V2Service { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/V2ServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/V2ServiceImpl.kt similarity index 85% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/V2ServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/V2ServiceImpl.kt index 328ed26c..d6dece1f 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/V2ServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/V2ServiceImpl.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.beta +package io.imagekit.api.services.blocking.beta -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.services.blocking.beta.v2.FileService -import io.imagekit.io.services.blocking.beta.v2.FileServiceImpl +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.services.blocking.beta.v2.FileService +import io.imagekit.api.services.blocking.beta.v2.FileServiceImpl import java.util.function.Consumer class V2ServiceImpl internal constructor(private val clientOptions: ClientOptions) : V2Service { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/v2/FileService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/v2/FileService.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/v2/FileService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/v2/FileService.kt index 770891ef..a778b9dd 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/v2/FileService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/v2/FileService.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.beta.v2 +package io.imagekit.api.services.blocking.beta.v2 import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.beta.v2.files.FileUploadParams -import io.imagekit.io.models.beta.v2.files.FileUploadResponse +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.beta.v2.files.FileUploadParams +import io.imagekit.api.models.beta.v2.files.FileUploadResponse import java.util.function.Consumer interface FileService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/v2/FileServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/v2/FileServiceImpl.kt similarity index 77% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/v2/FileServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/v2/FileServiceImpl.kt index e0f1a46f..5d5b0644 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/beta/v2/FileServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/v2/FileServiceImpl.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.beta.v2 +package io.imagekit.api.services.blocking.beta.v2 -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.multipartFormData -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepare -import io.imagekit.io.models.beta.v2.files.FileUploadParams -import io.imagekit.io.models.beta.v2.files.FileUploadResponse +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.multipartFormData +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepare +import io.imagekit.api.models.beta.v2.files.FileUploadParams +import io.imagekit.api.models.beta.v2.files.FileUploadResponse import java.util.function.Consumer class FileServiceImpl internal constructor(private val clientOptions: ClientOptions) : FileService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/cache/InvalidationService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/cache/InvalidationService.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/cache/InvalidationService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/cache/InvalidationService.kt index b4f056ed..a647400d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/cache/InvalidationService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/cache/InvalidationService.kt @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.cache +package io.imagekit.api.services.blocking.cache import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.cache.invalidation.InvalidationCreateParams -import io.imagekit.io.models.cache.invalidation.InvalidationCreateResponse -import io.imagekit.io.models.cache.invalidation.InvalidationGetParams -import io.imagekit.io.models.cache.invalidation.InvalidationGetResponse +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.cache.invalidation.InvalidationCreateParams +import io.imagekit.api.models.cache.invalidation.InvalidationCreateResponse +import io.imagekit.api.models.cache.invalidation.InvalidationGetParams +import io.imagekit.api.models.cache.invalidation.InvalidationGetResponse import java.util.function.Consumer interface InvalidationService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/cache/InvalidationServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/cache/InvalidationServiceImpl.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/cache/InvalidationServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/cache/InvalidationServiceImpl.kt index 999460ec..b1aeeacb 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/cache/InvalidationServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/cache/InvalidationServiceImpl.kt @@ -1,25 +1,25 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.cache +package io.imagekit.api.services.blocking.cache -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.json -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepare -import io.imagekit.io.models.cache.invalidation.InvalidationCreateParams -import io.imagekit.io.models.cache.invalidation.InvalidationCreateResponse -import io.imagekit.io.models.cache.invalidation.InvalidationGetParams -import io.imagekit.io.models.cache.invalidation.InvalidationGetResponse +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.json +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepare +import io.imagekit.api.models.cache.invalidation.InvalidationCreateParams +import io.imagekit.api.models.cache.invalidation.InvalidationCreateResponse +import io.imagekit.api.models.cache.invalidation.InvalidationGetParams +import io.imagekit.api.models.cache.invalidation.InvalidationGetResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/BulkService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/BulkService.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/BulkService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/BulkService.kt index 6282d37d..aa4306b1 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/BulkService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/BulkService.kt @@ -1,19 +1,19 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.files +package io.imagekit.api.services.blocking.files import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.files.bulk.BulkAddTagsParams -import io.imagekit.io.models.files.bulk.BulkAddTagsResponse -import io.imagekit.io.models.files.bulk.BulkDeleteParams -import io.imagekit.io.models.files.bulk.BulkDeleteResponse -import io.imagekit.io.models.files.bulk.BulkRemoveAiTagsParams -import io.imagekit.io.models.files.bulk.BulkRemoveAiTagsResponse -import io.imagekit.io.models.files.bulk.BulkRemoveTagsParams -import io.imagekit.io.models.files.bulk.BulkRemoveTagsResponse +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.files.bulk.BulkAddTagsParams +import io.imagekit.api.models.files.bulk.BulkAddTagsResponse +import io.imagekit.api.models.files.bulk.BulkDeleteParams +import io.imagekit.api.models.files.bulk.BulkDeleteResponse +import io.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams +import io.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse +import io.imagekit.api.models.files.bulk.BulkRemoveTagsParams +import io.imagekit.api.models.files.bulk.BulkRemoveTagsResponse import java.util.function.Consumer interface BulkService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/BulkServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/BulkServiceImpl.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/BulkServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/BulkServiceImpl.kt index 876406f0..e2fc23d9 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/BulkServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/BulkServiceImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.files - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.json -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepare -import io.imagekit.io.models.files.bulk.BulkAddTagsParams -import io.imagekit.io.models.files.bulk.BulkAddTagsResponse -import io.imagekit.io.models.files.bulk.BulkDeleteParams -import io.imagekit.io.models.files.bulk.BulkDeleteResponse -import io.imagekit.io.models.files.bulk.BulkRemoveAiTagsParams -import io.imagekit.io.models.files.bulk.BulkRemoveAiTagsResponse -import io.imagekit.io.models.files.bulk.BulkRemoveTagsParams -import io.imagekit.io.models.files.bulk.BulkRemoveTagsResponse +package io.imagekit.api.services.blocking.files + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.json +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepare +import io.imagekit.api.models.files.bulk.BulkAddTagsParams +import io.imagekit.api.models.files.bulk.BulkAddTagsResponse +import io.imagekit.api.models.files.bulk.BulkDeleteParams +import io.imagekit.api.models.files.bulk.BulkDeleteResponse +import io.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams +import io.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse +import io.imagekit.api.models.files.bulk.BulkRemoveTagsParams +import io.imagekit.api.models.files.bulk.BulkRemoveTagsResponse import java.util.function.Consumer class BulkServiceImpl internal constructor(private val clientOptions: ClientOptions) : BulkService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/MetadataService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/MetadataService.kt similarity index 92% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/MetadataService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/MetadataService.kt index 33f9a650..38a25136 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/MetadataService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/MetadataService.kt @@ -1,14 +1,14 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.files +package io.imagekit.api.services.blocking.files import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.files.Metadata -import io.imagekit.io.models.files.metadata.MetadataGetFromUrlParams -import io.imagekit.io.models.files.metadata.MetadataGetParams +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.files.Metadata +import io.imagekit.api.models.files.metadata.MetadataGetFromUrlParams +import io.imagekit.api.models.files.metadata.MetadataGetParams import java.util.function.Consumer interface MetadataService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/MetadataServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/MetadataServiceImpl.kt similarity index 83% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/MetadataServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/MetadataServiceImpl.kt index a37178c2..e7715008 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/MetadataServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/MetadataServiceImpl.kt @@ -1,23 +1,23 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.files +package io.imagekit.api.services.blocking.files -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepare -import io.imagekit.io.models.files.Metadata -import io.imagekit.io.models.files.metadata.MetadataGetFromUrlParams -import io.imagekit.io.models.files.metadata.MetadataGetParams +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepare +import io.imagekit.api.models.files.Metadata +import io.imagekit.api.models.files.metadata.MetadataGetFromUrlParams +import io.imagekit.api.models.files.metadata.MetadataGetParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/VersionService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/VersionService.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/VersionService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/VersionService.kt index 36eeb6ac..b4128f16 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/VersionService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/VersionService.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.files +package io.imagekit.api.services.blocking.files import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.files.File -import io.imagekit.io.models.files.versions.VersionDeleteParams -import io.imagekit.io.models.files.versions.VersionDeleteResponse -import io.imagekit.io.models.files.versions.VersionGetParams -import io.imagekit.io.models.files.versions.VersionListParams -import io.imagekit.io.models.files.versions.VersionRestoreParams +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.files.File +import io.imagekit.api.models.files.versions.VersionDeleteParams +import io.imagekit.api.models.files.versions.VersionDeleteResponse +import io.imagekit.api.models.files.versions.VersionGetParams +import io.imagekit.api.models.files.versions.VersionListParams +import io.imagekit.api.models.files.versions.VersionRestoreParams import java.util.function.Consumer interface VersionService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/VersionServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/VersionServiceImpl.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/VersionServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/VersionServiceImpl.kt index cc821536..9dc323e7 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/files/VersionServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/VersionServiceImpl.kt @@ -1,27 +1,27 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.files - -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.json -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepare -import io.imagekit.io.models.files.File -import io.imagekit.io.models.files.versions.VersionDeleteParams -import io.imagekit.io.models.files.versions.VersionDeleteResponse -import io.imagekit.io.models.files.versions.VersionGetParams -import io.imagekit.io.models.files.versions.VersionListParams -import io.imagekit.io.models.files.versions.VersionRestoreParams +package io.imagekit.api.services.blocking.files + +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.json +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepare +import io.imagekit.api.models.files.File +import io.imagekit.api.models.files.versions.VersionDeleteParams +import io.imagekit.api.models.files.versions.VersionDeleteResponse +import io.imagekit.api.models.files.versions.VersionGetParams +import io.imagekit.api.models.files.versions.VersionListParams +import io.imagekit.api.models.files.versions.VersionRestoreParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/folders/JobService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/folders/JobService.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/folders/JobService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/folders/JobService.kt index 58150fb1..a72f4d6f 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/folders/JobService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/folders/JobService.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.folders +package io.imagekit.api.services.blocking.folders import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.models.folders.job.JobGetParams -import io.imagekit.io.models.folders.job.JobGetResponse +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.models.folders.job.JobGetParams +import io.imagekit.api.models.folders.job.JobGetResponse import java.util.function.Consumer interface JobService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/folders/JobServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/folders/JobServiceImpl.kt similarity index 77% rename from image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/folders/JobServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/folders/JobServiceImpl.kt index 2cf38510..06026c65 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/io/services/blocking/folders/JobServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/folders/JobServiceImpl.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.folders +package io.imagekit.api.services.blocking.folders -import io.imagekit.io.core.ClientOptions -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.checkRequired -import io.imagekit.io.core.handlers.errorBodyHandler -import io.imagekit.io.core.handlers.errorHandler -import io.imagekit.io.core.handlers.jsonHandler -import io.imagekit.io.core.http.HttpMethod -import io.imagekit.io.core.http.HttpRequest -import io.imagekit.io.core.http.HttpResponse -import io.imagekit.io.core.http.HttpResponse.Handler -import io.imagekit.io.core.http.HttpResponseFor -import io.imagekit.io.core.http.parseable -import io.imagekit.io.core.prepare -import io.imagekit.io.models.folders.job.JobGetParams -import io.imagekit.io.models.folders.job.JobGetResponse +import io.imagekit.api.core.ClientOptions +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.checkRequired +import io.imagekit.api.core.handlers.errorBodyHandler +import io.imagekit.api.core.handlers.errorHandler +import io.imagekit.api.core.handlers.jsonHandler +import io.imagekit.api.core.http.HttpMethod +import io.imagekit.api.core.http.HttpRequest +import io.imagekit.api.core.http.HttpResponse +import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.api.core.http.HttpResponseFor +import io.imagekit.api.core.http.parseable +import io.imagekit.api.core.prepare +import io.imagekit.api.models.folders.job.JobGetParams +import io.imagekit.api.models.folders.job.JobGetResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro b/image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro index f94dc567..e27c5a3f 100644 --- a/image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro +++ b/image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro @@ -22,11 +22,11 @@ -keep class * extends com.fasterxml.jackson.core.type.TypeReference { *; } # Jackson uses reflection to access our class serializers and deserializers. --keep @com.fasterxml.jackson.databind.annotation.JsonSerialize class io.imagekit.io.** { *; } --keep @com.fasterxml.jackson.databind.annotation.JsonDeserialize class io.imagekit.io.** { *; } +-keep @com.fasterxml.jackson.databind.annotation.JsonSerialize class io.imagekit.api.** { *; } +-keep @com.fasterxml.jackson.databind.annotation.JsonDeserialize class io.imagekit.api.** { *; } # Jackson uses reflection to serialize and deserialize our classes based on their constructors and annotated members. --keepclassmembers class io.imagekit.io.** { +-keepclassmembers class io.imagekit.api.** { (...); @com.fasterxml.jackson.annotation.* *; } \ No newline at end of file diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/ClientOptionsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/ClientOptionsTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/core/ClientOptionsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/core/ClientOptionsTest.kt index 52212fa4..afe5ae34 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/ClientOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/ClientOptionsTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.core +package io.imagekit.api.core -import io.imagekit.io.core.http.HttpClient +import io.imagekit.api.core.http.HttpClient import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/ObjectMappersTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/ObjectMappersTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/core/ObjectMappersTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/core/ObjectMappersTest.kt index d08718a9..49fcb0a3 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/ObjectMappersTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/ObjectMappersTest.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.core +package io.imagekit.api.core import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.exc.MismatchedInputException diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/PhantomReachableTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/PhantomReachableTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/core/PhantomReachableTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/core/PhantomReachableTest.kt index 1148b526..2ab6a2c1 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/PhantomReachableTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/PhantomReachableTest.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.core +package io.imagekit.api.core import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/UtilsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/UtilsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/core/UtilsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/core/UtilsTest.kt index 506aee57..bb89dec0 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/UtilsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/UtilsTest.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.core +package io.imagekit.api.core import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/ValuesTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/ValuesTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/core/ValuesTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/core/ValuesTest.kt index 0d5b0d83..6e46df2f 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/ValuesTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/ValuesTest.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.core +package io.imagekit.api.core import java.util.Optional import org.assertj.core.api.Assertions.assertThat diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/AsyncStreamResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/AsyncStreamResponseTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/AsyncStreamResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/AsyncStreamResponseTest.kt index ae33c213..6da4579d 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/AsyncStreamResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/AsyncStreamResponseTest.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.core.http +package io.imagekit.api.core.http import java.util.* import java.util.concurrent.CompletableFuture diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/HeadersTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/HeadersTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/HeadersTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/HeadersTest.kt index 543dc978..514067fa 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/HeadersTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/HeadersTest.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.core.http +package io.imagekit.api.core.http import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.params.ParameterizedTest diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/HttpRequestBodiesTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/HttpRequestBodiesTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/HttpRequestBodiesTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/HttpRequestBodiesTest.kt index abfa9342..c7f66085 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/HttpRequestBodiesTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/HttpRequestBodiesTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.core.http +package io.imagekit.api.core.http -import io.imagekit.io.core.MultipartField -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.MultipartField +import io.imagekit.api.core.jsonMapper import java.io.ByteArrayOutputStream import java.io.InputStream import org.assertj.core.api.Assertions.assertThat diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/HttpRequestTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/HttpRequestTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/HttpRequestTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/HttpRequestTest.kt index 9a0900df..99530868 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/HttpRequestTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/HttpRequestTest.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.core.http +package io.imagekit.api.core.http import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.params.ParameterizedTest diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/QueryParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/QueryParamsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/QueryParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/QueryParamsTest.kt index aa7fe114..b517600c 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/QueryParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/QueryParamsTest.kt @@ -1,4 +1,4 @@ -package io.imagekit.io.core.http +package io.imagekit.api.core.http import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.params.ParameterizedTest diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/RetryingHttpClientTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/RetryingHttpClientTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/RetryingHttpClientTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/RetryingHttpClientTest.kt index 68463a03..b216b9c1 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/core/http/RetryingHttpClientTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/RetryingHttpClientTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.core.http +package io.imagekit.api.core.http import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.matching @@ -15,10 +15,10 @@ import com.github.tomakehurst.wiremock.client.WireMock.verify import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.github.tomakehurst.wiremock.stubbing.Scenario -import io.imagekit.io.client.okhttp.OkHttpClient -import io.imagekit.io.core.RequestOptions -import io.imagekit.io.core.Sleeper -import io.imagekit.io.errors.ImageKitRetryableException +import io.imagekit.api.client.okhttp.OkHttpClient +import io.imagekit.api.core.RequestOptions +import io.imagekit.api.core.Sleeper +import io.imagekit.api.errors.ImageKitRetryableException import java.io.InputStream import java.time.Clock import java.time.Duration diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/AiTagTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/AiTagTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/AiTagTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/AiTagTest.kt index 8d41108c..6f234dbc 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/AiTagTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/AiTagTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/BaseOverlayTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/BaseOverlayTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/BaseOverlayTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/BaseOverlayTest.kt index 3cfb1f4c..881c8928 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/BaseOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/BaseOverlayTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/CustomMetadataTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/CustomMetadataTest.kt similarity index 89% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/CustomMetadataTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/CustomMetadataTest.kt index b90d9dea..901186f5 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/CustomMetadataTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/CustomMetadataTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/EmbeddedMetadataTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/EmbeddedMetadataTest.kt similarity index 89% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/EmbeddedMetadataTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/EmbeddedMetadataTest.kt index fc859110..b15e16ce 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/EmbeddedMetadataTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/EmbeddedMetadataTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ExtensionConfigTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ExtensionConfigTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ExtensionConfigTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ExtensionConfigTest.kt index 0deb4df3..485a0aed 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ExtensionConfigTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ExtensionConfigTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper +import io.imagekit.api.errors.ImageKitInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ExtensionItemTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ExtensionItemTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ExtensionItemTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ExtensionItemTest.kt index f45dc441..8671b7a0 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ExtensionItemTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ExtensionItemTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper +import io.imagekit.api.errors.ImageKitInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/GetImageAttributesOptionsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/GetImageAttributesOptionsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/GetImageAttributesOptionsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/GetImageAttributesOptionsTest.kt index 2b5c3afe..ed603458 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/GetImageAttributesOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/GetImageAttributesOptionsTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ImageOverlayTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ImageOverlayTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ImageOverlayTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ImageOverlayTest.kt index c904e328..cf7477f8 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ImageOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ImageOverlayTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/OverlayPositionTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/OverlayPositionTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/OverlayPositionTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/OverlayPositionTest.kt index 3c7a15e5..095a640f 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/OverlayPositionTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/OverlayPositionTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/OverlayTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/OverlayTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/OverlayTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/OverlayTest.kt index ba1322af..a0259653 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/OverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/OverlayTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper +import io.imagekit.api.errors.ImageKitInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/OverlayTimingTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/OverlayTimingTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/OverlayTimingTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/OverlayTimingTest.kt index feb5042e..47b42054 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/OverlayTimingTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/OverlayTimingTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ResponsiveImageAttributesTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ResponsiveImageAttributesTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ResponsiveImageAttributesTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ResponsiveImageAttributesTest.kt index 884b12fe..90e879ff 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/ResponsiveImageAttributesTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ResponsiveImageAttributesTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SavedExtensionTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SavedExtensionTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SavedExtensionTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SavedExtensionTest.kt index 7edc6515..0e5c351b 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SavedExtensionTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SavedExtensionTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SelectedFieldsSchemaTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SelectedFieldsSchemaTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SelectedFieldsSchemaTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SelectedFieldsSchemaTest.kt index 5bd98100..aef3843c 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SelectedFieldsSchemaTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SelectedFieldsSchemaTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SolidColorOverlayTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SolidColorOverlayTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SolidColorOverlayTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SolidColorOverlayTest.kt index 13d14139..db7fd679 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SolidColorOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SolidColorOverlayTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SolidColorOverlayTransformationTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SolidColorOverlayTransformationTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SolidColorOverlayTransformationTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SolidColorOverlayTransformationTest.kt index bea6fd98..a9155038 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SolidColorOverlayTransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SolidColorOverlayTransformationTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SrcOptionsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SrcOptionsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SrcOptionsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SrcOptionsTest.kt index 4572a0cc..3f7d4897 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SrcOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SrcOptionsTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SubtitleOverlayTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SubtitleOverlayTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SubtitleOverlayTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SubtitleOverlayTest.kt index a0bf7f54..66f172e4 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SubtitleOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SubtitleOverlayTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SubtitleOverlayTransformationTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SubtitleOverlayTransformationTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SubtitleOverlayTransformationTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SubtitleOverlayTransformationTest.kt index f6d681d4..bf391385 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/SubtitleOverlayTransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SubtitleOverlayTransformationTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/TextOverlayTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/TextOverlayTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/TextOverlayTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/TextOverlayTest.kt index 0299dff9..2d347db1 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/TextOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/TextOverlayTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/TextOverlayTransformationTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/TextOverlayTransformationTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/TextOverlayTransformationTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/TextOverlayTransformationTest.kt index 6a3de249..4283d556 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/TextOverlayTransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/TextOverlayTransformationTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/TransformationTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/TransformationTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/TransformationTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/TransformationTest.kt index 526f81fb..e5f05ef5 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/TransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/TransformationTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/VersionInfoTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/VersionInfoTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/VersionInfoTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/VersionInfoTest.kt index 6ce80b1f..74965ad6 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/VersionInfoTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/VersionInfoTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/VideoOverlayTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/VideoOverlayTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/VideoOverlayTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/VideoOverlayTest.kt index 0790f5d1..c2d2c44e 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/VideoOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/VideoOverlayTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models +package io.imagekit.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginCreateParamsTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginCreateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginCreateParamsTest.kt index c1f8a46b..96aadea8 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginCreateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.origins +package io.imagekit.api.models.accounts.origins import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginDeleteParamsTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginDeleteParamsTest.kt index 4321d287..5fb0d833 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.origins +package io.imagekit.api.models.accounts.origins import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginGetParamsTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginGetParamsTest.kt index e70383e3..295648dc 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.origins +package io.imagekit.api.models.accounts.origins import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginListParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginListParamsTest.kt similarity index 81% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginListParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginListParamsTest.kt index 217de8e2..933b6547 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginListParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginListParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.origins +package io.imagekit.api.models.accounts.origins import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginRequestTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginRequestTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginRequestTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginRequestTest.kt index 4eaa9959..3adddeee 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginRequestTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginRequestTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.origins +package io.imagekit.api.models.accounts.origins import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper +import io.imagekit.api.errors.ImageKitInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginResponseTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginResponseTest.kt index 6f5a4be8..4cab4c21 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginResponseTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.origins +package io.imagekit.api.models.accounts.origins import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper -import io.imagekit.io.errors.ImageKitInvalidDataException +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper +import io.imagekit.api.errors.ImageKitInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginUpdateParamsTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginUpdateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginUpdateParamsTest.kt index b89c4a43..3b86375a 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/origins/OriginUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginUpdateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.origins +package io.imagekit.api.models.accounts.origins import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt index ba15bb19..20161bca 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.urlendpoints +package io.imagekit.api.models.accounts.urlendpoints import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt index 3cf5132a..9fe9e746 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.urlendpoints +package io.imagekit.api.models.accounts.urlendpoints import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt similarity index 90% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt index c2f390a4..f5c205a1 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.urlendpoints +package io.imagekit.api.models.accounts.urlendpoints import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt similarity index 80% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt index fa41afa5..aa9fc5bd 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.urlendpoints +package io.imagekit.api.models.accounts.urlendpoints import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointRequestTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequestTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointRequestTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequestTest.kt index 9c186088..3e0534d7 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointRequestTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequestTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.urlendpoints +package io.imagekit.api.models.accounts.urlendpoints import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponseTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponseTest.kt index 86ca85f1..37de7df8 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.urlendpoints +package io.imagekit.api.models.accounts.urlendpoints import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt index c2116918..3a28954f 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.urlendpoints +package io.imagekit.api.models.accounts.urlendpoints import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/usage/UsageGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/usage/UsageGetParamsTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/usage/UsageGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/usage/UsageGetParamsTest.kt index 11cf8c51..3e7bf3d6 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/usage/UsageGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/usage/UsageGetParamsTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.usage +package io.imagekit.api.models.accounts.usage -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.http.QueryParams import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/usage/UsageGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/usage/UsageGetResponseTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/usage/UsageGetResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/usage/UsageGetResponseTest.kt index 5ba5017f..58c92bba 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/accounts/usage/UsageGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/usage/UsageGetResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.accounts.usage +package io.imagekit.api.models.accounts.usage import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/assets/AssetListParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/assets/AssetListParamsTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/assets/AssetListParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/assets/AssetListParamsTest.kt index b45d1521..fc626d49 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/assets/AssetListParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/assets/AssetListParamsTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.assets +package io.imagekit.api.models.assets -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/assets/AssetListResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/assets/AssetListResponseTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/assets/AssetListResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/assets/AssetListResponseTest.kt index ffa4a350..5dc60617 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/assets/AssetListResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/assets/AssetListResponseTest.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.assets +package io.imagekit.api.models.assets import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper -import io.imagekit.io.errors.ImageKitInvalidDataException -import io.imagekit.io.models.AiTag -import io.imagekit.io.models.CustomMetadata -import io.imagekit.io.models.EmbeddedMetadata -import io.imagekit.io.models.SelectedFieldsSchema -import io.imagekit.io.models.VersionInfo -import io.imagekit.io.models.files.File -import io.imagekit.io.models.files.Folder +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper +import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.api.models.AiTag +import io.imagekit.api.models.CustomMetadata +import io.imagekit.api.models.EmbeddedMetadata +import io.imagekit.api.models.SelectedFieldsSchema +import io.imagekit.api.models.VersionInfo +import io.imagekit.api.models.files.File +import io.imagekit.api.models.files.Folder import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt index dc784d3b..6e902f3a 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.beta.v2.files +package io.imagekit.api.models.beta.v2.files -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.MultipartField -import io.imagekit.io.models.ExtensionItem +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.MultipartField +import io.imagekit.api.models.ExtensionItem import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt index 54fcf523..08444611 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/beta/v2/files/FileUploadResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.beta.v2.files +package io.imagekit.api.models.beta.v2.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper -import io.imagekit.io.models.AiTag -import io.imagekit.io.models.CustomMetadata -import io.imagekit.io.models.EmbeddedMetadata -import io.imagekit.io.models.SelectedFieldsSchema -import io.imagekit.io.models.VersionInfo -import io.imagekit.io.models.files.Metadata +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper +import io.imagekit.api.models.AiTag +import io.imagekit.api.models.CustomMetadata +import io.imagekit.api.models.EmbeddedMetadata +import io.imagekit.api.models.SelectedFieldsSchema +import io.imagekit.api.models.VersionInfo +import io.imagekit.api.models.files.Metadata import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateParamsTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateParamsTest.kt index 5985e173..9709a9a3 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.cache.invalidation +package io.imagekit.api.models.cache.invalidation import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateResponseTest.kt index b9f3b0b1..a8f8c7cf 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationCreateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.cache.invalidation +package io.imagekit.api.models.cache.invalidation import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetParamsTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetParamsTest.kt index 64536930..aeb5c10d 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.cache.invalidation +package io.imagekit.api.models.cache.invalidation import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetResponseTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetResponseTest.kt index aafff5de..de5a732e 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/cache/invalidation/InvalidationGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.cache.invalidation +package io.imagekit.api.models.cache.invalidation import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt index a1fffc99..a82fa5da 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.custommetadatafields +package io.imagekit.api.models.custommetadatafields import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt index 9bbe742a..84132329 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.custommetadatafields +package io.imagekit.api.models.custommetadatafields import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt index 95be91f3..7c1aa674 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.custommetadatafields +package io.imagekit.api.models.custommetadatafields import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt index 951751c3..ebb8b32f 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.custommetadatafields +package io.imagekit.api.models.custommetadatafields -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt index 10c24701..d98f516d 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.custommetadatafields +package io.imagekit.api.models.custommetadatafields import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt index 04d86784..5555c9ec 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.custommetadatafields +package io.imagekit.api.models.custommetadatafields import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileCopyParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileCopyParamsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileCopyParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileCopyParamsTest.kt index 91936d72..3807f110 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileCopyParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileCopyParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileCopyResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileCopyResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileCopyResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileCopyResponseTest.kt index 79835523..743c1729 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileCopyResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileCopyResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileDeleteParamsTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileDeleteParamsTest.kt index d2f4ab1f..c4dc748b 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileGetParamsTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileGetParamsTest.kt index 2cd9973a..84aeb0a4 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileMoveParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileMoveParamsTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileMoveParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileMoveParamsTest.kt index b687d6c0..25db423c 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileMoveParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileMoveParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileMoveResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileMoveResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileMoveResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileMoveResponseTest.kt index 830fc567..b23eff73 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileMoveResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileMoveResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileRenameParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileRenameParamsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileRenameParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileRenameParamsTest.kt index 976d292a..87ad4fa6 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileRenameParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileRenameParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileRenameResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileRenameResponseTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileRenameResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileRenameResponseTest.kt index c5765cb3..0cd3c6a0 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileRenameResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileRenameResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileTest.kt index 7e3a2a9d..290c916d 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileTest.kt @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper -import io.imagekit.io.models.AiTag -import io.imagekit.io.models.CustomMetadata -import io.imagekit.io.models.EmbeddedMetadata -import io.imagekit.io.models.SelectedFieldsSchema -import io.imagekit.io.models.VersionInfo +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper +import io.imagekit.api.models.AiTag +import io.imagekit.api.models.CustomMetadata +import io.imagekit.api.models.EmbeddedMetadata +import io.imagekit.api.models.SelectedFieldsSchema +import io.imagekit.api.models.VersionInfo import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUpdateParamsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUpdateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUpdateParamsTest.kt index dd092af9..1722cab1 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUpdateParamsTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files -import io.imagekit.io.core.JsonValue -import io.imagekit.io.models.ExtensionItem +import io.imagekit.api.core.JsonValue +import io.imagekit.api.models.ExtensionItem import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUpdateResponseTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUpdateResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUpdateResponseTest.kt index f517aa9b..1c561617 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUpdateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUpdateResponseTest.kt @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper -import io.imagekit.io.models.AiTag -import io.imagekit.io.models.CustomMetadata -import io.imagekit.io.models.EmbeddedMetadata -import io.imagekit.io.models.SelectedFieldsSchema -import io.imagekit.io.models.VersionInfo +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper +import io.imagekit.api.models.AiTag +import io.imagekit.api.models.CustomMetadata +import io.imagekit.api.models.EmbeddedMetadata +import io.imagekit.api.models.SelectedFieldsSchema +import io.imagekit.api.models.VersionInfo import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUploadParamsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUploadParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUploadParamsTest.kt index 455a5d08..d20c2843 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUploadParamsTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.MultipartField -import io.imagekit.io.models.ExtensionItem +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.MultipartField +import io.imagekit.api.models.ExtensionItem import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUploadResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUploadResponseTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUploadResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUploadResponseTest.kt index dc11488f..cf98e069 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FileUploadResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUploadResponseTest.kt @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper -import io.imagekit.io.models.AiTag -import io.imagekit.io.models.CustomMetadata -import io.imagekit.io.models.EmbeddedMetadata -import io.imagekit.io.models.SelectedFieldsSchema -import io.imagekit.io.models.VersionInfo +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper +import io.imagekit.api.models.AiTag +import io.imagekit.api.models.CustomMetadata +import io.imagekit.api.models.EmbeddedMetadata +import io.imagekit.api.models.SelectedFieldsSchema +import io.imagekit.api.models.VersionInfo import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FolderTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FolderTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FolderTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FolderTest.kt index 6611842f..98c19eb5 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/FolderTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FolderTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/MetadataTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/MetadataTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/MetadataTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/MetadataTest.kt index 175fb2fe..87f34119 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/MetadataTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/MetadataTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/UpdateFileRequestTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/UpdateFileRequestTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/UpdateFileRequestTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/UpdateFileRequestTest.kt index 9e2487b2..d5480b26 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/UpdateFileRequestTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/UpdateFileRequestTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files +package io.imagekit.api.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper -import io.imagekit.io.errors.ImageKitInvalidDataException -import io.imagekit.io.models.ExtensionItem +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper +import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.api.models.ExtensionItem import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsParamsTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsParamsTest.kt index a1f947ba..bad14b1a 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.bulk +package io.imagekit.api.models.files.bulk import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsResponseTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsResponseTest.kt index 50015a65..2c70545a 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkAddTagsResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.bulk +package io.imagekit.api.models.files.bulk import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteParamsTest.kt similarity index 94% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteParamsTest.kt index 8d349e22..9bb25a13 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.bulk +package io.imagekit.api.models.files.bulk import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteResponseTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteResponseTest.kt index 17f1e33c..c5f56c16 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkDeleteResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.bulk +package io.imagekit.api.models.files.bulk import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsParamsTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsParamsTest.kt index 61cccec8..7312a23d 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.bulk +package io.imagekit.api.models.files.bulk import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponseTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponseTest.kt index 3b21ad1b..5506e53a 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveAiTagsResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.bulk +package io.imagekit.api.models.files.bulk import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsParamsTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsParamsTest.kt index 2b013171..fdceaa14 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.bulk +package io.imagekit.api.models.files.bulk import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsResponseTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsResponseTest.kt index 342d3b18..8129e075 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/bulk/BulkRemoveTagsResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.bulk +package io.imagekit.api.models.files.bulk import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/metadata/MetadataGetFromUrlParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/metadata/MetadataGetFromUrlParamsTest.kt similarity index 86% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/metadata/MetadataGetFromUrlParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/metadata/MetadataGetFromUrlParamsTest.kt index 0c55f38c..95a07f9d 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/metadata/MetadataGetFromUrlParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/metadata/MetadataGetFromUrlParamsTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.metadata +package io.imagekit.api.models.files.metadata -import io.imagekit.io.core.http.QueryParams +import io.imagekit.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/metadata/MetadataGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/metadata/MetadataGetParamsTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/metadata/MetadataGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/metadata/MetadataGetParamsTest.kt index 86103156..0df3f2f4 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/metadata/MetadataGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/metadata/MetadataGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.metadata +package io.imagekit.api.models.files.metadata import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionDeleteParamsTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionDeleteParamsTest.kt index 887722b4..3de171f7 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.versions +package io.imagekit.api.models.files.versions import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionDeleteResponseTest.kt similarity index 90% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionDeleteResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionDeleteResponseTest.kt index 7e5b9695..c2c542c7 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionDeleteResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionDeleteResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.versions +package io.imagekit.api.models.files.versions import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionGetParamsTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionGetParamsTest.kt index 8af9ee86..ef2ab7b9 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.versions +package io.imagekit.api.models.files.versions import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionListParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionListParamsTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionListParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionListParamsTest.kt index 8cc12253..502149da 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionListParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionListParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.versions +package io.imagekit.api.models.files.versions import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionRestoreParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionRestoreParamsTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionRestoreParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionRestoreParamsTest.kt index 77ffad32..f57e9d24 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/files/versions/VersionRestoreParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionRestoreParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.files.versions +package io.imagekit.api.models.files.versions import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCopyParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCopyParamsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCopyParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCopyParamsTest.kt index 4491d0eb..0031b44f 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCopyParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCopyParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders +package io.imagekit.api.models.folders import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCopyResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCopyResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCopyResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCopyResponseTest.kt index 4f564393..d3dad6a8 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCopyResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCopyResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders +package io.imagekit.api.models.folders import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCreateParamsTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCreateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCreateParamsTest.kt index ce179e30..94241f3b 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCreateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders +package io.imagekit.api.models.folders import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCreateResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCreateResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCreateResponseTest.kt index 4ec5480a..a4914dc5 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderCreateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCreateResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders +package io.imagekit.api.models.folders import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderDeleteParamsTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderDeleteParamsTest.kt index 74c7bd80..7b05c342 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders +package io.imagekit.api.models.folders import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderDeleteResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderDeleteResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderDeleteResponseTest.kt index a837f6b6..b6cf526a 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderDeleteResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderDeleteResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders +package io.imagekit.api.models.folders import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderMoveParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderMoveParamsTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderMoveParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderMoveParamsTest.kt index 99662e39..a212a206 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderMoveParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderMoveParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders +package io.imagekit.api.models.folders import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderMoveResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderMoveResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderMoveResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderMoveResponseTest.kt index 6f655902..e013d0e1 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderMoveResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderMoveResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders +package io.imagekit.api.models.folders import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderRenameParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderRenameParamsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderRenameParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderRenameParamsTest.kt index 55a09138..6f8c65ea 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderRenameParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderRenameParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders +package io.imagekit.api.models.folders import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderRenameResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderRenameResponseTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderRenameResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderRenameResponseTest.kt index 2a29c34a..3b670605 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/FolderRenameResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderRenameResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders +package io.imagekit.api.models.folders import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/job/JobGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/job/JobGetParamsTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/job/JobGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/job/JobGetParamsTest.kt index c69ea598..f7494184 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/job/JobGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/job/JobGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders.job +package io.imagekit.api.models.folders.job import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/job/JobGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/job/JobGetResponseTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/job/JobGetResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/job/JobGetResponseTest.kt index 8f382df3..d0374ddf 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/folders/job/JobGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/job/JobGetResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.folders.job +package io.imagekit.api.models.folders.job import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionCreateParamsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionCreateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionCreateParamsTest.kt index 6783b54b..317d002a 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionCreateParamsTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.savedextensions +package io.imagekit.api.models.savedextensions -import io.imagekit.io.models.ExtensionConfig +import io.imagekit.api.models.ExtensionConfig import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionDeleteParamsTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionDeleteParamsTest.kt index 2e50c2bf..1b5e1b38 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.savedextensions +package io.imagekit.api.models.savedextensions import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionGetParamsTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionGetParamsTest.kt index 06926a16..c4fbf7a6 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.savedextensions +package io.imagekit.api.models.savedextensions import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionListParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionListParamsTest.kt similarity index 82% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionListParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionListParamsTest.kt index 92510888..1e972bd9 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionListParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionListParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.savedextensions +package io.imagekit.api.models.savedextensions import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionUpdateParamsTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionUpdateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionUpdateParamsTest.kt index 899b1378..84edd274 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/savedextensions/SavedExtensionUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionUpdateParamsTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.savedextensions +package io.imagekit.api.models.savedextensions -import io.imagekit.io.models.ExtensionConfig +import io.imagekit.api.models.ExtensionConfig import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/BaseWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/BaseWebhookEventTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/BaseWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/BaseWebhookEventTest.kt index ae01b4ce..bbc4dfe6 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/BaseWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/BaseWebhookEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileCreateEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileCreateEventTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileCreateEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileCreateEventTest.kt index 67088d14..89c8afdb 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileCreateEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileCreateEventTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper -import io.imagekit.io.models.AiTag -import io.imagekit.io.models.CustomMetadata -import io.imagekit.io.models.EmbeddedMetadata -import io.imagekit.io.models.SelectedFieldsSchema -import io.imagekit.io.models.VersionInfo -import io.imagekit.io.models.files.File +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper +import io.imagekit.api.models.AiTag +import io.imagekit.api.models.CustomMetadata +import io.imagekit.api.models.EmbeddedMetadata +import io.imagekit.api.models.SelectedFieldsSchema +import io.imagekit.api.models.VersionInfo +import io.imagekit.api.models.files.File import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileDeleteEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileDeleteEventTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileDeleteEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileDeleteEventTest.kt index 39e045de..a63eb4b1 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileDeleteEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileDeleteEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileUpdateEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileUpdateEventTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileUpdateEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileUpdateEventTest.kt index 1dcd6a4b..bf1fad8b 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileUpdateEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileUpdateEventTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper -import io.imagekit.io.models.AiTag -import io.imagekit.io.models.CustomMetadata -import io.imagekit.io.models.EmbeddedMetadata -import io.imagekit.io.models.SelectedFieldsSchema -import io.imagekit.io.models.VersionInfo -import io.imagekit.io.models.files.File +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper +import io.imagekit.api.models.AiTag +import io.imagekit.api.models.CustomMetadata +import io.imagekit.api.models.EmbeddedMetadata +import io.imagekit.api.models.SelectedFieldsSchema +import io.imagekit.api.models.VersionInfo +import io.imagekit.api.models.files.File import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileVersionCreateEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileVersionCreateEventTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileVersionCreateEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileVersionCreateEventTest.kt index 03339f56..0c5a7786 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileVersionCreateEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileVersionCreateEventTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper -import io.imagekit.io.models.AiTag -import io.imagekit.io.models.CustomMetadata -import io.imagekit.io.models.EmbeddedMetadata -import io.imagekit.io.models.SelectedFieldsSchema -import io.imagekit.io.models.VersionInfo -import io.imagekit.io.models.files.File +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper +import io.imagekit.api.models.AiTag +import io.imagekit.api.models.CustomMetadata +import io.imagekit.api.models.EmbeddedMetadata +import io.imagekit.api.models.SelectedFieldsSchema +import io.imagekit.api.models.VersionInfo +import io.imagekit.api.models.files.File import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileVersionDeleteEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileVersionDeleteEventTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileVersionDeleteEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileVersionDeleteEventTest.kt index 777a43e3..ae24d17f 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/FileVersionDeleteEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileVersionDeleteEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UnsafeUnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UnsafeUnwrapWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt index 4056774b..aa6f3976 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UnsafeUnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper -import io.imagekit.io.errors.ImageKitInvalidDataException -import io.imagekit.io.models.AiTag -import io.imagekit.io.models.CustomMetadata -import io.imagekit.io.models.EmbeddedMetadata -import io.imagekit.io.models.SelectedFieldsSchema -import io.imagekit.io.models.VersionInfo -import io.imagekit.io.models.files.File -import io.imagekit.io.models.files.Metadata +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper +import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.api.models.AiTag +import io.imagekit.api.models.CustomMetadata +import io.imagekit.api.models.EmbeddedMetadata +import io.imagekit.api.models.SelectedFieldsSchema +import io.imagekit.api.models.VersionInfo +import io.imagekit.api.models.files.File +import io.imagekit.api.models.files.Metadata import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UnwrapWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt index 5bd9f63f..ca4c7916 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper -import io.imagekit.io.errors.ImageKitInvalidDataException -import io.imagekit.io.models.AiTag -import io.imagekit.io.models.CustomMetadata -import io.imagekit.io.models.EmbeddedMetadata -import io.imagekit.io.models.SelectedFieldsSchema -import io.imagekit.io.models.VersionInfo -import io.imagekit.io.models.files.File -import io.imagekit.io.models.files.Metadata +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper +import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.api.models.AiTag +import io.imagekit.api.models.CustomMetadata +import io.imagekit.api.models.EmbeddedMetadata +import io.imagekit.api.models.SelectedFieldsSchema +import io.imagekit.api.models.VersionInfo +import io.imagekit.api.models.files.File +import io.imagekit.api.models.files.Metadata import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformErrorEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformErrorEventTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformErrorEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformErrorEventTest.kt index c8cc37d4..40bf24ad 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformErrorEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformErrorEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformSuccessEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformSuccessEventTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformSuccessEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformSuccessEventTest.kt index f566c2bc..ef79930b 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPostTransformSuccessEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformSuccessEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformErrorEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformErrorEventTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformErrorEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformErrorEventTest.kt index 3b4b8331..e23b4f36 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformErrorEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformErrorEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformSuccessEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformSuccessEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt index 93fb59f3..910e818c 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/UploadPreTransformSuccessEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper -import io.imagekit.io.models.AiTag -import io.imagekit.io.models.CustomMetadata -import io.imagekit.io.models.EmbeddedMetadata -import io.imagekit.io.models.SelectedFieldsSchema -import io.imagekit.io.models.VersionInfo -import io.imagekit.io.models.files.Metadata +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper +import io.imagekit.api.models.AiTag +import io.imagekit.api.models.CustomMetadata +import io.imagekit.api.models.EmbeddedMetadata +import io.imagekit.api.models.SelectedFieldsSchema +import io.imagekit.api.models.VersionInfo +import io.imagekit.api.models.files.Metadata import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/VideoTransformationAcceptedEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/VideoTransformationAcceptedEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt index c401f219..2a6d99f0 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/VideoTransformationAcceptedEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/VideoTransformationErrorEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/VideoTransformationErrorEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt index c62eefaf..1269a487 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/VideoTransformationErrorEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/VideoTransformationReadyEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/VideoTransformationReadyEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt index f6802ba0..62daa569 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/models/webhooks/VideoTransformationReadyEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.models.webhooks +package io.imagekit.api.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.core.jsonMapper +import io.imagekit.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/ErrorHandlingTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/ErrorHandlingTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/ErrorHandlingTest.kt index c93ab931..cdfdf760 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/ErrorHandlingTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/ErrorHandlingTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services +package io.imagekit.api.services import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.post @@ -8,22 +8,22 @@ import com.github.tomakehurst.wiremock.client.WireMock.status import com.github.tomakehurst.wiremock.client.WireMock.stubFor import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest -import io.imagekit.io.client.ImageKitClient -import io.imagekit.io.client.okhttp.ImageKitOkHttpClient -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.http.Headers -import io.imagekit.io.core.jsonMapper -import io.imagekit.io.errors.BadRequestException -import io.imagekit.io.errors.ImageKitException -import io.imagekit.io.errors.InternalServerException -import io.imagekit.io.errors.NotFoundException -import io.imagekit.io.errors.PermissionDeniedException -import io.imagekit.io.errors.RateLimitException -import io.imagekit.io.errors.UnauthorizedException -import io.imagekit.io.errors.UnexpectedStatusCodeException -import io.imagekit.io.errors.UnprocessableEntityException -import io.imagekit.io.models.ExtensionItem -import io.imagekit.io.models.files.FileUploadParams +import io.imagekit.api.client.ImageKitClient +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.http.Headers +import io.imagekit.api.core.jsonMapper +import io.imagekit.api.errors.BadRequestException +import io.imagekit.api.errors.ImageKitException +import io.imagekit.api.errors.InternalServerException +import io.imagekit.api.errors.NotFoundException +import io.imagekit.api.errors.PermissionDeniedException +import io.imagekit.api.errors.RateLimitException +import io.imagekit.api.errors.UnauthorizedException +import io.imagekit.api.errors.UnexpectedStatusCodeException +import io.imagekit.api.errors.UnprocessableEntityException +import io.imagekit.api.models.ExtensionItem +import io.imagekit.api.models.files.FileUploadParams import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.entry import org.junit.jupiter.api.BeforeEach diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/ServiceParamsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/ServiceParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/ServiceParamsTest.kt index cf80a8c6..68cf9566 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/ServiceParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services +package io.imagekit.api.services import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.equalTo @@ -12,11 +12,11 @@ import com.github.tomakehurst.wiremock.client.WireMock.stubFor import com.github.tomakehurst.wiremock.client.WireMock.verify import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest -import io.imagekit.io.client.ImageKitClient -import io.imagekit.io.client.okhttp.ImageKitOkHttpClient -import io.imagekit.io.core.JsonValue -import io.imagekit.io.models.ExtensionItem -import io.imagekit.io.models.files.FileUploadParams +import io.imagekit.api.client.ImageKitClient +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient +import io.imagekit.api.core.JsonValue +import io.imagekit.api.models.ExtensionItem +import io.imagekit.api.models.files.FileUploadParams import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/AssetServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/AssetServiceAsyncTest.kt similarity index 86% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/AssetServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/AssetServiceAsyncTest.kt index 4f7c43d7..6663c601 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/AssetServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/AssetServiceAsyncTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async +package io.imagekit.api.services.async -import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.io.models.assets.AssetListParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.api.models.assets.AssetListParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/CustomMetadataFieldServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/CustomMetadataFieldServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt index e64ec208..33ed30a5 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/CustomMetadataFieldServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async +package io.imagekit.api.services.async -import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldCreateParams -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldListParams -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldUpdateParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/FileServiceAsyncTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/FileServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/FileServiceAsyncTest.kt index becb09e5..f4da391f 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/FileServiceAsyncTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async +package io.imagekit.api.services.async -import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.io.core.JsonValue -import io.imagekit.io.models.ExtensionItem -import io.imagekit.io.models.files.FileCopyParams -import io.imagekit.io.models.files.FileMoveParams -import io.imagekit.io.models.files.FileRenameParams -import io.imagekit.io.models.files.FileUpdateParams -import io.imagekit.io.models.files.FileUploadParams -import io.imagekit.io.models.files.UpdateFileRequest +import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.api.core.JsonValue +import io.imagekit.api.models.ExtensionItem +import io.imagekit.api.models.files.FileCopyParams +import io.imagekit.api.models.files.FileMoveParams +import io.imagekit.api.models.files.FileRenameParams +import io.imagekit.api.models.files.FileUpdateParams +import io.imagekit.api.models.files.FileUploadParams +import io.imagekit.api.models.files.UpdateFileRequest import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/FolderServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/FolderServiceAsyncTest.kt similarity index 89% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/FolderServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/FolderServiceAsyncTest.kt index c8b10d81..58cf0557 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/FolderServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/FolderServiceAsyncTest.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async - -import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.io.models.folders.FolderCopyParams -import io.imagekit.io.models.folders.FolderCreateParams -import io.imagekit.io.models.folders.FolderDeleteParams -import io.imagekit.io.models.folders.FolderMoveParams -import io.imagekit.io.models.folders.FolderRenameParams +package io.imagekit.api.services.async + +import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.api.models.folders.FolderCopyParams +import io.imagekit.api.models.folders.FolderCreateParams +import io.imagekit.api.models.folders.FolderDeleteParams +import io.imagekit.api.models.folders.FolderMoveParams +import io.imagekit.api.models.folders.FolderRenameParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/SavedExtensionServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/SavedExtensionServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt index 793956a8..57cc5b60 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/SavedExtensionServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async +package io.imagekit.api.services.async -import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.io.models.ExtensionConfig -import io.imagekit.io.models.savedextensions.SavedExtensionCreateParams -import io.imagekit.io.models.savedextensions.SavedExtensionUpdateParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.api.models.ExtensionConfig +import io.imagekit.api.models.savedextensions.SavedExtensionCreateParams +import io.imagekit.api.models.savedextensions.SavedExtensionUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/WebhookServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/WebhookServiceAsyncTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/WebhookServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/WebhookServiceAsyncTest.kt index 2186b5e9..64072e5f 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/WebhookServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/WebhookServiceAsyncTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async +package io.imagekit.api.services.async import com.standardwebhooks.Webhook -import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.io.core.UnwrapWebhookParams -import io.imagekit.io.core.http.Headers -import io.imagekit.io.errors.ImageKitWebhookException +import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.api.core.UnwrapWebhookParams +import io.imagekit.api.core.http.Headers +import io.imagekit.api.errors.ImageKitWebhookException import java.time.Instant import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/accounts/OriginServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/accounts/OriginServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt index 5cfbcfb3..a54de338 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/accounts/OriginServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.accounts +package io.imagekit.api.services.async.accounts -import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.io.models.accounts.origins.OriginRequest -import io.imagekit.io.models.accounts.origins.OriginUpdateParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.api.models.accounts.origins.OriginRequest +import io.imagekit.api.models.accounts.origins.OriginUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/accounts/UrlEndpointServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/accounts/UrlEndpointServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt index 4006a00e..ed391486 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/accounts/UrlEndpointServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.accounts +package io.imagekit.api.services.async.accounts -import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointRequest -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointUpdateParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/accounts/UsageServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt similarity index 83% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/accounts/UsageServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt index cff198a7..2816aa94 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/accounts/UsageServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.accounts +package io.imagekit.api.services.async.accounts -import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.io.models.accounts.usage.UsageGetParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.api.models.accounts.usage.UsageGetParams import java.time.LocalDate import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/beta/v2/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/beta/v2/FileServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt index 6f202fa6..e9617a97 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/beta/v2/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.beta.v2 +package io.imagekit.api.services.async.beta.v2 -import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.io.core.JsonValue -import io.imagekit.io.models.ExtensionItem -import io.imagekit.io.models.beta.v2.files.FileUploadParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.api.core.JsonValue +import io.imagekit.api.models.ExtensionItem +import io.imagekit.api.models.beta.v2.files.FileUploadParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/cache/InvalidationServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt similarity index 88% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/cache/InvalidationServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt index 99164f5c..375a1aae 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/cache/InvalidationServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.cache +package io.imagekit.api.services.async.cache -import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.io.models.cache.invalidation.InvalidationCreateParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.api.models.cache.invalidation.InvalidationCreateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/files/BulkServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/files/BulkServiceAsyncTest.kt similarity index 89% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/files/BulkServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/files/BulkServiceAsyncTest.kt index 4b91cff5..0a5bd8ca 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/files/BulkServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/files/BulkServiceAsyncTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.files +package io.imagekit.api.services.async.files -import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.io.models.files.bulk.BulkAddTagsParams -import io.imagekit.io.models.files.bulk.BulkDeleteParams -import io.imagekit.io.models.files.bulk.BulkRemoveAiTagsParams -import io.imagekit.io.models.files.bulk.BulkRemoveTagsParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.api.models.files.bulk.BulkAddTagsParams +import io.imagekit.api.models.files.bulk.BulkDeleteParams +import io.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams +import io.imagekit.api.models.files.bulk.BulkRemoveTagsParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/files/MetadataServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt similarity index 87% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/files/MetadataServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt index d4cce619..7b9cfcf2 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/files/MetadataServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.files +package io.imagekit.api.services.async.files -import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.io.models.files.metadata.MetadataGetFromUrlParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.api.models.files.metadata.MetadataGetFromUrlParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/files/VersionServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/files/VersionServiceAsyncTest.kt similarity index 88% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/files/VersionServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/files/VersionServiceAsyncTest.kt index 110dc254..267880e4 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/files/VersionServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/files/VersionServiceAsyncTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.files +package io.imagekit.api.services.async.files -import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.io.models.files.versions.VersionDeleteParams -import io.imagekit.io.models.files.versions.VersionGetParams -import io.imagekit.io.models.files.versions.VersionRestoreParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.api.models.files.versions.VersionDeleteParams +import io.imagekit.api.models.files.versions.VersionGetParams +import io.imagekit.api.models.files.versions.VersionRestoreParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/folders/JobServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/folders/JobServiceAsyncTest.kt similarity index 84% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/folders/JobServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/folders/JobServiceAsyncTest.kt index c14501b0..a2e56bf0 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/async/folders/JobServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/folders/JobServiceAsyncTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.async.folders +package io.imagekit.api.services.async.folders -import io.imagekit.io.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/AssetServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/AssetServiceTest.kt similarity index 86% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/AssetServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/AssetServiceTest.kt index aa848f0a..20521f96 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/AssetServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/AssetServiceTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking +package io.imagekit.api.services.blocking -import io.imagekit.io.client.okhttp.ImageKitOkHttpClient -import io.imagekit.io.models.assets.AssetListParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient +import io.imagekit.api.models.assets.AssetListParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/CustomMetadataFieldServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/CustomMetadataFieldServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt index 133962b2..8403047b 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/CustomMetadataFieldServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking +package io.imagekit.api.services.blocking -import io.imagekit.io.client.okhttp.ImageKitOkHttpClient -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldCreateParams -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldListParams -import io.imagekit.io.models.custommetadatafields.CustomMetadataFieldUpdateParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams +import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/FileServiceTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/FileServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/FileServiceTest.kt index 68183268..8e4c829c 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/FileServiceTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking +package io.imagekit.api.services.blocking -import io.imagekit.io.client.okhttp.ImageKitOkHttpClient -import io.imagekit.io.core.JsonValue -import io.imagekit.io.models.ExtensionItem -import io.imagekit.io.models.files.FileCopyParams -import io.imagekit.io.models.files.FileMoveParams -import io.imagekit.io.models.files.FileRenameParams -import io.imagekit.io.models.files.FileUpdateParams -import io.imagekit.io.models.files.FileUploadParams -import io.imagekit.io.models.files.UpdateFileRequest +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient +import io.imagekit.api.core.JsonValue +import io.imagekit.api.models.ExtensionItem +import io.imagekit.api.models.files.FileCopyParams +import io.imagekit.api.models.files.FileMoveParams +import io.imagekit.api.models.files.FileRenameParams +import io.imagekit.api.models.files.FileUpdateParams +import io.imagekit.api.models.files.FileUploadParams +import io.imagekit.api.models.files.UpdateFileRequest import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/FolderServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/FolderServiceTest.kt similarity index 89% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/FolderServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/FolderServiceTest.kt index 7185ffbb..345b9f33 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/FolderServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/FolderServiceTest.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking - -import io.imagekit.io.client.okhttp.ImageKitOkHttpClient -import io.imagekit.io.models.folders.FolderCopyParams -import io.imagekit.io.models.folders.FolderCreateParams -import io.imagekit.io.models.folders.FolderDeleteParams -import io.imagekit.io.models.folders.FolderMoveParams -import io.imagekit.io.models.folders.FolderRenameParams +package io.imagekit.api.services.blocking + +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient +import io.imagekit.api.models.folders.FolderCopyParams +import io.imagekit.api.models.folders.FolderCreateParams +import io.imagekit.api.models.folders.FolderDeleteParams +import io.imagekit.api.models.folders.FolderMoveParams +import io.imagekit.api.models.folders.FolderRenameParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/SavedExtensionServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/SavedExtensionServiceTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/SavedExtensionServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/SavedExtensionServiceTest.kt index b09656a6..8be557a4 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/SavedExtensionServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/SavedExtensionServiceTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking +package io.imagekit.api.services.blocking -import io.imagekit.io.client.okhttp.ImageKitOkHttpClient -import io.imagekit.io.models.ExtensionConfig -import io.imagekit.io.models.savedextensions.SavedExtensionCreateParams -import io.imagekit.io.models.savedextensions.SavedExtensionUpdateParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient +import io.imagekit.api.models.ExtensionConfig +import io.imagekit.api.models.savedextensions.SavedExtensionCreateParams +import io.imagekit.api.models.savedextensions.SavedExtensionUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/WebhookServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/WebhookServiceTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/WebhookServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/WebhookServiceTest.kt index 962b28df..bd73abd2 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/WebhookServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/WebhookServiceTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking +package io.imagekit.api.services.blocking import com.standardwebhooks.Webhook -import io.imagekit.io.client.okhttp.ImageKitOkHttpClient -import io.imagekit.io.core.UnwrapWebhookParams -import io.imagekit.io.core.http.Headers -import io.imagekit.io.errors.ImageKitWebhookException +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient +import io.imagekit.api.core.UnwrapWebhookParams +import io.imagekit.api.core.http.Headers +import io.imagekit.api.errors.ImageKitWebhookException import java.time.Instant import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/accounts/OriginServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/accounts/OriginServiceTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/accounts/OriginServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/accounts/OriginServiceTest.kt index a251974c..a36c3577 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/accounts/OriginServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/accounts/OriginServiceTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.accounts +package io.imagekit.api.services.blocking.accounts -import io.imagekit.io.client.okhttp.ImageKitOkHttpClient -import io.imagekit.io.models.accounts.origins.OriginRequest -import io.imagekit.io.models.accounts.origins.OriginUpdateParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient +import io.imagekit.api.models.accounts.origins.OriginRequest +import io.imagekit.api.models.accounts.origins.OriginUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/accounts/UrlEndpointServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/accounts/UrlEndpointServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt index 46626d87..f16d0e9c 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/accounts/UrlEndpointServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.accounts +package io.imagekit.api.services.blocking.accounts -import io.imagekit.io.client.okhttp.ImageKitOkHttpClient -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointRequest -import io.imagekit.io.models.accounts.urlendpoints.UrlEndpointUpdateParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest +import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/accounts/UsageServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/accounts/UsageServiceTest.kt similarity index 82% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/accounts/UsageServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/accounts/UsageServiceTest.kt index 2157d5cc..195b456b 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/accounts/UsageServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/accounts/UsageServiceTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.accounts +package io.imagekit.api.services.blocking.accounts -import io.imagekit.io.client.okhttp.ImageKitOkHttpClient -import io.imagekit.io.models.accounts.usage.UsageGetParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient +import io.imagekit.api.models.accounts.usage.UsageGetParams import java.time.LocalDate import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/beta/v2/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/beta/v2/FileServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt index e34c88d9..d48bc0e6 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/beta/v2/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.beta.v2 +package io.imagekit.api.services.blocking.beta.v2 -import io.imagekit.io.client.okhttp.ImageKitOkHttpClient -import io.imagekit.io.core.JsonValue -import io.imagekit.io.models.ExtensionItem -import io.imagekit.io.models.beta.v2.files.FileUploadParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient +import io.imagekit.api.core.JsonValue +import io.imagekit.api.models.ExtensionItem +import io.imagekit.api.models.beta.v2.files.FileUploadParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/cache/InvalidationServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt similarity index 86% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/cache/InvalidationServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt index 7109694b..67753615 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/cache/InvalidationServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.cache +package io.imagekit.api.services.blocking.cache -import io.imagekit.io.client.okhttp.ImageKitOkHttpClient -import io.imagekit.io.models.cache.invalidation.InvalidationCreateParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient +import io.imagekit.api.models.cache.invalidation.InvalidationCreateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/files/BulkServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/files/BulkServiceTest.kt similarity index 88% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/files/BulkServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/files/BulkServiceTest.kt index 3d45028e..e737377e 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/files/BulkServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/files/BulkServiceTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.files +package io.imagekit.api.services.blocking.files -import io.imagekit.io.client.okhttp.ImageKitOkHttpClient -import io.imagekit.io.models.files.bulk.BulkAddTagsParams -import io.imagekit.io.models.files.bulk.BulkDeleteParams -import io.imagekit.io.models.files.bulk.BulkRemoveAiTagsParams -import io.imagekit.io.models.files.bulk.BulkRemoveTagsParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient +import io.imagekit.api.models.files.bulk.BulkAddTagsParams +import io.imagekit.api.models.files.bulk.BulkDeleteParams +import io.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams +import io.imagekit.api.models.files.bulk.BulkRemoveTagsParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/files/MetadataServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/files/MetadataServiceTest.kt similarity index 85% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/files/MetadataServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/files/MetadataServiceTest.kt index 2a42cb3d..9660e6fe 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/files/MetadataServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/files/MetadataServiceTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.files +package io.imagekit.api.services.blocking.files -import io.imagekit.io.client.okhttp.ImageKitOkHttpClient -import io.imagekit.io.models.files.metadata.MetadataGetFromUrlParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient +import io.imagekit.api.models.files.metadata.MetadataGetFromUrlParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/files/VersionServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/files/VersionServiceTest.kt similarity index 87% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/files/VersionServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/files/VersionServiceTest.kt index dfbc6c03..7f9d72cb 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/files/VersionServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/files/VersionServiceTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.files +package io.imagekit.api.services.blocking.files -import io.imagekit.io.client.okhttp.ImageKitOkHttpClient -import io.imagekit.io.models.files.versions.VersionDeleteParams -import io.imagekit.io.models.files.versions.VersionGetParams -import io.imagekit.io.models.files.versions.VersionRestoreParams +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient +import io.imagekit.api.models.files.versions.VersionDeleteParams +import io.imagekit.api.models.files.versions.VersionGetParams +import io.imagekit.api.models.files.versions.VersionRestoreParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/folders/JobServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/folders/JobServiceTest.kt similarity index 83% rename from image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/folders/JobServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/folders/JobServiceTest.kt index 22c86a55..c754963b 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/io/services/blocking/folders/JobServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/folders/JobServiceTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.services.blocking.folders +package io.imagekit.api.services.blocking.folders -import io.imagekit.io.client.okhttp.ImageKitOkHttpClient +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-example/src/main/java/com/imagekit/api/example/Main.java b/image-kit-java-example/src/main/java/com/imagekit/api/example/Main.java deleted file mode 100644 index 9c07ef84..00000000 --- a/image-kit-java-example/src/main/java/com/imagekit/api/example/Main.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.imagekit.api.example; - -import com.imagekit.api.client.ImageKitClient; -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient; -import com.imagekit.api.models.ExtensionItem; -import com.imagekit.api.models.ExtensionItem.AiTasks.Task.YesNo; -import com.imagekit.api.models.ExtensionItem.AiTasks.Task.YesNo.OnNo; -import com.imagekit.api.models.ExtensionItem.AiTasks.Task.YesNo.OnYes; -import com.imagekit.api.models.files.FileUploadParams; -import com.imagekit.api.models.files.FileUploadResponse; -import java.io.IOException; -import java.io.InputStream; -import java.net.URISyntaxException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -public final class Main { - public static void main(String[] args) throws IOException, URISyntaxException { - // Initialize the client using the IMAGEKIT_PRIVATE_KEY environment variable - ImageKitClient client = ImageKitOkHttpClient.builder().fromEnv().build(); - - // Resolve the sample image bundled in src/main/resources/test.png - Path filePath; - if (args.length > 0) { - filePath = Paths.get(args[0]); - } else { - filePath = Paths.get(Main.class.getResource("/test.png").toURI()); - } - System.out.println("Using file: " + filePath); - System.out.println(); - - // --- Example 1: Upload using Path --- - System.out.println("=== Upload using Path ==="); - FileUploadParams pathParams = FileUploadParams.builder() - .fileName("path-upload.jpg") - .file(filePath) - .folder("/java-sdk-testing") - .build(); - FileUploadResponse pathResponse = client.files().upload(pathParams); - System.out.println("Uploaded: " + pathResponse.name()); - System.out.println("URL: " + pathResponse.url()); - System.out.println("File ID: " + pathResponse.fileId()); - System.out.println(); - - // --- Example 2: Upload using InputStream --- - System.out.println("=== Upload using InputStream ==="); - InputStream imageStream = Main.class.getResourceAsStream("/test.png"); - FileUploadParams streamParams = FileUploadParams.builder() - .fileName("stream-upload.jpg") - .file(imageStream) - .folder("/java-sdk-testing") - .build(); - FileUploadResponse streamResponse = client.files().upload(streamParams); - System.out.println("Uploaded: " + streamResponse.name()); - System.out.println("URL: " + streamResponse.url()); - System.out.println("File ID: " + streamResponse.fileId()); - System.out.println(); - - // --- Example 3: Upload using byte[] --- - System.out.println("=== Upload using byte[] ==="); - byte[] fileBytes = Files.readAllBytes(filePath); - FileUploadParams bytesParams = FileUploadParams.builder() - .fileName("bytes-upload.jpg") - .file(fileBytes) - .folder("/java-sdk-testing") - .build(); - FileUploadResponse bytesResponse = client.files().upload(bytesParams); - System.out.println("Uploaded: " + bytesResponse.name()); - System.out.println("URL: " + bytesResponse.url()); - System.out.println("File ID: " + bytesResponse.fileId()); - System.out.println(); - - // --- Example 4: Upload with tags and folder --- - System.out.println("=== Upload with tags and folder ==="); - FileUploadParams taggedParams = FileUploadParams.builder() - .fileName("tagged-upload.jpg") - .file(filePath) - .folder("/java-sdk-testing") - .addTag("example") - .addTag("java-sdk") - .useUniqueFileName(false) - .build(); - FileUploadResponse taggedResponse = client.files().upload(taggedParams); - System.out.println("Uploaded: " + taggedResponse.name()); - System.out.println("URL: " + taggedResponse.url()); - System.out.println("File ID: " + taggedResponse.fileId()); - System.out.println("Tags: " + taggedResponse.tags()); - - System.out.println(); - - // --- Example 5: Upload with AI tasks extension --- - System.out.println("=== Upload with AI tasks extension ==="); - FileUploadParams aiParams = FileUploadParams.builder() - .fileName("ai-task-upload.png") - .file(filePath) - .folder("/java-sdk-testing") - .addExtension(ExtensionItem.AiTasks.builder() - .addTask(YesNo.builder() - .instruction("Does this image contain a person?") - .onYes(OnYes.builder().addAddTag("has-person").build()) - .onNo(OnNo.builder().addAddTag("no-person").build()) - .build()) - .addSelectTagsTask("What objects are visible in this image?") - .build()) - .addTag("ai-processed") - .build(); - FileUploadResponse aiResponse = client.files().upload(aiParams); - System.out.println("Uploaded: " + aiResponse.name()); - System.out.println("URL: " + aiResponse.url()); - System.out.println("File ID: " + aiResponse.fileId()); - System.out.println("Extensions: " + aiResponse.extensionStatus()); - - System.out.println(); - System.out.println("All uploads completed successfully!"); - } -} diff --git a/image-kit-java-lib/build.gradle.kts b/image-kit-java-lib/build.gradle.kts deleted file mode 100644 index dc97c82e..00000000 --- a/image-kit-java-lib/build.gradle.kts +++ /dev/null @@ -1,13 +0,0 @@ -plugins { - id("image-kit.kotlin") -} - -dependencies { - api(project(":image-kit-java-core")) - - testImplementation(kotlin("test")) - testImplementation(project(":image-kit-java-client-okhttp")) - testImplementation("org.assertj:assertj-core:3.27.7") - testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") - testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3") -} diff --git a/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperAdvancedTransformationsTest.kt b/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperAdvancedTransformationsTest.kt deleted file mode 100644 index 9ed906c2..00000000 --- a/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperAdvancedTransformationsTest.kt +++ /dev/null @@ -1,516 +0,0 @@ -package com.imagekit.api.lib - -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.models.SrcOptions -import com.imagekit.api.models.StreamingResolution -import com.imagekit.api.models.Transformation -import com.imagekit.api.models.TransformationPosition -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class HelperAdvancedTransformationsTest { - - private val privateKey = "My Private API Key" - private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() - - // AI Transformation Tests - @Test - fun `should generate the correct URL for AI background removal when set to true`() { - val transformation = - listOf( - Transformation.builder() - .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-bgremove") - } - - @Test - fun `should generate the correct URL for external AI background removal when set to true`() { - val transformation = - listOf( - Transformation.builder() - .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-removedotbg") - } - - @Test - fun `should generate the correct URL when AI drop shadow transformation is set to true`() { - val transformation = listOf(Transformation.builder().aiDropShadowTrue().build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-dropshadow") - } - - @Test - fun `should generate the correct URL when gradient transformation is set to true`() { - val transformation = listOf(Transformation.builder().gradientTrue().build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-gradient") - } - - @Test - fun `should not apply AI background removal when value is not true`() { - val transformation = listOf(Transformation.builder().build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg") - } - - @Test - fun `should not apply external AI background removal when value is not true`() { - val transformation = listOf(Transformation.builder().build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg") - } - - @Test - fun `should handle AI transformations with parameters`() { - val transformation = - listOf(Transformation.builder().aiDropShadow("custom-shadow-params").build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-dropshadow-custom-shadow-params" - ) - } - - @Test - fun `should handle gradient with parameters`() { - val transformation = - listOf(Transformation.builder().gradient("ld-top_from-green_to-00FF0010_sp-1").build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-gradient-ld-top_from-green_to-00FF0010_sp-1" - ) - } - - @Test - fun `should combine AI transformations with regular transformations`() { - val transformation = - listOf( - Transformation.builder() - .width(300.0) - .height(200.0) - .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=w-300,h-200,e-bgremove" - ) - } - - @Test - fun `should handle multiple AI transformations`() { - val transformation = - listOf( - Transformation.builder() - .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) - .aiDropShadowTrue() - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-bgremove,e-dropshadow" - ) - } - - // Parameter-specific tests - @Test - fun `should generate the correct URL for width transformation when provided with a number value`() { - val transformation = listOf(Transformation.builder().width(400.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=w-400") - } - - @Test - fun `should generate the correct URL for height transformation when provided with a string value`() { - val transformation = listOf(Transformation.builder().height("300").build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=h-300") - } - - @Test - fun `should generate the correct URL for aspectRatio transformation when provided with colon format`() { - val transformation = listOf(Transformation.builder().aspectRatio("4:3").build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=ar-4:3") - } - - @Test - fun `should generate the correct URL for quality transformation when provided with a number value`() { - val transformation = listOf(Transformation.builder().quality(80.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=q-80") - } - - @Test - fun `should skip transformation parameters that are undefined or empty`() { - val transformation = listOf(Transformation.builder().width(300.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=w-300") - } - - @Test - fun `should handle boolean transformation values`() { - val transformation = listOf(Transformation.builder().trimTrue().build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=t-true") - } - - @Test - fun `should handle transformation parameter with empty string value`() { - val transformation = listOf(Transformation.builder().defaultImage("").build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg") - } - - @Test - fun `should handle complex transformation combinations`() { - val transformation = - listOf( - Transformation.builder() - .width(300.0) - .height(200.0) - .quality(85.0) - .border("5_FF0000") - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=w-300,h-200,q-85,b-5_FF0000" - ) - } - - @Test - fun `should generate the correct URL for radius transformation with string value for per corner radius`() { - val transformation = listOf(Transformation.builder().radius("10_10_max_10").build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path1.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=r-10_10_max_10") - } - - @Test - fun `should generate the correct URL with many transformations, including video and AI transforms`() { - val transformation = - listOf( - Transformation.builder() - .height(300.0) - .width(400.0) - .aspectRatio("4-3") - .quality(40.0) - .crop(Transformation.Crop.FORCE) - .cropMode(Transformation.CropMode.EXTRACT) - .focus("left") - .format(Transformation.Format.JPEG) - .radius(50.0) - .background("A94D34") - .border("5-A94D34") - .rotation(90.0) - .blur(10.0) - .named("some_name") - .progressive(true) - .lossless(true) - .trim(5.0) - .metadata(true) - .colorProfile(true) - .defaultImage("/folder/file.jpg/") - .dpr(3.0) - .x(10.0) - .y(20.0) - .xCenter(30.0) - .yCenter(40.0) - .flip(Transformation.Flip.H) - .opacity(0.8) - .zoom(2.0) - .videoCodec(Transformation.VideoCodec.H264) - .audioCodec(Transformation.AudioCodec.AAC) - .startOffset(5.0) - .endOffset(15.0) - .duration(10.0) - .streamingResolutions( - listOf(StreamingResolution._1440, StreamingResolution._1080) - ) - .grayscale(Transformation.Grayscale.TRUE) - .aiUpscale(Transformation.AiUpscale.TRUE) - .aiRetouch(Transformation.AiRetouch.TRUE) - .aiVariation(Transformation.AiVariation.TRUE) - .aiDropShadowTrue() - .aiChangeBackground("prompt-car") - .aiEdit("prompt-make it vintage") - .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) - .contrastStretch(Transformation.ContrastStretch.TRUE) - .shadow("bl-15_st-40_x-10_y-N5") - .sharpen(10.0) - .unsharpMask("2-2-0.8-0.024") - .gradient("from-red_to-white") - .colorReplace("FF0000_100_0000FF") - .distort("a-45") - .original(true) - .page("2_4") - .raw("h-200,w-300,l-image,i-logo.png,l-end") - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path.jpg") - .transformation(transformation as List) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300,q-40,ar-4-3,c-force,cm-extract,fo-left,f-jpeg,r-50,bg-A94D34,b-5-A94D34,cr-FF0000_100_0000FF,di-folder@@file.jpg,dpr-3,x-10,y-20,xc-30,yc-40,o-0.8,z-2,rt-90,bl-10,n-some_name,pr-true,lo-true,fl-h,t-5,md-true,cp-true,vc-h264,ac-aac,so-5,eo-15,du-10,sr-1440_1080,e-grayscale,e-upscale,e-retouch,e-genvar,e-bgremove,e-contrast,e-dropshadow,e-changebg-prompt-car,e-edit-prompt-make it vintage,e-shadow-bl-15_st-40_x-10_y-N5,e-sharpen-10,e-usm-2-2-0.8-0.024,e-gradient-from-red_to-white,e-distort-a-45,orig-true,pg-2_4,h-200,w-300,l-image,i-logo.png,l-end" - ) - } -} diff --git a/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperAuthenticationTest.kt b/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperAuthenticationTest.kt deleted file mode 100644 index b866b936..00000000 --- a/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperAuthenticationTest.kt +++ /dev/null @@ -1,101 +0,0 @@ -package com.imagekit.api.lib - -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import kotlin.test.assertFailsWith -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class HelperAuthenticationTest { - - private val privateKey = "private_key_test" - private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() - - @Test - fun `should return correct authentication parameters with provided token and expire`() { - val token = "your_token" - val expire = 1582269249L - - val params = client.helper().getAuthenticationParameters(token, expire) - - // Expected exact match with Node.js/Go SDK output - val expectedSignature = "e71bcd6031016b060d349d212e23e85c791decdd" - - assertThat(params["token"]).isEqualTo(token) - assertThat(params["expire"]).isEqualTo(expire) - assertThat(params["signature"]).isEqualTo(expectedSignature) - } - - @Test - fun `should return authentication parameters with required properties when no params provided`() { - val params = client.helper().getAuthenticationParameters(null, null) - - // Check that all required properties exist - assertThat(params).containsKeys("token", "expire", "signature") - - // Token should be a 32-character hex string (16 bytes as hex) - val token = params["token"] as String - assertThat(token).matches("^[0-9a-f]{32}$") - - // Expire should be a number greater than current time - val expire = params["expire"] as Long - val currentTime = System.currentTimeMillis() / 1000 - assertThat(expire).isGreaterThan(currentTime) - - // Signature should be a hex string (40 characters for HMAC-SHA1) - val signature = params["signature"] as String - assertThat(signature).matches("^[a-f0-9]{40}$") - } - - @Test - fun `should handle edge case with expire time 0`() { - val token = "test-token" - val expire = 0L - - val params = client.helper().getAuthenticationParameters(token, expire) - - assertThat(params["token"]).isEqualTo(token) - - // When expire is 0 (falsy), it should use default expire time (30 minutes from now) - val expireResult = params["expire"] as Long - val expectedExpire = System.currentTimeMillis() / 1000 + 60 * 30 - - // Allow a 10 second tolerance for test execution time - assertThat(expireResult).isBetween(expectedExpire - 10, expectedExpire + 10) - - // Signature should be a hex string (40 characters for HMAC-SHA1) - val signature = params["signature"] as String - assertThat(signature).matches("^[a-f0-9]{40}$") - } - - @Test - fun `should handle empty string token`() { - val token = "" // Empty string is falsy - val expire = 1582269249L - - val params = client.helper().getAuthenticationParameters(token, expire) - - // Since empty string is falsy, it should generate a hex token - val tokenResult = params["token"] as String - assertThat(tokenResult).isNotEmpty() - assertThat(tokenResult).matches("^[0-9a-f]{32}$") - - assertThat(params["expire"]).isEqualTo(expire) - - // Signature should be a hex string (40 characters for HMAC-SHA1) - val signature = params["signature"] as String - assertThat(signature).matches("^[a-f0-9]{40}$") - } - - @Test - fun `should return error when private key is not provided`() { - val emptyKeyClient = ImageKitOkHttpClient.builder().privateKey("").build() - - val exception = - assertFailsWith { - emptyKeyClient.helper().getAuthenticationParameters("test", 123L) - } - - assertThat(exception.message) - .isEqualTo("private API key is required for authentication parameters generation") - } -} diff --git a/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperBuildUrlTest.kt b/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperBuildUrlTest.kt deleted file mode 100644 index be99d4d3..00000000 --- a/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperBuildUrlTest.kt +++ /dev/null @@ -1,433 +0,0 @@ -package com.imagekit.api.lib - -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.SrcOptions -import com.imagekit.api.models.Transformation -import com.imagekit.api.models.TransformationPosition -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class HelperBuildUrlTest { - - private val privateKey = "My Private API Key" - private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() - - @Test - fun `should throw exception when src is not provided`() { - org.junit.jupiter.api.assertThrows { - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .build() - ) - } - } - - @Test - fun `should generate a valid URL when src is slash`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/") - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/") - } - - @Test - fun `should generate a valid URL when src is provided without transformation`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path.jpg") - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path.jpg") - } - - @Test - fun `should generate a valid URL when absolute URL is provided without transformation`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg") - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg") - } - - @Test - fun `should generate valid URL when undefined transformation parameters are provided with path`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .src("/test_path_alt.jpg") - .transformationPosition(TransformationPosition.QUERY) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg") - } - - @Test - fun `by default transformationPosition should be query`() { - val transformation = - listOf( - Transformation.builder().height(300.0).width(400.0).build(), - Transformation.builder().rotation(90.0).build(), - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .src("/test_path.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300:rt-90" - ) - } - - @Test - fun `should generate the URL without sdk version`() { - val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .src("/test_path.jpg") - .transformation(transformation) - .transformationPosition(TransformationPosition.PATH) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/tr:w-400,h-300/test_path.jpg") - } - - @Test - fun `should generate the correct URL with a valid src and transformation`() { - val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300") - } - - @Test - fun `should add transformation as query when src has absolute url even if transformationPosition is path`() { - val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("https://my.custom.domain.com/test_path.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url).isEqualTo("https://my.custom.domain.com/test_path.jpg?tr=w-400,h-300") - } - - @Test - fun `handle non-default url-endpoint case`() { - val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/imagekit_id/new-endpoint/") - .src("/test_path.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/imagekit_id/new-endpoint/test_path.jpg?tr=w-400,h-300" - ) - } - - @Test - fun `should generate the correct URL when the provided path contains multiple leading slashes`() { - val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("///test_path.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300") - } - - @Test - fun `should generate the correct URL when the urlEndpoint is overridden`() { - val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint_alt") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint_alt/test_path.jpg?tr=w-400,h-300") - } - - @Test - fun `should generate the correct URL with transformationPosition as query parameter when src is provided`() { - val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .src("/test_path.jpg") - .transformationPosition(TransformationPosition.QUERY) - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300") - } - - @Test - fun `should generate the correct URL with a valid src parameter and transformation`() { - val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg?tr=w-400,h-300") - } - - @Test - fun `should merge query parameters correctly in the generated URL`() { - val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) - - val queryParams = - SrcOptions.QueryParameters.builder() - .putAdditionalProperty("t2", JsonValue.from("v2")) - .putAdditionalProperty("t3", JsonValue.from("v3")) - .build() - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg?t1=v1") - .queryParameters(queryParams) - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg?t1=v1&t2=v2&t3=v3&tr=w-400,h-300" - ) - } - - @Test - fun `should generate the correct URL with chained transformations`() { - val transformation = - listOf( - Transformation.builder().height(300.0).width(400.0).build(), - Transformation.builder().rotation(90.0).build(), - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300:rt-90" - ) - } - - @Test - fun `should generate the correct URL with chained transformations including raw transformation`() { - val transformation = - listOf( - Transformation.builder().height(300.0).width(400.0).build(), - Transformation.builder().raw("rndm_trnsf-abcd").build(), - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300:rndm_trnsf-abcd" - ) - } - - @Test - fun `should generate the correct URL when border transformation is applied`() { - val transformation = - listOf(Transformation.builder().height(300.0).width(400.0).border("20_FF0000").build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300,b-20_FF0000" - ) - } - - @Test - fun `should generate the correct URL when transformation has empty key and value`() { - val transformation = listOf(Transformation.builder().raw("").build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path.jpg") - } - - @Test - fun `should generate a valid URL when cname is used`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://custom.domain.com") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path.jpg") - .build() - ) - - assertThat(url).isEqualTo("https://custom.domain.com/test_path.jpg") - } - - @Test - fun `should generate a valid URL when cname is used with a url-pattern`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://custom.domain.com/url-pattern") - .transformationPosition(TransformationPosition.QUERY) - .src("/test_path.jpg") - .build() - ) - - assertThat(url).isEqualTo("https://custom.domain.com/url-pattern/test_path.jpg") - } -} diff --git a/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperOverlayTest.kt b/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperOverlayTest.kt deleted file mode 100644 index 6d16d855..00000000 --- a/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperOverlayTest.kt +++ /dev/null @@ -1,1564 +0,0 @@ -package com.imagekit.api.lib - -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class HelperOverlayTest { - - private val privateKey = "My Private API Key" - private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() - - // ======================================== - // TestOverlayTransformations - 12 tests - // ======================================== - - @Test - fun `should ignore overlay when type property is missing`() { - val transformation = listOf(Transformation.builder().width(300.0).build()) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/test_url_endpoint/tr:w-300/base-image.jpg") - } - - @Test - fun `should ignore text overlay when text property is missing`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder().text("").type(JsonValue.from("text")).build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/base-image.jpg") - } - - @Test - fun `should ignore image overlay when input property is missing`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder().input("").type(JsonValue.from("image")).build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/base-image.jpg") - } - - @Test - fun `should ignore video overlay when input property is missing`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofVideo( - VideoOverlay.builder().input("").type(JsonValue.from("video")).build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/base-image.jpg") - } - - @Test - fun `should ignore subtitle overlay when input property is missing`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofSubtitle( - SubtitleOverlay.builder() - .input("") - .type(JsonValue.from("subtitle")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/base-image.jpg") - } - - @Test - fun `should ignore solid color overlay when color property is missing`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofSolidColor( - SolidColorOverlay.builder() - .color("") - .type(JsonValue.from("solidColor")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/base-image.jpg") - } - - @Test - fun `should generate URL with text overlay using URL encoding`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("Minimal Text") - .type(JsonValue.from("text")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Minimal%20Text,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate URL with image overlay from input file`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("logo.png") - .type(JsonValue.from("image")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-logo.png,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate URL with video overlay from input file`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofVideo( - VideoOverlay.builder() - .input("play-pause-loop.mp4") - .type(JsonValue.from("video")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-video.mp4") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-video,i-play-pause-loop.mp4,l-end/base-video.mp4" - ) - } - - @Test - fun `should generate URL with subtitle overlay from input file`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofSubtitle( - SubtitleOverlay.builder() - .input("subtitle.srt") - .type(JsonValue.from("subtitle")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-video.mp4") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-subtitles,i-subtitle.srt,l-end/base-video.mp4" - ) - } - - @Test - fun `should generate URL with solid color overlay using background color`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofSolidColor( - SolidColorOverlay.builder() - .color("FF0000") - .type(JsonValue.from("solidColor")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-ik_canvas,bg-FF0000,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate URL with multiple complex overlays including nested transformations`() { - val transformation = - listOf( - // Text overlay with complex transformations - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("Every thing") - .type(JsonValue.from("text")) - .position( - OverlayPosition.builder() - .x("10") - .y("20") - .focus(OverlayPosition.Focus.CENTER) - .build() - ) - .timing( - OverlayTiming.builder() - .start(5.0) - .duration("10") - .end(15.0) - .build() - ) - .transformation( - listOf( - TextOverlayTransformation.builder() - .width("bw_mul_0.5") - .fontSize(20.0) - .fontFamily("Arial") - .fontColor("0000ff") - .innerAlignment( - TextOverlayTransformation.InnerAlignment.LEFT - ) - .padding(5.0) - .alpha(7.0) - .typography("b") - .background("red") - .radius(10.0) - .rotation("N45") - .flip(TextOverlayTransformation.Flip.H) - .lineHeight(20.0) - .build() - ) - ) - .build() - ) - ) - .build(), - // Image overlay with nested transformations including nested text overlay - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("logo.png") - .type(JsonValue.from("image")) - .position( - OverlayPosition.builder() - .x("10") - .y("20") - .focus(OverlayPosition.Focus.CENTER) - .build() - ) - .timing( - OverlayTiming.builder() - .start(5.0) - .duration("10") - .end(15.0) - .build() - ) - .transformation( - listOf( - Transformation.builder() - .width("bw_mul_0.5") - .height("bh_mul_0.5") - .rotation("N45") - .flip(Transformation.Flip.H) - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("Nested text overlay") - .type(JsonValue.from("text")) - .build() - ) - ) - .build() - ) - ) - .build() - ) - ) - .build(), - // Video overlay - Transformation.builder() - .overlay( - Overlay.ofVideo( - VideoOverlay.builder() - .input("play-pause-loop.mp4") - .type(JsonValue.from("video")) - .position( - OverlayPosition.builder() - .x("10") - .y("20") - .focus(OverlayPosition.Focus.CENTER) - .build() - ) - .timing( - OverlayTiming.builder() - .start(5.0) - .duration("10") - .end(15.0) - .build() - ) - .transformation( - listOf( - Transformation.builder() - .width("bw_mul_0.5") - .height("bh_mul_0.5") - .rotation("N45") - .flip(Transformation.Flip.H) - .build() - ) - ) - .build() - ) - ) - .build(), - // Subtitle overlay - Transformation.builder() - .overlay( - Overlay.ofSubtitle( - SubtitleOverlay.builder() - .input("subtitle.srt") - .type(JsonValue.from("subtitle")) - .position( - OverlayPosition.builder() - .x("10") - .y("20") - .focus(OverlayPosition.Focus.CENTER) - .build() - ) - .timing( - OverlayTiming.builder() - .start(5.0) - .duration("10") - .end(15.0) - .build() - ) - .transformation( - listOf( - SubtitleOverlayTransformation.builder() - .background("red") - .color("0000ff") - .fontFamily("Arial") - .fontOutline("2_A1CCDD50") - .fontShadow("A1CCDD_3") - .build() - ) - ) - .build() - ) - ) - .build(), - // Solid color overlay - Transformation.builder() - .overlay( - Overlay.ofSolidColor( - SolidColorOverlay.builder() - .color("FF0000") - .type(JsonValue.from("solidColor")) - .position( - OverlayPosition.builder() - .x("10") - .y("20") - .focus(OverlayPosition.Focus.CENTER) - .build() - ) - .timing( - OverlayTiming.builder() - .start(5.0) - .duration("10") - .end(15.0) - .build() - ) - .transformation( - listOf( - SolidColorOverlayTransformation.builder() - .width("bw_mul_0.5") - .height("bh_mul_0.5") - .alpha(0.5) - .background("red") - .gradientTrue() - .radiusMax() - .build() - ) - ) - .build() - ) - ) - .build(), - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Every%20thing,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,w-bw_mul_0.5,fs-20,ff-Arial,co-0000ff,ia-left,pa-5,al-7,tg-b,bg-red,r-10,rt-N45,fl-h,lh-20,l-end:l-image,i-logo.png,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,w-bw_mul_0.5,h-bh_mul_0.5,rt-N45,fl-h,l-text,i-Nested%20text%20overlay,l-end,l-end:l-video,i-play-pause-loop.mp4,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,w-bw_mul_0.5,h-bh_mul_0.5,rt-N45,fl-h,l-end:l-subtitles,i-subtitle.srt,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,bg-red,co-0000ff,ff-Arial,fol-2_A1CCDD50,fsh-A1CCDD_3,l-end:l-image,i-ik_canvas,bg-FF0000,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,w-bw_mul_0.5,h-bh_mul_0.5,al-0.5,bg-red,e-gradient,r-max,l-end/base-image.jpg" - ) - } - - // ======================================== - // TestOverlayEncoding - 19 tests - // ======================================== - - @Test - fun `should use plain encoding for simple image paths with slashes converted to @@`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("/customer_logo/nykaa.png") - .type(JsonValue.from("image")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/medium_cafe_B1iTdD0C.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-image,i-customer_logo@@nykaa.png,l-end/medium_cafe_B1iTdD0C.jpg" - ) - } - - @Test - fun `should use base64 encoding for image paths containing special characters`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("/customer_logo/Ñykaa.png") - .type(JsonValue.from("image")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/medium_cafe_B1iTdD0C.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-image,ie-Y3VzdG9tZXJfbG9nby%2FDkXlrYWEucG5n,l-end/medium_cafe_B1iTdD0C.jpg" - ) - } - - @Test - fun `should use plain encoding for simple text overlays`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder().text("Manu").type(JsonValue.from("text")).build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/medium_cafe_B1iTdD0C.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-text,i-Manu,l-end/medium_cafe_B1iTdD0C.jpg" - ) - } - - @Test - fun `should convert slashes to @@ in fontFamily paths for custom fonts`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("Manu") - .type(JsonValue.from("text")) - .transformation( - listOf( - TextOverlayTransformation.builder() - .fontFamily("nested-path/Poppins-Regular_Q15GrYWmL.ttf") - .build() - ) - ) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/medium_cafe_B1iTdD0C.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-text,i-Manu,ff-nested-path@@Poppins-Regular_Q15GrYWmL.ttf,l-end/medium_cafe_B1iTdD0C.jpg" - ) - } - - @Test - fun `should use URL encoding for text overlays with spaces and safe characters`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("alnum123-._ ") - .type(JsonValue.from("text")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/medium_cafe_B1iTdD0C.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-text,i-alnum123-._%20,l-end/medium_cafe_B1iTdD0C.jpg" - ) - } - - @Test - fun `should use base64 encoding for text overlays with special unicode characters`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("Let's use ©, ®, ™, etc") - .type(JsonValue.from("text")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/medium_cafe_B1iTdD0C.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-text,ie-TGV0J3MgdXNlIMKpLCDCriwg4oSiLCBldGM%3D,l-end/medium_cafe_B1iTdD0C.jpg" - ) - } - - @Test - fun `should use plain encoding when explicitly specified for text overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("HelloWorld") - .type(JsonValue.from("text")) - .encoding(TextOverlay.Encoding.PLAIN) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/sample.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/demo/tr:l-text,i-HelloWorld,l-end/sample.jpg") - } - - @Test - fun `should use base64 encoding when explicitly specified for text overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("HelloWorld") - .type(JsonValue.from("text")) - .encoding(TextOverlay.Encoding.BASE64) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/sample.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-text,ie-SGVsbG9Xb3JsZA%3D%3D,l-end/sample.jpg" - ) - } - - @Test - fun `should use plain encoding when explicitly specified for image overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("/customer/logo.png") - .type(JsonValue.from("image")) - .encoding(ImageOverlay.Encoding.PLAIN) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/sample.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-image,i-customer@@logo.png,l-end/sample.jpg" - ) - } - - @Test - fun `should use base64 encoding when explicitly specified for image overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("/customer/logo.png") - .type(JsonValue.from("image")) - .encoding(ImageOverlay.Encoding.BASE64) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/sample.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-image,ie-Y3VzdG9tZXIvbG9nby5wbmc%3D,l-end/sample.jpg" - ) - } - - @Test - fun `should use base64 encoding when explicitly specified for video overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofVideo( - VideoOverlay.builder() - .input("/path/to/video.mp4") - .type(JsonValue.from("video")) - .encoding(VideoOverlay.Encoding.BASE64) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/sample.mp4") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-video,ie-cGF0aC90by92aWRlby5tcDQ%3D,l-end/sample.mp4" - ) - } - - @Test - fun `should use plain encoding when explicitly specified for subtitle overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofSubtitle( - SubtitleOverlay.builder() - .input("/sub.srt") - .type(JsonValue.from("subtitle")) - .encoding(SubtitleOverlay.Encoding.PLAIN) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/sample.mp4") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/demo/tr:l-subtitles,i-sub.srt,l-end/sample.mp4") - } - - @Test - fun `should use base64 encoding when explicitly specified for subtitle overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofSubtitle( - SubtitleOverlay.builder() - .input("sub.srt") - .type(JsonValue.from("subtitle")) - .encoding(SubtitleOverlay.Encoding.BASE64) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.PATH) - .src("/sample.mp4") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-subtitles,ie-c3ViLnNydA%3D%3D,l-end/sample.mp4" - ) - } - - @Test - fun `should properly encode overlay text when transformations are in query parameters`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("Minimal Text") - .type(JsonValue.from("text")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo") - .transformationPosition(TransformationPosition.QUERY) - .src("/sample.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo("https://ik.imagekit.io/demo/sample.jpg?tr=l-text,i-Minimal%20Text,l-end") - } - - @Test - fun `should generate URL with image overlay using layerMode multiply`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("logo.png") - .type(JsonValue.from("image")) - .layerMode(BaseOverlay.LayerMode.MULTIPLY) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-logo.png,lm-multiply,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate URL with image overlay using layerMode cutter`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("mask.png") - .type(JsonValue.from("image")) - .layerMode(BaseOverlay.LayerMode.CUTTER) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-mask.png,lm-cutter,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate URL with image overlay using layerMode cutout`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("shape.png") - .type(JsonValue.from("image")) - .layerMode(BaseOverlay.LayerMode.CUTOUT) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-shape.png,lm-cutout,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate URL with image overlay using layerMode displace`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("displacement.png") - .type(JsonValue.from("image")) - .layerMode(BaseOverlay.LayerMode.DISPLACE) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-displacement.png,lm-displace,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate URL with image overlay using xCenter yCenter and anchorPoint`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("logo.png") - .type(JsonValue.from("image")) - .position( - OverlayPosition.builder() - .xCenter(50.0) - .yCenter("bh_mul_0.5") - .anchorPoint(OverlayPosition.AnchorPoint.TOP_LEFT) - .build() - ) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-logo.png,lxc-50,lyc-bh_mul_0.5,lap-top_left,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate layerMode on text overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("Hello") - .type(JsonValue.from("text")) - .layerMode(BaseOverlay.LayerMode.MULTIPLY) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Hello,lm-multiply,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate layerMode on video overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofVideo( - VideoOverlay.builder() - .input("video.mp4") - .type(JsonValue.from("video")) - .layerMode(BaseOverlay.LayerMode.MULTIPLY) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-video,i-video.mp4,lm-multiply,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate layerMode on subtitle overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofSubtitle( - SubtitleOverlay.builder() - .input("subtitle.srt") - .type(JsonValue.from("subtitle")) - .layerMode(BaseOverlay.LayerMode.CUTTER) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-subtitles,i-subtitle.srt,lm-cutter,l-end/base-image.jpg" - ) - } - - @Test - fun `should generate layerMode on solid color overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofSolidColor( - SolidColorOverlay.builder() - .color("FF0000") - .type(JsonValue.from("solidColor")) - .layerMode(BaseOverlay.LayerMode.CUTOUT) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-ik_canvas,bg-FF0000,lm-cutout,l-end/base-image.jpg" - ) - } - - @Test - fun `should strip leading and trailing slashes from image overlay input path`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("/path/to/logo.png/") - .type(JsonValue.from("image")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-path@@to@@logo.png,l-end/base-image.jpg" - ) - } - - @Test - fun `should strip leading and trailing slashes from fontFamily in text overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("Hello") - .type(JsonValue.from("text")) - .transformation( - listOf( - TextOverlayTransformation.builder() - .fontFamily("/sdk-testing-files/Poppins-Regular.ttf/") - .build() - ) - ) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Hello,ff-sdk-testing-files@@Poppins-Regular.ttf,l-end/base-image.jpg" - ) - } - - @Test - fun `should use processInputPath for subtitle overlay with slashes`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofSubtitle( - SubtitleOverlay.builder() - .input("/path/to/subtitle.srt") - .type(JsonValue.from("subtitle")) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-subtitles,i-path@@to@@subtitle.srt,l-end/base-image.jpg" - ) - } - - @Test - fun `should order anchorPoint before focus in overlay position`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofImage( - ImageOverlay.builder() - .input("logo.png") - .type(JsonValue.from("image")) - .position( - OverlayPosition.builder() - .focus(OverlayPosition.Focus.CENTER) - .anchorPoint(OverlayPosition.AnchorPoint.BOTTOM_RIGHT) - .build() - ) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-logo.png,lap-bottom_right,lfo-center,l-end/base-image.jpg" - ) - } - - @Test - fun `should properly path-escape special characters in plain text overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("Hello World") - .type(JsonValue.from("text")) - .encoding(TextOverlay.Encoding.PLAIN) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") - .transformationPosition(TransformationPosition.PATH) - .src("/base-image.jpg") - .transformation(transformation) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Hello%20World,l-end/base-image.jpg" - ) - } -} diff --git a/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperSigningTest.kt b/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperSigningTest.kt deleted file mode 100644 index e5caee28..00000000 --- a/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperSigningTest.kt +++ /dev/null @@ -1,279 +0,0 @@ -package com.imagekit.api.lib - -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class HelperSigningTest { - - private val privateKey = "dummy-key" - private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() - - @Test - fun `should generate a signed URL when signed is true without expiresIn`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo/") - .src("sdk-testing-files/future-search.png") - .signed(true) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/sdk-testing-files/future-search.png?ik-s=32dbbbfc5f945c0403c71b54c38e76896ef2d6b0" - ) - } - - @Test - fun `should generate a signed URL when signed is true with expiresIn`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo/") - .src("sdk-testing-files/future-search.png") - .signed(true) - .expiresIn(3600.0) - .build() - ) - - // Expect ik-t exist in the URL. We don't assert signature because it will keep changing. - assertThat(url).contains("ik-t") - } - - @Test - fun `should generate a signed URL when expiresIn is above 0 and even if signed is false`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo/") - .src("sdk-testing-files/future-search.png") - .signed(false) - .expiresIn(3600.0) - .build() - ) - - // Expect ik-t exist in the URL. We don't assert signature because it will keep changing. - assertThat(url).contains("ik-t") - } - - @Test - fun `should generate signed URL with special characters in filename`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo/") - .src("sdk-testing-files/हिन्दी.png") - .signed(true) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/sdk-testing-files/%E0%A4%B9%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%A6%E0%A5%80.png?ik-s=3fff2f31da1f45e007adcdbe95f88c8c330e743c" - ) - } - - @Test - fun `should generate signed URL with text overlay containing special characters`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("हिन्दी") - .type(JsonValue.from("text")) - .transformation( - listOf( - TextOverlayTransformation.builder() - .fontColor("red") - .fontSize("32") - .fontFamily( - "sdk-testing-files/Poppins-Regular_Q15GrYWmL.ttf" - ) - .build() - ) - ) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo/") - .src("sdk-testing-files/हिन्दी.png") - .transformation(transformation) - .signed(true) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/sdk-testing-files/%E0%A4%B9%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%A6%E0%A5%80.png?tr=l-text,ie-4KS54KS%2F4KSo4KWN4KSm4KWA,fs-32,ff-sdk-testing-files@@Poppins-Regular_Q15GrYWmL.ttf,co-red,l-end&ik-s=705e41579d368caa6530a4375355325277fcfe5c" - ) - } - - @Test - fun `should generate signed URL with text overlay and special characters using path transformation position`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder() - .text("हिन्दी") - .type(JsonValue.from("text")) - .transformation( - listOf( - TextOverlayTransformation.builder() - .fontColor("red") - .fontSize("32") - .fontFamily( - "sdk-testing-files/Poppins-Regular_Q15GrYWmL.ttf" - ) - .build() - ) - ) - .build() - ) - ) - .build() - ) - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo/") - .src("sdk-testing-files/हिन्दी.png") - .transformationPosition(TransformationPosition.PATH) - .transformation(transformation) - .signed(true) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:l-text,ie-4KS54KS%2F4KSo4KWN4KSm4KWA,fs-32,ff-sdk-testing-files@@Poppins-Regular_Q15GrYWmL.ttf,co-red,l-end/sdk-testing-files/%E0%A4%B9%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%A6%E0%A5%80.png?ik-s=20958f6126fd67c90653f55a49f2b7bb938d9d1c" - ) - } - - @Test - fun `should generate signed URL with query parameters`() { - val queryParams = - SrcOptions.QueryParameters.builder() - .putAdditionalProperty("version", JsonValue.from("1.0")) - .putAdditionalProperty("cache", JsonValue.from("false")) - .build() - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo/") - .src("sdk-testing-files/future-search.png") - .queryParameters(queryParams) - .signed(true) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/sdk-testing-files/future-search.png?cache=false&version=1.0&ik-s=03767bb6f0898c04e42f65714af65d937c696d66" - ) - } - - @Test - fun `should generate signed URL with transformations and query parameters`() { - val transformation = listOf(Transformation.builder().width(300.0).height(200.0).build()) - - val queryParams = - SrcOptions.QueryParameters.builder() - .putAdditionalProperty("version", JsonValue.from("2.0")) - .build() - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo/") - .src("sdk-testing-files/future-search.png") - .transformation(transformation) - .queryParameters(queryParams) - .signed(true) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/sdk-testing-files/future-search.png?version=2.0&tr=w-300,h-200&ik-s=601d97a7834b7554f4dabf0d3fc3a219ceeb6b31" - ) - } - - @Test - fun `should not sign URL when signed is false`() { - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo/") - .src("sdk-testing-files/future-search.png") - .signed(false) - .build() - ) - - assertThat(url).isEqualTo("https://ik.imagekit.io/demo/sdk-testing-files/future-search.png") - assertThat(url).doesNotContain("ik-s=") - assertThat(url).doesNotContain("ik-t=") - } - - @Test - fun `should generate signed URL with transformations in path position and query parameters`() { - val transformation = listOf(Transformation.builder().width(300.0).height(200.0).build()) - - val queryParams = - SrcOptions.QueryParameters.builder() - .putAdditionalProperty("version", JsonValue.from("2.0")) - .build() - - val url = - client - .helper() - .buildUrl( - SrcOptions.builder() - .urlEndpoint("https://ik.imagekit.io/demo/") - .src("sdk-testing-files/future-search.png") - .transformation(transformation) - .transformationPosition(TransformationPosition.PATH) - .queryParameters(queryParams) - .signed(true) - .build() - ) - - assertThat(url) - .isEqualTo( - "https://ik.imagekit.io/demo/tr:w-300,h-200/sdk-testing-files/future-search.png?version=2.0&ik-s=dd1ee8f83d019bc59fd57a5fc4674a11eb8a3496" - ) - } -} diff --git a/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperTransformationTest.kt b/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperTransformationTest.kt deleted file mode 100644 index bd33eb0b..00000000 --- a/image-kit-java-lib/src/test/kotlin/com/imagekit/api/lib/HelperTransformationTest.kt +++ /dev/null @@ -1,108 +0,0 @@ -package com.imagekit.api.lib - -import com.imagekit.api.client.okhttp.ImageKitOkHttpClient -import com.imagekit.api.core.JsonValue -import com.imagekit.api.models.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class HelperTransformationTest { - - private val privateKey = "test-key" - private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() - - @Test - fun `should return empty string for empty transformation array`() { - val result = client.helper().buildTransformationString(null) - assertThat(result).isEmpty() - - val result2 = client.helper().buildTransformationString(emptyList()) - assertThat(result2).isEmpty() - } - - @Test - fun `should generate transformation string for width only`() { - val transformation = listOf(Transformation.builder().width(300.0).build()) - - val result = client.helper().buildTransformationString(transformation) - assertThat(result).isEqualTo("w-300") - } - - @Test - fun `should generate transformation string for multiple parameters`() { - val transformation = listOf(Transformation.builder().width(300.0).height(200.0).build()) - - val result = client.helper().buildTransformationString(transformation) - assertThat(result).isEqualTo("w-300,h-200") - } - - @Test - fun `should generate transformation string for chained transformations`() { - val transformation = - listOf( - Transformation.builder().width(300.0).build(), - Transformation.builder().height(200.0).build(), - ) - - val result = client.helper().buildTransformationString(transformation) - assertThat(result).isEqualTo("w-300:h-200") - } - - @Test - fun `should handle empty transformation object`() { - val transformation = listOf(Transformation.builder().build()) - - val result = client.helper().buildTransformationString(transformation) - assertThat(result).isEmpty() - } - - @Test - fun `should handle transformation with overlay`() { - val transformation = - listOf( - Transformation.builder() - .overlay( - Overlay.ofText( - TextOverlay.builder().text("Hello").type(JsonValue.from("text")).build() - ) - ) - .build() - ) - - val result = client.helper().buildTransformationString(transformation) - assertThat(result).isEqualTo("l-text,i-Hello,l-end") - } - - @Test - fun `should handle raw transformation parameter`() { - val transformation = listOf(Transformation.builder().raw("custom-transform-123").build()) - - val result = client.helper().buildTransformationString(transformation) - assertThat(result).isEqualTo("custom-transform-123") - } - - @Test - fun `should handle mixed parameters with raw`() { - val transformation = - listOf(Transformation.builder().width(300.0).raw("custom-param-123").build()) - - val result = client.helper().buildTransformationString(transformation) - assertThat(result).isEqualTo("w-300,custom-param-123") - } - - @Test - fun `should handle quality parameter`() { - val transformation = listOf(Transformation.builder().quality(80.0).build()) - - val result = client.helper().buildTransformationString(transformation) - assertThat(result).isEqualTo("q-80") - } - - @Test - fun `should handle aspect ratio parameter`() { - val transformation = listOf(Transformation.builder().aspectRatio("4:3").build()) - - val result = client.helper().buildTransformationString(transformation) - assertThat(result).isEqualTo("ar-4:3") - } -} diff --git a/image-kit-java-proguard-test/build.gradle.kts b/image-kit-java-proguard-test/build.gradle.kts index a921f20a..b3d4162e 100644 --- a/image-kit-java-proguard-test/build.gradle.kts +++ b/image-kit-java-proguard-test/build.gradle.kts @@ -59,7 +59,7 @@ val testProGuard by tasks.registering(JavaExec::class) { dependsOn(proguardJar) notCompatibleWithConfigurationCache("ProGuard") - mainClass.set("io.imagekit.io.proguard.ProGuardCompatibilityTest") + mainClass.set("io.imagekit.api.proguard.ProGuardCompatibilityTest") classpath = files(proguardJarPath) } @@ -89,7 +89,7 @@ val testR8 by tasks.registering(JavaExec::class) { dependsOn(r8Jar) notCompatibleWithConfigurationCache("R8") - mainClass.set("io.imagekit.io.proguard.ProGuardCompatibilityTest") + mainClass.set("io.imagekit.api.proguard.ProGuardCompatibilityTest") classpath = files(r8JarPath) } diff --git a/image-kit-java-proguard-test/src/test/kotlin/io/imagekit/io/proguard/ProGuardCompatibilityTest.kt b/image-kit-java-proguard-test/src/test/kotlin/io/imagekit/api/proguard/ProGuardCompatibilityTest.kt similarity index 94% rename from image-kit-java-proguard-test/src/test/kotlin/io/imagekit/io/proguard/ProGuardCompatibilityTest.kt rename to image-kit-java-proguard-test/src/test/kotlin/io/imagekit/api/proguard/ProGuardCompatibilityTest.kt index 5338df20..c6e65633 100644 --- a/image-kit-java-proguard-test/src/test/kotlin/io/imagekit/io/proguard/ProGuardCompatibilityTest.kt +++ b/image-kit-java-proguard-test/src/test/kotlin/io/imagekit/api/proguard/ProGuardCompatibilityTest.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.io.proguard +package io.imagekit.api.proguard import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.io.client.okhttp.ImageKitOkHttpClient -import io.imagekit.io.core.JsonValue -import io.imagekit.io.core.jsonMapper -import io.imagekit.io.models.AiTag -import io.imagekit.io.models.CustomMetadata -import io.imagekit.io.models.EmbeddedMetadata -import io.imagekit.io.models.ExtensionItem -import io.imagekit.io.models.SelectedFieldsSchema -import io.imagekit.io.models.StreamingResolution -import io.imagekit.io.models.VersionInfo -import io.imagekit.io.models.files.File -import io.imagekit.io.models.files.UpdateFileRequest +import io.imagekit.api.client.okhttp.ImageKitOkHttpClient +import io.imagekit.api.core.JsonValue +import io.imagekit.api.core.jsonMapper +import io.imagekit.api.models.AiTag +import io.imagekit.api.models.CustomMetadata +import io.imagekit.api.models.EmbeddedMetadata +import io.imagekit.api.models.ExtensionItem +import io.imagekit.api.models.SelectedFieldsSchema +import io.imagekit.api.models.StreamingResolution +import io.imagekit.api.models.VersionInfo +import io.imagekit.api.models.files.File +import io.imagekit.api.models.files.UpdateFileRequest import java.time.OffsetDateTime import kotlin.reflect.full.memberFunctions import kotlin.reflect.jvm.javaMethod diff --git a/image-kit-java-proguard-test/test.pro b/image-kit-java-proguard-test/test.pro index dc442971..1b4acb55 100644 --- a/image-kit-java-proguard-test/test.pro +++ b/image-kit-java-proguard-test/test.pro @@ -1,5 +1,5 @@ # Specify the entrypoint where ProGuard starts to determine what's reachable. --keep class io.imagekit.io.proguard.** { *; } +-keep class io.imagekit.api.proguard.** { *; } # For the testing framework. -keep class org.junit.** { *; } From afb90e655bbe37ba25e2cb3f02577414483c3488 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 18:43:26 +0000 Subject: [PATCH 140/142] feat(api): manual updates --- .stats.yml | 2 +- README.md | 182 +++++++++--------- build.gradle.kts | 2 +- .../client/okhttp/ImageKitOkHttpClient.kt | 24 +-- .../okhttp/ImageKitOkHttpClientAsync.kt | 24 +-- .../{api => }/client/okhttp/OkHttpClient.kt | 22 +-- .../client/okhttp/OkHttpClientTest.kt | 6 +- .../{api => }/client/ImageKitClient.kt | 24 +-- .../{api => }/client/ImageKitClientAsync.kt | 24 +-- .../client/ImageKitClientAsyncImpl.kt | 44 ++--- .../{api => }/client/ImageKitClientImpl.kt | 44 ++--- .../{api => }/core/BaseDeserializer.kt | 2 +- .../imagekit/{api => }/core/BaseSerializer.kt | 2 +- .../io/imagekit/{api => }/core/Check.kt | 2 +- .../imagekit/{api => }/core/ClientOptions.kt | 20 +- .../imagekit/{api => }/core/DefaultSleeper.kt | 2 +- .../imagekit/{api => }/core/ObjectMappers.kt | 2 +- .../io/imagekit/{api => }/core/Params.kt | 6 +- .../{api => }/core/PhantomReachable.kt | 4 +- .../core/PhantomReachableExecutorService.kt | 2 +- .../{api => }/core/PhantomReachableSleeper.kt | 2 +- .../imagekit/{api => }/core/PrepareRequest.kt | 4 +- .../io/imagekit/{api => }/core/Properties.kt | 4 +- .../imagekit/{api => }/core/RequestOptions.kt | 2 +- .../io/imagekit/{api => }/core/Sleeper.kt | 2 +- .../io/imagekit/{api => }/core/Timeout.kt | 2 +- .../{api => }/core/UnwrapWebhookParams.kt | 4 +- .../io/imagekit/{api => }/core/Utils.kt | 4 +- .../io/imagekit/{api => }/core/Values.kt | 4 +- .../{api => }/core/handlers/EmptyHandler.kt | 6 +- .../{api => }/core/handlers/ErrorHandler.kt | 26 +-- .../{api => }/core/handlers/JsonHandler.kt | 8 +- .../{api => }/core/handlers/StringHandler.kt | 6 +- .../core/http/AsyncStreamResponse.kt | 4 +- .../imagekit/{api => }/core/http/Headers.kt | 22 +-- .../{api => }/core/http/HttpClient.kt | 4 +- .../{api => }/core/http/HttpMethod.kt | 2 +- .../{api => }/core/http/HttpRequest.kt | 6 +- .../{api => }/core/http/HttpRequestBodies.kt | 8 +- .../{api => }/core/http/HttpRequestBody.kt | 2 +- .../{api => }/core/http/HttpResponse.kt | 2 +- .../{api => }/core/http/HttpResponseFor.kt | 2 +- ...ntomReachableClosingAsyncStreamResponse.kt | 6 +- .../http/PhantomReachableClosingHttpClient.kt | 6 +- .../PhantomReachableClosingStreamResponse.kt | 4 +- .../{api => }/core/http/QueryParams.kt | 22 +-- .../{api => }/core/http/RetryingHttpClient.kt | 16 +- .../{api => }/core/http/StreamResponse.kt | 2 +- .../{api => }/errors/BadRequestException.kt | 8 +- .../{api => }/errors/ImageKitException.kt | 2 +- .../errors/ImageKitInvalidDataException.kt | 2 +- .../{api => }/errors/ImageKitIoException.kt | 2 +- .../errors/ImageKitRetryableException.kt | 2 +- .../errors/ImageKitServiceException.kt | 6 +- .../errors/ImageKitWebhookException.kt | 2 +- .../errors/InternalServerException.kt | 8 +- .../{api => }/errors/NotFoundException.kt | 8 +- .../errors/PermissionDeniedException.kt | 8 +- .../{api => }/errors/RateLimitException.kt | 8 +- .../{api => }/errors/UnauthorizedException.kt | 8 +- .../errors/UnexpectedStatusCodeException.kt | 8 +- .../errors/UnprocessableEntityException.kt | 8 +- .../io/imagekit/{api => }/models/AiTag.kt | 12 +- .../imagekit/{api => }/models/BaseOverlay.kt | 14 +- .../{api => }/models/CustomMetadata.kt | 10 +- .../{api => }/models/EmbeddedMetadata.kt | 10 +- .../{api => }/models/ExtensionConfig.kt | 28 +-- .../{api => }/models/ExtensionItem.kt | 28 +-- .../models/GetImageAttributesOptions.kt | 18 +- .../imagekit/{api => }/models/ImageOverlay.kt | 20 +- .../io/imagekit/{api => }/models/Overlay.kt | 12 +- .../{api => }/models/OverlayPosition.kt | 22 +-- .../{api => }/models/OverlayTiming.kt | 20 +- .../models/ResponsiveImageAttributes.kt | 14 +- .../{api => }/models/SavedExtension.kt | 12 +- .../{api => }/models/SelectedFieldsSchema.kt | 10 +- .../{api => }/models/SolidColorOverlay.kt | 18 +- .../models/SolidColorOverlayTransformation.kt | 20 +- .../imagekit/{api => }/models/SrcOptions.kt | 18 +- .../{api => }/models/StreamingResolution.kt | 8 +- .../{api => }/models/SubtitleOverlay.kt | 20 +- .../models/SubtitleOverlayTransformation.kt | 14 +- .../imagekit/{api => }/models/TextOverlay.kt | 20 +- .../models/TextOverlayTransformation.kt | 22 +-- .../{api => }/models/Transformation.kt | 26 +-- .../models/TransformationPosition.kt | 8 +- .../imagekit/{api => }/models/VersionInfo.kt | 12 +- .../imagekit/{api => }/models/VideoOverlay.kt | 20 +- .../accounts/origins/OriginCreateParams.kt | 10 +- .../accounts/origins/OriginDeleteParams.kt | 12 +- .../accounts/origins/OriginGetParams.kt | 8 +- .../accounts/origins/OriginListParams.kt | 8 +- .../models/accounts/origins/OriginRequest.kt | 20 +- .../models/accounts/origins/OriginResponse.kt | 20 +- .../accounts/origins/OriginUpdateParams.kt | 10 +- .../urlendpoints/UrlEndpointCreateParams.kt | 12 +- .../urlendpoints/UrlEndpointDeleteParams.kt | 12 +- .../urlendpoints/UrlEndpointGetParams.kt | 8 +- .../urlendpoints/UrlEndpointListParams.kt | 8 +- .../urlendpoints/UrlEndpointRequest.kt | 24 +-- .../urlendpoints/UrlEndpointResponse.kt | 24 +-- .../urlendpoints/UrlEndpointUpdateParams.kt | 12 +- .../models/accounts/usage/UsageGetParams.kt | 10 +- .../models/accounts/usage/UsageGetResponse.kt | 12 +- .../models/assets/AssetListParams.kt | 14 +- .../models/assets/AssetListResponse.kt | 16 +- .../models/beta/v2/files/FileUploadParams.kt | 32 +-- .../beta/v2}/files/FileUploadResponse.kt | 29 +-- .../invalidation/InvalidationCreateParams.kt | 20 +- .../InvalidationCreateResponse.kt | 12 +- .../invalidation/InvalidationGetParams.kt | 8 +- .../invalidation/InvalidationGetResponse.kt | 14 +- .../CustomMetadataField.kt | 28 +-- .../CustomMetadataFieldCreateParams.kt | 34 ++-- .../CustomMetadataFieldDeleteParams.kt | 12 +- .../CustomMetadataFieldDeleteResponse.kt | 8 +- .../CustomMetadataFieldListParams.kt | 8 +- .../CustomMetadataFieldUpdateParams.kt | 30 +-- .../imagekit/{api => }/models/files/File.kt | 28 +-- .../{api => }/models/files/FileCopyParams.kt | 20 +- .../models/files/FileCopyResponse.kt | 8 +- .../models/files/FileDeleteParams.kt | 12 +- .../{api => }/models/files/FileGetParams.kt | 8 +- .../{api => }/models/files/FileMoveParams.kt | 20 +- .../models/files/FileMoveResponse.kt | 8 +- .../models/files/FileRenameParams.kt | 20 +- .../models/files/FileRenameResponse.kt | 12 +- .../models/files/FileUpdateParams.kt | 10 +- .../models/files/FileUpdateResponse.kt | 28 +-- .../models/files/FileUploadParams.kt | 32 +-- .../v2 => models}/files/FileUploadResponse.kt | 29 ++- .../imagekit/{api => }/models/files/Folder.kt | 16 +- .../{api => }/models/files/Metadata.kt | 16 +- .../models/files/UpdateFileRequest.kt | 28 +-- .../models/files/bulk/BulkAddTagsParams.kt | 24 +-- .../models/files/bulk/BulkAddTagsResponse.kt | 16 +- .../models/files/bulk/BulkDeleteParams.kt | 24 +-- .../models/files/bulk/BulkDeleteResponse.kt | 16 +- .../files/bulk/BulkRemoveAiTagsParams.kt | 24 +-- .../files/bulk/BulkRemoveAiTagsResponse.kt | 16 +- .../models/files/bulk/BulkRemoveTagsParams.kt | 24 +-- .../files/bulk/BulkRemoveTagsResponse.kt | 16 +- .../metadata/MetadataGetFromUrlParams.kt | 10 +- .../files/metadata/MetadataGetParams.kt | 8 +- .../files/versions/VersionDeleteParams.kt | 16 +- .../files/versions/VersionDeleteResponse.kt | 8 +- .../models/files/versions/VersionGetParams.kt | 10 +- .../files/versions/VersionListParams.kt | 8 +- .../files/versions/VersionRestoreParams.kt | 16 +- .../models/folders/FolderCopyParams.kt | 20 +- .../models/folders/FolderCopyResponse.kt | 14 +- .../models/folders/FolderCreateParams.kt | 20 +- .../models/folders/FolderCreateResponse.kt | 8 +- .../models/folders/FolderDeleteParams.kt | 20 +- .../models/folders/FolderDeleteResponse.kt | 8 +- .../models/folders/FolderMoveParams.kt | 20 +- .../models/folders/FolderMoveResponse.kt | 14 +- .../models/folders/FolderRenameParams.kt | 20 +- .../models/folders/FolderRenameResponse.kt | 14 +- .../models/folders/job/JobGetParams.kt | 8 +- .../models/folders/job/JobGetResponse.kt | 14 +- .../SavedExtensionCreateParams.kt | 22 +-- .../SavedExtensionDeleteParams.kt | 12 +- .../SavedExtensionGetParams.kt | 8 +- .../SavedExtensionListParams.kt | 8 +- .../SavedExtensionUpdateParams.kt | 20 +- .../models/webhooks/BaseWebhookEvent.kt | 14 +- .../models/webhooks/FileCreateEvent.kt | 16 +- .../models/webhooks/FileDeleteEvent.kt | 14 +- .../models/webhooks/FileUpdateEvent.kt | 16 +- .../models/webhooks/FileVersionCreateEvent.kt | 16 +- .../models/webhooks/FileVersionDeleteEvent.kt | 14 +- .../webhooks/UnsafeUnwrapWebhookEvent.kt | 14 +- .../models/webhooks/UnwrapWebhookEvent.kt | 14 +- .../webhooks/UploadPostTransformErrorEvent.kt | 16 +- .../UploadPostTransformSuccessEvent.kt | 16 +- .../webhooks/UploadPreTransformErrorEvent.kt | 14 +- .../UploadPreTransformSuccessEvent.kt | 32 +-- .../VideoTransformationAcceptedEvent.kt | 20 +- .../webhooks/VideoTransformationErrorEvent.kt | 20 +- .../webhooks/VideoTransformationReadyEvent.kt | 20 +- .../services/async/AccountServiceAsync.kt | 10 +- .../services/async/AccountServiceAsyncImpl.kt | 18 +- .../services/async/AssetServiceAsync.kt | 12 +- .../services/async/AssetServiceAsyncImpl.kt | 30 +-- .../services/async/BetaServiceAsync.kt | 6 +- .../services/async/BetaServiceAsyncImpl.kt | 8 +- .../services/async/CacheServiceAsync.kt | 6 +- .../services/async/CacheServiceAsyncImpl.kt | 8 +- .../async/CustomMetadataFieldServiceAsync.kt | 22 +-- .../CustomMetadataFieldServiceAsyncImpl.kt | 44 ++--- .../services/async/FileServiceAsync.kt | 44 ++--- .../services/async/FileServiceAsyncImpl.kt | 74 +++---- .../services/async/FolderServiceAsync.kt | 32 +-- .../services/async/FolderServiceAsyncImpl.kt | 52 ++--- .../async/SavedExtensionServiceAsync.kt | 24 +-- .../async/SavedExtensionServiceAsyncImpl.kt | 46 ++--- .../services/async/WebhookServiceAsync.kt | 16 +- .../services/async/WebhookServiceAsyncImpl.kt | 12 +- .../async/accounts/OriginServiceAsync.kt | 26 +-- .../async/accounts/OriginServiceAsyncImpl.kt | 46 ++--- .../async/accounts/UrlEndpointServiceAsync.kt | 26 +-- .../accounts/UrlEndpointServiceAsyncImpl.kt | 46 ++--- .../async/accounts/UsageServiceAsync.kt | 12 +- .../async/accounts/UsageServiceAsyncImpl.kt | 30 +-- .../services/async/beta/V2ServiceAsync.kt | 6 +- .../services/async/beta/V2ServiceAsyncImpl.kt | 8 +- .../async/beta/v2/FileServiceAsync.kt | 12 +- .../async/beta/v2/FileServiceAsyncImpl.kt | 32 +-- .../async/cache/InvalidationServiceAsync.kt | 18 +- .../cache/InvalidationServiceAsyncImpl.kt | 38 ++-- .../services/async/files/BulkServiceAsync.kt | 26 +-- .../async/files/BulkServiceAsyncImpl.kt | 46 ++--- .../async/files/MetadataServiceAsync.kt | 16 +- .../async/files/MetadataServiceAsyncImpl.kt | 34 ++-- .../async/files/VersionServiceAsync.kt | 22 +-- .../async/files/VersionServiceAsyncImpl.kt | 44 ++--- .../services/async/folders/JobServiceAsync.kt | 12 +- .../async/folders/JobServiceAsyncImpl.kt | 32 +-- .../services/blocking/AccountService.kt | 10 +- .../services/blocking/AccountServiceImpl.kt | 18 +- .../services/blocking/AssetService.kt | 12 +- .../services/blocking/AssetServiceImpl.kt | 30 +-- .../services/blocking/BetaService.kt | 6 +- .../services/blocking/BetaServiceImpl.kt | 8 +- .../services/blocking/CacheService.kt | 6 +- .../services/blocking/CacheServiceImpl.kt | 8 +- .../blocking/CustomMetadataFieldService.kt | 20 +- .../CustomMetadataFieldServiceImpl.kt | 44 ++--- .../services/blocking/FileService.kt | 42 ++-- .../services/blocking/FileServiceImpl.kt | 74 +++---- .../services/blocking/FolderService.kt | 30 +-- .../services/blocking/FolderServiceImpl.kt | 54 +++--- .../blocking/SavedExtensionService.kt | 22 +-- .../blocking/SavedExtensionServiceImpl.kt | 46 ++--- .../services/blocking/WebhookService.kt | 16 +- .../services/blocking/WebhookServiceImpl.kt | 16 +- .../blocking/accounts/OriginService.kt | 24 +-- .../blocking/accounts/OriginServiceImpl.kt | 46 ++--- .../blocking/accounts/UrlEndpointService.kt | 24 +-- .../accounts/UrlEndpointServiceImpl.kt | 46 ++--- .../blocking/accounts/UsageService.kt | 12 +- .../blocking/accounts/UsageServiceImpl.kt | 30 +-- .../services/blocking/beta/V2Service.kt | 6 +- .../services/blocking/beta/V2ServiceImpl.kt | 8 +- .../services/blocking/beta/v2/FileService.kt | 12 +- .../blocking/beta/v2/FileServiceImpl.kt | 32 +-- .../blocking/cache/InvalidationService.kt | 16 +- .../blocking/cache/InvalidationServiceImpl.kt | 38 ++-- .../services/blocking/files/BulkService.kt | 24 +-- .../blocking/files/BulkServiceImpl.kt | 46 ++--- .../blocking/files/MetadataService.kt | 14 +- .../blocking/files/MetadataServiceImpl.kt | 34 ++-- .../services/blocking/files/VersionService.kt | 20 +- .../blocking/files/VersionServiceImpl.kt | 44 ++--- .../services/blocking/folders/JobService.kt | 12 +- .../blocking/folders/JobServiceImpl.kt | 32 +-- .../META-INF/proguard/image-kit-java-core.pro | 6 +- .../{api => }/core/ClientOptionsTest.kt | 4 +- .../{api => }/core/ObjectMappersTest.kt | 2 +- .../{api => }/core/PhantomReachableTest.kt | 2 +- .../io/imagekit/{api => }/core/UtilsTest.kt | 2 +- .../io/imagekit/{api => }/core/ValuesTest.kt | 2 +- .../core/http/AsyncStreamResponseTest.kt | 2 +- .../{api => }/core/http/HeadersTest.kt | 2 +- .../core/http/HttpRequestBodiesTest.kt | 6 +- .../{api => }/core/http/HttpRequestTest.kt | 2 +- .../{api => }/core/http/QueryParamsTest.kt | 2 +- .../core/http/RetryingHttpClientTest.kt | 10 +- .../io/imagekit/{api => }/models/AiTagTest.kt | 4 +- .../{api => }/models/BaseOverlayTest.kt | 4 +- .../{api => }/models/CustomMetadataTest.kt | 6 +- .../{api => }/models/EmbeddedMetadataTest.kt | 6 +- .../{api => }/models/ExtensionConfigTest.kt | 8 +- .../{api => }/models/ExtensionItemTest.kt | 8 +- .../models/GetImageAttributesOptionsTest.kt | 6 +- .../{api => }/models/ImageOverlayTest.kt | 4 +- .../{api => }/models/OverlayPositionTest.kt | 4 +- .../imagekit/{api => }/models/OverlayTest.kt | 8 +- .../{api => }/models/OverlayTimingTest.kt | 4 +- .../models/ResponsiveImageAttributesTest.kt | 4 +- .../{api => }/models/SavedExtensionTest.kt | 4 +- .../models/SelectedFieldsSchemaTest.kt | 6 +- .../{api => }/models/SolidColorOverlayTest.kt | 4 +- .../SolidColorOverlayTransformationTest.kt | 4 +- .../{api => }/models/SrcOptionsTest.kt | 6 +- .../{api => }/models/SubtitleOverlayTest.kt | 4 +- .../SubtitleOverlayTransformationTest.kt | 4 +- .../{api => }/models/TextOverlayTest.kt | 4 +- .../models/TextOverlayTransformationTest.kt | 4 +- .../{api => }/models/TransformationTest.kt | 4 +- .../{api => }/models/VersionInfoTest.kt | 4 +- .../{api => }/models/VideoOverlayTest.kt | 4 +- .../origins/OriginCreateParamsTest.kt | 2 +- .../origins/OriginDeleteParamsTest.kt | 2 +- .../accounts/origins/OriginGetParamsTest.kt | 2 +- .../accounts/origins/OriginListParamsTest.kt | 2 +- .../accounts/origins/OriginRequestTest.kt | 8 +- .../accounts/origins/OriginResponseTest.kt | 8 +- .../origins/OriginUpdateParamsTest.kt | 2 +- .../UrlEndpointCreateParamsTest.kt | 2 +- .../UrlEndpointDeleteParamsTest.kt | 2 +- .../urlendpoints/UrlEndpointGetParamsTest.kt | 2 +- .../urlendpoints/UrlEndpointListParamsTest.kt | 2 +- .../urlendpoints/UrlEndpointRequestTest.kt | 4 +- .../urlendpoints/UrlEndpointResponseTest.kt | 4 +- .../UrlEndpointUpdateParamsTest.kt | 2 +- .../accounts/usage/UsageGetParamsTest.kt | 4 +- .../accounts/usage/UsageGetResponseTest.kt | 4 +- .../models/assets/AssetListParamsTest.kt | 4 +- .../models/assets/AssetListResponseTest.kt | 22 +-- .../beta/v2/files/FileUploadParamsTest.kt | 8 +- .../beta/v2/files/FileUploadResponseTest.kt | 18 +- .../InvalidationCreateParamsTest.kt | 2 +- .../InvalidationCreateResponseTest.kt | 4 +- .../invalidation/InvalidationGetParamsTest.kt | 2 +- .../InvalidationGetResponseTest.kt | 4 +- .../CustomMetadataFieldCreateParamsTest.kt | 2 +- .../CustomMetadataFieldDeleteParamsTest.kt | 2 +- .../CustomMetadataFieldDeleteResponseTest.kt | 4 +- .../CustomMetadataFieldListParamsTest.kt | 4 +- .../CustomMetadataFieldTest.kt | 4 +- .../CustomMetadataFieldUpdateParamsTest.kt | 2 +- .../models/files/FileCopyParamsTest.kt | 2 +- .../models/files/FileCopyResponseTest.kt | 4 +- .../models/files/FileDeleteParamsTest.kt | 2 +- .../models/files/FileGetParamsTest.kt | 2 +- .../models/files/FileMoveParamsTest.kt | 2 +- .../models/files/FileMoveResponseTest.kt | 4 +- .../models/files/FileRenameParamsTest.kt | 2 +- .../models/files/FileRenameResponseTest.kt | 4 +- .../{api => }/models/files/FileTest.kt | 16 +- .../models/files/FileUpdateParamsTest.kt | 6 +- .../models/files/FileUpdateResponseTest.kt | 16 +- .../models/files/FileUploadParamsTest.kt | 8 +- .../models/files/FileUploadResponseTest.kt | 16 +- .../{api => }/models/files/FolderTest.kt | 6 +- .../{api => }/models/files/MetadataTest.kt | 6 +- .../models/files/UpdateFileRequestTest.kt | 10 +- .../files/bulk/BulkAddTagsParamsTest.kt | 2 +- .../files/bulk/BulkAddTagsResponseTest.kt | 4 +- .../models/files/bulk/BulkDeleteParamsTest.kt | 2 +- .../files/bulk/BulkDeleteResponseTest.kt | 4 +- .../files/bulk/BulkRemoveAiTagsParamsTest.kt | 2 +- .../bulk/BulkRemoveAiTagsResponseTest.kt | 4 +- .../files/bulk/BulkRemoveTagsParamsTest.kt | 2 +- .../files/bulk/BulkRemoveTagsResponseTest.kt | 4 +- .../metadata/MetadataGetFromUrlParamsTest.kt | 4 +- .../files/metadata/MetadataGetParamsTest.kt | 2 +- .../files/versions/VersionDeleteParamsTest.kt | 2 +- .../versions/VersionDeleteResponseTest.kt | 4 +- .../files/versions/VersionGetParamsTest.kt | 2 +- .../files/versions/VersionListParamsTest.kt | 2 +- .../versions/VersionRestoreParamsTest.kt | 2 +- .../models/folders/FolderCopyParamsTest.kt | 2 +- .../models/folders/FolderCopyResponseTest.kt | 4 +- .../models/folders/FolderCreateParamsTest.kt | 2 +- .../folders/FolderCreateResponseTest.kt | 4 +- .../models/folders/FolderDeleteParamsTest.kt | 2 +- .../folders/FolderDeleteResponseTest.kt | 4 +- .../models/folders/FolderMoveParamsTest.kt | 2 +- .../models/folders/FolderMoveResponseTest.kt | 4 +- .../models/folders/FolderRenameParamsTest.kt | 2 +- .../folders/FolderRenameResponseTest.kt | 4 +- .../models/folders/job/JobGetParamsTest.kt | 2 +- .../models/folders/job/JobGetResponseTest.kt | 4 +- .../SavedExtensionCreateParamsTest.kt | 4 +- .../SavedExtensionDeleteParamsTest.kt | 2 +- .../SavedExtensionGetParamsTest.kt | 2 +- .../SavedExtensionListParamsTest.kt | 2 +- .../SavedExtensionUpdateParamsTest.kt | 4 +- .../models/webhooks/BaseWebhookEventTest.kt | 4 +- .../models/webhooks/FileCreateEventTest.kt | 18 +- .../models/webhooks/FileDeleteEventTest.kt | 4 +- .../models/webhooks/FileUpdateEventTest.kt | 18 +- .../webhooks/FileVersionCreateEventTest.kt | 18 +- .../webhooks/FileVersionDeleteEventTest.kt | 4 +- .../webhooks/UnsafeUnwrapWebhookEventTest.kt | 22 +-- .../models/webhooks/UnwrapWebhookEventTest.kt | 22 +-- .../UploadPostTransformErrorEventTest.kt | 4 +- .../UploadPostTransformSuccessEventTest.kt | 4 +- .../UploadPreTransformErrorEventTest.kt | 4 +- .../UploadPreTransformSuccessEventTest.kt | 18 +- .../VideoTransformationAcceptedEventTest.kt | 4 +- .../VideoTransformationErrorEventTest.kt | 4 +- .../VideoTransformationReadyEventTest.kt | 4 +- .../{api => }/services/ErrorHandlingTest.kt | 34 ++-- .../{api => }/services/ServiceParamsTest.kt | 12 +- .../services/async/AssetServiceAsyncTest.kt | 6 +- .../CustomMetadataFieldServiceAsyncTest.kt | 10 +- .../services/async/FileServiceAsyncTest.kt | 20 +- .../services/async/FolderServiceAsyncTest.kt | 16 +- .../async/SavedExtensionServiceAsyncTest.kt | 10 +- .../services/async/WebhookServiceAsyncTest.kt | 10 +- .../async/accounts/OriginServiceAsyncTest.kt | 8 +- .../accounts/UrlEndpointServiceAsyncTest.kt | 8 +- .../async/accounts/UsageServiceAsyncTest.kt | 6 +- .../async/beta/v2/FileServiceAsyncTest.kt | 10 +- .../cache/InvalidationServiceAsyncTest.kt | 6 +- .../async/files/BulkServiceAsyncTest.kt | 12 +- .../async/files/MetadataServiceAsyncTest.kt | 6 +- .../async/files/VersionServiceAsyncTest.kt | 10 +- .../async/folders/JobServiceAsyncTest.kt | 4 +- .../services/blocking/AssetServiceTest.kt | 6 +- .../CustomMetadataFieldServiceTest.kt | 10 +- .../services/blocking/FileServiceTest.kt | 20 +- .../services/blocking/FolderServiceTest.kt | 16 +- .../blocking/SavedExtensionServiceTest.kt | 10 +- .../services/blocking/WebhookServiceTest.kt | 10 +- .../blocking/accounts/OriginServiceTest.kt | 8 +- .../accounts/UrlEndpointServiceTest.kt | 8 +- .../blocking/accounts/UsageServiceTest.kt | 6 +- .../blocking/beta/v2/FileServiceTest.kt | 10 +- .../blocking/cache/InvalidationServiceTest.kt | 6 +- .../blocking/files/BulkServiceTest.kt | 12 +- .../blocking/files/MetadataServiceTest.kt | 6 +- .../blocking/files/VersionServiceTest.kt | 10 +- .../blocking/folders/JobServiceTest.kt | 4 +- image-kit-java-proguard-test/build.gradle.kts | 4 +- .../proguard/ProGuardCompatibilityTest.kt | 26 +-- image-kit-java-proguard-test/test.pro | 2 +- 421 files changed, 2817 insertions(+), 2817 deletions(-) rename image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/{api => }/client/okhttp/ImageKitOkHttpClient.kt (96%) rename image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/{api => }/client/okhttp/ImageKitOkHttpClientAsync.kt (96%) rename image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/{api => }/client/okhttp/OkHttpClient.kt (96%) rename image-kit-java-client-okhttp/src/test/kotlin/io/imagekit/{api => }/client/okhttp/OkHttpClientTest.kt (91%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/client/ImageKitClient.kt (85%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/client/ImageKitClientAsync.kt (85%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/client/ImageKitClientAsyncImpl.kt (81%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/client/ImageKitClientImpl.kt (81%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/BaseDeserializer.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/BaseSerializer.kt (85%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/Check.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/ClientOptions.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/DefaultSleeper.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/ObjectMappers.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/Params.kt (77%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/PhantomReachable.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/PhantomReachableExecutorService.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/PhantomReachableSleeper.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/PrepareRequest.kt (91%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/Properties.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/RequestOptions.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/Sleeper.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/Timeout.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/UnwrapWebhookParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/Utils.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/Values.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/handlers/EmptyHandler.kt (62%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/handlers/ErrorHandler.kt (81%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/handlers/JsonHandler.kt (73%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/handlers/StringHandler.kt (68%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/http/AsyncStreamResponse.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/http/Headers.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/http/HttpClient.kt (90%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/http/HttpMethod.kt (78%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/http/HttpRequest.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/http/HttpRequestBodies.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/http/HttpRequestBody.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/http/HttpResponse.kt (92%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/http/HttpResponseFor.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/http/PhantomReachableClosingAsyncStreamResponse.kt (92%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/http/PhantomReachableClosingHttpClient.kt (85%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/http/PhantomReachableClosingStreamResponse.kt (86%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/http/QueryParams.kt (90%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/http/RetryingHttpClient.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/core/http/StreamResponse.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/errors/BadRequestException.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/errors/ImageKitException.kt (82%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/errors/ImageKitInvalidDataException.kt (82%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/errors/ImageKitIoException.kt (81%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/errors/ImageKitRetryableException.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/errors/ImageKitServiceException.kt (74%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/errors/ImageKitWebhookException.kt (82%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/errors/InternalServerException.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/errors/NotFoundException.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/errors/PermissionDeniedException.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/errors/RateLimitException.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/errors/UnauthorizedException.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/errors/UnexpectedStatusCodeException.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/errors/UnprocessableEntityException.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/AiTag.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/BaseOverlay.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/CustomMetadata.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/EmbeddedMetadata.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/ExtensionConfig.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/ExtensionItem.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/GetImageAttributesOptions.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/ImageOverlay.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/Overlay.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/OverlayPosition.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/OverlayTiming.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/ResponsiveImageAttributes.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/SavedExtension.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/SelectedFieldsSchema.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/SolidColorOverlay.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/SolidColorOverlayTransformation.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/SrcOptions.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/StreamingResolution.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/SubtitleOverlay.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/SubtitleOverlayTransformation.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/TextOverlay.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/TextOverlayTransformation.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/Transformation.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/TransformationPosition.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/VersionInfo.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/VideoOverlay.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/accounts/origins/OriginCreateParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/accounts/origins/OriginDeleteParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/accounts/origins/OriginGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/accounts/origins/OriginListParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/accounts/origins/OriginRequest.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/accounts/origins/OriginResponse.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/accounts/origins/OriginUpdateParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/accounts/urlendpoints/UrlEndpointCreateParams.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/accounts/urlendpoints/UrlEndpointGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/accounts/urlendpoints/UrlEndpointListParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/accounts/urlendpoints/UrlEndpointRequest.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/accounts/urlendpoints/UrlEndpointResponse.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/accounts/usage/UsageGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/accounts/usage/UsageGetResponse.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/assets/AssetListParams.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/assets/AssetListResponse.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/beta/v2/files/FileUploadParams.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api/models => models/beta/v2}/files/FileUploadResponse.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/cache/invalidation/InvalidationCreateParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/cache/invalidation/InvalidationCreateResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/cache/invalidation/InvalidationGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/cache/invalidation/InvalidationGetResponse.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/custommetadatafields/CustomMetadataField.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/custommetadatafields/CustomMetadataFieldCreateParams.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/custommetadatafields/CustomMetadataFieldListParams.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/File.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/FileCopyParams.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/FileCopyResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/FileDeleteParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/FileGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/FileMoveParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/FileMoveResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/FileRenameParams.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/FileRenameResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/FileUpdateParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/FileUpdateResponse.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/FileUploadParams.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api/models/beta/v2 => models}/files/FileUploadResponse.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/Folder.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/Metadata.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/UpdateFileRequest.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/bulk/BulkAddTagsParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/bulk/BulkAddTagsResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/bulk/BulkDeleteParams.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/bulk/BulkDeleteResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/bulk/BulkRemoveAiTagsParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/bulk/BulkRemoveAiTagsResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/bulk/BulkRemoveTagsParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/bulk/BulkRemoveTagsResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/metadata/MetadataGetFromUrlParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/metadata/MetadataGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/versions/VersionDeleteParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/versions/VersionDeleteResponse.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/versions/VersionGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/versions/VersionListParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/files/versions/VersionRestoreParams.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/folders/FolderCopyParams.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/folders/FolderCopyResponse.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/folders/FolderCreateParams.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/folders/FolderCreateResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/folders/FolderDeleteParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/folders/FolderDeleteResponse.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/folders/FolderMoveParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/folders/FolderMoveResponse.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/folders/FolderRenameParams.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/folders/FolderRenameResponse.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/folders/job/JobGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/folders/job/JobGetResponse.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/savedextensions/SavedExtensionCreateParams.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/savedextensions/SavedExtensionDeleteParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/savedextensions/SavedExtensionGetParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/savedextensions/SavedExtensionListParams.kt (97%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/savedextensions/SavedExtensionUpdateParams.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/webhooks/BaseWebhookEvent.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/webhooks/FileCreateEvent.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/webhooks/FileDeleteEvent.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/webhooks/FileUpdateEvent.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/webhooks/FileVersionCreateEvent.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/webhooks/FileVersionDeleteEvent.kt (98%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/webhooks/UnsafeUnwrapWebhookEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/webhooks/UnwrapWebhookEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/webhooks/UploadPostTransformErrorEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/webhooks/UploadPostTransformSuccessEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/webhooks/UploadPreTransformErrorEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/webhooks/UploadPreTransformSuccessEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/webhooks/VideoTransformationAcceptedEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/webhooks/VideoTransformationErrorEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/models/webhooks/VideoTransformationReadyEvent.kt (99%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/AccountServiceAsync.kt (81%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/AccountServiceAsyncImpl.kt (82%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/AssetServiceAsync.kt (91%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/AssetServiceAsyncImpl.kt (79%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/BetaServiceAsync.kt (87%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/BetaServiceAsyncImpl.kt (87%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/CacheServiceAsync.kt (87%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/CacheServiceAsyncImpl.kt (87%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/CustomMetadataFieldServiceAsync.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/CustomMetadataFieldServiceAsyncImpl.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/FileServiceAsync.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/FileServiceAsyncImpl.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/FolderServiceAsync.kt (89%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/FolderServiceAsyncImpl.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/SavedExtensionServiceAsync.kt (95%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/SavedExtensionServiceAsyncImpl.kt (89%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/WebhookServiceAsync.kt (82%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/WebhookServiceAsyncImpl.kt (82%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/accounts/OriginServiceAsync.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/accounts/OriginServiceAsyncImpl.kt (89%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/accounts/UrlEndpointServiceAsync.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/accounts/UrlEndpointServiceAsyncImpl.kt (89%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/accounts/UsageServiceAsync.kt (87%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/accounts/UsageServiceAsyncImpl.kt (79%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/beta/V2ServiceAsync.kt (87%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/beta/V2ServiceAsyncImpl.kt (86%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/beta/v2/FileServiceAsync.kt (91%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/beta/v2/FileServiceAsyncImpl.kt (79%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/cache/InvalidationServiceAsync.kt (91%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/cache/InvalidationServiceAsyncImpl.kt (83%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/files/BulkServiceAsync.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/files/BulkServiceAsyncImpl.kt (87%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/files/MetadataServiceAsync.kt (93%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/files/MetadataServiceAsyncImpl.kt (84%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/files/VersionServiceAsync.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/files/VersionServiceAsyncImpl.kt (89%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/folders/JobServiceAsync.kt (92%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/async/folders/JobServiceAsyncImpl.kt (79%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/AccountService.kt (81%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/AccountServiceImpl.kt (81%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/AssetService.kt (90%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/AssetServiceImpl.kt (77%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/BetaService.kt (87%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/BetaServiceImpl.kt (86%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/CacheService.kt (87%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/CacheServiceImpl.kt (86%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/CustomMetadataFieldService.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/CustomMetadataFieldServiceImpl.kt (87%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/FileService.kt (92%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/FileServiceImpl.kt (87%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/FolderService.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/FolderServiceImpl.kt (86%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/SavedExtensionService.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/SavedExtensionServiceImpl.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/WebhookService.kt (81%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/WebhookServiceImpl.kt (86%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/accounts/OriginService.kt (96%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/accounts/OriginServiceImpl.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/accounts/UrlEndpointService.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/accounts/UrlEndpointServiceImpl.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/accounts/UsageService.kt (86%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/accounts/UsageServiceImpl.kt (76%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/beta/V2Service.kt (86%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/beta/V2ServiceImpl.kt (85%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/beta/v2/FileService.kt (91%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/beta/v2/FileServiceImpl.kt (77%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/cache/InvalidationService.kt (91%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/cache/InvalidationServiceImpl.kt (81%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/files/BulkService.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/files/BulkServiceImpl.kt (86%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/files/MetadataService.kt (92%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/files/MetadataServiceImpl.kt (83%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/files/VersionService.kt (94%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/files/VersionServiceImpl.kt (88%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/folders/JobService.kt (91%) rename image-kit-java-core/src/main/kotlin/io/imagekit/{api => }/services/blocking/folders/JobServiceImpl.kt (77%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/core/ClientOptionsTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/core/ObjectMappersTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/core/PhantomReachableTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/core/UtilsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/core/ValuesTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/core/http/AsyncStreamResponseTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/core/http/HeadersTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/core/http/HttpRequestBodiesTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/core/http/HttpRequestTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/core/http/QueryParamsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/core/http/RetryingHttpClientTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/AiTagTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/BaseOverlayTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/CustomMetadataTest.kt (89%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/EmbeddedMetadataTest.kt (89%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/ExtensionConfigTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/ExtensionItemTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/GetImageAttributesOptionsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/ImageOverlayTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/OverlayPositionTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/OverlayTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/OverlayTimingTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/ResponsiveImageAttributesTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/SavedExtensionTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/SelectedFieldsSchemaTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/SolidColorOverlayTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/SolidColorOverlayTransformationTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/SrcOptionsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/SubtitleOverlayTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/SubtitleOverlayTransformationTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/TextOverlayTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/TextOverlayTransformationTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/TransformationTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/VersionInfoTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/VideoOverlayTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/accounts/origins/OriginCreateParamsTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/accounts/origins/OriginDeleteParamsTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/accounts/origins/OriginGetParamsTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/accounts/origins/OriginListParamsTest.kt (81%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/accounts/origins/OriginRequestTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/accounts/origins/OriginResponseTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/accounts/origins/OriginUpdateParamsTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt (90%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt (80%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/accounts/urlendpoints/UrlEndpointRequestTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/accounts/urlendpoints/UrlEndpointResponseTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/accounts/usage/UsageGetParamsTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/accounts/usage/UsageGetResponseTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/assets/AssetListParamsTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/assets/AssetListResponseTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/beta/v2/files/FileUploadParamsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/beta/v2/files/FileUploadResponseTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/cache/invalidation/InvalidationCreateParamsTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/cache/invalidation/InvalidationCreateResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/cache/invalidation/InvalidationGetParamsTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/cache/invalidation/InvalidationGetResponseTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/custommetadatafields/CustomMetadataFieldTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/FileCopyParamsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/FileCopyResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/FileDeleteParamsTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/FileGetParamsTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/FileMoveParamsTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/FileMoveResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/FileRenameParamsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/FileRenameResponseTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/FileTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/FileUpdateParamsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/FileUpdateResponseTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/FileUploadParamsTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/FileUploadResponseTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/FolderTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/MetadataTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/UpdateFileRequestTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/bulk/BulkAddTagsParamsTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/bulk/BulkAddTagsResponseTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/bulk/BulkDeleteParamsTest.kt (94%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/bulk/BulkDeleteResponseTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/bulk/BulkRemoveAiTagsParamsTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/bulk/BulkRemoveAiTagsResponseTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/bulk/BulkRemoveTagsParamsTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/bulk/BulkRemoveTagsResponseTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/metadata/MetadataGetFromUrlParamsTest.kt (86%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/metadata/MetadataGetParamsTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/versions/VersionDeleteParamsTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/versions/VersionDeleteResponseTest.kt (90%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/versions/VersionGetParamsTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/versions/VersionListParamsTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/files/versions/VersionRestoreParamsTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/folders/FolderCopyParamsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/folders/FolderCopyResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/folders/FolderCreateParamsTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/folders/FolderCreateResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/folders/FolderDeleteParamsTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/folders/FolderDeleteResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/folders/FolderMoveParamsTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/folders/FolderMoveResponseTest.kt (91%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/folders/FolderRenameParamsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/folders/FolderRenameResponseTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/folders/job/JobGetParamsTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/folders/job/JobGetResponseTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/savedextensions/SavedExtensionCreateParamsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/savedextensions/SavedExtensionDeleteParamsTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/savedextensions/SavedExtensionGetParamsTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/savedextensions/SavedExtensionListParamsTest.kt (82%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/savedextensions/SavedExtensionUpdateParamsTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/webhooks/BaseWebhookEventTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/webhooks/FileCreateEventTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/webhooks/FileDeleteEventTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/webhooks/FileUpdateEventTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/webhooks/FileVersionCreateEventTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/webhooks/FileVersionDeleteEventTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/webhooks/UnsafeUnwrapWebhookEventTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/webhooks/UnwrapWebhookEventTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/webhooks/UploadPostTransformErrorEventTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/webhooks/UploadPostTransformSuccessEventTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/webhooks/UploadPreTransformErrorEventTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/webhooks/UploadPreTransformSuccessEventTest.kt (98%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/webhooks/VideoTransformationAcceptedEventTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/webhooks/VideoTransformationErrorEventTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/models/webhooks/VideoTransformationReadyEventTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/ErrorHandlingTest.kt (99%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/ServiceParamsTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/async/AssetServiceAsyncTest.kt (86%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/async/CustomMetadataFieldServiceAsyncTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/async/FileServiceAsyncTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/async/FolderServiceAsyncTest.kt (89%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/async/SavedExtensionServiceAsyncTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/async/WebhookServiceAsyncTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/async/accounts/OriginServiceAsyncTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/async/accounts/UrlEndpointServiceAsyncTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/async/accounts/UsageServiceAsyncTest.kt (83%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/async/beta/v2/FileServiceAsyncTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/async/cache/InvalidationServiceAsyncTest.kt (88%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/async/files/BulkServiceAsyncTest.kt (89%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/async/files/MetadataServiceAsyncTest.kt (87%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/async/files/VersionServiceAsyncTest.kt (88%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/async/folders/JobServiceAsyncTest.kt (84%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/blocking/AssetServiceTest.kt (86%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/blocking/CustomMetadataFieldServiceTest.kt (95%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/blocking/FileServiceTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/blocking/FolderServiceTest.kt (89%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/blocking/SavedExtensionServiceTest.kt (92%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/blocking/WebhookServiceTest.kt (96%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/blocking/accounts/OriginServiceTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/blocking/accounts/UrlEndpointServiceTest.kt (93%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/blocking/accounts/UsageServiceTest.kt (82%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/blocking/beta/v2/FileServiceTest.kt (97%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/blocking/cache/InvalidationServiceTest.kt (86%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/blocking/files/BulkServiceTest.kt (88%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/blocking/files/MetadataServiceTest.kt (85%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/blocking/files/VersionServiceTest.kt (87%) rename image-kit-java-core/src/test/kotlin/io/imagekit/{api => }/services/blocking/folders/JobServiceTest.kt (83%) rename image-kit-java-proguard-test/src/test/kotlin/io/imagekit/{api => }/proguard/ProGuardCompatibilityTest.kt (94%) diff --git a/.stats.yml b/.stats.yml index 8624958a..6d0a83a8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 47 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-c7f578172392bde58bbb72be2a25b9e917529cd07550358c645ce155debf2418.yml openapi_spec_hash: f0d797a17b1e8e81707517700cd44b13 -config_hash: 4e6bdc90056ab9bddbeb207bd720cf53 +config_hash: da0c89d794fefcf600a4ddfc78553c2a diff --git a/README.md b/README.md index fcdc768b..ae23dbad 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit.api/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit.api/image-kit-java/0.0.1) -[![javadoc](https://javadoc.io/badge2/io.imagekit.api/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/io.imagekit.api/image-kit-java/0.0.1) +[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit/image-kit-java/0.0.1) +[![javadoc](https://javadoc.io/badge2/io.imagekit/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1) @@ -20,7 +20,7 @@ Use the Image Kit MCP Server to enable AI assistants to interact with this API, -The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit.api/image-kit-java/0.0.1). +The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1). @@ -31,14 +31,14 @@ The REST API documentation can be found on [imagekit.io](https://imagekit.io/doc ### Gradle ```kotlin -implementation("io.imagekit.api:image-kit-java:0.0.1") +implementation("io.imagekit:image-kit-java:0.0.1") ``` ### Maven ```xml - io.imagekit.api + io.imagekit image-kit-java 0.0.1 @@ -53,10 +53,10 @@ This library requires Java 8 or later. ## Usage ```java -import io.imagekit.api.client.ImageKitClient; -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; -import io.imagekit.api.models.files.FileUploadParams; -import io.imagekit.api.models.files.FileUploadResponse; +import io.imagekit.client.ImageKitClient; +import io.imagekit.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.models.files.FileUploadParams; +import io.imagekit.models.files.FileUploadResponse; import java.io.ByteArrayInputStream; // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties @@ -75,8 +75,8 @@ FileUploadResponse response = client.files().upload(params); Configure the client using system properties or environment variables: ```java -import io.imagekit.api.client.ImageKitClient; -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.client.ImageKitClient; +import io.imagekit.client.okhttp.ImageKitOkHttpClient; // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables @@ -86,8 +86,8 @@ ImageKitClient client = ImageKitOkHttpClient.fromEnv(); Or manually: ```java -import io.imagekit.api.client.ImageKitClient; -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.client.ImageKitClient; +import io.imagekit.client.okhttp.ImageKitOkHttpClient; ImageKitClient client = ImageKitOkHttpClient.builder() .privateKey("My Private Key") @@ -98,8 +98,8 @@ ImageKitClient client = ImageKitOkHttpClient.builder() Or using a combination of the two approaches: ```java -import io.imagekit.api.client.ImageKitClient; -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.client.ImageKitClient; +import io.imagekit.client.okhttp.ImageKitOkHttpClient; ImageKitClient client = ImageKitOkHttpClient.builder() // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties @@ -129,7 +129,7 @@ System properties take precedence over environment variables. To temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service: ```java -import io.imagekit.api.client.ImageKitClient; +import io.imagekit.client.ImageKitClient; ImageKitClient clientWithOptions = client.withOptions(optionsBuilder -> { optionsBuilder.baseUrl("https://example.com"); @@ -158,10 +158,10 @@ Because each class is immutable, builder modification will _never_ affect alread The default client is synchronous. To switch to asynchronous execution, call the `async()` method: ```java -import io.imagekit.api.client.ImageKitClient; -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; -import io.imagekit.api.models.files.FileUploadParams; -import io.imagekit.api.models.files.FileUploadResponse; +import io.imagekit.client.ImageKitClient; +import io.imagekit.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.models.files.FileUploadParams; +import io.imagekit.models.files.FileUploadResponse; import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; @@ -179,10 +179,10 @@ CompletableFuture response = client.async().files().upload(p Or create an asynchronous client from the beginning: ```java -import io.imagekit.api.client.ImageKitClientAsync; -import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync; -import io.imagekit.api.models.files.FileUploadParams; -import io.imagekit.api.models.files.FileUploadResponse; +import io.imagekit.client.ImageKitClientAsync; +import io.imagekit.client.okhttp.ImageKitOkHttpClientAsync; +import io.imagekit.models.files.FileUploadParams; +import io.imagekit.models.files.FileUploadResponse; import java.io.ByteArrayInputStream; import java.util.concurrent.CompletableFuture; @@ -206,8 +206,8 @@ The SDK defines methods that accept files. To upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html): ```java -import io.imagekit.api.models.files.FileUploadParams; -import io.imagekit.api.models.files.FileUploadResponse; +import io.imagekit.models.files.FileUploadParams; +import io.imagekit.models.files.FileUploadResponse; import java.nio.file.Paths; FileUploadParams params = FileUploadParams.builder() @@ -220,8 +220,8 @@ FileUploadResponse response = client.files().upload(params); Or an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html): ```java -import io.imagekit.api.models.files.FileUploadParams; -import io.imagekit.api.models.files.FileUploadResponse; +import io.imagekit.models.files.FileUploadParams; +import io.imagekit.models.files.FileUploadResponse; import java.net.URL; FileUploadParams params = FileUploadParams.builder() @@ -234,8 +234,8 @@ FileUploadResponse response = client.files().upload(params); Or a `byte[]` array: ```java -import io.imagekit.api.models.files.FileUploadParams; -import io.imagekit.api.models.files.FileUploadResponse; +import io.imagekit.models.files.FileUploadParams; +import io.imagekit.models.files.FileUploadResponse; FileUploadParams params = FileUploadParams.builder() .fileName("fileName") @@ -244,12 +244,12 @@ FileUploadParams params = FileUploadParams.builder() FileUploadResponse response = client.files().upload(params); ``` -Note that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt): +Note that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt): ```java -import io.imagekit.api.core.MultipartField; -import io.imagekit.api.models.files.FileUploadParams; -import io.imagekit.api.models.files.FileUploadResponse; +import io.imagekit.core.MultipartField; +import io.imagekit.models.files.FileUploadParams; +import io.imagekit.models.files.FileUploadResponse; import java.io.InputStream; import java.net.URL; @@ -270,10 +270,10 @@ The SDK defines methods that deserialize responses into instances of Java classe To access this data, prefix any HTTP method call on a client or service with `withRawResponse()`: ```java -import io.imagekit.api.core.http.Headers; -import io.imagekit.api.core.http.HttpResponseFor; -import io.imagekit.api.models.files.FileUploadParams; -import io.imagekit.api.models.files.FileUploadResponse; +import io.imagekit.core.http.Headers; +import io.imagekit.core.http.HttpResponseFor; +import io.imagekit.models.files.FileUploadParams; +import io.imagekit.models.files.FileUploadResponse; import java.io.ByteArrayInputStream; FileUploadParams params = FileUploadParams.builder() @@ -289,7 +289,7 @@ Headers headers = response.headers(); You can still deserialize the response into an instance of a Java class if needed: ```java -import io.imagekit.api.models.files.FileUploadResponse; +import io.imagekit.models.files.FileUploadResponse; FileUploadResponse parsedResponse = response.parse(); ``` @@ -298,26 +298,26 @@ FileUploadResponse parsedResponse = response.parse(); The SDK throws custom unchecked exception types: -- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code: +- [`ImageKitServiceException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code: - | Status | Exception | - | ------ | ------------------------------------------------------------------------------------------------------------------------------ | - | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/BadRequestException.kt) | - | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnauthorizedException.kt) | - | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/PermissionDeniedException.kt) | - | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/NotFoundException.kt) | - | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnprocessableEntityException.kt) | - | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/RateLimitException.kt) | - | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/InternalServerException.kt) | - | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnexpectedStatusCodeException.kt) | + | Status | Exception | + | ------ | -------------------------------------------------------------------------------------------------------------------------- | + | 400 | [`BadRequestException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/BadRequestException.kt) | + | 401 | [`UnauthorizedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnauthorizedException.kt) | + | 403 | [`PermissionDeniedException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/PermissionDeniedException.kt) | + | 404 | [`NotFoundException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/NotFoundException.kt) | + | 422 | [`UnprocessableEntityException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnprocessableEntityException.kt) | + | 429 | [`RateLimitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/RateLimitException.kt) | + | 5xx | [`InternalServerException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/InternalServerException.kt) | + | others | [`UnexpectedStatusCodeException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnexpectedStatusCodeException.kt) | -- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitIoException.kt): I/O networking errors. +- [`ImageKitIoException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitIoException.kt): I/O networking errors. -- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client. +- [`ImageKitRetryableException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitRetryableException.kt): Generic error indicating a failure that could be retried by the client. -- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response. +- [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response. -- [`ImageKitException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class. +- [`ImageKitException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class. ## Logging @@ -347,7 +347,7 @@ The SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON seri The SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config). -If the SDK threw an exception, but you're _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt). +If the SDK threw an exception, but you're _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt). > [!CAUTION] > We make no guarantee that the SDK works correctly when the Jackson version check is disabled. @@ -373,8 +373,8 @@ The API may also explicitly instruct the SDK to retry or not retry a request. To set a custom number of retries, configure the client using the `maxRetries` method: ```java -import io.imagekit.api.client.ImageKitClient; -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.client.ImageKitClient; +import io.imagekit.client.okhttp.ImageKitOkHttpClient; ImageKitClient client = ImageKitOkHttpClient.builder() .fromEnv() @@ -389,7 +389,7 @@ Requests time out after 1 minute by default. To set a custom timeout, configure the method call using the `timeout` method: ```java -import io.imagekit.api.models.files.FileUploadResponse; +import io.imagekit.models.files.FileUploadResponse; FileUploadResponse response = client.files().upload( params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build() @@ -399,8 +399,8 @@ FileUploadResponse response = client.files().upload( Or configure the default for all method calls at the client level: ```java -import io.imagekit.api.client.ImageKitClient; -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.client.ImageKitClient; +import io.imagekit.client.okhttp.ImageKitOkHttpClient; import java.time.Duration; ImageKitClient client = ImageKitOkHttpClient.builder() @@ -414,8 +414,8 @@ ImageKitClient client = ImageKitOkHttpClient.builder() To route requests through a proxy, configure the client using the `proxy` method: ```java -import io.imagekit.api.client.ImageKitClient; -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.client.ImageKitClient; +import io.imagekit.client.okhttp.ImageKitOkHttpClient; import java.net.InetSocketAddress; import java.net.Proxy; @@ -434,8 +434,8 @@ ImageKitClient client = ImageKitOkHttpClient.builder() To customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods: ```java -import io.imagekit.api.client.ImageKitClient; -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.client.ImageKitClient; +import io.imagekit.client.okhttp.ImageKitOkHttpClient; import java.time.Duration; ImageKitClient client = ImageKitOkHttpClient.builder() @@ -457,8 +457,8 @@ If both options are unset, OkHttp's default connection pool settings are used. To configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods: ```java -import io.imagekit.api.client.ImageKitClient; -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.client.ImageKitClient; +import io.imagekit.client.okhttp.ImageKitOkHttpClient; ImageKitClient client = ImageKitOkHttpClient.builder() .fromEnv() @@ -476,10 +476,10 @@ The SDK consists of three artifacts: - `image-kit-java-core` - Contains core SDK logic - Does not depend on [OkHttp](https://square.github.io/okhttp) - - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client + - Exposes [`ImageKitClient`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt), [`ImageKitClientAsync`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt), [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt), and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), all of which can work with any HTTP client - `image-kit-java-client-okhttp` - Depends on [OkHttp](https://square.github.io/okhttp) - - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp + - Exposes [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) and [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), which provide a way to construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) and [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), respectively, using OkHttp - `image-kit-java` - Depends on and exposes the APIs of both `image-kit-java-core` and `image-kit-java-client-okhttp` - Does not have its own logic @@ -494,16 +494,16 @@ This structure allows replacing the SDK's default HTTP client without pulling in To use a customized `OkHttpClient`: 1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core` -2. Copy `image-kit-java-client-okhttp`'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/OkHttpClient.kt) class into your code and customize it -3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client +2. Copy `image-kit-java-client-okhttp`'s [`OkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/OkHttpClient.kt) class into your code and customize it +3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your customized client ### Completely custom HTTP client To use a completely custom HTTP client: 1. Replace your [`image-kit-java` dependency](#installation) with `image-kit-java-core` -2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpClient.kt) interface -3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class +2. Write a class that implements the [`HttpClient`](image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpClient.kt) interface +3. Construct [`ImageKitClientImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt) or [`ImageKitClientAsyncImpl`](image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt), similarly to [`ImageKitOkHttpClient`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt) or [`ImageKitOkHttpClientAsync`](image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt), using your new client class ## Undocumented API functionality @@ -514,8 +514,8 @@ The SDK is typed for convenient usage of the documented API. However, it also su To set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class: ```java -import io.imagekit.api.core.JsonValue; -import io.imagekit.api.models.files.FileUploadParams; +import io.imagekit.core.JsonValue; +import io.imagekit.models.files.FileUploadParams; FileUploadParams params = FileUploadParams.builder() .putAdditionalHeader("Secret-Header", "42") @@ -529,8 +529,8 @@ These can be accessed on the built object later using the `_additionalHeaders()` To set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class: ```java -import io.imagekit.api.core.JsonValue; -import io.imagekit.api.models.files.FileUploadParams; +import io.imagekit.core.JsonValue; +import io.imagekit.models.files.FileUploadParams; FileUploadParams params = FileUploadParams.builder() .transformation(FileUploadParams.UploadTransformation.builder() @@ -541,11 +541,11 @@ FileUploadParams params = FileUploadParams.builder() These properties can be accessed on the nested built object later using the `_additionalProperties()` method. -To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt) object to its setter: +To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) object to its setter: ```java -import io.imagekit.api.core.JsonValue; -import io.imagekit.api.models.files.FileUploadParams; +import io.imagekit.core.JsonValue; +import io.imagekit.models.files.FileUploadParams; FileUploadParams params = FileUploadParams.builder() .file(JsonValue.from(42)) @@ -553,10 +553,10 @@ FileUploadParams params = FileUploadParams.builder() .build(); ``` -The most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt) is using its `from(...)` method: +The most straightforward way to create a [`JsonValue`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt) is using its `from(...)` method: ```java -import io.imagekit.api.core.JsonValue; +import io.imagekit.core.JsonValue; import java.util.List; import java.util.Map; @@ -594,11 +594,11 @@ JsonValue complexValue = JsonValue.from(Map.of( Normally a `Builder` class's `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset. -To forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt): +To forcibly omit a required parameter or property, pass [`JsonMissing`](image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt): ```java -import io.imagekit.api.core.JsonMissing; -import io.imagekit.api.models.files.FileUploadParams; +import io.imagekit.core.JsonMissing; +import io.imagekit.models.files.FileUploadParams; FileUploadParams params = FileUploadParams.builder() .fileName("fileName") @@ -611,7 +611,7 @@ FileUploadParams params = FileUploadParams.builder() To access undocumented response properties, call the `_additionalProperties()` method: ```java -import io.imagekit.api.core.JsonValue; +import io.imagekit.core.JsonValue; import java.util.Map; Map additionalProperties = client.files().upload(params)._additionalProperties(); @@ -641,7 +641,7 @@ String result = secretPropertyValue.accept(new JsonValue.Visitor<>() { To access a property's raw JSON value, which may be undocumented, call its `_` prefixed method: ```java -import io.imagekit.api.core.JsonField; +import io.imagekit.core.JsonField; import java.io.InputStream; import java.util.Optional; @@ -665,12 +665,12 @@ if (file.isMissing()) { In rare cases, the API may return a response that doesn't match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else. -By default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitInvalidDataException.kt) only if you directly access the property. +By default, the SDK will not throw an exception in this case. It will throw [`ImageKitInvalidDataException`](image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt) only if you directly access the property. If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`: ```java -import io.imagekit.api.models.files.FileUploadResponse; +import io.imagekit.models.files.FileUploadResponse; FileUploadResponse response = client.files().upload(params).validate(); ``` @@ -678,7 +678,7 @@ FileUploadResponse response = client.files().upload(params).validate(); Or configure the method call to validate the response using the `responseValidation` method: ```java -import io.imagekit.api.models.files.FileUploadResponse; +import io.imagekit.models.files.FileUploadResponse; FileUploadResponse response = client.files().upload( params, RequestOptions.builder().responseValidation(true).build() @@ -688,8 +688,8 @@ FileUploadResponse response = client.files().upload( Or configure the default for all method calls at the client level: ```java -import io.imagekit.api.client.ImageKitClient; -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.client.ImageKitClient; +import io.imagekit.client.okhttp.ImageKitOkHttpClient; ImageKitClient client = ImageKitOkHttpClient.builder() .fromEnv() diff --git a/build.gradle.kts b/build.gradle.kts index 22c72257..bac92a82 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ repositories { } allprojects { - group = "io.imagekit.api" + group = "io.imagekit" version = "0.0.1" // x-release-please-version } diff --git a/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt similarity index 96% rename from image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt rename to image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt index 249aa459..7f2325e8 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClient.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClient.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.client.okhttp +package io.imagekit.client.okhttp import com.fasterxml.jackson.databind.json.JsonMapper -import io.imagekit.api.client.ImageKitClient -import io.imagekit.api.client.ImageKitClientImpl -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.Sleeper -import io.imagekit.api.core.Timeout -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.HttpClient -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.core.jsonMapper +import io.imagekit.client.ImageKitClient +import io.imagekit.client.ImageKitClientImpl +import io.imagekit.core.ClientOptions +import io.imagekit.core.Sleeper +import io.imagekit.core.Timeout +import io.imagekit.core.http.Headers +import io.imagekit.core.http.HttpClient +import io.imagekit.core.http.QueryParams +import io.imagekit.core.jsonMapper import java.net.Proxy import java.time.Clock import java.time.Duration @@ -179,8 +179,8 @@ class ImageKitOkHttpClient private constructor() { /** * The Jackson JSON mapper to use for serializing and deserializing JSON. * - * Defaults to [io.imagekit.api.core.jsonMapper]. The default is usually sufficient and - * rarely needs to be overridden. + * Defaults to [io.imagekit.core.jsonMapper]. The default is usually sufficient and rarely + * needs to be overridden. */ fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } diff --git a/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt similarity index 96% rename from image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt rename to image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt index 5923d63a..c0af9fc1 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/ImageKitOkHttpClientAsync.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/ImageKitOkHttpClientAsync.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.client.okhttp +package io.imagekit.client.okhttp import com.fasterxml.jackson.databind.json.JsonMapper -import io.imagekit.api.client.ImageKitClientAsync -import io.imagekit.api.client.ImageKitClientAsyncImpl -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.Sleeper -import io.imagekit.api.core.Timeout -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.HttpClient -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.core.jsonMapper +import io.imagekit.client.ImageKitClientAsync +import io.imagekit.client.ImageKitClientAsyncImpl +import io.imagekit.core.ClientOptions +import io.imagekit.core.Sleeper +import io.imagekit.core.Timeout +import io.imagekit.core.http.Headers +import io.imagekit.core.http.HttpClient +import io.imagekit.core.http.QueryParams +import io.imagekit.core.jsonMapper import java.net.Proxy import java.time.Clock import java.time.Duration @@ -179,8 +179,8 @@ class ImageKitOkHttpClientAsync private constructor() { /** * The Jackson JSON mapper to use for serializing and deserializing JSON. * - * Defaults to [io.imagekit.api.core.jsonMapper]. The default is usually sufficient and - * rarely needs to be overridden. + * Defaults to [io.imagekit.core.jsonMapper]. The default is usually sufficient and rarely + * needs to be overridden. */ fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } diff --git a/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/OkHttpClient.kt b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/OkHttpClient.kt similarity index 96% rename from image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/OkHttpClient.kt rename to image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/OkHttpClient.kt index bcbd305d..4a6fed28 100644 --- a/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/api/client/okhttp/OkHttpClient.kt +++ b/image-kit-java-client-okhttp/src/main/kotlin/io/imagekit/client/okhttp/OkHttpClient.kt @@ -1,14 +1,14 @@ -package io.imagekit.api.client.okhttp - -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.Timeout -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.HttpClient -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpRequestBody -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.errors.ImageKitIoException +package io.imagekit.client.okhttp + +import io.imagekit.core.RequestOptions +import io.imagekit.core.Timeout +import io.imagekit.core.http.Headers +import io.imagekit.core.http.HttpClient +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpRequestBody +import io.imagekit.core.http.HttpResponse +import io.imagekit.errors.ImageKitIoException import java.io.IOException import java.io.InputStream import java.net.Proxy diff --git a/image-kit-java-client-okhttp/src/test/kotlin/io/imagekit/api/client/okhttp/OkHttpClientTest.kt b/image-kit-java-client-okhttp/src/test/kotlin/io/imagekit/client/okhttp/OkHttpClientTest.kt similarity index 91% rename from image-kit-java-client-okhttp/src/test/kotlin/io/imagekit/api/client/okhttp/OkHttpClientTest.kt rename to image-kit-java-client-okhttp/src/test/kotlin/io/imagekit/client/okhttp/OkHttpClientTest.kt index 1ce7e04a..f1c28fca 100644 --- a/image-kit-java-client-okhttp/src/test/kotlin/io/imagekit/api/client/okhttp/OkHttpClientTest.kt +++ b/image-kit-java-client-okhttp/src/test/kotlin/io/imagekit/client/okhttp/OkHttpClientTest.kt @@ -1,10 +1,10 @@ -package io.imagekit.api.client.okhttp +package io.imagekit.client.okhttp import com.github.tomakehurst.wiremock.client.WireMock.* import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClient.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt similarity index 85% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClient.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt index 891ec0ce..a1946c26 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClient.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClient.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.client - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.services.blocking.AccountService -import io.imagekit.api.services.blocking.AssetService -import io.imagekit.api.services.blocking.BetaService -import io.imagekit.api.services.blocking.CacheService -import io.imagekit.api.services.blocking.CustomMetadataFieldService -import io.imagekit.api.services.blocking.FileService -import io.imagekit.api.services.blocking.FolderService -import io.imagekit.api.services.blocking.SavedExtensionService -import io.imagekit.api.services.blocking.WebhookService +package io.imagekit.client + +import io.imagekit.core.ClientOptions +import io.imagekit.services.blocking.AccountService +import io.imagekit.services.blocking.AssetService +import io.imagekit.services.blocking.BetaService +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.SavedExtensionService +import io.imagekit.services.blocking.WebhookService import java.util.function.Consumer /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt similarity index 85% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt index 40d641b7..1dd949c6 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsync.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.client - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.services.async.AccountServiceAsync -import io.imagekit.api.services.async.AssetServiceAsync -import io.imagekit.api.services.async.BetaServiceAsync -import io.imagekit.api.services.async.CacheServiceAsync -import io.imagekit.api.services.async.CustomMetadataFieldServiceAsync -import io.imagekit.api.services.async.FileServiceAsync -import io.imagekit.api.services.async.FolderServiceAsync -import io.imagekit.api.services.async.SavedExtensionServiceAsync -import io.imagekit.api.services.async.WebhookServiceAsync +package io.imagekit.client + +import io.imagekit.core.ClientOptions +import io.imagekit.services.async.AccountServiceAsync +import io.imagekit.services.async.AssetServiceAsync +import io.imagekit.services.async.BetaServiceAsync +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.SavedExtensionServiceAsync +import io.imagekit.services.async.WebhookServiceAsync import java.util.function.Consumer /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt index ed596c22..7acd014c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientAsyncImpl.kt @@ -1,27 +1,27 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.client - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.getPackageVersion -import io.imagekit.api.services.async.AccountServiceAsync -import io.imagekit.api.services.async.AccountServiceAsyncImpl -import io.imagekit.api.services.async.AssetServiceAsync -import io.imagekit.api.services.async.AssetServiceAsyncImpl -import io.imagekit.api.services.async.BetaServiceAsync -import io.imagekit.api.services.async.BetaServiceAsyncImpl -import io.imagekit.api.services.async.CacheServiceAsync -import io.imagekit.api.services.async.CacheServiceAsyncImpl -import io.imagekit.api.services.async.CustomMetadataFieldServiceAsync -import io.imagekit.api.services.async.CustomMetadataFieldServiceAsyncImpl -import io.imagekit.api.services.async.FileServiceAsync -import io.imagekit.api.services.async.FileServiceAsyncImpl -import io.imagekit.api.services.async.FolderServiceAsync -import io.imagekit.api.services.async.FolderServiceAsyncImpl -import io.imagekit.api.services.async.SavedExtensionServiceAsync -import io.imagekit.api.services.async.SavedExtensionServiceAsyncImpl -import io.imagekit.api.services.async.WebhookServiceAsync -import io.imagekit.api.services.async.WebhookServiceAsyncImpl +package io.imagekit.client + +import io.imagekit.core.ClientOptions +import io.imagekit.core.getPackageVersion +import io.imagekit.services.async.AccountServiceAsync +import io.imagekit.services.async.AccountServiceAsyncImpl +import io.imagekit.services.async.AssetServiceAsync +import io.imagekit.services.async.AssetServiceAsyncImpl +import io.imagekit.services.async.BetaServiceAsync +import io.imagekit.services.async.BetaServiceAsyncImpl +import io.imagekit.services.async.CacheServiceAsync +import io.imagekit.services.async.CacheServiceAsyncImpl +import io.imagekit.services.async.CustomMetadataFieldServiceAsync +import io.imagekit.services.async.CustomMetadataFieldServiceAsyncImpl +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.SavedExtensionServiceAsync +import io.imagekit.services.async.SavedExtensionServiceAsyncImpl +import io.imagekit.services.async.WebhookServiceAsync +import io.imagekit.services.async.WebhookServiceAsyncImpl import java.util.function.Consumer class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageKitClientAsync { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt index d976c665..18683fc3 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/client/ImageKitClientImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/client/ImageKitClientImpl.kt @@ -1,27 +1,27 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.client - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.getPackageVersion -import io.imagekit.api.services.blocking.AccountService -import io.imagekit.api.services.blocking.AccountServiceImpl -import io.imagekit.api.services.blocking.AssetService -import io.imagekit.api.services.blocking.AssetServiceImpl -import io.imagekit.api.services.blocking.BetaService -import io.imagekit.api.services.blocking.BetaServiceImpl -import io.imagekit.api.services.blocking.CacheService -import io.imagekit.api.services.blocking.CacheServiceImpl -import io.imagekit.api.services.blocking.CustomMetadataFieldService -import io.imagekit.api.services.blocking.CustomMetadataFieldServiceImpl -import io.imagekit.api.services.blocking.FileService -import io.imagekit.api.services.blocking.FileServiceImpl -import io.imagekit.api.services.blocking.FolderService -import io.imagekit.api.services.blocking.FolderServiceImpl -import io.imagekit.api.services.blocking.SavedExtensionService -import io.imagekit.api.services.blocking.SavedExtensionServiceImpl -import io.imagekit.api.services.blocking.WebhookService -import io.imagekit.api.services.blocking.WebhookServiceImpl +package io.imagekit.client + +import io.imagekit.core.ClientOptions +import io.imagekit.core.getPackageVersion +import io.imagekit.services.blocking.AccountService +import io.imagekit.services.blocking.AccountServiceImpl +import io.imagekit.services.blocking.AssetService +import io.imagekit.services.blocking.AssetServiceImpl +import io.imagekit.services.blocking.BetaService +import io.imagekit.services.blocking.BetaServiceImpl +import io.imagekit.services.blocking.CacheService +import io.imagekit.services.blocking.CacheServiceImpl +import io.imagekit.services.blocking.CustomMetadataFieldService +import io.imagekit.services.blocking.CustomMetadataFieldServiceImpl +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.SavedExtensionService +import io.imagekit.services.blocking.SavedExtensionServiceImpl +import io.imagekit.services.blocking.WebhookService +import io.imagekit.services.blocking.WebhookServiceImpl import java.util.function.Consumer class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitClient { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/BaseDeserializer.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/BaseDeserializer.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/BaseDeserializer.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/BaseDeserializer.kt index 11845068..bc7683a0 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/BaseDeserializer.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/BaseDeserializer.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.core +package io.imagekit.core import com.fasterxml.jackson.core.JsonParser import com.fasterxml.jackson.core.ObjectCodec diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/BaseSerializer.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/BaseSerializer.kt similarity index 85% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/BaseSerializer.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/BaseSerializer.kt index d5fe1b5b..368a0d04 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/BaseSerializer.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/BaseSerializer.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.core +package io.imagekit.core import com.fasterxml.jackson.databind.ser.std.StdSerializer import kotlin.reflect.KClass diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Check.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/Check.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Check.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/Check.kt index 43cc495d..2897284d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Check.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/Check.kt @@ -1,6 +1,6 @@ @file:JvmName("Check") -package io.imagekit.api.core +package io.imagekit.core import com.fasterxml.jackson.core.Version import com.fasterxml.jackson.core.util.VersionUtil diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/ClientOptions.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/ClientOptions.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/ClientOptions.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/ClientOptions.kt index d0ae63ce..0cee88bc 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/ClientOptions.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/ClientOptions.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.core +package io.imagekit.core import com.fasterxml.jackson.databind.json.JsonMapper -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.HttpClient -import io.imagekit.api.core.http.PhantomReachableClosingHttpClient -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.core.http.RetryingHttpClient +import io.imagekit.core.http.Headers +import io.imagekit.core.http.HttpClient +import io.imagekit.core.http.PhantomReachableClosingHttpClient +import io.imagekit.core.http.QueryParams +import io.imagekit.core.http.RetryingHttpClient import java.time.Clock import java.time.Duration import java.util.Base64 @@ -37,8 +37,8 @@ private constructor( /** * The Jackson JSON mapper to use for serializing and deserializing JSON. * - * Defaults to [io.imagekit.api.core.jsonMapper]. The default is usually sufficient and rarely - * needs to be overridden. + * Defaults to [io.imagekit.core.jsonMapper]. The default is usually sufficient and rarely needs + * to be overridden. */ @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, /** @@ -219,8 +219,8 @@ private constructor( /** * The Jackson JSON mapper to use for serializing and deserializing JSON. * - * Defaults to [io.imagekit.api.core.jsonMapper]. The default is usually sufficient and - * rarely needs to be overridden. + * Defaults to [io.imagekit.core.jsonMapper]. The default is usually sufficient and rarely + * needs to be overridden. */ fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/DefaultSleeper.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/DefaultSleeper.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/DefaultSleeper.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/DefaultSleeper.kt index 37341444..983e189d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/DefaultSleeper.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/DefaultSleeper.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.core +package io.imagekit.core import java.time.Duration import java.util.Timer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/ObjectMappers.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/ObjectMappers.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/ObjectMappers.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/ObjectMappers.kt index 5fa7f285..8c7bf11c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/ObjectMappers.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/ObjectMappers.kt @@ -1,6 +1,6 @@ @file:JvmName("ObjectMappers") -package io.imagekit.api.core +package io.imagekit.core import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.core.JsonGenerator diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Params.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/Params.kt similarity index 77% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Params.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/Params.kt index 43fed708..a134db3d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Params.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/Params.kt @@ -1,7 +1,7 @@ -package io.imagekit.api.core +package io.imagekit.core -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams +import io.imagekit.core.http.Headers +import io.imagekit.core.http.QueryParams /** An interface representing parameters passed to a service method. */ interface Params { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PhantomReachable.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/PhantomReachable.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PhantomReachable.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/PhantomReachable.kt index 3a4fb11a..93214fa5 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PhantomReachable.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/PhantomReachable.kt @@ -1,8 +1,8 @@ @file:JvmName("PhantomReachable") -package io.imagekit.api.core +package io.imagekit.core -import io.imagekit.api.errors.ImageKitException +import io.imagekit.errors.ImageKitException import java.lang.reflect.InvocationTargetException /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PhantomReachableExecutorService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/PhantomReachableExecutorService.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PhantomReachableExecutorService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/PhantomReachableExecutorService.kt index fd0be25c..dbcf1100 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PhantomReachableExecutorService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/PhantomReachableExecutorService.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.core +package io.imagekit.core import java.util.concurrent.Callable import java.util.concurrent.ExecutorService diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PhantomReachableSleeper.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/PhantomReachableSleeper.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PhantomReachableSleeper.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/PhantomReachableSleeper.kt index 9da2c352..59c6f0ab 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PhantomReachableSleeper.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/PhantomReachableSleeper.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.core +package io.imagekit.core import java.time.Duration import java.util.concurrent.CompletableFuture diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PrepareRequest.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/PrepareRequest.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PrepareRequest.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/PrepareRequest.kt index ead8466f..672769f0 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/PrepareRequest.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/PrepareRequest.kt @@ -1,8 +1,8 @@ @file:JvmName("PrepareRequest") -package io.imagekit.api.core +package io.imagekit.core -import io.imagekit.api.core.http.HttpRequest +import io.imagekit.core.http.HttpRequest import java.util.concurrent.CompletableFuture @JvmSynthetic diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Properties.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/Properties.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Properties.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/Properties.kt index f5e46a07..be7a3360 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Properties.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/Properties.kt @@ -1,8 +1,8 @@ @file:JvmName("Properties") -package io.imagekit.api.core +package io.imagekit.core -import io.imagekit.api.client.ImageKitClient +import io.imagekit.client.ImageKitClient fun getOsArch(): String { val osArch = System.getProperty("os.arch") diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/RequestOptions.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/RequestOptions.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/RequestOptions.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/RequestOptions.kt index 4dbbec22..ec271554 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/RequestOptions.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/RequestOptions.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.core +package io.imagekit.core import java.time.Duration diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Sleeper.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/Sleeper.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Sleeper.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/Sleeper.kt index bc448c25..a542c006 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Sleeper.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/Sleeper.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.core +package io.imagekit.core import java.time.Duration import java.util.concurrent.CompletableFuture diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Timeout.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/Timeout.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Timeout.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/Timeout.kt index 7555e325..6e02470a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Timeout.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/Timeout.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.core +package io.imagekit.core import java.time.Duration import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/UnwrapWebhookParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/UnwrapWebhookParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/UnwrapWebhookParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/UnwrapWebhookParams.kt index 4a287ab7..ab260302 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/UnwrapWebhookParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/UnwrapWebhookParams.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.core +package io.imagekit.core -import io.imagekit.api.core.http.Headers +import io.imagekit.core.http.Headers import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Utils.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/Utils.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Utils.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/Utils.kt index 4eab8308..a847bd3c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Utils.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/Utils.kt @@ -1,8 +1,8 @@ @file:JvmName("Utils") -package io.imagekit.api.core +package io.imagekit.core -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.SortedMap import java.util.concurrent.CompletableFuture diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt index 5711a914..317076fc 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/Values.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/Values.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.core +package io.imagekit.core import com.fasterxml.jackson.annotation.JacksonAnnotationsInside import com.fasterxml.jackson.annotation.JsonCreator @@ -24,7 +24,7 @@ import com.fasterxml.jackson.databind.node.JsonNodeType.OBJECT import com.fasterxml.jackson.databind.node.JsonNodeType.POJO import com.fasterxml.jackson.databind.node.JsonNodeType.STRING import com.fasterxml.jackson.databind.ser.std.NullSerializer -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.errors.ImageKitInvalidDataException import java.io.InputStream import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/EmptyHandler.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/handlers/EmptyHandler.kt similarity index 62% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/EmptyHandler.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/handlers/EmptyHandler.kt index 775d5bf5..3b2e5b5a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/EmptyHandler.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/handlers/EmptyHandler.kt @@ -1,9 +1,9 @@ @file:JvmName("EmptyHandler") -package io.imagekit.api.core.handlers +package io.imagekit.core.handlers -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler @JvmSynthetic internal fun emptyHandler(): Handler = EmptyHandlerInternal diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/ErrorHandler.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/handlers/ErrorHandler.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/ErrorHandler.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/handlers/ErrorHandler.kt index a48b2e53..fc880fcd 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/ErrorHandler.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/handlers/ErrorHandler.kt @@ -2,21 +2,21 @@ @file:JvmName("ErrorHandler") -package io.imagekit.api.core.handlers +package io.imagekit.core.handlers import com.fasterxml.jackson.databind.json.JsonMapper -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.errors.BadRequestException -import io.imagekit.api.errors.InternalServerException -import io.imagekit.api.errors.NotFoundException -import io.imagekit.api.errors.PermissionDeniedException -import io.imagekit.api.errors.RateLimitException -import io.imagekit.api.errors.UnauthorizedException -import io.imagekit.api.errors.UnexpectedStatusCodeException -import io.imagekit.api.errors.UnprocessableEntityException +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.errors.BadRequestException +import io.imagekit.errors.InternalServerException +import io.imagekit.errors.NotFoundException +import io.imagekit.errors.PermissionDeniedException +import io.imagekit.errors.RateLimitException +import io.imagekit.errors.UnauthorizedException +import io.imagekit.errors.UnexpectedStatusCodeException +import io.imagekit.errors.UnprocessableEntityException @JvmSynthetic internal fun errorBodyHandler(jsonMapper: JsonMapper): Handler { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/JsonHandler.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/handlers/JsonHandler.kt similarity index 73% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/JsonHandler.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/handlers/JsonHandler.kt index 20590773..52d622e9 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/JsonHandler.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/handlers/JsonHandler.kt @@ -1,12 +1,12 @@ @file:JvmName("JsonHandler") -package io.imagekit.api.core.handlers +package io.imagekit.core.handlers import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.errors.ImageKitInvalidDataException @JvmSynthetic internal inline fun jsonHandler(jsonMapper: JsonMapper): Handler = diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/StringHandler.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/handlers/StringHandler.kt similarity index 68% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/StringHandler.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/handlers/StringHandler.kt index a31433dd..ccb4c006 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/handlers/StringHandler.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/handlers/StringHandler.kt @@ -1,9 +1,9 @@ @file:JvmName("StringHandler") -package io.imagekit.api.core.handlers +package io.imagekit.core.handlers -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler @JvmSynthetic internal fun stringHandler(): Handler = StringHandlerInternal diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/AsyncStreamResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/AsyncStreamResponse.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/AsyncStreamResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/http/AsyncStreamResponse.kt index 7231f80d..6ebe7345 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/AsyncStreamResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/AsyncStreamResponse.kt @@ -1,6 +1,6 @@ -package io.imagekit.api.core.http +package io.imagekit.core.http -import io.imagekit.api.core.http.AsyncStreamResponse.Handler +import io.imagekit.core.http.AsyncStreamResponse.Handler import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/Headers.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/Headers.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/Headers.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/http/Headers.kt index 5b14b8e9..8060745d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/Headers.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/Headers.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.core.http - -import io.imagekit.api.core.JsonArray -import io.imagekit.api.core.JsonBoolean -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonNull -import io.imagekit.api.core.JsonNumber -import io.imagekit.api.core.JsonObject -import io.imagekit.api.core.JsonString -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.toImmutable +package io.imagekit.core.http + +import io.imagekit.core.JsonArray +import io.imagekit.core.JsonBoolean +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonNull +import io.imagekit.core.JsonNumber +import io.imagekit.core.JsonObject +import io.imagekit.core.JsonString +import io.imagekit.core.JsonValue +import io.imagekit.core.toImmutable import java.util.TreeMap class Headers diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpClient.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpClient.kt similarity index 90% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpClient.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpClient.kt index cf9c1a37..bfe0b40d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpClient.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpClient.kt @@ -1,6 +1,6 @@ -package io.imagekit.api.core.http +package io.imagekit.core.http -import io.imagekit.api.core.RequestOptions +import io.imagekit.core.RequestOptions import java.lang.AutoCloseable import java.util.concurrent.CompletableFuture diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpMethod.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpMethod.kt similarity index 78% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpMethod.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpMethod.kt index 303e7791..f223d458 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpMethod.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpMethod.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.core.http +package io.imagekit.core.http enum class HttpMethod { GET, diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpRequest.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpRequest.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpRequest.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpRequest.kt index c85c3149..2b1dfc60 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpRequest.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpRequest.kt @@ -1,7 +1,7 @@ -package io.imagekit.api.core.http +package io.imagekit.core.http -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.toImmutable +import io.imagekit.core.checkRequired +import io.imagekit.core.toImmutable import java.net.URLEncoder class HttpRequest diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpRequestBodies.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpRequestBodies.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpRequestBodies.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpRequestBodies.kt index 0457e4a0..cb3d6a93 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpRequestBodies.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpRequestBodies.kt @@ -2,14 +2,14 @@ @file:JvmName("HttpRequestBodies") -package io.imagekit.api.core.http +package io.imagekit.core.http import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.databind.node.JsonNodeType -import io.imagekit.api.core.MultipartField -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.MultipartField +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.io.ByteArrayInputStream import java.io.InputStream import java.io.OutputStream diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpRequestBody.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpRequestBody.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpRequestBody.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpRequestBody.kt index f4d018cb..9e5d3a32 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpRequestBody.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpRequestBody.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.core.http +package io.imagekit.core.http import java.io.OutputStream import java.lang.AutoCloseable diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpResponse.kt similarity index 92% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpResponse.kt index ee1ce039..c64e65b3 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.core.http +package io.imagekit.core.http import java.io.InputStream diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpResponseFor.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpResponseFor.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpResponseFor.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpResponseFor.kt index e1d7058f..0217eda1 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/HttpResponseFor.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/HttpResponseFor.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.core.http +package io.imagekit.core.http import java.io.InputStream diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/PhantomReachableClosingAsyncStreamResponse.kt similarity index 92% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/http/PhantomReachableClosingAsyncStreamResponse.kt index 17fd9091..a82b5c53 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/PhantomReachableClosingAsyncStreamResponse.kt @@ -1,7 +1,7 @@ -package io.imagekit.api.core.http +package io.imagekit.core.http -import io.imagekit.api.core.closeWhenPhantomReachable -import io.imagekit.api.core.http.AsyncStreamResponse.Handler +import io.imagekit.core.closeWhenPhantomReachable +import io.imagekit.core.http.AsyncStreamResponse.Handler import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/PhantomReachableClosingHttpClient.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/PhantomReachableClosingHttpClient.kt similarity index 85% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/PhantomReachableClosingHttpClient.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/http/PhantomReachableClosingHttpClient.kt index d0fc712b..126c202e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/PhantomReachableClosingHttpClient.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/PhantomReachableClosingHttpClient.kt @@ -1,7 +1,7 @@ -package io.imagekit.api.core.http +package io.imagekit.core.http -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.closeWhenPhantomReachable +import io.imagekit.core.RequestOptions +import io.imagekit.core.closeWhenPhantomReachable import java.util.concurrent.CompletableFuture /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/PhantomReachableClosingStreamResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/PhantomReachableClosingStreamResponse.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/PhantomReachableClosingStreamResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/http/PhantomReachableClosingStreamResponse.kt index 20fdf928..91602fc6 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/PhantomReachableClosingStreamResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/PhantomReachableClosingStreamResponse.kt @@ -1,6 +1,6 @@ -package io.imagekit.api.core.http +package io.imagekit.core.http -import io.imagekit.api.core.closeWhenPhantomReachable +import io.imagekit.core.closeWhenPhantomReachable import java.util.stream.Stream /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/QueryParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/QueryParams.kt similarity index 90% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/QueryParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/http/QueryParams.kt index 2ca231d5..e23bda1d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/QueryParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/QueryParams.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.core.http - -import io.imagekit.api.core.JsonArray -import io.imagekit.api.core.JsonBoolean -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonNull -import io.imagekit.api.core.JsonNumber -import io.imagekit.api.core.JsonObject -import io.imagekit.api.core.JsonString -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.toImmutable +package io.imagekit.core.http + +import io.imagekit.core.JsonArray +import io.imagekit.core.JsonBoolean +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonNull +import io.imagekit.core.JsonNumber +import io.imagekit.core.JsonObject +import io.imagekit.core.JsonString +import io.imagekit.core.JsonValue +import io.imagekit.core.toImmutable class QueryParams private constructor( diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/RetryingHttpClient.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/RetryingHttpClient.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/RetryingHttpClient.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/http/RetryingHttpClient.kt index 78456b46..446b760e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/RetryingHttpClient.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/RetryingHttpClient.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.core.http - -import io.imagekit.api.core.DefaultSleeper -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.Sleeper -import io.imagekit.api.core.checkRequired -import io.imagekit.api.errors.ImageKitIoException -import io.imagekit.api.errors.ImageKitRetryableException +package io.imagekit.core.http + +import io.imagekit.core.DefaultSleeper +import io.imagekit.core.RequestOptions +import io.imagekit.core.Sleeper +import io.imagekit.core.checkRequired +import io.imagekit.errors.ImageKitIoException +import io.imagekit.errors.ImageKitRetryableException import java.io.IOException import java.time.Clock import java.time.Duration diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/StreamResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/StreamResponse.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/StreamResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/core/http/StreamResponse.kt index 9eb3d797..6b1d1276 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/core/http/StreamResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/core/http/StreamResponse.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.core.http +package io.imagekit.core.http import java.util.stream.Stream diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/BadRequestException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/BadRequestException.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/BadRequestException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/errors/BadRequestException.kt index fe88342e..a2d14b65 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/BadRequestException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/BadRequestException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.errors +package io.imagekit.errors -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers +import io.imagekit.core.JsonValue +import io.imagekit.core.checkRequired +import io.imagekit.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitException.kt similarity index 82% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitException.kt index 154209c8..ed1ef88d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitException.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.errors +package io.imagekit.errors open class ImageKitException @JvmOverloads diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitInvalidDataException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt similarity index 82% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitInvalidDataException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt index bfb165d7..db2f6219 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitInvalidDataException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitInvalidDataException.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.errors +package io.imagekit.errors class ImageKitInvalidDataException @JvmOverloads diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitIoException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitIoException.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitIoException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitIoException.kt index adeb3734..47f8d0da 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitIoException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitIoException.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.errors +package io.imagekit.errors class ImageKitIoException @JvmOverloads diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitRetryableException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitRetryableException.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitRetryableException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitRetryableException.kt index 87876047..ad2f14ef 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitRetryableException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitRetryableException.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.errors +package io.imagekit.errors /** * Exception that indicates a transient error that can be retried. diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitServiceException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitServiceException.kt similarity index 74% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitServiceException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitServiceException.kt index c9a01f2c..07d0d49a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitServiceException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitServiceException.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.errors +package io.imagekit.errors -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.http.Headers +import io.imagekit.core.JsonValue +import io.imagekit.core.http.Headers abstract class ImageKitServiceException protected constructor(message: String, cause: Throwable? = null) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitWebhookException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitWebhookException.kt similarity index 82% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitWebhookException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitWebhookException.kt index b0dd35a0..51adb4d7 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/ImageKitWebhookException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/ImageKitWebhookException.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.errors +package io.imagekit.errors class ImageKitWebhookException @JvmOverloads diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/InternalServerException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/InternalServerException.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/InternalServerException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/errors/InternalServerException.kt index e549eba2..a121ff83 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/InternalServerException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/InternalServerException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.errors +package io.imagekit.errors -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers +import io.imagekit.core.JsonValue +import io.imagekit.core.checkRequired +import io.imagekit.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/NotFoundException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/NotFoundException.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/NotFoundException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/errors/NotFoundException.kt index ab310ae6..41721640 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/NotFoundException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/NotFoundException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.errors +package io.imagekit.errors -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers +import io.imagekit.core.JsonValue +import io.imagekit.core.checkRequired +import io.imagekit.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/PermissionDeniedException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/PermissionDeniedException.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/PermissionDeniedException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/errors/PermissionDeniedException.kt index 1cccf75c..6d1e3e35 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/PermissionDeniedException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/PermissionDeniedException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.errors +package io.imagekit.errors -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers +import io.imagekit.core.JsonValue +import io.imagekit.core.checkRequired +import io.imagekit.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/RateLimitException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/RateLimitException.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/RateLimitException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/errors/RateLimitException.kt index 56d017e3..5f369cf4 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/RateLimitException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/RateLimitException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.errors +package io.imagekit.errors -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers +import io.imagekit.core.JsonValue +import io.imagekit.core.checkRequired +import io.imagekit.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnauthorizedException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnauthorizedException.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnauthorizedException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnauthorizedException.kt index 3881bcee..13bbfbc6 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnauthorizedException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnauthorizedException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.errors +package io.imagekit.errors -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers +import io.imagekit.core.JsonValue +import io.imagekit.core.checkRequired +import io.imagekit.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnexpectedStatusCodeException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnexpectedStatusCodeException.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnexpectedStatusCodeException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnexpectedStatusCodeException.kt index 8be813dc..9bc1ddf3 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnexpectedStatusCodeException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnexpectedStatusCodeException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.errors +package io.imagekit.errors -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers +import io.imagekit.core.JsonValue +import io.imagekit.core.checkRequired +import io.imagekit.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnprocessableEntityException.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnprocessableEntityException.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnprocessableEntityException.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnprocessableEntityException.kt index 3283d359..61554585 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/errors/UnprocessableEntityException.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/errors/UnprocessableEntityException.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.errors +package io.imagekit.errors -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers +import io.imagekit.core.JsonValue +import io.imagekit.core.checkRequired +import io.imagekit.core.http.Headers import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/AiTag.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/AiTag.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/AiTag.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/AiTag.kt index 73274625..7bbe153f 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/AiTag.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/AiTag.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/BaseOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/BaseOverlay.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/BaseOverlay.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/BaseOverlay.kt index 0b7f2a8b..6204419e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/BaseOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/BaseOverlay.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +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.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/CustomMetadata.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/CustomMetadata.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/CustomMetadata.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/CustomMetadata.kt index ea53a38d..69181dc1 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/CustomMetadata.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/CustomMetadata.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Objects /** A key-value data associated with the asset. */ diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/EmbeddedMetadata.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/EmbeddedMetadata.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/EmbeddedMetadata.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/EmbeddedMetadata.kt index 85782a77..9ff9cf92 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/EmbeddedMetadata.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/EmbeddedMetadata.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Objects /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ExtensionConfig.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/ExtensionConfig.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ExtensionConfig.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/ExtensionConfig.kt index 799e0b40..98a263ac 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ExtensionConfig.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/ExtensionConfig.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,19 +13,19 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.BaseDeserializer -import io.imagekit.api.core.BaseSerializer -import io.imagekit.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.allMaxBy -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.getOrThrow -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.BaseDeserializer +import io.imagekit.core.BaseSerializer +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.allMaxBy +import io.imagekit.core.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.getOrThrow +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ExtensionItem.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/ExtensionItem.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ExtensionItem.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/ExtensionItem.kt index 57d777ec..263cb754 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ExtensionItem.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/ExtensionItem.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,19 +13,19 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.BaseDeserializer -import io.imagekit.api.core.BaseSerializer -import io.imagekit.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.allMaxBy -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.getOrThrow -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.BaseDeserializer +import io.imagekit.core.BaseSerializer +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.allMaxBy +import io.imagekit.core.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.getOrThrow +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/GetImageAttributesOptions.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/GetImageAttributesOptions.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/GetImageAttributesOptions.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/GetImageAttributesOptions.kt index b6bcbf14..713b8faa 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/GetImageAttributesOptions.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/GetImageAttributesOptions.kt @@ -1,19 +1,19 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ImageOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/ImageOverlay.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ImageOverlay.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/ImageOverlay.kt index 99582dbf..e0c858a3 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ImageOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/ImageOverlay.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +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.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/Overlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/Overlay.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/Overlay.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/Overlay.kt index 84a17378..4032d5e3 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/Overlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/Overlay.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -9,11 +9,11 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.BaseDeserializer -import io.imagekit.api.core.BaseSerializer -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.getOrThrow -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.BaseDeserializer +import io.imagekit.core.BaseSerializer +import io.imagekit.core.JsonValue +import io.imagekit.core.getOrThrow +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/OverlayPosition.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/OverlayPosition.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/OverlayPosition.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/OverlayPosition.kt index 953f6e46..56e22284 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/OverlayPosition.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/OverlayPosition.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,16 +13,16 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.BaseDeserializer -import io.imagekit.api.core.BaseSerializer -import io.imagekit.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.allMaxBy -import io.imagekit.api.core.getOrThrow -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.BaseDeserializer +import io.imagekit.core.BaseSerializer +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.allMaxBy +import io.imagekit.core.getOrThrow +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/OverlayTiming.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/OverlayTiming.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/OverlayTiming.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/OverlayTiming.kt index 473b0c44..9ba19767 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/OverlayTiming.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/OverlayTiming.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,15 +13,15 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.BaseDeserializer -import io.imagekit.api.core.BaseSerializer -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.allMaxBy -import io.imagekit.api.core.getOrThrow -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.BaseDeserializer +import io.imagekit.core.BaseSerializer +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.allMaxBy +import io.imagekit.core.getOrThrow +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ResponsiveImageAttributes.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/ResponsiveImageAttributes.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ResponsiveImageAttributes.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/ResponsiveImageAttributes.kt index 8651431e..f9420a46 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/ResponsiveImageAttributes.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/ResponsiveImageAttributes.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkRequired +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SavedExtension.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SavedExtension.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SavedExtension.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/SavedExtension.kt index 6e8748c5..5e81cbca 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SavedExtension.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SavedExtension.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SelectedFieldsSchema.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SelectedFieldsSchema.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SelectedFieldsSchema.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/SelectedFieldsSchema.kt index 552dadf7..7baa61a9 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SelectedFieldsSchema.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SelectedFieldsSchema.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Objects /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SolidColorOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SolidColorOverlay.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SolidColorOverlay.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/SolidColorOverlay.kt index e9758fae..882268a7 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SolidColorOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SolidColorOverlay.kt @@ -1,19 +1,19 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SolidColorOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SolidColorOverlayTransformation.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SolidColorOverlayTransformation.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/SolidColorOverlayTransformation.kt index 90cdda47..38657c66 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SolidColorOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SolidColorOverlayTransformation.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,15 +13,15 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.BaseDeserializer -import io.imagekit.api.core.BaseSerializer -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.allMaxBy -import io.imagekit.api.core.getOrThrow -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.BaseDeserializer +import io.imagekit.core.BaseSerializer +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.allMaxBy +import io.imagekit.core.getOrThrow +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SrcOptions.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SrcOptions.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SrcOptions.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/SrcOptions.kt index 27ec9d42..08135372 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SrcOptions.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SrcOptions.kt @@ -1,19 +1,19 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/StreamingResolution.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/StreamingResolution.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/StreamingResolution.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/StreamingResolution.kt index 207b6799..e179c5fe 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/StreamingResolution.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/StreamingResolution.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.api.core.Enum -import io.imagekit.api.core.JsonField -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.Enum +import io.imagekit.core.JsonField +import io.imagekit.errors.ImageKitInvalidDataException /** * Available streaming resolutions for diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SubtitleOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SubtitleOverlay.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SubtitleOverlay.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/SubtitleOverlay.kt index ed428531..d6248053 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SubtitleOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SubtitleOverlay.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +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.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SubtitleOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SubtitleOverlayTransformation.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SubtitleOverlayTransformation.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/SubtitleOverlayTransformation.kt index 5503e8f7..b3969f17 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/SubtitleOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/SubtitleOverlayTransformation.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +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.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/TextOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/TextOverlay.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/TextOverlay.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/TextOverlay.kt index 6dea0fd0..9fcccac3 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/TextOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/TextOverlay.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +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.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/TextOverlayTransformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/TextOverlayTransformation.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/TextOverlayTransformation.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/TextOverlayTransformation.kt index 6f2e8ca5..a1c3479a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/TextOverlayTransformation.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/TextOverlayTransformation.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,16 +13,16 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.BaseDeserializer -import io.imagekit.api.core.BaseSerializer -import io.imagekit.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.allMaxBy -import io.imagekit.api.core.getOrThrow -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.BaseDeserializer +import io.imagekit.core.BaseSerializer +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.allMaxBy +import io.imagekit.core.getOrThrow +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/Transformation.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/Transformation.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/Transformation.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/Transformation.kt index 1eb86fe1..d726a08e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/Transformation.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/Transformation.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,18 +13,18 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.BaseDeserializer -import io.imagekit.api.core.BaseSerializer -import io.imagekit.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.allMaxBy -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.getOrThrow -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.BaseDeserializer +import io.imagekit.core.BaseSerializer +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.allMaxBy +import io.imagekit.core.checkKnown +import io.imagekit.core.getOrThrow +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/TransformationPosition.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/TransformationPosition.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/TransformationPosition.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/TransformationPosition.kt index 43212e10..09e81abc 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/TransformationPosition.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/TransformationPosition.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.api.core.Enum -import io.imagekit.api.core.JsonField -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.Enum +import io.imagekit.core.JsonField +import io.imagekit.errors.ImageKitInvalidDataException /** * By default, the transformation string is added as a query parameter in the URL, e.g., diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/VersionInfo.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/VersionInfo.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/VersionInfo.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/VersionInfo.kt index a6b92f97..b2207a64 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/VersionInfo.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/VersionInfo.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/VideoOverlay.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/VideoOverlay.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/VideoOverlay.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/VideoOverlay.kt index d598b1f5..db0a28b5 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/VideoOverlay.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/VideoOverlay.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +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.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/origins/OriginCreateParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginCreateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/origins/OriginCreateParams.kt index 1e09dbf1..3fa5e1f4 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/origins/OriginCreateParams.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.origins +package io.imagekit.models.accounts.origins -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams +import io.imagekit.core.Params +import io.imagekit.core.checkRequired +import io.imagekit.core.http.Headers +import io.imagekit.core.http.QueryParams import java.util.Objects /** **Note:** This API is currently in beta. Creates a new origin and returns the origin object. */ diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/origins/OriginDeleteParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/origins/OriginDeleteParams.kt index eebfc5d3..eda0a94c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/origins/OriginDeleteParams.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.origins +package io.imagekit.models.accounts.origins -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.core.toImmutable +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/origins/OriginGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/origins/OriginGetParams.kt index 0e22d779..8b920bf4 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/origins/OriginGetParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.origins +package io.imagekit.models.accounts.origins -import io.imagekit.api.core.Params -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginListParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/origins/OriginListParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginListParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/origins/OriginListParams.kt index f1823b0c..78af32cf 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginListParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/origins/OriginListParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.origins +package io.imagekit.models.accounts.origins -import io.imagekit.api.core.Params -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams +import io.imagekit.core.Params +import io.imagekit.core.http.Headers +import io.imagekit.core.http.QueryParams import java.util.Objects /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginRequest.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/origins/OriginRequest.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginRequest.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/origins/OriginRequest.kt index 9619119f..3d43ec9b 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginRequest.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/origins/OriginRequest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.origins +package io.imagekit.models.accounts.origins import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,15 +13,15 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.BaseDeserializer -import io.imagekit.api.core.BaseSerializer -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.getOrThrow -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.BaseDeserializer +import io.imagekit.core.BaseSerializer +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.core.getOrThrow +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/origins/OriginResponse.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/origins/OriginResponse.kt index 9e8eeb85..4a70feb2 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/origins/OriginResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.origins +package io.imagekit.models.accounts.origins import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,15 +13,15 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.BaseDeserializer -import io.imagekit.api.core.BaseSerializer -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.getOrThrow -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.BaseDeserializer +import io.imagekit.core.BaseSerializer +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.core.getOrThrow +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/origins/OriginUpdateParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginUpdateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/origins/OriginUpdateParams.kt index 98ed8632..950f65ba 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/origins/OriginUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/origins/OriginUpdateParams.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.origins +package io.imagekit.models.accounts.origins -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams +import io.imagekit.core.Params +import io.imagekit.core.checkRequired +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointCreateParams.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointCreateParams.kt index 21798404..16ae0606 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointCreateParams.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.urlendpoints +package io.imagekit.models.accounts.urlendpoints -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams +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 java.util.Objects /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt index 873cc944..86c83a7c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointDeleteParams.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.urlendpoints +package io.imagekit.models.accounts.urlendpoints -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.core.toImmutable +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointGetParams.kt index 6bbcefed..4dcee8cc 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointGetParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.urlendpoints +package io.imagekit.models.accounts.urlendpoints -import io.imagekit.api.core.Params -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointListParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointListParams.kt index 963474ea..2c0f2f90 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointListParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.urlendpoints +package io.imagekit.models.accounts.urlendpoints -import io.imagekit.api.core.Params -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams +import io.imagekit.core.Params +import io.imagekit.core.http.Headers +import io.imagekit.core.http.QueryParams import java.util.Objects /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequest.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointRequest.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequest.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointRequest.kt index 18dd5d20..e9d2c244 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequest.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointRequest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.urlendpoints +package io.imagekit.models.accounts.urlendpoints import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,17 +13,17 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.BaseDeserializer -import io.imagekit.api.core.BaseSerializer -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.getOrThrow -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.BaseDeserializer +import io.imagekit.core.BaseSerializer +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.getOrThrow +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointResponse.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointResponse.kt index 4c1e4146..b0cf304a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.urlendpoints +package io.imagekit.models.accounts.urlendpoints import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,17 +13,17 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.BaseDeserializer -import io.imagekit.api.core.BaseSerializer -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.getOrThrow -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.BaseDeserializer +import io.imagekit.core.BaseSerializer +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.getOrThrow +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt index e59831b1..1c57435f 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointUpdateParams.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.urlendpoints +package io.imagekit.models.accounts.urlendpoints -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams +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 java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/usage/UsageGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/usage/UsageGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/usage/UsageGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/usage/UsageGetParams.kt index e014eaca..a4b76c84 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/usage/UsageGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/usage/UsageGetParams.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.usage +package io.imagekit.models.accounts.usage -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams +import io.imagekit.core.Params +import io.imagekit.core.checkRequired +import io.imagekit.core.http.Headers +import io.imagekit.core.http.QueryParams import java.time.LocalDate import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/usage/UsageGetResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/usage/UsageGetResponse.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/usage/UsageGetResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/usage/UsageGetResponse.kt index 79a32f9b..46b510fc 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/accounts/usage/UsageGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/accounts/usage/UsageGetResponse.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.usage +package io.imagekit.models.accounts.usage 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/assets/AssetListParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/assets/AssetListParams.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/assets/AssetListParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/assets/AssetListParams.kt index a03de4d5..d8def1cd 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/assets/AssetListParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/assets/AssetListParams.kt @@ -1,14 +1,14 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.assets +package io.imagekit.models.assets import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.api.core.Enum -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.Params -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.Enum +import io.imagekit.core.JsonField +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.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/assets/AssetListResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/assets/AssetListResponse.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/assets/AssetListResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/assets/AssetListResponse.kt index 8c5cbcb4..e98dbaeb 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/assets/AssetListResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/assets/AssetListResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.assets +package io.imagekit.models.assets import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -9,13 +9,13 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.BaseDeserializer -import io.imagekit.api.core.BaseSerializer -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.getOrThrow -import io.imagekit.api.errors.ImageKitInvalidDataException -import io.imagekit.api.models.files.File -import io.imagekit.api.models.files.Folder +import io.imagekit.core.BaseDeserializer +import io.imagekit.core.BaseSerializer +import io.imagekit.core.JsonValue +import io.imagekit.core.getOrThrow +import io.imagekit.errors.ImageKitInvalidDataException +import io.imagekit.models.files.File +import io.imagekit.models.files.Folder import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/beta/v2/files/FileUploadParams.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/beta/v2/files/FileUploadParams.kt index 81b85cf1..40b37deb 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/beta/v2/files/FileUploadParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.beta.v2.files +package io.imagekit.models.beta.v2.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -9,21 +9,21 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonSerialize -import io.imagekit.api.core.BaseSerializer -import io.imagekit.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.MultipartField -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.getOrThrow -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException -import io.imagekit.api.models.ExtensionItem +import io.imagekit.core.BaseSerializer +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonValue +import io.imagekit.core.MultipartField +import io.imagekit.core.Params +import io.imagekit.core.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.getOrThrow +import io.imagekit.core.http.Headers +import io.imagekit.core.http.QueryParams +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException +import io.imagekit.models.ExtensionItem import java.io.InputStream import java.nio.file.Path import java.util.Collections diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/beta/v2/files/FileUploadResponse.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUploadResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/beta/v2/files/FileUploadResponse.kt index 8452e3ef..8ebdc361 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUploadResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/beta/v2/files/FileUploadResponse.kt @@ -1,24 +1,25 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.beta.v2.files 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.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException -import io.imagekit.api.models.AiTag -import io.imagekit.api.models.CustomMetadata -import io.imagekit.api.models.EmbeddedMetadata -import io.imagekit.api.models.SelectedFieldsSchema -import io.imagekit.api.models.VersionInfo +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException +import io.imagekit.models.AiTag +import io.imagekit.models.CustomMetadata +import io.imagekit.models.EmbeddedMetadata +import io.imagekit.models.SelectedFieldsSchema +import io.imagekit.models.VersionInfo +import io.imagekit.models.files.Metadata import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/cache/invalidation/InvalidationCreateParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/cache/invalidation/InvalidationCreateParams.kt index 37ba7e32..b8575a6c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/cache/invalidation/InvalidationCreateParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.cache.invalidation +package io.imagekit.models.cache.invalidation 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.errors.ImageKitInvalidDataException +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/cache/invalidation/InvalidationCreateResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/cache/invalidation/InvalidationCreateResponse.kt index c6979018..17f3b15d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/cache/invalidation/InvalidationCreateResponse.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.cache.invalidation +package io.imagekit.models.cache.invalidation 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/cache/invalidation/InvalidationGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/cache/invalidation/InvalidationGetParams.kt index f766c993..47785754 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/cache/invalidation/InvalidationGetParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.cache.invalidation +package io.imagekit.models.cache.invalidation -import io.imagekit.api.core.Params -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/cache/invalidation/InvalidationGetResponse.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/cache/invalidation/InvalidationGetResponse.kt index a7c3b8d9..490d3041 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/cache/invalidation/InvalidationGetResponse.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.cache.invalidation +package io.imagekit.models.cache.invalidation 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.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataField.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataField.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataField.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataField.kt index 72e4e0ad..b8b6f6fc 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataField.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataField.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.custommetadatafields +package io.imagekit.models.custommetadatafields import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,19 +13,19 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.BaseDeserializer -import io.imagekit.api.core.BaseSerializer -import io.imagekit.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.allMaxBy -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.getOrThrow -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.BaseDeserializer +import io.imagekit.core.BaseSerializer +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.allMaxBy +import io.imagekit.core.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.getOrThrow +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldCreateParams.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldCreateParams.kt index eb87e03d..ddd024f6 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldCreateParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.custommetadatafields +package io.imagekit.models.custommetadatafields import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,22 +13,22 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.BaseDeserializer -import io.imagekit.api.core.BaseSerializer -import io.imagekit.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.allMaxBy -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.getOrThrow -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.BaseDeserializer +import io.imagekit.core.BaseSerializer +import io.imagekit.core.Enum +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.allMaxBy +import io.imagekit.core.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.getOrThrow +import io.imagekit.core.http.Headers +import io.imagekit.core.http.QueryParams +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt index 30af50b5..9ab37174 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldDeleteParams.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.custommetadatafields +package io.imagekit.models.custommetadatafields -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.core.toImmutable +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt index 63a160df..dd6cdfdb 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldDeleteResponse.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.custommetadatafields +package io.imagekit.models.custommetadatafields import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonValue +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldListParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldListParams.kt index 432b35bd..411dfb8c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldListParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.custommetadatafields +package io.imagekit.models.custommetadatafields -import io.imagekit.api.core.Params -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt index fd72bb5c..17dd40d7 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldUpdateParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.custommetadatafields +package io.imagekit.models.custommetadatafields import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,20 +13,20 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.BaseDeserializer -import io.imagekit.api.core.BaseSerializer -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.allMaxBy -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.getOrThrow -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.BaseDeserializer +import io.imagekit.core.BaseSerializer +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.allMaxBy +import io.imagekit.core.checkKnown +import io.imagekit.core.getOrThrow +import io.imagekit.core.http.Headers +import io.imagekit.core.http.QueryParams +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/File.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/File.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/File.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/File.kt index 94799525..eec3f1a3 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/File.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/File.kt @@ -1,24 +1,24 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files 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.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException -import io.imagekit.api.models.AiTag -import io.imagekit.api.models.CustomMetadata -import io.imagekit.api.models.EmbeddedMetadata -import io.imagekit.api.models.SelectedFieldsSchema -import io.imagekit.api.models.VersionInfo +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException +import io.imagekit.models.AiTag +import io.imagekit.models.CustomMetadata +import io.imagekit.models.EmbeddedMetadata +import io.imagekit.models.SelectedFieldsSchema +import io.imagekit.models.VersionInfo import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileCopyParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileCopyParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileCopyParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileCopyParams.kt index de237dbe..13b49c09 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileCopyParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileCopyParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.errors.ImageKitInvalidDataException +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileCopyResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileCopyResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileCopyResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileCopyResponse.kt index 5551c970..5b34a5c3 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileCopyResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileCopyResponse.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonValue +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileDeleteParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileDeleteParams.kt index db27e56d..e49111b2 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileDeleteParams.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.core.toImmutable +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileGetParams.kt index d2036f07..acd8b62a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileGetParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files -import io.imagekit.api.core.Params -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileMoveParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileMoveParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileMoveParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileMoveParams.kt index 1a6e9b67..0658965d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileMoveParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileMoveParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.errors.ImageKitInvalidDataException +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileMoveResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileMoveResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileMoveResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileMoveResponse.kt index 021ac591..86d755dd 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileMoveResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileMoveResponse.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonValue +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileRenameParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileRenameParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileRenameParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileRenameParams.kt index 1ccfab29..6d9295e0 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileRenameParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileRenameParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.errors.ImageKitInvalidDataException +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileRenameResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileRenameResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileRenameResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileRenameResponse.kt index 15b0ba2f..9ecbd54f 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileRenameResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileRenameResponse.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUpdateParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUpdateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUpdateParams.kt index e948d9a5..7ffaf076 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUpdateParams.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams +import io.imagekit.core.Params +import io.imagekit.core.checkRequired +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUpdateResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUpdateResponse.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUpdateResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUpdateResponse.kt index c76a278c..9076aa68 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUpdateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUpdateResponse.kt @@ -1,24 +1,24 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files 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.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException -import io.imagekit.api.models.AiTag -import io.imagekit.api.models.CustomMetadata -import io.imagekit.api.models.EmbeddedMetadata -import io.imagekit.api.models.SelectedFieldsSchema -import io.imagekit.api.models.VersionInfo +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException +import io.imagekit.models.AiTag +import io.imagekit.models.CustomMetadata +import io.imagekit.models.EmbeddedMetadata +import io.imagekit.models.SelectedFieldsSchema +import io.imagekit.models.VersionInfo import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUploadParams.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUploadParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUploadParams.kt index af79f5b7..6d2b66ab 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUploadParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -9,21 +9,21 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonSerialize -import io.imagekit.api.core.BaseSerializer -import io.imagekit.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.MultipartField -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.getOrThrow -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException -import io.imagekit.api.models.ExtensionItem +import io.imagekit.core.BaseSerializer +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonValue +import io.imagekit.core.MultipartField +import io.imagekit.core.Params +import io.imagekit.core.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.getOrThrow +import io.imagekit.core.http.Headers +import io.imagekit.core.http.QueryParams +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException +import io.imagekit.models.ExtensionItem import java.io.InputStream import java.nio.file.Path import java.util.Collections diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUploadResponse.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUploadResponse.kt index b2f1338f..d366a454 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUploadResponse.kt @@ -1,25 +1,24 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.beta.v2.files +package io.imagekit.models.files 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.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException -import io.imagekit.api.models.AiTag -import io.imagekit.api.models.CustomMetadata -import io.imagekit.api.models.EmbeddedMetadata -import io.imagekit.api.models.SelectedFieldsSchema -import io.imagekit.api.models.VersionInfo -import io.imagekit.api.models.files.Metadata +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException +import io.imagekit.models.AiTag +import io.imagekit.models.CustomMetadata +import io.imagekit.models.EmbeddedMetadata +import io.imagekit.models.SelectedFieldsSchema +import io.imagekit.models.VersionInfo import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/Folder.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/Folder.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/Folder.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/Folder.kt index 32c7d678..35f4df55 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/Folder.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/Folder.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files 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.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/Metadata.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/Metadata.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/Metadata.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/Metadata.kt index 9d0ac8e4..66885a1d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/Metadata.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/Metadata.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/UpdateFileRequest.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/UpdateFileRequest.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/UpdateFileRequest.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/UpdateFileRequest.kt index 7b37cd33..9582a26c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/UpdateFileRequest.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/UpdateFileRequest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -13,19 +13,19 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.BaseDeserializer -import io.imagekit.api.core.BaseSerializer -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.allMaxBy -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.getOrThrow -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException -import io.imagekit.api.models.ExtensionItem +import io.imagekit.core.BaseDeserializer +import io.imagekit.core.BaseSerializer +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.allMaxBy +import io.imagekit.core.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.getOrThrow +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException +import io.imagekit.models.ExtensionItem import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkAddTagsParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkAddTagsParams.kt index f46828d2..f0bcc033 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkAddTagsParams.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.bulk +package io.imagekit.models.files.bulk 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +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.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.http.Headers +import io.imagekit.core.http.QueryParams +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkAddTagsResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkAddTagsResponse.kt index fd0160ee..1124d430 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkAddTagsResponse.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.bulk +package io.imagekit.models.files.bulk 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkDeleteParams.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkDeleteParams.kt index a7e54721..fc3e0dd2 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkDeleteParams.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.bulk +package io.imagekit.models.files.bulk 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +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.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.http.Headers +import io.imagekit.core.http.QueryParams +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkDeleteResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkDeleteResponse.kt index 08c74e59..539f9a9e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkDeleteResponse.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.bulk +package io.imagekit.models.files.bulk 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkRemoveAiTagsParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkRemoveAiTagsParams.kt index 1395723d..a4977e61 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkRemoveAiTagsParams.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.bulk +package io.imagekit.models.files.bulk 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +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.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.http.Headers +import io.imagekit.core.http.QueryParams +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkRemoveAiTagsResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkRemoveAiTagsResponse.kt index a183fc71..5966074a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkRemoveAiTagsResponse.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.bulk +package io.imagekit.models.files.bulk 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkRemoveTagsParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkRemoveTagsParams.kt index d059ac8b..cd33eca9 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkRemoveTagsParams.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.bulk +package io.imagekit.models.files.bulk 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +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.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.http.Headers +import io.imagekit.core.http.QueryParams +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkRemoveTagsResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkRemoveTagsResponse.kt index 0ee86d18..f1b2ad24 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/bulk/BulkRemoveTagsResponse.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.bulk +package io.imagekit.models.files.bulk 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/metadata/MetadataGetFromUrlParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/metadata/MetadataGetFromUrlParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/metadata/MetadataGetFromUrlParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/metadata/MetadataGetFromUrlParams.kt index f0fd2de7..4c7fc7a9 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/metadata/MetadataGetFromUrlParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/metadata/MetadataGetFromUrlParams.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.metadata +package io.imagekit.models.files.metadata -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams +import io.imagekit.core.Params +import io.imagekit.core.checkRequired +import io.imagekit.core.http.Headers +import io.imagekit.core.http.QueryParams import java.util.Objects /** Get image EXIF, pHash, and other metadata from ImageKit.io powered remote URL using this API. */ diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/metadata/MetadataGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/metadata/MetadataGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/metadata/MetadataGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/metadata/MetadataGetParams.kt index c46eca25..6fb2681b 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/metadata/MetadataGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/metadata/MetadataGetParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.metadata +package io.imagekit.models.files.metadata -import io.imagekit.api.core.Params -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/versions/VersionDeleteParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/versions/VersionDeleteParams.kt index 98218d88..a738a421 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/versions/VersionDeleteParams.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.versions - -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.core.toImmutable +package io.imagekit.models.files.versions + +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.core.toImmutable import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/versions/VersionDeleteResponse.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionDeleteResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/versions/VersionDeleteResponse.kt index 8887e072..047daa8e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionDeleteResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/versions/VersionDeleteResponse.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.versions +package io.imagekit.models.files.versions import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonValue +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/versions/VersionGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/versions/VersionGetParams.kt index 4aca8292..cf92a30a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/versions/VersionGetParams.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.versions +package io.imagekit.models.files.versions -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams +import io.imagekit.core.Params +import io.imagekit.core.checkRequired +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionListParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/versions/VersionListParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionListParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/versions/VersionListParams.kt index ba9e6ccd..07fe2eff 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionListParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/versions/VersionListParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.versions +package io.imagekit.models.files.versions -import io.imagekit.api.core.Params -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionRestoreParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/versions/VersionRestoreParams.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionRestoreParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/files/versions/VersionRestoreParams.kt index 3b621ed5..0aa85c58 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/files/versions/VersionRestoreParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/versions/VersionRestoreParams.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.versions - -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.core.toImmutable +package io.imagekit.models.files.versions + +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.core.toImmutable import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCopyParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderCopyParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCopyParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderCopyParams.kt index c0b97ce1..114a8aa1 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCopyParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderCopyParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders +package io.imagekit.models.folders 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.errors.ImageKitInvalidDataException +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCopyResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderCopyResponse.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCopyResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderCopyResponse.kt index 5ce8295a..f4b76851 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCopyResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderCopyResponse.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders +package io.imagekit.models.folders 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkRequired +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderCreateParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCreateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderCreateParams.kt index e710351b..6194d129 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderCreateParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders +package io.imagekit.models.folders 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.errors.ImageKitInvalidDataException +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCreateResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderCreateResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCreateResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderCreateResponse.kt index 60c0a6f0..ee65253e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderCreateResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderCreateResponse.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders +package io.imagekit.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonValue +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderDeleteParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderDeleteParams.kt index 92fee7ce..ee709fe6 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderDeleteParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders +package io.imagekit.models.folders 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.errors.ImageKitInvalidDataException +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderDeleteResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderDeleteResponse.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderDeleteResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderDeleteResponse.kt index 74280bb4..92bc1296 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderDeleteResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderDeleteResponse.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders +package io.imagekit.models.folders import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonValue +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderMoveParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderMoveParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderMoveParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderMoveParams.kt index 0b5f5e5a..48d274e0 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderMoveParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderMoveParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders +package io.imagekit.models.folders 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.errors.ImageKitInvalidDataException +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderMoveResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderMoveResponse.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderMoveResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderMoveResponse.kt index 252b6a96..d02e2e16 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderMoveResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderMoveResponse.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders +package io.imagekit.models.folders 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkRequired +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderRenameParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderRenameParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderRenameParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderRenameParams.kt index 61324c7b..967c2203 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderRenameParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderRenameParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders +package io.imagekit.models.folders 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.errors.ImageKitInvalidDataException +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderRenameResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderRenameResponse.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderRenameResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderRenameResponse.kt index e970ff31..703dc048 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/FolderRenameResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/FolderRenameResponse.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders +package io.imagekit.models.folders 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkRequired +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/job/JobGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/job/JobGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/job/JobGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/job/JobGetParams.kt index cc415e6e..2633e4b6 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/job/JobGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/job/JobGetParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders.job +package io.imagekit.models.folders.job -import io.imagekit.api.core.Params -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/job/JobGetResponse.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/job/JobGetResponse.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/job/JobGetResponse.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/job/JobGetResponse.kt index 5a213887..94e8586b 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/folders/job/JobGetResponse.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/folders/job/JobGetResponse.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders.job +package io.imagekit.models.folders.job 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.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionCreateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/savedextensions/SavedExtensionCreateParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionCreateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/savedextensions/SavedExtensionCreateParams.kt index 195ab60a..15b325db 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionCreateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/savedextensions/SavedExtensionCreateParams.kt @@ -1,21 +1,21 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.savedextensions +package io.imagekit.models.savedextensions 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.errors.ImageKitInvalidDataException -import io.imagekit.api.models.ExtensionConfig +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 io.imagekit.models.ExtensionConfig import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionDeleteParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/savedextensions/SavedExtensionDeleteParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionDeleteParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/savedextensions/SavedExtensionDeleteParams.kt index b58db767..662936e8 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionDeleteParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/savedextensions/SavedExtensionDeleteParams.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.savedextensions +package io.imagekit.models.savedextensions -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.core.toImmutable +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionGetParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/savedextensions/SavedExtensionGetParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionGetParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/savedextensions/SavedExtensionGetParams.kt index d0882a0a..ac5870ce 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionGetParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/savedextensions/SavedExtensionGetParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.savedextensions +package io.imagekit.models.savedextensions -import io.imagekit.api.core.Params -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionListParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/savedextensions/SavedExtensionListParams.kt similarity index 97% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionListParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/savedextensions/SavedExtensionListParams.kt index 634f6ef7..550aff85 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionListParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/savedextensions/SavedExtensionListParams.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.savedextensions +package io.imagekit.models.savedextensions -import io.imagekit.api.core.Params -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams +import io.imagekit.core.Params +import io.imagekit.core.http.Headers +import io.imagekit.core.http.QueryParams import java.util.Objects /** diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionUpdateParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/savedextensions/SavedExtensionUpdateParams.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionUpdateParams.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/savedextensions/SavedExtensionUpdateParams.kt index eb8060b9..cd08d06d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionUpdateParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/savedextensions/SavedExtensionUpdateParams.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.savedextensions +package io.imagekit.models.savedextensions 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.Params -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.http.QueryParams -import io.imagekit.api.errors.ImageKitInvalidDataException -import io.imagekit.api.models.ExtensionConfig +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 io.imagekit.models.ExtensionConfig import java.util.Collections import java.util.Objects import java.util.Optional diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/BaseWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/BaseWebhookEvent.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/BaseWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/BaseWebhookEvent.kt index c398d991..b1afda2e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/BaseWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/BaseWebhookEvent.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkRequired +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileCreateEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/FileCreateEvent.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileCreateEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/FileCreateEvent.kt index b5835b89..191e0445 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileCreateEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/FileCreateEvent.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.errors.ImageKitInvalidDataException -import io.imagekit.api.models.files.File +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 io.imagekit.models.files.File import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileDeleteEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/FileDeleteEvent.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileDeleteEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/FileDeleteEvent.kt index a5aa1a39..17feedff 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileDeleteEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/FileDeleteEvent.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.errors.ImageKitInvalidDataException +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileUpdateEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/FileUpdateEvent.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileUpdateEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/FileUpdateEvent.kt index 1ef9b420..981f19e8 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileUpdateEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/FileUpdateEvent.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.errors.ImageKitInvalidDataException -import io.imagekit.api.models.files.File +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 io.imagekit.models.files.File import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileVersionCreateEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/FileVersionCreateEvent.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileVersionCreateEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/FileVersionCreateEvent.kt index 6c5e1131..e8a7f526 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileVersionCreateEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/FileVersionCreateEvent.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.errors.ImageKitInvalidDataException -import io.imagekit.api.models.files.File +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 io.imagekit.models.files.File import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileVersionDeleteEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/FileVersionDeleteEvent.kt similarity index 98% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileVersionDeleteEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/FileVersionDeleteEvent.kt index cce06f26..4049505f 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/FileVersionDeleteEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/FileVersionDeleteEvent.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.errors.ImageKitInvalidDataException +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UnsafeUnwrapWebhookEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UnsafeUnwrapWebhookEvent.kt index 69f2966f..2cc0d228 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UnsafeUnwrapWebhookEvent.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -9,12 +9,12 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.BaseDeserializer -import io.imagekit.api.core.BaseSerializer -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.allMaxBy -import io.imagekit.api.core.getOrThrow -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.BaseDeserializer +import io.imagekit.core.BaseSerializer +import io.imagekit.core.JsonValue +import io.imagekit.core.allMaxBy +import io.imagekit.core.getOrThrow +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UnwrapWebhookEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UnwrapWebhookEvent.kt index 6e40ba9f..6d402456 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UnwrapWebhookEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UnwrapWebhookEvent.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec @@ -9,12 +9,12 @@ import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.BaseDeserializer -import io.imagekit.api.core.BaseSerializer -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.allMaxBy -import io.imagekit.api.core.getOrThrow -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.BaseDeserializer +import io.imagekit.core.BaseSerializer +import io.imagekit.core.JsonValue +import io.imagekit.core.allMaxBy +import io.imagekit.core.getOrThrow +import io.imagekit.errors.ImageKitInvalidDataException import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPostTransformErrorEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPostTransformErrorEvent.kt index 45a14591..41fcb8a9 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformErrorEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPostTransformErrorEvent.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks 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.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.Enum +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPostTransformSuccessEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPostTransformSuccessEvent.kt index 611c1353..1b4f1e0f 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformSuccessEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPostTransformSuccessEvent.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks 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.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.Enum +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPreTransformErrorEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPreTransformErrorEvent.kt index e306081b..af3bac71 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformErrorEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPreTransformErrorEvent.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks 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.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkRequired -import io.imagekit.api.errors.ImageKitInvalidDataException +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 diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPreTransformSuccessEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPreTransformSuccessEvent.kt index 0fc5cc5b..8e01813a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformSuccessEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/UploadPreTransformSuccessEvent.kt @@ -1,26 +1,26 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks 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.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException -import io.imagekit.api.models.AiTag -import io.imagekit.api.models.CustomMetadata -import io.imagekit.api.models.EmbeddedMetadata -import io.imagekit.api.models.SelectedFieldsSchema -import io.imagekit.api.models.VersionInfo -import io.imagekit.api.models.files.Metadata +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException +import io.imagekit.models.AiTag +import io.imagekit.models.CustomMetadata +import io.imagekit.models.EmbeddedMetadata +import io.imagekit.models.SelectedFieldsSchema +import io.imagekit.models.VersionInfo +import io.imagekit.models.files.Metadata import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/VideoTransformationAcceptedEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/VideoTransformationAcceptedEvent.kt index 0f54c1bd..d873e2a3 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/VideoTransformationAcceptedEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/VideoTransformationAcceptedEvent.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks 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.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/VideoTransformationErrorEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/VideoTransformationErrorEvent.kt index eefb103d..993182e5 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/VideoTransformationErrorEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/VideoTransformationErrorEvent.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks 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.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/VideoTransformationReadyEvent.kt similarity index 99% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/VideoTransformationReadyEvent.kt index d9c1bdd2..bf3bfcbf 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/models/webhooks/VideoTransformationReadyEvent.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/webhooks/VideoTransformationReadyEvent.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks 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.api.core.Enum -import io.imagekit.api.core.ExcludeMissing -import io.imagekit.api.core.JsonField -import io.imagekit.api.core.JsonMissing -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.checkKnown -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.toImmutable -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.Enum +import io.imagekit.core.ExcludeMissing +import io.imagekit.core.JsonField +import io.imagekit.core.JsonMissing +import io.imagekit.core.JsonValue +import io.imagekit.core.checkKnown +import io.imagekit.core.checkRequired +import io.imagekit.core.toImmutable +import io.imagekit.errors.ImageKitInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AccountServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/AccountServiceAsync.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AccountServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/AccountServiceAsync.kt index 209efd83..0eab4551 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AccountServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/AccountServiceAsync.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async +package io.imagekit.services.async -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.services.async.accounts.OriginServiceAsync -import io.imagekit.api.services.async.accounts.UrlEndpointServiceAsync -import io.imagekit.api.services.async.accounts.UsageServiceAsync +import io.imagekit.core.ClientOptions +import io.imagekit.services.async.accounts.OriginServiceAsync +import io.imagekit.services.async.accounts.UrlEndpointServiceAsync +import io.imagekit.services.async.accounts.UsageServiceAsync import java.util.function.Consumer interface AccountServiceAsync { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AccountServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/AccountServiceAsyncImpl.kt similarity index 82% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AccountServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/AccountServiceAsyncImpl.kt index 27a1510d..77885c6e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AccountServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/AccountServiceAsyncImpl.kt @@ -1,14 +1,14 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.services.async.accounts.OriginServiceAsync -import io.imagekit.api.services.async.accounts.OriginServiceAsyncImpl -import io.imagekit.api.services.async.accounts.UrlEndpointServiceAsync -import io.imagekit.api.services.async.accounts.UrlEndpointServiceAsyncImpl -import io.imagekit.api.services.async.accounts.UsageServiceAsync -import io.imagekit.api.services.async.accounts.UsageServiceAsyncImpl +package io.imagekit.services.async + +import io.imagekit.core.ClientOptions +import io.imagekit.services.async.accounts.OriginServiceAsync +import io.imagekit.services.async.accounts.OriginServiceAsyncImpl +import io.imagekit.services.async.accounts.UrlEndpointServiceAsync +import io.imagekit.services.async.accounts.UrlEndpointServiceAsyncImpl +import io.imagekit.services.async.accounts.UsageServiceAsync +import io.imagekit.services.async.accounts.UsageServiceAsyncImpl import java.util.function.Consumer class AccountServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AssetServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/AssetServiceAsync.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AssetServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/AssetServiceAsync.kt index c195e8b2..bca8792a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AssetServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/AssetServiceAsync.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async +package io.imagekit.services.async -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.assets.AssetListParams -import io.imagekit.api.models.assets.AssetListResponse +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.assets.AssetListParams +import io.imagekit.models.assets.AssetListResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AssetServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/AssetServiceAsyncImpl.kt similarity index 79% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AssetServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/AssetServiceAsyncImpl.kt index e59efd72..230d090b 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/AssetServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/AssetServiceAsyncImpl.kt @@ -1,21 +1,21 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async +package io.imagekit.services.async -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepareAsync -import io.imagekit.api.models.assets.AssetListParams -import io.imagekit.api.models.assets.AssetListResponse +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.parseable +import io.imagekit.core.prepareAsync +import io.imagekit.models.assets.AssetListParams +import io.imagekit.models.assets.AssetListResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/BetaServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/BetaServiceAsync.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/BetaServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/BetaServiceAsync.kt index b05446ec..c6e048ce 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/BetaServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/BetaServiceAsync.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async +package io.imagekit.services.async -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.services.async.beta.V2ServiceAsync +import io.imagekit.core.ClientOptions +import io.imagekit.services.async.beta.V2ServiceAsync import java.util.function.Consumer interface BetaServiceAsync { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/BetaServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/BetaServiceAsyncImpl.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/BetaServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/BetaServiceAsyncImpl.kt index 5911488c..248a87af 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/BetaServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/BetaServiceAsyncImpl.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async +package io.imagekit.services.async -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.services.async.beta.V2ServiceAsync -import io.imagekit.api.services.async.beta.V2ServiceAsyncImpl +import io.imagekit.core.ClientOptions +import io.imagekit.services.async.beta.V2ServiceAsync +import io.imagekit.services.async.beta.V2ServiceAsyncImpl import java.util.function.Consumer class BetaServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CacheServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/CacheServiceAsync.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CacheServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/CacheServiceAsync.kt index f8432587..dd2fe092 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CacheServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/CacheServiceAsync.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async +package io.imagekit.services.async -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.services.async.cache.InvalidationServiceAsync +import io.imagekit.core.ClientOptions +import io.imagekit.services.async.cache.InvalidationServiceAsync import java.util.function.Consumer interface CacheServiceAsync { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CacheServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/CacheServiceAsyncImpl.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CacheServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/CacheServiceAsyncImpl.kt index 7925b3d6..cacfabcd 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CacheServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/CacheServiceAsyncImpl.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async +package io.imagekit.services.async -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.services.async.cache.InvalidationServiceAsync -import io.imagekit.api.services.async.cache.InvalidationServiceAsyncImpl +import io.imagekit.core.ClientOptions +import io.imagekit.services.async.cache.InvalidationServiceAsync +import io.imagekit.services.async.cache.InvalidationServiceAsyncImpl import java.util.function.Consumer class CacheServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CustomMetadataFieldServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/CustomMetadataFieldServiceAsync.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CustomMetadataFieldServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/CustomMetadataFieldServiceAsync.kt index d7fe5574..82398fc8 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CustomMetadataFieldServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/CustomMetadataFieldServiceAsync.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.custommetadatafields.CustomMetadataField -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +package io.imagekit.services.async + +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.custommetadatafields.CustomMetadataField +import io.imagekit.models.custommetadatafields.CustomMetadataFieldCreateParams +import io.imagekit.models.custommetadatafields.CustomMetadataFieldDeleteParams +import io.imagekit.models.custommetadatafields.CustomMetadataFieldDeleteResponse +import io.imagekit.models.custommetadatafields.CustomMetadataFieldListParams +import io.imagekit.models.custommetadatafields.CustomMetadataFieldUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CustomMetadataFieldServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/CustomMetadataFieldServiceAsyncImpl.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CustomMetadataFieldServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/CustomMetadataFieldServiceAsyncImpl.kt index 8ebc7fdc..137d59e2 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/CustomMetadataFieldServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/CustomMetadataFieldServiceAsyncImpl.kt @@ -1,27 +1,27 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.json -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepareAsync -import io.imagekit.api.models.custommetadatafields.CustomMetadataField -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +package io.imagekit.services.async + +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.checkRequired +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.json +import io.imagekit.core.http.parseable +import io.imagekit.core.prepareAsync +import io.imagekit.models.custommetadatafields.CustomMetadataField +import io.imagekit.models.custommetadatafields.CustomMetadataFieldCreateParams +import io.imagekit.models.custommetadatafields.CustomMetadataFieldDeleteParams +import io.imagekit.models.custommetadatafields.CustomMetadataFieldDeleteResponse +import io.imagekit.models.custommetadatafields.CustomMetadataFieldListParams +import io.imagekit.models.custommetadatafields.CustomMetadataFieldUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/FileServiceAsync.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FileServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/FileServiceAsync.kt index 9988fc96..5b01b0fc 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FileServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/FileServiceAsync.kt @@ -1,27 +1,27 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.files.File -import io.imagekit.api.models.files.FileCopyParams -import io.imagekit.api.models.files.FileCopyResponse -import io.imagekit.api.models.files.FileDeleteParams -import io.imagekit.api.models.files.FileGetParams -import io.imagekit.api.models.files.FileMoveParams -import io.imagekit.api.models.files.FileMoveResponse -import io.imagekit.api.models.files.FileRenameParams -import io.imagekit.api.models.files.FileRenameResponse -import io.imagekit.api.models.files.FileUpdateParams -import io.imagekit.api.models.files.FileUpdateResponse -import io.imagekit.api.models.files.FileUploadParams -import io.imagekit.api.models.files.FileUploadResponse -import io.imagekit.api.services.async.files.BulkServiceAsync -import io.imagekit.api.services.async.files.MetadataServiceAsync -import io.imagekit.api.services.async.files.VersionServiceAsync +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.files.File +import io.imagekit.models.files.FileCopyParams +import io.imagekit.models.files.FileCopyResponse +import io.imagekit.models.files.FileDeleteParams +import io.imagekit.models.files.FileGetParams +import io.imagekit.models.files.FileMoveParams +import io.imagekit.models.files.FileMoveResponse +import io.imagekit.models.files.FileRenameParams +import io.imagekit.models.files.FileRenameResponse +import io.imagekit.models.files.FileUpdateParams +import io.imagekit.models.files.FileUpdateResponse +import io.imagekit.models.files.FileUploadParams +import io.imagekit.models.files.FileUploadResponse +import io.imagekit.services.async.files.BulkServiceAsync +import io.imagekit.services.async.files.MetadataServiceAsync +import io.imagekit.services.async.files.VersionServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FileServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/FileServiceAsyncImpl.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FileServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/FileServiceAsyncImpl.kt index 07220375..eaace45b 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FileServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/FileServiceAsyncImpl.kt @@ -1,42 +1,42 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.handlers.emptyHandler -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.json -import io.imagekit.api.core.http.multipartFormData -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepareAsync -import io.imagekit.api.models.files.File -import io.imagekit.api.models.files.FileCopyParams -import io.imagekit.api.models.files.FileCopyResponse -import io.imagekit.api.models.files.FileDeleteParams -import io.imagekit.api.models.files.FileGetParams -import io.imagekit.api.models.files.FileMoveParams -import io.imagekit.api.models.files.FileMoveResponse -import io.imagekit.api.models.files.FileRenameParams -import io.imagekit.api.models.files.FileRenameResponse -import io.imagekit.api.models.files.FileUpdateParams -import io.imagekit.api.models.files.FileUpdateResponse -import io.imagekit.api.models.files.FileUploadParams -import io.imagekit.api.models.files.FileUploadResponse -import io.imagekit.api.services.async.files.BulkServiceAsync -import io.imagekit.api.services.async.files.BulkServiceAsyncImpl -import io.imagekit.api.services.async.files.MetadataServiceAsync -import io.imagekit.api.services.async.files.MetadataServiceAsyncImpl -import io.imagekit.api.services.async.files.VersionServiceAsync -import io.imagekit.api.services.async.files.VersionServiceAsyncImpl +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.multipartFormData +import io.imagekit.core.http.parseable +import io.imagekit.core.prepareAsync +import io.imagekit.models.files.File +import io.imagekit.models.files.FileCopyParams +import io.imagekit.models.files.FileCopyResponse +import io.imagekit.models.files.FileDeleteParams +import io.imagekit.models.files.FileGetParams +import io.imagekit.models.files.FileMoveParams +import io.imagekit.models.files.FileMoveResponse +import io.imagekit.models.files.FileRenameParams +import io.imagekit.models.files.FileRenameResponse +import io.imagekit.models.files.FileUpdateParams +import io.imagekit.models.files.FileUpdateResponse +import io.imagekit.models.files.FileUploadParams +import io.imagekit.models.files.FileUploadResponse +import io.imagekit.services.async.files.BulkServiceAsync +import io.imagekit.services.async.files.BulkServiceAsyncImpl +import io.imagekit.services.async.files.MetadataServiceAsync +import io.imagekit.services.async.files.MetadataServiceAsyncImpl +import io.imagekit.services.async.files.VersionServiceAsync +import io.imagekit.services.async.files.VersionServiceAsyncImpl import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FolderServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/FolderServiceAsync.kt similarity index 89% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FolderServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/FolderServiceAsync.kt index a455aca8..850b8e32 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FolderServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/FolderServiceAsync.kt @@ -1,21 +1,21 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.folders.FolderCopyParams -import io.imagekit.api.models.folders.FolderCopyResponse -import io.imagekit.api.models.folders.FolderCreateParams -import io.imagekit.api.models.folders.FolderCreateResponse -import io.imagekit.api.models.folders.FolderDeleteParams -import io.imagekit.api.models.folders.FolderDeleteResponse -import io.imagekit.api.models.folders.FolderMoveParams -import io.imagekit.api.models.folders.FolderMoveResponse -import io.imagekit.api.models.folders.FolderRenameParams -import io.imagekit.api.models.folders.FolderRenameResponse -import io.imagekit.api.services.async.folders.JobServiceAsync +package io.imagekit.services.async + +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.folders.FolderCopyParams +import io.imagekit.models.folders.FolderCopyResponse +import io.imagekit.models.folders.FolderCreateParams +import io.imagekit.models.folders.FolderCreateResponse +import io.imagekit.models.folders.FolderDeleteParams +import io.imagekit.models.folders.FolderDeleteResponse +import io.imagekit.models.folders.FolderMoveParams +import io.imagekit.models.folders.FolderMoveResponse +import io.imagekit.models.folders.FolderRenameParams +import io.imagekit.models.folders.FolderRenameResponse +import io.imagekit.services.async.folders.JobServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FolderServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/FolderServiceAsyncImpl.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FolderServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/FolderServiceAsyncImpl.kt index 92a21c8a..6723cee5 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/FolderServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/FolderServiceAsyncImpl.kt @@ -1,32 +1,32 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async +package io.imagekit.services.async -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.json -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepareAsync -import io.imagekit.api.models.folders.FolderCopyParams -import io.imagekit.api.models.folders.FolderCopyResponse -import io.imagekit.api.models.folders.FolderCreateParams -import io.imagekit.api.models.folders.FolderCreateResponse -import io.imagekit.api.models.folders.FolderDeleteParams -import io.imagekit.api.models.folders.FolderDeleteResponse -import io.imagekit.api.models.folders.FolderMoveParams -import io.imagekit.api.models.folders.FolderMoveResponse -import io.imagekit.api.models.folders.FolderRenameParams -import io.imagekit.api.models.folders.FolderRenameResponse -import io.imagekit.api.services.async.folders.JobServiceAsync -import io.imagekit.api.services.async.folders.JobServiceAsyncImpl +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.json +import io.imagekit.core.http.parseable +import io.imagekit.core.prepareAsync +import io.imagekit.models.folders.FolderCopyParams +import io.imagekit.models.folders.FolderCopyResponse +import io.imagekit.models.folders.FolderCreateParams +import io.imagekit.models.folders.FolderCreateResponse +import io.imagekit.models.folders.FolderDeleteParams +import io.imagekit.models.folders.FolderDeleteResponse +import io.imagekit.models.folders.FolderMoveParams +import io.imagekit.models.folders.FolderMoveResponse +import io.imagekit.models.folders.FolderRenameParams +import io.imagekit.models.folders.FolderRenameResponse +import io.imagekit.services.async.folders.JobServiceAsync +import io.imagekit.services.async.folders.JobServiceAsyncImpl import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/SavedExtensionServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/SavedExtensionServiceAsync.kt similarity index 95% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/SavedExtensionServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/SavedExtensionServiceAsync.kt index 70f5cc8e..75098074 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/SavedExtensionServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/SavedExtensionServiceAsync.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.SavedExtension -import io.imagekit.api.models.savedextensions.SavedExtensionCreateParams -import io.imagekit.api.models.savedextensions.SavedExtensionDeleteParams -import io.imagekit.api.models.savedextensions.SavedExtensionGetParams -import io.imagekit.api.models.savedextensions.SavedExtensionListParams -import io.imagekit.api.models.savedextensions.SavedExtensionUpdateParams +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.SavedExtension +import io.imagekit.models.savedextensions.SavedExtensionCreateParams +import io.imagekit.models.savedextensions.SavedExtensionDeleteParams +import io.imagekit.models.savedextensions.SavedExtensionGetParams +import io.imagekit.models.savedextensions.SavedExtensionListParams +import io.imagekit.models.savedextensions.SavedExtensionUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/SavedExtensionServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/SavedExtensionServiceAsyncImpl.kt similarity index 89% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/SavedExtensionServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/SavedExtensionServiceAsyncImpl.kt index f289a3cd..911c9354 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/SavedExtensionServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/SavedExtensionServiceAsyncImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.handlers.emptyHandler -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.json -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepareAsync -import io.imagekit.api.models.SavedExtension -import io.imagekit.api.models.savedextensions.SavedExtensionCreateParams -import io.imagekit.api.models.savedextensions.SavedExtensionDeleteParams -import io.imagekit.api.models.savedextensions.SavedExtensionGetParams -import io.imagekit.api.models.savedextensions.SavedExtensionListParams -import io.imagekit.api.models.savedextensions.SavedExtensionUpdateParams +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.SavedExtension +import io.imagekit.models.savedextensions.SavedExtensionCreateParams +import io.imagekit.models.savedextensions.SavedExtensionDeleteParams +import io.imagekit.models.savedextensions.SavedExtensionGetParams +import io.imagekit.models.savedextensions.SavedExtensionListParams +import io.imagekit.models.savedextensions.SavedExtensionUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/WebhookServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/WebhookServiceAsync.kt similarity index 82% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/WebhookServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/WebhookServiceAsync.kt index 21584614..7ae13aeb 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/WebhookServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/WebhookServiceAsync.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.UnwrapWebhookParams -import io.imagekit.api.errors.ImageKitInvalidDataException -import io.imagekit.api.errors.ImageKitWebhookException -import io.imagekit.api.models.webhooks.UnsafeUnwrapWebhookEvent -import io.imagekit.api.models.webhooks.UnwrapWebhookEvent +package io.imagekit.services.async + +import io.imagekit.core.ClientOptions +import io.imagekit.core.UnwrapWebhookParams +import io.imagekit.errors.ImageKitInvalidDataException +import io.imagekit.errors.ImageKitWebhookException +import io.imagekit.models.webhooks.UnsafeUnwrapWebhookEvent +import io.imagekit.models.webhooks.UnwrapWebhookEvent import java.util.function.Consumer interface WebhookServiceAsync { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/WebhookServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/WebhookServiceAsyncImpl.kt similarity index 82% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/WebhookServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/WebhookServiceAsyncImpl.kt index c2a5bbd3..d2b29477 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/WebhookServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/WebhookServiceAsyncImpl.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async +package io.imagekit.services.async -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.UnwrapWebhookParams -import io.imagekit.api.models.webhooks.UnsafeUnwrapWebhookEvent -import io.imagekit.api.models.webhooks.UnwrapWebhookEvent -import io.imagekit.api.services.blocking.WebhookServiceImpl +import io.imagekit.core.ClientOptions +import io.imagekit.core.UnwrapWebhookParams +import io.imagekit.models.webhooks.UnsafeUnwrapWebhookEvent +import io.imagekit.models.webhooks.UnwrapWebhookEvent +import io.imagekit.services.blocking.WebhookServiceImpl import java.util.function.Consumer class WebhookServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/OriginServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/OriginServiceAsync.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/OriginServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/OriginServiceAsync.kt index ace1dd61..a5841e49 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/OriginServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/OriginServiceAsync.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.accounts - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.accounts.origins.OriginCreateParams -import io.imagekit.api.models.accounts.origins.OriginDeleteParams -import io.imagekit.api.models.accounts.origins.OriginGetParams -import io.imagekit.api.models.accounts.origins.OriginListParams -import io.imagekit.api.models.accounts.origins.OriginRequest -import io.imagekit.api.models.accounts.origins.OriginResponse -import io.imagekit.api.models.accounts.origins.OriginUpdateParams +package io.imagekit.services.async.accounts + +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.accounts.origins.OriginCreateParams +import io.imagekit.models.accounts.origins.OriginDeleteParams +import io.imagekit.models.accounts.origins.OriginGetParams +import io.imagekit.models.accounts.origins.OriginListParams +import io.imagekit.models.accounts.origins.OriginRequest +import io.imagekit.models.accounts.origins.OriginResponse +import io.imagekit.models.accounts.origins.OriginUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/OriginServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/OriginServiceAsyncImpl.kt similarity index 89% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/OriginServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/OriginServiceAsyncImpl.kt index 7ba0f5e7..e336d2d7 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/OriginServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/OriginServiceAsyncImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.accounts - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.handlers.emptyHandler -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.json -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepareAsync -import io.imagekit.api.models.accounts.origins.OriginCreateParams -import io.imagekit.api.models.accounts.origins.OriginDeleteParams -import io.imagekit.api.models.accounts.origins.OriginGetParams -import io.imagekit.api.models.accounts.origins.OriginListParams -import io.imagekit.api.models.accounts.origins.OriginResponse -import io.imagekit.api.models.accounts.origins.OriginUpdateParams +package io.imagekit.services.async.accounts + +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.accounts.origins.OriginCreateParams +import io.imagekit.models.accounts.origins.OriginDeleteParams +import io.imagekit.models.accounts.origins.OriginGetParams +import io.imagekit.models.accounts.origins.OriginListParams +import io.imagekit.models.accounts.origins.OriginResponse +import io.imagekit.models.accounts.origins.OriginUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UrlEndpointServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UrlEndpointServiceAsync.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UrlEndpointServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UrlEndpointServiceAsync.kt index 74c40398..0c6e7d7a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UrlEndpointServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UrlEndpointServiceAsync.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.accounts - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +package io.imagekit.services.async.accounts + +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.accounts.urlendpoints.UrlEndpointCreateParams +import io.imagekit.models.accounts.urlendpoints.UrlEndpointDeleteParams +import io.imagekit.models.accounts.urlendpoints.UrlEndpointGetParams +import io.imagekit.models.accounts.urlendpoints.UrlEndpointListParams +import io.imagekit.models.accounts.urlendpoints.UrlEndpointRequest +import io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse +import io.imagekit.models.accounts.urlendpoints.UrlEndpointUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UrlEndpointServiceAsyncImpl.kt similarity index 89% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UrlEndpointServiceAsyncImpl.kt index cd9bf44d..59e2fe1e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UrlEndpointServiceAsyncImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.accounts - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.handlers.emptyHandler -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.json -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepareAsync -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +package io.imagekit.services.async.accounts + +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.accounts.urlendpoints.UrlEndpointCreateParams +import io.imagekit.models.accounts.urlendpoints.UrlEndpointDeleteParams +import io.imagekit.models.accounts.urlendpoints.UrlEndpointGetParams +import io.imagekit.models.accounts.urlendpoints.UrlEndpointListParams +import io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse +import io.imagekit.models.accounts.urlendpoints.UrlEndpointUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UsageServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UsageServiceAsync.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UsageServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UsageServiceAsync.kt index 5d272a4f..d91156df 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UsageServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UsageServiceAsync.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.accounts +package io.imagekit.services.async.accounts -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.accounts.usage.UsageGetParams -import io.imagekit.api.models.accounts.usage.UsageGetResponse +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.accounts.usage.UsageGetParams +import io.imagekit.models.accounts.usage.UsageGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UsageServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UsageServiceAsyncImpl.kt similarity index 79% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UsageServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UsageServiceAsyncImpl.kt index a0984331..ef1f2eee 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/accounts/UsageServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/accounts/UsageServiceAsyncImpl.kt @@ -1,21 +1,21 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.accounts +package io.imagekit.services.async.accounts -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepareAsync -import io.imagekit.api.models.accounts.usage.UsageGetParams -import io.imagekit.api.models.accounts.usage.UsageGetResponse +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.parseable +import io.imagekit.core.prepareAsync +import io.imagekit.models.accounts.usage.UsageGetParams +import io.imagekit.models.accounts.usage.UsageGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/V2ServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/beta/V2ServiceAsync.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/V2ServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/beta/V2ServiceAsync.kt index 795b5c70..c2c91026 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/V2ServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/beta/V2ServiceAsync.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.beta +package io.imagekit.services.async.beta -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.services.async.beta.v2.FileServiceAsync +import io.imagekit.core.ClientOptions +import io.imagekit.services.async.beta.v2.FileServiceAsync import java.util.function.Consumer interface V2ServiceAsync { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/V2ServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/beta/V2ServiceAsyncImpl.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/V2ServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/beta/V2ServiceAsyncImpl.kt index ba1a287e..6c428610 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/V2ServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/beta/V2ServiceAsyncImpl.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.beta +package io.imagekit.services.async.beta -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.services.async.beta.v2.FileServiceAsync -import io.imagekit.api.services.async.beta.v2.FileServiceAsyncImpl +import io.imagekit.core.ClientOptions +import io.imagekit.services.async.beta.v2.FileServiceAsync +import io.imagekit.services.async.beta.v2.FileServiceAsyncImpl import java.util.function.Consumer class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/v2/FileServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/beta/v2/FileServiceAsync.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/v2/FileServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/beta/v2/FileServiceAsync.kt index aa7d9a99..1bd07809 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/v2/FileServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/beta/v2/FileServiceAsync.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.beta.v2 +package io.imagekit.services.async.beta.v2 -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.beta.v2.files.FileUploadParams -import io.imagekit.api.models.beta.v2.files.FileUploadResponse +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.beta.v2.files.FileUploadParams +import io.imagekit.models.beta.v2.files.FileUploadResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/v2/FileServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/beta/v2/FileServiceAsyncImpl.kt similarity index 79% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/v2/FileServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/beta/v2/FileServiceAsyncImpl.kt index dbc739e8..c280b4db 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/beta/v2/FileServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/beta/v2/FileServiceAsyncImpl.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.beta.v2 +package io.imagekit.services.async.beta.v2 -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.multipartFormData -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepareAsync -import io.imagekit.api.models.beta.v2.files.FileUploadParams -import io.imagekit.api.models.beta.v2.files.FileUploadResponse +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.multipartFormData +import io.imagekit.core.http.parseable +import io.imagekit.core.prepareAsync +import io.imagekit.models.beta.v2.files.FileUploadParams +import io.imagekit.models.beta.v2.files.FileUploadResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/cache/InvalidationServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/cache/InvalidationServiceAsync.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/cache/InvalidationServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/cache/InvalidationServiceAsync.kt index 2f50da90..0c13551e 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/cache/InvalidationServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/cache/InvalidationServiceAsync.kt @@ -1,14 +1,14 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.cache - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.cache.invalidation.InvalidationCreateParams -import io.imagekit.api.models.cache.invalidation.InvalidationCreateResponse -import io.imagekit.api.models.cache.invalidation.InvalidationGetParams -import io.imagekit.api.models.cache.invalidation.InvalidationGetResponse +package io.imagekit.services.async.cache + +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.cache.invalidation.InvalidationCreateParams +import io.imagekit.models.cache.invalidation.InvalidationCreateResponse +import io.imagekit.models.cache.invalidation.InvalidationGetParams +import io.imagekit.models.cache.invalidation.InvalidationGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/cache/InvalidationServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/cache/InvalidationServiceAsyncImpl.kt similarity index 83% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/cache/InvalidationServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/cache/InvalidationServiceAsyncImpl.kt index 8fb4fb67..90bda417 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/cache/InvalidationServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/cache/InvalidationServiceAsyncImpl.kt @@ -1,25 +1,25 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.cache +package io.imagekit.services.async.cache -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.json -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepareAsync -import io.imagekit.api.models.cache.invalidation.InvalidationCreateParams -import io.imagekit.api.models.cache.invalidation.InvalidationCreateResponse -import io.imagekit.api.models.cache.invalidation.InvalidationGetParams -import io.imagekit.api.models.cache.invalidation.InvalidationGetResponse +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.checkRequired +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.json +import io.imagekit.core.http.parseable +import io.imagekit.core.prepareAsync +import io.imagekit.models.cache.invalidation.InvalidationCreateParams +import io.imagekit.models.cache.invalidation.InvalidationCreateResponse +import io.imagekit.models.cache.invalidation.InvalidationGetParams +import io.imagekit.models.cache.invalidation.InvalidationGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/BulkServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/files/BulkServiceAsync.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/BulkServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/files/BulkServiceAsync.kt index fb6db5c8..6b06c7c8 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/BulkServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/files/BulkServiceAsync.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.files - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.files.bulk.BulkAddTagsParams -import io.imagekit.api.models.files.bulk.BulkAddTagsResponse -import io.imagekit.api.models.files.bulk.BulkDeleteParams -import io.imagekit.api.models.files.bulk.BulkDeleteResponse -import io.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams -import io.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse -import io.imagekit.api.models.files.bulk.BulkRemoveTagsParams -import io.imagekit.api.models.files.bulk.BulkRemoveTagsResponse +package io.imagekit.services.async.files + +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.files.bulk.BulkAddTagsParams +import io.imagekit.models.files.bulk.BulkAddTagsResponse +import io.imagekit.models.files.bulk.BulkDeleteParams +import io.imagekit.models.files.bulk.BulkDeleteResponse +import io.imagekit.models.files.bulk.BulkRemoveAiTagsParams +import io.imagekit.models.files.bulk.BulkRemoveAiTagsResponse +import io.imagekit.models.files.bulk.BulkRemoveTagsParams +import io.imagekit.models.files.bulk.BulkRemoveTagsResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/BulkServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/files/BulkServiceAsyncImpl.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/BulkServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/files/BulkServiceAsyncImpl.kt index 07518862..d248dad2 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/BulkServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/files/BulkServiceAsyncImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.files - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.json -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepareAsync -import io.imagekit.api.models.files.bulk.BulkAddTagsParams -import io.imagekit.api.models.files.bulk.BulkAddTagsResponse -import io.imagekit.api.models.files.bulk.BulkDeleteParams -import io.imagekit.api.models.files.bulk.BulkDeleteResponse -import io.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams -import io.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse -import io.imagekit.api.models.files.bulk.BulkRemoveTagsParams -import io.imagekit.api.models.files.bulk.BulkRemoveTagsResponse +package io.imagekit.services.async.files + +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.json +import io.imagekit.core.http.parseable +import io.imagekit.core.prepareAsync +import io.imagekit.models.files.bulk.BulkAddTagsParams +import io.imagekit.models.files.bulk.BulkAddTagsResponse +import io.imagekit.models.files.bulk.BulkDeleteParams +import io.imagekit.models.files.bulk.BulkDeleteResponse +import io.imagekit.models.files.bulk.BulkRemoveAiTagsParams +import io.imagekit.models.files.bulk.BulkRemoveAiTagsResponse +import io.imagekit.models.files.bulk.BulkRemoveTagsParams +import io.imagekit.models.files.bulk.BulkRemoveTagsResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/MetadataServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/files/MetadataServiceAsync.kt similarity index 93% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/MetadataServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/files/MetadataServiceAsync.kt index e6dccc4d..f6243cce 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/MetadataServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/files/MetadataServiceAsync.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.files - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.files.Metadata -import io.imagekit.api.models.files.metadata.MetadataGetFromUrlParams -import io.imagekit.api.models.files.metadata.MetadataGetParams +package io.imagekit.services.async.files + +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.files.Metadata +import io.imagekit.models.files.metadata.MetadataGetFromUrlParams +import io.imagekit.models.files.metadata.MetadataGetParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/MetadataServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/files/MetadataServiceAsyncImpl.kt similarity index 84% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/MetadataServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/files/MetadataServiceAsyncImpl.kt index 218afe26..2de71490 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/MetadataServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/files/MetadataServiceAsyncImpl.kt @@ -1,23 +1,23 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.files +package io.imagekit.services.async.files -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepareAsync -import io.imagekit.api.models.files.Metadata -import io.imagekit.api.models.files.metadata.MetadataGetFromUrlParams -import io.imagekit.api.models.files.metadata.MetadataGetParams +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.checkRequired +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.parseable +import io.imagekit.core.prepareAsync +import io.imagekit.models.files.Metadata +import io.imagekit.models.files.metadata.MetadataGetFromUrlParams +import io.imagekit.models.files.metadata.MetadataGetParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/VersionServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/files/VersionServiceAsync.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/VersionServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/files/VersionServiceAsync.kt index 3559bd31..867b3b00 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/VersionServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/files/VersionServiceAsync.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.files - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.files.File -import io.imagekit.api.models.files.versions.VersionDeleteParams -import io.imagekit.api.models.files.versions.VersionDeleteResponse -import io.imagekit.api.models.files.versions.VersionGetParams -import io.imagekit.api.models.files.versions.VersionListParams -import io.imagekit.api.models.files.versions.VersionRestoreParams +package io.imagekit.services.async.files + +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.files.File +import io.imagekit.models.files.versions.VersionDeleteParams +import io.imagekit.models.files.versions.VersionDeleteResponse +import io.imagekit.models.files.versions.VersionGetParams +import io.imagekit.models.files.versions.VersionListParams +import io.imagekit.models.files.versions.VersionRestoreParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/VersionServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/files/VersionServiceAsyncImpl.kt similarity index 89% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/VersionServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/files/VersionServiceAsyncImpl.kt index c552cce0..9412ebdc 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/files/VersionServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/files/VersionServiceAsyncImpl.kt @@ -1,27 +1,27 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.files - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.json -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepareAsync -import io.imagekit.api.models.files.File -import io.imagekit.api.models.files.versions.VersionDeleteParams -import io.imagekit.api.models.files.versions.VersionDeleteResponse -import io.imagekit.api.models.files.versions.VersionGetParams -import io.imagekit.api.models.files.versions.VersionListParams -import io.imagekit.api.models.files.versions.VersionRestoreParams +package io.imagekit.services.async.files + +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.checkRequired +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.json +import io.imagekit.core.http.parseable +import io.imagekit.core.prepareAsync +import io.imagekit.models.files.File +import io.imagekit.models.files.versions.VersionDeleteParams +import io.imagekit.models.files.versions.VersionDeleteResponse +import io.imagekit.models.files.versions.VersionGetParams +import io.imagekit.models.files.versions.VersionListParams +import io.imagekit.models.files.versions.VersionRestoreParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/folders/JobServiceAsync.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/folders/JobServiceAsync.kt similarity index 92% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/folders/JobServiceAsync.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/folders/JobServiceAsync.kt index d3f41024..a11340cc 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/folders/JobServiceAsync.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/folders/JobServiceAsync.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.folders +package io.imagekit.services.async.folders -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.folders.job.JobGetParams -import io.imagekit.api.models.folders.job.JobGetResponse +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.folders.job.JobGetParams +import io.imagekit.models.folders.job.JobGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/folders/JobServiceAsyncImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/folders/JobServiceAsyncImpl.kt similarity index 79% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/folders/JobServiceAsyncImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/async/folders/JobServiceAsyncImpl.kt index ae7703ca..1c5fb3f6 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/async/folders/JobServiceAsyncImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/async/folders/JobServiceAsyncImpl.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.folders +package io.imagekit.services.async.folders -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepareAsync -import io.imagekit.api.models.folders.job.JobGetParams -import io.imagekit.api.models.folders.job.JobGetResponse +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.checkRequired +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.parseable +import io.imagekit.core.prepareAsync +import io.imagekit.models.folders.job.JobGetParams +import io.imagekit.models.folders.job.JobGetResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AccountService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/AccountService.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AccountService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/AccountService.kt index 95795703..e58140f1 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AccountService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/AccountService.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking +package io.imagekit.services.blocking -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.services.blocking.accounts.OriginService -import io.imagekit.api.services.blocking.accounts.UrlEndpointService -import io.imagekit.api.services.blocking.accounts.UsageService +import io.imagekit.core.ClientOptions +import io.imagekit.services.blocking.accounts.OriginService +import io.imagekit.services.blocking.accounts.UrlEndpointService +import io.imagekit.services.blocking.accounts.UsageService import java.util.function.Consumer interface AccountService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AccountServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/AccountServiceImpl.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AccountServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/AccountServiceImpl.kt index 5c10a8cf..d9a8800b 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AccountServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/AccountServiceImpl.kt @@ -1,14 +1,14 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.services.blocking.accounts.OriginService -import io.imagekit.api.services.blocking.accounts.OriginServiceImpl -import io.imagekit.api.services.blocking.accounts.UrlEndpointService -import io.imagekit.api.services.blocking.accounts.UrlEndpointServiceImpl -import io.imagekit.api.services.blocking.accounts.UsageService -import io.imagekit.api.services.blocking.accounts.UsageServiceImpl +package io.imagekit.services.blocking + +import io.imagekit.core.ClientOptions +import io.imagekit.services.blocking.accounts.OriginService +import io.imagekit.services.blocking.accounts.OriginServiceImpl +import io.imagekit.services.blocking.accounts.UrlEndpointService +import io.imagekit.services.blocking.accounts.UrlEndpointServiceImpl +import io.imagekit.services.blocking.accounts.UsageService +import io.imagekit.services.blocking.accounts.UsageServiceImpl import java.util.function.Consumer class AccountServiceImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AssetService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/AssetService.kt similarity index 90% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AssetService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/AssetService.kt index 508d8533..4868f52a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AssetService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/AssetService.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking +package io.imagekit.services.blocking import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.assets.AssetListParams -import io.imagekit.api.models.assets.AssetListResponse +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.assets.AssetListParams +import io.imagekit.models.assets.AssetListResponse import java.util.function.Consumer interface AssetService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AssetServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/AssetServiceImpl.kt similarity index 77% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AssetServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/AssetServiceImpl.kt index 4626620e..772436e5 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/AssetServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/AssetServiceImpl.kt @@ -1,21 +1,21 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking +package io.imagekit.services.blocking -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepare -import io.imagekit.api.models.assets.AssetListParams -import io.imagekit.api.models.assets.AssetListResponse +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.parseable +import io.imagekit.core.prepare +import io.imagekit.models.assets.AssetListParams +import io.imagekit.models.assets.AssetListResponse import java.util.function.Consumer class AssetServiceImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/BetaService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/BetaService.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/BetaService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/BetaService.kt index b090eb03..3768664a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/BetaService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/BetaService.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking +package io.imagekit.services.blocking -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.services.blocking.beta.V2Service +import io.imagekit.core.ClientOptions +import io.imagekit.services.blocking.beta.V2Service import java.util.function.Consumer interface BetaService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/BetaServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/BetaServiceImpl.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/BetaServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/BetaServiceImpl.kt index 5953a110..8f6a291b 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/BetaServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/BetaServiceImpl.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking +package io.imagekit.services.blocking -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.services.blocking.beta.V2Service -import io.imagekit.api.services.blocking.beta.V2ServiceImpl +import io.imagekit.core.ClientOptions +import io.imagekit.services.blocking.beta.V2Service +import io.imagekit.services.blocking.beta.V2ServiceImpl import java.util.function.Consumer class BetaServiceImpl internal constructor(private val clientOptions: ClientOptions) : BetaService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CacheService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/CacheService.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CacheService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/CacheService.kt index f92ffbe5..e6c945cd 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CacheService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/CacheService.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking +package io.imagekit.services.blocking -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.services.blocking.cache.InvalidationService +import io.imagekit.core.ClientOptions +import io.imagekit.services.blocking.cache.InvalidationService import java.util.function.Consumer interface CacheService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CacheServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/CacheServiceImpl.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CacheServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/CacheServiceImpl.kt index 4df61fe6..93610b0a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CacheServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/CacheServiceImpl.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking +package io.imagekit.services.blocking -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.services.blocking.cache.InvalidationService -import io.imagekit.api.services.blocking.cache.InvalidationServiceImpl +import io.imagekit.core.ClientOptions +import io.imagekit.services.blocking.cache.InvalidationService +import io.imagekit.services.blocking.cache.InvalidationServiceImpl import java.util.function.Consumer class CacheServiceImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CustomMetadataFieldService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/CustomMetadataFieldService.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CustomMetadataFieldService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/CustomMetadataFieldService.kt index 19bcb0dc..c00aa0c4 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CustomMetadataFieldService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/CustomMetadataFieldService.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking +package io.imagekit.services.blocking import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.custommetadatafields.CustomMetadataField -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.custommetadatafields.CustomMetadataField +import io.imagekit.models.custommetadatafields.CustomMetadataFieldCreateParams +import io.imagekit.models.custommetadatafields.CustomMetadataFieldDeleteParams +import io.imagekit.models.custommetadatafields.CustomMetadataFieldDeleteResponse +import io.imagekit.models.custommetadatafields.CustomMetadataFieldListParams +import io.imagekit.models.custommetadatafields.CustomMetadataFieldUpdateParams import java.util.function.Consumer interface CustomMetadataFieldService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CustomMetadataFieldServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/CustomMetadataFieldServiceImpl.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CustomMetadataFieldServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/CustomMetadataFieldServiceImpl.kt index bbb5b94a..607d4b96 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/CustomMetadataFieldServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/CustomMetadataFieldServiceImpl.kt @@ -1,27 +1,27 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.json -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepare -import io.imagekit.api.models.custommetadatafields.CustomMetadataField -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteParams -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldDeleteResponse -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +package io.imagekit.services.blocking + +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.checkRequired +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.json +import io.imagekit.core.http.parseable +import io.imagekit.core.prepare +import io.imagekit.models.custommetadatafields.CustomMetadataField +import io.imagekit.models.custommetadatafields.CustomMetadataFieldCreateParams +import io.imagekit.models.custommetadatafields.CustomMetadataFieldDeleteParams +import io.imagekit.models.custommetadatafields.CustomMetadataFieldDeleteResponse +import io.imagekit.models.custommetadatafields.CustomMetadataFieldListParams +import io.imagekit.models.custommetadatafields.CustomMetadataFieldUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FileService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/FileService.kt similarity index 92% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FileService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/FileService.kt index cab5f57e..f08afc49 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FileService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/FileService.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking +package io.imagekit.services.blocking import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.files.File -import io.imagekit.api.models.files.FileCopyParams -import io.imagekit.api.models.files.FileCopyResponse -import io.imagekit.api.models.files.FileDeleteParams -import io.imagekit.api.models.files.FileGetParams -import io.imagekit.api.models.files.FileMoveParams -import io.imagekit.api.models.files.FileMoveResponse -import io.imagekit.api.models.files.FileRenameParams -import io.imagekit.api.models.files.FileRenameResponse -import io.imagekit.api.models.files.FileUpdateParams -import io.imagekit.api.models.files.FileUpdateResponse -import io.imagekit.api.models.files.FileUploadParams -import io.imagekit.api.models.files.FileUploadResponse -import io.imagekit.api.services.blocking.files.BulkService -import io.imagekit.api.services.blocking.files.MetadataService -import io.imagekit.api.services.blocking.files.VersionService +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.files.File +import io.imagekit.models.files.FileCopyParams +import io.imagekit.models.files.FileCopyResponse +import io.imagekit.models.files.FileDeleteParams +import io.imagekit.models.files.FileGetParams +import io.imagekit.models.files.FileMoveParams +import io.imagekit.models.files.FileMoveResponse +import io.imagekit.models.files.FileRenameParams +import io.imagekit.models.files.FileRenameResponse +import io.imagekit.models.files.FileUpdateParams +import io.imagekit.models.files.FileUpdateResponse +import io.imagekit.models.files.FileUploadParams +import io.imagekit.models.files.FileUploadResponse +import io.imagekit.services.blocking.files.BulkService +import io.imagekit.services.blocking.files.MetadataService +import io.imagekit.services.blocking.files.VersionService import java.util.function.Consumer interface FileService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FileServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/FileServiceImpl.kt similarity index 87% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FileServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/FileServiceImpl.kt index d8c59a86..fd6c6deb 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FileServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/FileServiceImpl.kt @@ -1,42 +1,42 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.handlers.emptyHandler -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.json -import io.imagekit.api.core.http.multipartFormData -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepare -import io.imagekit.api.models.files.File -import io.imagekit.api.models.files.FileCopyParams -import io.imagekit.api.models.files.FileCopyResponse -import io.imagekit.api.models.files.FileDeleteParams -import io.imagekit.api.models.files.FileGetParams -import io.imagekit.api.models.files.FileMoveParams -import io.imagekit.api.models.files.FileMoveResponse -import io.imagekit.api.models.files.FileRenameParams -import io.imagekit.api.models.files.FileRenameResponse -import io.imagekit.api.models.files.FileUpdateParams -import io.imagekit.api.models.files.FileUpdateResponse -import io.imagekit.api.models.files.FileUploadParams -import io.imagekit.api.models.files.FileUploadResponse -import io.imagekit.api.services.blocking.files.BulkService -import io.imagekit.api.services.blocking.files.BulkServiceImpl -import io.imagekit.api.services.blocking.files.MetadataService -import io.imagekit.api.services.blocking.files.MetadataServiceImpl -import io.imagekit.api.services.blocking.files.VersionService -import io.imagekit.api.services.blocking.files.VersionServiceImpl +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.multipartFormData +import io.imagekit.core.http.parseable +import io.imagekit.core.prepare +import io.imagekit.models.files.File +import io.imagekit.models.files.FileCopyParams +import io.imagekit.models.files.FileCopyResponse +import io.imagekit.models.files.FileDeleteParams +import io.imagekit.models.files.FileGetParams +import io.imagekit.models.files.FileMoveParams +import io.imagekit.models.files.FileMoveResponse +import io.imagekit.models.files.FileRenameParams +import io.imagekit.models.files.FileRenameResponse +import io.imagekit.models.files.FileUpdateParams +import io.imagekit.models.files.FileUpdateResponse +import io.imagekit.models.files.FileUploadParams +import io.imagekit.models.files.FileUploadResponse +import io.imagekit.services.blocking.files.BulkService +import io.imagekit.services.blocking.files.BulkServiceImpl +import io.imagekit.services.blocking.files.MetadataService +import io.imagekit.services.blocking.files.MetadataServiceImpl +import io.imagekit.services.blocking.files.VersionService +import io.imagekit.services.blocking.files.VersionServiceImpl import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FolderService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/FolderService.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FolderService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/FolderService.kt index 7bb974bf..07819785 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FolderService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/FolderService.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking +package io.imagekit.services.blocking import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.folders.FolderCopyParams -import io.imagekit.api.models.folders.FolderCopyResponse -import io.imagekit.api.models.folders.FolderCreateParams -import io.imagekit.api.models.folders.FolderCreateResponse -import io.imagekit.api.models.folders.FolderDeleteParams -import io.imagekit.api.models.folders.FolderDeleteResponse -import io.imagekit.api.models.folders.FolderMoveParams -import io.imagekit.api.models.folders.FolderMoveResponse -import io.imagekit.api.models.folders.FolderRenameParams -import io.imagekit.api.models.folders.FolderRenameResponse -import io.imagekit.api.services.blocking.folders.JobService +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.folders.FolderCopyParams +import io.imagekit.models.folders.FolderCopyResponse +import io.imagekit.models.folders.FolderCreateParams +import io.imagekit.models.folders.FolderCreateResponse +import io.imagekit.models.folders.FolderDeleteParams +import io.imagekit.models.folders.FolderDeleteResponse +import io.imagekit.models.folders.FolderMoveParams +import io.imagekit.models.folders.FolderMoveResponse +import io.imagekit.models.folders.FolderRenameParams +import io.imagekit.models.folders.FolderRenameResponse +import io.imagekit.services.blocking.folders.JobService import java.util.function.Consumer interface FolderService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FolderServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/FolderServiceImpl.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FolderServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/FolderServiceImpl.kt index 1446fa71..329f91f4 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/FolderServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/FolderServiceImpl.kt @@ -1,32 +1,32 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.json -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepare -import io.imagekit.api.models.folders.FolderCopyParams -import io.imagekit.api.models.folders.FolderCopyResponse -import io.imagekit.api.models.folders.FolderCreateParams -import io.imagekit.api.models.folders.FolderCreateResponse -import io.imagekit.api.models.folders.FolderDeleteParams -import io.imagekit.api.models.folders.FolderDeleteResponse -import io.imagekit.api.models.folders.FolderMoveParams -import io.imagekit.api.models.folders.FolderMoveResponse -import io.imagekit.api.models.folders.FolderRenameParams -import io.imagekit.api.models.folders.FolderRenameResponse -import io.imagekit.api.services.blocking.folders.JobService -import io.imagekit.api.services.blocking.folders.JobServiceImpl +package io.imagekit.services.blocking + +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.json +import io.imagekit.core.http.parseable +import io.imagekit.core.prepare +import io.imagekit.models.folders.FolderCopyParams +import io.imagekit.models.folders.FolderCopyResponse +import io.imagekit.models.folders.FolderCreateParams +import io.imagekit.models.folders.FolderCreateResponse +import io.imagekit.models.folders.FolderDeleteParams +import io.imagekit.models.folders.FolderDeleteResponse +import io.imagekit.models.folders.FolderMoveParams +import io.imagekit.models.folders.FolderMoveResponse +import io.imagekit.models.folders.FolderRenameParams +import io.imagekit.models.folders.FolderRenameResponse +import io.imagekit.services.blocking.folders.JobService +import io.imagekit.services.blocking.folders.JobServiceImpl import java.util.function.Consumer class FolderServiceImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/SavedExtensionService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/SavedExtensionService.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/SavedExtensionService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/SavedExtensionService.kt index edbd1687..b26f71bc 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/SavedExtensionService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/SavedExtensionService.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking +package io.imagekit.services.blocking import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.SavedExtension -import io.imagekit.api.models.savedextensions.SavedExtensionCreateParams -import io.imagekit.api.models.savedextensions.SavedExtensionDeleteParams -import io.imagekit.api.models.savedextensions.SavedExtensionGetParams -import io.imagekit.api.models.savedextensions.SavedExtensionListParams -import io.imagekit.api.models.savedextensions.SavedExtensionUpdateParams +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.SavedExtension +import io.imagekit.models.savedextensions.SavedExtensionCreateParams +import io.imagekit.models.savedextensions.SavedExtensionDeleteParams +import io.imagekit.models.savedextensions.SavedExtensionGetParams +import io.imagekit.models.savedextensions.SavedExtensionListParams +import io.imagekit.models.savedextensions.SavedExtensionUpdateParams import java.util.function.Consumer interface SavedExtensionService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/SavedExtensionServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/SavedExtensionServiceImpl.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/SavedExtensionServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/SavedExtensionServiceImpl.kt index 251a44ad..db009aac 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/SavedExtensionServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/SavedExtensionServiceImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.handlers.emptyHandler -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.json -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepare -import io.imagekit.api.models.SavedExtension -import io.imagekit.api.models.savedextensions.SavedExtensionCreateParams -import io.imagekit.api.models.savedextensions.SavedExtensionDeleteParams -import io.imagekit.api.models.savedextensions.SavedExtensionGetParams -import io.imagekit.api.models.savedextensions.SavedExtensionListParams -import io.imagekit.api.models.savedextensions.SavedExtensionUpdateParams +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.SavedExtension +import io.imagekit.models.savedextensions.SavedExtensionCreateParams +import io.imagekit.models.savedextensions.SavedExtensionDeleteParams +import io.imagekit.models.savedextensions.SavedExtensionGetParams +import io.imagekit.models.savedextensions.SavedExtensionListParams +import io.imagekit.models.savedextensions.SavedExtensionUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/WebhookService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/WebhookService.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/WebhookService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/WebhookService.kt index 92a8edde..5953f0d6 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/WebhookService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/WebhookService.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.UnwrapWebhookParams -import io.imagekit.api.errors.ImageKitInvalidDataException -import io.imagekit.api.errors.ImageKitWebhookException -import io.imagekit.api.models.webhooks.UnsafeUnwrapWebhookEvent -import io.imagekit.api.models.webhooks.UnwrapWebhookEvent +package io.imagekit.services.blocking + +import io.imagekit.core.ClientOptions +import io.imagekit.core.UnwrapWebhookParams +import io.imagekit.errors.ImageKitInvalidDataException +import io.imagekit.errors.ImageKitWebhookException +import io.imagekit.models.webhooks.UnsafeUnwrapWebhookEvent +import io.imagekit.models.webhooks.UnwrapWebhookEvent import java.util.function.Consumer interface WebhookService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/WebhookServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/WebhookServiceImpl.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/WebhookServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/WebhookServiceImpl.kt index f78b1220..c5152a7c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/WebhookServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/WebhookServiceImpl.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking +package io.imagekit.services.blocking import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.standardwebhooks.Webhook import com.standardwebhooks.exceptions.WebhookVerificationException -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.UnwrapWebhookParams -import io.imagekit.api.core.checkRequired -import io.imagekit.api.errors.ImageKitInvalidDataException -import io.imagekit.api.errors.ImageKitWebhookException -import io.imagekit.api.models.webhooks.UnsafeUnwrapWebhookEvent -import io.imagekit.api.models.webhooks.UnwrapWebhookEvent +import io.imagekit.core.ClientOptions +import io.imagekit.core.UnwrapWebhookParams +import io.imagekit.core.checkRequired +import io.imagekit.errors.ImageKitInvalidDataException +import io.imagekit.errors.ImageKitWebhookException +import io.imagekit.models.webhooks.UnsafeUnwrapWebhookEvent +import io.imagekit.models.webhooks.UnwrapWebhookEvent import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/OriginService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/OriginService.kt similarity index 96% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/OriginService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/OriginService.kt index 3c21f6c8..12bd252f 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/OriginService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/OriginService.kt @@ -1,19 +1,19 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.accounts +package io.imagekit.services.blocking.accounts import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.accounts.origins.OriginCreateParams -import io.imagekit.api.models.accounts.origins.OriginDeleteParams -import io.imagekit.api.models.accounts.origins.OriginGetParams -import io.imagekit.api.models.accounts.origins.OriginListParams -import io.imagekit.api.models.accounts.origins.OriginRequest -import io.imagekit.api.models.accounts.origins.OriginResponse -import io.imagekit.api.models.accounts.origins.OriginUpdateParams +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.accounts.origins.OriginCreateParams +import io.imagekit.models.accounts.origins.OriginDeleteParams +import io.imagekit.models.accounts.origins.OriginGetParams +import io.imagekit.models.accounts.origins.OriginListParams +import io.imagekit.models.accounts.origins.OriginRequest +import io.imagekit.models.accounts.origins.OriginResponse +import io.imagekit.models.accounts.origins.OriginUpdateParams import java.util.function.Consumer interface OriginService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/OriginServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/OriginServiceImpl.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/OriginServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/OriginServiceImpl.kt index d7e56549..06ce6280 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/OriginServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/OriginServiceImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.accounts - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.handlers.emptyHandler -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.json -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepare -import io.imagekit.api.models.accounts.origins.OriginCreateParams -import io.imagekit.api.models.accounts.origins.OriginDeleteParams -import io.imagekit.api.models.accounts.origins.OriginGetParams -import io.imagekit.api.models.accounts.origins.OriginListParams -import io.imagekit.api.models.accounts.origins.OriginResponse -import io.imagekit.api.models.accounts.origins.OriginUpdateParams +package io.imagekit.services.blocking.accounts + +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.accounts.origins.OriginCreateParams +import io.imagekit.models.accounts.origins.OriginDeleteParams +import io.imagekit.models.accounts.origins.OriginGetParams +import io.imagekit.models.accounts.origins.OriginListParams +import io.imagekit.models.accounts.origins.OriginResponse +import io.imagekit.models.accounts.origins.OriginUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UrlEndpointService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UrlEndpointService.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UrlEndpointService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UrlEndpointService.kt index a15b85a8..e2c75f51 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UrlEndpointService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UrlEndpointService.kt @@ -1,19 +1,19 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.accounts +package io.imagekit.services.blocking.accounts import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +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.accounts.urlendpoints.UrlEndpointCreateParams +import io.imagekit.models.accounts.urlendpoints.UrlEndpointDeleteParams +import io.imagekit.models.accounts.urlendpoints.UrlEndpointGetParams +import io.imagekit.models.accounts.urlendpoints.UrlEndpointListParams +import io.imagekit.models.accounts.urlendpoints.UrlEndpointRequest +import io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse +import io.imagekit.models.accounts.urlendpoints.UrlEndpointUpdateParams import java.util.function.Consumer interface UrlEndpointService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UrlEndpointServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UrlEndpointServiceImpl.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UrlEndpointServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UrlEndpointServiceImpl.kt index be5dd00a..9efc064d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UrlEndpointServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UrlEndpointServiceImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.accounts - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.handlers.emptyHandler -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.json -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepare -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointCreateParams -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointDeleteParams -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointGetParams -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointListParams -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointResponse -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +package io.imagekit.services.blocking.accounts + +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.accounts.urlendpoints.UrlEndpointCreateParams +import io.imagekit.models.accounts.urlendpoints.UrlEndpointDeleteParams +import io.imagekit.models.accounts.urlendpoints.UrlEndpointGetParams +import io.imagekit.models.accounts.urlendpoints.UrlEndpointListParams +import io.imagekit.models.accounts.urlendpoints.UrlEndpointResponse +import io.imagekit.models.accounts.urlendpoints.UrlEndpointUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UsageService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UsageService.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UsageService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UsageService.kt index 14739d50..62581a91 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UsageService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UsageService.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.accounts +package io.imagekit.services.blocking.accounts import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.accounts.usage.UsageGetParams -import io.imagekit.api.models.accounts.usage.UsageGetResponse +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.accounts.usage.UsageGetParams +import io.imagekit.models.accounts.usage.UsageGetResponse import java.util.function.Consumer interface UsageService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UsageServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UsageServiceImpl.kt similarity index 76% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UsageServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UsageServiceImpl.kt index 79e454f3..7e96862d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/accounts/UsageServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/accounts/UsageServiceImpl.kt @@ -1,21 +1,21 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.accounts +package io.imagekit.services.blocking.accounts -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepare -import io.imagekit.api.models.accounts.usage.UsageGetParams -import io.imagekit.api.models.accounts.usage.UsageGetResponse +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.parseable +import io.imagekit.core.prepare +import io.imagekit.models.accounts.usage.UsageGetParams +import io.imagekit.models.accounts.usage.UsageGetResponse import java.util.function.Consumer class UsageServiceImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/V2Service.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/beta/V2Service.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/V2Service.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/beta/V2Service.kt index f8c12520..db4186c7 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/V2Service.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/beta/V2Service.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.beta +package io.imagekit.services.blocking.beta -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.services.blocking.beta.v2.FileService +import io.imagekit.core.ClientOptions +import io.imagekit.services.blocking.beta.v2.FileService import java.util.function.Consumer interface V2Service { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/V2ServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/beta/V2ServiceImpl.kt similarity index 85% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/V2ServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/beta/V2ServiceImpl.kt index d6dece1f..9691794a 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/V2ServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/beta/V2ServiceImpl.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.beta +package io.imagekit.services.blocking.beta -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.services.blocking.beta.v2.FileService -import io.imagekit.api.services.blocking.beta.v2.FileServiceImpl +import io.imagekit.core.ClientOptions +import io.imagekit.services.blocking.beta.v2.FileService +import io.imagekit.services.blocking.beta.v2.FileServiceImpl import java.util.function.Consumer class V2ServiceImpl internal constructor(private val clientOptions: ClientOptions) : V2Service { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/v2/FileService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/beta/v2/FileService.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/v2/FileService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/beta/v2/FileService.kt index a778b9dd..499eb3d3 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/v2/FileService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/beta/v2/FileService.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.beta.v2 +package io.imagekit.services.blocking.beta.v2 import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.beta.v2.files.FileUploadParams -import io.imagekit.api.models.beta.v2.files.FileUploadResponse +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.beta.v2.files.FileUploadParams +import io.imagekit.models.beta.v2.files.FileUploadResponse import java.util.function.Consumer interface FileService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/v2/FileServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/beta/v2/FileServiceImpl.kt similarity index 77% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/v2/FileServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/beta/v2/FileServiceImpl.kt index 5d5b0644..8fddfcf8 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/beta/v2/FileServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/beta/v2/FileServiceImpl.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.beta.v2 +package io.imagekit.services.blocking.beta.v2 -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.multipartFormData -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepare -import io.imagekit.api.models.beta.v2.files.FileUploadParams -import io.imagekit.api.models.beta.v2.files.FileUploadResponse +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.multipartFormData +import io.imagekit.core.http.parseable +import io.imagekit.core.prepare +import io.imagekit.models.beta.v2.files.FileUploadParams +import io.imagekit.models.beta.v2.files.FileUploadResponse import java.util.function.Consumer class FileServiceImpl internal constructor(private val clientOptions: ClientOptions) : FileService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/cache/InvalidationService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/cache/InvalidationService.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/cache/InvalidationService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/cache/InvalidationService.kt index a647400d..92604359 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/cache/InvalidationService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/cache/InvalidationService.kt @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.cache +package io.imagekit.services.blocking.cache import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.cache.invalidation.InvalidationCreateParams -import io.imagekit.api.models.cache.invalidation.InvalidationCreateResponse -import io.imagekit.api.models.cache.invalidation.InvalidationGetParams -import io.imagekit.api.models.cache.invalidation.InvalidationGetResponse +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.cache.invalidation.InvalidationCreateParams +import io.imagekit.models.cache.invalidation.InvalidationCreateResponse +import io.imagekit.models.cache.invalidation.InvalidationGetParams +import io.imagekit.models.cache.invalidation.InvalidationGetResponse import java.util.function.Consumer interface InvalidationService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/cache/InvalidationServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/cache/InvalidationServiceImpl.kt similarity index 81% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/cache/InvalidationServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/cache/InvalidationServiceImpl.kt index b1aeeacb..100cc88d 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/cache/InvalidationServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/cache/InvalidationServiceImpl.kt @@ -1,25 +1,25 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.cache +package io.imagekit.services.blocking.cache -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.json -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepare -import io.imagekit.api.models.cache.invalidation.InvalidationCreateParams -import io.imagekit.api.models.cache.invalidation.InvalidationCreateResponse -import io.imagekit.api.models.cache.invalidation.InvalidationGetParams -import io.imagekit.api.models.cache.invalidation.InvalidationGetResponse +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.checkRequired +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.json +import io.imagekit.core.http.parseable +import io.imagekit.core.prepare +import io.imagekit.models.cache.invalidation.InvalidationCreateParams +import io.imagekit.models.cache.invalidation.InvalidationCreateResponse +import io.imagekit.models.cache.invalidation.InvalidationGetParams +import io.imagekit.models.cache.invalidation.InvalidationGetResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/BulkService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/files/BulkService.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/BulkService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/files/BulkService.kt index aa4306b1..10ee318c 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/BulkService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/files/BulkService.kt @@ -1,19 +1,19 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.files +package io.imagekit.services.blocking.files import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.files.bulk.BulkAddTagsParams -import io.imagekit.api.models.files.bulk.BulkAddTagsResponse -import io.imagekit.api.models.files.bulk.BulkDeleteParams -import io.imagekit.api.models.files.bulk.BulkDeleteResponse -import io.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams -import io.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse -import io.imagekit.api.models.files.bulk.BulkRemoveTagsParams -import io.imagekit.api.models.files.bulk.BulkRemoveTagsResponse +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.files.bulk.BulkAddTagsParams +import io.imagekit.models.files.bulk.BulkAddTagsResponse +import io.imagekit.models.files.bulk.BulkDeleteParams +import io.imagekit.models.files.bulk.BulkDeleteResponse +import io.imagekit.models.files.bulk.BulkRemoveAiTagsParams +import io.imagekit.models.files.bulk.BulkRemoveAiTagsResponse +import io.imagekit.models.files.bulk.BulkRemoveTagsParams +import io.imagekit.models.files.bulk.BulkRemoveTagsResponse import java.util.function.Consumer interface BulkService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/BulkServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/files/BulkServiceImpl.kt similarity index 86% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/BulkServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/files/BulkServiceImpl.kt index e2fc23d9..ca2a53a3 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/BulkServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/files/BulkServiceImpl.kt @@ -1,28 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.files - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.json -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepare -import io.imagekit.api.models.files.bulk.BulkAddTagsParams -import io.imagekit.api.models.files.bulk.BulkAddTagsResponse -import io.imagekit.api.models.files.bulk.BulkDeleteParams -import io.imagekit.api.models.files.bulk.BulkDeleteResponse -import io.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams -import io.imagekit.api.models.files.bulk.BulkRemoveAiTagsResponse -import io.imagekit.api.models.files.bulk.BulkRemoveTagsParams -import io.imagekit.api.models.files.bulk.BulkRemoveTagsResponse +package io.imagekit.services.blocking.files + +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.json +import io.imagekit.core.http.parseable +import io.imagekit.core.prepare +import io.imagekit.models.files.bulk.BulkAddTagsParams +import io.imagekit.models.files.bulk.BulkAddTagsResponse +import io.imagekit.models.files.bulk.BulkDeleteParams +import io.imagekit.models.files.bulk.BulkDeleteResponse +import io.imagekit.models.files.bulk.BulkRemoveAiTagsParams +import io.imagekit.models.files.bulk.BulkRemoveAiTagsResponse +import io.imagekit.models.files.bulk.BulkRemoveTagsParams +import io.imagekit.models.files.bulk.BulkRemoveTagsResponse import java.util.function.Consumer class BulkServiceImpl internal constructor(private val clientOptions: ClientOptions) : BulkService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/MetadataService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/files/MetadataService.kt similarity index 92% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/MetadataService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/files/MetadataService.kt index 38a25136..9d615576 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/MetadataService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/files/MetadataService.kt @@ -1,14 +1,14 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.files +package io.imagekit.services.blocking.files import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.files.Metadata -import io.imagekit.api.models.files.metadata.MetadataGetFromUrlParams -import io.imagekit.api.models.files.metadata.MetadataGetParams +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.files.Metadata +import io.imagekit.models.files.metadata.MetadataGetFromUrlParams +import io.imagekit.models.files.metadata.MetadataGetParams import java.util.function.Consumer interface MetadataService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/MetadataServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/files/MetadataServiceImpl.kt similarity index 83% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/MetadataServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/files/MetadataServiceImpl.kt index e7715008..6cfeb06f 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/MetadataServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/files/MetadataServiceImpl.kt @@ -1,23 +1,23 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.files +package io.imagekit.services.blocking.files -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepare -import io.imagekit.api.models.files.Metadata -import io.imagekit.api.models.files.metadata.MetadataGetFromUrlParams -import io.imagekit.api.models.files.metadata.MetadataGetParams +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.checkRequired +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.parseable +import io.imagekit.core.prepare +import io.imagekit.models.files.Metadata +import io.imagekit.models.files.metadata.MetadataGetFromUrlParams +import io.imagekit.models.files.metadata.MetadataGetParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/VersionService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/files/VersionService.kt similarity index 94% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/VersionService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/files/VersionService.kt index b4128f16..846dfc83 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/VersionService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/files/VersionService.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.files +package io.imagekit.services.blocking.files import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.files.File -import io.imagekit.api.models.files.versions.VersionDeleteParams -import io.imagekit.api.models.files.versions.VersionDeleteResponse -import io.imagekit.api.models.files.versions.VersionGetParams -import io.imagekit.api.models.files.versions.VersionListParams -import io.imagekit.api.models.files.versions.VersionRestoreParams +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.files.File +import io.imagekit.models.files.versions.VersionDeleteParams +import io.imagekit.models.files.versions.VersionDeleteResponse +import io.imagekit.models.files.versions.VersionGetParams +import io.imagekit.models.files.versions.VersionListParams +import io.imagekit.models.files.versions.VersionRestoreParams import java.util.function.Consumer interface VersionService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/VersionServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/files/VersionServiceImpl.kt similarity index 88% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/VersionServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/files/VersionServiceImpl.kt index 9dc323e7..ba246bfb 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/files/VersionServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/files/VersionServiceImpl.kt @@ -1,27 +1,27 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.files - -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.json -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepare -import io.imagekit.api.models.files.File -import io.imagekit.api.models.files.versions.VersionDeleteParams -import io.imagekit.api.models.files.versions.VersionDeleteResponse -import io.imagekit.api.models.files.versions.VersionGetParams -import io.imagekit.api.models.files.versions.VersionListParams -import io.imagekit.api.models.files.versions.VersionRestoreParams +package io.imagekit.services.blocking.files + +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.checkRequired +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.json +import io.imagekit.core.http.parseable +import io.imagekit.core.prepare +import io.imagekit.models.files.File +import io.imagekit.models.files.versions.VersionDeleteParams +import io.imagekit.models.files.versions.VersionDeleteResponse +import io.imagekit.models.files.versions.VersionGetParams +import io.imagekit.models.files.versions.VersionListParams +import io.imagekit.models.files.versions.VersionRestoreParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/folders/JobService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/folders/JobService.kt similarity index 91% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/folders/JobService.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/folders/JobService.kt index a72f4d6f..0d77b109 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/folders/JobService.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/folders/JobService.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.folders +package io.imagekit.services.blocking.folders import com.google.errorprone.annotations.MustBeClosed -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.models.folders.job.JobGetParams -import io.imagekit.api.models.folders.job.JobGetResponse +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.models.folders.job.JobGetParams +import io.imagekit.models.folders.job.JobGetResponse import java.util.function.Consumer interface JobService { diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/folders/JobServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/folders/JobServiceImpl.kt similarity index 77% rename from image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/folders/JobServiceImpl.kt rename to image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/folders/JobServiceImpl.kt index 06026c65..353003de 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/api/services/blocking/folders/JobServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/folders/JobServiceImpl.kt @@ -1,22 +1,22 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.folders +package io.imagekit.services.blocking.folders -import io.imagekit.api.core.ClientOptions -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.checkRequired -import io.imagekit.api.core.handlers.errorBodyHandler -import io.imagekit.api.core.handlers.errorHandler -import io.imagekit.api.core.handlers.jsonHandler -import io.imagekit.api.core.http.HttpMethod -import io.imagekit.api.core.http.HttpRequest -import io.imagekit.api.core.http.HttpResponse -import io.imagekit.api.core.http.HttpResponse.Handler -import io.imagekit.api.core.http.HttpResponseFor -import io.imagekit.api.core.http.parseable -import io.imagekit.api.core.prepare -import io.imagekit.api.models.folders.job.JobGetParams -import io.imagekit.api.models.folders.job.JobGetResponse +import io.imagekit.core.ClientOptions +import io.imagekit.core.RequestOptions +import io.imagekit.core.checkRequired +import io.imagekit.core.handlers.errorBodyHandler +import io.imagekit.core.handlers.errorHandler +import io.imagekit.core.handlers.jsonHandler +import io.imagekit.core.http.HttpMethod +import io.imagekit.core.http.HttpRequest +import io.imagekit.core.http.HttpResponse +import io.imagekit.core.http.HttpResponse.Handler +import io.imagekit.core.http.HttpResponseFor +import io.imagekit.core.http.parseable +import io.imagekit.core.prepare +import io.imagekit.models.folders.job.JobGetParams +import io.imagekit.models.folders.job.JobGetResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull diff --git a/image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro b/image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro index e27c5a3f..c0a34edd 100644 --- a/image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro +++ b/image-kit-java-core/src/main/resources/META-INF/proguard/image-kit-java-core.pro @@ -22,11 +22,11 @@ -keep class * extends com.fasterxml.jackson.core.type.TypeReference { *; } # Jackson uses reflection to access our class serializers and deserializers. --keep @com.fasterxml.jackson.databind.annotation.JsonSerialize class io.imagekit.api.** { *; } --keep @com.fasterxml.jackson.databind.annotation.JsonDeserialize class io.imagekit.api.** { *; } +-keep @com.fasterxml.jackson.databind.annotation.JsonSerialize class io.imagekit.** { *; } +-keep @com.fasterxml.jackson.databind.annotation.JsonDeserialize class io.imagekit.** { *; } # Jackson uses reflection to serialize and deserialize our classes based on their constructors and annotated members. --keepclassmembers class io.imagekit.api.** { +-keepclassmembers class io.imagekit.** { (...); @com.fasterxml.jackson.annotation.* *; } \ No newline at end of file diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/ClientOptionsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/core/ClientOptionsTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/core/ClientOptionsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/core/ClientOptionsTest.kt index afe5ae34..c13a2841 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/ClientOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/core/ClientOptionsTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.core +package io.imagekit.core -import io.imagekit.api.core.http.HttpClient +import io.imagekit.core.http.HttpClient import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/ObjectMappersTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/core/ObjectMappersTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/core/ObjectMappersTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/core/ObjectMappersTest.kt index 49fcb0a3..35c8a1b7 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/ObjectMappersTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/core/ObjectMappersTest.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.core +package io.imagekit.core import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.exc.MismatchedInputException diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/PhantomReachableTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/core/PhantomReachableTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/core/PhantomReachableTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/core/PhantomReachableTest.kt index 2ab6a2c1..c2fdda9c 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/PhantomReachableTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/core/PhantomReachableTest.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.core +package io.imagekit.core import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/UtilsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/core/UtilsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/core/UtilsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/core/UtilsTest.kt index bb89dec0..fac4b98d 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/UtilsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/core/UtilsTest.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.core +package io.imagekit.core import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/ValuesTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/core/ValuesTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/core/ValuesTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/core/ValuesTest.kt index 6e46df2f..a951f532 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/ValuesTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/core/ValuesTest.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.core +package io.imagekit.core import java.util.Optional import org.assertj.core.api.Assertions.assertThat diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/AsyncStreamResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/core/http/AsyncStreamResponseTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/AsyncStreamResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/core/http/AsyncStreamResponseTest.kt index 6da4579d..f057b661 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/AsyncStreamResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/core/http/AsyncStreamResponseTest.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.core.http +package io.imagekit.core.http import java.util.* import java.util.concurrent.CompletableFuture diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/HeadersTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/core/http/HeadersTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/HeadersTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/core/http/HeadersTest.kt index 514067fa..a99dd24f 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/HeadersTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/core/http/HeadersTest.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.core.http +package io.imagekit.core.http import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.params.ParameterizedTest diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/HttpRequestBodiesTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/core/http/HttpRequestBodiesTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/HttpRequestBodiesTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/core/http/HttpRequestBodiesTest.kt index c7f66085..bfe1ba68 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/HttpRequestBodiesTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/core/http/HttpRequestBodiesTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.core.http +package io.imagekit.core.http -import io.imagekit.api.core.MultipartField -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.MultipartField +import io.imagekit.core.jsonMapper import java.io.ByteArrayOutputStream import java.io.InputStream import org.assertj.core.api.Assertions.assertThat diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/HttpRequestTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/core/http/HttpRequestTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/HttpRequestTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/core/http/HttpRequestTest.kt index 99530868..f701b64a 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/HttpRequestTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/core/http/HttpRequestTest.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.core.http +package io.imagekit.core.http import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.params.ParameterizedTest diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/QueryParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/core/http/QueryParamsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/QueryParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/core/http/QueryParamsTest.kt index b517600c..c3b5f602 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/QueryParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/core/http/QueryParamsTest.kt @@ -1,4 +1,4 @@ -package io.imagekit.api.core.http +package io.imagekit.core.http import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.params.ParameterizedTest diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/RetryingHttpClientTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/core/http/RetryingHttpClientTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/RetryingHttpClientTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/core/http/RetryingHttpClientTest.kt index b216b9c1..126d0f88 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/core/http/RetryingHttpClientTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/core/http/RetryingHttpClientTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.core.http +package io.imagekit.core.http import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.matching @@ -15,10 +15,10 @@ import com.github.tomakehurst.wiremock.client.WireMock.verify import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.github.tomakehurst.wiremock.stubbing.Scenario -import io.imagekit.api.client.okhttp.OkHttpClient -import io.imagekit.api.core.RequestOptions -import io.imagekit.api.core.Sleeper -import io.imagekit.api.errors.ImageKitRetryableException +import io.imagekit.client.okhttp.OkHttpClient +import io.imagekit.core.RequestOptions +import io.imagekit.core.Sleeper +import io.imagekit.errors.ImageKitRetryableException import java.io.InputStream import java.time.Clock import java.time.Duration diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/AiTagTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/AiTagTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/AiTagTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/AiTagTest.kt index 6f234dbc..da610dc8 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/AiTagTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/AiTagTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/BaseOverlayTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/BaseOverlayTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/BaseOverlayTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/BaseOverlayTest.kt index 881c8928..6e5ead18 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/BaseOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/BaseOverlayTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/CustomMetadataTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/CustomMetadataTest.kt similarity index 89% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/CustomMetadataTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/CustomMetadataTest.kt index 901186f5..979d1536 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/CustomMetadataTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/CustomMetadataTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/EmbeddedMetadataTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/EmbeddedMetadataTest.kt similarity index 89% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/EmbeddedMetadataTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/EmbeddedMetadataTest.kt index b15e16ce..06a01d92 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/EmbeddedMetadataTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/EmbeddedMetadataTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ExtensionConfigTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/ExtensionConfigTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ExtensionConfigTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/ExtensionConfigTest.kt index 485a0aed..478e1412 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ExtensionConfigTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/ExtensionConfigTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper +import io.imagekit.errors.ImageKitInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ExtensionItemTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/ExtensionItemTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ExtensionItemTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/ExtensionItemTest.kt index 8671b7a0..e8b7e9a4 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ExtensionItemTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/ExtensionItemTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper +import io.imagekit.errors.ImageKitInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/GetImageAttributesOptionsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/GetImageAttributesOptionsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/GetImageAttributesOptionsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/GetImageAttributesOptionsTest.kt index ed603458..ccf3387a 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/GetImageAttributesOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/GetImageAttributesOptionsTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ImageOverlayTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/ImageOverlayTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ImageOverlayTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/ImageOverlayTest.kt index cf7477f8..9f518d9f 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ImageOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/ImageOverlayTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/OverlayPositionTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/OverlayPositionTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/OverlayPositionTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/OverlayPositionTest.kt index 095a640f..7c55f4b2 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/OverlayPositionTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/OverlayPositionTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/OverlayTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/OverlayTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/OverlayTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/OverlayTest.kt index a0259653..6bf1166d 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/OverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/OverlayTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper +import io.imagekit.errors.ImageKitInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/OverlayTimingTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/OverlayTimingTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/OverlayTimingTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/OverlayTimingTest.kt index 47b42054..56d84b11 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/OverlayTimingTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/OverlayTimingTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ResponsiveImageAttributesTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/ResponsiveImageAttributesTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ResponsiveImageAttributesTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/ResponsiveImageAttributesTest.kt index 90e879ff..f5518020 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/ResponsiveImageAttributesTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/ResponsiveImageAttributesTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SavedExtensionTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/SavedExtensionTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SavedExtensionTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/SavedExtensionTest.kt index 0e5c351b..e7f6f153 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SavedExtensionTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/SavedExtensionTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SelectedFieldsSchemaTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/SelectedFieldsSchemaTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SelectedFieldsSchemaTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/SelectedFieldsSchemaTest.kt index aef3843c..da5e4595 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SelectedFieldsSchemaTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/SelectedFieldsSchemaTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SolidColorOverlayTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/SolidColorOverlayTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SolidColorOverlayTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/SolidColorOverlayTest.kt index db7fd679..4f96d947 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SolidColorOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/SolidColorOverlayTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SolidColorOverlayTransformationTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/SolidColorOverlayTransformationTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SolidColorOverlayTransformationTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/SolidColorOverlayTransformationTest.kt index a9155038..4fbde69f 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SolidColorOverlayTransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/SolidColorOverlayTransformationTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SrcOptionsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/SrcOptionsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SrcOptionsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/SrcOptionsTest.kt index 3f7d4897..f27478c1 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SrcOptionsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/SrcOptionsTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SubtitleOverlayTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/SubtitleOverlayTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SubtitleOverlayTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/SubtitleOverlayTest.kt index 66f172e4..9d07d31e 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SubtitleOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/SubtitleOverlayTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SubtitleOverlayTransformationTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/SubtitleOverlayTransformationTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SubtitleOverlayTransformationTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/SubtitleOverlayTransformationTest.kt index bf391385..e32c9678 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/SubtitleOverlayTransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/SubtitleOverlayTransformationTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/TextOverlayTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/TextOverlayTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/TextOverlayTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/TextOverlayTest.kt index 2d347db1..ba8603fe 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/TextOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/TextOverlayTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/TextOverlayTransformationTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/TextOverlayTransformationTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/TextOverlayTransformationTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/TextOverlayTransformationTest.kt index 4283d556..150e6c4e 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/TextOverlayTransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/TextOverlayTransformationTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/TransformationTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/TransformationTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/TransformationTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/TransformationTest.kt index e5f05ef5..090e5c98 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/TransformationTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/TransformationTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/VersionInfoTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/VersionInfoTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/VersionInfoTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/VersionInfoTest.kt index 74965ad6..04dbeb2b 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/VersionInfoTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/VersionInfoTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/VideoOverlayTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/VideoOverlayTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/VideoOverlayTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/VideoOverlayTest.kt index c2d2c44e..7af2bd90 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/VideoOverlayTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/VideoOverlayTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models +package io.imagekit.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/origins/OriginCreateParamsTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginCreateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/origins/OriginCreateParamsTest.kt index 96aadea8..b5c83a1c 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/origins/OriginCreateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.origins +package io.imagekit.models.accounts.origins import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/origins/OriginDeleteParamsTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/origins/OriginDeleteParamsTest.kt index 5fb0d833..ec58ec96 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/origins/OriginDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.origins +package io.imagekit.models.accounts.origins import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/origins/OriginGetParamsTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/origins/OriginGetParamsTest.kt index 295648dc..1f72b14b 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/origins/OriginGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.origins +package io.imagekit.models.accounts.origins import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginListParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/origins/OriginListParamsTest.kt similarity index 81% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginListParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/origins/OriginListParamsTest.kt index 933b6547..6321de45 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginListParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/origins/OriginListParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.origins +package io.imagekit.models.accounts.origins import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginRequestTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/origins/OriginRequestTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginRequestTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/origins/OriginRequestTest.kt index 3adddeee..f0ca88a8 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginRequestTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/origins/OriginRequestTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.origins +package io.imagekit.models.accounts.origins import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper +import io.imagekit.errors.ImageKitInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/origins/OriginResponseTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/origins/OriginResponseTest.kt index 4cab4c21..0147ac7e 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/origins/OriginResponseTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.origins +package io.imagekit.models.accounts.origins import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper -import io.imagekit.api.errors.ImageKitInvalidDataException +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper +import io.imagekit.errors.ImageKitInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/origins/OriginUpdateParamsTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginUpdateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/origins/OriginUpdateParamsTest.kt index 3b86375a..4d2f3475 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/origins/OriginUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/origins/OriginUpdateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.origins +package io.imagekit.models.accounts.origins import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt index 20161bca..572b1383 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointCreateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.urlendpoints +package io.imagekit.models.accounts.urlendpoints import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt index 9fe9e746..9ca4e420 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.urlendpoints +package io.imagekit.models.accounts.urlendpoints import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt similarity index 90% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt index f5c205a1..8e7dd79a 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.urlendpoints +package io.imagekit.models.accounts.urlendpoints import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt similarity index 80% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt index aa9fc5bd..8c93b7c4 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointListParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.urlendpoints +package io.imagekit.models.accounts.urlendpoints import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequestTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointRequestTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequestTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointRequestTest.kt index 3e0534d7..055ae441 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointRequestTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointRequestTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.urlendpoints +package io.imagekit.models.accounts.urlendpoints import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointResponseTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointResponseTest.kt index 37de7df8..89266625 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.urlendpoints +package io.imagekit.models.accounts.urlendpoints import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt index 3a28954f..834a37a5 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/urlendpoints/UrlEndpointUpdateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.urlendpoints +package io.imagekit.models.accounts.urlendpoints import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/usage/UsageGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/usage/UsageGetParamsTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/usage/UsageGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/usage/UsageGetParamsTest.kt index 3e7bf3d6..050822e2 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/usage/UsageGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/usage/UsageGetParamsTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.usage +package io.imagekit.models.accounts.usage -import io.imagekit.api.core.http.QueryParams +import io.imagekit.core.http.QueryParams import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/usage/UsageGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/usage/UsageGetResponseTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/usage/UsageGetResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/usage/UsageGetResponseTest.kt index 58c92bba..c07828b1 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/accounts/usage/UsageGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/accounts/usage/UsageGetResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.accounts.usage +package io.imagekit.models.accounts.usage import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/assets/AssetListParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/assets/AssetListParamsTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/assets/AssetListParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/assets/AssetListParamsTest.kt index fc626d49..9f91463c 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/assets/AssetListParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/assets/AssetListParamsTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.assets +package io.imagekit.models.assets -import io.imagekit.api.core.http.QueryParams +import io.imagekit.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/assets/AssetListResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/assets/AssetListResponseTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/assets/AssetListResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/assets/AssetListResponseTest.kt index 5dc60617..3de29753 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/assets/AssetListResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/assets/AssetListResponseTest.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.assets +package io.imagekit.models.assets import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper -import io.imagekit.api.errors.ImageKitInvalidDataException -import io.imagekit.api.models.AiTag -import io.imagekit.api.models.CustomMetadata -import io.imagekit.api.models.EmbeddedMetadata -import io.imagekit.api.models.SelectedFieldsSchema -import io.imagekit.api.models.VersionInfo -import io.imagekit.api.models.files.File -import io.imagekit.api.models.files.Folder +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper +import io.imagekit.errors.ImageKitInvalidDataException +import io.imagekit.models.AiTag +import io.imagekit.models.CustomMetadata +import io.imagekit.models.EmbeddedMetadata +import io.imagekit.models.SelectedFieldsSchema +import io.imagekit.models.VersionInfo +import io.imagekit.models.files.File +import io.imagekit.models.files.Folder import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/beta/v2/files/FileUploadParamsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/beta/v2/files/FileUploadParamsTest.kt index 6e902f3a..ac001550 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/beta/v2/files/FileUploadParamsTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.beta.v2.files +package io.imagekit.models.beta.v2.files -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.MultipartField -import io.imagekit.api.models.ExtensionItem +import io.imagekit.core.JsonValue +import io.imagekit.core.MultipartField +import io.imagekit.models.ExtensionItem import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/beta/v2/files/FileUploadResponseTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/beta/v2/files/FileUploadResponseTest.kt index 08444611..b9a37cba 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/beta/v2/files/FileUploadResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/beta/v2/files/FileUploadResponseTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.beta.v2.files +package io.imagekit.models.beta.v2.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper -import io.imagekit.api.models.AiTag -import io.imagekit.api.models.CustomMetadata -import io.imagekit.api.models.EmbeddedMetadata -import io.imagekit.api.models.SelectedFieldsSchema -import io.imagekit.api.models.VersionInfo -import io.imagekit.api.models.files.Metadata +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper +import io.imagekit.models.AiTag +import io.imagekit.models.CustomMetadata +import io.imagekit.models.EmbeddedMetadata +import io.imagekit.models.SelectedFieldsSchema +import io.imagekit.models.VersionInfo +import io.imagekit.models.files.Metadata import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/cache/invalidation/InvalidationCreateParamsTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/cache/invalidation/InvalidationCreateParamsTest.kt index 9709a9a3..99a1d922 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/cache/invalidation/InvalidationCreateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.cache.invalidation +package io.imagekit.models.cache.invalidation import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/cache/invalidation/InvalidationCreateResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/cache/invalidation/InvalidationCreateResponseTest.kt index a8f8c7cf..08b98bdb 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationCreateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/cache/invalidation/InvalidationCreateResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.cache.invalidation +package io.imagekit.models.cache.invalidation import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/cache/invalidation/InvalidationGetParamsTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/cache/invalidation/InvalidationGetParamsTest.kt index aeb5c10d..eb96a5fb 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/cache/invalidation/InvalidationGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.cache.invalidation +package io.imagekit.models.cache.invalidation import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/cache/invalidation/InvalidationGetResponseTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/cache/invalidation/InvalidationGetResponseTest.kt index de5a732e..fbc9e76c 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/cache/invalidation/InvalidationGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/cache/invalidation/InvalidationGetResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.cache.invalidation +package io.imagekit.models.cache.invalidation import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt index a82fa5da..092fc696 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldCreateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.custommetadatafields +package io.imagekit.models.custommetadatafields import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt index 84132329..884890e9 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.custommetadatafields +package io.imagekit.models.custommetadatafields import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt index 7c1aa674..94a1b10b 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldDeleteResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.custommetadatafields +package io.imagekit.models.custommetadatafields import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt index ebb8b32f..eb0f1262 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldListParamsTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.custommetadatafields +package io.imagekit.models.custommetadatafields -import io.imagekit.api.core.http.QueryParams +import io.imagekit.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldTest.kt index d98f516d..618813d4 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.custommetadatafields +package io.imagekit.models.custommetadatafields import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt index 5555c9ec..dc99c64d 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/custommetadatafields/CustomMetadataFieldUpdateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.custommetadatafields +package io.imagekit.models.custommetadatafields import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileCopyParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileCopyParamsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileCopyParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileCopyParamsTest.kt index 3807f110..9bcd5e0e 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileCopyParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileCopyParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileCopyResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileCopyResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileCopyResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileCopyResponseTest.kt index 743c1729..da87a52a 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileCopyResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileCopyResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileDeleteParamsTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileDeleteParamsTest.kt index c4dc748b..237ec982 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileGetParamsTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileGetParamsTest.kt index 84aeb0a4..c4dd8f7a 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileMoveParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileMoveParamsTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileMoveParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileMoveParamsTest.kt index 25db423c..81b9fad1 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileMoveParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileMoveParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileMoveResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileMoveResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileMoveResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileMoveResponseTest.kt index b23eff73..a069beef 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileMoveResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileMoveResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileRenameParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileRenameParamsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileRenameParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileRenameParamsTest.kt index 87ad4fa6..56d3d46a 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileRenameParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileRenameParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileRenameResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileRenameResponseTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileRenameResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileRenameResponseTest.kt index 0cd3c6a0..b48c4011 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileRenameResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileRenameResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileTest.kt index 290c916d..ee56e12b 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileTest.kt @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper -import io.imagekit.api.models.AiTag -import io.imagekit.api.models.CustomMetadata -import io.imagekit.api.models.EmbeddedMetadata -import io.imagekit.api.models.SelectedFieldsSchema -import io.imagekit.api.models.VersionInfo +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper +import io.imagekit.models.AiTag +import io.imagekit.models.CustomMetadata +import io.imagekit.models.EmbeddedMetadata +import io.imagekit.models.SelectedFieldsSchema +import io.imagekit.models.VersionInfo import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileUpdateParamsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUpdateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileUpdateParamsTest.kt index 1722cab1..c3a6a728 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileUpdateParamsTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files -import io.imagekit.api.core.JsonValue -import io.imagekit.api.models.ExtensionItem +import io.imagekit.core.JsonValue +import io.imagekit.models.ExtensionItem import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUpdateResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileUpdateResponseTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUpdateResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileUpdateResponseTest.kt index 1c561617..48ec44cf 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUpdateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileUpdateResponseTest.kt @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper -import io.imagekit.api.models.AiTag -import io.imagekit.api.models.CustomMetadata -import io.imagekit.api.models.EmbeddedMetadata -import io.imagekit.api.models.SelectedFieldsSchema -import io.imagekit.api.models.VersionInfo +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper +import io.imagekit.models.AiTag +import io.imagekit.models.CustomMetadata +import io.imagekit.models.EmbeddedMetadata +import io.imagekit.models.SelectedFieldsSchema +import io.imagekit.models.VersionInfo import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUploadParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileUploadParamsTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUploadParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileUploadParamsTest.kt index d20c2843..6bcbfb38 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUploadParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileUploadParamsTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.MultipartField -import io.imagekit.api.models.ExtensionItem +import io.imagekit.core.JsonValue +import io.imagekit.core.MultipartField +import io.imagekit.models.ExtensionItem import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUploadResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileUploadResponseTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUploadResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileUploadResponseTest.kt index cf98e069..07f1f69e 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FileUploadResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FileUploadResponseTest.kt @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper -import io.imagekit.api.models.AiTag -import io.imagekit.api.models.CustomMetadata -import io.imagekit.api.models.EmbeddedMetadata -import io.imagekit.api.models.SelectedFieldsSchema -import io.imagekit.api.models.VersionInfo +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper +import io.imagekit.models.AiTag +import io.imagekit.models.CustomMetadata +import io.imagekit.models.EmbeddedMetadata +import io.imagekit.models.SelectedFieldsSchema +import io.imagekit.models.VersionInfo import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FolderTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FolderTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FolderTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FolderTest.kt index 98c19eb5..15d9a975 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/FolderTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/FolderTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/MetadataTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/MetadataTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/MetadataTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/MetadataTest.kt index 87f34119..ab004c52 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/MetadataTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/MetadataTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/UpdateFileRequestTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/UpdateFileRequestTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/UpdateFileRequestTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/UpdateFileRequestTest.kt index d5480b26..91e81df2 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/UpdateFileRequestTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/UpdateFileRequestTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files +package io.imagekit.models.files import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper -import io.imagekit.api.errors.ImageKitInvalidDataException -import io.imagekit.api.models.ExtensionItem +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper +import io.imagekit.errors.ImageKitInvalidDataException +import io.imagekit.models.ExtensionItem import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkAddTagsParamsTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkAddTagsParamsTest.kt index bad14b1a..da487a34 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkAddTagsParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.bulk +package io.imagekit.models.files.bulk import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkAddTagsResponseTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkAddTagsResponseTest.kt index 2c70545a..7c9e20f9 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkAddTagsResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkAddTagsResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.bulk +package io.imagekit.models.files.bulk import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkDeleteParamsTest.kt similarity index 94% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkDeleteParamsTest.kt index 9bb25a13..380102d3 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.bulk +package io.imagekit.models.files.bulk import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkDeleteResponseTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkDeleteResponseTest.kt index c5f56c16..42af91a0 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkDeleteResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkDeleteResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.bulk +package io.imagekit.models.files.bulk import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkRemoveAiTagsParamsTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkRemoveAiTagsParamsTest.kt index 7312a23d..49b6ee40 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkRemoveAiTagsParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.bulk +package io.imagekit.models.files.bulk import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkRemoveAiTagsResponseTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkRemoveAiTagsResponseTest.kt index 5506e53a..a0444597 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveAiTagsResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkRemoveAiTagsResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.bulk +package io.imagekit.models.files.bulk import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkRemoveTagsParamsTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkRemoveTagsParamsTest.kt index fdceaa14..41e7517e 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkRemoveTagsParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.bulk +package io.imagekit.models.files.bulk import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkRemoveTagsResponseTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkRemoveTagsResponseTest.kt index 8129e075..06cd5b90 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/bulk/BulkRemoveTagsResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/bulk/BulkRemoveTagsResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.bulk +package io.imagekit.models.files.bulk import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/metadata/MetadataGetFromUrlParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/metadata/MetadataGetFromUrlParamsTest.kt similarity index 86% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/metadata/MetadataGetFromUrlParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/metadata/MetadataGetFromUrlParamsTest.kt index 95a07f9d..0f43d2e2 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/metadata/MetadataGetFromUrlParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/metadata/MetadataGetFromUrlParamsTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.metadata +package io.imagekit.models.files.metadata -import io.imagekit.api.core.http.QueryParams +import io.imagekit.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/metadata/MetadataGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/metadata/MetadataGetParamsTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/metadata/MetadataGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/metadata/MetadataGetParamsTest.kt index 0df3f2f4..6c1960b0 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/metadata/MetadataGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/metadata/MetadataGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.metadata +package io.imagekit.models.files.metadata import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/versions/VersionDeleteParamsTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/versions/VersionDeleteParamsTest.kt index 3de171f7..accedc03 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/versions/VersionDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.versions +package io.imagekit.models.files.versions import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/versions/VersionDeleteResponseTest.kt similarity index 90% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionDeleteResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/versions/VersionDeleteResponseTest.kt index c2c542c7..a20093bb 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionDeleteResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/versions/VersionDeleteResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.versions +package io.imagekit.models.files.versions import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/versions/VersionGetParamsTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/versions/VersionGetParamsTest.kt index ef2ab7b9..6dd744c1 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/versions/VersionGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.versions +package io.imagekit.models.files.versions import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionListParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/versions/VersionListParamsTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionListParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/versions/VersionListParamsTest.kt index 502149da..910f7471 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionListParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/versions/VersionListParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.versions +package io.imagekit.models.files.versions import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionRestoreParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/versions/VersionRestoreParamsTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionRestoreParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/files/versions/VersionRestoreParamsTest.kt index f57e9d24..c7e72e76 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/files/versions/VersionRestoreParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/files/versions/VersionRestoreParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.files.versions +package io.imagekit.models.files.versions import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCopyParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderCopyParamsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCopyParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderCopyParamsTest.kt index 0031b44f..30f3c9ed 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCopyParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderCopyParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders +package io.imagekit.models.folders import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCopyResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderCopyResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCopyResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderCopyResponseTest.kt index d3dad6a8..82b783e5 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCopyResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderCopyResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders +package io.imagekit.models.folders import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderCreateParamsTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCreateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderCreateParamsTest.kt index 94241f3b..a9dbdcc8 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderCreateParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders +package io.imagekit.models.folders import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCreateResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderCreateResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCreateResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderCreateResponseTest.kt index a4914dc5..f1afa9e2 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderCreateResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderCreateResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders +package io.imagekit.models.folders import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderDeleteParamsTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderDeleteParamsTest.kt index 7b05c342..d11bc80f 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders +package io.imagekit.models.folders import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderDeleteResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderDeleteResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderDeleteResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderDeleteResponseTest.kt index b6cf526a..3909d002 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderDeleteResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderDeleteResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders +package io.imagekit.models.folders import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderMoveParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderMoveParamsTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderMoveParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderMoveParamsTest.kt index a212a206..977bb385 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderMoveParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderMoveParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders +package io.imagekit.models.folders import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderMoveResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderMoveResponseTest.kt similarity index 91% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderMoveResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderMoveResponseTest.kt index e013d0e1..75622dda 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderMoveResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderMoveResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders +package io.imagekit.models.folders import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderRenameParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderRenameParamsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderRenameParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderRenameParamsTest.kt index 6f8c65ea..ded2d403 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderRenameParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderRenameParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders +package io.imagekit.models.folders import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderRenameResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderRenameResponseTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderRenameResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderRenameResponseTest.kt index 3b670605..f5bee9f2 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/FolderRenameResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/FolderRenameResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders +package io.imagekit.models.folders import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/job/JobGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/job/JobGetParamsTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/job/JobGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/job/JobGetParamsTest.kt index f7494184..5b327b8c 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/job/JobGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/job/JobGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders.job +package io.imagekit.models.folders.job import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/job/JobGetResponseTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/job/JobGetResponseTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/job/JobGetResponseTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/job/JobGetResponseTest.kt index d0374ddf..df3bb4e1 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/folders/job/JobGetResponseTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/folders/job/JobGetResponseTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.folders.job +package io.imagekit.models.folders.job import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionCreateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/savedextensions/SavedExtensionCreateParamsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionCreateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/savedextensions/SavedExtensionCreateParamsTest.kt index 317d002a..36fa8064 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionCreateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/savedextensions/SavedExtensionCreateParamsTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.savedextensions +package io.imagekit.models.savedextensions -import io.imagekit.api.models.ExtensionConfig +import io.imagekit.models.ExtensionConfig import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionDeleteParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/savedextensions/SavedExtensionDeleteParamsTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionDeleteParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/savedextensions/SavedExtensionDeleteParamsTest.kt index 1b5e1b38..f8937ebd 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionDeleteParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/savedextensions/SavedExtensionDeleteParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.savedextensions +package io.imagekit.models.savedextensions import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionGetParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/savedextensions/SavedExtensionGetParamsTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionGetParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/savedextensions/SavedExtensionGetParamsTest.kt index c4fbf7a6..bf3d4c5c 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionGetParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/savedextensions/SavedExtensionGetParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.savedextensions +package io.imagekit.models.savedextensions import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionListParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/savedextensions/SavedExtensionListParamsTest.kt similarity index 82% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionListParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/savedextensions/SavedExtensionListParamsTest.kt index 1e972bd9..455ad716 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionListParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/savedextensions/SavedExtensionListParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.savedextensions +package io.imagekit.models.savedextensions import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionUpdateParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/savedextensions/SavedExtensionUpdateParamsTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionUpdateParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/savedextensions/SavedExtensionUpdateParamsTest.kt index 84edd274..c217ee44 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/savedextensions/SavedExtensionUpdateParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/savedextensions/SavedExtensionUpdateParamsTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.savedextensions +package io.imagekit.models.savedextensions -import io.imagekit.api.models.ExtensionConfig +import io.imagekit.models.ExtensionConfig import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/BaseWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/BaseWebhookEventTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/BaseWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/BaseWebhookEventTest.kt index bbc4dfe6..5398abe1 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/BaseWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/BaseWebhookEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileCreateEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/FileCreateEventTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileCreateEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/FileCreateEventTest.kt index 89c8afdb..201f5988 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileCreateEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/FileCreateEventTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper -import io.imagekit.api.models.AiTag -import io.imagekit.api.models.CustomMetadata -import io.imagekit.api.models.EmbeddedMetadata -import io.imagekit.api.models.SelectedFieldsSchema -import io.imagekit.api.models.VersionInfo -import io.imagekit.api.models.files.File +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper +import io.imagekit.models.AiTag +import io.imagekit.models.CustomMetadata +import io.imagekit.models.EmbeddedMetadata +import io.imagekit.models.SelectedFieldsSchema +import io.imagekit.models.VersionInfo +import io.imagekit.models.files.File import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileDeleteEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/FileDeleteEventTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileDeleteEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/FileDeleteEventTest.kt index a63eb4b1..2be82979 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileDeleteEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/FileDeleteEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileUpdateEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/FileUpdateEventTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileUpdateEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/FileUpdateEventTest.kt index bf1fad8b..34362792 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileUpdateEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/FileUpdateEventTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper -import io.imagekit.api.models.AiTag -import io.imagekit.api.models.CustomMetadata -import io.imagekit.api.models.EmbeddedMetadata -import io.imagekit.api.models.SelectedFieldsSchema -import io.imagekit.api.models.VersionInfo -import io.imagekit.api.models.files.File +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper +import io.imagekit.models.AiTag +import io.imagekit.models.CustomMetadata +import io.imagekit.models.EmbeddedMetadata +import io.imagekit.models.SelectedFieldsSchema +import io.imagekit.models.VersionInfo +import io.imagekit.models.files.File import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileVersionCreateEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/FileVersionCreateEventTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileVersionCreateEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/FileVersionCreateEventTest.kt index 0c5a7786..8479d5f4 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileVersionCreateEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/FileVersionCreateEventTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper -import io.imagekit.api.models.AiTag -import io.imagekit.api.models.CustomMetadata -import io.imagekit.api.models.EmbeddedMetadata -import io.imagekit.api.models.SelectedFieldsSchema -import io.imagekit.api.models.VersionInfo -import io.imagekit.api.models.files.File +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper +import io.imagekit.models.AiTag +import io.imagekit.models.CustomMetadata +import io.imagekit.models.EmbeddedMetadata +import io.imagekit.models.SelectedFieldsSchema +import io.imagekit.models.VersionInfo +import io.imagekit.models.files.File import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileVersionDeleteEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/FileVersionDeleteEventTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileVersionDeleteEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/FileVersionDeleteEventTest.kt index ae24d17f..75ba86dd 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/FileVersionDeleteEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/FileVersionDeleteEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UnsafeUnwrapWebhookEventTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UnsafeUnwrapWebhookEventTest.kt index aa6f3976..d7674219 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UnsafeUnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UnsafeUnwrapWebhookEventTest.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper -import io.imagekit.api.errors.ImageKitInvalidDataException -import io.imagekit.api.models.AiTag -import io.imagekit.api.models.CustomMetadata -import io.imagekit.api.models.EmbeddedMetadata -import io.imagekit.api.models.SelectedFieldsSchema -import io.imagekit.api.models.VersionInfo -import io.imagekit.api.models.files.File -import io.imagekit.api.models.files.Metadata +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper +import io.imagekit.errors.ImageKitInvalidDataException +import io.imagekit.models.AiTag +import io.imagekit.models.CustomMetadata +import io.imagekit.models.EmbeddedMetadata +import io.imagekit.models.SelectedFieldsSchema +import io.imagekit.models.VersionInfo +import io.imagekit.models.files.File +import io.imagekit.models.files.Metadata import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UnwrapWebhookEventTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UnwrapWebhookEventTest.kt index ca4c7916..616ad516 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UnwrapWebhookEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UnwrapWebhookEventTest.kt @@ -1,18 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper -import io.imagekit.api.errors.ImageKitInvalidDataException -import io.imagekit.api.models.AiTag -import io.imagekit.api.models.CustomMetadata -import io.imagekit.api.models.EmbeddedMetadata -import io.imagekit.api.models.SelectedFieldsSchema -import io.imagekit.api.models.VersionInfo -import io.imagekit.api.models.files.File -import io.imagekit.api.models.files.Metadata +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper +import io.imagekit.errors.ImageKitInvalidDataException +import io.imagekit.models.AiTag +import io.imagekit.models.CustomMetadata +import io.imagekit.models.EmbeddedMetadata +import io.imagekit.models.SelectedFieldsSchema +import io.imagekit.models.VersionInfo +import io.imagekit.models.files.File +import io.imagekit.models.files.Metadata import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformErrorEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UploadPostTransformErrorEventTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformErrorEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UploadPostTransformErrorEventTest.kt index 40bf24ad..0bc6e68d 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformErrorEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UploadPostTransformErrorEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformSuccessEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UploadPostTransformSuccessEventTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformSuccessEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UploadPostTransformSuccessEventTest.kt index ef79930b..70bd24ce 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPostTransformSuccessEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UploadPostTransformSuccessEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformErrorEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UploadPreTransformErrorEventTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformErrorEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UploadPreTransformErrorEventTest.kt index e23b4f36..d946bfef 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformErrorEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UploadPreTransformErrorEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UploadPreTransformSuccessEventTest.kt similarity index 98% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UploadPreTransformSuccessEventTest.kt index 910e818c..4c62f94f 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/UploadPreTransformSuccessEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/UploadPreTransformSuccessEventTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper -import io.imagekit.api.models.AiTag -import io.imagekit.api.models.CustomMetadata -import io.imagekit.api.models.EmbeddedMetadata -import io.imagekit.api.models.SelectedFieldsSchema -import io.imagekit.api.models.VersionInfo -import io.imagekit.api.models.files.Metadata +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper +import io.imagekit.models.AiTag +import io.imagekit.models.CustomMetadata +import io.imagekit.models.EmbeddedMetadata +import io.imagekit.models.SelectedFieldsSchema +import io.imagekit.models.VersionInfo +import io.imagekit.models.files.Metadata import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/VideoTransformationAcceptedEventTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/VideoTransformationAcceptedEventTest.kt index 2a6d99f0..89cbf669 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/VideoTransformationAcceptedEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/VideoTransformationAcceptedEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/VideoTransformationErrorEventTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/VideoTransformationErrorEventTest.kt index 1269a487..a535a7c2 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/VideoTransformationErrorEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/VideoTransformationErrorEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/VideoTransformationReadyEventTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/VideoTransformationReadyEventTest.kt index 62daa569..1a6d241d 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/models/webhooks/VideoTransformationReadyEventTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/models/webhooks/VideoTransformationReadyEventTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.models.webhooks +package io.imagekit.models.webhooks import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.core.jsonMapper +import io.imagekit.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/ErrorHandlingTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/ErrorHandlingTest.kt similarity index 99% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/ErrorHandlingTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/ErrorHandlingTest.kt index cdfdf760..ef9c8747 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/ErrorHandlingTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/ErrorHandlingTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services +package io.imagekit.services import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.post @@ -8,22 +8,22 @@ import com.github.tomakehurst.wiremock.client.WireMock.status import com.github.tomakehurst.wiremock.client.WireMock.stubFor import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest -import io.imagekit.api.client.ImageKitClient -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.http.Headers -import io.imagekit.api.core.jsonMapper -import io.imagekit.api.errors.BadRequestException -import io.imagekit.api.errors.ImageKitException -import io.imagekit.api.errors.InternalServerException -import io.imagekit.api.errors.NotFoundException -import io.imagekit.api.errors.PermissionDeniedException -import io.imagekit.api.errors.RateLimitException -import io.imagekit.api.errors.UnauthorizedException -import io.imagekit.api.errors.UnexpectedStatusCodeException -import io.imagekit.api.errors.UnprocessableEntityException -import io.imagekit.api.models.ExtensionItem -import io.imagekit.api.models.files.FileUploadParams +import io.imagekit.client.ImageKitClient +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.core.JsonValue +import io.imagekit.core.http.Headers +import io.imagekit.core.jsonMapper +import io.imagekit.errors.BadRequestException +import io.imagekit.errors.ImageKitException +import io.imagekit.errors.InternalServerException +import io.imagekit.errors.NotFoundException +import io.imagekit.errors.PermissionDeniedException +import io.imagekit.errors.RateLimitException +import io.imagekit.errors.UnauthorizedException +import io.imagekit.errors.UnexpectedStatusCodeException +import io.imagekit.errors.UnprocessableEntityException +import io.imagekit.models.ExtensionItem +import io.imagekit.models.files.FileUploadParams import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.entry import org.junit.jupiter.api.BeforeEach diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/ServiceParamsTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/ServiceParamsTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/ServiceParamsTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/ServiceParamsTest.kt index 68cf9566..3278cba7 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/ServiceParamsTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/ServiceParamsTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services +package io.imagekit.services import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.equalTo @@ -12,11 +12,11 @@ import com.github.tomakehurst.wiremock.client.WireMock.stubFor import com.github.tomakehurst.wiremock.client.WireMock.verify import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest -import io.imagekit.api.client.ImageKitClient -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient -import io.imagekit.api.core.JsonValue -import io.imagekit.api.models.ExtensionItem -import io.imagekit.api.models.files.FileUploadParams +import io.imagekit.client.ImageKitClient +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.core.JsonValue +import io.imagekit.models.ExtensionItem +import io.imagekit.models.files.FileUploadParams import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/AssetServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/AssetServiceAsyncTest.kt similarity index 86% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/AssetServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/async/AssetServiceAsyncTest.kt index 6663c601..1b91f88f 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/AssetServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/AssetServiceAsyncTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async +package io.imagekit.services.async -import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.api.models.assets.AssetListParams +import io.imagekit.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.models.assets.AssetListParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/CustomMetadataFieldServiceAsyncTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/async/CustomMetadataFieldServiceAsyncTest.kt index 33ed30a5..d76f3da0 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/CustomMetadataFieldServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/CustomMetadataFieldServiceAsyncTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async +package io.imagekit.services.async -import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +import io.imagekit.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.models.custommetadatafields.CustomMetadataFieldCreateParams +import io.imagekit.models.custommetadatafields.CustomMetadataFieldListParams +import io.imagekit.models.custommetadatafields.CustomMetadataFieldUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/FileServiceAsyncTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/FileServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/async/FileServiceAsyncTest.kt index f4da391f..65298396 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/FileServiceAsyncTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async +package io.imagekit.services.async -import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.api.core.JsonValue -import io.imagekit.api.models.ExtensionItem -import io.imagekit.api.models.files.FileCopyParams -import io.imagekit.api.models.files.FileMoveParams -import io.imagekit.api.models.files.FileRenameParams -import io.imagekit.api.models.files.FileUpdateParams -import io.imagekit.api.models.files.FileUploadParams -import io.imagekit.api.models.files.UpdateFileRequest +import io.imagekit.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.core.JsonValue +import io.imagekit.models.ExtensionItem +import io.imagekit.models.files.FileCopyParams +import io.imagekit.models.files.FileMoveParams +import io.imagekit.models.files.FileRenameParams +import io.imagekit.models.files.FileUpdateParams +import io.imagekit.models.files.FileUploadParams +import io.imagekit.models.files.UpdateFileRequest import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/FolderServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/FolderServiceAsyncTest.kt similarity index 89% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/FolderServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/async/FolderServiceAsyncTest.kt index 58cf0557..e54654d1 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/FolderServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/FolderServiceAsyncTest.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async - -import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.api.models.folders.FolderCopyParams -import io.imagekit.api.models.folders.FolderCreateParams -import io.imagekit.api.models.folders.FolderDeleteParams -import io.imagekit.api.models.folders.FolderMoveParams -import io.imagekit.api.models.folders.FolderRenameParams +package io.imagekit.services.async + +import io.imagekit.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.models.folders.FolderCopyParams +import io.imagekit.models.folders.FolderCreateParams +import io.imagekit.models.folders.FolderDeleteParams +import io.imagekit.models.folders.FolderMoveParams +import io.imagekit.models.folders.FolderRenameParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/SavedExtensionServiceAsyncTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/async/SavedExtensionServiceAsyncTest.kt index 57cc5b60..a126f226 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/SavedExtensionServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/SavedExtensionServiceAsyncTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async +package io.imagekit.services.async -import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.api.models.ExtensionConfig -import io.imagekit.api.models.savedextensions.SavedExtensionCreateParams -import io.imagekit.api.models.savedextensions.SavedExtensionUpdateParams +import io.imagekit.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.models.ExtensionConfig +import io.imagekit.models.savedextensions.SavedExtensionCreateParams +import io.imagekit.models.savedextensions.SavedExtensionUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/WebhookServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/WebhookServiceAsyncTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/WebhookServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/async/WebhookServiceAsyncTest.kt index 64072e5f..e0c6889d 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/WebhookServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/WebhookServiceAsyncTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async +package io.imagekit.services.async import com.standardwebhooks.Webhook -import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.api.core.UnwrapWebhookParams -import io.imagekit.api.core.http.Headers -import io.imagekit.api.errors.ImageKitWebhookException +import io.imagekit.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.core.UnwrapWebhookParams +import io.imagekit.core.http.Headers +import io.imagekit.errors.ImageKitWebhookException import java.time.Instant import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/accounts/OriginServiceAsyncTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/async/accounts/OriginServiceAsyncTest.kt index a54de338..df0fcd93 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/accounts/OriginServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/accounts/OriginServiceAsyncTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.accounts +package io.imagekit.services.async.accounts -import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.api.models.accounts.origins.OriginRequest -import io.imagekit.api.models.accounts.origins.OriginUpdateParams +import io.imagekit.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.models.accounts.origins.OriginRequest +import io.imagekit.models.accounts.origins.OriginUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/accounts/UrlEndpointServiceAsyncTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/async/accounts/UrlEndpointServiceAsyncTest.kt index ed391486..bad0a2b2 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/accounts/UrlEndpointServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/accounts/UrlEndpointServiceAsyncTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.accounts +package io.imagekit.services.async.accounts -import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +import io.imagekit.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.models.accounts.urlendpoints.UrlEndpointRequest +import io.imagekit.models.accounts.urlendpoints.UrlEndpointUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/accounts/UsageServiceAsyncTest.kt similarity index 83% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/async/accounts/UsageServiceAsyncTest.kt index 2816aa94..9aea8b67 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/accounts/UsageServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/accounts/UsageServiceAsyncTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.accounts +package io.imagekit.services.async.accounts -import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.api.models.accounts.usage.UsageGetParams +import io.imagekit.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.models.accounts.usage.UsageGetParams import java.time.LocalDate import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/beta/v2/FileServiceAsyncTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/async/beta/v2/FileServiceAsyncTest.kt index e9617a97..6302c99d 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/beta/v2/FileServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/beta/v2/FileServiceAsyncTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.beta.v2 +package io.imagekit.services.async.beta.v2 -import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.api.core.JsonValue -import io.imagekit.api.models.ExtensionItem -import io.imagekit.api.models.beta.v2.files.FileUploadParams +import io.imagekit.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.core.JsonValue +import io.imagekit.models.ExtensionItem +import io.imagekit.models.beta.v2.files.FileUploadParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/cache/InvalidationServiceAsyncTest.kt similarity index 88% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/async/cache/InvalidationServiceAsyncTest.kt index 375a1aae..fa761021 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/cache/InvalidationServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/cache/InvalidationServiceAsyncTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.cache +package io.imagekit.services.async.cache -import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.api.models.cache.invalidation.InvalidationCreateParams +import io.imagekit.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.models.cache.invalidation.InvalidationCreateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/files/BulkServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/files/BulkServiceAsyncTest.kt similarity index 89% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/files/BulkServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/async/files/BulkServiceAsyncTest.kt index 0a5bd8ca..e965210f 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/files/BulkServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/files/BulkServiceAsyncTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.files +package io.imagekit.services.async.files -import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.api.models.files.bulk.BulkAddTagsParams -import io.imagekit.api.models.files.bulk.BulkDeleteParams -import io.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams -import io.imagekit.api.models.files.bulk.BulkRemoveTagsParams +import io.imagekit.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.models.files.bulk.BulkAddTagsParams +import io.imagekit.models.files.bulk.BulkDeleteParams +import io.imagekit.models.files.bulk.BulkRemoveAiTagsParams +import io.imagekit.models.files.bulk.BulkRemoveTagsParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/files/MetadataServiceAsyncTest.kt similarity index 87% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/async/files/MetadataServiceAsyncTest.kt index 7b9cfcf2..11323147 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/files/MetadataServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/files/MetadataServiceAsyncTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.files +package io.imagekit.services.async.files -import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.api.models.files.metadata.MetadataGetFromUrlParams +import io.imagekit.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.models.files.metadata.MetadataGetFromUrlParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/files/VersionServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/files/VersionServiceAsyncTest.kt similarity index 88% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/files/VersionServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/async/files/VersionServiceAsyncTest.kt index 267880e4..7d280ab0 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/files/VersionServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/files/VersionServiceAsyncTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.files +package io.imagekit.services.async.files -import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync -import io.imagekit.api.models.files.versions.VersionDeleteParams -import io.imagekit.api.models.files.versions.VersionGetParams -import io.imagekit.api.models.files.versions.VersionRestoreParams +import io.imagekit.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.models.files.versions.VersionDeleteParams +import io.imagekit.models.files.versions.VersionGetParams +import io.imagekit.models.files.versions.VersionRestoreParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/folders/JobServiceAsyncTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/folders/JobServiceAsyncTest.kt similarity index 84% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/folders/JobServiceAsyncTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/async/folders/JobServiceAsyncTest.kt index a2e56bf0..9f047389 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/async/folders/JobServiceAsyncTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/async/folders/JobServiceAsyncTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.async.folders +package io.imagekit.services.async.folders -import io.imagekit.api.client.okhttp.ImageKitOkHttpClientAsync +import io.imagekit.client.okhttp.ImageKitOkHttpClientAsync import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/AssetServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/AssetServiceTest.kt similarity index 86% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/AssetServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/AssetServiceTest.kt index 20521f96..27870e83 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/AssetServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/AssetServiceTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking +package io.imagekit.services.blocking -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient -import io.imagekit.api.models.assets.AssetListParams +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.models.assets.AssetListParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/CustomMetadataFieldServiceTest.kt similarity index 95% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/CustomMetadataFieldServiceTest.kt index 8403047b..74357e26 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/CustomMetadataFieldServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/CustomMetadataFieldServiceTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking +package io.imagekit.services.blocking -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldCreateParams -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldListParams -import io.imagekit.api.models.custommetadatafields.CustomMetadataFieldUpdateParams +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.models.custommetadatafields.CustomMetadataFieldCreateParams +import io.imagekit.models.custommetadatafields.CustomMetadataFieldListParams +import io.imagekit.models.custommetadatafields.CustomMetadataFieldUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/FileServiceTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/FileServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/FileServiceTest.kt index 8e4c829c..ac8275f3 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/FileServiceTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking +package io.imagekit.services.blocking -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient -import io.imagekit.api.core.JsonValue -import io.imagekit.api.models.ExtensionItem -import io.imagekit.api.models.files.FileCopyParams -import io.imagekit.api.models.files.FileMoveParams -import io.imagekit.api.models.files.FileRenameParams -import io.imagekit.api.models.files.FileUpdateParams -import io.imagekit.api.models.files.FileUploadParams -import io.imagekit.api.models.files.UpdateFileRequest +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.core.JsonValue +import io.imagekit.models.ExtensionItem +import io.imagekit.models.files.FileCopyParams +import io.imagekit.models.files.FileMoveParams +import io.imagekit.models.files.FileRenameParams +import io.imagekit.models.files.FileUpdateParams +import io.imagekit.models.files.FileUploadParams +import io.imagekit.models.files.UpdateFileRequest import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/FolderServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/FolderServiceTest.kt similarity index 89% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/FolderServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/FolderServiceTest.kt index 345b9f33..d04722fe 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/FolderServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/FolderServiceTest.kt @@ -1,13 +1,13 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking - -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient -import io.imagekit.api.models.folders.FolderCopyParams -import io.imagekit.api.models.folders.FolderCreateParams -import io.imagekit.api.models.folders.FolderDeleteParams -import io.imagekit.api.models.folders.FolderMoveParams -import io.imagekit.api.models.folders.FolderRenameParams +package io.imagekit.services.blocking + +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.models.folders.FolderCopyParams +import io.imagekit.models.folders.FolderCreateParams +import io.imagekit.models.folders.FolderDeleteParams +import io.imagekit.models.folders.FolderMoveParams +import io.imagekit.models.folders.FolderRenameParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/SavedExtensionServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/SavedExtensionServiceTest.kt similarity index 92% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/SavedExtensionServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/SavedExtensionServiceTest.kt index 8be557a4..775bd3c3 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/SavedExtensionServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/SavedExtensionServiceTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking +package io.imagekit.services.blocking -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient -import io.imagekit.api.models.ExtensionConfig -import io.imagekit.api.models.savedextensions.SavedExtensionCreateParams -import io.imagekit.api.models.savedextensions.SavedExtensionUpdateParams +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.models.ExtensionConfig +import io.imagekit.models.savedextensions.SavedExtensionCreateParams +import io.imagekit.models.savedextensions.SavedExtensionUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/WebhookServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/WebhookServiceTest.kt similarity index 96% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/WebhookServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/WebhookServiceTest.kt index bd73abd2..97ade4ec 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/WebhookServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/WebhookServiceTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking +package io.imagekit.services.blocking import com.standardwebhooks.Webhook -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient -import io.imagekit.api.core.UnwrapWebhookParams -import io.imagekit.api.core.http.Headers -import io.imagekit.api.errors.ImageKitWebhookException +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.core.UnwrapWebhookParams +import io.imagekit.core.http.Headers +import io.imagekit.errors.ImageKitWebhookException import java.time.Instant import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/accounts/OriginServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/accounts/OriginServiceTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/accounts/OriginServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/accounts/OriginServiceTest.kt index a36c3577..03fbd1bd 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/accounts/OriginServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/accounts/OriginServiceTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.accounts +package io.imagekit.services.blocking.accounts -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient -import io.imagekit.api.models.accounts.origins.OriginRequest -import io.imagekit.api.models.accounts.origins.OriginUpdateParams +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.models.accounts.origins.OriginRequest +import io.imagekit.models.accounts.origins.OriginUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/accounts/UrlEndpointServiceTest.kt similarity index 93% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/accounts/UrlEndpointServiceTest.kt index f16d0e9c..6976535e 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/accounts/UrlEndpointServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/accounts/UrlEndpointServiceTest.kt @@ -1,10 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.accounts +package io.imagekit.services.blocking.accounts -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointRequest -import io.imagekit.api.models.accounts.urlendpoints.UrlEndpointUpdateParams +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.models.accounts.urlendpoints.UrlEndpointRequest +import io.imagekit.models.accounts.urlendpoints.UrlEndpointUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/accounts/UsageServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/accounts/UsageServiceTest.kt similarity index 82% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/accounts/UsageServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/accounts/UsageServiceTest.kt index 195b456b..fd7852a1 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/accounts/UsageServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/accounts/UsageServiceTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.accounts +package io.imagekit.services.blocking.accounts -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient -import io.imagekit.api.models.accounts.usage.UsageGetParams +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.models.accounts.usage.UsageGetParams import java.time.LocalDate import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/beta/v2/FileServiceTest.kt similarity index 97% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/beta/v2/FileServiceTest.kt index d48bc0e6..a374938b 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/beta/v2/FileServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/beta/v2/FileServiceTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.beta.v2 +package io.imagekit.services.blocking.beta.v2 -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient -import io.imagekit.api.core.JsonValue -import io.imagekit.api.models.ExtensionItem -import io.imagekit.api.models.beta.v2.files.FileUploadParams +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.core.JsonValue +import io.imagekit.models.ExtensionItem +import io.imagekit.models.beta.v2.files.FileUploadParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/cache/InvalidationServiceTest.kt similarity index 86% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/cache/InvalidationServiceTest.kt index 67753615..0237baf7 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/cache/InvalidationServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/cache/InvalidationServiceTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.cache +package io.imagekit.services.blocking.cache -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient -import io.imagekit.api.models.cache.invalidation.InvalidationCreateParams +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.models.cache.invalidation.InvalidationCreateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/files/BulkServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/files/BulkServiceTest.kt similarity index 88% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/files/BulkServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/files/BulkServiceTest.kt index e737377e..8734aa20 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/files/BulkServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/files/BulkServiceTest.kt @@ -1,12 +1,12 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.files +package io.imagekit.services.blocking.files -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient -import io.imagekit.api.models.files.bulk.BulkAddTagsParams -import io.imagekit.api.models.files.bulk.BulkDeleteParams -import io.imagekit.api.models.files.bulk.BulkRemoveAiTagsParams -import io.imagekit.api.models.files.bulk.BulkRemoveTagsParams +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.models.files.bulk.BulkAddTagsParams +import io.imagekit.models.files.bulk.BulkDeleteParams +import io.imagekit.models.files.bulk.BulkRemoveAiTagsParams +import io.imagekit.models.files.bulk.BulkRemoveTagsParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/files/MetadataServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/files/MetadataServiceTest.kt similarity index 85% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/files/MetadataServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/files/MetadataServiceTest.kt index 9660e6fe..5b6d374d 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/files/MetadataServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/files/MetadataServiceTest.kt @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.files +package io.imagekit.services.blocking.files -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient -import io.imagekit.api.models.files.metadata.MetadataGetFromUrlParams +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.models.files.metadata.MetadataGetFromUrlParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/files/VersionServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/files/VersionServiceTest.kt similarity index 87% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/files/VersionServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/files/VersionServiceTest.kt index 7f9d72cb..c19cb6c8 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/files/VersionServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/files/VersionServiceTest.kt @@ -1,11 +1,11 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.files +package io.imagekit.services.blocking.files -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient -import io.imagekit.api.models.files.versions.VersionDeleteParams -import io.imagekit.api.models.files.versions.VersionGetParams -import io.imagekit.api.models.files.versions.VersionRestoreParams +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.models.files.versions.VersionDeleteParams +import io.imagekit.models.files.versions.VersionGetParams +import io.imagekit.models.files.versions.VersionRestoreParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/folders/JobServiceTest.kt b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/folders/JobServiceTest.kt similarity index 83% rename from image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/folders/JobServiceTest.kt rename to image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/folders/JobServiceTest.kt index c754963b..cb04e670 100644 --- a/image-kit-java-core/src/test/kotlin/io/imagekit/api/services/blocking/folders/JobServiceTest.kt +++ b/image-kit-java-core/src/test/kotlin/io/imagekit/services/blocking/folders/JobServiceTest.kt @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.services.blocking.folders +package io.imagekit.services.blocking.folders -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient +import io.imagekit.client.okhttp.ImageKitOkHttpClient import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test diff --git a/image-kit-java-proguard-test/build.gradle.kts b/image-kit-java-proguard-test/build.gradle.kts index b3d4162e..1ac61e92 100644 --- a/image-kit-java-proguard-test/build.gradle.kts +++ b/image-kit-java-proguard-test/build.gradle.kts @@ -59,7 +59,7 @@ val testProGuard by tasks.registering(JavaExec::class) { dependsOn(proguardJar) notCompatibleWithConfigurationCache("ProGuard") - mainClass.set("io.imagekit.api.proguard.ProGuardCompatibilityTest") + mainClass.set("io.imagekit.proguard.ProGuardCompatibilityTest") classpath = files(proguardJarPath) } @@ -89,7 +89,7 @@ val testR8 by tasks.registering(JavaExec::class) { dependsOn(r8Jar) notCompatibleWithConfigurationCache("R8") - mainClass.set("io.imagekit.api.proguard.ProGuardCompatibilityTest") + mainClass.set("io.imagekit.proguard.ProGuardCompatibilityTest") classpath = files(r8JarPath) } diff --git a/image-kit-java-proguard-test/src/test/kotlin/io/imagekit/api/proguard/ProGuardCompatibilityTest.kt b/image-kit-java-proguard-test/src/test/kotlin/io/imagekit/proguard/ProGuardCompatibilityTest.kt similarity index 94% rename from image-kit-java-proguard-test/src/test/kotlin/io/imagekit/api/proguard/ProGuardCompatibilityTest.kt rename to image-kit-java-proguard-test/src/test/kotlin/io/imagekit/proguard/ProGuardCompatibilityTest.kt index c6e65633..6976f2da 100644 --- a/image-kit-java-proguard-test/src/test/kotlin/io/imagekit/api/proguard/ProGuardCompatibilityTest.kt +++ b/image-kit-java-proguard-test/src/test/kotlin/io/imagekit/proguard/ProGuardCompatibilityTest.kt @@ -1,20 +1,20 @@ // File generated from our OpenAPI spec by Stainless. -package io.imagekit.api.proguard +package io.imagekit.proguard import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import io.imagekit.api.client.okhttp.ImageKitOkHttpClient -import io.imagekit.api.core.JsonValue -import io.imagekit.api.core.jsonMapper -import io.imagekit.api.models.AiTag -import io.imagekit.api.models.CustomMetadata -import io.imagekit.api.models.EmbeddedMetadata -import io.imagekit.api.models.ExtensionItem -import io.imagekit.api.models.SelectedFieldsSchema -import io.imagekit.api.models.StreamingResolution -import io.imagekit.api.models.VersionInfo -import io.imagekit.api.models.files.File -import io.imagekit.api.models.files.UpdateFileRequest +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.core.JsonValue +import io.imagekit.core.jsonMapper +import io.imagekit.models.AiTag +import io.imagekit.models.CustomMetadata +import io.imagekit.models.EmbeddedMetadata +import io.imagekit.models.ExtensionItem +import io.imagekit.models.SelectedFieldsSchema +import io.imagekit.models.StreamingResolution +import io.imagekit.models.VersionInfo +import io.imagekit.models.files.File +import io.imagekit.models.files.UpdateFileRequest import java.time.OffsetDateTime import kotlin.reflect.full.memberFunctions import kotlin.reflect.jvm.javaMethod diff --git a/image-kit-java-proguard-test/test.pro b/image-kit-java-proguard-test/test.pro index 1b4acb55..891d57c2 100644 --- a/image-kit-java-proguard-test/test.pro +++ b/image-kit-java-proguard-test/test.pro @@ -1,5 +1,5 @@ # Specify the entrypoint where ProGuard starts to determine what's reachable. --keep class io.imagekit.api.proguard.** { *; } +-keep class io.imagekit.proguard.** { *; } # For the testing framework. -keep class org.junit.** { *; } From 92fb768157a6630a3770f5ad99596b6c3ed184f3 Mon Sep 17 00:00:00 2001 From: Manu Chaudhary Date: Tue, 21 Apr 2026 08:01:13 +0000 Subject: [PATCH 141/142] feat: add helper utilities and lib module with tests --- .gitignore | 5 + README.md | 402 ++++- .../src/main/kotlin/image-kit.java.gradle.kts | 2 +- .../main/kotlin/image-kit.kotlin.gradle.kts | 2 +- .../io/imagekit/client/ImageKitClient.kt | 3 + .../io/imagekit/client/ImageKitClientAsync.kt | 3 + .../client/ImageKitClientAsyncImpl.kt | 6 + .../io/imagekit/client/ImageKitClientImpl.kt | 6 + .../src/main/kotlin/io/imagekit/lib/Helper.kt | 970 ++++++++++ .../kotlin/io/imagekit/lib/HelperService.kt | 26 + .../models/beta/v2/files/FileUploadParams.kt | 42 +- .../imagekit/models/files/FileUploadParams.kt | 42 +- .../services/blocking/WebhookServiceImpl.kt | 4 +- image-kit-java-example/build.gradle.kts | 2 +- .../main/java/io/imagekit/example/Main.java | 117 ++ image-kit-java-lib/build.gradle.kts | 13 + .../lib/HelperAdvancedTransformationsTest.kt | 516 ++++++ .../imagekit/lib/HelperAuthenticationTest.kt | 101 ++ .../io/imagekit/lib/HelperBuildUrlTest.kt | 433 +++++ .../io/imagekit/lib/HelperOverlayTest.kt | 1564 +++++++++++++++++ .../io/imagekit/lib/HelperSigningTest.kt | 279 +++ .../imagekit/lib/HelperTransformationTest.kt | 108 ++ 22 files changed, 4578 insertions(+), 68 deletions(-) create mode 100644 image-kit-java-core/src/main/kotlin/io/imagekit/lib/Helper.kt create mode 100644 image-kit-java-core/src/main/kotlin/io/imagekit/lib/HelperService.kt create mode 100644 image-kit-java-example/src/main/java/io/imagekit/example/Main.java create mode 100644 image-kit-java-lib/build.gradle.kts create mode 100644 image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperAdvancedTransformationsTest.kt create mode 100644 image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperAuthenticationTest.kt create mode 100644 image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperBuildUrlTest.kt create mode 100644 image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperOverlayTest.kt create mode 100644 image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperSigningTest.kt create mode 100644 image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperTransformationTest.kt diff --git a/.gitignore b/.gitignore index 90b85e94..3f9641c6 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,8 @@ build/ codegen.log kls_database.db + + +image-kit-java-example/resources +image-kit-java-example/src/main/resources/ +temp \ No newline at end of file diff --git a/README.md b/README.md index ae23dbad..1fa6d0ad 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Image Kit Java API Library +# ImageKit.io Java SDK @@ -7,16 +7,7 @@ -The Image Kit Java SDK provides convenient access to the [Image Kit REST API](https://imagekit.io/docs/api-reference) from applications written in Java. - -## MCP Server - -Use the Image Kit MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application. - -[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40imagekit%2Fapi-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBpbWFnZWtpdC9hcGktbWNwIl0sImVudiI6eyJJTUFHRUtJVF9QUklWQVRFX0tFWSI6Ik15IFByaXZhdGUgS2V5IiwiT1BUSU9OQUxfSU1BR0VLSVRfSUdOT1JFU19USElTIjoiTXkgUGFzc3dvcmQiLCJJTUFHRUtJVF9XRUJIT09LX1NFQ1JFVCI6Ik15IFdlYmhvb2sgU2VjcmV0In19) -[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40imagekit%2Fapi-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40imagekit%2Fapi-mcp%22%5D%2C%22env%22%3A%7B%22IMAGEKIT_PRIVATE_KEY%22%3A%22My%20Private%20Key%22%2C%22OPTIONAL_IMAGEKIT_IGNORES_THIS%22%3A%22My%20Password%22%2C%22IMAGEKIT_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D) - -> Note: You may need to set environment variables in your MCP client. +The ImageKit Java SDK is a comprehensive library designed to simplify the integration of ImageKit into your server-side applications. It provides powerful tools for working with the ImageKit REST API, including building and transforming URLs, generating signed URLs for secure content delivery, verifying webhooks, and handling file uploads. @@ -24,6 +15,30 @@ The REST API documentation can be found on [imagekit.io](https://imagekit.io/doc +## Table of Contents + +- [Installation](#installation) +- [Requirements](#requirements) +- [Usage](#usage) +- [URL generation](#url-generation) + - [Basic URL generation](#basic-url-generation) + - [URL generation with transformations](#url-generation-with-transformations) + - [URL generation with image overlay](#url-generation-with-image-overlay) + - [URL generation with text overlay](#url-generation-with-text-overlay) + - [URL generation with multiple overlays](#url-generation-with-multiple-overlays) + - [Signed URLs for secure delivery](#signed-urls-for-secure-delivery) +- [Authentication parameters for client-side uploads](#authentication-parameters-for-client-side-uploads) +- [Webhook verification](#webhook-verification) +- [Advanced Usage](#advanced-usage) + - [Client configuration](#client-configuration) + - [File uploads](#file-uploads) + - [Error handling](#error-handling) + - [Retries](#retries) + - [Timeouts](#timeouts) + - [Proxies](#proxies) + - [Logging](#logging) +- [Semantic versioning](#semantic-versioning) + ## Installation @@ -59,17 +74,298 @@ import io.imagekit.models.files.FileUploadParams; import io.imagekit.models.files.FileUploadResponse; import java.io.ByteArrayInputStream; -// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables +// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() - .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) - .fileName("file-name.jpg") + .file(new FileInputStream("/path/to/your/image.jpg")) + .fileName("uploaded-image.jpg") .build(); FileUploadResponse response = client.files().upload(params); +System.out.println(response); +``` + +## URL generation + +The ImageKit SDK provides a powerful `client.helper().buildUrl()` method for generating optimized image and video URLs with transformations. + +### Basic URL generation + +Generate a simple URL without any transformations: + +```java +import io.imagekit.client.ImageKitClient; +import io.imagekit.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.models.SrcOptions; + +ImageKitClient client = ImageKitOkHttpClient.builder() + .privateKey("private_key_xxx") + .build(); + +String url = client.helper().buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") + .src("/path/to/image.jpg") + .build() +); +System.out.println(url); +// Result: https://ik.imagekit.io/your_imagekit_id/path/to/image.jpg +``` + +### URL generation with transformations + +Apply common transformations like resizing, quality, and format conversion: + +```java +import io.imagekit.models.SrcOptions; +import io.imagekit.models.Transformation; + +String url = client.helper().buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") + .src("/path/to/image.jpg") + .addTransformation( + Transformation.builder() + .width(400.0) + .height(300.0) + .crop(Transformation.Crop.MAINTAIN_RATIO) + .quality(80.0) + .format(Transformation.Format.WEBP) + .build() + ) + .build() +); +System.out.println(url); +// Result: https://ik.imagekit.io/your_imagekit_id/path/to/image.jpg?tr=w-400,h-300,c-maintain_ratio,q-80,f-webp +``` + +### URL generation with image overlay + +Add image overlays to your base image: + +```java +import io.imagekit.models.ImageOverlay; +import io.imagekit.models.Overlay; +import io.imagekit.models.OverlayPosition; +import io.imagekit.models.SrcOptions; +import io.imagekit.models.Transformation; + +String url = client.helper().buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") + .src("/path/to/base-image.jpg") + .addTransformation( + Transformation.builder() + .width(500.0) + .height(400.0) + .overlay(Overlay.ofImage( + ImageOverlay.builder() + .input("/path/to/overlay-logo.png") + .position(OverlayPosition.builder() + .x(10.0) + .y(10.0) + .build()) + .addTransformation( + Transformation.builder() + .width(100.0) + .height(50.0) + .build() + ) + .build() + )) + .build() + ) + .build() +); +System.out.println(url); +// Result: URL with image overlay positioned at x:10, y:10 +``` + +### URL generation with text overlay + +Add customized text overlays: + +```java +import io.imagekit.models.Overlay; +import io.imagekit.models.OverlayPosition; +import io.imagekit.models.SrcOptions; +import io.imagekit.models.TextOverlay; +import io.imagekit.models.TextOverlayTransformation; +import io.imagekit.models.Transformation; + +String url = client.helper().buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") + .src("/path/to/base-image.jpg") + .addTransformation( + Transformation.builder() + .width(600.0) + .height(400.0) + .overlay(Overlay.ofText( + TextOverlay.builder() + .text("Sample Text Overlay") + .position(OverlayPosition.builder() + .x(50.0) + .y(50.0) + .focus(OverlayPosition.Focus.CENTER) + .build()) + .addTransformation( + TextOverlayTransformation.builder() + .fontSize(40.0) + .fontFamily("Arial") + .fontColor("FFFFFF") + .build() + ) + .build() + )) + .build() + ) + .build() +); +System.out.println(url); +// Result: URL with white Arial text overlay at center position +``` + +### URL generation with multiple overlays + +Combine multiple overlays for complex compositions: + +```java +import io.imagekit.models.ImageOverlay; +import io.imagekit.models.Overlay; +import io.imagekit.models.OverlayPosition; +import io.imagekit.models.SrcOptions; +import io.imagekit.models.TextOverlay; +import io.imagekit.models.TextOverlayTransformation; +import io.imagekit.models.Transformation; +import java.util.Arrays; + +String url = client.helper().buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") + .src("/path/to/base-image.jpg") + .addTransformation( + // First transformation step: text overlay + Transformation.builder() + .width(800.0) + .height(600.0) + .overlay(Overlay.ofText( + TextOverlay.builder() + .text("Header Text") + .position(OverlayPosition.builder() + .x(20.0) + .y(20.0) + .build()) + .addTransformation( + TextOverlayTransformation.builder() + .fontSize(30.0) + .fontColor("000000") + .build() + ) + .build() + )) + .build() + ) + .addTransformation( + // Second transformation step: image watermark overlay + Transformation.builder() + .overlay(Overlay.ofImage( + ImageOverlay.builder() + .input("/watermark.png") + .position(OverlayPosition.builder() + .focus(OverlayPosition.Focus.BOTTOM_RIGHT) + .build()) + .addTransformation( + Transformation.builder() + .width(100.0) + .opacity(70.0) + .build() + ) + .build() + )) + .build() + ) + .build() +); +System.out.println(url); +// Result: URL with text overlay at top-left and semi-transparent watermark at bottom-right +``` + +### Signed URLs for secure delivery + +Generate signed URLs that expire after a specified time for secure content delivery: + +```java +import io.imagekit.models.SrcOptions; +import io.imagekit.models.Transformation; + +// Generate a signed URL that expires in 1 hour (3600 seconds) +String url = client.helper().buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") + .src("/private/secure-image.jpg") + .addTransformation( + Transformation.builder() + .width(400.0) + .height(300.0) + .quality(90.0) + .build() + ) + .signed(true) + .expiresIn(3600.0) // URL expires in 1 hour + .build() +); +System.out.println(url); +// Result: URL with signature parameters (?ik-t=timestamp&ik-s=signature) + +// Generate a signed URL that doesn't expire +String permanentSignedUrl = client.helper().buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/your_imagekit_id") + .src("/private/secure-image.jpg") + .signed(true) + // No expiresIn means the URL won't expire + .build() +); +System.out.println(permanentSignedUrl); +// Result: URL with signature parameter (?ik-s=signature) +``` + +## Authentication parameters for client-side uploads + +Generate authentication parameters for secure client-side file uploads: + +```java +import io.imagekit.client.ImageKitClient; +import io.imagekit.client.okhttp.ImageKitOkHttpClient; +import java.util.Map; + +ImageKitClient client = ImageKitOkHttpClient.builder() + .privateKey("private_key_xxx") + .build(); + +// Generate authentication parameters with auto-generated token and default expiry +Map authParams = client.helper().getAuthenticationParameters(null, null); +System.out.println(authParams); +// Result: {token=, expire=, signature=} + +// Generate with custom token and expiry +Map customAuthParams = client.helper().getAuthenticationParameters("my-custom-token", 1800L); +System.out.println(customAuthParams); +// Result: {token=my-custom-token, expire=1800, signature=} ``` +These authentication parameters can be used in client-side upload forms to securely upload files without exposing your private API key. + +## Webhook verification + +The ImageKit SDK provides utilities to verify webhook signatures for secure event handling. This ensures that webhook requests are actually coming from ImageKit and haven't been tampered with. + +For detailed information about webhook setup, signature verification, and handling different webhook events, refer to the [ImageKit webhook documentation](https://imagekit.io/docs/webhooks#verify-webhook-signature). + +# Advanced Usage + ## Client configuration Configure the client using system properties or environment variables: @@ -78,8 +374,8 @@ Configure the client using system properties or environment variables: import io.imagekit.client.ImageKitClient; import io.imagekit.client.okhttp.ImageKitOkHttpClient; -// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables +// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); ``` @@ -90,8 +386,7 @@ import io.imagekit.client.ImageKitClient; import io.imagekit.client.okhttp.ImageKitOkHttpClient; ImageKitClient client = ImageKitOkHttpClient.builder() - .privateKey("My Private Key") - .password("My Password") + .privateKey("private_key_xxx") .build(); ``` @@ -102,23 +397,20 @@ import io.imagekit.client.ImageKitClient; import io.imagekit.client.okhttp.ImageKitOkHttpClient; ImageKitClient client = ImageKitOkHttpClient.builder() - // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties - // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables + // Configures using the `imagekit.imagekitPrivateKey`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties + // Or configures using the `IMAGEKIT_PRIVATE_KEY`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables .fromEnv() - .privateKey("My Private Key") + .privateKey("private_key_xxx") .build(); ``` See this table for the available options: -| Setter | System property | Environment variable | Required | Default value | -| --------------- | -------------------------------------- | -------------------------------- | -------- | --------------------------- | -| `privateKey` | `imagekit.imagekitPrivateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - | -| `password` | `imagekit.optionalImagekitIgnoresThis` | `OPTIONAL_IMAGEKIT_IGNORES_THIS` | false | `"do_not_set"` | -| `webhookSecret` | `imagekit.imagekitWebhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - | -| `baseUrl` | `imagekit.baseUrl` | `IMAGE_KIT_BASE_URL` | true | `"https://api.imagekit.io"` | - -System properties take precedence over environment variables. +| Setter | Environment variable | Required | Default value | +| --------------- | -------------------------------- | -------- | --------------------------- | +| `privateKey` | `IMAGEKIT_PRIVATE_KEY` | true | - | +| `webhookSecret` | `IMAGEKIT_WEBHOOK_SECRET` | false | - | +| `baseUrl` | `IMAGE_KIT_BASE_URL` | false | `"https://api.imagekit.io"` | > [!TIP] > Don't create more than one client in the same application. Each client has a connection pool and @@ -162,16 +454,16 @@ import io.imagekit.client.ImageKitClient; import io.imagekit.client.okhttp.ImageKitOkHttpClient; import io.imagekit.models.files.FileUploadParams; import io.imagekit.models.files.FileUploadResponse; -import java.io.ByteArrayInputStream; +import java.io.FileInputStream; import java.util.concurrent.CompletableFuture; -// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables +// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClient client = ImageKitOkHttpClient.fromEnv(); FileUploadParams params = FileUploadParams.builder() - .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) - .fileName("file-name.jpg") + .file(new FileInputStream("/path/to/your/image.jpg")) + .fileName("uploaded-image.jpg") .build(); CompletableFuture response = client.async().files().upload(params); ``` @@ -183,16 +475,16 @@ import io.imagekit.client.ImageKitClientAsync; import io.imagekit.client.okhttp.ImageKitOkHttpClientAsync; import io.imagekit.models.files.FileUploadParams; import io.imagekit.models.files.FileUploadResponse; -import java.io.ByteArrayInputStream; +import java.io.FileInputStream; import java.util.concurrent.CompletableFuture; -// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.optionalImagekitIgnoresThis`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties -// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `OPTIONAL_IMAGEKIT_IGNORES_THIS`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables +// Configures using the `imagekit.imagekitPrivateKey`, `imagekit.imagekitWebhookSecret` and `imagekit.baseUrl` system properties +// Or configures using the `IMAGEKIT_PRIVATE_KEY`, `IMAGEKIT_WEBHOOK_SECRET` and `IMAGE_KIT_BASE_URL` environment variables ImageKitClientAsync client = ImageKitOkHttpClientAsync.fromEnv(); FileUploadParams params = FileUploadParams.builder() - .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) - .fileName("file-name.jpg") + .file(new FileInputStream("/path/to/your/image.jpg")) + .fileName("uploaded-image.jpg") .build(); CompletableFuture response = client.files().upload(params); ``` @@ -211,8 +503,8 @@ import io.imagekit.models.files.FileUploadResponse; import java.nio.file.Paths; FileUploadParams params = FileUploadParams.builder() - .fileName("fileName") - .file(Paths.get("/path/to/file")) + .fileName("uploaded-image.jpg") + .file(Paths.get("/path/to/your/image.jpg")) .build(); FileUploadResponse response = client.files().upload(params); ``` @@ -222,11 +514,11 @@ Or an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/i ```java import io.imagekit.models.files.FileUploadParams; import io.imagekit.models.files.FileUploadResponse; -import java.net.URL; +import java.io.FileInputStream; FileUploadParams params = FileUploadParams.builder() - .fileName("fileName") - .file(new URL("https://example.com//path/to/file").openStream()) + .fileName("uploaded-image.jpg") + .file(new FileInputStream("/path/to/your/image.jpg")) .build(); FileUploadResponse response = client.files().upload(params); ``` @@ -237,9 +529,10 @@ Or a `byte[]` array: import io.imagekit.models.files.FileUploadParams; import io.imagekit.models.files.FileUploadResponse; +byte[] imageData = /* your binary data */; FileUploadParams params = FileUploadParams.builder() - .fileName("fileName") - .file("content".getBytes()) + .fileName("binary-upload.jpg") + .file(imageData) .build(); FileUploadResponse response = client.files().upload(params); ``` @@ -250,14 +543,15 @@ Note that when passing a non-`Path` its filename is unknown so it will not be in import io.imagekit.core.MultipartField; import io.imagekit.models.files.FileUploadParams; import io.imagekit.models.files.FileUploadResponse; +import java.io.FileInputStream; import java.io.InputStream; -import java.net.URL; FileUploadParams params = FileUploadParams.builder() - .fileName("fileName") + .fileName("custom-upload.jpg") .file(MultipartField.builder() - .value(new URL("https://example.com//path/to/file").openStream()) - .filename("/path/to/file") + .value(new FileInputStream("/path/to/your/image.jpg")) + .filename("image.jpg") + .contentType("image/jpeg") .build()) .build(); FileUploadResponse response = client.files().upload(params); @@ -274,11 +568,11 @@ import io.imagekit.core.http.Headers; import io.imagekit.core.http.HttpResponseFor; import io.imagekit.models.files.FileUploadParams; import io.imagekit.models.files.FileUploadResponse; -import java.io.ByteArrayInputStream; +import java.io.FileInputStream; FileUploadParams params = FileUploadParams.builder() - .file(new ByteArrayInputStream("https://www.example.com/public-url.jpg".getBytes())) - .fileName("file-name.jpg") + .file(new FileInputStream("/path/to/your/image.jpg")) + .fileName("uploaded-image.jpg") .build(); HttpResponseFor response = client.files().withRawResponse().upload(params); diff --git a/buildSrc/src/main/kotlin/image-kit.java.gradle.kts b/buildSrc/src/main/kotlin/image-kit.java.gradle.kts index 8f4f902a..0f1f0c0e 100644 --- a/buildSrc/src/main/kotlin/image-kit.java.gradle.kts +++ b/buildSrc/src/main/kotlin/image-kit.java.gradle.kts @@ -10,7 +10,7 @@ repositories { java { toolchain { - languageVersion.set(JavaLanguageVersion.of(21)) + languageVersion.set(JavaLanguageVersion.of(17)) } sourceCompatibility = JavaVersion.VERSION_1_8 diff --git a/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts b/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts index dd476783..ffb5e8d6 100644 --- a/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/image-kit.kotlin.gradle.kts @@ -12,7 +12,7 @@ repositories { kotlin { jvmToolchain { - languageVersion.set(JavaLanguageVersion.of(21)) + languageVersion.set(JavaLanguageVersion.of(17)) } compilerOptions { 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 a1946c26..9a3a74ca 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 @@ -3,6 +3,7 @@ package io.imagekit.client import io.imagekit.core.ClientOptions +import io.imagekit.lib.HelperService import io.imagekit.services.blocking.AccountService import io.imagekit.services.blocking.AssetService import io.imagekit.services.blocking.BetaService @@ -68,6 +69,8 @@ interface ImageKitClient { fun webhooks(): WebhookService + fun helper(): HelperService + /** * Closes this client, relinquishing any underlying resources. * 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 1dd949c6..cba5ce63 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 @@ -3,6 +3,7 @@ package io.imagekit.client import io.imagekit.core.ClientOptions +import io.imagekit.lib.HelperService import io.imagekit.services.async.AccountServiceAsync import io.imagekit.services.async.AssetServiceAsync import io.imagekit.services.async.BetaServiceAsync @@ -68,6 +69,8 @@ interface ImageKitClientAsync { fun webhooks(): WebhookServiceAsync + fun helper(): HelperService + /** * Closes this client, relinquishing any underlying resources. * 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 7acd014c..ef9cab34 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 @@ -4,6 +4,8 @@ package io.imagekit.client import io.imagekit.core.ClientOptions import io.imagekit.core.getPackageVersion +import io.imagekit.lib.Helper +import io.imagekit.lib.HelperService import io.imagekit.services.async.AccountServiceAsync import io.imagekit.services.async.AccountServiceAsyncImpl import io.imagekit.services.async.AssetServiceAsync @@ -73,6 +75,8 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK WebhookServiceAsyncImpl(clientOptionsWithUserAgent) } + private val helper: Helper by lazy { Helper.create(clientOptions) } + override fun sync(): ImageKitClient = sync override fun withRawResponse(): ImageKitClientAsync.WithRawResponse = withRawResponse @@ -98,6 +102,8 @@ class ImageKitClientAsyncImpl(private val clientOptions: ClientOptions) : ImageK override fun webhooks(): WebhookServiceAsync = webhooks + override fun helper(): HelperService = helper + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : 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 18683fc3..b8deaa48 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 @@ -4,6 +4,8 @@ package io.imagekit.client import io.imagekit.core.ClientOptions import io.imagekit.core.getPackageVersion +import io.imagekit.lib.Helper +import io.imagekit.lib.HelperService import io.imagekit.services.blocking.AccountService import io.imagekit.services.blocking.AccountServiceImpl import io.imagekit.services.blocking.AssetService @@ -63,6 +65,8 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli private val webhooks: WebhookService by lazy { WebhookServiceImpl(clientOptionsWithUserAgent) } + private val helper: Helper by lazy { Helper.create(clientOptions) } + override fun async(): ImageKitClientAsync = async override fun withRawResponse(): ImageKitClient.WithRawResponse = withRawResponse @@ -88,6 +92,8 @@ class ImageKitClientImpl(private val clientOptions: ClientOptions) : ImageKitCli override fun webhooks(): WebhookService = webhooks + override fun helper(): HelperService = helper + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/lib/Helper.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/lib/Helper.kt new file mode 100644 index 00000000..6f0c49c1 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/lib/Helper.kt @@ -0,0 +1,970 @@ +// Package lib provides helper utilities for ImageKit SDK +// This file contains custom helper functions - not generated + +package io.imagekit.lib + +import io.imagekit.core.ClientOptions +import io.imagekit.models.SrcOptions +import io.imagekit.models.Transformation +import io.imagekit.models.TransformationPosition +import java.security.SecureRandom +import java.time.Instant +import javax.crypto.Mac +import javax.crypto.spec.SecretKeySpec + +/** + * Helper service containing utility methods for ImageKit SDK operations like URL building, + * transformation string generation, and authentication parameter generation. + */ +class Helper(private val privateKey: String) : HelperService { + + companion object { + private const val DEFAULT_TIMESTAMP = 9999999999L + + /** + * Creates a new Helper instance with the given private key. + * + * @param privateKey The private API key from ImageKit dashboard + * @return A new Helper instance + */ + @JvmStatic fun create(privateKey: String): Helper = Helper(privateKey) + + /** + * Creates a new Helper instance from ClientOptions. + * + * @param options The client options containing the private key + * @return A new Helper instance + */ + @JvmStatic fun create(options: ClientOptions): Helper = Helper(options.privateKey) + } + + /** + * Builds a URL with the given options including transformations. + * + * @param options The source options for URL generation + * @return The generated URL string + */ + override fun buildUrl(options: SrcOptions): String { + val urlEndpoint = options.urlEndpoint() + val src = options.src() + + if (src.isEmpty()) { + return "" + } + + val transformationPosition = + options.transformationPosition().orElse(TransformationPosition.QUERY) + + val isAbsoluteURL = src.startsWith("http://") || src.startsWith("https://") + + val urlObj: java.net.URL + val isSrcParameterUsedForURL: Boolean + + try { + if (!isAbsoluteURL) { + urlObj = java.net.URL(urlEndpoint) + isSrcParameterUsedForURL = false + } else { + urlObj = java.net.URL(src) + isSrcParameterUsedForURL = true + } + } catch (e: Exception) { + return "" + } + + // Extract existing query parameters from URL if present + val existingQuery = + if (isSrcParameterUsedForURL && urlObj.query != null) { + urlObj.query + } else { + "" + } + + // Build query parameters + val queryParts = mutableListOf() + + // Add existing query parameters first + if (existingQuery.isNotEmpty()) { + queryParts.add(existingQuery) + } + + // Add new query parameters (sorted alphabetically for consistent signing) + options.queryParameters().ifPresent { queryParams -> + val params = queryParams._additionalProperties() + if (params.isNotEmpty()) { + val newQuery = + params.entries + .sortedBy { it.key } // Sort alphabetically by key + .joinToString("&") { (key, value) -> + val valueStr = + value.asString().orElseGet { + value + .asNumber() + .map { it.toString() } + .orElseGet { + value + .asBoolean() + .map { it.toString() } + .orElse(value.toString()) + } + } + "${java.net.URLEncoder.encode(key, "UTF-8")}=${java.net.URLEncoder.encode(valueStr, "UTF-8")}" + } + queryParts.add(newQuery) + } + } + + val query = queryParts.joinToString("&") + + // Build transformation string + val transformationString = + options.transformation().map { buildTransformationString(it) }.orElse("") + + // Determine if transformation will be in query params + val addAsQuery = + transformationPosition == TransformationPosition.QUERY || isSrcParameterUsedForURL + + // Transformation placeholder to avoid URL encoding issues + val transformationPlaceholder = "PLEASEREPLACEJUSTBEFORESIGN" + + // Build the URL path + var path = "" + if (!isAbsoluteURL) { + // For non-absolute URLs, construct: endpoint_path + transformations + src + val endpointPath = urlObj.path.ifEmpty { "/" } + val pathParts = mutableListOf() + pathParts.add(endpointPath) + + if (transformationString.isNotEmpty() && !addAsQuery) { + pathParts.add("tr:$transformationPlaceholder") + } + pathParts.add(src) + + path = pathParts.joinToString("/") { it.trim('/') }.replace(Regex("/+"), "/") + if (!path.startsWith("/")) { + path = "/$path" + } + } else { + path = urlObj.path + } + + // Build the complete URL using URI to properly encode the path + val uriString = + try { + java.net + .URI( + urlObj.protocol, + null, // user info + urlObj.host, + if (urlObj.port != -1 && urlObj.port != urlObj.defaultPort) urlObj.port + else -1, + path, + null, // query will be added later + null, // fragment + ) + .toASCIIString() + } catch (e: Exception) { + // Fallback to manual construction + "${urlObj.protocol}://${urlObj.host}${if (urlObj.port != -1 && urlObj.port != urlObj.defaultPort) ":${urlObj.port}" else ""}$path" + } + + var finalURL = uriString + + // Add query parameters + if (query.isNotEmpty()) { + finalURL += "?$query" + } + + // Add transformation parameter to query if needed + if (transformationString.isNotEmpty() && addAsQuery) { + val separator = if (query.isEmpty()) "?" else "&" + finalURL += "${separator}tr=$transformationPlaceholder" + } + + // Replace the placeholder with actual transformation string + if (transformationString.isNotEmpty()) { + finalURL = finalURL.replace(transformationPlaceholder, transformationString) + } + + // Sign the URL if needed + val shouldSign = options.signed().orElse(false) || (options.expiresIn().orElse(0.0) > 0) + if (shouldSign) { + val expiryTimestamp = getSignatureTimestamp(options.expiresIn().orElse(0.0)) + val urlSignature = getSignature(finalURL, urlEndpoint, expiryTimestamp) + + val hasExistingParams = finalURL.contains("?") + val separator = if (hasExistingParams) "&" else "?" + + if (expiryTimestamp != DEFAULT_TIMESTAMP) { + finalURL += "${separator}ik-t=$expiryTimestamp&ik-s=$urlSignature" + } else { + finalURL += "${separator}ik-s=$urlSignature" + } + } + + return finalURL + } + + private fun getSignatureTimestamp(expiresIn: Double): Long { + return if (expiresIn > 0) { + Instant.now().epochSecond + expiresIn.toLong() + } else { + DEFAULT_TIMESTAMP + } + } + + private fun getSignature(finalURL: String, urlEndpoint: String, expiryTimestamp: Long): String { + if (privateKey.isEmpty() || finalURL.isEmpty() || urlEndpoint.isEmpty()) { + return "" + } + + // Create the string to sign: relative path + expiry timestamp + val urlEndpointWithSlash = if (urlEndpoint.endsWith("/")) urlEndpoint else "$urlEndpoint/" + val stringToSign = + finalURL.replaceFirst(urlEndpointWithSlash, "") + expiryTimestamp.toString() + + val mac = Mac.getInstance("HmacSHA1") + val secretKey = SecretKeySpec(privateKey.toByteArray(), "HmacSHA1") + mac.init(secretKey) + val hash = mac.doFinal(stringToSign.toByteArray()) + + return hash.joinToString("") { "%02x".format(it) } + } + + /** + * Builds a transformation string from the given transformations. + * + * @param transformations The list of transformations + * @return The transformation string + */ + override fun buildTransformationString(transformations: List?): String { + if (transformations.isNullOrEmpty()) { + return "" + } + + val parsedTransforms = mutableListOf() + + for (transform in transformations) { + val parts = mutableListOf() + + // Basic transformations (in order from Go SDK) + + // Width + transform.width().ifPresent { w -> + when { + w.isNumber() -> parts.add("w-${formatNumber(w.asNumber())}") + w.isString() -> parts.add("w-${w.asString()}") + } + } + + // Height + transform.height().ifPresent { h -> + when { + h.isNumber() -> parts.add("h-${formatNumber(h.asNumber())}") + h.isString() -> parts.add("h-${h.asString()}") + } + } + + // Quality + transform.quality().ifPresent { q -> parts.add("q-${formatNumber(q)}") } + + // Aspect Ratio + transform.aspectRatio().ifPresent { ar -> + when { + ar.isNumber() -> parts.add("ar-${formatNumber(ar.asNumber())}") + ar.isString() -> parts.add("ar-${ar.asString()}") + } + } + + // Crop + transform.crop().ifPresent { c -> if (c.toString().isNotEmpty()) parts.add("c-$c") } + + // Crop Mode + transform.cropMode().ifPresent { cm -> + if (cm.toString().isNotEmpty()) parts.add("cm-$cm") + } + + // Focus + transform.focus().ifPresent { fo -> parts.add("fo-$fo") } + + // Format + transform.format().ifPresent { f -> if (f.toString().isNotEmpty()) parts.add("f-$f") } + + // Radius + transform.radius().ifPresent { r -> + when { + r.isMax() -> parts.add("r-max") + r.isNumber() -> parts.add("r-${formatNumber(r.asNumber())}") + r.isString() -> parts.add("r-${r.asString()}") + } + } + + // Background + transform.background().ifPresent { bg -> parts.add("bg-$bg") } + + // Border + transform.border().ifPresent { b -> parts.add("b-$b") } + + // Color Replace + transform.colorReplace().ifPresent { cr -> parts.add("cr-$cr") } + + // Default Image + transform.defaultImage().ifPresent { di -> + if (di.isNotEmpty()) { + val value = di.removePrefix("/").removeSuffix("/").replace("/", "@@") + parts.add("di-$value") + } + } + + // DPR + transform.dpr().ifPresent { dpr -> parts.add("dpr-${formatNumber(dpr)}") } + + // X position + transform.x().ifPresent { x -> + when { + x.isNumber() -> parts.add("x-${formatNumber(x.asNumber())}") + x.isString() -> parts.add("x-${x.asString()}") + } + } + + // Y position + transform.y().ifPresent { y -> + when { + y.isNumber() -> parts.add("y-${formatNumber(y.asNumber())}") + y.isString() -> parts.add("y-${y.asString()}") + } + } + + // X Center + transform.xCenter().ifPresent { xc -> + when { + xc.isNumber() -> parts.add("xc-${formatNumber(xc.asNumber())}") + xc.isString() -> parts.add("xc-${xc.asString()}") + } + } + + // Y Center + transform.yCenter().ifPresent { yc -> + when { + yc.isNumber() -> parts.add("yc-${formatNumber(yc.asNumber())}") + yc.isString() -> parts.add("yc-${yc.asString()}") + } + } + + // Opacity + transform.opacity().ifPresent { o -> parts.add("o-${formatNumber(o)}") } + + // Zoom + transform.zoom().ifPresent { z -> parts.add("z-${formatNumber(z)}") } + + // Rotation + transform.rotation().ifPresent { rt -> + when { + rt.isNumber() -> parts.add("rt-${formatNumber(rt.asNumber())}") + rt.isString() -> parts.add("rt-${rt.asString()}") + } + } + + // Blur + transform.blur().ifPresent { bl -> parts.add("bl-${formatNumber(bl)}") } + + // Named + transform.named().ifPresent { n -> parts.add("n-$n") } + + // Progressive + transform.progressive().ifPresent { pr -> parts.add("pr-$pr") } + + // Lossless + transform.lossless().ifPresent { lo -> parts.add("lo-$lo") } + + // Flip + transform.flip().ifPresent { fl -> if (fl.toString().isNotEmpty()) parts.add("fl-$fl") } + + // Trim + transform.trim().ifPresent { t -> + when { + t.isTrue() -> parts.add("t-true") + t.isNumber() -> parts.add("t-${formatNumber(t.asNumber())}") + } + } + + // Metadata + transform.metadata().ifPresent { md -> parts.add("md-$md") } + + // Color Profile + transform.colorProfile().ifPresent { cp -> parts.add("cp-$cp") } + + // Video Codec + transform.videoCodec().ifPresent { vc -> + if (vc.toString().isNotEmpty()) parts.add("vc-$vc") + } + + // Audio Codec + transform.audioCodec().ifPresent { ac -> + if (ac.toString().isNotEmpty()) parts.add("ac-$ac") + } + + // Start Offset + transform.startOffset().ifPresent { so -> + when { + so.isNumber() -> parts.add("so-${formatNumber(so.asNumber())}") + so.isString() -> parts.add("so-${so.asString()}") + } + } + + // End Offset + transform.endOffset().ifPresent { eo -> + when { + eo.isNumber() -> parts.add("eo-${formatNumber(eo.asNumber())}") + eo.isString() -> parts.add("eo-${eo.asString()}") + } + } + + // Duration + transform.duration().ifPresent { du -> + when { + du.isNumber() -> parts.add("du-${formatNumber(du.asNumber())}") + du.isString() -> parts.add("du-${du.asString()}") + } + } + + // Streaming Resolutions + transform.streamingResolutions().ifPresent { resolutions -> + if (resolutions.isNotEmpty()) { + val sr = resolutions.joinToString("_") + parts.add("sr-$sr") + } + } + + // AI transformations (boolean flags) + transform.grayscale().ifPresent { gs -> if (gs.asBoolean()) parts.add("e-grayscale") } + transform.aiUpscale().ifPresent { au -> if (au.asBoolean()) parts.add("e-upscale") } + transform.aiRetouch().ifPresent { ar -> if (ar.asBoolean()) parts.add("e-retouch") } + transform.aiVariation().ifPresent { av -> if (av.asBoolean()) parts.add("e-genvar") } + transform.aiRemoveBackground().ifPresent { rb -> + if (rb.asBoolean()) parts.add("e-bgremove") + } + transform.aiRemoveBackgroundExternal().ifPresent { re -> + if (re.asBoolean()) parts.add("e-removedotbg") + } + transform.contrastStretch().ifPresent { cs -> + if (cs.asBoolean()) parts.add("e-contrast") + } + + // AI Drop Shadow + transform.aiDropShadow().ifPresent { ds -> + when { + ds.isTrue() -> parts.add("e-dropshadow") + ds.isString() -> parts.add("e-dropshadow-${ds.asString()}") + } + } + + // AI Change Background + transform.aiChangeBackground().ifPresent { bg -> parts.add("e-changebg-$bg") } + + // AI Edit + transform.aiEdit().ifPresent { edit -> parts.add("e-edit-$edit") } + + // Effects + transform.shadow().ifPresent { s -> + when { + s.isTrue() -> parts.add("e-shadow") + s.isString() -> parts.add("e-shadow-${s.asString()}") + } + } + + transform.sharpen().ifPresent { sh -> + when { + sh.isTrue() -> parts.add("e-sharpen") + sh.isNumber() -> parts.add("e-sharpen-${formatNumber(sh.asNumber())}") + } + } + + transform.unsharpMask().ifPresent { usm -> + when { + usm.isTrue() -> parts.add("e-usm") + usm.isString() -> parts.add("e-usm-${usm.asString()}") + } + } + + transform.gradient().ifPresent { gr -> + when { + gr.isTrue() -> parts.add("e-gradient") + gr.isString() -> parts.add("e-gradient-${gr.asString()}") + } + } + + transform.distort().ifPresent { d -> parts.add("e-distort-$d") } + + // Original + transform.original().ifPresent { orig -> if (orig) parts.add("orig-true") } + + // Page + transform.page().ifPresent { pg -> + when { + pg.isNumber() -> parts.add("pg-${formatNumber(pg.asNumber())}") + pg.isString() -> parts.add("pg-${pg.asString()}") + } + } + + // Overlay + transform.overlay().ifPresent { overlay -> + val overlayStr = processOverlay(overlay) + if (overlayStr.isNotEmpty()) { + parts.add(overlayStr) + } + } + + // Raw parameter (added last) + transform.raw().ifPresent { raw -> + if (raw.isNotEmpty()) { + parts.add(raw) + } + } + + if (parts.isNotEmpty()) { + parsedTransforms.add(parts.joinToString(",")) + } + } + + return parsedTransforms.joinToString(":") + } + + private fun formatNumber(value: Double): String { + return if (value == value.toLong().toDouble()) { + value.toLong().toString() + } else { + value.toString() + } + } + + private val simpleOverlayPathRegex = Regex("^[a-zA-Z0-9\\-._/ ]*$") + private val simpleOverlayTextRegex = Regex("^[a-zA-Z0-9\\-._ ]*$") + + private fun processOverlay(overlay: io.imagekit.models.Overlay): String { + val entries = mutableListOf() + var transformationString = "" + + // Each branch: add layer type + input, extract base overlay fields, build transformation + // string + var layerMode: String? = null + var position: io.imagekit.models.OverlayPosition? = null + var timing: io.imagekit.models.OverlayTiming? = null + + when { + overlay.isText() -> { + val textOverlay = overlay.asText() + if (textOverlay.text().isEmpty()) return "" + + val encoding = + textOverlay.encoding().orElse(null)?.toString()?.lowercase() ?: "auto" + entries.add("l-text") + entries.add(processText(textOverlay.text(), encoding)) + + textOverlay.layerMode().ifPresent { layerMode = it.toString().lowercase() } + textOverlay.position().ifPresent { position = it } + textOverlay.timing().ifPresent { timing = it } + + textOverlay.transformation().ifPresent { transformations -> + if (transformations.isNotEmpty()) { + transformationString = buildTextOverlayTransformation(transformations) + } + } + } + + overlay.isImage() -> { + val imageOverlay = overlay.asImage() + if (imageOverlay.input().isEmpty()) return "" + + val encoding = + imageOverlay.encoding().orElse(null)?.toString()?.lowercase() ?: "auto" + entries.add("l-image") + entries.add(processInputPath(imageOverlay.input(), encoding)) + + imageOverlay.layerMode().ifPresent { layerMode = it.toString().lowercase() } + imageOverlay.position().ifPresent { position = it } + imageOverlay.timing().ifPresent { timing = it } + + imageOverlay.transformation().ifPresent { transformations -> + if (transformations.isNotEmpty()) { + transformationString = buildTransformationString(transformations) + } + } + } + + overlay.isVideo() -> { + val videoOverlay = overlay.asVideo() + if (videoOverlay.input().isEmpty()) return "" + + val encoding = + videoOverlay.encoding().orElse(null)?.toString()?.lowercase() ?: "auto" + entries.add("l-video") + entries.add(processInputPath(videoOverlay.input(), encoding)) + + videoOverlay.layerMode().ifPresent { layerMode = it.toString().lowercase() } + videoOverlay.position().ifPresent { position = it } + videoOverlay.timing().ifPresent { timing = it } + + videoOverlay.transformation().ifPresent { transformations -> + if (transformations.isNotEmpty()) { + transformationString = buildTransformationString(transformations) + } + } + } + + overlay.isSubtitle() -> { + val subtitleOverlay = overlay.asSubtitle() + if (subtitleOverlay.input().isEmpty()) return "" + + val encoding = + subtitleOverlay.encoding().orElse(null)?.toString()?.lowercase() ?: "auto" + entries.add("l-subtitles") + entries.add(processInputPath(subtitleOverlay.input(), encoding)) + + subtitleOverlay.layerMode().ifPresent { layerMode = it.toString().lowercase() } + subtitleOverlay.position().ifPresent { position = it } + subtitleOverlay.timing().ifPresent { timing = it } + + subtitleOverlay.transformation().ifPresent { transformations -> + if (transformations.isNotEmpty()) { + transformationString = buildSubtitleOverlayTransformation(transformations) + } + } + } + + overlay.isSolidColor() -> { + val solidColorOverlay = overlay.asSolidColor() + if (solidColorOverlay.color().isEmpty()) return "" + + entries.add("l-image") + entries.add("i-ik_canvas") + entries.add("bg-${solidColorOverlay.color()}") + + solidColorOverlay.layerMode().ifPresent { layerMode = it.toString().lowercase() } + solidColorOverlay.position().ifPresent { position = it } + solidColorOverlay.timing().ifPresent { timing = it } + + solidColorOverlay.transformation().ifPresent { transformations -> + if (transformations.isNotEmpty()) { + transformationString = buildSolidColorOverlayTransformation(transformations) + } + } + } + } + + if (entries.isEmpty()) return "" + + // Shared base overlay processing (matches Go's order) + // LayerMode + if (!layerMode.isNullOrEmpty()) { + entries.add("lm-$layerMode") + } + + // Position + if (position != null) { + processOverlayPosition(position!!, entries) + } + + // Timing + if (timing != null) { + processOverlayTiming(timing!!, entries) + } + + // Transformation string + if (transformationString.isNotEmpty()) { + entries.add(transformationString) + } + + // Close layer + entries.add("l-end") + return entries.joinToString(",") + } + + private fun processInputPath(str: String, encoding: String): String { + val cleaned = str.removePrefix("/").removeSuffix("/") + + if (encoding == "plain") { + return "i-${cleaned.replace("/", "@@")}" + } + + if (encoding == "base64") { + val base64 = java.util.Base64.getEncoder().encodeToString(cleaned.toByteArray()) + return "ie-${java.net.URLEncoder.encode(base64, "UTF-8")}" + } + + // Auto-detect + if (simpleOverlayPathRegex.matches(cleaned)) { + return "i-${cleaned.replace("/", "@@")}" + } + + val base64 = java.util.Base64.getEncoder().encodeToString(cleaned.toByteArray()) + return "ie-${java.net.URLEncoder.encode(base64, "UTF-8")}" + } + + private fun processText(str: String, encoding: String): String { + if (encoding == "plain") { + return "i-${pathEscape(str)}" + } + + if (encoding == "base64") { + val base64 = java.util.Base64.getEncoder().encodeToString(str.toByteArray()) + return "ie-${java.net.URLEncoder.encode(base64, "UTF-8")}" + } + + // Auto-detect + if (simpleOverlayTextRegex.matches(str)) { + return "i-${pathEscape(str)}" + } + + val base64 = java.util.Base64.getEncoder().encodeToString(str.toByteArray()) + return "ie-${java.net.URLEncoder.encode(base64, "UTF-8")}" + } + + /** Equivalent to Go's url.PathEscape — encodes for use in URL path segments */ + private fun pathEscape(str: String): String { + return java.net.URI(null, null, "/$str", null).toASCIIString().removePrefix("/") + } + + private fun buildTextOverlayTransformation( + transformations: List + ): String { + val entries = mutableListOf() + for (transform in transformations) { + processTextOverlayTransformation(transform, entries) + } + return entries.joinToString(",") + } + + private fun buildSubtitleOverlayTransformation( + transformations: List + ): String { + val entries = mutableListOf() + for (transform in transformations) { + processSubtitleOverlayTransformation(transform, entries) + } + return entries.joinToString(",") + } + + private fun buildSolidColorOverlayTransformation( + transformations: List + ): String { + val entries = mutableListOf() + for (transform in transformations) { + processSolidColorOverlayTransformation(transform, entries) + } + return entries.joinToString(",") + } + + private fun processTextOverlayTransformation( + transform: io.imagekit.models.TextOverlayTransformation, + parts: MutableList, + ) { + transform.width().ifPresent { w -> + when { + w.isNumber() -> parts.add("w-${formatNumber(w.asNumber())}") + w.isString() -> parts.add("w-${w.asString()}") + } + } + transform.fontSize().ifPresent { fs -> + when { + fs.isNumber() -> parts.add("fs-${formatNumber(fs.asNumber())}") + fs.isString() -> parts.add("fs-${fs.asString()}") + } + } + transform.fontFamily().ifPresent { ff -> + val cleaned = ff.removePrefix("/").removeSuffix("/").replace("/", "@@") + parts.add("ff-$cleaned") + } + transform.fontColor().ifPresent { fc -> parts.add("co-$fc") } + transform.innerAlignment().ifPresent { ia -> parts.add("ia-${ia.toString().lowercase()}") } + transform.padding().ifPresent { p -> + when { + p.isNumber() -> parts.add("pa-${formatNumber(p.asNumber())}") + p.isString() -> parts.add("pa-${p.asString()}") + } + } + transform.alpha().ifPresent { a -> parts.add("al-${formatNumber(a)}") } + transform.typography().ifPresent { t -> parts.add("tg-$t") } + transform.background().ifPresent { bg -> parts.add("bg-$bg") } + transform.radius().ifPresent { r -> + when { + r.isMax() -> parts.add("r-max") + r.isNumber() -> parts.add("r-${formatNumber(r.asNumber())}") + r.isString() -> parts.add("r-${r.asString()}") + } + } + transform.rotation().ifPresent { rt -> + when { + rt.isNumber() -> parts.add("rt-${formatNumber(rt.asNumber())}") + rt.isString() -> parts.add("rt-${rt.asString()}") + } + } + transform.flip().ifPresent { fl -> parts.add("fl-${fl.toString().lowercase()}") } + transform.lineHeight().ifPresent { lh -> + when { + lh.isNumber() -> parts.add("lh-${formatNumber(lh.asNumber())}") + lh.isString() -> parts.add("lh-${lh.asString()}") + } + } + } + + private fun processSolidColorOverlayTransformation( + transform: io.imagekit.models.SolidColorOverlayTransformation, + parts: MutableList, + ) { + transform.width().ifPresent { w -> + when { + w.isNumber() -> parts.add("w-${formatNumber(w.asNumber())}") + w.isString() -> parts.add("w-${w.asString()}") + } + } + transform.height().ifPresent { h -> + when { + h.isNumber() -> parts.add("h-${formatNumber(h.asNumber())}") + h.isString() -> parts.add("h-${h.asString()}") + } + } + transform.alpha().ifPresent { a -> parts.add("al-${formatNumber(a)}") } + transform.background().ifPresent { bg -> parts.add("bg-$bg") } + transform.gradient().ifPresent { g -> + when { + g.isTrue() -> parts.add("e-gradient") + g.isString() -> parts.add("e-gradient-${g.asString()}") + } + } + transform.radius().ifPresent { r -> + when { + r.isMax() -> parts.add("r-max") + r.isNumber() -> parts.add("r-${formatNumber(r.asNumber())}") + r.isString() -> parts.add("r-${r.asString()}") + } + } + } + + private fun processSubtitleOverlayTransformation( + transform: io.imagekit.models.SubtitleOverlayTransformation, + parts: MutableList, + ) { + transform.background().ifPresent { bg -> parts.add("bg-$bg") } + transform.color().ifPresent { c -> parts.add("co-$c") } + transform.fontSize().ifPresent { fs -> parts.add("fs-${formatNumber(fs)}") } + transform.fontFamily().ifPresent { ff -> parts.add("ff-$ff") } + transform.fontOutline().ifPresent { fo -> parts.add("fol-$fo") } + transform.fontShadow().ifPresent { fs -> parts.add("fsh-$fs") } + transform.typography().ifPresent { tg -> parts.add("tg-$tg") } + } + + private fun processOverlayPosition( + position: io.imagekit.models.OverlayPosition, + parts: MutableList, + ) { + position.x().ifPresent { x -> + when { + x.isNumber() -> parts.add("lx-${formatNumber(x.asNumber())}") + x.isString() -> parts.add("lx-${x.asString()}") + } + } + position.y().ifPresent { y -> + when { + y.isNumber() -> parts.add("ly-${formatNumber(y.asNumber())}") + y.isString() -> parts.add("ly-${y.asString()}") + } + } + position.xCenter().ifPresent { xc -> + when { + xc.isNumber() -> parts.add("lxc-${formatNumber(xc.asNumber())}") + xc.isString() -> parts.add("lxc-${xc.asString()}") + } + } + position.yCenter().ifPresent { yc -> + when { + yc.isNumber() -> parts.add("lyc-${formatNumber(yc.asNumber())}") + yc.isString() -> parts.add("lyc-${yc.asString()}") + } + } + position.anchorPoint().ifPresent { ap -> parts.add("lap-${ap.toString().lowercase()}") } + position.focus().ifPresent { f -> parts.add("lfo-${f.toString().lowercase()}") } + } + + private fun processOverlayTiming( + timing: io.imagekit.models.OverlayTiming, + parts: MutableList, + ) { + timing.start().ifPresent { s -> + when { + s.isNumber() -> parts.add("lso-${formatNumber(s.asNumber())}") + s.isString() -> parts.add("lso-${s.asString()}") + } + } + timing.end().ifPresent { e -> + when { + e.isNumber() -> parts.add("leo-${formatNumber(e.asNumber())}") + e.isString() -> parts.add("leo-${e.asString()}") + } + } + timing.duration().ifPresent { d -> + when { + d.isNumber() -> parts.add("ldu-${formatNumber(d.asNumber())}") + d.isString() -> parts.add("ldu-${d.asString()}") + } + } + } + + /** + * Generates authentication parameters for client-side file uploads. + * + * @param token Optional custom token. If null or empty, a random token will be generated. + * @param expire Optional expiration timestamp in seconds. If 0 or null, defaults to 30 minutes + * from now. + * @return Map containing token, expire, and signature + */ + override fun getAuthenticationParameters(token: String?, expire: Long?): Map { + if (privateKey.isEmpty()) { + throw IllegalStateException( + "private API key is required for authentication parameters generation" + ) + } + + val defaultExpire = Instant.now().epochSecond + (60 * 30) // 30 minutes + val finalToken = + if (token.isNullOrEmpty()) { + generateToken() + } else { + token + } + + val finalExpire = + if (expire == null || expire == 0L) { + defaultExpire + } else { + expire + } + + val signature = getAuthenticationSignature(finalToken, finalExpire, privateKey) + + return mapOf("token" to finalToken, "expire" to finalExpire, "signature" to signature) + } + + // Private helper methods + + private fun getAuthenticationSignature( + token: String, + expire: Long, + privateKey: String, + ): String { + val signatureString = "$token$expire" + val mac = Mac.getInstance("HmacSHA1") + val secretKey = SecretKeySpec(privateKey.toByteArray(), "HmacSHA1") + mac.init(secretKey) + val hash = mac.doFinal(signatureString.toByteArray()) + + return hash.joinToString("") { "%02x".format(it) } + } + + private fun generateToken(): String { + val random = SecureRandom() + val bytes = ByteArray(16) + random.nextBytes(bytes) + return bytes.joinToString("") { "%02x".format(it) } + } +} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/lib/HelperService.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/lib/HelperService.kt new file mode 100644 index 00000000..57cfb063 --- /dev/null +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/lib/HelperService.kt @@ -0,0 +1,26 @@ +package io.imagekit.lib + +import io.imagekit.models.SrcOptions +import io.imagekit.models.Transformation + +/** + * Helper service interface for ImageKit SDK operations like URL building, transformation string + * generation, and authentication parameter generation. + * + * You should not instantiate this service directly, and instead use it via the client: + * ```java + * ImageKitClient client = ImageKitOkHttpClient.builder() + * .privateKey("private_key_xxx") + * .build(); + * + * String url = client.helper().buildUrl(srcOptions); + * ``` + */ +interface HelperService { + + fun buildUrl(options: SrcOptions): String + + fun buildTransformationString(transformations: List?): String + + fun getAuthenticationParameters(token: String? = null, expire: Long? = null): Map +} diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/beta/v2/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/beta/v2/files/FileUploadParams.kt index 40b37deb..17466d52 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/beta/v2/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/beta/v2/files/FileUploadParams.kt @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonSerialize import io.imagekit.core.BaseSerializer @@ -21,6 +22,7 @@ import io.imagekit.core.checkRequired import io.imagekit.core.getOrThrow import io.imagekit.core.http.Headers import io.imagekit.core.http.QueryParams +import io.imagekit.core.jsonMapper import io.imagekit.core.toImmutable import io.imagekit.errors.ImageKitInvalidDataException import io.imagekit.models.ExtensionItem @@ -1082,9 +1084,9 @@ private constructor( "token" to _token(), "checks" to _checks(), "customCoordinates" to _customCoordinates(), - "customMetadata" to _customMetadata(), + "customMetadata" to _toJsonString(_customMetadata()), "description" to _description(), - "extensions" to _extensions(), + "extensions" to _toJsonString(_extensions()), "folder" to _folder(), "isPrivateFile" to _isPrivateFile(), "isPublished" to _isPublished(), @@ -1092,14 +1094,44 @@ private constructor( "overwriteCustomMetadata" to _overwriteCustomMetadata(), "overwriteFile" to _overwriteFile(), "overwriteTags" to _overwriteTags(), - "responseFields" to _responseFields(), - "tags" to _tags(), - "transformation" to _transformation(), + "responseFields" to _toCommaSeparated(_responseFields()), + "tags" to _toCommaSeparated(_tags()), + "transformation" to _toJsonString(_transformation()), "useUniqueFileName" to _useUniqueFileName(), "webhookUrl" to _webhookUrl(), ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) .toImmutable() + private fun _toJsonString(field: MultipartField<*>): MultipartField { + if (field.value.isMissing() || field.value.isNull()) { + @Suppress("UNCHECKED_CAST") + return field as MultipartField + } + val jsonString = jsonMapper().writeValueAsString(field.value) + return MultipartField.of(jsonString) + } + + private fun _toCommaSeparated(field: MultipartField<*>): MultipartField { + if (field.value.isMissing() || field.value.isNull()) { + @Suppress("UNCHECKED_CAST") + return field as MultipartField + } + val mapper = jsonMapper() + val node = mapper.valueToTree(field.value) + if (!node.isArray) { + @Suppress("UNCHECKED_CAST") + return field as MultipartField + } + val csv = + node + .elements() + .asSequence() + .filter { !it.isNull && !it.isMissingNode } + .map { it.asText() } + .joinToString(",") + return MultipartField.of(csv) + } + override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUploadParams.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUploadParams.kt index 6d2b66ab..be2fc322 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUploadParams.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/models/files/FileUploadParams.kt @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonSerialize import io.imagekit.core.BaseSerializer @@ -21,6 +22,7 @@ import io.imagekit.core.checkRequired import io.imagekit.core.getOrThrow import io.imagekit.core.http.Headers import io.imagekit.core.http.QueryParams +import io.imagekit.core.jsonMapper import io.imagekit.core.toImmutable import io.imagekit.errors.ImageKitInvalidDataException import io.imagekit.models.ExtensionItem @@ -1201,10 +1203,10 @@ private constructor( "token" to _token(), "checks" to _checks(), "customCoordinates" to _customCoordinates(), - "customMetadata" to _customMetadata(), + "customMetadata" to _toJsonString(_customMetadata()), "description" to _description(), "expire" to _expire(), - "extensions" to _extensions(), + "extensions" to _toJsonString(_extensions()), "folder" to _folder(), "isPrivateFile" to _isPrivateFile(), "isPublished" to _isPublished(), @@ -1213,15 +1215,45 @@ private constructor( "overwriteFile" to _overwriteFile(), "overwriteTags" to _overwriteTags(), "publicKey" to _publicKey(), - "responseFields" to _responseFields(), + "responseFields" to _toCommaSeparated(_responseFields()), "signature" to _signature(), - "tags" to _tags(), - "transformation" to _transformation(), + "tags" to _toCommaSeparated(_tags()), + "transformation" to _toJsonString(_transformation()), "useUniqueFileName" to _useUniqueFileName(), "webhookUrl" to _webhookUrl(), ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) .toImmutable() + private fun _toJsonString(field: MultipartField<*>): MultipartField { + if (field.value.isMissing() || field.value.isNull()) { + @Suppress("UNCHECKED_CAST") + return field as MultipartField + } + val jsonString = jsonMapper().writeValueAsString(field.value) + return MultipartField.of(jsonString) + } + + private fun _toCommaSeparated(field: MultipartField<*>): MultipartField { + if (field.value.isMissing() || field.value.isNull()) { + @Suppress("UNCHECKED_CAST") + return field as MultipartField + } + val mapper = jsonMapper() + val node = mapper.valueToTree(field.value) + if (!node.isArray) { + @Suppress("UNCHECKED_CAST") + return field as MultipartField + } + val csv = + node + .elements() + .asSequence() + .filter { !it.isNull && !it.isMissingNode } + .map { it.asText() } + .joinToString(",") + return MultipartField.of(csv) + } + override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams diff --git a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/WebhookServiceImpl.kt b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/WebhookServiceImpl.kt index c5152a7c..26c56f4f 100644 --- a/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/WebhookServiceImpl.kt +++ b/image-kit-java-core/src/main/kotlin/io/imagekit/services/blocking/WebhookServiceImpl.kt @@ -12,6 +12,7 @@ import io.imagekit.errors.ImageKitInvalidDataException import io.imagekit.errors.ImageKitWebhookException import io.imagekit.models.webhooks.UnsafeUnwrapWebhookEvent import io.imagekit.models.webhooks.UnwrapWebhookEvent +import java.util.Base64 import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -55,7 +56,8 @@ class WebhookServiceImpl internal constructor(private val clientOptions: ClientO val headersMap = headers.names().associateWith { name -> headers.values(name) }.toMap() - val webhook = Webhook(webhookSecret) + val encodedKey = Base64.getEncoder().encodeToString(webhookSecret.toByteArray()) + val webhook = Webhook(encodedKey) webhook.verify(unwrapParams.body(), headersMap) } catch (e: WebhookVerificationException) { throw ImageKitWebhookException("Could not verify webhook event signature", e) diff --git a/image-kit-java-example/build.gradle.kts b/image-kit-java-example/build.gradle.kts index f9f4b81b..139fe9f0 100644 --- a/image-kit-java-example/build.gradle.kts +++ b/image-kit-java-example/build.gradle.kts @@ -19,7 +19,7 @@ tasks.withType().configureEach { application { // Use `./gradlew :image-kit-java-example:run` to run `Main` // Use `./gradlew :image-kit-java-example:run -Pexample=Something` to run `SomethingExample` - mainClass = "com.imagekit.api.example.${ + mainClass = "io.imagekit.example.${ if (project.hasProperty("example")) "${project.property("example")}Example" else diff --git a/image-kit-java-example/src/main/java/io/imagekit/example/Main.java b/image-kit-java-example/src/main/java/io/imagekit/example/Main.java new file mode 100644 index 00000000..f9881a57 --- /dev/null +++ b/image-kit-java-example/src/main/java/io/imagekit/example/Main.java @@ -0,0 +1,117 @@ +package io.imagekit.example; + +import io.imagekit.client.ImageKitClient; +import io.imagekit.client.okhttp.ImageKitOkHttpClient; +import io.imagekit.models.ExtensionItem; +import io.imagekit.models.ExtensionItem.AiTasks.Task.YesNo; +import io.imagekit.models.ExtensionItem.AiTasks.Task.YesNo.OnNo; +import io.imagekit.models.ExtensionItem.AiTasks.Task.YesNo.OnYes; +import io.imagekit.models.files.FileUploadParams; +import io.imagekit.models.files.FileUploadResponse; +import java.io.IOException; +import java.io.InputStream; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +public final class Main { + public static void main(String[] args) throws IOException, URISyntaxException { + // Initialize the client using the IMAGEKIT_PRIVATE_KEY environment variable + ImageKitClient client = ImageKitOkHttpClient.builder().fromEnv().build(); + + // Resolve the sample image bundled in src/main/resources/test.png + Path filePath; + if (args.length > 0) { + filePath = Paths.get(args[0]); + } else { + filePath = Paths.get(Main.class.getResource("/test.png").toURI()); + } + System.out.println("Using file: " + filePath); + System.out.println(); + + // --- Example 1: Upload using Path --- + System.out.println("=== Upload using Path ==="); + FileUploadParams pathParams = FileUploadParams.builder() + .fileName("path-upload.jpg") + .file(filePath) + .folder("/java-sdk-testing") + .build(); + FileUploadResponse pathResponse = client.files().upload(pathParams); + System.out.println("Uploaded: " + pathResponse.name()); + System.out.println("URL: " + pathResponse.url()); + System.out.println("File ID: " + pathResponse.fileId()); + System.out.println(); + + // --- Example 2: Upload using InputStream --- + System.out.println("=== Upload using InputStream ==="); + InputStream imageStream = Main.class.getResourceAsStream("/test.png"); + FileUploadParams streamParams = FileUploadParams.builder() + .fileName("stream-upload.jpg") + .file(imageStream) + .folder("/java-sdk-testing") + .build(); + FileUploadResponse streamResponse = client.files().upload(streamParams); + System.out.println("Uploaded: " + streamResponse.name()); + System.out.println("URL: " + streamResponse.url()); + System.out.println("File ID: " + streamResponse.fileId()); + System.out.println(); + + // --- Example 3: Upload using byte[] --- + System.out.println("=== Upload using byte[] ==="); + byte[] fileBytes = Files.readAllBytes(filePath); + FileUploadParams bytesParams = FileUploadParams.builder() + .fileName("bytes-upload.jpg") + .file(fileBytes) + .folder("/java-sdk-testing") + .build(); + FileUploadResponse bytesResponse = client.files().upload(bytesParams); + System.out.println("Uploaded: " + bytesResponse.name()); + System.out.println("URL: " + bytesResponse.url()); + System.out.println("File ID: " + bytesResponse.fileId()); + System.out.println(); + + // --- Example 4: Upload with tags and folder --- + System.out.println("=== Upload with tags and folder ==="); + FileUploadParams taggedParams = FileUploadParams.builder() + .fileName("tagged-upload.jpg") + .file(filePath) + .folder("/java-sdk-testing") + .addTag("example") + .addTag("java-sdk") + .useUniqueFileName(false) + .build(); + FileUploadResponse taggedResponse = client.files().upload(taggedParams); + System.out.println("Uploaded: " + taggedResponse.name()); + System.out.println("URL: " + taggedResponse.url()); + System.out.println("File ID: " + taggedResponse.fileId()); + System.out.println("Tags: " + taggedResponse.tags()); + + System.out.println(); + + // --- Example 5: Upload with AI tasks extension --- + System.out.println("=== Upload with AI tasks extension ==="); + FileUploadParams aiParams = FileUploadParams.builder() + .fileName("ai-task-upload.png") + .file(filePath) + .folder("/java-sdk-testing") + .addExtension(ExtensionItem.AiTasks.builder() + .addTask(YesNo.builder() + .instruction("Does this image contain a person?") + .onYes(OnYes.builder().addAddTag("has-person").build()) + .onNo(OnNo.builder().addAddTag("no-person").build()) + .build()) + .addSelectTagsTask("What objects are visible in this image?") + .build()) + .addTag("ai-processed") + .build(); + FileUploadResponse aiResponse = client.files().upload(aiParams); + System.out.println("Uploaded: " + aiResponse.name()); + System.out.println("URL: " + aiResponse.url()); + System.out.println("File ID: " + aiResponse.fileId()); + System.out.println("Extensions: " + aiResponse.extensionStatus()); + + System.out.println(); + System.out.println("All uploads completed successfully!"); + } +} diff --git a/image-kit-java-lib/build.gradle.kts b/image-kit-java-lib/build.gradle.kts new file mode 100644 index 00000000..dc97c82e --- /dev/null +++ b/image-kit-java-lib/build.gradle.kts @@ -0,0 +1,13 @@ +plugins { + id("image-kit.kotlin") +} + +dependencies { + api(project(":image-kit-java-core")) + + testImplementation(kotlin("test")) + testImplementation(project(":image-kit-java-client-okhttp")) + testImplementation("org.assertj:assertj-core:3.27.7") + testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") + testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3") +} diff --git a/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperAdvancedTransformationsTest.kt b/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperAdvancedTransformationsTest.kt new file mode 100644 index 00000000..20c035ff --- /dev/null +++ b/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperAdvancedTransformationsTest.kt @@ -0,0 +1,516 @@ +package io.imagekit.lib + +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.models.SrcOptions +import io.imagekit.models.StreamingResolution +import io.imagekit.models.Transformation +import io.imagekit.models.TransformationPosition +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class HelperAdvancedTransformationsTest { + + private val privateKey = "My Private API Key" + private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() + + // AI Transformation Tests + @Test + fun `should generate the correct URL for AI background removal when set to true`() { + val transformation = + listOf( + Transformation.builder() + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-bgremove") + } + + @Test + fun `should generate the correct URL for external AI background removal when set to true`() { + val transformation = + listOf( + Transformation.builder() + .aiRemoveBackgroundExternal(Transformation.AiRemoveBackgroundExternal.TRUE) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-removedotbg") + } + + @Test + fun `should generate the correct URL when AI drop shadow transformation is set to true`() { + val transformation = listOf(Transformation.builder().aiDropShadowTrue().build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-dropshadow") + } + + @Test + fun `should generate the correct URL when gradient transformation is set to true`() { + val transformation = listOf(Transformation.builder().gradientTrue().build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-gradient") + } + + @Test + fun `should not apply AI background removal when value is not true`() { + val transformation = listOf(Transformation.builder().build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg") + } + + @Test + fun `should not apply external AI background removal when value is not true`() { + val transformation = listOf(Transformation.builder().build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg") + } + + @Test + fun `should handle AI transformations with parameters`() { + val transformation = + listOf(Transformation.builder().aiDropShadow("custom-shadow-params").build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-dropshadow-custom-shadow-params" + ) + } + + @Test + fun `should handle gradient with parameters`() { + val transformation = + listOf(Transformation.builder().gradient("ld-top_from-green_to-00FF0010_sp-1").build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-gradient-ld-top_from-green_to-00FF0010_sp-1" + ) + } + + @Test + fun `should combine AI transformations with regular transformations`() { + val transformation = + listOf( + Transformation.builder() + .width(300.0) + .height(200.0) + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=w-300,h-200,e-bgremove" + ) + } + + @Test + fun `should handle multiple AI transformations`() { + val transformation = + listOf( + Transformation.builder() + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .aiDropShadowTrue() + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=e-bgremove,e-dropshadow" + ) + } + + // Parameter-specific tests + @Test + fun `should generate the correct URL for width transformation when provided with a number value`() { + val transformation = listOf(Transformation.builder().width(400.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=w-400") + } + + @Test + fun `should generate the correct URL for height transformation when provided with a string value`() { + val transformation = listOf(Transformation.builder().height("300").build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=h-300") + } + + @Test + fun `should generate the correct URL for aspectRatio transformation when provided with colon format`() { + val transformation = listOf(Transformation.builder().aspectRatio("4:3").build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=ar-4:3") + } + + @Test + fun `should generate the correct URL for quality transformation when provided with a number value`() { + val transformation = listOf(Transformation.builder().quality(80.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=q-80") + } + + @Test + fun `should skip transformation parameters that are undefined or empty`() { + val transformation = listOf(Transformation.builder().width(300.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=w-300") + } + + @Test + fun `should handle boolean transformation values`() { + val transformation = listOf(Transformation.builder().trimTrue().build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=t-true") + } + + @Test + fun `should handle transformation parameter with empty string value`() { + val transformation = listOf(Transformation.builder().defaultImage("").build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg") + } + + @Test + fun `should handle complex transformation combinations`() { + val transformation = + listOf( + Transformation.builder() + .width(300.0) + .height(200.0) + .quality(85.0) + .border("5_FF0000") + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=w-300,h-200,q-85,b-5_FF0000" + ) + } + + @Test + fun `should generate the correct URL for radius transformation with string value for per corner radius`() { + val transformation = listOf(Transformation.builder().radius("10_10_max_10").build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path1.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path1.jpg?tr=r-10_10_max_10") + } + + @Test + fun `should generate the correct URL with many transformations, including video and AI transforms`() { + val transformation = + listOf( + Transformation.builder() + .height(300.0) + .width(400.0) + .aspectRatio("4-3") + .quality(40.0) + .crop(Transformation.Crop.FORCE) + .cropMode(Transformation.CropMode.EXTRACT) + .focus("left") + .format(Transformation.Format.JPEG) + .radius(50.0) + .background("A94D34") + .border("5-A94D34") + .rotation(90.0) + .blur(10.0) + .named("some_name") + .progressive(true) + .lossless(true) + .trim(5.0) + .metadata(true) + .colorProfile(true) + .defaultImage("/folder/file.jpg/") + .dpr(3.0) + .x(10.0) + .y(20.0) + .xCenter(30.0) + .yCenter(40.0) + .flip(Transformation.Flip.H) + .opacity(0.8) + .zoom(2.0) + .videoCodec(Transformation.VideoCodec.H264) + .audioCodec(Transformation.AudioCodec.AAC) + .startOffset(5.0) + .endOffset(15.0) + .duration(10.0) + .streamingResolutions( + listOf(StreamingResolution._1440, StreamingResolution._1080) + ) + .grayscale(Transformation.Grayscale.TRUE) + .aiUpscale(Transformation.AiUpscale.TRUE) + .aiRetouch(Transformation.AiRetouch.TRUE) + .aiVariation(Transformation.AiVariation.TRUE) + .aiDropShadowTrue() + .aiChangeBackground("prompt-car") + .aiEdit("prompt-make it vintage") + .aiRemoveBackground(Transformation.AiRemoveBackground.TRUE) + .contrastStretch(Transformation.ContrastStretch.TRUE) + .shadow("bl-15_st-40_x-10_y-N5") + .sharpen(10.0) + .unsharpMask("2-2-0.8-0.024") + .gradient("from-red_to-white") + .colorReplace("FF0000_100_0000FF") + .distort("a-45") + .original(true) + .page("2_4") + .raw("h-200,w-300,l-image,i-logo.png,l-end") + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path.jpg") + .transformation(transformation as List) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300,q-40,ar-4-3,c-force,cm-extract,fo-left,f-jpeg,r-50,bg-A94D34,b-5-A94D34,cr-FF0000_100_0000FF,di-folder@@file.jpg,dpr-3,x-10,y-20,xc-30,yc-40,o-0.8,z-2,rt-90,bl-10,n-some_name,pr-true,lo-true,fl-h,t-5,md-true,cp-true,vc-h264,ac-aac,so-5,eo-15,du-10,sr-1440_1080,e-grayscale,e-upscale,e-retouch,e-genvar,e-bgremove,e-contrast,e-dropshadow,e-changebg-prompt-car,e-edit-prompt-make it vintage,e-shadow-bl-15_st-40_x-10_y-N5,e-sharpen-10,e-usm-2-2-0.8-0.024,e-gradient-from-red_to-white,e-distort-a-45,orig-true,pg-2_4,h-200,w-300,l-image,i-logo.png,l-end" + ) + } +} diff --git a/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperAuthenticationTest.kt b/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperAuthenticationTest.kt new file mode 100644 index 00000000..b8b361a4 --- /dev/null +++ b/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperAuthenticationTest.kt @@ -0,0 +1,101 @@ +package io.imagekit.lib + +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import kotlin.test.assertFailsWith +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class HelperAuthenticationTest { + + private val privateKey = "private_key_test" + private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() + + @Test + fun `should return correct authentication parameters with provided token and expire`() { + val token = "your_token" + val expire = 1582269249L + + val params = client.helper().getAuthenticationParameters(token, expire) + + // Expected exact match with Node.js/Go SDK output + val expectedSignature = "e71bcd6031016b060d349d212e23e85c791decdd" + + assertThat(params["token"]).isEqualTo(token) + assertThat(params["expire"]).isEqualTo(expire) + assertThat(params["signature"]).isEqualTo(expectedSignature) + } + + @Test + fun `should return authentication parameters with required properties when no params provided`() { + val params = client.helper().getAuthenticationParameters(null, null) + + // Check that all required properties exist + assertThat(params).containsKeys("token", "expire", "signature") + + // Token should be a 32-character hex string (16 bytes as hex) + val token = params["token"] as String + assertThat(token).matches("^[0-9a-f]{32}$") + + // Expire should be a number greater than current time + val expire = params["expire"] as Long + val currentTime = System.currentTimeMillis() / 1000 + assertThat(expire).isGreaterThan(currentTime) + + // Signature should be a hex string (40 characters for HMAC-SHA1) + val signature = params["signature"] as String + assertThat(signature).matches("^[a-f0-9]{40}$") + } + + @Test + fun `should handle edge case with expire time 0`() { + val token = "test-token" + val expire = 0L + + val params = client.helper().getAuthenticationParameters(token, expire) + + assertThat(params["token"]).isEqualTo(token) + + // When expire is 0 (falsy), it should use default expire time (30 minutes from now) + val expireResult = params["expire"] as Long + val expectedExpire = System.currentTimeMillis() / 1000 + 60 * 30 + + // Allow a 10 second tolerance for test execution time + assertThat(expireResult).isBetween(expectedExpire - 10, expectedExpire + 10) + + // Signature should be a hex string (40 characters for HMAC-SHA1) + val signature = params["signature"] as String + assertThat(signature).matches("^[a-f0-9]{40}$") + } + + @Test + fun `should handle empty string token`() { + val token = "" // Empty string is falsy + val expire = 1582269249L + + val params = client.helper().getAuthenticationParameters(token, expire) + + // Since empty string is falsy, it should generate a hex token + val tokenResult = params["token"] as String + assertThat(tokenResult).isNotEmpty() + assertThat(tokenResult).matches("^[0-9a-f]{32}$") + + assertThat(params["expire"]).isEqualTo(expire) + + // Signature should be a hex string (40 characters for HMAC-SHA1) + val signature = params["signature"] as String + assertThat(signature).matches("^[a-f0-9]{40}$") + } + + @Test + fun `should return error when private key is not provided`() { + val emptyKeyClient = ImageKitOkHttpClient.builder().privateKey("").build() + + val exception = + assertFailsWith { + emptyKeyClient.helper().getAuthenticationParameters("test", 123L) + } + + assertThat(exception.message) + .isEqualTo("private API key is required for authentication parameters generation") + } +} diff --git a/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperBuildUrlTest.kt b/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperBuildUrlTest.kt new file mode 100644 index 00000000..ced3c2a7 --- /dev/null +++ b/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperBuildUrlTest.kt @@ -0,0 +1,433 @@ +package io.imagekit.lib + +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.core.JsonValue +import io.imagekit.models.SrcOptions +import io.imagekit.models.Transformation +import io.imagekit.models.TransformationPosition +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class HelperBuildUrlTest { + + private val privateKey = "My Private API Key" + private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() + + @Test + fun `should throw exception when src is not provided`() { + org.junit.jupiter.api.assertThrows { + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .build() + ) + } + } + + @Test + fun `should generate a valid URL when src is slash`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/") + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/") + } + + @Test + fun `should generate a valid URL when src is provided without transformation`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path.jpg") + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path.jpg") + } + + @Test + fun `should generate a valid URL when absolute URL is provided without transformation`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg") + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg") + } + + @Test + fun `should generate valid URL when undefined transformation parameters are provided with path`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .src("/test_path_alt.jpg") + .transformationPosition(TransformationPosition.QUERY) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg") + } + + @Test + fun `by default transformationPosition should be query`() { + val transformation = + listOf( + Transformation.builder().height(300.0).width(400.0).build(), + Transformation.builder().rotation(90.0).build(), + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .src("/test_path.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300:rt-90" + ) + } + + @Test + fun `should generate the URL without sdk version`() { + val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .src("/test_path.jpg") + .transformation(transformation) + .transformationPosition(TransformationPosition.PATH) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/tr:w-400,h-300/test_path.jpg") + } + + @Test + fun `should generate the correct URL with a valid src and transformation`() { + val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300") + } + + @Test + fun `should add transformation as query when src has absolute url even if transformationPosition is path`() { + val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("https://my.custom.domain.com/test_path.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url).isEqualTo("https://my.custom.domain.com/test_path.jpg?tr=w-400,h-300") + } + + @Test + fun `handle non-default url-endpoint case`() { + val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/imagekit_id/new-endpoint/") + .src("/test_path.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/imagekit_id/new-endpoint/test_path.jpg?tr=w-400,h-300" + ) + } + + @Test + fun `should generate the correct URL when the provided path contains multiple leading slashes`() { + val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("///test_path.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300") + } + + @Test + fun `should generate the correct URL when the urlEndpoint is overridden`() { + val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint_alt") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint_alt/test_path.jpg?tr=w-400,h-300") + } + + @Test + fun `should generate the correct URL with transformationPosition as query parameter when src is provided`() { + val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .src("/test_path.jpg") + .transformationPosition(TransformationPosition.QUERY) + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300") + } + + @Test + fun `should generate the correct URL with a valid src parameter and transformation`() { + val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg?tr=w-400,h-300") + } + + @Test + fun `should merge query parameters correctly in the generated URL`() { + val transformation = listOf(Transformation.builder().height(300.0).width(400.0).build()) + + val queryParams = + SrcOptions.QueryParameters.builder() + .putAdditionalProperty("t2", JsonValue.from("v2")) + .putAdditionalProperty("t3", JsonValue.from("v3")) + .build() + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg?t1=v1") + .queryParameters(queryParams) + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path_alt.jpg?t1=v1&t2=v2&t3=v3&tr=w-400,h-300" + ) + } + + @Test + fun `should generate the correct URL with chained transformations`() { + val transformation = + listOf( + Transformation.builder().height(300.0).width(400.0).build(), + Transformation.builder().rotation(90.0).build(), + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300:rt-90" + ) + } + + @Test + fun `should generate the correct URL with chained transformations including raw transformation`() { + val transformation = + listOf( + Transformation.builder().height(300.0).width(400.0).build(), + Transformation.builder().raw("rndm_trnsf-abcd").build(), + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300:rndm_trnsf-abcd" + ) + } + + @Test + fun `should generate the correct URL when border transformation is applied`() { + val transformation = + listOf(Transformation.builder().height(300.0).width(400.0).border("20_FF0000").build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/test_path.jpg?tr=w-400,h-300,b-20_FF0000" + ) + } + + @Test + fun `should generate the correct URL when transformation has empty key and value`() { + val transformation = listOf(Transformation.builder().raw("").build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/test_path.jpg") + } + + @Test + fun `should generate a valid URL when cname is used`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://custom.domain.com") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path.jpg") + .build() + ) + + assertThat(url).isEqualTo("https://custom.domain.com/test_path.jpg") + } + + @Test + fun `should generate a valid URL when cname is used with a url-pattern`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://custom.domain.com/url-pattern") + .transformationPosition(TransformationPosition.QUERY) + .src("/test_path.jpg") + .build() + ) + + assertThat(url).isEqualTo("https://custom.domain.com/url-pattern/test_path.jpg") + } +} diff --git a/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperOverlayTest.kt b/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperOverlayTest.kt new file mode 100644 index 00000000..f8be2b29 --- /dev/null +++ b/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperOverlayTest.kt @@ -0,0 +1,1564 @@ +package io.imagekit.lib + +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.core.JsonValue +import io.imagekit.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class HelperOverlayTest { + + private val privateKey = "My Private API Key" + private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() + + // ======================================== + // TestOverlayTransformations - 12 tests + // ======================================== + + @Test + fun `should ignore overlay when type property is missing`() { + val transformation = listOf(Transformation.builder().width(300.0).build()) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/test_url_endpoint/tr:w-300/base-image.jpg") + } + + @Test + fun `should ignore text overlay when text property is missing`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder().text("").type(JsonValue.from("text")).build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/base-image.jpg") + } + + @Test + fun `should ignore image overlay when input property is missing`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder().input("").type(JsonValue.from("image")).build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/base-image.jpg") + } + + @Test + fun `should ignore video overlay when input property is missing`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofVideo( + VideoOverlay.builder().input("").type(JsonValue.from("video")).build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/base-image.jpg") + } + + @Test + fun `should ignore subtitle overlay when input property is missing`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofSubtitle( + SubtitleOverlay.builder() + .input("") + .type(JsonValue.from("subtitle")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/base-image.jpg") + } + + @Test + fun `should ignore solid color overlay when color property is missing`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofSolidColor( + SolidColorOverlay.builder() + .color("") + .type(JsonValue.from("solidColor")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/test_url_endpoint/base-image.jpg") + } + + @Test + fun `should generate URL with text overlay using URL encoding`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("Minimal Text") + .type(JsonValue.from("text")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Minimal%20Text,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate URL with image overlay from input file`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("logo.png") + .type(JsonValue.from("image")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-logo.png,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate URL with video overlay from input file`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofVideo( + VideoOverlay.builder() + .input("play-pause-loop.mp4") + .type(JsonValue.from("video")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-video.mp4") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-video,i-play-pause-loop.mp4,l-end/base-video.mp4" + ) + } + + @Test + fun `should generate URL with subtitle overlay from input file`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofSubtitle( + SubtitleOverlay.builder() + .input("subtitle.srt") + .type(JsonValue.from("subtitle")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-video.mp4") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-subtitles,i-subtitle.srt,l-end/base-video.mp4" + ) + } + + @Test + fun `should generate URL with solid color overlay using background color`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofSolidColor( + SolidColorOverlay.builder() + .color("FF0000") + .type(JsonValue.from("solidColor")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-ik_canvas,bg-FF0000,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate URL with multiple complex overlays including nested transformations`() { + val transformation = + listOf( + // Text overlay with complex transformations + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("Every thing") + .type(JsonValue.from("text")) + .position( + OverlayPosition.builder() + .x("10") + .y("20") + .focus(OverlayPosition.Focus.CENTER) + .build() + ) + .timing( + OverlayTiming.builder() + .start(5.0) + .duration("10") + .end(15.0) + .build() + ) + .transformation( + listOf( + TextOverlayTransformation.builder() + .width("bw_mul_0.5") + .fontSize(20.0) + .fontFamily("Arial") + .fontColor("0000ff") + .innerAlignment( + TextOverlayTransformation.InnerAlignment.LEFT + ) + .padding(5.0) + .alpha(7.0) + .typography("b") + .background("red") + .radius(10.0) + .rotation("N45") + .flip(TextOverlayTransformation.Flip.H) + .lineHeight(20.0) + .build() + ) + ) + .build() + ) + ) + .build(), + // Image overlay with nested transformations including nested text overlay + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("logo.png") + .type(JsonValue.from("image")) + .position( + OverlayPosition.builder() + .x("10") + .y("20") + .focus(OverlayPosition.Focus.CENTER) + .build() + ) + .timing( + OverlayTiming.builder() + .start(5.0) + .duration("10") + .end(15.0) + .build() + ) + .transformation( + listOf( + Transformation.builder() + .width("bw_mul_0.5") + .height("bh_mul_0.5") + .rotation("N45") + .flip(Transformation.Flip.H) + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("Nested text overlay") + .type(JsonValue.from("text")) + .build() + ) + ) + .build() + ) + ) + .build() + ) + ) + .build(), + // Video overlay + Transformation.builder() + .overlay( + Overlay.ofVideo( + VideoOverlay.builder() + .input("play-pause-loop.mp4") + .type(JsonValue.from("video")) + .position( + OverlayPosition.builder() + .x("10") + .y("20") + .focus(OverlayPosition.Focus.CENTER) + .build() + ) + .timing( + OverlayTiming.builder() + .start(5.0) + .duration("10") + .end(15.0) + .build() + ) + .transformation( + listOf( + Transformation.builder() + .width("bw_mul_0.5") + .height("bh_mul_0.5") + .rotation("N45") + .flip(Transformation.Flip.H) + .build() + ) + ) + .build() + ) + ) + .build(), + // Subtitle overlay + Transformation.builder() + .overlay( + Overlay.ofSubtitle( + SubtitleOverlay.builder() + .input("subtitle.srt") + .type(JsonValue.from("subtitle")) + .position( + OverlayPosition.builder() + .x("10") + .y("20") + .focus(OverlayPosition.Focus.CENTER) + .build() + ) + .timing( + OverlayTiming.builder() + .start(5.0) + .duration("10") + .end(15.0) + .build() + ) + .transformation( + listOf( + SubtitleOverlayTransformation.builder() + .background("red") + .color("0000ff") + .fontFamily("Arial") + .fontOutline("2_A1CCDD50") + .fontShadow("A1CCDD_3") + .build() + ) + ) + .build() + ) + ) + .build(), + // Solid color overlay + Transformation.builder() + .overlay( + Overlay.ofSolidColor( + SolidColorOverlay.builder() + .color("FF0000") + .type(JsonValue.from("solidColor")) + .position( + OverlayPosition.builder() + .x("10") + .y("20") + .focus(OverlayPosition.Focus.CENTER) + .build() + ) + .timing( + OverlayTiming.builder() + .start(5.0) + .duration("10") + .end(15.0) + .build() + ) + .transformation( + listOf( + SolidColorOverlayTransformation.builder() + .width("bw_mul_0.5") + .height("bh_mul_0.5") + .alpha(0.5) + .background("red") + .gradientTrue() + .radiusMax() + .build() + ) + ) + .build() + ) + ) + .build(), + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Every%20thing,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,w-bw_mul_0.5,fs-20,ff-Arial,co-0000ff,ia-left,pa-5,al-7,tg-b,bg-red,r-10,rt-N45,fl-h,lh-20,l-end:l-image,i-logo.png,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,w-bw_mul_0.5,h-bh_mul_0.5,rt-N45,fl-h,l-text,i-Nested%20text%20overlay,l-end,l-end:l-video,i-play-pause-loop.mp4,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,w-bw_mul_0.5,h-bh_mul_0.5,rt-N45,fl-h,l-end:l-subtitles,i-subtitle.srt,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,bg-red,co-0000ff,ff-Arial,fol-2_A1CCDD50,fsh-A1CCDD_3,l-end:l-image,i-ik_canvas,bg-FF0000,lx-10,ly-20,lfo-center,lso-5,leo-15,ldu-10,w-bw_mul_0.5,h-bh_mul_0.5,al-0.5,bg-red,e-gradient,r-max,l-end/base-image.jpg" + ) + } + + // ======================================== + // TestOverlayEncoding - 19 tests + // ======================================== + + @Test + fun `should use plain encoding for simple image paths with slashes converted to @@`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("/customer_logo/nykaa.png") + .type(JsonValue.from("image")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/medium_cafe_B1iTdD0C.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-image,i-customer_logo@@nykaa.png,l-end/medium_cafe_B1iTdD0C.jpg" + ) + } + + @Test + fun `should use base64 encoding for image paths containing special characters`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("/customer_logo/Ñykaa.png") + .type(JsonValue.from("image")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/medium_cafe_B1iTdD0C.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-image,ie-Y3VzdG9tZXJfbG9nby%2FDkXlrYWEucG5n,l-end/medium_cafe_B1iTdD0C.jpg" + ) + } + + @Test + fun `should use plain encoding for simple text overlays`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder().text("Manu").type(JsonValue.from("text")).build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/medium_cafe_B1iTdD0C.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-text,i-Manu,l-end/medium_cafe_B1iTdD0C.jpg" + ) + } + + @Test + fun `should convert slashes to @@ in fontFamily paths for custom fonts`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("Manu") + .type(JsonValue.from("text")) + .transformation( + listOf( + TextOverlayTransformation.builder() + .fontFamily("nested-path/Poppins-Regular_Q15GrYWmL.ttf") + .build() + ) + ) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/medium_cafe_B1iTdD0C.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-text,i-Manu,ff-nested-path@@Poppins-Regular_Q15GrYWmL.ttf,l-end/medium_cafe_B1iTdD0C.jpg" + ) + } + + @Test + fun `should use URL encoding for text overlays with spaces and safe characters`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("alnum123-._ ") + .type(JsonValue.from("text")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/medium_cafe_B1iTdD0C.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-text,i-alnum123-._%20,l-end/medium_cafe_B1iTdD0C.jpg" + ) + } + + @Test + fun `should use base64 encoding for text overlays with special unicode characters`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("Let's use ©, ®, ™, etc") + .type(JsonValue.from("text")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/medium_cafe_B1iTdD0C.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-text,ie-TGV0J3MgdXNlIMKpLCDCriwg4oSiLCBldGM%3D,l-end/medium_cafe_B1iTdD0C.jpg" + ) + } + + @Test + fun `should use plain encoding when explicitly specified for text overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("HelloWorld") + .type(JsonValue.from("text")) + .encoding(TextOverlay.Encoding.PLAIN) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/sample.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/demo/tr:l-text,i-HelloWorld,l-end/sample.jpg") + } + + @Test + fun `should use base64 encoding when explicitly specified for text overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("HelloWorld") + .type(JsonValue.from("text")) + .encoding(TextOverlay.Encoding.BASE64) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/sample.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-text,ie-SGVsbG9Xb3JsZA%3D%3D,l-end/sample.jpg" + ) + } + + @Test + fun `should use plain encoding when explicitly specified for image overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("/customer/logo.png") + .type(JsonValue.from("image")) + .encoding(ImageOverlay.Encoding.PLAIN) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/sample.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-image,i-customer@@logo.png,l-end/sample.jpg" + ) + } + + @Test + fun `should use base64 encoding when explicitly specified for image overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("/customer/logo.png") + .type(JsonValue.from("image")) + .encoding(ImageOverlay.Encoding.BASE64) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/sample.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-image,ie-Y3VzdG9tZXIvbG9nby5wbmc%3D,l-end/sample.jpg" + ) + } + + @Test + fun `should use base64 encoding when explicitly specified for video overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofVideo( + VideoOverlay.builder() + .input("/path/to/video.mp4") + .type(JsonValue.from("video")) + .encoding(VideoOverlay.Encoding.BASE64) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/sample.mp4") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-video,ie-cGF0aC90by92aWRlby5tcDQ%3D,l-end/sample.mp4" + ) + } + + @Test + fun `should use plain encoding when explicitly specified for subtitle overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofSubtitle( + SubtitleOverlay.builder() + .input("/sub.srt") + .type(JsonValue.from("subtitle")) + .encoding(SubtitleOverlay.Encoding.PLAIN) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/sample.mp4") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/demo/tr:l-subtitles,i-sub.srt,l-end/sample.mp4") + } + + @Test + fun `should use base64 encoding when explicitly specified for subtitle overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofSubtitle( + SubtitleOverlay.builder() + .input("sub.srt") + .type(JsonValue.from("subtitle")) + .encoding(SubtitleOverlay.Encoding.BASE64) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.PATH) + .src("/sample.mp4") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-subtitles,ie-c3ViLnNydA%3D%3D,l-end/sample.mp4" + ) + } + + @Test + fun `should properly encode overlay text when transformations are in query parameters`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("Minimal Text") + .type(JsonValue.from("text")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo") + .transformationPosition(TransformationPosition.QUERY) + .src("/sample.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo("https://ik.imagekit.io/demo/sample.jpg?tr=l-text,i-Minimal%20Text,l-end") + } + + @Test + fun `should generate URL with image overlay using layerMode multiply`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("logo.png") + .type(JsonValue.from("image")) + .layerMode(BaseOverlay.LayerMode.MULTIPLY) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-logo.png,lm-multiply,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate URL with image overlay using layerMode cutter`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("mask.png") + .type(JsonValue.from("image")) + .layerMode(BaseOverlay.LayerMode.CUTTER) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-mask.png,lm-cutter,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate URL with image overlay using layerMode cutout`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("shape.png") + .type(JsonValue.from("image")) + .layerMode(BaseOverlay.LayerMode.CUTOUT) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-shape.png,lm-cutout,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate URL with image overlay using layerMode displace`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("displacement.png") + .type(JsonValue.from("image")) + .layerMode(BaseOverlay.LayerMode.DISPLACE) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-displacement.png,lm-displace,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate URL with image overlay using xCenter yCenter and anchorPoint`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("logo.png") + .type(JsonValue.from("image")) + .position( + OverlayPosition.builder() + .xCenter(50.0) + .yCenter("bh_mul_0.5") + .anchorPoint(OverlayPosition.AnchorPoint.TOP_LEFT) + .build() + ) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-logo.png,lxc-50,lyc-bh_mul_0.5,lap-top_left,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate layerMode on text overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("Hello") + .type(JsonValue.from("text")) + .layerMode(BaseOverlay.LayerMode.MULTIPLY) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Hello,lm-multiply,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate layerMode on video overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofVideo( + VideoOverlay.builder() + .input("video.mp4") + .type(JsonValue.from("video")) + .layerMode(BaseOverlay.LayerMode.MULTIPLY) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-video,i-video.mp4,lm-multiply,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate layerMode on subtitle overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofSubtitle( + SubtitleOverlay.builder() + .input("subtitle.srt") + .type(JsonValue.from("subtitle")) + .layerMode(BaseOverlay.LayerMode.CUTTER) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-subtitles,i-subtitle.srt,lm-cutter,l-end/base-image.jpg" + ) + } + + @Test + fun `should generate layerMode on solid color overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofSolidColor( + SolidColorOverlay.builder() + .color("FF0000") + .type(JsonValue.from("solidColor")) + .layerMode(BaseOverlay.LayerMode.CUTOUT) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-ik_canvas,bg-FF0000,lm-cutout,l-end/base-image.jpg" + ) + } + + @Test + fun `should strip leading and trailing slashes from image overlay input path`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("/path/to/logo.png/") + .type(JsonValue.from("image")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-path@@to@@logo.png,l-end/base-image.jpg" + ) + } + + @Test + fun `should strip leading and trailing slashes from fontFamily in text overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("Hello") + .type(JsonValue.from("text")) + .transformation( + listOf( + TextOverlayTransformation.builder() + .fontFamily("/sdk-testing-files/Poppins-Regular.ttf/") + .build() + ) + ) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Hello,ff-sdk-testing-files@@Poppins-Regular.ttf,l-end/base-image.jpg" + ) + } + + @Test + fun `should use processInputPath for subtitle overlay with slashes`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofSubtitle( + SubtitleOverlay.builder() + .input("/path/to/subtitle.srt") + .type(JsonValue.from("subtitle")) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-subtitles,i-path@@to@@subtitle.srt,l-end/base-image.jpg" + ) + } + + @Test + fun `should order anchorPoint before focus in overlay position`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofImage( + ImageOverlay.builder() + .input("logo.png") + .type(JsonValue.from("image")) + .position( + OverlayPosition.builder() + .focus(OverlayPosition.Focus.CENTER) + .anchorPoint(OverlayPosition.AnchorPoint.BOTTOM_RIGHT) + .build() + ) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-image,i-logo.png,lap-bottom_right,lfo-center,l-end/base-image.jpg" + ) + } + + @Test + fun `should properly path-escape special characters in plain text overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("Hello World") + .type(JsonValue.from("text")) + .encoding(TextOverlay.Encoding.PLAIN) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/test_url_endpoint") + .transformationPosition(TransformationPosition.PATH) + .src("/base-image.jpg") + .transformation(transformation) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/test_url_endpoint/tr:l-text,i-Hello%20World,l-end/base-image.jpg" + ) + } +} diff --git a/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperSigningTest.kt b/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperSigningTest.kt new file mode 100644 index 00000000..8c24cf6e --- /dev/null +++ b/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperSigningTest.kt @@ -0,0 +1,279 @@ +package io.imagekit.lib + +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.core.JsonValue +import io.imagekit.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class HelperSigningTest { + + private val privateKey = "dummy-key" + private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() + + @Test + fun `should generate a signed URL when signed is true without expiresIn`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo/") + .src("sdk-testing-files/future-search.png") + .signed(true) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/sdk-testing-files/future-search.png?ik-s=32dbbbfc5f945c0403c71b54c38e76896ef2d6b0" + ) + } + + @Test + fun `should generate a signed URL when signed is true with expiresIn`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo/") + .src("sdk-testing-files/future-search.png") + .signed(true) + .expiresIn(3600.0) + .build() + ) + + // Expect ik-t exist in the URL. We don't assert signature because it will keep changing. + assertThat(url).contains("ik-t") + } + + @Test + fun `should generate a signed URL when expiresIn is above 0 and even if signed is false`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo/") + .src("sdk-testing-files/future-search.png") + .signed(false) + .expiresIn(3600.0) + .build() + ) + + // Expect ik-t exist in the URL. We don't assert signature because it will keep changing. + assertThat(url).contains("ik-t") + } + + @Test + fun `should generate signed URL with special characters in filename`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo/") + .src("sdk-testing-files/हिन्दी.png") + .signed(true) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/sdk-testing-files/%E0%A4%B9%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%A6%E0%A5%80.png?ik-s=3fff2f31da1f45e007adcdbe95f88c8c330e743c" + ) + } + + @Test + fun `should generate signed URL with text overlay containing special characters`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("हिन्दी") + .type(JsonValue.from("text")) + .transformation( + listOf( + TextOverlayTransformation.builder() + .fontColor("red") + .fontSize("32") + .fontFamily( + "sdk-testing-files/Poppins-Regular_Q15GrYWmL.ttf" + ) + .build() + ) + ) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo/") + .src("sdk-testing-files/हिन्दी.png") + .transformation(transformation) + .signed(true) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/sdk-testing-files/%E0%A4%B9%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%A6%E0%A5%80.png?tr=l-text,ie-4KS54KS%2F4KSo4KWN4KSm4KWA,fs-32,ff-sdk-testing-files@@Poppins-Regular_Q15GrYWmL.ttf,co-red,l-end&ik-s=705e41579d368caa6530a4375355325277fcfe5c" + ) + } + + @Test + fun `should generate signed URL with text overlay and special characters using path transformation position`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder() + .text("हिन्दी") + .type(JsonValue.from("text")) + .transformation( + listOf( + TextOverlayTransformation.builder() + .fontColor("red") + .fontSize("32") + .fontFamily( + "sdk-testing-files/Poppins-Regular_Q15GrYWmL.ttf" + ) + .build() + ) + ) + .build() + ) + ) + .build() + ) + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo/") + .src("sdk-testing-files/हिन्दी.png") + .transformationPosition(TransformationPosition.PATH) + .transformation(transformation) + .signed(true) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:l-text,ie-4KS54KS%2F4KSo4KWN4KSm4KWA,fs-32,ff-sdk-testing-files@@Poppins-Regular_Q15GrYWmL.ttf,co-red,l-end/sdk-testing-files/%E0%A4%B9%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%A6%E0%A5%80.png?ik-s=20958f6126fd67c90653f55a49f2b7bb938d9d1c" + ) + } + + @Test + fun `should generate signed URL with query parameters`() { + val queryParams = + SrcOptions.QueryParameters.builder() + .putAdditionalProperty("version", JsonValue.from("1.0")) + .putAdditionalProperty("cache", JsonValue.from("false")) + .build() + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo/") + .src("sdk-testing-files/future-search.png") + .queryParameters(queryParams) + .signed(true) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/sdk-testing-files/future-search.png?cache=false&version=1.0&ik-s=03767bb6f0898c04e42f65714af65d937c696d66" + ) + } + + @Test + fun `should generate signed URL with transformations and query parameters`() { + val transformation = listOf(Transformation.builder().width(300.0).height(200.0).build()) + + val queryParams = + SrcOptions.QueryParameters.builder() + .putAdditionalProperty("version", JsonValue.from("2.0")) + .build() + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo/") + .src("sdk-testing-files/future-search.png") + .transformation(transformation) + .queryParameters(queryParams) + .signed(true) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/sdk-testing-files/future-search.png?version=2.0&tr=w-300,h-200&ik-s=601d97a7834b7554f4dabf0d3fc3a219ceeb6b31" + ) + } + + @Test + fun `should not sign URL when signed is false`() { + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo/") + .src("sdk-testing-files/future-search.png") + .signed(false) + .build() + ) + + assertThat(url).isEqualTo("https://ik.imagekit.io/demo/sdk-testing-files/future-search.png") + assertThat(url).doesNotContain("ik-s=") + assertThat(url).doesNotContain("ik-t=") + } + + @Test + fun `should generate signed URL with transformations in path position and query parameters`() { + val transformation = listOf(Transformation.builder().width(300.0).height(200.0).build()) + + val queryParams = + SrcOptions.QueryParameters.builder() + .putAdditionalProperty("version", JsonValue.from("2.0")) + .build() + + val url = + client + .helper() + .buildUrl( + SrcOptions.builder() + .urlEndpoint("https://ik.imagekit.io/demo/") + .src("sdk-testing-files/future-search.png") + .transformation(transformation) + .transformationPosition(TransformationPosition.PATH) + .queryParameters(queryParams) + .signed(true) + .build() + ) + + assertThat(url) + .isEqualTo( + "https://ik.imagekit.io/demo/tr:w-300,h-200/sdk-testing-files/future-search.png?version=2.0&ik-s=dd1ee8f83d019bc59fd57a5fc4674a11eb8a3496" + ) + } +} diff --git a/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperTransformationTest.kt b/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperTransformationTest.kt new file mode 100644 index 00000000..504f0acd --- /dev/null +++ b/image-kit-java-lib/src/test/kotlin/io/imagekit/lib/HelperTransformationTest.kt @@ -0,0 +1,108 @@ +package io.imagekit.lib + +import io.imagekit.client.okhttp.ImageKitOkHttpClient +import io.imagekit.core.JsonValue +import io.imagekit.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class HelperTransformationTest { + + private val privateKey = "test-key" + private val client = ImageKitOkHttpClient.builder().privateKey(privateKey).build() + + @Test + fun `should return empty string for empty transformation array`() { + val result = client.helper().buildTransformationString(null) + assertThat(result).isEmpty() + + val result2 = client.helper().buildTransformationString(emptyList()) + assertThat(result2).isEmpty() + } + + @Test + fun `should generate transformation string for width only`() { + val transformation = listOf(Transformation.builder().width(300.0).build()) + + val result = client.helper().buildTransformationString(transformation) + assertThat(result).isEqualTo("w-300") + } + + @Test + fun `should generate transformation string for multiple parameters`() { + val transformation = listOf(Transformation.builder().width(300.0).height(200.0).build()) + + val result = client.helper().buildTransformationString(transformation) + assertThat(result).isEqualTo("w-300,h-200") + } + + @Test + fun `should generate transformation string for chained transformations`() { + val transformation = + listOf( + Transformation.builder().width(300.0).build(), + Transformation.builder().height(200.0).build(), + ) + + val result = client.helper().buildTransformationString(transformation) + assertThat(result).isEqualTo("w-300:h-200") + } + + @Test + fun `should handle empty transformation object`() { + val transformation = listOf(Transformation.builder().build()) + + val result = client.helper().buildTransformationString(transformation) + assertThat(result).isEmpty() + } + + @Test + fun `should handle transformation with overlay`() { + val transformation = + listOf( + Transformation.builder() + .overlay( + Overlay.ofText( + TextOverlay.builder().text("Hello").type(JsonValue.from("text")).build() + ) + ) + .build() + ) + + val result = client.helper().buildTransformationString(transformation) + assertThat(result).isEqualTo("l-text,i-Hello,l-end") + } + + @Test + fun `should handle raw transformation parameter`() { + val transformation = listOf(Transformation.builder().raw("custom-transform-123").build()) + + val result = client.helper().buildTransformationString(transformation) + assertThat(result).isEqualTo("custom-transform-123") + } + + @Test + fun `should handle mixed parameters with raw`() { + val transformation = + listOf(Transformation.builder().width(300.0).raw("custom-param-123").build()) + + val result = client.helper().buildTransformationString(transformation) + assertThat(result).isEqualTo("w-300,custom-param-123") + } + + @Test + fun `should handle quality parameter`() { + val transformation = listOf(Transformation.builder().quality(80.0).build()) + + val result = client.helper().buildTransformationString(transformation) + assertThat(result).isEqualTo("q-80") + } + + @Test + fun `should handle aspect ratio parameter`() { + val transformation = listOf(Transformation.builder().aspectRatio("4:3").build()) + + val result = client.helper().buildTransformationString(transformation) + assertThat(result).isEqualTo("ar-4:3") + } +} From 99c2be8b3dbd535c9c46cadd1a4e49dd07aff115 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 21 Apr 2026 08:08:12 +0000 Subject: [PATCH 142/142] release: 3.0.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 146 ++++++++++++++++++++++++++++++++++ README.md | 10 +-- build.gradle.kts | 2 +- 4 files changed, 153 insertions(+), 7 deletions(-) create mode 100644 CHANGELOG.md diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 1332969b..4191c889 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.0.1" + ".": "3.0.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..e128eed8 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,146 @@ +# Changelog + +## 3.0.0 (2026-04-21) + +Full Changelog: [v0.0.1...v3.0.0](https://github.com/imagekit-developer/imagekit-java/compare/v0.0.1...v3.0.0) + +### Features + +* add helper utilities and lib module with tests ([92fb768](https://github.com/imagekit-developer/imagekit-java/commit/92fb768157a6630a3770f5ad99596b6c3ed184f3)) +* **api:** add BaseWebhookEvent ([4ab06b0](https://github.com/imagekit-developer/imagekit-java/commit/4ab06b01316b114e526159de348b9d52fdd57567)) +* **api:** add customMetadata property to folder schema ([0413e64](https://github.com/imagekit-developer/imagekit-java/commit/0413e64aa737500a42764fb2613f94cf582cb2b8)) +* **api:** add GetImageAttributesOptions and ResponsiveImageAttributes schemas; update resource references in main.yaml; remove dummy endpoint ([70d2551](https://github.com/imagekit-developer/imagekit-java/commit/70d2551ec48038eb1deb0459a0b4dc2b6506c837)) +* **api:** add path policy related non-breaking changes ([6e2eac3](https://github.com/imagekit-developer/imagekit-java/commit/6e2eac363b8f707a58009f6812350f45d4856da2)) +* **api:** Add saved extensions API and enhance transformation options ([1bca614](https://github.com/imagekit-developer/imagekit-java/commit/1bca6144095239ef2892cd989f89136e4af1a953)) +* **api:** add selectedFieldsSchema in upload and list API response ([34289ae](https://github.com/imagekit-developer/imagekit-java/commit/34289ae2c42a258e56ad87133c9eff209b248163)) +* **api:** add webhook signature verification ([ff73a7a](https://github.com/imagekit-developer/imagekit-java/commit/ff73a7abfc250eb2558c073684d328a48b9df29e)) +* **api:** dam related webhook events ([8352cba](https://github.com/imagekit-developer/imagekit-java/commit/8352cbaa2184947c142175d475c2cc06c9e9f57f)) +* **api:** dpr type update ([6a528ff](https://github.com/imagekit-developer/imagekit-java/commit/6a528ff9db3c2123c79997bd48b503be731cca65)) +* **api:** extract UpdateFileDetailsRequest to model ([c75a767](https://github.com/imagekit-developer/imagekit-java/commit/c75a767180e2d032fc0ab1d2fe74e41795bd957d)) +* **api:** fix spec indentation ([26eba98](https://github.com/imagekit-developer/imagekit-java/commit/26eba981e412103f0293fafd8888e3d075deec0d)) +* **api:** fix upload API request params ([7abe230](https://github.com/imagekit-developer/imagekit-java/commit/7abe23093ccf53fcf4b0829cc7d4b792cf8c4406)) +* **api:** indentation fix ([0caeef8](https://github.com/imagekit-developer/imagekit-java/commit/0caeef861804c31031de369a40e0ac755ff26396)) +* **api:** Introduce lxc, lyc, lap parameters in overlays. ([e3b34fb](https://github.com/imagekit-developer/imagekit-java/commit/e3b34fb41f580c5bd557c99cc7c26af6d5583b20)) +* **api:** manual updates ([afb90e6](https://github.com/imagekit-developer/imagekit-java/commit/afb90e655bbe37ba25e2cb3f02577414483c3488)) +* **api:** manual updates ([b586d51](https://github.com/imagekit-developer/imagekit-java/commit/b586d513361b7ed938fb9a4c29a44a9e47e1cca2)) +* **api:** manual updates ([75ff27c](https://github.com/imagekit-developer/imagekit-java/commit/75ff27c3c8a2c90d7bf5d14e75b1e3de05733781)) +* **api:** manual updates ([646022d](https://github.com/imagekit-developer/imagekit-java/commit/646022de6d3820653968a99867c60b3df998f9d3)) +* **api:** manual updates ([f5206be](https://github.com/imagekit-developer/imagekit-java/commit/f5206beb4c997de9c2ff47a70d36795557fae7c5)) +* **api:** manual updates ([e474ef2](https://github.com/imagekit-developer/imagekit-java/commit/e474ef2004c784def6eba33158337511c073d178)) +* **api:** manual updates ([09a68d6](https://github.com/imagekit-developer/imagekit-java/commit/09a68d6fb594866ed049c11cba27d797ef553908)) +* **api:** manual updates ([e01a75a](https://github.com/imagekit-developer/imagekit-java/commit/e01a75a9df1f6f49754095c9b61159236b5658b5)) +* **api:** manual updates ([2d41187](https://github.com/imagekit-developer/imagekit-java/commit/2d41187dea1edca9d0f941690244b4c50874d9cc)) +* **api:** manual updates ([2ef93ad](https://github.com/imagekit-developer/imagekit-java/commit/2ef93ad3db97af5fef99687a4438c76e2220b384)) +* **api:** manual updates ([c6e61f8](https://github.com/imagekit-developer/imagekit-java/commit/c6e61f8ca6b3a9485ab15d0221842ef76b6cae32)) +* **api:** manual updates ([1c76234](https://github.com/imagekit-developer/imagekit-java/commit/1c762344ee41aa7099febdca72f368943ee8428b)) +* **api:** manual updates ([cd2b64e](https://github.com/imagekit-developer/imagekit-java/commit/cd2b64ef8d6324264a71321bb11a7849260d98fc)) +* **api:** manual updates ([1341b62](https://github.com/imagekit-developer/imagekit-java/commit/1341b6282b4a32013cb60f11ee0ec9aaef8acac4)) +* **api:** manual updates ([83ce070](https://github.com/imagekit-developer/imagekit-java/commit/83ce0707ff45a9daa97e12daa9ad050dcbab53f9)) +* **api:** manual updates ([d57885b](https://github.com/imagekit-developer/imagekit-java/commit/d57885b731de1837a7edcd3f6eab303db855475a)) +* **api:** manual updates ([74027ef](https://github.com/imagekit-developer/imagekit-java/commit/74027efe9095a5e650addddf064d6e3773413894)) +* **api:** manual updates ([76c5b5e](https://github.com/imagekit-developer/imagekit-java/commit/76c5b5e1fbc0ac3415d5e35febce642dd47cd0ab)) +* **api:** manual updates ([b462410](https://github.com/imagekit-developer/imagekit-java/commit/b46241040326016adf4ad220178ccf3221323f90)) +* **api:** manual updates ([cbbd424](https://github.com/imagekit-developer/imagekit-java/commit/cbbd424da5ebd388dd6e3d8af7e38b7633ed0604)) +* **api:** merge with main to bring back missing parameters ([fb7f512](https://github.com/imagekit-developer/imagekit-java/commit/fb7f512d8932eb43656a89fdce6ccc8f59b3ebb6)) +* **api:** remove Stainless attribution from readme ([065125f](https://github.com/imagekit-developer/imagekit-java/commit/065125f9c510b69c6ec41ddb811f9cebcdd37c1b)) +* **api:** revert dpr breaking change ([997ab63](https://github.com/imagekit-developer/imagekit-java/commit/997ab6353eeb46a8b97cad9f9688a11b9d700fc3)) +* **api:** update api docs link ([0b273a9](https://github.com/imagekit-developer/imagekit-java/commit/0b273a981219fbf9083fcb2559d81f3e472ca9e1)) +* **api:** Update env var name ([1b520d1](https://github.com/imagekit-developer/imagekit-java/commit/1b520d13de7c42693d3acc4a364fdec55eb341ce)) +* **api:** update webhook event names and remove DAM prefix ([0cbbc63](https://github.com/imagekit-developer/imagekit-java/commit/0cbbc63ad53db27fae27e4b0f470b3242d8bdaeb)) +* **client:** add `HttpRequest#url()` method ([fa1b9b7](https://github.com/imagekit-developer/imagekit-java/commit/fa1b9b7159b51b86831440ba956082f3d2619c37)) +* **client:** add connection pooling option ([c7a7295](https://github.com/imagekit-developer/imagekit-java/commit/c7a72959cf29e796657dea8d7590f4b96d5fb542)) +* **client:** add more convenience service method overloads ([f462bff](https://github.com/imagekit-developer/imagekit-java/commit/f462bfff56865ae16dadb5a404c696d3d5ff1ff9)) +* **client:** allow configuring dispatcher executor service ([a7be5ce](https://github.com/imagekit-developer/imagekit-java/commit/a7be5cec994774da7ba3c6129e63d13686d065c9)) +* **client:** send `X-Stainless-Kotlin-Version` header ([2224a12](https://github.com/imagekit-developer/imagekit-java/commit/2224a1264e0fd8772808873c4978b7930f0acb4b)) + + +### Bug Fixes + +* add ai-tasks property to response schemas with enum values ([b0bfdf6](https://github.com/imagekit-developer/imagekit-java/commit/b0bfdf6c142e23170be4051a985d7206c74f5958)) +* add one more method in multipartbuilder to build from json ([9dc2f89](https://github.com/imagekit-developer/imagekit-java/commit/9dc2f897ec7b9a1998d283359472b882cfb9ee68)) +* **api:** add missing embeddedMetadata and video properties to FileDetails ([ceb43dd](https://github.com/imagekit-developer/imagekit-java/commit/ceb43ddf46ac19fc90fb28e716d6f5490630bc30)) +* **api:** extract shared schemas to prevent Go webhook union breaking changes ([f5fdf8f](https://github.com/imagekit-developer/imagekit-java/commit/f5fdf8fd7cc5a0f70fef28fd8b1fc23ebda05c8c)) +* **api:** rename DamFile events to File for consistency ([f18e22b](https://github.com/imagekit-developer/imagekit-java/commit/f18e22be52528874c7adb453bc360b0e511001c3)) +* **ci:** use java-version 21 for publish step ([181fbe5](https://github.com/imagekit-developer/imagekit-java/commit/181fbe5360fbc5820cb9df684d242896ec146049)) +* **client:** allow updating header/query affecting fields in `toBuilder()` ([91e327e](https://github.com/imagekit-developer/imagekit-java/commit/91e327e82db972ae6e5a50f9fb14e52ead007621)) +* **client:** cancel okhttp call when future cancelled ([d4b8c84](https://github.com/imagekit-developer/imagekit-java/commit/d4b8c848066b410e35a95c555bc238f8e5228b83)) +* **client:** deserialization of empty objects ([8ccff9b](https://github.com/imagekit-developer/imagekit-java/commit/8ccff9bc6b39dbd306eb5325a830bbadc0053585)) +* **client:** disallow coercion from float to int ([a6dc3e2](https://github.com/imagekit-developer/imagekit-java/commit/a6dc3e26f63b2b3c2d5a8185c329f5140f84076d)) +* **client:** fully respect max retries ([87d2ad3](https://github.com/imagekit-developer/imagekit-java/commit/87d2ad3db0d0730371b5f814dd5a14c2c0ab0ee0)) +* **client:** incorrect `getPackageVersion` impl ([078eab8](https://github.com/imagekit-developer/imagekit-java/commit/078eab8cf903109aaead3f0e90a2ee0b14c9c9ce)) +* **client:** incorrect `Retry-After` parsing ([15b04f7](https://github.com/imagekit-developer/imagekit-java/commit/15b04f7bfb7677c941dda5db230b273115551600)) +* **client:** multi-value header serialization ([ccb0ffb](https://github.com/imagekit-developer/imagekit-java/commit/ccb0ffb22b5a6ce7789110fa3d83e42a279fcb22)) +* **client:** preserve time zone in lenient date-time parsing ([3c1ce69](https://github.com/imagekit-developer/imagekit-java/commit/3c1ce699ab55a45358fc78b2437ca1971c6918ea)) +* **client:** send retry count header for max retries 0 ([87d2ad3](https://github.com/imagekit-developer/imagekit-java/commit/87d2ad3db0d0730371b5f814dd5a14c2c0ab0ee0)) +* date time deserialization leniency ([7f3e0d6](https://github.com/imagekit-developer/imagekit-java/commit/7f3e0d6f67a4e7b598ef2763d81faff8e00b9959)) +* deserialization order ([a7d3f1e](https://github.com/imagekit-developer/imagekit-java/commit/a7d3f1e74b0cd489ed67458efe462996b2706e50)) +* **docs:** fix mcp installation instructions for remote servers ([2a727d4](https://github.com/imagekit-developer/imagekit-java/commit/2a727d401b4dff5441414b565ba081822a737926)) +* fix request delays for retrying to be more respectful of high requested delays ([eb80ae5](https://github.com/imagekit-developer/imagekit-java/commit/eb80ae59186571723c253602ebf87e31bc52b988)) +* vocab field is required ([ea9bfc3](https://github.com/imagekit-developer/imagekit-java/commit/ea9bfc30c34316aca3f1536e366b920e7e9c8bb7)) + + +### Chores + +* **ci:** skip lint on metadata-only changes ([f43fd3a](https://github.com/imagekit-developer/imagekit-java/commit/f43fd3ae0642cc33b727775e62eb58a6fb3f0123)) +* **ci:** skip uploading artifacts on stainless-internal branches ([19e8f78](https://github.com/imagekit-developer/imagekit-java/commit/19e8f78f7ee6e65ad0943dcccc7e17af31cf074c)) +* **ci:** upgrade `actions/github-script` ([940ebfc](https://github.com/imagekit-developer/imagekit-java/commit/940ebfcf3a2153e86b2292f2ca6077874d9fb170)) +* **ci:** upgrade `actions/setup-java` ([e60fd58](https://github.com/imagekit-developer/imagekit-java/commit/e60fd58b5a303ea126c427f046fc30c0c63bfa79)) +* configure new SDK language ([4c0fdb3](https://github.com/imagekit-developer/imagekit-java/commit/4c0fdb3884cf537b504527a651790546eb645210)) +* drop apache dependency ([48e02f7](https://github.com/imagekit-developer/imagekit-java/commit/48e02f702dea5f4c0553740e48bd670c63477f51)) +* improve formatter performance ([daaa7f3](https://github.com/imagekit-developer/imagekit-java/commit/daaa7f33c20310093952bd4396d305bef42c81b8)) +* **internal:** allow passing args to `./scripts/test` ([1d14a59](https://github.com/imagekit-developer/imagekit-java/commit/1d14a5930b16ce47c2f85e2e5e8b2507dec9a61f)) +* **internal:** bump palantir-java-format ([87b5f18](https://github.com/imagekit-developer/imagekit-java/commit/87b5f1817dda7429a6b4a154f71d4196198df0c0)) +* **internal:** change some comment formatting ([86ca3d7](https://github.com/imagekit-developer/imagekit-java/commit/86ca3d7d9676b6a07f1930195a8dd5dacf12714a)) +* **internal:** clean up maven repo artifact script and add html documentation to repo root ([8e34e08](https://github.com/imagekit-developer/imagekit-java/commit/8e34e08c8aa939a06b933c0c29c0df46b175b8c2)) +* **internal:** codegen related update ([e970882](https://github.com/imagekit-developer/imagekit-java/commit/e970882efd7aa0f4770edce814c9b837e8ae247c)) +* **internal:** codegen related update ([da02221](https://github.com/imagekit-developer/imagekit-java/commit/da0222197fca08583b2096effa2bd18a9f9f615b)) +* **internal:** codegen related update ([814caf9](https://github.com/imagekit-developer/imagekit-java/commit/814caf9f6454c4b32af76f3a5b68d6af54d631b3)) +* **internal:** codegen related update ([cd82f98](https://github.com/imagekit-developer/imagekit-java/commit/cd82f981b54a9131ed8195f62de0bb65bb436b6d)) +* **internal:** codegen related update ([da788af](https://github.com/imagekit-developer/imagekit-java/commit/da788af79c52a70075f39b26776b203cd958ceb0)) +* **internal:** codegen related update ([f25c3c4](https://github.com/imagekit-developer/imagekit-java/commit/f25c3c46f4104091a5e8e376c22727eb3aaa4611)) +* **internal:** correct cache invalidation for `SKIP_MOCK_TESTS` ([1f6f1dc](https://github.com/imagekit-developer/imagekit-java/commit/1f6f1dcfb312298c1cbb524512d0a8aa7e05560e)) +* **internal:** depend on packages directly in example ([87d2ad3](https://github.com/imagekit-developer/imagekit-java/commit/87d2ad3db0d0730371b5f814dd5a14c2c0ab0ee0)) +* **internal:** expand imports ([f10c1b0](https://github.com/imagekit-developer/imagekit-java/commit/f10c1b040943402094e0f75669b0eb61503d9875)) +* **internal:** improve examples ([998d126](https://github.com/imagekit-developer/imagekit-java/commit/998d126b14aebc0a454a15d9169049888395ec35)) +* **internal:** improve maven repo docs ([b92f5f0](https://github.com/imagekit-developer/imagekit-java/commit/b92f5f0ea9c1defd19ed0224471dc6cd2bed2e2e)) +* **internal:** make `OkHttp` constructor internal ([534feb3](https://github.com/imagekit-developer/imagekit-java/commit/534feb30f3c327e09d1e13423e447224e2da90d7)) +* **internal:** remove mock server code ([3f1d1c6](https://github.com/imagekit-developer/imagekit-java/commit/3f1d1c67caa0d9824d3c03bef1c8b58a5d58c76e)) +* **internal:** remove redundant deserializer symbols ([2d52469](https://github.com/imagekit-developer/imagekit-java/commit/2d52469a65c898504a76adb6ab4826aa3febbbdc)) +* **internal:** remove unnecessary base URL ([98d50fa](https://github.com/imagekit-developer/imagekit-java/commit/98d50fa72841ab2a4fe4baf62861f4c2e911a23b)) +* **internal:** support uploading Maven repo artifacts to stainless package server ([83de2bf](https://github.com/imagekit-developer/imagekit-java/commit/83de2bfb62facd417c3cd626c0f3a7ed7e989165)) +* **internal:** tweak CI branches ([3e76397](https://github.com/imagekit-developer/imagekit-java/commit/3e76397ba5582f39d56aeb243d2fa81564814604)) +* **internal:** update `actions/checkout` version ([7115c38](https://github.com/imagekit-developer/imagekit-java/commit/7115c3879f8983659e87b369a23600d4c2ae9646)) +* **internal:** update `TestServerExtension` comment ([89b8598](https://github.com/imagekit-developer/imagekit-java/commit/89b85982f5be8ac9de8b4ea05a6ca0490951f21b)) +* **internal:** update gitignore ([4c944e0](https://github.com/imagekit-developer/imagekit-java/commit/4c944e0804b949085602a5d724120ab40acba53d)) +* **internal:** update maven repo doc to include authentication ([7156f6f](https://github.com/imagekit-developer/imagekit-java/commit/7156f6fa1a10aa4d4cd1655d2a3612239fc25422)) +* **internal:** update multipart form array serialization ([11184c7](https://github.com/imagekit-developer/imagekit-java/commit/11184c77fbc86d278f2791bdbbfcaa1cb542eaae)) +* **internal:** update retry delay tests ([51a3135](https://github.com/imagekit-developer/imagekit-java/commit/51a3135751d0ff2bdc2c741e714061615d232b7b)) +* **internal:** upgrade AssertJ ([99a48d6](https://github.com/imagekit-developer/imagekit-java/commit/99a48d6896e90c14b96e182b85692a7f1b6aece7)) +* make `Properties` more resilient to `null` ([34b930a](https://github.com/imagekit-developer/imagekit-java/commit/34b930ad491dafb8e94442ef07864d47d1f54137)) +* remove custom code ([ec944a0](https://github.com/imagekit-developer/imagekit-java/commit/ec944a0fafc93f26bc277530738901258e787bb1)) +* sync repo ([05af7d5](https://github.com/imagekit-developer/imagekit-java/commit/05af7d57aab0174c720f1dd71e87d39f1197bfa1)) +* test on Jackson 2.14.0 to avoid encountering FasterXML/jackson-databind[#3240](https://github.com/imagekit-developer/imagekit-java/issues/3240) in tests ([7f3e0d6](https://github.com/imagekit-developer/imagekit-java/commit/7f3e0d6f67a4e7b598ef2763d81faff8e00b9959)) +* **tests:** bump steady to v0.19.4 ([3b0fc2e](https://github.com/imagekit-developer/imagekit-java/commit/3b0fc2efe92fcf1733f4bbdefe779cd2203e585a)) +* **tests:** update webhook tests ([2f221f7](https://github.com/imagekit-developer/imagekit-java/commit/2f221f7678f232232a18d3b533bbeb93a7758599)) +* update mock server docs ([6fb3f0c](https://github.com/imagekit-developer/imagekit-java/commit/6fb3f0cfd3a1f8bb17c9c632c56db7f5a7240948)) +* update placeholder string ([6b3d9f5](https://github.com/imagekit-developer/imagekit-java/commit/6b3d9f5c59f9e416ea67380045bf54ef9f48f135)) +* update SDK settings ([b39e9dc](https://github.com/imagekit-developer/imagekit-java/commit/b39e9dc8e9af7806353b5f9276f023fec45c5905)) +* update SDK settings ([00f7055](https://github.com/imagekit-developer/imagekit-java/commit/00f705596f585c9020a4620a9675e733f28b8b1b)) + + +### Documentation + +* correct typo in default value description for custom metadata field ([fc00907](https://github.com/imagekit-developer/imagekit-java/commit/fc00907646fa9bfb333ac303783d58956cc262c2)) +* improve examples ([f9a78b0](https://github.com/imagekit-developer/imagekit-java/commit/f9a78b0fd65f309da64d400d91665696ebfb67eb)) +* prominently feature MCP server setup in root SDK readmes ([41bf700](https://github.com/imagekit-developer/imagekit-java/commit/41bf7009b03948c41ffd933a80ee0ffea1a7a00b)) +* remove `$` for better copy-pasteabality ([2273b04](https://github.com/imagekit-developer/imagekit-java/commit/2273b04035285050a65b6703e523789905d71387)) + + +### Refactors + +* AITags to singular AITag schema with array items pattern ([e71dfe1](https://github.com/imagekit-developer/imagekit-java/commit/e71dfe138309b105b1eb38d5622e21f147446571)) + + +### Build System + +* updating CI ([a14b7cc](https://github.com/imagekit-developer/imagekit-java/commit/a14b7cc70204cd8af648e3c3ac7664f3916850b1)) diff --git a/README.md b/README.md index 1fa6d0ad..69642eee 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit/image-kit-java/0.0.1) -[![javadoc](https://javadoc.io/badge2/io.imagekit/image-kit-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1) +[![Maven Central](https://img.shields.io/maven-central/v/io.imagekit/image-kit-java)](https://central.sonatype.com/artifact/io.imagekit/image-kit-java/3.0.0) +[![javadoc](https://javadoc.io/badge2/io.imagekit/image-kit-java/3.0.0/javadoc.svg)](https://javadoc.io/doc/io.imagekit/image-kit-java/3.0.0) @@ -11,7 +11,7 @@ The ImageKit Java SDK is a comprehensive library designed to simplify the integr -The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit/image-kit-java/0.0.1). +The REST API documentation can be found on [imagekit.io](https://imagekit.io/docs/api-reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/io.imagekit/image-kit-java/3.0.0). @@ -46,7 +46,7 @@ The REST API documentation can be found on [imagekit.io](https://imagekit.io/doc ### Gradle ```kotlin -implementation("io.imagekit:image-kit-java:0.0.1") +implementation("io.imagekit:image-kit-java:3.0.0") ``` ### Maven @@ -55,7 +55,7 @@ implementation("io.imagekit:image-kit-java:0.0.1") io.imagekit image-kit-java - 0.0.1 + 3.0.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index bac92a82..411f291f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "io.imagekit" - version = "0.0.1" // x-release-please-version + version = "3.0.0" // x-release-please-version } subprojects {